From fcdd5c442bd82f9836096fc29d4830a2660a3ad9 Mon Sep 17 00:00:00 2001 From: bagyenda <> Date: Mon, 10 Sep 2007 12:04:49 +0000 Subject: [PATCH] minor bug fix re address fixup --- mbuni/mmlib/mms_queue.c | 4 ++-- mbuni/mmlib/mms_util.c | 24 ++++++++++++------------ mbuni/mmlib/mms_util.h | 2 +- mbuni/mmsbox/mmsbox.c | 6 +++--- mbuni/mmsc/mmsglobalsender.c | 2 +- mbuni/mmsc/mmsmobilesender.c | 2 +- mbuni/mmsc/mmssend.c | 4 ++-- 7 files changed, 22 insertions(+), 22 deletions(-) diff --git a/mbuni/mmlib/mms_queue.c b/mbuni/mmlib/mms_queue.c index 695d72f..749b8e2 100644 --- a/mbuni/mmlib/mms_queue.c +++ b/mbuni/mmlib/mms_queue.c @@ -263,7 +263,7 @@ static MmsEnvelope *mms_queue_readenvelope(char *qf, char *mms_queuedir, int sho if (mms_validate_address(e->from) != 0) { warning(0, "mms_queueread: Mal-formed address [%s] in file %s! " "Attempting fixup.", res, xqf); - _mms_fixup_address(e->from, NULL); + _mms_fixup_address(&e->from, NULL); } break; case 'R': @@ -272,7 +272,7 @@ static MmsEnvelope *mms_queue_readenvelope(char *qf, char *mms_queuedir, int sho if (mms_validate_address(t) != 0) { warning(0, "mms_queueread: Mal-formed address [%s] in file %s! " "Attempting fixup.", res, xqf); - _mms_fixup_address(t, NULL); + _mms_fixup_address(&t, NULL); } to = gw_malloc(sizeof *to); to->rcpt = t; diff --git a/mbuni/mmlib/mms_util.c b/mbuni/mmlib/mms_util.c index b6a7900..878f1e5 100644 --- a/mbuni/mmlib/mms_util.c +++ b/mbuni/mmlib/mms_util.c @@ -957,31 +957,31 @@ int isphonenum(Octstr *s) } /* Doesn't handle IP addresses very well */ -void _mms_fixup_address(Octstr *address, char *unified_prefix) +void _mms_fixup_address(Octstr **address, char *unified_prefix) { int i; Octstr *typ; - - if (!address) return; - i = octstr_search_char(address, '@', 0); + + if (!address || !*address) return; + i = octstr_search_char(*address, '@', 0); if (i>0) /* an email address. */ return; - i = octstr_search(address, octstr_imm("/TYPE="), 0); + i = octstr_search(*address, octstr_imm("/TYPE="), 0); if (i > 0) { - typ = octstr_copy(address, i, octstr_len(address)); - octstr_delete(address, i, octstr_len(address)); + typ = octstr_copy(*address, i, octstr_len(*address)); + octstr_delete(*address, i, octstr_len(*address)); } else typ = NULL; - if (isphonenum(address) || (typ && octstr_str_compare(typ, "/TYPE=PLMN") == 0)) { + if (isphonenum(*address) || (typ && octstr_str_compare(typ, "/TYPE=PLMN") == 0)) { if (unified_prefix) - normalize_number(unified_prefix, &address); - octstr_append(address, octstr_imm("/TYPE=PLMN")); + normalize_number(unified_prefix, address); + octstr_append(*address, octstr_imm("/TYPE=PLMN")); } else if (typ) - octstr_append(address, typ); + octstr_append(*address, typ); else - octstr_append(address, octstr_imm("@unknown")); + octstr_append(*address, octstr_imm("@unknown")); octstr_destroy(typ); } diff --git a/mbuni/mmlib/mms_util.h b/mbuni/mmlib/mms_util.h index 40680c1..0de6761 100644 --- a/mbuni/mmlib/mms_util.h +++ b/mbuni/mmlib/mms_util.h @@ -154,7 +154,7 @@ unsigned long _mshash(char *s); /* Tell us whether address is a phone number. */ int isphonenum(Octstr *s); /* Fixup an address: Normalize number (if prefix given), Add type, etc. */ -void _mms_fixup_address(Octstr *address, char *unified_prefix); +void _mms_fixup_address(Octstr **address, char *unified_prefix); /* Check that host is one of hosts in semi-colon separated list in host_list */ int is_allowed_host(Octstr *host, Octstr *host_list); diff --git a/mbuni/mmsbox/mmsbox.c b/mbuni/mmsbox/mmsbox.c index 718625c..f4150d1 100644 --- a/mbuni/mmsbox/mmsbox.c +++ b/mbuni/mmsbox/mmsbox.c @@ -863,7 +863,7 @@ static int make_and_queue_msg(Octstr *data, Octstr *ctype, List *reply_headers, for (j = 0; j < gwlist_len(hv); j++) { Octstr *v = gwlist_get(hv, j); /* Fix the address. */ - _mms_fixup_address(v, unified_prefix ? octstr_get_cstr(unified_prefix) : NULL); + _mms_fixup_address(&v, unified_prefix ? octstr_get_cstr(unified_prefix) : NULL); gwlist_append(xto, v); } octstr_destroy(v); @@ -919,7 +919,7 @@ static int make_and_queue_msg(Octstr *data, Octstr *ctype, List *reply_headers, xservice_code = octstr_duplicate(hsvc_code); if (from) - _mms_fixup_address(from, unified_prefix ? octstr_get_cstr(unified_prefix) : NULL); + _mms_fixup_address(&from, unified_prefix ? octstr_get_cstr(unified_prefix) : NULL); /* Now get the data. */ if (octstr_case_compare(ctype, octstr_imm("application/vnd.wap.mms-message")) == 0) @@ -1260,7 +1260,7 @@ static void sendmms_func(void *unused) if ((from = http_cgi_variable(cgivars, "from")) != NULL) { from = octstr_duplicate(from); - _mms_fixup_address(from, unified_prefix ? octstr_get_cstr(unified_prefix) : NULL); + _mms_fixup_address(&from, unified_prefix ? octstr_get_cstr(unified_prefix) : NULL); http_header_add(rh, "X-Mbuni-From", octstr_get_cstr(from)); octstr_destroy(from); } else if (!u->faked_sender) diff --git a/mbuni/mmsc/mmsglobalsender.c b/mbuni/mmsc/mmsglobalsender.c index 9ba2c2f..db21875 100644 --- a/mbuni/mmsc/mmsglobalsender.c +++ b/mbuni/mmsc/mmsglobalsender.c @@ -79,7 +79,7 @@ static int sendMsg(MmsEnvelope *e) MmsEnvelopeTo *to = gwlist_get(e->to, i); Octstr *s = octstr_duplicate(to->rcpt); - _mms_fixup_address(s, octstr_get_cstr(settings->unified_prefix)); + _mms_fixup_address(&s, octstr_get_cstr(settings->unified_prefix)); gwlist_append(l, s); } diff --git a/mbuni/mmsc/mmsmobilesender.c b/mbuni/mmsc/mmsmobilesender.c index dd7aa66..478c7e2 100644 --- a/mbuni/mmsc/mmsmobilesender.c +++ b/mbuni/mmsc/mmsmobilesender.c @@ -368,7 +368,7 @@ static int sendNotify(MmsEnvelope *e) /* To get here means we can send Ind. */ url = mms_makefetchurl(e->xqfname, e->token, MMS_LOC_MQUEUE, - to, + phonenum ? phonenum : to, settings); transid = mms_maketransid(e->xqfname, settings->host_alias); diff --git a/mbuni/mmsc/mmssend.c b/mbuni/mmsc/mmssend.c index 5df0fc9..180a2c8 100644 --- a/mbuni/mmsc/mmssend.c +++ b/mbuni/mmsc/mmssend.c @@ -109,7 +109,7 @@ int main(int argc, char *argv[]) Octstr *x; while ((x = gwlist_extract_first(to)) != NULL) { octstr_strip_blanks(x); - _mms_fixup_address(x, + _mms_fixup_address(&x, settings->unified_prefix ? octstr_get_cstr(settings->unified_prefix) : NULL); gwlist_append(l, x); } @@ -118,7 +118,7 @@ int main(int argc, char *argv[]) } /* fix from address. */ - _mms_fixup_address(from, + _mms_fixup_address(&from, settings->unified_prefix ? octstr_get_cstr(settings->unified_prefix) : NULL); #if 0