MM4 - fixup of addresses in headers
This commit is contained in:
parent
7a0d166d21
commit
825102fc0a
|
@ -43,6 +43,7 @@ static int find_own(int i, int argc, char *argv[]);
|
|||
|
||||
static void fixup_recipient(void);
|
||||
static void fixup_sender(void);
|
||||
static void fixup_addresses(List *headers);
|
||||
|
||||
static void send_mm4_res(int mtype, Octstr *to, Octstr *sender, Octstr *transid, char *status, Octstr *msgid);
|
||||
|
||||
|
@ -183,6 +184,8 @@ int main(int argc, char *argv[])
|
|||
if (msgid)
|
||||
http_header_add(headers, "Message-ID", octstr_get_cstr(msgid));
|
||||
|
||||
fixup_addresses(headers);
|
||||
|
||||
if (mm4_type) {
|
||||
unsigned char *x = NULL;
|
||||
int i;
|
||||
|
@ -526,6 +529,42 @@ static void fixup_sender(void)
|
|||
}
|
||||
}
|
||||
|
||||
static void fixup_address_type(List *headers, char *hdr)
|
||||
{
|
||||
List *l;
|
||||
int i, n;
|
||||
|
||||
l = http_header_find_all(headers, hdr);
|
||||
|
||||
http_header_remove_all(headers,hdr);
|
||||
for (i = 0, n = gwlist_len(l); i<n; i++) {
|
||||
Octstr *name, *value;
|
||||
int j, k;
|
||||
http_header_get(l, i, &name, &value);
|
||||
|
||||
if (!value || !name ||
|
||||
octstr_case_compare(name, octstr_imm(hdr)) != 0)
|
||||
goto loop;
|
||||
if ((j = octstr_search(value, octstr_imm("/TYPE="), 0))>0) {
|
||||
k = octstr_search_char(value, '@', 0);
|
||||
if (k > j) { /* we have @, after TYPE=PLMN remove it */
|
||||
octstr_delete(value, k, octstr_len(value));
|
||||
}
|
||||
}
|
||||
http_header_add(headers, octstr_get_cstr(name), octstr_get_cstr(value));
|
||||
loop:
|
||||
if (value) octstr_destroy(value);
|
||||
if (name) octstr_destroy(name);
|
||||
}
|
||||
http_destroy_headers(l);
|
||||
}
|
||||
|
||||
static void fixup_addresses(List *headers)
|
||||
{
|
||||
fixup_address_type(headers, "To");
|
||||
fixup_address_type(headers, "From");
|
||||
}
|
||||
|
||||
static void send_mm4_res(int mtype, Octstr *to, Octstr *sender, Octstr *transid, char *status, Octstr *msgid)
|
||||
{
|
||||
List *h = http_create_empty_headers();
|
||||
|
|
Loading…
Reference in New Issue