1
0
Fork 0

minor bug fix re address fixup

This commit is contained in:
bagyenda 2007-09-10 12:04:49 +00:00
parent 3059138928
commit fcdd5c442b
7 changed files with 22 additions and 22 deletions

View File

@ -263,7 +263,7 @@ static MmsEnvelope *mms_queue_readenvelope(char *qf, char *mms_queuedir, int sho
if (mms_validate_address(e->from) != 0) { if (mms_validate_address(e->from) != 0) {
warning(0, "mms_queueread: Mal-formed address [%s] in file %s! " warning(0, "mms_queueread: Mal-formed address [%s] in file %s! "
"Attempting fixup.", res, xqf); "Attempting fixup.", res, xqf);
_mms_fixup_address(e->from, NULL); _mms_fixup_address(&e->from, NULL);
} }
break; break;
case 'R': case 'R':
@ -272,7 +272,7 @@ static MmsEnvelope *mms_queue_readenvelope(char *qf, char *mms_queuedir, int sho
if (mms_validate_address(t) != 0) { if (mms_validate_address(t) != 0) {
warning(0, "mms_queueread: Mal-formed address [%s] in file %s! " warning(0, "mms_queueread: Mal-formed address [%s] in file %s! "
"Attempting fixup.", res, xqf); "Attempting fixup.", res, xqf);
_mms_fixup_address(t, NULL); _mms_fixup_address(&t, NULL);
} }
to = gw_malloc(sizeof *to); to = gw_malloc(sizeof *to);
to->rcpt = t; to->rcpt = t;

View File

@ -957,31 +957,31 @@ int isphonenum(Octstr *s)
} }
/* Doesn't handle IP addresses very well */ /* 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; int i;
Octstr *typ; Octstr *typ;
if (!address) return; if (!address || !*address) return;
i = octstr_search_char(address, '@', 0); i = octstr_search_char(*address, '@', 0);
if (i>0) /* an email address. */ if (i>0) /* an email address. */
return; return;
i = octstr_search(address, octstr_imm("/TYPE="), 0); i = octstr_search(*address, octstr_imm("/TYPE="), 0);
if (i > 0) { if (i > 0) {
typ = octstr_copy(address, i, octstr_len(address)); typ = octstr_copy(*address, i, octstr_len(*address));
octstr_delete(address, i, octstr_len(address)); octstr_delete(*address, i, octstr_len(*address));
} else } else
typ = NULL; 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) if (unified_prefix)
normalize_number(unified_prefix, &address); normalize_number(unified_prefix, address);
octstr_append(address, octstr_imm("/TYPE=PLMN")); octstr_append(*address, octstr_imm("/TYPE=PLMN"));
} else if (typ) } else if (typ)
octstr_append(address, typ); octstr_append(*address, typ);
else else
octstr_append(address, octstr_imm("@unknown")); octstr_append(*address, octstr_imm("@unknown"));
octstr_destroy(typ); octstr_destroy(typ);
} }

View File

@ -154,7 +154,7 @@ unsigned long _mshash(char *s);
/* Tell us whether address is a phone number. */ /* Tell us whether address is a phone number. */
int isphonenum(Octstr *s); int isphonenum(Octstr *s);
/* Fixup an address: Normalize number (if prefix given), Add type, etc. */ /* 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 */ /* Check that host is one of hosts in semi-colon separated list in host_list */
int is_allowed_host(Octstr *host, Octstr *host_list); int is_allowed_host(Octstr *host, Octstr *host_list);

View File

@ -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++) { for (j = 0; j < gwlist_len(hv); j++) {
Octstr *v = gwlist_get(hv, j); Octstr *v = gwlist_get(hv, j);
/* Fix the address. */ /* 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); gwlist_append(xto, v);
} }
octstr_destroy(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); xservice_code = octstr_duplicate(hsvc_code);
if (from) 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. */ /* Now get the data. */
if (octstr_case_compare(ctype, octstr_imm("application/vnd.wap.mms-message")) == 0) 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) { if ((from = http_cgi_variable(cgivars, "from")) != NULL) {
from = octstr_duplicate(from); 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)); http_header_add(rh, "X-Mbuni-From", octstr_get_cstr(from));
octstr_destroy(from); octstr_destroy(from);
} else if (!u->faked_sender) } else if (!u->faked_sender)

View File

@ -79,7 +79,7 @@ static int sendMsg(MmsEnvelope *e)
MmsEnvelopeTo *to = gwlist_get(e->to, i); MmsEnvelopeTo *to = gwlist_get(e->to, i);
Octstr *s = octstr_duplicate(to->rcpt); 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); gwlist_append(l, s);
} }

View File

@ -368,7 +368,7 @@ static int sendNotify(MmsEnvelope *e)
/* To get here means we can send Ind. */ /* To get here means we can send Ind. */
url = mms_makefetchurl(e->xqfname, e->token, MMS_LOC_MQUEUE, url = mms_makefetchurl(e->xqfname, e->token, MMS_LOC_MQUEUE,
to, phonenum ? phonenum : to,
settings); settings);
transid = mms_maketransid(e->xqfname, settings->host_alias); transid = mms_maketransid(e->xqfname, settings->host_alias);

View File

@ -109,7 +109,7 @@ int main(int argc, char *argv[])
Octstr *x; Octstr *x;
while ((x = gwlist_extract_first(to)) != NULL) { while ((x = gwlist_extract_first(to)) != NULL) {
octstr_strip_blanks(x); octstr_strip_blanks(x);
_mms_fixup_address(x, _mms_fixup_address(&x,
settings->unified_prefix ? octstr_get_cstr(settings->unified_prefix) : NULL); settings->unified_prefix ? octstr_get_cstr(settings->unified_prefix) : NULL);
gwlist_append(l, x); gwlist_append(l, x);
} }
@ -118,7 +118,7 @@ int main(int argc, char *argv[])
} }
/* fix from address. */ /* fix from address. */
_mms_fixup_address(from, _mms_fixup_address(&from,
settings->unified_prefix ? octstr_get_cstr(settings->unified_prefix) : NULL); settings->unified_prefix ? octstr_get_cstr(settings->unified_prefix) : NULL);
#if 0 #if 0