[commit] r9703 - freeswitch/trunk/src/mod/endpoints/mod_sofia
Author: anthm Date: Sun Sep 28 17:36:39 2008 New Revision: 9703 Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c Log: append -1 .. -N postfix after any X-headers as vars that have the same name Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c ============================================================================== --- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c (original) +++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c Sun Sep 28 17:36:39 2008 @@ -3836,10 +3836,22 @@ } } else if (!strncasecmp(un->un_name, "X-", 2) || !strncasecmp(un->un_name, "P-", 2)) { if (!switch_strlen_zero(un->un_value)) { - char *new_name; - if ((new_name = switch_mprintf("%s%s", SOFIA_SIP_HEADER_PREFIX, un->un_name))) { + char new_name[512] = ""; + int reps = 0; + for(;;) { + char postfix[25] = ""; + if (reps > 0) { + switch_snprintf(postfix, sizeof(postfix), "-%d", reps); + } + reps++; + switch_snprintf(new_name, sizeof(new_name), "%s%s%s", SOFIA_SIP_HEADER_PREFIX, un->un_name, postfix); + + if (switch_channel_get_variable(channel, new_name)) { + continue; + } + switch_channel_set_variable(channel, new_name, un->un_value); - free(new_name); + break; } } }
participants (1)
-
Freeswitch SVN