Benjamin,

Well it's really up to you... but if you do decide to post the diff or
a URL to the diff... other developers can eye the code and give you
feedback (if they feel like it, of course).

Good idea. :) Here's the current location of said diff file.

   http://66.255.55.23/interop.diff

If anyone knows of a better way to do the structure handling (ie. submit_sm vs. data_sm and their items, ie. data_coding) in a better way, it'd be much appreciated. I tried to do some dynamic casting with the same code for both cases (only consolidated into one instance of said code), just re-casting a void pointer to the individual structure with no success. Most of the code is identical (ie. handling the "+", checking the length, etc.). The big two-tier switch statement was the best I could figure out with the deadline I had to get it working in.

     An example of what I meant above is something like:

void* ptr;

...

switch (command_id)
{
case COMMAND_ID_SUBMIT_SM:
pdu = smpp_pdu_create(submit_sm, counter_increase(smpp->message_id_counter));
ptr = &pdu->u.submit_sm;
#undef DYN_CAST
#define DYN_CAST struct submit_sm*
break;


case COMMAND_ID_DATA_SM:
pdu = smpp_pdu_create(data_sm, counter_increase(smpp->message_id_counter));
ptr = &pdu->u.data_sm;
#undef DYN_CAST
#define DYN_CAST struct data_sm*
break;


...

((DYN_CAST)ptr)->source_addr = octstr_duplicate(msg->sms.sender);
((DYN_CAST)ptr)->destination_addr = octstr_duplicate(msg->sms.receiver);

I thought I was really smooth until I remembered that #define's are pre-processor and essentially just lump the code into the place of the token, thus the above only worked for data_sm as it's #define came last. <sigh> I'd rather not duplicate 2-300 lines of code just because of the structure's oddities. So like I said, if there are any tricks to handling this struct of structs, please let me know.


It's a free world. ;-) And yay for it!

Agreed. :P

Jon



Reply via email to