From c3feca09ff091b35517cad8e8ef232489762c0f4 Mon Sep 17 00:00:00 2001
From: bagyenda <>
Date: Thu, 12 Oct 2006 15:21:46 +0000
Subject: [PATCH] Mbuni updated to Kannel 1.4.1 -- initial stab
---
mbuni/Makefile.am | 2 +-
mbuni/configure.ac | 6 +-
mbuni/doc/userguide.shtml | 33 +-
mbuni/misc-patches/Makefile.am | 1 -
mbuni/misc-patches/mbuni-kannel-patch-full | 1018 --------------------
mbuni/mmlib/mms_cfg.c | 24 +-
mbuni/mmlib/mms_mm7soap.c | 145 +--
mbuni/mmlib/mms_mmbox.c | 58 +-
mbuni/mmlib/mms_msg.c | 327 ++++---
mbuni/mmlib/mms_queue.c | 88 +-
mbuni/mmlib/mms_uaprof.c | 425 ++++----
mbuni/mmlib/mms_util.c | 296 +++---
mbuni/mmlib/mms_util.h | 12 +-
mbuni/mmsbox/bearerbox.c | 42 +-
mbuni/mmsbox/mmsbox.c | 248 +++--
mbuni/mmsbox/mmsbox_cfg.c | 44 +-
mbuni/mmsc/mms_billing_shell.c | 4 +-
mbuni/mmsc/mms_detokenize_shell.c | 2 +-
mbuni/mmsc/mms_resolve.c | 6 +-
mbuni/mmsc/mmsc_cfg.c | 28 +-
mbuni/mmsc/mmsfromemail.c | 45 +-
mbuni/mmsc/mmsglobalsender.c | 70 +-
mbuni/mmsc/mmsmobilesender.c | 22 +-
mbuni/mmsc/mmsproxy.c | 126 +--
mbuni/mmsc/mmssend.c | 10 +-
25 files changed, 1161 insertions(+), 1921 deletions(-)
delete mode 100644 mbuni/misc-patches/Makefile.am
delete mode 100644 mbuni/misc-patches/mbuni-kannel-patch-full
diff --git a/mbuni/Makefile.am b/mbuni/Makefile.am
index bcba468..68fee17 100644
--- a/mbuni/Makefile.am
+++ b/mbuni/Makefile.am
@@ -1,3 +1,3 @@
-SUBDIRS = autotools doc misc-patches mmlib mmsc mmsbox
+SUBDIRS = autotools doc mmlib mmsc mmsbox
EXTRA_DIST = GnuLICENSE KannelLICENSE bootstrap Notes todo
diff --git a/mbuni/configure.ac b/mbuni/configure.ac
index 62a76dd..af63597 100644
--- a/mbuni/configure.ac
+++ b/mbuni/configure.ac
@@ -1,6 +1,6 @@
dnl Mbuni - Open Source MMS Gateway
dnl
-dnl Copyright (C) 2003 - 2005, Digital Solutions Ltd. - http://www.dsmagic.com
+dnl Copyright (C) 2003 - 2006, Digital Solutions Ltd. - http://www.dsmagic.com
dnl
dnl Paul Bagyenda
dnl
@@ -252,7 +252,7 @@ AC_CHECK_LIB([wap], [wsp_headers_pack], [], AC_MSG_ERROR([Kannel WAP lib is requ
dnl May be we need to check for media conversion tools (imagemagick, etc)?
-AC_CONFIG_FILES([Makefile autotools/Makefile doc/Makefile doc/examples/Makefile doc/images/Makefile misc-patches/Makefile mmlib/Makefile mmsc/Makefile mmsbox/Makefile])
+AC_CONFIG_FILES([Makefile autotools/Makefile doc/Makefile doc/examples/Makefile doc/images/Makefile mmlib/Makefile mmsc/Makefile mmsbox/Makefile])
AC_OUTPUT
@@ -260,7 +260,7 @@ cat<Requirements
Chapter 2: Installing The Gateway
@@ -364,16 +364,16 @@ less power.
Chapter 2: Installing The Gateway
This section
-explains the steps required to install the gateway. If you are
+explains the steps required to install the gateway. If you are
installing from a binary distribution, you may safely skip to here.
+ href="#required_comps">here.
In brief, to install Mbuni, you need to:
- Download and install required packages (such as libXML, libiconv)
-
- Download, patch and install Kannel v1.4.0
+
- Download and install Kannel v1.4.1
- Download and install Mbuni
- Download, patch and install the AMR encoder/decoder
- Download and install additional requried packages
@@ -387,11 +387,11 @@ href="http://www.mbuni.org/downloads.shtml">download area of the website
-
Patching and Installing Kannel
+Installing Kannel
In order to compile the software, you
-will first need to download, patch, compile and install Kannel v1.4.0 from kannel.org:
+will first need to download and install Kannel v1.4.1 from kannel.org:
@@ -399,26 +399,9 @@ href="http://www.kannel.org/download/1.4.0/gateway-1.4.0.tar.bz2">kannel.org
source files using a command like:
bzip2 -cd
-gateway-1.4.0.tar.bz2 | tar xf -
+gateway-1.4.1.tar.bz2 | tar xf -
-The kannel
-sources need to be patched for Mbuni using the supplied patch file from
-the Mbuni downloads section given above.
-
-
- mbuni-kannel-patch-full contains important updates to Kannel 1.4.0 that are now part of Kannel CVS.
- (Mbuni still depends on the v1.4.0 release version.)
-
-
-
-Apply the patch as follows:
-
-cd gateway-1.4.0
-
-patch -p1 < ../mbuni-kannel-patch-full
-
-
Then proceed to
compile and install Kannel normally:
diff --git a/mbuni/misc-patches/Makefile.am b/mbuni/misc-patches/Makefile.am
deleted file mode 100644
index 245bd6c..0000000
--- a/mbuni/misc-patches/Makefile.am
+++ /dev/null
@@ -1 +0,0 @@
-EXTRA_DIST = mbuni-kannel-patch-full
diff --git a/mbuni/misc-patches/mbuni-kannel-patch-full b/mbuni/misc-patches/mbuni-kannel-patch-full
deleted file mode 100644
index 5732498..0000000
--- a/mbuni/misc-patches/mbuni-kannel-patch-full
+++ /dev/null
@@ -1,1018 +0,0 @@
-diff -Naur gateway-1.4.0/Makefile.in gateway-1.4.0-patched/Makefile.in
---- gateway-1.4.0/Makefile.in 2004-08-25 00:50:09.000000000 +0300
-+++ gateway-1.4.0-patched/Makefile.in 2005-01-29 16:21:19.000000000 +0300
-@@ -262,9 +262,13 @@
- $(INSTALL) $(man8pages) $(DESTDIR)$(mandir)/man8
- $(INSTALL) -d $(DESTDIR)$(includedir)/kannel/gwlib
- $(INSTALL_DATA) $(top_srcdir)/gwlib/*.h $(DESTDIR)$(includedir)/kannel/gwlib
-+ $(INSTALL) -d $(DESTDIR)$(includedir)/kannel/wap
-+ $(INSTALL_DATA) $(top_srcdir)/wap/*.h $(DESTDIR)$(includedir)/kannel/wap
-+ $(INSTALL_DATA) $(top_srcdir)/wap/*.def $(DESTDIR)$(includedir)/kannel/wap
- $(INSTALL_DATA) gw-config.h $(DESTDIR)$(includedir)/kannel
- $(INSTALL) -d $(DESTDIR)$(libdir)/kannel
- $(INSTALL_DATA) libgwlib.a $(DESTDIR)$(libdir)/kannel
-+ $(INSTALL_DATA) libwap.a $(DESTDIR)$(libdir)/kannel
-
- install-test: all
- $(INSTALL) -d $(DESTDIR)$(libdir)/kannel
-@@ -356,6 +360,6 @@
-
- gw-config: utils/foobar-config.sh Makefile
- ./utils/foobar-config.sh "-I$(includedir)/kannel @CFLAGS@" \
-- "-L$(libdir)/kannel -lgwlib @LIBS@" \
-+ "-L$(libdir)/kannel -lwap -lgwlib @LIBS@" \
- "@VERSION@" > gw-config
- chmod 0755 gw-config
-diff -Naur gateway-1.4.0/gw/ota_compiler.c gateway-1.4.0-patched/gw/ota_compiler.c
---- gateway-1.4.0/gw/ota_compiler.c 2004-01-22 17:08:24.000000000 +0300
-+++ gateway-1.4.0-patched/gw/ota_compiler.c 2005-01-28 17:07:56.000000000 +0300
-@@ -91,9 +91,10 @@
- * chapter 8.2.
- */
- struct ota_3table_t {
-- char *name;
-- char *value;
-- unsigned char token;
-+ char *name;
-+ char *value;
-+ unsigned char token;
-+ unsigned char code_page;
- };
-
- typedef struct ota_3table_t ota_3table_t;
-@@ -103,9 +104,10 @@
- */
-
- static ota_2table_t ota_elements[] = {
-- { "CHARACTERISTIC-LIST", 0x05 },
-- { "CHARACTERISTIC", 0x06 },
-- { "PARM", 0x07 }
-+ { "wap-provisioningdoc", 0x05},
-+ { "CHARACTERISTIC-LIST", 0x05 },
-+ { "CHARACTERISTIC", 0x06 },
-+ { "PARM", 0x07 }
- };
-
- #define NUMBER_OF_ELEMENTS sizeof(ota_elements)/sizeof(ota_elements[0])
-@@ -178,6 +180,174 @@
-
- #define NUMBER_OF_ATTRIBUTES sizeof(ota_attributes)/sizeof(ota_attributes[0])
-
-+static ota_3table_t oma_ota_attributes[] = {
-+ {"version", "1.0", 0x46},
-+ {"version", "INLINE", 0x45},
-+ {"type", "PXLOGICAL", 0x51},
-+ {"type", "PXPHYSICAL", 0x52},
-+ {"type", "PORT", 0x53},
-+ {"type", "VALIDITY", 0x54},
-+ {"type", "NAPDEF", 0x55},
-+ {"type", "BOOTSTRAP", 0x56},
-+ {"type", "VENDORCONFIG", 0x57},
-+ {"type", "PXAUTHINFO", 0x59},
-+ {"type", "NAPAUTHINFO", 0x5A},
-+ {"type", "ACCESS", 0x5B},
-+ {"type", "CLIENTIDENTITY", 0x58},
-+ {"type", "APPLICATION", 0x55,1},
-+ {"type", "APPADDR", 0x56,1},
-+ {"type", "APPAUTH", 0x57,1},
-+ {"type", "RESOURCE", 0x59,1},
-+ {"type", "INLINE", 0x50},
-+ {"name", "NAME", 0x7},
-+ {"name", "NAP-ADDRESS", 0x8},
-+ {"name", "NAP-ADDRTYPE", 0x9},
-+ {"name", "CALLTYPE", 0xA},
-+ {"name", "VALIDUNTIL", 0xB},
-+ {"name", "AUTHTYPE", 0xC},
-+ {"name", "AUTHNAME", 0xD},
-+ {"name", "AUTHSECRET", 0xE},
-+ {"name", "LINGER", 0xF},
-+ {"name", "BEARER", 0x10},
-+ {"name", "NAPID", 0x11},
-+ {"name", "COUNTRY", 0x12},
-+ {"name", "NETWORK", 0x13},
-+ {"name", "INTERNET", 0x14},
-+ {"name", "PROXY-ID", 0x15},
-+ {"name", "PROXY-PROVIDER-ID", 0x16},
-+ {"name", "DOMAIN", 0x17},
-+ {"name", "PROVURL", 0x18},
-+ {"name", "PXAUTH-TYPE", 0x19},
-+ {"name", "PXAUTH-ID", 0x1A},
-+ {"name", "PXAUTH-PW", 0x1B},
-+ {"name", "STARTPAGE", 0x1C},
-+ {"name", "BASAUTH-ID", 0x1D},
-+ {"name", "BASAUTH-PW", 0x1E},
-+ {"name", "PUSHENABLED", 0x1F},
-+ {"name", "PXADDR", 0x20},
-+ {"name", "PXADDRTYPE", 0x21},
-+ {"name", "PORTNBR", 0x23},
-+ {"name", "SERVICE", 0x24},
-+ {"name", "LINKSPEED", 0x25},
-+ {"name", "DNLINKSPEED", 0x26},
-+ {"name", "LOCAL-ADDR", 0x27},
-+ {"name", "LOCAL-ADDRTYPE", 0x28},
-+ {"name", "CONTEXT-ALLOW", 0x29},
-+ {"name", "TRUST", 0x2A},
-+ {"name", "MASTER", 0x2B},
-+ {"name", "SID", 0x2C},
-+ {"name", "SOC", 0x2D},
-+ {"name", "WSP-VERSION", 0x2E},
-+ {"name", "PHYSICAL-PROXY-ID", 0x2F},
-+ {"name", "CLIENT-ID", 0x30},
-+ {"name", "DELIVERY-ERR-SDU", 0x31},
-+ {"name", "DELIVERY-ORDER", 0x32},
-+ {"name", "TRAFFIC-CLASS", 0x33},
-+ {"name", "MAX-SDU-SIZE", 0x34},
-+ {"name", "MAX-BITRATE-UPLINK", 0x35},
-+ {"name", "MAX-BITRATE-DNLINK", 0x36},
-+ {"name", "RESIDUAL-BER", 0x37},
-+ {"name", "SDU-ERROR-RATIO", 0x38},
-+ {"name", "TRAFFIC-HANDL-PRIO", 0x39},
-+ {"name", "TRANSFER-DELAY", 0x3A},
-+ {"name", "GUARANTEED-BITRATE-UPLINK", 0x3B},
-+ {"name", "GUARANTEED-BITRATE-DNLINK", 0x3C},
-+ {"name", "PXADDR-FQDN", 0x3D},
-+ {"name", "PROXY-PW", 0x3E},
-+ {"name", "PPGAUTH-TYPE", 0x3F},
-+ {"name", "PULLENABLED", 0x47},
-+ {"name", "DNS-ADDR", 0x48},
-+ {"name", "MAX-NUM-RETRY", 0x49},
-+ {"name", "FIRST-RETRY-TIMEOUT", 0x4A},
-+ {"name", "REREG-THRESHOLD", 0x4B},
-+ {"name", "T-BIT", 0x4C},
-+ {"name", "AUTH-ENTITY", 0x4E},
-+ {"name", "SPI", 0x4F},
-+ {"name", "TO-NAPID", 0x22},
-+ {"name", "AACCEPT", 0x2E,1},
-+ {"name", "AAUTHDATA", 0x2F,1},
-+ {"name", "AAUTHLEVEL", 0x30,1},
-+ {"name", "AAUTHNAME", 0x31,1},
-+ {"name", "AAUTHSECRET", 0x32,1},
-+ {"name", "AAUTHTYPE", 0x33,1},
-+ {"name", "ADDR", 0x34,1},
-+ {"name", "ADDRTYPE", 0x35,1},
-+ {"name", "APPID", 0x36,1},
-+ {"name", "APROTOCOL", 0x37,1},
-+ {"name", "PROVIDER-ID", 0x38,1},
-+ {"name", "TO-PROXY", 0x39,1},
-+ {"name", "URI", 0x3A,1},
-+ {"name", "RULE", 0x3B,1},
-+ {"name", "INLINE", 0x5},
-+ {"value", "IPV4", 0x85},
-+ {"value", "IPV6", 0x86},
-+ {"value", "E164", 0x87},
-+ {"value", "ALPHA", 0x88},
-+ {"value", "APN", 0x89},
-+ {"value", "SCODE", 0x8A},
-+ {"value", "TETRA-ITSI", 0x8B},
-+ {"value", "APPSRV", 0x8D,1},
-+ {"value", "OBEX", 0x8E,1},
-+ {"value", "MAN", 0x8C},
-+ {"value", "ANALOG-MODEM", 0x90},
-+ {"value", "V.120", 0x91},
-+ {"value", "V.110", 0x92},
-+ {"value", "X.31", 0x93},
-+ {"value", "BIT-TRANSPARENT", 0x94},
-+ {"value", "DIRECT-ASYNCHRONOUS-DATA-SERVICE", 0x95},
-+ {"value", "PAP", 0x9A},
-+ {"value", "CHAP", 0x9B},
-+ {"value", "HTTP-BASIC", 0x9C},
-+ {"value", "HTTP-DIGEST", 0x9D},
-+ {"value", "WTLS-SS", 0x9E},
-+ {"value", "MD5", 0x9F},
-+ {"value", "GSM-USSD", 0xA2},
-+ {"value", "GSM-SMS", 0xA3},
-+ {"value", "ANSI-136-GUTS", 0xA4},
-+ {"value", "IS-95-CDMA-SMS", 0xA5},
-+ {"value", "IS-95-CDMA-CSD", 0xA6},
-+ {"value", "IS-95-CDMA-PACKET", 0xA7},
-+ {"value", "ANSI-136-CSD", 0xA8},
-+ {"value", "ANSI-136-GPRS", 0xA9},
-+ {"value", "GSM-CSD", 0xAA},
-+ {"value", "GSM-GPRS", 0xAB},
-+ {"value", "AMPS-CDPD", 0xAC},
-+ {"value", "PDC-CSD", 0xAD},
-+ {"value", "PDC-PACKET", 0xAE},
-+ {"value", "IDEN-SMS", 0xAF},
-+ {"value", "IDEN-CSD", 0xB0},
-+ {"value", "IDEN-PACKET", 0xB1},
-+ {"value", "FLEX/REFLEX", 0xB2},
-+ {"value", "PHS-SMS", 0xB3},
-+ {"value", "PHS-CSD", 0xB4},
-+ {"value", "TETRA-SDS", 0xB5},
-+ {"value", "TETRA-PACKET", 0xB6},
-+ {"value", "ANSI-136-GHOST", 0xB7},
-+ {"value", "MOBITEX-MPAK", 0xB8},
-+ {"value", "CDMA2000-1X-SIMPLE-IP", 0xB9},
-+ {"value", "CDMA2000-1X-MOBILE-IP", 0xBA},
-+ {"value", "AUTOBAUDING", 0xC5},
-+ {"value", "CL-WSP", 0xCA},
-+ {"value", "CO-WSP", 0xCB},
-+ {"value", "CL-SEC-WSP", 0xCC},
-+ {"value", "CO-SEC-WSP", 0xCD},
-+ {"value", "CL-SEC-WTA", 0xCE},
-+ {"value", "CO-SEC-WTA", 0xCF},
-+ {"value", "OTA-HTTP-TO", 0xD0},
-+ {"value", "OTA-HTTP-TLS-TO", 0xD1},
-+ {"value", "OTA-HTTP-PO", 0xD2},
-+ {"value", "OTA-HTTP-TLS-PO", 0xD3},
-+ {"value", ",", 0x80,1},
-+ {"value", "HTTP-", 0x81,1},
-+ {"value", "BASIC", 0x82},
-+ {"value", "DIGEST", 0x83},
-+ {"value", "AAA", 0xE0},
-+ {"value", "HA", 0xE1},
-+ {"value", "INLINE", 0x6}
-+};
-+
-+#define OMA_VALUE_TAG 0x06
-+#define NUMBER_OF_OMA_ATTRIBUTES sizeof(oma_ota_attributes)/sizeof(oma_ota_attributes[0])
- #include "xml_definitions.h"
-
- /****************************************************************************
-@@ -187,9 +357,9 @@
-
- static int parse_document(xmlDocPtr document, Octstr *charset,
- simple_binary_t **ota_binary);
--static int parse_node(xmlNodePtr node, simple_binary_t **otabxml);
--static int parse_element(xmlNodePtr node, simple_binary_t **otabxml);
--static int parse_attribute(xmlAttrPtr attr, simple_binary_t **otabxml);
-+static int parse_node(xmlNodePtr node, simple_binary_t **otabxml, int is_oma);
-+static int parse_element(xmlNodePtr node, simple_binary_t **otabxml, int is_oma);
-+static int parse_attribute(xmlAttrPtr attr, simple_binary_t **otabxml, int is_oma);
- static int use_inline_string(Octstr *valueos);
-
- /***************************************************************************
-@@ -246,16 +416,26 @@
- simple_binary_t **otabxml)
- {
- xmlNodePtr node;
--
-- (*otabxml)->wbxml_version = 0x01; /* WBXML Version number 1.1 */
-- (*otabxml)->public_id = 0x01; /* Public id for an unknown document type */
-+ int is_oma;
-
-+ if (document->intSubset &&
-+ document->intSubset->ExternalID &&
-+ strcmp(document->intSubset->ExternalID, "-//WAPFORUM//DTD PROV 1.0//EN") == 0) {
-+ is_oma = 1;
-+ (*otabxml)->wbxml_version = 0x03; /* WBXML Version number 1.3 */
-+ (*otabxml)->public_id = 0x0B; /* Public id for this kind of doc */
-+ } else {
-+ (*otabxml)->wbxml_version = 0x01; /* WBXML Version number 1.1 */
-+ (*otabxml)->public_id = 0x01; /* Public id for an unknown document type */
-+ is_oma = 0;
-+ }
-+ (*otabxml)->code_page = 0;
- charset = octstr_create("UTF-8");
- (*otabxml)->charset = parse_charset(charset);
- octstr_destroy(charset);
-
- node = xmlDocGetRootElement(document);
-- return parse_node(node, otabxml);
-+ return parse_node(node, otabxml, is_oma);
- }
-
- /*
-@@ -265,14 +445,14 @@
- * after that calls itself for the next child on the list.
- */
-
--static int parse_node(xmlNodePtr node, simple_binary_t **otabxml)
-+static int parse_node(xmlNodePtr node, simple_binary_t **otabxml, int is_oma)
- {
- int status = 0;
-
- /* Call for the parser function of the node type. */
- switch (node->type) {
- case XML_ELEMENT_NODE:
-- status = parse_element(node, otabxml);
-+ status = parse_element(node, otabxml,is_oma);
- break;
- case XML_TEXT_NODE:
- case XML_COMMENT_NODE:
-@@ -297,12 +477,12 @@
- case 0:
-
- if (node->children != NULL)
-- if (parse_node(node->children, otabxml) == -1)
-+ if (parse_node(node->children, otabxml,is_oma) == -1)
- return -1;
- break;
- case 1:
- if (node->children != NULL)
-- if (parse_node(node->children, otabxml) == -1)
-+ if (parse_node(node->children, otabxml,is_oma) == -1)
- return -1;
- parse_end(otabxml);
- break;
-@@ -316,7 +496,7 @@
- }
-
- if (node->next != NULL)
-- if (parse_node(node->next, otabxml) == -1)
-+ if (parse_node(node->next, otabxml,is_oma) == -1)
- return -1;
-
- return 0;
-@@ -330,7 +510,7 @@
- * 0, do not add an end tag (it has children)
- * -1, an error occurred
- */
--static int parse_element(xmlNodePtr node, simple_binary_t **otabxml)
-+static int parse_element(xmlNodePtr node, simple_binary_t **otabxml, int is_oma)
- {
- Octstr *name;
- size_t i;
-@@ -347,7 +527,7 @@
-
- i = 0;
- while (i < NUMBER_OF_ELEMENTS) {
-- if (octstr_compare(name, octstr_imm(ota_elements[i].name)) == 0)
-+ if (octstr_case_compare(name, octstr_imm(ota_elements[i].name)) == 0)
- break;
- ++i;
- }
-@@ -382,7 +562,7 @@
- if (node->properties != NULL) {
- attribute = node->properties;
- while (attribute != NULL) {
-- parse_attribute(attribute, otabxml);
-+ parse_attribute(attribute, otabxml,is_oma);
- attribute = attribute->next;
- }
- parse_end(otabxml);
-@@ -398,15 +578,16 @@
- * chapters 8.1 and 8.2.
- * Returns 0 when success, -1 when error.
- */
--static int parse_attribute(xmlAttrPtr attr, simple_binary_t **otabxml)
-+static int parse_attribute(xmlAttrPtr attr, simple_binary_t **otabxml, int is_oma)
- {
- Octstr *name,
- *value,
- *valueos,
- *nameos;
- unsigned char ota_hex;
-- size_t i;
--
-+ size_t i, lim;
-+ ota_3table_t *alist;
-+
- name = octstr_create(attr->name);
-
- if (attr->children != NULL)
-@@ -417,16 +598,24 @@
- if (value == NULL)
- goto error;
-
-+ if (is_oma) { /* Pick right one. */
-+ alist = oma_ota_attributes;
-+ lim = NUMBER_OF_OMA_ATTRIBUTES;
-+ } else {
-+ alist = ota_attributes;
-+ lim = NUMBER_OF_ATTRIBUTES;
-+ }
-+
- i = 0;
- valueos = NULL;
- nameos = NULL;
-- while (i < NUMBER_OF_ATTRIBUTES) {
-- nameos = octstr_imm(ota_attributes[i].name);
-- if (octstr_compare(name, nameos) == 0) {
-- if (ota_attributes[i].value != NULL) {
-- valueos = octstr_imm(ota_attributes[i].value);
-+ while (i < lim) {
-+ nameos = octstr_imm(alist[i].name);
-+ if (octstr_case_compare(name, nameos) == 0) {
-+ if (alist[i].value != NULL) {
-+ valueos = octstr_imm(alist[i].value);
- }
-- if (octstr_compare(value, valueos) == 0) {
-+ if (octstr_case_compare(value, valueos) == 0) {
- break;
- }
- if (octstr_compare(valueos, octstr_imm("INLINE")) == 0) {
-@@ -436,15 +625,22 @@
- ++i;
- }
-
-- if (i == NUMBER_OF_ATTRIBUTES) {
-+ if (i == lim) {
- warning(0, "unknown attribute %s in OTA source",
- octstr_get_cstr(name));
- warning(0, "its value being %s", octstr_get_cstr(value));
- goto error;
- }
-
-- ota_hex = ota_attributes[i].token;
-+ ota_hex = alist[i].token;
- if (!use_inline_string(valueos)) {
-+ if (alist[i].code_page != (*otabxml)->code_page) { /* Switch code page. */
-+ output_char(0, otabxml);
-+ output_char(alist[i].code_page, otabxml);
-+ (*otabxml)->code_page = alist[i].code_page;
-+ }
-+ if (is_oma && name && octstr_case_compare(name, octstr_imm("value")) == 0)
-+ output_char(OMA_VALUE_TAG, otabxml);
- output_char(ota_hex, otabxml);
- } else {
- output_char(ota_hex, otabxml);
-diff -Naur gateway-1.4.0/gw/ota_prov.c gateway-1.4.0-patched/gw/ota_prov.c
---- gateway-1.4.0/gw/ota_prov.c 2004-01-22 17:08:24.000000000 +0300
-+++ gateway-1.4.0-patched/gw/ota_prov.c 2005-06-20 13:32:51.000000000 +0300
-@@ -70,12 +70,16 @@
-
- #include "gwlib/gwlib.h"
-
-+#ifdef HAVE_LIBSSL
-+#include
-+#endif
-+
- #include "msg.h"
- #include "sms.h"
- #include "ota_prov.h"
- #include "ota_prov_attr.h"
- #include "ota_compiler.h"
--
-+#include "wap/wsp_headers.h"
-
- /***************************************************************************
- *
-@@ -87,17 +91,20 @@
- * UDH here - SAR UDH is added when (or if) we split the message. This is our
- * *specific* WDP layer.
- */
--static void ota_pack_udh(Msg **msg)
-+static void ota_pack_udh(Msg **msg, Octstr *doc_type)
- {
- (*msg)->sms.udhdata = octstr_create("");
-- octstr_append_from_hex((*msg)->sms.udhdata, "060504C34FC002");
-+ if (octstr_case_compare(doc_type, octstr_imm("oma-settings")) == 0)
-+ octstr_append_from_hex((*msg)->sms.udhdata, "0605040B840B84");
-+ else
-+ octstr_append_from_hex((*msg)->sms.udhdata, "060504C34FC002");
- }
-
-
- /*
- * Our WSP headers: Push Id, PDU type, headers, charset.
- */
--static int ota_pack_push_headers(Msg **msg, Octstr *mime_type)
-+static int ota_pack_push_headers(Msg **msg, Octstr *mime_type, Octstr *sec, Octstr *pin, Octstr *ota_binary)
- {
- (*msg)->sms.msgdata = octstr_create("");
- if (octstr_case_compare(mime_type, octstr_imm("settings")) == 0) {
-@@ -107,6 +114,10 @@
- octstr_format_append((*msg)->sms.msgdata, "%s",
- "application/x-wap-prov.browser-settings");
- octstr_append_from_hex((*msg)->sms.msgdata, "00");
-+
-+ /* charset UTF-8 */
-+ octstr_append_from_hex((*msg)->sms.msgdata, "81EA");
-+
- } else if (octstr_case_compare(mime_type, octstr_imm("bookmarks")) == 0) {
- /* PUSH ID, PDU type, header length, value length */
- octstr_append_from_hex((*msg)->sms.msgdata, "01062D1F2B");
-@@ -114,13 +125,61 @@
- octstr_format_append((*msg)->sms.msgdata, "%s",
- "application/x-wap-prov.browser-bookmarks");
- octstr_append_from_hex((*msg)->sms.msgdata, "00");
-+ /* charset UTF-8 */
-+ octstr_append_from_hex((*msg)->sms.msgdata, "81EA");
-+
-+ } else if (octstr_case_compare(mime_type, octstr_imm("oma-settings")) == 0) {
-+ Octstr *hdr = octstr_create(""), *mac;
-+ unsigned char *p;
-+ int mac_len;
-+#ifdef HAVE_LIBSSL
-+ unsigned char macbuf[EVP_MAX_MD_SIZE];
-+#endif
-+ /* PUSH ID, PDU type, header length, value length */
-+ octstr_append_from_hex((*msg)->sms.msgdata, "0106");
-+
-+ octstr_append_from_hex(hdr, "1f2db6"); /* Content type + other type + sec param */
-+ wsp_pack_short_integer(hdr, 0x11);
-+ if (octstr_case_compare(sec, octstr_imm("netwpin")) == 0)
-+ wsp_pack_short_integer(hdr, 0x0);
-+ else if (octstr_case_compare(sec, octstr_imm("userpin")) == 0)
-+ wsp_pack_short_integer(hdr, 0x01);
-+ else if (octstr_case_compare(sec, octstr_imm("usernetwpin")) == 0)
-+ wsp_pack_short_integer(hdr, 0x02);
-+ else if (octstr_case_compare(sec, octstr_imm("userpinmac")) == 0)
-+ wsp_pack_short_integer(hdr, 0x03); /* XXXX Although not quite supported now.*/
-+ else {
-+ warning(0, "Unknown SEC pin type '%s'.", octstr_get_cstr(sec));
-+ wsp_pack_short_integer(hdr, 0x01);
-+ }
-+ wsp_pack_short_integer(hdr, 0x12); /* MAC */
-+
-+#ifdef HAVE_LIBSSL
-+ p = HMAC(EVP_sha1(), octstr_get_cstr(pin), octstr_len(pin),
-+ octstr_get_cstr(ota_binary), octstr_len(ota_binary),
-+ macbuf, &mac_len);
-+#else
-+ mac_len = 0;
-+ p = "";
-+ warning(0, "No SSL Support, '%s' not supported!", octstr_get_cstr(mime_type));
-+#endif
-+ mac = octstr_create_from_data(p, mac_len);
-+ octstr_binary_to_hex(mac,1);
-+
-+ octstr_append(hdr,mac);
-+ octstr_append_from_hex(hdr, "00");
-+
-+ octstr_append_uintvar((*msg)->sms.msgdata, octstr_len(hdr));
-+ octstr_append((*msg)->sms.msgdata, hdr);
-+
-+ octstr_destroy(hdr);
-+ octstr_destroy(mac);
-+
- } else {
- warning(0, "Unknown MIME type in OTA request, type '%s' is unsupported.",
- octstr_get_cstr(mime_type));
- return 0;
- }
-- /* charset UTF-8 */
-- octstr_append_from_hex((*msg)->sms.msgdata, "81EA");
-
- return 1;
- }
-@@ -132,17 +191,19 @@
- */
-
- int ota_pack_message(Msg **msg, Octstr *ota_doc, Octstr *doc_type,
-- Octstr *from, Octstr *phone_number)
-+ Octstr *from, Octstr *phone_number, Octstr *sec, Octstr *pin)
- {
- Octstr *ota_binary;
-
- *msg = msg_create(sms);
- (*msg)->sms.sms_type = mt_push;
-- ota_pack_udh(msg);
-- if (!ota_pack_push_headers(msg, doc_type))
-- goto herror;
-+ ota_pack_udh(msg,doc_type);
-+
- if (ota_compile(ota_doc, octstr_imm("UTF-8"), &ota_binary) == -1)
- goto cerror;
-+
-+ if (!ota_pack_push_headers(msg, doc_type, sec, pin, ota_binary))
-+ goto herror;
- octstr_format_append((*msg)->sms.msgdata, "%S", ota_binary);
- (*msg)->sms.sender = octstr_duplicate(from);
- (*msg)->sms.receiver = octstr_duplicate(phone_number);
-@@ -156,18 +217,25 @@
- octstr_destroy(ota_doc);
- octstr_destroy(doc_type);
- octstr_destroy(from);
-+ octstr_destroy(sec);
-+ octstr_destroy(pin);
- return 0;
-
- herror:
-+ octstr_destroy(ota_binary);
- octstr_destroy(ota_doc);
- octstr_destroy(doc_type);
- octstr_destroy(from);
-+ octstr_destroy(sec);
-+ octstr_destroy(pin);
- return -2;
-
- cerror:
- octstr_destroy(ota_doc);
- octstr_destroy(doc_type);
- octstr_destroy(from);
-+ octstr_destroy(sec);
-+ octstr_destroy(pin);
- return -1;
- }
-
-diff -Naur gateway-1.4.0/gw/ota_prov.h gateway-1.4.0-patched/gw/ota_prov.h
---- gateway-1.4.0/gw/ota_prov.h 2004-01-22 17:08:24.000000000 +0300
-+++ gateway-1.4.0-patched/gw/ota_prov.h 2005-01-28 17:18:20.000000000 +0300
-@@ -77,7 +77,7 @@
- * Return -2 when header error, -1 when compile error, 0 when no error
- */
- int ota_pack_message(Msg **msg, Octstr *ota_doc, Octstr *doc_type,
-- Octstr *from, Octstr *phone_number);
-+ Octstr *from, Octstr *phone_number, Octstr *sec, Octstr *pin);
-
- /*
- * Tokenizes a given 'ota-setting' group (without using the xml compiler) to
-diff -Naur gateway-1.4.0/gw/smsbox.c gateway-1.4.0-patched/gw/smsbox.c
---- gateway-1.4.0/gw/smsbox.c 2004-09-03 15:42:33.000000000 +0300
-+++ gateway-1.4.0-patched/gw/smsbox.c 2005-02-08 11:23:25.000000000 +0300
-@@ -1210,6 +1210,7 @@
- break;
-
- case TRANSTYPE_EXECUTE:
-+ octstr_url_decode(pattern);
- debug("sms.exec", 0, "executing sms-service '%s'",
- octstr_get_cstr(pattern));
- if ((f = popen(octstr_get_cstr(pattern), "r")) != NULL) {
-@@ -2739,7 +2740,7 @@
-
- /* check does we have an external XML source for configuration */
- if ((ota_doc = http_cgi_variable(list, "text")) != NULL) {
--
-+ Octstr *sec, *pin;
- /*
- * We are doing the XML OTA compiler mode for this request
- */
-@@ -2750,9 +2751,18 @@
- } else {
- doc_type = octstr_duplicate(doc_type);
- }
--
-+ if ((sec = http_cgi_variable(list, "sec")) == NULL)
-+ sec = octstr_create("USERPIN");
-+ else
-+ sec = octstr_duplicate(sec);
-+
-+ if ((pin = http_cgi_variable(list, "pin")) == NULL)
-+ pin = octstr_create("12345");
-+ else
-+ pin = octstr_duplicate(pin);
-+
- if ((ret = ota_pack_message(&msg, ota_doc, doc_type, from,
-- phonenumber)) < 0) {
-+ phonenumber, sec, pin)) < 0) {
- *status = HTTP_BAD_REQUEST;
- msg_destroy(msg);
- if (ret == -2)
-@@ -2870,7 +2880,7 @@
- {
- Octstr *name, *val, *ret;
- Octstr *from, *to, *id, *user, *pass, *smsc;
-- Octstr *type, *charset, *doc_type, *ota_doc;
-+ Octstr *type, *charset, *doc_type, *ota_doc, *sec = NULL, *pin = NULL;
- URLTranslation *t;
- Msg *msg;
- long l;
-@@ -2909,6 +2919,14 @@
- smsc = octstr_duplicate(val);
- octstr_strip_blanks(smsc);
- }
-+ else if (octstr_case_compare(name, octstr_imm("X-Kannel-SEC")) == 0) {
-+ sec = octstr_duplicate(val);
-+ octstr_strip_blanks(sec);
-+ }
-+ else if (octstr_case_compare(name, octstr_imm("X-Kannel-PIN")) == 0) {
-+ pin = octstr_duplicate(val);
-+ octstr_strip_blanks(pin);
-+ }
- }
-
- /* check the username and password */
-@@ -2946,11 +2964,15 @@
- octstr_imm("application/x-wap-prov.browser-settings")) == 0) {
- doc_type = octstr_format("%s", "settings");
- }
-- else if (octstr_case_compare(type,
-- octstr_imm("application/x-wap-prov.browser-bookmarks")) == 0) {
-- doc_type = octstr_format("%s", "bookmarks");
-- }
--
-+ else if (octstr_case_compare(type,
-+ octstr_imm("application/x-wap-prov.browser-bookmarks")) == 0) {
-+ doc_type = octstr_format("%s", "bookmarks");
-+ }
-+ else if (octstr_case_compare(type,
-+ octstr_imm("text/vnd.wap.connectivity-xml")) == 0) {
-+ doc_type = octstr_format("%s", "oma-settings");
-+ }
-+
- if (doc_type == NULL) {
- error(0, "%s got weird content type %s", octstr_get_cstr(sendota_url),
- octstr_get_cstr(type));
-@@ -2964,7 +2986,9 @@
- */
- ota_doc = octstr_duplicate(body);
-
-- if ((r = ota_pack_message(&msg, ota_doc, doc_type, from, to)) < 0) {
-+ if ((r = ota_pack_message(&msg, ota_doc, doc_type, from, to,
-+ sec ? sec : octstr_imm("USERPIN"),
-+ pin ? pin : octstr_imm("1234"))) < 0) {
- *status = HTTP_BAD_REQUEST;
- msg_destroy(msg);
- if (r == -2) {
-diff -Naur gateway-1.4.0/gw/xml_shared.h gateway-1.4.0-patched/gw/xml_shared.h
---- gateway-1.4.0/gw/xml_shared.h 2004-01-22 17:08:24.000000000 +0300
-+++ gateway-1.4.0-patched/gw/xml_shared.h 2005-01-28 17:23:22.000000000 +0300
-@@ -82,10 +82,11 @@
- * XML binary type not containing a string table. This is used for SI and SL.
- */
- struct simple_binary_t {
-- unsigned char wbxml_version;
-- unsigned char public_id;
-- unsigned long charset;
-- Octstr *binary;
-+ unsigned char wbxml_version;
-+ unsigned char public_id;
-+ unsigned long charset;
-+ Octstr *binary;
-+ int code_page;
- };
-
- /*
-diff -Naur gateway-1.4.0/gwlib/conn.c gateway-1.4.0-patched/gwlib/conn.c
---- gateway-1.4.0/gwlib/conn.c 2004-02-18 19:52:33.000000000 +0300
-+++ gateway-1.4.0-patched/gwlib/conn.c 2006-02-17 08:39:38.000000000 +0300
-@@ -1315,6 +1315,7 @@
- info(0, "Using global server SSL key from file `%s'", octstr_get_cstr(keyfile));
- }
-
-+
- static int verify_callback(int preverify_ok, X509_STORE_CTX *ctx)
- {
- char subject[256];
-@@ -1331,6 +1332,28 @@
- return preverify_ok;
- }
-
-+void use_global_trusted_ca_file(Octstr *ssl_trusted_ca_file)
-+{
-+ if (ssl_trusted_ca_file != NULL) {
-+ if (!SSL_CTX_load_verify_locations(global_ssl_context,
-+ octstr_get_cstr(ssl_trusted_ca_file),
-+ NULL)) {
-+ panic(0, "Failed to load SSL CA file: %s", octstr_get_cstr(ssl_trusted_ca_file));
-+ } else {
-+ info(0, "Using CA root certificates from file %s",
-+ octstr_get_cstr(ssl_trusted_ca_file));
-+ SSL_CTX_set_verify(global_ssl_context,
-+ SSL_VERIFY_PEER,
-+ verify_callback);
-+ }
-+
-+ } else {
-+ SSL_CTX_set_verify(global_ssl_context,
-+ SSL_VERIFY_NONE,
-+ NULL);
-+ }
-+}
-+
- void conn_config_ssl (CfgGroup *grp)
- {
- Octstr *ssl_client_certkey_file = NULL;
-@@ -1357,25 +1380,8 @@
-
- ssl_trusted_ca_file = cfg_get(grp, octstr_imm("ssl-trusted-ca-file"));
-
-- if (ssl_trusted_ca_file != NULL) {
-- if (!SSL_CTX_load_verify_locations(global_ssl_context,
-- octstr_get_cstr(ssl_trusted_ca_file),
-- NULL)) {
-- panic(0, "Failed to load SSL CA file: %s", octstr_get_cstr(ssl_trusted_ca_file));
-- } else {
-- info(0, "Using CA root certificates from file %s",
-- octstr_get_cstr(ssl_trusted_ca_file));
-- SSL_CTX_set_verify(global_ssl_context,
-- SSL_VERIFY_PEER,
-- verify_callback);
-- }
--
-- } else {
-- SSL_CTX_set_verify(global_ssl_context,
-- SSL_VERIFY_NONE,
-- NULL);
-- }
--
-+ use_global_trusted_ca_file(ssl_trusted_ca_file);
-+
- octstr_destroy(ssl_client_certkey_file);
- octstr_destroy(ssl_server_cert_file);
- octstr_destroy(ssl_server_key_file);
-diff -Naur gateway-1.4.0/gwlib/conn.h gateway-1.4.0-patched/gwlib/conn.h
---- gateway-1.4.0/gwlib/conn.h 2004-02-16 22:41:26.000000000 +0300
-+++ gateway-1.4.0-patched/gwlib/conn.h 2006-02-17 08:42:32.000000000 +0300
-@@ -307,6 +307,11 @@
- */
- void use_global_server_certkey_file(Octstr *certfile, Octstr *keyfile);
-
-+/* Specifies files containing certificates Kannel is willing to trusted when
-+ * actins as https clients
-+ */
-+void use_global_trusted_ca_file(Octstr *ssl_trusted_ca_file);
-+
- /* Configures all global variables for client and server SSL mode
- * from the values specified within the configuration file.
- */
-diff -Naur gateway-1.4.0/gwlib/mime.c gateway-1.4.0-patched/gwlib/mime.c
---- gateway-1.4.0/gwlib/mime.c 2004-08-11 19:41:29.000000000 +0300
-+++ gateway-1.4.0-patched/gwlib/mime.c 2005-09-09 15:31:17.000000000 +0300
-@@ -191,14 +191,16 @@
- value = http_header_value(headers, octstr_imm("Content-Type"));
- boundary = http_get_header_parameter(value, octstr_imm("boundary"));
- if (boundary == NULL) {
-- boundary = octstr_format("_MIME_boundary-%d-%ld_%c_%c_bd%d",
-+ boundary = octstr_format("_boundary_%d_%ld_%c_%c_bd%d",
- random(), (long)time(NULL), 'A' + (random()%26),
- 'a'+(random() % 26), random());
-- octstr_append(value, octstr_imm("; boundary="));
-- octstr_append(value, boundary);
-+ octstr_format_append(value, "; boundary=%S", boundary);
-+
- http_header_remove_all(headers, "Content-Type");
- http_header_add(headers, "Content-Type", octstr_get_cstr(value));
-+#if 0
- http_header_add(headers, "MIME-Version", "1.0");
-+#endif
- }
- octstr_destroy(value);
-
-@@ -213,9 +215,10 @@
- for (i = 0; i < list_len(m->multiparts); i++) {
- MIMEEntity *e = list_get(m->multiparts, i);
- Octstr *body;
--
-- if (i != 0)
-- octstr_append(mime, octstr_imm("\r\n"));
-+#if 0 /* Is this extra new line needed ?? */
-+ if (i != 0)
-+ octstr_append(mime, octstr_imm("\r\n"));
-+#endif
- octstr_append(mime, octstr_imm("\r\n--"));
- octstr_append(mime, boundary);
- octstr_append(mime, octstr_imm("\r\n"));
-@@ -331,10 +334,13 @@
- else
- octstr_delete(entity, 0, 1);
-
-- if (octstr_get_char(entity, octstr_len(entity) - 2) == '\r')
-+ if (octstr_get_char(entity, octstr_len(entity) - 2) == '\r' &&
-+ octstr_get_char(entity, octstr_len(entity) - 4) == '\r')
- octstr_delete(entity, octstr_len(entity) - 4, 4);
-+ else if (octstr_get_char(entity, octstr_len(entity) - 2) == '\r')
-+ octstr_delete(entity, octstr_len(entity) - 2, 2);
- else
-- octstr_delete(entity, octstr_len(entity) - 2, 2);
-+ octstr_delete(entity, octstr_len(entity) - 1, 1);
-
-
- debug("mime.parse",0,"MIME multipart: Parsing entity:");
-@@ -443,6 +449,34 @@
- return body;
- }
-
-+int mime_entity_body_and_headers(MIMEEntity *m, Octstr **body, List **headers)
-+{
-+ Octstr *os;
-+ ParseContext *context;
-+
-+ gw_assert(m != NULL && m->headers != NULL);
-+
-+ os = mime_entity_to_octstr(m);
-+ context = parse_context_create(os);
-+
-+ *headers = http_create_empty_headers();
-+
-+ /* parse the headers up to the body */
-+ if ((read_mime_headers(context, *headers) != 0) ||*headers == NULL) {
-+ debug("mime.parse",0,"Failed to read MIME headers in Octstr block:");
-+ octstr_dump(os, 0);
-+ parse_context_destroy(context);
-+ return -1;
-+ }
-+
-+ /* the rest is the body */
-+ *body = parse_get_rest(context);
-+
-+ octstr_destroy(os);
-+
-+ parse_context_destroy(context);
-+ return 0;
-+}
-
- /********************************************************************
- * Routines for debugging purposes.
-diff -Naur gateway-1.4.0/gwlib/mime.h gateway-1.4.0-patched/gwlib/mime.h
---- gateway-1.4.0/gwlib/mime.h 2004-01-26 18:04:57.000000000 +0300
-+++ gateway-1.4.0-patched/gwlib/mime.h 2005-04-13 17:59:48.000000000 +0300
-@@ -141,6 +141,13 @@
- Octstr *mime_entity_body(MIMEEntity *m);
-
- /*
-+ * Take a MIME multipart representation and return the headers and body as would
-+ * result from turning it into a string.
-+ * this then serves for http header and body...
-+ */
-+int mime_entity_body_and_headers(MIMEEntity *m, Octstr **body, List **headers);
-+
-+/*
- * Dump the structure (hicharchical view) of the MIME representation
- * structure into our DEBUG log level facility.
- */
-diff -Naur gateway-1.4.0/test/test_ppg.c gateway-1.4.0-patched/test/test_ppg.c
---- gateway-1.4.0/test/test_ppg.c 2004-10-13 10:38:13.000000000 +0300
-+++ gateway-1.4.0-patched/test/test_ppg.c 2005-05-31 08:31:10.000000000 +0300
-@@ -81,7 +81,7 @@
- static int verbose = 1,
- use_hardcoded = 0,
- num_urls = 0,
-- wait = 0,
-+ xwait = 0,
- use_headers = 0,
- use_config = 0,
- accept_binary = 0,
-@@ -648,7 +648,7 @@
- if (i >= max_pushes)
- goto receive_rest;
- start_push(caller, i);
-- if (wait)
-+ if (xwait)
- gwthread_sleep(wait_seconds);
- ++in_queue;
- }
-@@ -784,7 +784,7 @@
- break;
-
- case 'i':
-- wait = 1;
-+ xwait = 1;
- wait_seconds = atof(optarg);
- break;
-
-diff -Naur gateway-1.4.0/wap/wsp_headers.c gateway-1.4.0-patched/wap/wsp_headers.c
---- gateway-1.4.0/wap/wsp_headers.c 2004-08-08 23:39:56.000000000 +0300
-+++ gateway-1.4.0-patched/wap/wsp_headers.c 2005-07-07 18:53:59.000000000 +0300
-@@ -122,10 +122,9 @@
- } else if (val > 127) {
- *well_known_value = val - 128;
- return WSP_FIELD_VALUE_ENCODED;
-- } else if (val == WSP_QUOTE) { /* 127 */
-+ } else if (val == WSP_QUOTE || val == '"') { /* 127 or quote -- this is not ideal, but... */
- *well_known_value = -1;
-- /* We already consumed the Quote */
-- return WSP_FIELD_VALUE_NUL_STRING;
-+ return WSP_FIELD_VALUE_NUL_STRING;
- } else {
- *well_known_value = -1;
- /* Un-parse the character we just read */
-@@ -1487,7 +1486,7 @@
- { WSP_HEADER_X_WAP_CONTENT_URI, pack_uri, 0},
- { WSP_HEADER_X_WAP_INITIATOR_URI, pack_uri, 0},
- { WSP_HEADER_X_WAP_APPLICATION_ID, wsp_pack_integer_string, 0},
-- { WSP_HEADER_CONTENT_ID, wsp_pack_text, 0},
-+ { WSP_HEADER_CONTENT_ID, wsp_pack_quoted_text, 0},
- { WSP_HEADER_ENCODING_VERSION, wsp_pack_version_value, 0 }
- // DAVI { WSP_HEADER_SET_COOKIE, pack_version_value, 0 }
- };
-@@ -1616,13 +1615,23 @@
- {
- /* This check catches 0-length strings as well, because
- * octstr_get_char will return -1. */
-- if (octstr_get_char(text, 0) >= 128 || octstr_get_char(text, 0) < 32)
-+ if (octstr_get_char(text, 0) >= 128 || octstr_get_char(text, 0) < 32 ||
-+ octstr_get_char(text, 0) == '"') /* quote the quote as well. */
- octstr_append_char(packed, WSP_QUOTE);
- octstr_append(packed, text);
- octstr_append_char(packed, 0);
- return 0;
- }
-
-+/* Pack a string as quoted-text WAP WSP 203, Section 8.4.2.1 */
-+int wsp_pack_quoted_text(Octstr *packed, Octstr *text)
-+{
-+ octstr_append_char(packed, '"');
-+ octstr_append(packed,text);
-+ octstr_append_char(packed,0);
-+ return 0;
-+}
-+
- /* Pack text as Quoted-string if it starts with a " character.
- * Pack it as Text-string otherwise. */
- static void pack_quoted_string(Octstr *packed, Octstr *text)
-@@ -1884,6 +1893,7 @@
- keytoken = wsp_string_to_versioned_parameter(parm->key, WSP_1_2);
-
- if (keytoken >= 0) {
-+ Octstr *s;
- /* Typed-parameter = Well-known-parameter-token Typed-value */
- /* Well-known-parameter-token = Integer-value */
- wsp_pack_integer_value(packed, keytoken);
-@@ -1904,7 +1914,12 @@
- }
- break;
- case 1: /* charset */
-- tmp = wsp_string_to_charset(parm->value);
-+
-+ s = octstr_duplicate(parm->value); /* lower-case it. */
-+ octstr_convert_range(s, 0, octstr_len(s), tolower);
-+
-+ tmp = wsp_string_to_charset(s);
-+ octstr_destroy(s);
- if (tmp >= 0) {
- wsp_pack_integer_value(packed, tmp);
- return;
-diff -Naur gateway-1.4.0/wap/wsp_headers.h gateway-1.4.0-patched/wap/wsp_headers.h
---- gateway-1.4.0/wap/wsp_headers.h 2004-01-26 18:06:38.000000000 +0300
-+++ gateway-1.4.0-patched/wap/wsp_headers.h 2005-07-06 08:19:01.000000000 +0300
-@@ -141,6 +141,7 @@
- int wsp_pack_date(Octstr *packet, Octstr *value);
- int wsp_pack_retry_after(Octstr *packet, Octstr *value);
- int wsp_pack_text(Octstr *packet, Octstr *value);
-+int wsp_pack_quoted_text(Octstr *packed, Octstr *text);
- int wsp_pack_integer_string(Octstr *packet, Octstr *value);
- int wsp_pack_version_value(Octstr *packet, Octstr *value);
- int wsp_pack_constrained_value(Octstr *packed, Octstr *text, long value);
diff --git a/mbuni/mmlib/mms_cfg.c b/mbuni/mmlib/mms_cfg.c
index d7364a6..870b716 100644
--- a/mbuni/mmlib/mms_cfg.c
+++ b/mbuni/mmlib/mms_cfg.c
@@ -140,8 +140,8 @@ mCfg *mms_cfg_read(Octstr *file)
cfg->grps = dict_create(7, NULL);
lines = octstr_split(sf, octstr_imm("\n"));
- for (i = 0, n = list_len(lines); i < n; i++) {
- Octstr *current = list_get(lines,i);
+ for (i = 0, n = gwlist_len(lines); i < n; i++) {
+ Octstr *current = gwlist_get(lines,i);
int pos;
octstr_strip_blanks(current);
@@ -182,10 +182,10 @@ mCfg *mms_cfg_read(Octstr *file)
List *l = dict_get(cfg->grps, value);
if (l == NULL) {
- l = list_create();
+ l = gwlist_create();
dict_put(cfg->grps, value, l);
}
- list_append(l, grp);
+ gwlist_append(l, grp);
} else if (dict_put_once(cfg->grps, value, grp) == 0)
panic(0, "Group `%s' [at line %d] cannot appear more "
"than once in config!",
@@ -207,7 +207,7 @@ mCfg *mms_cfg_read(Octstr *file)
panic(0, "mal-formed entry in conf file at line %d!", i+1);
}
- list_destroy(lines, (list_item_destructor_t *)octstr_destroy);
+ gwlist_destroy(lines, (gwlist_item_destructor_t *)octstr_destroy);
octstr_destroy(sf);
return cfg;
}
@@ -226,18 +226,18 @@ void mms_cfg_destroy(mCfg *cfg)
gw_assert(cfg);
- for (i = 0, l = dict_keys(cfg->grps), n = list_len(l); i < n; i++) {
- Octstr *grpname = list_get(l, i);
+ for (i = 0, l = dict_keys(cfg->grps), n = gwlist_len(l); i < n; i++) {
+ Octstr *grpname = gwlist_get(l, i);
void *val = dict_get(cfg->grps, grpname);
if (is_multigroup(grpname)) {
List *gl = val;
- int j, m = list_len(gl);
+ int j, m = gwlist_len(gl);
for (j = 0; j < m; j++)
- mGrp_destroy(list_get(gl, j));
+ mGrp_destroy(gwlist_get(gl, j));
} else
mGrp_destroy(val);
}
- list_destroy(l, (list_item_destructor_t *)octstr_destroy);
+ gwlist_destroy(l, (gwlist_item_destructor_t *)octstr_destroy);
dict_destroy(cfg->grps);
octstr_destroy(cfg->file);
gw_free(cfg);
@@ -262,8 +262,8 @@ List *mms_cfg_get_multi(mCfg *cfg, Octstr *name)
r = dict_get(cfg->grps, name);
if (r)
- for (i = 0, l = list_create(); i < list_len(r); i++)
- list_append(l, list_get(r,i));
+ for (i = 0, l = gwlist_create(); i < gwlist_len(r); i++)
+ gwlist_append(l, gwlist_get(r,i));
return l;
}
diff --git a/mbuni/mmlib/mms_mm7soap.c b/mbuni/mmlib/mms_mm7soap.c
index a94950a..a290403 100644
--- a/mbuni/mmlib/mms_mm7soap.c
+++ b/mbuni/mmlib/mms_mm7soap.c
@@ -101,7 +101,7 @@ static int parse_header(xmlNodePtr node, List *headers, int *sigparent)
/* look at each node in turn, extract meaning.
* we ignore some tags: senderidentification, etc because we don't need them.
- * we are also not strict on syntax (when receiving): we will be on sending!
+ * we are also not strict on syntax (when receiving): we will be on sending!
*/
hname = (char *)node->name;
@@ -228,31 +228,26 @@ static int parse_headers(xmlNodePtr start, List *h, int sigparent)
MSoapMsg_t *mm7_parse_soap(List *headers, Octstr *body)
{
- MIMEEntity *mime = mime_http_to_entity(headers, body);
+ MIMEEntity *mime = mime_http_to_entity(headers, body), *start = NULL;
Octstr *xml = NULL, *cloc;
xmlDocPtr doc;
MIMEEntity *msg = NULL;
List *h;
int s = -1;
MSoapMsg_t *smsg = NULL;
-
+
if (!mime)
return NULL;
/* Find the start element:
- * - either the mime entity is multipart and has start param ...
- * - or entity is multipart and start element is (implicitly) first element
+ * - either the mime entity is multipart and has start param (or implicitly first element) ...
* - or entity is not multipart, so body is xml
*/
-
- if (mime->start)
- xml = mime->start->body;
- else if (mime->multiparts && list_len(mime->multiparts) > 0) {
- MIMEEntity *x = list_get(mime->multiparts,0);
- xml = x->body;
- } else
- xml = mime->body;
-
- /* Don't free 'xml'! It is part of mime object. */
+
+ if ((start = mime_multipart_start_elem(mime)) != NULL)
+ xml = mime_entity_body(start);
+ else
+ xml = mime_entity_body(mime);
+
if (!xml)
goto done;
#if 1
@@ -277,24 +272,26 @@ MSoapMsg_t *mm7_parse_soap(List *headers, Octstr *body)
MIMEEntity *c = NULL;
int i, n;
char *loc = octstr_get_cstr(cloc) + 4; /* skip 'cid:' part. */
- for (i = 0, n = list_len(mime->multiparts); imultiparts, i);
- Octstr *y = x ? http_header_value(x->headers, octstr_imm("Content-ID")) : NULL;
+ for (i = 0, n = mime_entity_num_parts(mime); imsg) {
@@ -585,21 +587,31 @@ int mm7_soapmsg_to_httpmsg(MSoapMsg_t *m, List **hdrs, Octstr **body)
'a' + random() % 26);
MIMEEntity *xml = mime_entity_create();
List *hh = http_header_duplicate(m->envelope);
-
+ List *hx;
+
/* Replace in envelope. */
http_header_remove_all(hh, "Content");
http_header_add(hh, "Content", octstr_get_cstr(cloc));
/* Replace content location in msg part. */
- http_header_remove_all(c->headers, "Content-ID");
- http_header_add(c->headers, "Content-ID", octstr_get_cstr(cloc_str));
-
- http_header_add(xml->headers, "Content-Type", "\"text/xml\"");
- http_header_add(xml->headers, "Content-ID", octstr_get_cstr(envloc));
- xml->body = headers_to_soapxml(hh);
+ hx = _x_mime_entity_headers(c);
+ http_header_remove_all(hx, "Content-ID");
+ http_header_add(hx, "Content-ID", octstr_get_cstr(cloc_str));
+ mime_replace_headers(c, hx);
+ http_destroy_headers(hx);
- list_append(mime->multiparts, xml);
- list_append(mime->multiparts, c);
+ hx = http_create_empty_headers();
+ http_header_add(hx, "Content-Type", "\"text/xml\"");
+ http_header_add(hx, "Content-ID", octstr_get_cstr(envloc));
+ mime_replace_headers(xml, hx);
+ http_destroy_headers(hx);
+
+ s = headers_to_soapxml(hh);
+ mime_entity_set_body(xml, s);
+ octstr_destroy(s);
+
+ mime_entity_add_part(mime, xml);
+ mime_entity_add_part(mime, c);
http_destroy_headers(hh);
@@ -608,16 +620,25 @@ int mm7_soapmsg_to_httpmsg(MSoapMsg_t *m, List **hdrs, Octstr **body)
octstr_destroy(envloc);
octstr_destroy(cloc);
- octstr_destroy(cloc_str);
+ octstr_destroy(cloc_str);
+
+ mime_entity_destroy(xml);
+ mime_entity_destroy(c);
} else {
ctype = octstr_imm("\"text/xml\"");
- mime->body = headers_to_soapxml(m->envelope);
+ s = headers_to_soapxml(m->envelope);
+ mime_entity_set_body(mime,s);
+ octstr_destroy(s);
}
- http_header_add(mime->headers, "Content-Type", octstr_get_cstr(ctype));
- http_header_add(mime->headers, "SOAPAction", "\"some-url\"");
-
- mime_entity_body_and_headers(mime, body, hdrs);
+ headers = http_create_empty_headers();
+ http_header_add(headers, "Content-Type", octstr_get_cstr(ctype));
+ http_header_add(headers, "SOAPAction", "\"some-url\"");
+ mime_replace_headers(mime, headers);
+ http_destroy_headers(headers);
+
+ *body = mime_entity_body(mime);
+ *hdrs = _x_mime_entity_headers(mime);
mime_entity_destroy(mime);
@@ -645,14 +666,14 @@ static int get_rcptvalues(List *to, List *headers, char *hname)
l = http_header_find_all(headers, hname);
- for (i = 0, n = (l) ? list_len(l) : 0; i < n; i++) {
+ for (i = 0, n = (l) ? gwlist_len(l) : 0; i < n; i++) {
Octstr *h, *v;
int ch;
http_header_get(l, i, &h, &v);
ch = octstr_get_char(v, 0);
if (ch == '+')
- list_append(to, octstr_copy(v, 2, octstr_len(v)));
+ gwlist_append(to, octstr_copy(v, 2, octstr_len(v)));
octstr_destroy(h);
octstr_destroy(v);
}
@@ -670,7 +691,7 @@ int mm7_get_envelope(MSoapMsg_t *m,
Octstr *s;
if (*to == NULL)
- *to = list_create();
+ *to = gwlist_create();
get_rcptvalues(*to, m->envelope, "To");
get_rcptvalues(*to, m->envelope, "Cc");
@@ -730,7 +751,7 @@ MmsMsg *mm7_soap_to_mmsmsg(MSoapMsg_t *m, Octstr *from)
if (!msg)
break;
-
+ mms_remove_headers(msg, "Content-ID"); /* not necessary, but... */
/* Put in some headers... */
if (from)
mms_replace_header_value(msg, "From", octstr_get_cstr(from));
@@ -784,15 +805,15 @@ MmsMsg *mm7_soap_to_mmsmsg(MSoapMsg_t *m, Octstr *from)
}
/* Put in recipient list. XXX - really?? */
- l = list_create();
+ l = gwlist_create();
get_rcptvalues(l, m->envelope, "To");
mms_replace_header_values(msg, "To", l);
- list_destroy(l, (list_item_destructor_t *)octstr_destroy);
+ gwlist_destroy(l, (gwlist_item_destructor_t *)octstr_destroy);
- l = list_create();
+ l = gwlist_create();
get_rcptvalues(l, m->envelope, "Cc");
mms_replace_header_values(msg, "Cc", l);
- list_destroy(l, (list_item_destructor_t *)octstr_destroy);
+ gwlist_destroy(l, (gwlist_item_destructor_t *)octstr_destroy);
/* XXX - we ignore reply charging, etc. */
break;
@@ -877,7 +898,8 @@ MSoapMsg_t *mm7_mmsmsg_to_soap(MmsMsg *msg, Octstr *from, List *xto,
Octstr *s;
int i, n;
Octstr *xfrom;
-
+ List *headers;
+
xfrom = octstr_format("+ %S", from ? from : octstr_imm("anon@anon"));
switch(mtype) {
case MMS_MSGTYPE_SEND_REQ:
@@ -886,8 +908,8 @@ MSoapMsg_t *mm7_mmsmsg_to_soap(MmsMsg *msg, Octstr *from, List *xto,
transid);
m->msg = mms_tomime(msg,1);
- for (i = 0, n = xto ? list_len(xto) : 0; i < n; i++) { /* Add recipients. */
- Octstr *xx = octstr_format("+ %S", list_get(xto, i));
+ for (i = 0, n = xto ? gwlist_len(xto) : 0; i < n; i++) { /* Add recipients. */
+ Octstr *xx = octstr_format("+ %S", gwlist_get(xto, i));
http_header_add(m->envelope, "To",
octstr_get_cstr(xx));
octstr_destroy(xx);
@@ -952,13 +974,16 @@ MSoapMsg_t *mm7_mmsmsg_to_soap(MmsMsg *msg, Octstr *from, List *xto,
}
/* Should we bother to strip message part of headers??? */
- http_header_remove_all(m->msg->headers, "Subject");
- http_header_remove_all(m->msg->headers, "X-Mms-Message-Type");
- http_header_remove_all(m->msg->headers, "X-Mms-Message-Version");
- http_header_remove_all(m->msg->headers, "From");
- http_header_remove_all(m->msg->headers, "To");
- http_header_remove_all(m->msg->headers, "Cc");
- http_header_remove_all(m->msg->headers, "Bcc");
+ headers = _x_mime_entity_headers(m->msg);
+ http_header_remove_all(headers, "Subject");
+ http_header_remove_all(headers, "X-Mms-Message-Type");
+ http_header_remove_all(headers, "X-Mms-Message-Version");
+ http_header_remove_all(headers, "From");
+ http_header_remove_all(headers, "To");
+ http_header_remove_all(headers, "Cc");
+ http_header_remove_all(headers, "Bcc");
+ mime_replace_headers(m->msg, headers);
+ http_destroy_headers(headers);
break;
case MMS_MSGTYPE_READ_ORIG_IND:
case MMS_MSGTYPE_DELIVERY_IND:
@@ -968,8 +993,8 @@ MSoapMsg_t *mm7_mmsmsg_to_soap(MmsMsg *msg, Octstr *from, List *xto,
http_header_add(m->envelope, "Sender", octstr_get_cstr(xfrom));
- if (xto && list_len(xto) > 0) {
- Octstr *xx = octstr_format("+ %S", list_get(xto, 0));
+ if (xto && gwlist_len(xto) > 0) {
+ Octstr *xx = octstr_format("+ %S", gwlist_get(xto, 0));
http_header_add(m->envelope, "To",
octstr_get_cstr(xx));
octstr_destroy(xx);
diff --git a/mbuni/mmlib/mms_mmbox.c b/mbuni/mmlib/mms_mmbox.c
index 5765452..572eb1e 100644
--- a/mbuni/mmlib/mms_mmbox.c
+++ b/mbuni/mmlib/mms_mmbox.c
@@ -215,8 +215,8 @@ static Octstr *linearise_string_list(List *l, char *sep)
Octstr *s = octstr_create("");
- for (i = 0, n = list_len(l); i < n; i++) {
- Octstr *p = list_get(l,i);
+ for (i = 0, n = gwlist_len(l); i < n; i++) {
+ Octstr *p = gwlist_get(l,i);
if (p)
octstr_format_append(s, "%s%S", (i == 0) ? "" : sep, p);
}
@@ -227,10 +227,10 @@ static List *parse_string_list(char *buf)
{
int i = 0;
char sbuf[128], *p = buf;
- List *l = list_create();
+ List *l = gwlist_create();
while (sscanf(p, "%s%n", sbuf, &i) > 0) {
- list_append(l, octstr_create(sbuf));
+ gwlist_append(l, octstr_create(sbuf));
p += i;
}
@@ -341,19 +341,19 @@ static int update_mmbox_index(int fd, char *mmbox_dir, int cmd,
static List *make_mm_flags(List *oflags, List *flag_cmds)
{
- List *l = oflags ? oflags : list_create();
+ List *l = oflags ? oflags : gwlist_create();
int i, n;
- for (i = 0, n = list_len(l); i < n; i++) { /* cleanup list. */
- Octstr *x = list_get(l,i);
+ for (i = 0, n = gwlist_len(l); i < n; i++) { /* cleanup list. */
+ Octstr *x = gwlist_get(l,i);
int ch = octstr_get_char(x, 0);
if (ch == '+' || ch == '-' || ch == '/')
octstr_delete(x,0,1);
}
- for (i = 0, n = (flag_cmds ? list_len(flag_cmds) : 0); i= start && list_len(dflist) <= limit) {
+ if (match && ct >= start && gwlist_len(dflist) <= limit) {
Octstr *x = octstr_create(idx);
/* octstr_replace(x, octstr_imm("/"), octstr_imm("-")); */
- list_append(dflist, x);
+ gwlist_append(dflist, x);
}
ct++;
if (xflags)
- list_destroy(xflags, (list_item_destructor_t *)octstr_destroy);
+ gwlist_destroy(xflags, (gwlist_item_destructor_t *)octstr_destroy);
}
done:
@@ -710,7 +710,7 @@ List *mms_mmbox_search(char *mmbox_root, char *user,
close(ifd);
if (flags)
- list_destroy(flags, (list_item_destructor_t *)octstr_destroy);
+ gwlist_destroy(flags, (gwlist_item_destructor_t *)octstr_destroy);
if (home)
octstr_destroy(home);
diff --git a/mbuni/mmlib/mms_msg.c b/mbuni/mmlib/mms_msg.c
index 094e0b4..233f10e 100644
--- a/mbuni/mmlib/mms_msg.c
+++ b/mbuni/mmlib/mms_msg.c
@@ -31,10 +31,11 @@ struct MmsMsg {
#define SIZHINT 47
-static void mm_destroy(MIMEEntity *mx);
+
static int encode_msgheaders(Octstr *os, List *hdrs);
static int decode_msgheaders(ParseContext *context, List *hdr, Octstr *from, int stop_on_ctype);
+
static inline void pack_short_integer(Octstr *s, int ch)
{
unsigned long c = ((unsigned)ch)&0x7f;
@@ -90,13 +91,13 @@ static int decode_multipart(ParseContext *context, List *body)
for (i = 0; i 0 ; i++) {
int dlen, hlen;
- MIMEEntity *x = gw_malloc(sizeof *x);
+ MIMEEntity *x = mime_entity_create();
+ List *headers;
Octstr *hs;
Octstr *content;
Octstr *content_type;
- memset(x, 0,sizeof *x);
hlen = parse_get_uintvar(context);
dlen = parse_get_uintvar(context);
@@ -105,23 +106,32 @@ static int decode_multipart(ParseContext *context, List *body)
hs = parse_get_octets(context, parse_octets_left(context));
- x->headers = wsp_headers_unpack(hs, 1);
-
+ headers = wsp_headers_unpack(hs, 1);
octstr_destroy(hs);
+
+ strip_boundary_element(headers,NULL);
+ mime_replace_headers(x, headers);
parse_skip_to_limit(context);
parse_pop_limit(context);
- content_type = http_header_value(x->headers, octstr_imm("Content-Type"));
+ content_type = http_header_value(headers, octstr_imm("Content-Type"));
content = parse_get_octets(context, dlen);
+ http_destroy_headers(headers);
+
if (!content || !content_type) {
int pleft = parse_octets_left(context);
- warning(0, "Parse error reading mime body [hlen=%d, dlen=%d, left=%d]!",hlen,dlen, pleft);
+ warning(0, "Parse error reading mime body [hlen=%d, dlen=%d, left=%d]!",
+ hlen,dlen, pleft);
mime_entity_destroy(x);
- if (content_type) octstr_destroy(content_type);
+ if (content_type)
+ octstr_destroy(content_type);
+ if (content)
+ octstr_destroy(content);
return -1;
}
+
if (octstr_case_compare(content_type,
octstr_imm("application/vnd.wap.multipart.related")) == 0 ||
octstr_case_compare(content_type,
@@ -129,46 +139,65 @@ static int decode_multipart(ParseContext *context, List *body)
octstr_case_compare(content_type,
octstr_imm("application/vnd.wap.multipart.mixed")) == 0) { /* Body is multipart. */
ParseContext *p = parse_context_create(content);
- int res;
- List *ml = x->multiparts = list_create();
-
- res = decode_multipart(p, x->multiparts);
- octstr_destroy(content);
- parse_context_destroy(p);
+ List *ml = gwlist_create();
+ int res = decode_multipart(p, ml);
+ parse_context_destroy(p);
+ if (res == 0) {
+ /* Put body parts into mime object. */
+ int j, m = gwlist_len(ml);
+ for (j = 0; j < m; j++)
+ mime_entity_add_part(x, gwlist_get(ml,i));
+ }
+
+ gwlist_destroy(ml, (gwlist_item_destructor_t *)mime_entity_destroy);
if (res < 0) {
- list_destroy(ml, (list_item_destructor_t *)mime_entity_destroy);
+ if (content_type)
+ octstr_destroy(content_type);
+ if (content)
+ octstr_destroy(content);
return -1;
}
} else
- x->body = content;
-
+ mime_entity_set_body(x,content);
+ octstr_destroy(content);
octstr_destroy(content_type);
-
- list_append(body, x);
+ gwlist_append(body, x);
}
return 0;
}
static int encode_multipart(Octstr *os, List *body)
{
- int i, n;
+ int i, j, n, m;
- n = list_len(body);
+ n = gwlist_len(body);
octstr_append_uintvar(os, n);
i = 0;
while (iheaders, 1, WSP_1_3);
-
- if (x->multiparts &&
- list_len(x->multiparts) > 0) /* This is a multi-part, go down further. */
- encode_multipart(mbody, x->multiparts);
- else if (x->body)
- octstr_append(mbody, x->body);
+ if ((m = mime_entity_num_parts(x)) > 0) { /* This is a multi-part,
+ * go down further.
+ */
+ List *l = gwlist_create();
+
+ for (j = 0; j < m; j++)
+ gwlist_append(l, mime_entity_get_part(x, j));
+ encode_multipart(mbody, l);
+ gwlist_destroy(l, (gwlist_item_destructor_t *)mime_entity_destroy);
+ } else if ((s = mime_entity_body(x)) != NULL) {
+ octstr_append(mbody, s);
+ octstr_destroy(s);
+ }
octstr_append_uintvar(os, octstr_len(mhdr));
octstr_append_uintvar(os, octstr_len(mbody));
@@ -188,7 +217,7 @@ static int decode_msgbody(ParseContext *context, MmsMsg *msg)
{
int res = 0;
if (msg->ismultipart) {
- msg->body.l = list_create();
+ msg->body.l = gwlist_create();
res = decode_multipart(context, msg->body.l);
} else
msg->body.s = parse_get_rest(context);
@@ -863,7 +892,7 @@ static void mms_pack_well_known_field(Octstr *os, int field_type, Octstr *value)
params = get_value_parameters(cpar);
wsp_pack_text(encoded, cv);
- n = list_len(params);
+ n = gwlist_len(params);
for (i = 0; iheaders, "X-Mms-MMS-Version", MMS_DEFAULT_VERSION);
} else if (octstr_str_compare(ver, "1.2") <= 0)
m->enc = MS_1_2;
-
+ http_header_remove_all(m->headers, "MIME-Version");
if (m->message_type == MMS_MSGTYPE_SEND_REQ ||
m->message_type == MMS_MSGTYPE_RETRIEVE_CONF) {
Octstr *s = NULL;
@@ -1030,7 +1060,8 @@ static int fixup_msg(MmsMsg *m, Octstr *from)
} else
octstr_destroy(s);
}
-
+ strip_boundary_element(m->headers, NULL); /* remove top-level boundary element if any. */
+
return 0;
}
@@ -1053,11 +1084,11 @@ MmsMsg *mms_frombinary(Octstr *msg, Octstr *from)
p = parse_context_create(msg);
mms_strings_init(); /* Just in case. */
- _m.headers = list_create();
+ _m.headers = gwlist_create();
decode_msgheaders(p, _m.headers, from, 1);
if (_m.headers == NULL ||
- list_len(_m.headers) == 0)
+ gwlist_len(_m.headers) == 0)
goto done;
/* Get the message type and also set flag for whether multipart.*/
@@ -1094,7 +1125,7 @@ MmsMsg *mms_frombinary(Octstr *msg, Octstr *from)
MmsMsg *msg = &_m;
if (msg->ismultipart && msg->body.l)
- list_destroy(msg->body.l, (list_item_destructor_t *)mm_destroy);
+ gwlist_destroy(msg->body.l, (gwlist_item_destructor_t *)mime_entity_destroy);
else if (msg->body.s)
octstr_destroy(msg->body.s);
@@ -1108,17 +1139,29 @@ MmsMsg *mms_frombinary(Octstr *msg, Octstr *from)
static void _x_mime_entity_dump(MIMEEntity *x, int level, int headers_only)
{
- int i, n, ism;
-
- ism = (x->multiparts && list_len(x->multiparts) > 0) ? 1 : 0;
- debug("part.dump", 0, "%sMultipart -> ", ism ? "" : "Not ");
- http_header_dump(x->headers);
+ int i,m, ism;
+ List *h;
+ Octstr *body;
+ ism = ((m = mime_entity_num_parts(x)) > 0);
+ debug("part.dump", 0, "%sMultipart -> ", ism ? "" : "Not ");
+
+ h = _x_mime_entity_headers(x);
+ strip_boundary_element(h,NULL);
+ http_header_dump(h);
+ http_destroy_headers(h);
+
if (ism)
- for (i = 0, n = list_len(x->multiparts); imultiparts, i), level+1, headers_only);
- else if (x->body && !headers_only)
- octstr_dump(x->body, level);
+ for (i = 0; i ",
m->ismultipart ? "mulitpart" : "not multipart",
- m->ismultipart ? list_len(m->body.l) : 0);
+ m->ismultipart ? gwlist_len(m->body.l) : 0);
if (m->ismultipart)
- for (i = 0, n = list_len(m->body.l); i< n; i++) {
- MIMEEntity *x = list_get(m->body.l, i);
- debug("mms.dump", 0, "--->Message part: %d --->", i);
-
- _x_mime_entity_dump(x,0,headers_only);
- }
+ for (i = 0, n = gwlist_len(m->body.l); i< n; i++) {
+ MIMEEntity *x = gwlist_get(m->body.l, i);
+ debug("mms.dump", 0, "--->Message part: %d --->", i);
+
+ _x_mime_entity_dump(x,0,headers_only);
+ }
else if (!headers_only)
- octstr_dump(m->body.s, 0);
+ octstr_dump(m->body.s, 0);
}
@@ -1171,8 +1214,9 @@ static void convert_mime_msg(MIMEEntity *m)
int i, n;
Octstr *content_type, *params;
char *s = NULL;
-
- get_content_type(m->headers, &content_type, ¶ms);
+ List *h = _x_mime_entity_headers(m);
+
+ get_content_type(h, &content_type, ¶ms);
if (content_type) {
if (octstr_str_compare(content_type,
@@ -1187,24 +1231,25 @@ static void convert_mime_msg(MIMEEntity *m)
octstr_destroy(content_type);
}
if (s) {
- Octstr *value;
-
- value = (params && octstr_len(params) > 0) ?
- octstr_format("%s; %S", s, params) : octstr_create(s);
-
- http_header_remove_all(m->headers, "Content-Type");
- http_header_add(m->headers, "Content-Type", octstr_get_cstr(value));
+ Octstr *value = (params && octstr_len(params) > 0) ?
+ octstr_format("%s; %S", s, params) : octstr_create(s);
+ http_header_remove_all(h, "Content-Type");
+ http_header_add(h, "Content-Type", octstr_get_cstr(value));
+ mime_replace_headers(m,h);
octstr_destroy(value);
}
-
+ if (h)
+ http_destroy_headers(h);
if (params)
octstr_destroy(params);
- if (m->multiparts)
- for (i = 0, n = list_len(m->multiparts); i < n; i++)
- convert_mime_msg(list_get(m->multiparts, i));
-
+ if ((n = mime_entity_num_parts(m)) > 0)
+ for (i = 0; i < n; i++) {
+ MIMEEntity *x = mime_entity_get_part(m, i);
+ convert_mime_msg(x);
+ mime_entity_replace_part(m, i, x);
+ }
}
static void unconvert_mime_msg(MIMEEntity *m)
@@ -1212,8 +1257,9 @@ static void unconvert_mime_msg(MIMEEntity *m)
int i, n;
Octstr *content_type, *params;
char *s = NULL;
+ List *h = _x_mime_entity_headers(m);
- get_content_type(m->headers, &content_type, ¶ms);
+ get_content_type(h, &content_type, ¶ms);
if (content_type) {
if (octstr_case_compare(content_type,
@@ -1227,35 +1273,21 @@ static void unconvert_mime_msg(MIMEEntity *m)
s = "application/vnd.wap.multipart.mixed";
octstr_destroy(content_type);
}
- if (s) {
- Octstr *value;
- if (params) {
- List *h = get_value_parameters(params);
- Octstr *ps;
- http_header_remove_all(h,"boundary"); /* We don't need the boundary param if it is there. */
- ps = make_value_parameters(h);
-
- value = octstr_format("%s%s%S", s,
- (ps && octstr_len(ps) > 0) ? "; " : "",
- ps);
- octstr_destroy(ps);
- http_destroy_headers(h);
- } else
- value = octstr_create(s);
-
- http_header_remove_all(m->headers, "Content-Type");
- http_header_add(m->headers, "Content-Type", octstr_get_cstr(value));
- octstr_destroy(value);
- }
-
+ if (s)
+ strip_boundary_element(h,s);
+ mime_replace_headers(m, h);
+ http_destroy_headers(h);
+
if (params)
octstr_destroy(params);
- if (m->multiparts && list_len(m->multiparts) > 0)
- for (i = 0, n = list_len(m->multiparts); i < n; i++)
- unconvert_mime_msg(list_get(m->multiparts, i));
-
+ if ((n = mime_entity_num_parts(m)) > 0)
+ for (i = 0; i < n; i++) {
+ MIMEEntity *x = mime_entity_get_part(m, i);
+ unconvert_mime_msg(x);
+ mime_entity_replace_part(m, i, x);
+ }
}
@@ -1267,20 +1299,15 @@ MIMEEntity *mms_tomime(MmsMsg *msg, int base64)
if (!msg)
return NULL;
- m = gw_malloc(sizeof *m);
- memset(m, 0, sizeof *m);
- m->body = NULL;
- m->multiparts = NULL;
- m->start = NULL;
- m->headers = http_header_duplicate(msg->headers);
+ m = mime_entity_create();
+ mime_replace_headers(m, msg->headers);
if (!msg->ismultipart)
- m->body = msg->body.s ? octstr_duplicate(msg->body.s) : NULL;
+ mime_entity_set_body(m, msg->body.s);
else {
- m->multiparts = list_create();
- for (i = 0, n = list_len(msg->body.l); i < n; i++) {
- MIMEEntity *mx = mime_entity_duplicate(list_get(msg->body.l, i));
- list_append(m->multiparts, mx);
+ for (i = 0, n = gwlist_len(msg->body.l); i < n; i++) {
+ MIMEEntity *mx = gwlist_get(msg->body.l, i);
+ mime_entity_add_part(m, mx);
}
}
convert_mime_msg(m);
@@ -1294,29 +1321,34 @@ MmsMsg *mms_frommime(MIMEEntity *mime)
MmsMsg *m;
Octstr *s;
MIMEEntity *mx;
-
+ int n;
+
if (!mime)
return NULL;
m = gw_malloc(sizeof *m);
memset(m, 0, sizeof *m);
+ n = mime_entity_num_parts(mime);
mx = mime_entity_duplicate(mime);
+
unconvert_mime_msg(mx); /* Fix-up content type issues. */
unpack_mimeheaders(mx);
unbase64_mimeparts(mx);
- m->headers = mx->headers;
-
- if (mx->multiparts && list_len(mx->multiparts) > 0) {
+ m->headers = _x_mime_entity_headers(mx);
+ if (n > 0) {
+ int i;
m->ismultipart = 1;
- m->body.l = mx->multiparts;
+ m->body.l = gwlist_create();
+ for (i = 0; i < n; i++)
+ gwlist_append(m->body.l, mime_entity_get_part(mx, i));
} else {
m->ismultipart = 0;
- m->body.s = mx->body ? mx->body : octstr_imm("");
+ m->body.s = mime_entity_body(mx);
}
+ mime_entity_destroy(mx); /* Because all its bits are used above. XXX not very clean! */
- gw_free(mx); /* Because all its bits are used above. XXX not very clean! */
/* Now check for important headers. If missing, put them in */
m->msgId = http_header_value(m->headers, octstr_imm("Message-ID"));
@@ -1385,15 +1417,6 @@ MmsMsg *mms_frommime(MIMEEntity *mime)
return NULL;
}
-static void mm_destroy(MIMEEntity *mx)
-{
- http_destroy_headers(mx->headers);
- if (mx->body)
- octstr_destroy(mx->body);
- else if (mx->multiparts)
- list_destroy(mx->multiparts, (list_item_destructor_t *)mm_destroy);
- gw_free(mx);
-}
void mms_destroy(MmsMsg *msg)
{
@@ -1401,7 +1424,7 @@ void mms_destroy(MmsMsg *msg)
if (!msg)
return;
if (msg->ismultipart)
- list_destroy(msg->body.l, (list_item_destructor_t *)mm_destroy);
+ gwlist_destroy(msg->body.l, (gwlist_item_destructor_t *)mime_entity_destroy);
else if (msg->body.s)
octstr_destroy(msg->body.s);
http_destroy_headers(msg->headers);
@@ -1596,11 +1619,11 @@ MmsMsg *mms_retrieveconf(MmsMsg *msg, Octstr *transactionid,
else
/* Body is a list of MIMEEntities, so recreate it. */
- for (m->body.l = list_create(), i = 0,
- n = list_len(msg->body.l);
+ for (m->body.l = gwlist_create(), i = 0,
+ n = gwlist_len(msg->body.l);
ibody.l,
- mime_entity_duplicate(list_get(msg->body.l, i)));
+ gwlist_append(m->body.l,
+ mime_entity_duplicate(gwlist_get(msg->body.l, i)));
/* Remove some headers that may not be permitted. */
mms_remove_headers(m, "X-Mms-Expiry");
mms_remove_headers(m, "X-Mms-Delivery-Time");
@@ -1694,8 +1717,8 @@ int mms_replace_header_values(MmsMsg *msg, char *hname, List *value)
gw_assert(msg);
http_header_remove_all(msg->headers, hname);
- for (i = 0; i < list_len(value); i++) {
- Octstr *x = list_get(value, i);
+ for (i = 0; i < gwlist_len(value); i++) {
+ Octstr *x = gwlist_get(value, i);
http_header_add(msg->headers, hname, octstr_get_cstr(x));
}
return 0;
@@ -1716,14 +1739,14 @@ List *mms_get_header_values(MmsMsg *msg, Octstr *header)
int i;
gw_assert(msg);
- l = list_create();
+ l = gwlist_create();
h = http_header_find_all(msg->headers, octstr_get_cstr(header));
- for (i = 0; i < list_len(h); i++) {
+ for (i = 0; i < gwlist_len(h); i++) {
Octstr *hname, *value;
http_header_get(h, i, &hname, &value);
- list_append(l, value);
+ gwlist_append(l, value);
octstr_destroy(hname);
}
http_destroy_headers(h);
@@ -1836,8 +1859,8 @@ static int mms_convert_to_mboxdescr(MmsMsg *mm, Octstr *cloc, List *reqhdrs,
http_header_add(mh, "X-Mms-Content-Location", octstr_get_cstr(cloc));
/* Add only those headers requested. */
- for (i = 0, n = list_len(reqhdrs); i < n; i++) {
- Octstr *header = list_get(reqhdrs,i);
+ for (i = 0, n = gwlist_len(reqhdrs); i < n; i++) {
+ Octstr *header = gwlist_get(reqhdrs,i);
List *h = http_header_find_all(mm->headers, octstr_get_cstr(header));
int j;
@@ -1853,7 +1876,7 @@ static int mms_convert_to_mboxdescr(MmsMsg *mm, Octstr *cloc, List *reqhdrs,
} else if (octstr_case_compare(header, octstr_imm("Message-ID")) == 0)
hasmsgid = 1;
- for (j = 0; j < list_len(h); j++) {
+ for (j = 0; j < gwlist_len(h); j++) {
Octstr *hname, *value;
http_header_get(h, j, &hname, &value);
octstr_destroy(hname);
@@ -1892,7 +1915,7 @@ static int mms_convert_to_mboxdescr(MmsMsg *mm, Octstr *cloc, List *reqhdrs,
if (!addcontent) {
if (mm->ismultipart)
- list_destroy(mm->body.l, (list_item_destructor_t *)mm_destroy);
+ gwlist_destroy(mm->body.l, (gwlist_item_destructor_t *)mime_entity_destroy);
else if (mm->body.s)
octstr_destroy(mm->body.s);
mm->body.s = NULL;
@@ -1956,15 +1979,15 @@ MmsMsg *mms_viewconf(char *transid,
msize = mms_msgsize(m);
- n = list_len(msgrefs);
+ n = gwlist_len(msgrefs);
msgcount = 0;
m->ismultipart = 1;
- m->body.l = list_create();
+ m->body.l = gwlist_create();
for (i = 0; i < n; i++) {
unsigned long tmsize;
- Octstr *msgref = list_get(msgrefs,i);
- Octstr *msgloc = list_get(msglocs, i);
+ Octstr *msgref = gwlist_get(msgrefs,i);
+ Octstr *msgloc = gwlist_get(msglocs, i);
MmsMsg *mm = getmsg(p1, p2, msgref, &tmsize);
Octstr *ms;
@@ -1976,12 +1999,16 @@ MmsMsg *mms_viewconf(char *transid,
ms = mms_tobinary(mm);
if (octstr_len(ms) + msize <= maxsize) {
MIMEEntity *mtmp = mime_entity_create();
+ List *h = _x_mime_entity_headers(mtmp);
- http_header_add(mtmp->headers, "Content-Type",
+ http_header_add(h, "Content-Type",
"application/vnd.wap.mms-message");
- mtmp->body = ms;
+ mime_replace_headers(mtmp, h);
+ mime_entity_set_body(mtmp, ms);
+
+ http_destroy_headers(h);
- list_append(m->body.l, mtmp);
+ gwlist_append(m->body.l, mtmp);
msgcount++;
msize += octstr_len(ms);
} else {
@@ -1994,13 +2021,13 @@ MmsMsg *mms_viewconf(char *transid,
loop:(void)0;
}
- if (list_len(m->body.l) > 0) {
+ if (gwlist_len(m->body.l) > 0) {
char x[32];
- sprintf(x, "%d", (int)list_len(m->body.l));
+ sprintf(x, "%d", (int)gwlist_len(m->body.l));
mms_replace_header_value(m, "X-Mms-Message-Count", x);
mms_replace_header_value(m, "Content-Type", "application/vnd.wap.multipart.mixed");
} else {
- list_destroy(m->body.l,NULL);
+ gwlist_destroy(m->body.l,NULL);
m->body.s = NULL;
m->ismultipart = 0;
}
@@ -2014,11 +2041,11 @@ void *mms_msgbody(MmsMsg *msg)
return NULL;
if (msg->ismultipart) {
- List *l = list_create();
+ List *l = gwlist_create();
int i;
- for (i = 0; i < list_len(msg->body.l); i++)
- list_append(l, mime_entity_duplicate(list_get(msg->body.l,i)));
+ for (i = 0; i < gwlist_len(msg->body.l); i++)
+ gwlist_append(l, mime_entity_duplicate(gwlist_get(msg->body.l,i)));
return l;
} else
return octstr_duplicate(msg->body.s);
@@ -2030,7 +2057,7 @@ int mms_clearbody(MmsMsg *msg)
return -1;
if (msg->ismultipart)
- list_destroy(msg->body.l, (list_item_destructor_t *)mm_destroy);
+ gwlist_destroy(msg->body.l, (gwlist_item_destructor_t *)mime_entity_destroy);
else if (msg->body.s)
octstr_destroy(msg->body.s);
msg->body.s = NULL;
diff --git a/mbuni/mmlib/mms_queue.c b/mbuni/mmlib/mms_queue.c
index 8b145a3..95f0b3a 100644
--- a/mbuni/mmlib/mms_queue.c
+++ b/mbuni/mmlib/mms_queue.c
@@ -151,13 +151,13 @@ MmsEnvelope *mms_queue_readenvelope(char *qf, char *mms_queuedir, int shouldbloc
int okfile = 0;
char subdir[64];
char realqf[QFNAMEMAX];
- char *xqf = NULL;
+ char xqf[QFNAMEMAX+64];
get_subdir(qf, subdir, realqf); /* break it down... */
fname = octstr_format( "%.128s/%s%s", mms_queuedir, subdir, realqf);
- xqf = octstr_get_cstr(fname);
+ strncpy(xqf, octstr_get_cstr(fname), sizeof xqf);
if ((fd = open(octstr_get_cstr(fname), O_RDONLY)) < 0) {
octstr_destroy(fname);
@@ -171,7 +171,7 @@ MmsEnvelope *mms_queue_readenvelope(char *qf, char *mms_queuedir, int shouldbloc
e = gw_malloc(sizeof *e);
memset(e, 0, sizeof *e); /* Clear it all .*/
- e->to = list_create();
+ e->to = gwlist_create();
e->qf.fd = fd;
strncpy(e->qf.name, realqf, sizeof e->qf.name);
strncpy(e->qf.subdir, subdir, sizeof e->qf.subdir);
@@ -226,7 +226,7 @@ MmsEnvelope *mms_queue_readenvelope(char *qf, char *mms_queuedir, int shouldbloc
to = gw_malloc(sizeof *to);
to->rcpt = t;
to->process = 1;
- list_append(e->to, to);
+ gwlist_append(e->to, to);
break;
case 'C':
e->created = atol(res);
@@ -379,19 +379,19 @@ static int writeenvelope(MmsEnvelope *e, int newenv)
_putline(fd, "F", octstr_get_cstr(e->from));
if (e->to)
- n = list_len(e->to);
+ n = gwlist_len(e->to);
else
n = 0;
for (i = 0; i < n; i++) {
- MmsEnvelopeTo *to = list_get(e->to, i);
+ MmsEnvelopeTo *to = gwlist_get(e->to, i);
if (to->process)
_putline(fd, "R", octstr_get_cstr(to->rcpt));
}
/* Output headers if any. */
- n = (e->hdrs) ? list_len(e->hdrs) : 0;
+ n = (e->hdrs) ? gwlist_len(e->hdrs) : 0;
for (i = 0; i < n; i++) {
Octstr *h = NULL, *v = NULL;
@@ -666,7 +666,7 @@ Octstr *mms_queue_add(Octstr *from, List *to,
char qf[QFNAMEMAX], subdir[64];
int fd, i, n;
MmsEnvelope *e;
- Octstr *msgid, *s = NULL, *r = NULL;
+ Octstr *msgid, *r = NULL;
Octstr *ms, *res = NULL, *xfrom = NULL;
int mtype;
fd = mkqf(qf, subdir, directory);
@@ -710,7 +710,7 @@ Octstr *mms_queue_add(Octstr *from, List *to,
e->fromproxy = fromproxy;
e->viaproxy = viaproxy;
e->subject = subject;
- e->to = list_create();
+ e->to = gwlist_create();
e->msize = octstr_len(ms);
e->msgId = msgid;
e->token = token;
@@ -723,22 +723,16 @@ Octstr *mms_queue_add(Octstr *from, List *to,
e->dlr = dlr;
e->bill.billed = 0;
- /* Insert message ID into message if it is missing. */
- if (mms_messagetype(m) == MMS_MSGTYPE_SEND_REQ &&
- (s = mms_get_header_value(m, octstr_imm("Message-ID"))) == NULL)
- mms_replace_header_value(m, "Message-ID", octstr_get_cstr(msgid));
- else if (s)
- octstr_destroy(s);
- for (i = 0, n = to ? list_len(to) : 0; ircpt = r;
t->process = 1;
- list_append(e->to, t);
+ gwlist_append(e->to, t);
}
/* Write queue data. */
@@ -763,12 +757,12 @@ Octstr *mms_queue_add(Octstr *from, List *to,
done:
/* Free the envelope stuff since we do not need it any more, then free 'e' */
- for (i = 0, n = list_len(e->to); ito, i);
+ for (i = 0, n = gwlist_len(e->to); ito, i);
octstr_destroy(to->rcpt);
gw_free(to);
}
- list_destroy(e->to, NULL);
+ gwlist_destroy(e->to, NULL);
gw_free(e); /* Free struct only, caller responsible for arguments. */
@@ -788,13 +782,13 @@ static int free_envelope(MmsEnvelope *e, int removefromqueue)
if (e->msgId)
octstr_destroy(e->msgId);
- for (i = 0, n = list_len(e->to); i < n; i++) {
- MmsEnvelopeTo *x = list_get(e->to, i);
+ for (i = 0, n = gwlist_len(e->to); i < n; i++) {
+ MmsEnvelopeTo *x = gwlist_get(e->to, i);
octstr_destroy(x->rcpt);
gw_free(x);
}
- list_destroy(e->to, NULL);
+ gwlist_destroy(e->to, NULL);
if (e->from)
octstr_destroy(e->from);
@@ -849,14 +843,16 @@ int mms_queue_free_env(MmsEnvelope *e)
}
int mms_queue_update(MmsEnvelope *e)
{
- int i, n = (e && e->to) ? list_len(e->to) : 0;
+ int i, n = (e && e->to) ? gwlist_len(e->to) : 0;
int hasrcpt = 0;
MmsEnvelopeTo *x;
if (!e) return -1;
-
+ /* FIX: Don't allow expiry to be <= 0 */
+ if (e->expiryt <= 0)
+ e->expiryt = time(NULL) + DEFAULT_EXPIRE;
for (i = 0; i < n; i++)
- if ((x = list_get(e->to, i)) != NULL &&
+ if ((x = gwlist_get(e->to, i)) != NULL &&
x->process) {
hasrcpt = 1;
break;
@@ -941,15 +937,16 @@ static void tdeliver(struct Qthread_t *qt)
{
MmsEnvelope *e;
- while ((e = list_consume(qt->l)) != NULL) {
- int res = qt->deliver(e); /* If it is on the queue, it has to be delivered. */
-
+ while ((e = gwlist_consume(qt->l)) != NULL) {
+ int res;
+ res = qt->deliver(e); /* If it is on the queue, it has to be delivered. */
+
if (res != 1) /* Then delete as it wasn't deleted. */
free_envelope(e, 0);
}
/* Consume failed, time to go away. */
if (qt->l)
- list_destroy(qt->l, NULL);
+ gwlist_destroy(qt->l, NULL);
qt->l = NULL; /* Signal that we are gone. */
}
@@ -963,7 +960,7 @@ static int run_dir(char *topdir, char *dir, struct Qthread_t *tlist, int num_thr
{
DIR *dirp;
struct dirent *dp;
- time_t tnow = time(NULL);
+
Octstr *tdir = octstr_format("%s/%s", topdir, dir);
char *xdir = octstr_get_cstr(tdir);
int ret = 0;
@@ -981,7 +978,8 @@ static int run_dir(char *topdir, char *dir, struct Qthread_t *tlist, int num_thr
struct stat st;
Octstr *xfname = octstr_format("%s%s", xdir, dp->d_name);
int sres = stat(octstr_get_cstr(xfname), &st);
-
+ time_t tnow = time(NULL);
+
octstr_destroy(xfname);
if (sres == 0 && S_ISREG(st.st_mode) &&
@@ -1000,9 +998,9 @@ static int run_dir(char *topdir, char *dir, struct Qthread_t *tlist, int num_thr
int j = *i; /* This is the next thread to use. Checking for cycles. */
do {
if (tlist[*i].l) {
- debug("queuerun", 0, "Queued to thread %d for %s%s",
- *i, xdir, dp->d_name);
- list_produce(tlist[*i].l, e);
+ debug("queuerun", 0, "Queued to thread %d for %s%s, sendt=%d, tnow=%d",
+ *i, xdir, dp->d_name, (int)e->sendt, (int)tnow);
+ gwlist_produce(tlist[*i].l, e);
queued = 1;
}
*i = (*i+1)%num_threads;
@@ -1022,7 +1020,7 @@ static int run_dir(char *topdir, char *dir, struct Qthread_t *tlist, int num_thr
strcmp(dp->d_name, ".") != 0 &&
strcmp(dp->d_name, "..") != 0) {
Octstr *newdir = octstr_format("%s%s/", dir, dp->d_name);
- list_append(stack, newdir); /* push it... */
+ gwlist_append(stack, newdir); /* push it... */
}
}
if (dirp) closedir(dirp);
@@ -1038,15 +1036,15 @@ void mms_queue_run(char *dir,
{
struct Qthread_t *tlist;
int i, qstop = 0;
- List *stack = list_create();
+ List *stack = gwlist_create();
gw_assert(num_threads>0);
tlist = gw_malloc(num_threads*sizeof tlist[0]);
for (i = 0; iversions)
- list_destroy(prof->versions,
- (list_item_destructor_t *)octstr_destroy);
+ gwlist_destroy(prof->versions,
+ (gwlist_item_destructor_t *)octstr_destroy);
if (prof->ccppaccept.content) {
- list_destroy(prof->ccppaccept.content, (list_item_destructor_t *)octstr_destroy);
- list_destroy(prof->ccppaccept._hash, NULL);
+ gwlist_destroy(prof->ccppaccept.content, (gwlist_item_destructor_t *)octstr_destroy);
+ gwlist_destroy(prof->ccppaccept._hash, NULL);
}
if (prof->ccppaccept.charset) {
- list_destroy(prof->ccppaccept.charset, (list_item_destructor_t *)octstr_destroy);
- list_destroy(prof->ccppaccept._chash, NULL);
+ gwlist_destroy(prof->ccppaccept.charset, (gwlist_item_destructor_t *)octstr_destroy);
+ gwlist_destroy(prof->ccppaccept._chash, NULL);
} if (prof->ccppaccept.lang)
- list_destroy(prof->ccppaccept.lang, (list_item_destructor_t *)octstr_destroy);
+ gwlist_destroy(prof->ccppaccept.lang, (gwlist_item_destructor_t *)octstr_destroy);
if (prof->ccppaccept.enc)
- list_destroy(prof->ccppaccept.enc, (list_item_destructor_t *)octstr_destroy);
+ gwlist_destroy(prof->ccppaccept.enc, (gwlist_item_destructor_t *)octstr_destroy);
gw_free(prof);
}
@@ -88,37 +88,37 @@ static void dump_profile(MmsUaProfile *prof, Octstr *name)
s = octstr_create("");
if (prof->ccppaccept.content)
- for (i=0; iccppaccept.content); i++)
- octstr_format_append(s, "%S, ", list_get(prof->ccppaccept.content,i));
+ for (i=0; iccppaccept.content); i++)
+ octstr_format_append(s, "%S, ", gwlist_get(prof->ccppaccept.content,i));
debug("mms.uaprof", 0, "Accept content: %s", octstr_get_cstr(s));
octstr_destroy(s);
s = octstr_create("");
if (prof->ccppaccept.enc)
- for (i=0; iccppaccept.enc); i++)
- octstr_format_append(s, "%S, ", list_get(prof->ccppaccept.enc,i));
+ for (i=0; iccppaccept.enc); i++)
+ octstr_format_append(s, "%S, ", gwlist_get(prof->ccppaccept.enc,i));
debug("mms.uaprof", 0, "Accept encodings: %s", octstr_get_cstr(s));
octstr_destroy(s);
s = octstr_create("");
if (prof->ccppaccept.lang)
- for (i=0; iccppaccept.lang); i++)
- octstr_format_append(s, "%S, ", list_get(prof->ccppaccept.lang,i));
+ for (i=0; iccppaccept.lang); i++)
+ octstr_format_append(s, "%S, ", gwlist_get(prof->ccppaccept.lang,i));
debug("mms.uaprof", 0, "Accept language: %s", octstr_get_cstr(s));
octstr_destroy(s);
s = octstr_create("");
if (prof->ccppaccept.charset)
- for (i=0; iccppaccept.charset); i++)
- octstr_format_append(s, "%S, ", list_get(prof->ccppaccept.charset,i));
+ for (i=0; iccppaccept.charset); i++)
+ octstr_format_append(s, "%S, ", gwlist_get(prof->ccppaccept.charset,i));
debug("mms.uaprof", 0, "Accept charset: %s", octstr_get_cstr(s));
octstr_destroy(s);
s = octstr_create("");
if (prof->versions)
- for (i=0; iversions); i++)
- octstr_format_append(s, "%S, ", list_get(prof->versions,i));
+ for (i=0; iversions); i++)
+ octstr_format_append(s, "%S, ", gwlist_get(prof->versions,i));
debug("mms.uaprof", 0, "Mms Version: %s", octstr_get_cstr(s));
octstr_destroy(s);
@@ -192,19 +192,19 @@ MmsUaProfile *mms_make_ua_profile(List *req_headers)
prof->maxres.x = 640;
prof->maxres.y = 480;
prof->maxmsgsize = 100*1024;
- prof->versions = list_create();
+ prof->versions = gwlist_create();
- list_append(prof->versions, octstr_imm("1.0")); /* Assume 1.0 for now. */
+ gwlist_append(prof->versions, octstr_imm("1.0")); /* Assume 1.0 for now. */
/* Get accepted charsets. */
s = http_header_value(req_headers, octstr_imm("Accept-Charset"));
if (s && (l = http_header_split_value(s)) != NULL) {
prof->ccppaccept.charset = l;
- prof->ccppaccept._chash = list_create();
- for (i = 0, n = list_len(l); iccppaccept._chash, (void *)hash_key(list_get(l, i)));
+ prof->ccppaccept._chash = gwlist_create();
+ for (i = 0, n = gwlist_len(l); iccppaccept._chash, (void *)hash_key(gwlist_get(l, i)));
}
if (s) octstr_destroy(s);
@@ -229,16 +229,16 @@ MmsUaProfile *mms_make_ua_profile(List *req_headers)
s = http_header_value(req_headers, octstr_imm("Accept"));
if (s && (l = http_header_split_value(s)) != NULL) {
prof->ccppaccept.content = l;
- prof->ccppaccept._hash = list_create();
+ prof->ccppaccept._hash = gwlist_create();
- for (i = 0, n = l ? list_len(l) : 0; iccppaccept.all = 1;
else if (octstr_case_compare(x, octstr_imm(PRES_TYPE)) == 0)
prof->ccppaccept.presentation = 1;
- list_append(prof->ccppaccept._hash, (void *)hash_key(x));
+ gwlist_append(prof->ccppaccept._hash, (void *)hash_key(x));
}
}
@@ -295,12 +295,12 @@ static MmsUaProfile *parse_uaprofile(Octstr *xml)
/* If there is a Bag, get the list. */
if ((rdfnode = find_node(xnode->xmlChildrenNode, "Bag", NULL,0,1)) != NULL) {
- l = list_create();
+ l = gwlist_create();
for (lnode = rdfnode->xmlChildrenNode; lnode; lnode = lnode->next)
if (xmlStrcasecmp(lnode->name, (const xmlChar *)"li") == 0) {
unsigned char *t = xmlNodeListGetString(doc, lnode->xmlChildrenNode,1);
if (t) {
- list_append(l, octstr_create((char *)t));
+ gwlist_append(l, octstr_create((char *)t));
xmlFree(t);
}
}
@@ -315,32 +315,32 @@ static MmsUaProfile *parse_uaprofile(Octstr *xml)
xmlStrcasecmp(xname, (const xmlChar *)"MmsCcppAccept-CharSet") == 0) {/* Cranky old ones! */
int i, n;
prof->ccppaccept.charset = l;
- prof->ccppaccept._chash = list_create();
- for (i = 0, n = list_len(l); iccppaccept._chash, (void *)hash_key(list_get(l, i)));
+ prof->ccppaccept._chash = gwlist_create();
+ for (i = 0, n = gwlist_len(l); iccppaccept._chash, (void *)hash_key(gwlist_get(l, i)));
} else if (xmlStrcasecmp(xname, (const xmlChar *)"MmsCcppAcceptLanguage") == 0)
prof->ccppaccept.lang = l;
else if (xmlStrcasecmp(xname, (const xmlChar *)"MmsCcppAcceptEncoding") == 0)
prof->ccppaccept.enc = l;
else if (xmlStrcasecmp(xname, (const xmlChar *)"MmsVersion") == 0) {
if (!l && childtext) { /* SonyEriccson uses old format! */
- l = list_create();
- list_append(l, octstr_create((char *)childtext));
+ l = gwlist_create();
+ gwlist_append(l, octstr_create((char *)childtext));
}
prof->versions = l;
} else if (xmlStrcasecmp(xname, (const xmlChar *)"MmsCcppAccept") == 0) {
int i, n;
prof->ccppaccept.content = l;
- prof->ccppaccept._hash = list_create();
+ prof->ccppaccept._hash = gwlist_create();
- for (i = 0, n = l ? list_len(l) : 0; iccppaccept.all = 1;
else if (octstr_case_compare(x, octstr_imm(PRES_TYPE)) == 0)
prof->ccppaccept.presentation = 1;
- list_append(prof->ccppaccept._hash, (void *)hash_key(x));
+ gwlist_append(prof->ccppaccept._hash, (void *)hash_key(x));
}
}
if (childtext) xmlFree(childtext);
@@ -439,7 +439,7 @@ static MmsUaProfile *profile_fetch(Octstr *profile_url)
http_header_add(h, "User-Agent", MM_NAME "/" MMSC_VERSION);
status = http_get_real(HTTP_METHOD_GET, profile_url, h, &final_url, &rh, &body);
- if (status == HTTP_OK) {
+ if (http_status_class(status) == HTTP_STATUS_SUCCESSFUL) {
prof = parse_uaprofile(body);
debug("mms.uaprof", 0, "Fetcher got %s", octstr_get_cstr(profile_url));
@@ -591,12 +591,19 @@ static void init_format_table(void)
/* Removes an object by making it text/plain. For now not configurable. */
static void remove_object(MIMEEntity *m, Octstr *ctype)
{
- http_header_remove_all(m->headers, "Content-Type");
-
- http_header_add(m->headers, "Content-Type", "text/plain");
+ List *h = _x_mime_entity_headers(m);
+ Octstr *s = octstr_format("Unsupported object (content type %S) removed", ctype);
- octstr_destroy(m->body);
- m->body = octstr_format("Unsupported object (content type %S) removed", ctype);
+ http_header_remove_all(h, "Content-Type");
+ http_header_add(h, "Content-Type", "text/plain");
+
+ mime_replace_headers(m, h);
+ http_destroy_headers(h);
+
+ while (mime_entity_num_parts(m) > 0) /* Delete all parts, if any. */
+ mime_entity_remove_part(m, 0);
+ mime_entity_set_body(m, s);
+ octstr_destroy(s);
}
static void mktmpfname(char fname[])
@@ -627,7 +634,7 @@ static Octstr *mknewname(Octstr *oldname, char *ext)
static void replace_ctype(List *headers, char *newcontent_type, List *params_h)
{
Octstr *ct;
- if (list_len(params_h) > 0) {
+ if (gwlist_len(params_h) > 0) {
Octstr *tmp = make_value_parameters(params_h);
ct = octstr_format("%s; %S", newcontent_type, tmp);
octstr_destroy(tmp);
@@ -645,10 +652,11 @@ static void replace_body(MIMEEntity *msg, Octstr *newbody, List *params_h,
{
Octstr *part_name;
Octstr *new_partname = NULL;
-
- octstr_destroy(msg->body); /* Replace the body. */
- msg->body = newbody;
-
+ List *h = _x_mime_entity_headers(msg);
+
+ mime_entity_set_body(msg, newbody); /* Replace the body. */
+ octstr_destroy(newbody);
+
if ((part_name = http_header_value(params_h, octstr_imm("name"))) != NULL) {
Octstr *tmp = mknewname(part_name, file_ext);
http_header_remove_all(params_h, "name");
@@ -658,15 +666,16 @@ static void replace_body(MIMEEntity *msg, Octstr *newbody, List *params_h,
new_partname = tmp;
}
- replace_ctype(msg->headers, newcontent_type, params_h);
+ replace_ctype(h, newcontent_type, params_h);
if (add_disposition_header) {
Octstr *tmp = octstr_format("inline; filename=\"%S\"",
new_partname ? new_partname : octstr_imm("any"));
- http_header_add(msg->headers, "Content-Disposition", octstr_get_cstr(tmp));
+ http_header_add(h, "Content-Disposition", octstr_get_cstr(tmp));
octstr_destroy(tmp);
}
-
+ mime_replace_headers(msg,h);
+ http_destroy_headers(h);
if (new_partname) octstr_destroy(new_partname);
}
@@ -688,45 +697,51 @@ static int modify_msg(MIMEEntity *msg, MmsUaProfile *prof)
FILE *pf;
char tmpf[40], tmpf2[40];
Octstr *cmd = NULL;
+ List *h = NULL;
if (!msg) return 0;
tmpf[0] = tmpf2[0] = 0; /* Clear .*/
/* Get the content type, hash it. */
-
- get_content_type(msg->headers, &content_type, ¶ms);
+ h = _x_mime_entity_headers(msg);
+ get_content_type(h, &content_type, ¶ms);
params_h = get_value_parameters(params);
-
+
#if 0
- debug("MMS uaprof:", 0, " content_type = ### %s & %s: Header dump follows:",
- octstr_get_cstr(content_type), params ? octstr_get_cstr(params) : "NULL");
- http_header_dump(params_h);
+ debug("MMS uaprof:", 0, " content_type = ### %s & %s: Header dump follows:",
+ octstr_get_cstr(content_type), params ? octstr_get_cstr(params) : "NULL");
+ http_header_dump(params_h);
#endif
- if (msg->multiparts && list_len(msg->multiparts) > 0) {
+ if ((n = mime_entity_num_parts(msg)) > 0) {
Octstr *startp = http_header_value(params_h, octstr_imm("start"));
int sflag = 0;
-
- for (i = 0, n = list_len(msg->multiparts); imultiparts,i);
- Octstr *cid = http_header_value(x->headers, octstr_imm("Content-ID"));
+
+ for (i = 0; iheaders, "multipart/mixed", params_h);
+
+ replace_ctype(h, "multipart/mixed", params_h);
}
if (startp) octstr_destroy(startp);
-
+
supported = 1;
goto done;
}
@@ -769,21 +784,21 @@ static int modify_msg(MIMEEntity *msg, MmsUaProfile *prof)
charset = octstr_imm(DEFAULT_CHARSET);
}
- n = prof->ccppaccept.charset ? list_len(prof->ccppaccept.charset) : 0;
+ n = prof->ccppaccept.charset ? gwlist_len(prof->ccppaccept.charset) : 0;
/* Is this character set supported? If so do nothing. */
for (i = 0; iccppaccept.charset,i), charset) == 0) {
+ if (octstr_case_compare(gwlist_get(prof->ccppaccept.charset,i), charset) == 0) {
csupport = 1;
break;
}
if (!csupport)
for (i = 0; iccppaccept.charset,i); /* Don't free this! */
+ Octstr *ncharset = gwlist_get(prof->ccppaccept.charset,i); /* Don't free this! */
Octstr *ct;
-
- if (charset_convert(msg->body, octstr_get_cstr(charset),
+ Octstr *s = mime_entity_body(msg);
+ if (charset_convert(s, octstr_get_cstr(charset),
octstr_get_cstr(ncharset)) != -1) { /* using libiconv...*/
Octstr *tmp;
@@ -793,12 +808,14 @@ static int modify_msg(MIMEEntity *msg, MmsUaProfile *prof)
ct = octstr_format("%S; %S", content_type, tmp);
octstr_destroy(tmp);
- http_header_remove_all(msg->headers, "Content-Type");
- http_header_add(msg->headers, "Content-Type", octstr_get_cstr(ct));
+ http_header_remove_all(h, "Content-Type");
+ http_header_add(h, "Content-Type", octstr_get_cstr(ct));
octstr_destroy(ct);
+ mime_entity_set_body(msg,s); /* replace with new body. */
break; /* We succeeded in converting it so we shd go away. */
- }
+ } else
+ octstr_destroy(s);
}
octstr_destroy(charset);
@@ -811,10 +828,10 @@ static int modify_msg(MIMEEntity *msg, MmsUaProfile *prof)
if (prof->ccppaccept.all) /* Check if it accepts all content types. */
supported = 1;
else
- for (i = 0, n = prof->ccppaccept.content ? list_len(prof->ccppaccept.content) : 0;
+ for (i = 0, n = prof->ccppaccept.content ? gwlist_len(prof->ccppaccept.content) : 0;
iccppaccept._hash,i) == chash &&
- octstr_case_compare(list_get(prof->ccppaccept.content,i),content_type) == 0) {
+ if ((unsigned long)gwlist_get(prof->ccppaccept._hash,i) == chash &&
+ octstr_case_compare(gwlist_get(prof->ccppaccept.content,i),content_type) == 0) {
supported = 1;
break;
}
@@ -847,10 +864,10 @@ static int modify_msg(MIMEEntity *msg, MmsUaProfile *prof)
oindex = -1;
for (i = 0; i < NELEMS(cformats); i++)
if (cformats[i].fromstandard_cmd) /* Check only ones we can convert from. */
- for (j = 0, m = list_len(prof->ccppaccept.content); jccppaccept._hash,j) == cformats[i].chash &&
+ for (j = 0, m = gwlist_len(prof->ccppaccept.content); jccppaccept._hash,j) == cformats[i].chash &&
cformats[i].t == type && /* Convert to like type ! */
- octstr_case_compare(list_get(prof->ccppaccept.content,j),
+ octstr_case_compare(gwlist_get(prof->ccppaccept.content,j),
octstr_imm(cformats[i].content_type)) == 0){
oindex = i;
i = NELEMS(cformats); /* So the other loop breaks too. */
@@ -858,18 +875,16 @@ static int modify_msg(MIMEEntity *msg, MmsUaProfile *prof)
}
- if (iindex < 0 || oindex < 0) { /* We don't know how to convert this one fully, so... */
- if (!supported)
- remove_object(msg, content_type);
- goto done;
- }
+ if (iindex < 0 || oindex < 0) /* We don't know how to convert this one fully, so... */
+ goto done2; /* go away, don't even replace headers. */
+
/* Whatever we have (audio or image) we know how to convert it fully, so ... */
mktmpfname(tmpf);
if (type == TIMAGE) {
FILE *pf;
long x = 640, y = 480;
- Octstr *icmd;
+ Octstr *icmd, *s;
char *selector;
mktmpfname(tmpf2);
@@ -877,9 +892,11 @@ static int modify_msg(MIMEEntity *msg, MmsUaProfile *prof)
if (!pf)
goto done;
- n = octstr_print(pf, msg->body);
+ s = mime_entity_body(msg);
+ n = octstr_print(pf, s);
m = fclose(pf);
-
+
+ octstr_destroy(s);
if (n < 0 || m != 0)
goto done; /* error .*/
@@ -918,7 +935,7 @@ static int modify_msg(MIMEEntity *msg, MmsUaProfile *prof)
cformats[oindex].file_ext, tmpf);
octstr_destroy(icmd);
} else
- cmd = octstr_format("cat %S | " IMGCONVERTCMD,
+ cmd = octstr_format("cat %s | " IMGCONVERTCMD,
tmpf2, cformats[iindex].file_ext, selector,
cformats[oindex].file_ext, tmpf);
@@ -935,29 +952,35 @@ static int modify_msg(MIMEEntity *msg, MmsUaProfile *prof)
if (!pf)
goto done;
- if (send_data) /* If this is not set then write the content... */
- n = octstr_print(pf, msg->body);
- else
+ if (send_data) { /* If this is not set then write the content... */
+ Octstr *sx = mime_entity_body(msg);
+ n = octstr_print(pf, sx);
+ octstr_destroy(sx);
+ } else
n = 0;
m = pclose(pf);
-
if (n < 0 || m != 0)
goto done; /* Error -- finish up. */
- s = octstr_read_file(tmpf);
- if (s)
+ if ((s = octstr_read_file(tmpf)) != NULL) {
replace_body(msg, s, params_h,
cformats[oindex].content_type,
cformats[oindex].file_ext,0);
- else
+ supported = 1;
+ goto done2; /* we are done, don't even change headers. */
+ } else /* failed to convert, hence unsupported. */
goto done;
-
- supported = 1; /* Means we have sorted it out. */
-
+
done:
+ if (h)
+ mime_replace_headers(msg,h);
+ done2:
if (!supported)
remove_object(msg, content_type);
+ if (h)
+ http_destroy_headers(h);
+
if (content_type)
octstr_destroy(content_type);
if (params)
@@ -1023,66 +1046,71 @@ static int format_special(MIMEEntity *m,
char tmpf[40];
Octstr *cmd = NULL;
List *params_h;
+ List *headers;
tmpf[0] = 0;
- get_content_type(m->headers, &content_type, ¶ms);
+ headers = _x_mime_entity_headers(m);
+ get_content_type(headers, &content_type, ¶ms);
params_h = get_value_parameters(params);
- if (m->multiparts && list_len(m->multiparts) > 0) {
- MIMEEntity *pres = NULL;
+ if ((n = mime_entity_num_parts(m)) > 0) {
int presindex = -1;
Octstr *presbody;
Octstr *start = http_header_value(params_h, octstr_imm("start"));
- for (i = 0, n = list_len(m->multiparts); imultiparts,i);
+ for (i = 0; iheaders, octstr_imm("Content-ID"));
+ List *hx = _x_mime_entity_headers(x);
+ Octstr *cid = _x_get_content_id(hx);
- http_header_get_content_type(x->headers, &ctype, &charset);
+ http_header_get_content_type(hx, &ctype, &charset);
/* Find presentation part: If we have start param, and it matches
* this one, and this one is SMIL, then...
*/
if (start && cid && octstr_compare(cid, start) == 0 &&
- octstr_case_compare(ctype, octstr_imm(PRES_TYPE)) == 0) {
- pres = x;
+ octstr_case_compare(ctype, octstr_imm(PRES_TYPE)) == 0)
presindex = i;
- }
+
if (ctype) octstr_destroy(ctype);
if (charset) octstr_destroy(charset);
if (cid) octstr_destroy(cid);
format_special(x, trans_smil, txtmsg, htmlmsg, counter);
+ mime_entity_replace_part(m, i, x);
+ http_destroy_headers(hx);
+ mime_entity_destroy(x);
}
if (start) octstr_destroy(start);
- if (trans_smil && pres) { /* Reformat. */
- MIMEEntity *x;
+ if (trans_smil && presindex >= 0) { /* Reformat. */
+ MIMEEntity *x, *pres;
Octstr *btxt = octstr_create("");
-
+ List *h = NULL, *h2 = NULL;
+ Octstr *tmp;
+
/* Remove type & start param from top level. */
- http_header_remove_all(params_h, "type");
- http_header_remove_all(params_h, "start");
- replace_ctype(m->headers, "multipart/related", params_h);
-
-
+ http_header_remove_all(params_h, "type");
+ replace_ctype(headers, "multipart/related", params_h);
+
/* Put content ids on all siblings, and build html. */
- for (i = 0, n = list_len(m->multiparts); imultiparts,i);
+ for (i = 0, n = mime_entity_num_parts(m); iheaders, octstr_imm("Content-ID"));
+ if (i == presindex) continue; /* Skip the presentation param. */
+
+ hx = _x_mime_entity_headers(x);
+ cid = _x_get_content_id(hx);
+
if (cid == NULL) {
time_t t = time(NULL);
char ch[2];
@@ -1091,17 +1119,23 @@ static int format_special(MIMEEntity *m,
ch[1] = 0;
cid = octstr_format("", ch, *counter, (t%99989));
- http_header_add(x->headers, "Content-ID", octstr_get_cstr(cid));
+ http_header_add(hx, "Content-ID", octstr_get_cstr(cid));
++*counter;
+ } else if (octstr_get_char(cid, 0) != '<') { /* fix up for badly behaved clients. */
+ octstr_insert_char(cid, 0, '<');
+ octstr_append_char(cid, '>');
+ http_header_remove_all(hx, "Content-ID");
+ http_header_add(hx, "Content-ID", octstr_get_cstr(cid));
}
+
y = octstr_copy(cid, 1, octstr_len(cid) - 2);
- loc = http_header_value(x->headers, octstr_imm("Content-Location"));
+ loc = http_header_value(hx, octstr_imm("Content-Location"));
cidurl = octstr_duplicate(y);
octstr_url_encode(cidurl);
- get_content_type(x->headers, &ctype, &cparams); /* Get type of object. */
+ get_content_type(hx, &ctype, &cparams); /* Get type of object. */
if (cparams) { /* Get its name. */
if ((cparamsl = get_value_parameters(cparams)) != NULL) {
@@ -1116,10 +1150,12 @@ static int format_special(MIMEEntity *m,
if (octstr_case_search(ctype, octstr_imm("image/"), 0) == 0)
octstr_format_append(btxt,
"\n
\n",
- cidurl, pname);
- else if (octstr_case_search(ctype, octstr_imm("text/"), 0) == 0)
- octstr_format_append(btxt, "%S
\n",
- x->body ? x->body : octstr_imm(""));
+ cidurl, pname ? pname : octstr_imm("image"));
+ else if (octstr_case_search(ctype, octstr_imm("text/"), 0) == 0) {
+ Octstr *s = mime_entity_body(x);
+ octstr_format_append(btxt, "%S
\n", s);
+ octstr_destroy(s);
+ }
#if 0
else if (octstr_case_search(ctype, octstr_imm("audio/"), 0) == 0)
octstr_format_append(btxt,
@@ -1129,10 +1165,16 @@ static int format_special(MIMEEntity *m,
else
octstr_format_append(btxt,
"%S
\n",
- ctype, cidurl, pname);
+ ctype, cidurl, pname ? pname : octstr_imm(""));
+
+ http_header_remove_all(hx, "Content-Location");
+
+ mime_replace_headers(x, hx); /* put back headers, replace part in main...*/
+ mime_entity_replace_part(m, i, x);
+
+ http_destroy_headers(hx);
+ mime_entity_destroy(x);
- http_header_remove_all(x->headers, "Content-Location");
-
if (y) octstr_destroy(y);
if (loc) octstr_destroy(loc);
if (ctype) octstr_destroy(ctype);
@@ -1142,50 +1184,69 @@ static int format_special(MIMEEntity *m,
octstr_destroy(cid);
}
+ pres = mime_entity_get_part(m,presindex);
+ presbody = mime_entity_body(pres);
+ h = _x_mime_entity_headers(pres);
- http_header_remove_all(pres->headers, "Content-Type");
- http_header_add(pres->headers, "Content-Type", "multipart/alternative");
+ http_header_remove_all(h, "Content-Type");
+ http_header_add(h, "Content-Type", "multipart/alternative");
- presbody = pres->body;
- pres->body = NULL;
- if (!pres->multiparts)
- pres->multiparts = list_create();
+ mime_replace_headers(pres,h);
+ http_destroy_headers(h);
-
/* first the text part ... */
x = mime_entity_create();
- http_header_add(x->headers, "Content-Type", "text/plain");
- x->body = octstr_create(txtmsg ? txtmsg : "");
- list_append(pres->multiparts, x);
+ h2 = http_create_empty_headers();
+ http_header_add(h2, "Content-Type", "text/plain");
+ tmp = octstr_create(txtmsg ? txtmsg : "");
+
+ mime_replace_headers(x, h2);
+ mime_entity_set_body(x,tmp);
+
+ mime_entity_add_part(pres, x);
+
+ http_destroy_headers(h2);
+ octstr_destroy(tmp);
+ mime_entity_destroy(x);
/* Lets also leave the pres part in there, just in case somebody knows how to handle it... */
x = mime_entity_create();
- http_header_add(x->headers, "Content-Type", PRES_TYPE);
- x->body = presbody;
- list_append(pres->multiparts, x);
-
+ h2 = http_create_empty_headers();
+ http_header_add(h2, "Content-Type", PRES_TYPE);
+ mime_replace_headers(x, h2);
+ mime_entity_set_body(x, presbody);
+ mime_entity_add_part(pres, x);
+
+ http_destroy_headers(h2);
+ mime_entity_destroy(x);
+
/* then the html part. */
x = mime_entity_create();
- http_header_add(x->headers, "Content-Type", "text/html");
- x->body = octstr_format("%s
%S
\n",
+ h2 = http_create_empty_headers();
+ http_header_add(h2, "Content-Type", "text/html");
+ tmp = octstr_format("%s
%S
\n",
htmlmsg ? htmlmsg : "", btxt);
- list_append(pres->multiparts, x);
-
- list_delete(m->multiparts, presindex, 1); /* Put it at the beginning. */
- list_insert(m->multiparts, 0, pres);
-#if 0
- http_header_remove_all(pres->headers, "Content-ID"); /* Not needed anymore. */
-#endif
- octstr_destroy(btxt);
+ mime_replace_headers(x, h2);
+ mime_entity_set_body(x,tmp);
+ mime_entity_add_part(pres, x);
+
+ http_destroy_headers(h2);
+ octstr_destroy(tmp);
+ mime_entity_destroy(x);
+
+
+ mime_entity_replace_part(m, presindex, pres);
+ mime_entity_destroy(pres);
+
+ octstr_destroy(btxt);
}
goto done;
}
-
if (octstr_case_search(content_type, octstr_imm("image/"), 0) == 0)
type = TIMAGE;
else if (octstr_case_search(content_type, octstr_imm("audio/"), 0) == 0)
@@ -1232,15 +1293,17 @@ static int format_special(MIMEEntity *m,
pf = popen(octstr_get_cstr(cmd), "w");
if (!pf)
- goto done;
- n = octstr_print(pf, m->body);
+ goto done;
+ s = mime_entity_body(m);
+ n = octstr_print(pf, s);
+ octstr_destroy(s);
+
o = pclose(pf);
if (n < 0 || o != 0)
goto done; /* Error -- finish up. */
- s = octstr_read_file(tmpf);
- if (s)
+ if ((s = octstr_read_file(tmpf)) != NULL)
replace_body(m, s, params_h,
cformats[ipref].content_type,
cformats[ipref].file_ext,1);
@@ -1249,6 +1312,7 @@ static int format_special(MIMEEntity *m,
} else if (type == TTEXT) {/* change to default charset. */
Octstr *charset = http_header_value(params_h, octstr_imm("charset"));
+ Octstr *s;
if (charset == NULL ||
octstr_case_compare(charset, octstr_imm("unknown")) == 0 ||
octstr_case_compare(charset, octstr_imm(DEFAULT_CHARSET)) == 0) {
@@ -1256,7 +1320,8 @@ static int format_special(MIMEEntity *m,
goto done; /* Nothing more to do here. */
}
- if (charset_convert(m->body, octstr_get_cstr(charset),
+ s = mime_entity_body(m);
+ if (charset_convert(s, octstr_get_cstr(charset),
DEFAULT_CHARSET) != -1) { /* using libiconv...*/
Octstr *tmp, *ct;
@@ -1266,18 +1331,20 @@ static int format_special(MIMEEntity *m,
ct = octstr_format("%S; %S", content_type, tmp);
octstr_destroy(tmp);
- http_header_remove_all(m->headers, "Content-Type");
- http_header_add(m->headers, "Content-Type", octstr_get_cstr(ct));
+ http_header_remove_all(headers, "Content-Type");
+ http_header_add(headers, "Content-Type", octstr_get_cstr(ct));
octstr_destroy(ct);
-
+ mime_entity_set_body(m, s);
} /* Else goto done. */
-
+ octstr_destroy(s);
} /* Else do nothing. */
-
-
done:
+ if (headers) {
+ mime_replace_headers(m, headers);
+ http_destroy_headers(headers);
+ }
if (content_type)
octstr_destroy(content_type);
if (params_h)
@@ -1296,7 +1363,7 @@ int mms_format_special(MmsMsg *inmsg,
char *txtmsg,
char *htmlmsg, MIMEEntity **outmsg)
{
- MIMEEntity *m = mms_tomime(inmsg,0);
+ MIMEEntity *m = mms_tomime(inmsg,0);
int ct = 0;
if (!m)
diff --git a/mbuni/mmlib/mms_util.c b/mbuni/mmlib/mms_util.c
index 5842b1f..91618f8 100644
--- a/mbuni/mmlib/mms_util.c
+++ b/mbuni/mmlib/mms_util.c
@@ -70,17 +70,20 @@ int mms_load_core_settings(mCfgGrp *cgrp)
octstr_imm("http-proxy-password"));
List *exceptions = mms_cfg_get_list(cgrp,
octstr_imm("http-proxy-exceptions"));
+ Octstr *except_regex = mms_cfg_get(cgrp,
+ octstr_imm("http-proxy-exceptions-regex"));
long http_proxy_port = -1;
mms_cfg_get_int(cgrp, octstr_imm("http-proxy-port"), &http_proxy_port);
if (http_proxy_port > 0)
http_use_proxy(http_proxy_host, http_proxy_port,
- exceptions, username, password);
+ exceptions, username, password, except_regex);
octstr_destroy(http_proxy_host);
octstr_destroy(username);
octstr_destroy(password);
- list_destroy(exceptions, octstr_destroy_item);
+ octstr_destroy(except_regex);
+ gwlist_destroy(exceptions, octstr_destroy_item);
}
#ifdef HAVE_LIBSSL
@@ -283,7 +286,7 @@ static int needs_quotes(Octstr *s)
for (i = 0, n = octstr_len(s); i')
return 1;
}
return 0;
@@ -294,7 +297,7 @@ Octstr *make_value_parameters(List *params)
Octstr *s = octstr_create(""), *name, *value;
int i, n;
- for (i = 0, n = params ? list_len(params) : 0; iheaders); iheaders, i, &header, &value);
+ http_header_get(headers, i, &header, &value);
if (header == NULL ||
octstr_str_compare(header, "X-Unknown") == 0 ||
@@ -342,23 +346,25 @@ void unpack_mimeheaders(MIMEEntity *mm)
/* XXX This may not be safe. Need to skip over quotes. */
if (!skip && octstr_search_char(value, ',', 0) > 0 &&
(l = http_header_split_value(value)) != NULL &&
- list_len(l) > 1)
- for (j = 0, m = list_len(l); j 1)
+ for (j = 0, m = gwlist_len(l); jheaders);
- mm->headers = h;
+
+ mime_replace_headers(mm, h);
+ http_destroy_headers(headers);
+ http_destroy_headers(h);
+
}
@@ -366,26 +372,36 @@ void unpack_mimeheaders(MIMEEntity *mm)
void unbase64_mimeparts(MIMEEntity *m)
{
int i, n;
-
- if (m->multiparts && list_len(m->multiparts) > 0)
- for (i = 0, n = list_len(m->multiparts); imultiparts, i));
+
+ if ((n = mime_entity_num_parts(m)) > 0)
+ for (i = 0; iheaders, octstr_imm("Content-Type"));
- Octstr *te = http_header_value(m->headers, octstr_imm("Content-Transfer-Encoding"));
+ List *headers = _x_mime_entity_headers(m);
+ Octstr *ctype = http_header_value(headers, octstr_imm("Content-Type"));
+ Octstr *te = http_header_value(headers, octstr_imm("Content-Transfer-Encoding"));
if (ctype && te &&
- octstr_case_compare(te,octstr_imm("base64")) == 0)
- octstr_base64_to_binary(m->body);
+ octstr_case_compare(te,octstr_imm("base64")) == 0) {
+ Octstr *s = mime_entity_body(m);
+ octstr_base64_to_binary(s);
+ mime_entity_set_body(m, s);
+ octstr_destroy(s);
+ }
+ http_header_remove_all(headers, "Content-Transfer-Encoding"); /* Remove it in all cases (?).*/
+ mime_replace_headers(m, headers);
- http_header_remove_all(m->headers, "Content-Transfer-Encoding"); /* Remove it in all cases (?).*/
-
/* XXX may be we should deal with other transfer encodings here as well... */
if (ctype)
octstr_destroy(ctype);
if (te)
octstr_destroy(te);
+ http_destroy_headers(headers);
}
}
@@ -400,31 +416,35 @@ void base64_mimeparts(MIMEEntity *m)
{
int i, n;
- if (m->multiparts && list_len(m->multiparts) > 0)
- for (i = 0, n = list_len(m->multiparts); imultiparts, i));
+ if ((n = mime_entity_num_parts(m)) > 0)
+ for (i = 0; iheaders, octstr_imm("Content-Type"));
- Octstr *te = http_header_value(m->headers, octstr_imm("Content-Transfer-Encoding"));
-
- if (ctype && !te
-#if 1
-&&
- (m->body && octstr_check_range(m->body, 0, octstr_len(m->body), _mms_gw_isprint) == 0)
-#endif
- ) {
- octstr_binary_to_base64(m->body);
- http_header_add(m->headers, "Content-Transfer-Encoding", "base64");
+ List *headers = _x_mime_entity_headers(m);
+ Octstr *ctype = http_header_value(headers, octstr_imm("Content-Type"));
+ Octstr *te = http_header_value(headers, octstr_imm("Content-Transfer-Encoding"));
+ Octstr *body = mime_entity_body(m);
+ if (ctype && !te &&
+ (body && octstr_check_range(body, 0, octstr_len(body), _mms_gw_isprint) == 0)) {
+ octstr_binary_to_base64(body);
+
+ http_header_add(headers, "Content-Transfer-Encoding", "base64");
+ mime_entity_set_body(m, body);
+ mime_replace_headers(m, headers);
}
if (ctype)
octstr_destroy(ctype);
if (te)
octstr_destroy(te);
+ octstr_destroy(body);
+ http_destroy_headers(headers);
}
}
-
-
static void addmmscname(Octstr *s, Octstr *myhostname)
{
int j;
@@ -448,23 +468,24 @@ static int send2email(Octstr *to, Octstr *from, Octstr *subject,
Octstr *s;
FILE *f;
int ret = MMS_SEND_OK, i;
- Octstr *cmd = octstr_create("");
+ Octstr *cmd = octstr_create("");
+ List *headers = mime_entity_headers(m); /* we don't want the mime version header removed. */
if (append_hostname) { /* Add our hostname to all phone numbers. */
int i, n;
List *l = http_create_empty_headers();
- Octstr *xfrom = http_header_value(m->headers, octstr_imm("From"));
- List *lto = http_header_find_all(m->headers, "To");
- List *lcc = http_header_find_all(m->headers, "Cc");
+ Octstr *xfrom = http_header_value(headers, octstr_imm("From"));
+ List *lto = http_header_find_all(headers, "To");
+ List *lcc = http_header_find_all(headers, "Cc");
if (xfrom) {
addmmscname(xfrom, myhostname);
http_header_add(l, "From", octstr_get_cstr(xfrom));
octstr_destroy(xfrom);
}
- http_header_remove_all(m->headers, "From");
+ http_header_remove_all(headers, "From");
- for (i = 0, n = list_len(lto); i < n; i++) {
+ for (i = 0, n = gwlist_len(lto); i < n; i++) {
Octstr *name, *value;
http_header_get(lto, i, &name, &value);
@@ -481,9 +502,9 @@ static int send2email(Octstr *to, Octstr *from, Octstr *subject,
}
http_destroy_headers(lto);
- http_header_remove_all(m->headers, "To");
+ http_header_remove_all(headers, "To");
- for (i = 0, n = list_len(lcc); i < n; i++) {
+ for (i = 0, n = gwlist_len(lcc); i < n; i++) {
Octstr *name, *value;
http_header_get(lcc, i, &name, &value);
@@ -500,14 +521,15 @@ static int send2email(Octstr *to, Octstr *from, Octstr *subject,
}
http_destroy_headers(lcc);
- http_header_remove_all(m->headers, "Cc");
+ http_header_remove_all(headers, "Cc");
- http_append_headers(m->headers, l); /* combine old with new. */
+ http_append_headers(headers, l); /* combine old with new. */
http_destroy_headers(l);
}
/* Pack headers, get string rep of mime entity. */
- http_header_pack(m->headers);
+ http_header_pack(headers);
+ mime_replace_headers(m, headers);
s = mime_entity_to_octstr(m);
/*
@@ -601,6 +623,7 @@ static int send2email(Octstr *to, Octstr *from, Octstr *subject,
ret = MMS_SEND_OK;
done:
+ http_destroy_headers(headers);
octstr_destroy(cmd);
octstr_destroy(s);
return ret;
@@ -618,7 +641,7 @@ int mms_sendtoemail(Octstr *from, Octstr *to,
{
MIMEEntity *m = NULL;
-
+ List *headers = NULL;
List *newhdrs = http_create_empty_headers();
int ret;
@@ -629,7 +652,7 @@ int mms_sendtoemail(Octstr *from, Octstr *to,
}
if (!trans_msg)
- m = mms_tomime(msg,0);
+ m = mms_tomime(msg,0);
else
if ((ret = mms_format_special(msg, trans_smil, txt, html, &m)) < 0 ||
m == NULL) {
@@ -648,10 +671,12 @@ int mms_sendtoemail(Octstr *from, Octstr *to,
http_header_add(newhdrs, "MIME-Version", "1.0");
- http_header_combine(newhdrs, m->headers);
- http_destroy_headers(m->headers);
- m->headers = newhdrs;
-
+ headers = _x_mime_entity_headers(m);
+ http_header_combine(headers, newhdrs);
+ mime_replace_headers(m, headers);
+
+ http_destroy_headers(headers);
+ http_destroy_headers(newhdrs);
ret = send2email(to, from, subject, msgid, m, append_hostname, error, sendmail_cmd, myhostname);
mime_entity_destroy(m);
@@ -667,15 +692,15 @@ void mms_log2(char *logmsg, Octstr *from, Octstr *to,
{
List *l;
if (to) {
- l = list_create();
- list_append(l, to);
+ l = gwlist_create();
+ gwlist_append(l, to);
} else
l = NULL;
mms_log(logmsg, from,l,msize,msgid,acct,viaproxy,interface,ua,mmboxloc);
if (l)
- list_destroy(l, NULL);
+ gwlist_destroy(l, NULL);
}
void mms_log(char *logmsg, Octstr *from, List *to,
@@ -685,13 +710,13 @@ void mms_log(char *logmsg, Octstr *from, List *to,
char *interface, Octstr *ua, Octstr *mmboxloc)
{
Octstr *xto = octstr_create("");
- int i, n = to ? list_len(to) : 0;
+ int i, n = to ? gwlist_len(to) : 0;
for (i = 0; i < n; i++)
octstr_format_append(xto,
"%s%S",
(i == 0) ? "" : ", ",
- list_get(to,i));
+ gwlist_get(to,i));
alog("%s MMS [INT:%s] [ACT:%s] [MMSC:%s] [from:%s] [to:%s] [msgid:%s] [size=%d] [UA:%s] [MMBox:%s]",
logmsg, interface,
@@ -758,28 +783,6 @@ int mm_lockfile(int fd, char *fname, int shouldblock)
return 0;
}
-MIMEEntity *mime_entity_duplicate(MIMEEntity *m)
-{
- MIMEEntity *mx = gw_malloc(sizeof *mx);
-
- mx->headers = http_header_duplicate(m->headers);
- if (m->multiparts && list_len(m->multiparts) > 0) {
- int i, n;
- mx->multiparts = list_create();
- for (i = 0, n = list_len(m->multiparts); i < n; i++) {
- MIMEEntity *x = mime_entity_duplicate(list_get(m->multiparts, i));
- list_append(mx->multiparts, x);
- }
- mx->body = NULL;
- } else {
- mx->body = m->body ? octstr_duplicate(m->body) : NULL;
- mx->multiparts = NULL;
- }
- mx->start = NULL;
-
- return mx;
-}
-
void mms_collect_envdata_from_msgheaders(List *mh, List **xto,
Octstr **subject,
Octstr **otransid, time_t *expiryt,
@@ -790,10 +793,10 @@ void mms_collect_envdata_from_msgheaders(List *mh, List **xto,
List *l = http_header_find_all(mh, "To");
if (l) {
int i, n;
- for (i = 0, n = list_len(l); iname = list_extract_first(r);
- x->value = list_extract_first(r);
+ x->name = gwlist_extract_first(r);
+ x->value = gwlist_extract_first(r);
if (!x->value)
x->value = octstr_imm("");
@@ -991,12 +994,12 @@ int parse_cgivars(List *request_headers, Octstr *request_body,
octstr_url_decode(x->name);
octstr_url_decode(x->value);
- list_append(*cgivars, x);
+ gwlist_append(*cgivars, x);
}
octstr_destroy(v);
- list_destroy(r, octstr_destroy_item);
+ gwlist_destroy(r, octstr_destroy_item);
}
- list_destroy(l, NULL);
+ gwlist_destroy(l, NULL);
} else if (octstr_case_compare(ctype, octstr_imm("multipart/form-data")) == 0) {
/* multi-part form data */
MIMEEntity *m = mime_http_to_entity(request_headers, request_body);
@@ -1009,33 +1012,36 @@ int parse_cgivars(List *request_headers, Octstr *request_body,
goto done;
}
/* Go through body parts, pick out what we need. */
- for (i = 0, n = list_len(m->multiparts); i < n; i++) {
- MIMEEntity *mp = list_get(m->multiparts, i);
- Octstr *ct = http_header_value(mp->headers,
+ for (i = 0, n = mime_entity_num_parts(m); i < n; i++) {
+ MIMEEntity *mp = mime_entity_get_part(m, i);
+ List *headers = _x_mime_entity_headers(mp);
+ Octstr *body = mime_entity_body(mp);
+ Octstr *ct = http_header_value(headers,
octstr_imm("Content-Type"));
- Octstr *cd = http_header_value(mp->headers,
+ Octstr *cd = http_header_value(headers,
octstr_imm("Content-Disposition"));
Octstr *name = http_get_header_parameter(cd, octstr_imm("name"));
+
if (name) {
HTTPCGIVar *x = gw_malloc(sizeof *x);
-
+
/* Strip quotes */
if (octstr_get_char(name, 0) == '"') {
octstr_delete(name, 0, 1);
octstr_truncate(name, octstr_len(name) - 1);
}
-
- x->name = octstr_duplicate(name);
- x->value = octstr_duplicate(mp->body);
- list_append(*cgivars, x);
-
+ x->name = octstr_duplicate(name);
+ x->value = octstr_duplicate(body);
+
+ gwlist_append(*cgivars, x);
+
if (ct) { /* If the content type is set, use it. */
x = gw_malloc(sizeof *x);
x->name = octstr_duplicate(name);
x->value = octstr_duplicate(ct);
- list_append(*cgivar_ctypes, x);
+ gwlist_append(*cgivar_ctypes, x);
}
octstr_destroy(name);
}
@@ -1044,6 +1050,9 @@ int parse_cgivars(List *request_headers, Octstr *request_body,
if (cd)
octstr_destroy(cd);
+ octstr_destroy(body);
+ http_destroy_headers(headers);
+ mime_entity_destroy(mp);
}
mime_entity_destroy(m);
@@ -1056,3 +1065,66 @@ done:
octstr_destroy(charset);
return ret;
}
+
+/* We need this because of boundary element adding bug in gwlib/mime.c */
+List *_x_mime_entity_headers(MIMEEntity *m)
+{
+ List *h = mime_entity_headers(m);
+ http_header_remove_all(h, "MIME-Version");
+
+ /* also remove boundary element -- it was added erroneously */
+ if (mime_entity_num_parts(m) == 0)
+ strip_boundary_element(h,NULL);
+ mime_replace_headers(m, h);
+ return h;
+}
+
+/* get content-ID header, fix: WAP decoder may leave " at beginning */
+Octstr *_x_get_content_id(List *headers)
+{
+ Octstr *cid = http_header_value(headers, octstr_imm("Content-ID"));
+
+ if (cid)
+ if (octstr_get_char(cid, 0) == '"' &&
+ octstr_get_char(cid, octstr_len(cid) - 1) != '"')
+ octstr_delete(cid, 0,1);
+ return cid;
+}
+
+/* Utility: Take a header list, remove any boundary parameter from the content-type
+ * element. We don't want this in the WSP packed content.
+ */
+void strip_boundary_element(List *headers, char *s)
+{
+ Octstr *ctype = NULL, *params = NULL;
+ Octstr *value;
+
+ gw_assert(headers);
+ get_content_type(headers, &ctype, ¶ms);
+
+ if (s) {/* we are replacing the content type as well as stripping */
+ if (ctype)
+ octstr_destroy(ctype);
+ ctype = octstr_create(s);
+ }
+
+ if (params) {
+ List *h = get_value_parameters(params);
+ Octstr *ps;
+ http_header_remove_all(h,"boundary"); /* We don't need the boundary param if it is there. */
+ ps = make_value_parameters(h);
+
+ value = octstr_format("%S%s%S", ctype,
+ (ps && octstr_len(ps) > 0) ? "; " : "",
+ ps);
+ octstr_destroy(ps);
+ http_destroy_headers(h);
+ } else
+ value = ctype;
+
+ http_header_remove_all(headers, "Content-Type");
+ http_header_add(headers, "Content-Type", octstr_get_cstr(value));
+ if (ctype != value)
+ octstr_destroy(ctype);
+ octstr_destroy(value);
+}
diff --git a/mbuni/mmlib/mms_util.h b/mbuni/mmlib/mms_util.h
index 2582389..b0199ba 100644
--- a/mbuni/mmlib/mms_util.h
+++ b/mbuni/mmlib/mms_util.h
@@ -111,8 +111,6 @@ void mms_log2(char *logmsg, Octstr *from, Octstr *to,
*/
int mm_lockfile(int fd, char *fname, int shouldblock);
-/* This should be elsewhere, but it isn't, so we do it here... */
-extern MIMEEntity *mime_entity_duplicate(MIMEEntity *m);
/* Returns true if the character is printable or space */
int _mms_gw_isprint(int c);
@@ -150,6 +148,16 @@ void escape_shell_chars(Octstr *str);
*/
int parse_cgivars(List *request_headers, Octstr *request_body,
List **cgivars, List **cgivar_ctypes);
+
+
+/* Helper function: The gwlib func adds an additional MIME-Version header which is not ideal! */
+List *_x_mime_entity_headers(MIMEEntity *m);
+/* get content-ID header, fix: WAP decoder may leave " at beginning */
+Octstr *_x_get_content_id(List *headers);
+
+/* Remove the boundary element from a list of headers. */
+void strip_boundary_element(List *headers, char *s);
+
#define MAXQTRIES 100
#define BACKOFF_FACTOR 5*60 /* In seconds */
#define QUEUERUN_INTERVAL 1*60 /* 1 minutes. */
diff --git a/mbuni/mmsbox/bearerbox.c b/mbuni/mmsbox/bearerbox.c
index 54b20a6..2b3c679 100644
--- a/mbuni/mmsbox/bearerbox.c
+++ b/mbuni/mmsbox/bearerbox.c
@@ -265,7 +265,7 @@ static void mm7soap_receive(MmsHTTPClientInfo *h)
mm7_soap_destroy(mreq);
if (to)
- list_destroy(to, (list_item_destructor_t *)octstr_destroy);
+ gwlist_destroy(to, (gwlist_item_destructor_t *)octstr_destroy);
}
@@ -277,7 +277,7 @@ static void mm7eaif_receive(MmsHTTPClientInfo *h)
List *rh = http_create_empty_headers();
Octstr *reply_body = NULL, *value, *value2;
- List *to = list_create(), *hto = NULL;
+ List *to = gwlist_create(), *hto = NULL;
Octstr *subject = NULL, *otransid = NULL, *msgid = NULL;
Octstr *hfrom = NULL;
time_t expiryt = -1, deliveryt = -1;
@@ -312,13 +312,13 @@ static void mm7eaif_receive(MmsHTTPClientInfo *h)
if ((hto = http_header_find_all(h->headers, "X-NOKIA-MMSC-To")) != NULL &&
- list_len(hto) > 0) { /* To address is in headers. */
+ gwlist_len(hto) > 0) { /* To address is in headers. */
int i, n;
if (to)
- list_destroy(to, (list_item_destructor_t *)octstr_destroy);
- to = list_create();
- for (i = 0, n = list_len(hto); i < n; i++) {
+ gwlist_destroy(to, (gwlist_item_destructor_t *)octstr_destroy);
+ to = gwlist_create();
+ for (i = 0, n = gwlist_len(hto); i < n; i++) {
Octstr *h = NULL, *v = NULL;
List *l;
int j, m;
@@ -326,10 +326,10 @@ static void mm7eaif_receive(MmsHTTPClientInfo *h)
http_header_get(hto,i, &h, &v);
l = http_header_split_value(v);
- for (j = 0, m = list_len(l); j < m; j++)
- list_append(to, list_get(l, j));
+ for (j = 0, m = gwlist_len(l); j < m; j++)
+ gwlist_append(to, gwlist_get(l, j));
- list_destroy(l, NULL);
+ gwlist_destroy(l, NULL);
if (h) octstr_destroy(h);
if (v) octstr_destroy(v);
}
@@ -419,7 +419,7 @@ static void mm7eaif_receive(MmsHTTPClientInfo *h)
if (hto)
http_destroy_headers(hto);
if (to)
- list_destroy(to, (list_item_destructor_t *)octstr_destroy);
+ gwlist_destroy(to, (gwlist_item_destructor_t *)octstr_destroy);
if (hfrom)
octstr_destroy(hfrom);
if (subject)
@@ -531,7 +531,7 @@ static Octstr *mm7soap_send(MmscGrp *mmc, Octstr *from, Octstr *to,
Octstr *ret = NULL;
int mtype = mms_messagetype(m);
int hstatus = HTTP_OK, tstatus;
- List *xto = list_create();
+ List *xto = gwlist_create();
MSoapMsg_t *mreq = NULL, *mresp = NULL;
List *rh = NULL, *ph = NULL;
Octstr *body = NULL, *rbody = NULL, *url = NULL;
@@ -542,7 +542,7 @@ static Octstr *mm7soap_send(MmscGrp *mmc, Octstr *from, Octstr *to,
mms_message_type_to_cstr(mtype),
octstr_get_cstr(from), octstr_get_cstr(to));
- list_append(xto, to);
+ gwlist_append(xto, to);
if ((mreq = mm7_mmsmsg_to_soap(m, from, xto, transid,
service_code,
@@ -562,7 +562,7 @@ static Octstr *mm7soap_send(MmscGrp *mmc, Octstr *from, Octstr *to,
http_header_combine(rh, hdrs); /* If specified, then update and pass on. */
hstatus = mmsbox_url_fetch_content(HTTP_METHOD_POST, mmc->mmsc_url, rh, body, &ph,&rbody);
- if (hstatus != HTTP_OK) {
+ if (http_status_class(hstatus) != HTTP_STATUS_SUCCESSFUL) {
*error = octstr_format("Failed to contact MMC[url=%s] => HTTP returned status = %d!",
octstr_get_cstr(mmc->mmsc_url), hstatus);
goto done1;
@@ -628,7 +628,7 @@ done1:
if (url)
octstr_destroy(url);
- list_destroy(xto, NULL);
+ gwlist_destroy(xto, NULL);
return ret;
}
@@ -778,14 +778,14 @@ static MmscGrp *get_handler_mmc(Octstr *id, Octstr *to)
Octstr *phonenum = NULL;
if (id)
- for (i = 0, n = list_len(mmscs); i < n; i++)
- if ((mmc = list_get(mmscs, i)) != NULL &&
+ for (i = 0, n = gwlist_len(mmscs); i < n; i++)
+ if ((mmc = gwlist_get(mmscs, i)) != NULL &&
mmc->id && octstr_compare(mmc->id, id) == 0)
return mmc;
if (octstr_search_char(to, '@', 0) > 0 ||
octstr_case_search(to, octstr_imm("/TYPE=IPv"), 0) > 0) /* For emails, or ip take first mmsc. */
- return list_get(mmscs, 0);
+ return gwlist_get(mmscs, 0);
j = octstr_case_search(to, octstr_imm("/TYPE=PLMN"), 0);
@@ -796,8 +796,8 @@ static MmscGrp *get_handler_mmc(Octstr *id, Octstr *to)
normalize_number(octstr_get_cstr(unified_prefix), &phonenum);
- for (i = 0, n = list_len(mmscs); i < n; i++)
- if ((mmc = list_get(mmscs, i)) != NULL &&
+ for (i = 0, n = gwlist_len(mmscs); i < n; i++)
+ if ((mmc = gwlist_get(mmscs, i)) != NULL &&
(mmc->allowed_prefix == NULL ||
does_prefix_match(mmc->allowed_prefix, phonenum)) &&
(mmc->denied_prefix == NULL ||
@@ -816,9 +816,9 @@ static int sendMsg(MmsEnvelope *e)
msg = mms_queue_getdata(e);
- for (i = 0, n = list_len(e->to); ito); ito, i);
+ MmsEnvelopeTo *to = gwlist_get(e->to, i);
Octstr *err = NULL;
time_t tnow = time(NULL);
MmscGrp *mmc = NULL;
diff --git a/mbuni/mmsbox/mmsbox.c b/mbuni/mmsbox/mmsbox.c
index 3719fa7..ccee436 100644
--- a/mbuni/mmsbox/mmsbox.c
+++ b/mbuni/mmsbox/mmsbox.c
@@ -34,46 +34,57 @@ static void quit_now(int notused)
if (sendmms_port.port > 0)
http_close_port(sendmms_port.port);
- for (i = 0, n = list_len(mmscs); i < n; i++)
- if ((mmc = list_get(mmscs, i)) != NULL &&
+ for (i = 0, n = gwlist_len(mmscs); i < n; i++)
+ if ((mmc = gwlist_get(mmscs, i)) != NULL &&
mmc->incoming.port > 0)
http_close_port(mmc->incoming.port);
}
+/* Finds text part, returns copy. */
static MIMEEntity *find_textpart(MIMEEntity *m)
{
Octstr *ctype = NULL, *params = NULL;
MIMEEntity *res = NULL;
+ List *headers;
+ int i, n;
if (!m) return NULL;
- get_content_type(m->headers, &ctype, ¶ms);
-
+ headers = _x_mime_entity_headers(m);
+ get_content_type(headers, &ctype, ¶ms);
+ http_destroy_headers(headers);
+
if (ctype && octstr_str_compare(ctype, "text/plain") == 0) {
- res = m;
+ res = mime_entity_duplicate(m);
goto done;
}
- if (m->multiparts) {
- int i, n = list_len(m->multiparts);
- for (i = 0; i < n; i++)
- if ((res = find_textpart(list_get(m->multiparts, i))) != NULL)
+ if ((n = mime_entity_num_parts(m)) > 0) {
+ for (i = 0; i < n; i++) {
+ MIMEEntity *x = mime_entity_get_part(m, i);
+ res = find_textpart(x);
+ mime_entity_destroy(x);
+
+ if (res != NULL)
goto done2;
+ }
}
done:
-
if (res) { /* We got it! Convert charset if needed. */
List *params_h = get_value_parameters(params);
Octstr *charset = http_header_value(params_h, octstr_imm("charset"));
-
+ Octstr *body = mime_entity_body(res);
if (charset == NULL ||
octstr_str_compare(charset, "unknown") == 0) {
if (charset) octstr_destroy(charset);
charset = octstr_imm(DEFAULT_CHARSET);
}
- if (octstr_case_compare(charset, octstr_imm(DEFAULT_CHARSET)) != 0)
- charset_convert(m->body, DEFAULT_CHARSET, octstr_get_cstr(charset)); /* XXX error ignored? */
+ if (octstr_case_compare(charset, octstr_imm(DEFAULT_CHARSET)) != 0) {
+ charset_convert(body, DEFAULT_CHARSET, octstr_get_cstr(charset)); /* XXX error ignored? */
+ mime_entity_set_body(res, body);
+ }
+ octstr_destroy(body);
http_destroy_headers(params_h);
octstr_destroy(charset);
}
@@ -95,16 +106,20 @@ static Octstr *get_keyword(MIMEEntity *me)
{
MIMEEntity *t = find_textpart(me);
- Octstr *txt = t ? t->body : NULL;
+ Octstr *txt = t ? mime_entity_body(t) : NULL;
List *l = t ? octstr_split_words(txt) : NULL;
- Octstr *keyword = l ? list_get(l, 0) : NULL;
+ Octstr *keyword = l ? gwlist_get(l, 0) : NULL;
if (keyword)
keyword = octstr_duplicate(keyword);
if (l)
- list_destroy(l, (list_item_destructor_t *)octstr_destroy);
+ gwlist_destroy(l, (gwlist_item_destructor_t *)octstr_destroy);
+ if (txt)
+ octstr_destroy(txt);
+ if (t)
+ mime_entity_destroy(t);
return keyword;
}
@@ -118,24 +133,24 @@ static MmsService *get_service(Octstr *keyword, Octstr *mmc_id)
int i, n;
MmsService *catch_all = NULL;
- for (i = 0, n = list_len(mms_services); i < n; i++) {
- MmsService *ms = list_get(mms_services,i);
+ for (i = 0, n = gwlist_len(mms_services); i < n; i++) {
+ MmsService *ms = gwlist_get(mms_services,i);
/* Check that mmc_id is allowed:
* denied list is not null and we are on it, or allowed list is not null and we
* are *not* on it.
*/
if (ms->denied_mmscs &&
- list_search(ms->denied_mmscs, mmc_id, (list_item_matches_t *)octstr_compare) != NULL)
+ gwlist_search(ms->denied_mmscs, mmc_id, (gwlist_item_matches_t *)octstr_compare) != NULL)
continue;
if (ms->allowed_mmscs &&
- list_search(ms->allowed_mmscs, mmc_id, (list_item_matches_t *)octstr_compare) == NULL)
+ gwlist_search(ms->allowed_mmscs, mmc_id, (gwlist_item_matches_t *)octstr_compare) == NULL)
continue;
if (keyword == NULL ||
- list_search(ms->keywords, keyword,
- (list_item_matches_t *)_x_octstr_comp) != NULL)
+ gwlist_search(ms->keywords, keyword,
+ (gwlist_item_matches_t *)_x_octstr_comp) != NULL)
return ms;
if (ms->isdefault) /* We also find the catch-all for this sender. */
@@ -149,9 +164,11 @@ static void add_all_matching_parts(MIMEEntity *plist, MmsServiceUrlParam *pm,
MIMEEntity *me, MmsMsg *msg, int lev, int count)
{
int i, n;
-
+ List *headers = NULL;
Octstr *data = NULL, *ctype = NULL, *xctype = NULL, *params = NULL;
+ Octstr *s;
+ headers = _x_mime_entity_headers(me);
if (pm->type == WHOLE_BINARY && lev == 0) {
data = mms_tobinary(msg);
ctype = octstr_imm("application/vnd.wap.mms-message");
@@ -160,14 +177,16 @@ static void add_all_matching_parts(MIMEEntity *plist, MmsServiceUrlParam *pm,
goto done;
}
- if (me->multiparts && list_len(me->multiparts) > 0) { /* Don't process multipart. */
- for (i = 0, n = list_len(me->multiparts); i < n; i++)
- add_all_matching_parts(plist, pm,
- list_get(me->multiparts, i), msg, lev+1,i);
+ if ((n = mime_entity_num_parts(me)) > 0) { /* Recurse over multi-parts. */
+ for (i = 0; i < n; i++) {
+ MIMEEntity *x = mime_entity_get_part(me,i);
+ add_all_matching_parts(plist, pm, x, msg, lev+1,i);
+ mime_entity_destroy(x);
+ }
goto done;
}
-
- get_content_type(me->headers, &xctype, ¶ms);
+
+ get_content_type(headers, &xctype, ¶ms);
#define BEGINSWITH(s, prefix) (octstr_case_search(s, octstr_imm(prefix),0) == 0)
#define TYPE_MATCH(typ, prefix) ((pm->type) == (typ) && \
@@ -186,19 +205,20 @@ static void add_all_matching_parts(MIMEEntity *plist, MmsServiceUrlParam *pm,
!BEGINSWITH(xctype, "image/") &&
!BEGINSWITH(xctype, "application/smil")))) {
- ctype = http_header_value(me->headers, octstr_imm("Content-Type"));
- data = me->body ? octstr_duplicate(me->body) : octstr_create("");
+ ctype = http_header_value(headers, octstr_imm("Content-Type"));
+ data = mime_entity_body(me);
}
done:
if (data) {
MIMEEntity *p = mime_entity_create();
Octstr *cd = octstr_format("form-data; name=\"%S\"", pm->name);
-
+ List *xh;
+
if (ctype) {
/* If Content-Location header or name (content-type) parameter given, pass it as filename. */
Octstr *c = NULL, *q = NULL;
- Octstr *cloc = http_header_value(me->headers,
+ Octstr *cloc = http_header_value(headers,
octstr_imm("Content-Location"));
split_header_value(ctype, &c, &q);
@@ -234,18 +254,25 @@ done:
if (cloc)
octstr_destroy(cloc);
}
- http_header_add(p->headers, "Content-Disposition", octstr_get_cstr(cd));
- if (ctype) /* This header must come after the above it seems. */
- http_header_add(p->headers, "Content-Type", octstr_get_cstr(ctype));
-
- p->body = data;
+ xh = http_create_empty_headers();
+ http_header_add(xh, "Content-Disposition", octstr_get_cstr(cd));
+ if (ctype) /* This header must come after the above it seems. */
+ http_header_add(xh, "Content-Type", octstr_get_cstr(ctype));
+
+ mime_replace_headers(p, xh);
+ http_destroy_headers(xh);
+
+ s = octstr_duplicate(data); /* data for the parameter */
if (pm->value) /* add value part as needed. */
- octstr_append(p->body, pm->value);
+ octstr_append(s, pm->value);
+ mime_entity_set_body(p, s);
+ octstr_destroy(s);
#if 0
base64_mimeparts(p);
#endif
- list_append(plist->multiparts, p);
+ mime_entity_add_part(plist, p); /* add it to list so far. */
+ mime_entity_destroy(p);
octstr_destroy(cd);
@@ -257,6 +284,11 @@ done:
octstr_destroy(params);
if (ctype)
octstr_destroy(ctype);
+
+ if (data)
+ octstr_destroy(data);
+ if (headers)
+ http_destroy_headers(headers);
}
enum _xurltype {FILE_TYPE, URL_TYPE};
@@ -297,8 +329,8 @@ static int fetch_serviceurl(MmsEnvelope *e,
if (e->subject)
http_header_add(rh, "X-Mbuni-Subject", octstr_get_cstr(e->subject));
- for (i = 0, n = list_len(e->to); i < n; i++) {
- MmsEnvelopeTo *r = list_get(e->to, i);
+ for (i = 0, n = gwlist_len(e->to); i < n; i++) {
+ MmsEnvelopeTo *r = gwlist_get(e->to, i);
if (r && r->rcpt)
http_header_add(rh, "X-Mbuni-To", octstr_get_cstr(r->rcpt));
}
@@ -306,15 +338,17 @@ static int fetch_serviceurl(MmsEnvelope *e,
MIMEEntity *x = mime_entity_create();
http_header_add(rh, "Content-Type", "multipart/form-data");
+ mime_replace_headers(x, rh);
+ http_destroy_headers(rh);
- http_destroy_headers(x->headers);
- x->headers = rh;
- for (i = 0, n = list_len(ms->params); i < n; i++) {
- MmsServiceUrlParam *p = list_get(ms->params, i);
+ for (i = 0, n = gwlist_len(ms->params); i < n; i++) {
+ MmsServiceUrlParam *p = gwlist_get(ms->params, i);
add_all_matching_parts(x, p, msg, m, 0, i);
}
-
- mime_entity_body_and_headers(x, &body, &rh);
+
+ body = mime_entity_body(x);
+ rh = _x_mime_entity_headers(x);
+
mime_entity_destroy(x);
method = HTTP_METHOD_POST;
@@ -461,8 +495,8 @@ done:
octstr_destroy(err);
}
if (res == -1 || res == 0) /* Fatal error, or success delete queue entry. */
- for (i = 0, n = list_len(e->to); i < n; i++) {
- MmsEnvelopeTo *r = list_get(e->to,i);
+ for (i = 0, n = gwlist_len(e->to); i < n; i++) {
+ MmsEnvelopeTo *r = gwlist_get(e->to,i);
if (r)
r->process = 0;
}
@@ -576,7 +610,7 @@ int mmsbox_url_fetch_content(int method, Octstr *url, List *request_headers,
octstr_destroy(ctype);
- if (list_len(ph) > 0) {
+ if (gwlist_len(ph) > 0) {
p = make_value_parameters(ph);
ctype = octstr_format("%S; %S",
n,p);
@@ -604,7 +638,7 @@ int mmsbox_url_fetch_content(int method, Octstr *url, List *request_headers,
} else {
HTTPCaller *c = http_caller_create();
http_start_request(c, method, url, request_headers, body, 1, NULL, NULL);
- if (http_receive_result(c, &status, &furl, reply_headers, reply_body) == NULL)
+ if (http_receive_result_real(c, &status, &furl, reply_headers, reply_body,1) == NULL)
status = -1;
http_caller_destroy(c);
}
@@ -805,12 +839,16 @@ static int add_msg_part(MIMEEntity *res, xmlNodePtr node, Octstr *base_url,
char *p = octstr_get_cstr(attr) + 4;
Octstr *cid_header_val = octstr_format("<%s>", p);
MIMEEntity *x = mime_entity_create();
+ List *headers = http_create_empty_headers();
+
+ http_header_add(headers, "Content-Type", octstr_get_cstr(ctype));
+ http_header_add(headers, "Content-ID", octstr_get_cstr(cid_header_val));
+ mime_replace_headers(x, headers);
+ mime_entity_set_body(x, body);
- http_header_add(x->headers, "Content-Type", octstr_get_cstr(ctype));
- http_header_add(x->headers, "Content-ID", octstr_get_cstr(cid_header_val));
- x->body = body;
- list_append(res->multiparts, x);
+ mime_entity_add_part(res, x);
+ mime_entity_destroy(x);
dict_put_once(url_map, curl, octstr_duplicate(attr)); /* Store the cid. */
@@ -818,6 +856,7 @@ static int add_msg_part(MIMEEntity *res, xmlNodePtr node, Octstr *base_url,
octstr_destroy(attr);
octstr_destroy(cid_header_val);
+ http_destroy_headers(headers);
}
done:
@@ -825,6 +864,8 @@ done:
octstr_destroy(curl);
if (ctype)
octstr_destroy(ctype);
+ if (body)
+ octstr_destroy(body);
xmlFree(src);
return 0;
}
@@ -854,11 +895,12 @@ static int make_and_queue_msg(Octstr *data, Octstr *ctype, List *reply_headers,
Octstr *dlr_url = NULL, *rr_url = NULL, *mmc = NULL, *xservice_code = NULL;
MmsMsg *m = NULL;
MIMEEntity *me = mime_entity_create();
- List *hdrs = NULL;
+ List *hdrs = NULL, *xheaders = NULL;
+
time_t expiryt = time(NULL) + DEFAULT_EXPIRE;
Octstr *x;
- List *xto = list_create();
+ List *xto = gwlist_create();
int i, n, res = -1;
gw_assert(svc_name);
@@ -871,7 +913,7 @@ static int make_and_queue_msg(Octstr *data, Octstr *ctype, List *reply_headers,
(void)0; /* all done above. */
else {
/* get first recipient, set that as sender. */
- MmsEnvelopeTo *r = (e) ? list_get(e->to, 0) : NULL;
+ MmsEnvelopeTo *r = (e) ? gwlist_get(e->to, 0) : NULL;
if (r)
from = octstr_duplicate(r->rcpt);
else
@@ -895,11 +937,14 @@ static int make_and_queue_msg(Octstr *data, Octstr *ctype, List *reply_headers,
xmlChar *buf = NULL;
int bsize = 0;
Dict *url_map = dict_create(97, (void (*)(void *))octstr_destroy);
+ List *xh = http_create_empty_headers();
/* This is the hard bit: Fetch each external reference in smil, add it to message! */
- http_header_add(me->headers, "Content-Type", "multipart/related; "
+ http_header_add(xh, "Content-Type", "multipart/related; "
"type=\"application/smil\"; start=\"\"");
-
+ mime_replace_headers(me,xh);
+ http_destroy_headers(xh);
+
/* Parse the smil as XML. */
smil = xmlParseMemory(octstr_get_cstr(data), octstr_len(data));
if (!smil || !smil->xmlChildrenNode) {
@@ -918,12 +963,22 @@ static int make_and_queue_msg(Octstr *data, Octstr *ctype, List *reply_headers,
xmlFreeDoc(smil);
if (buf) {
MIMEEntity *sm = mime_entity_create();
-
- http_header_add(sm->headers, "Content-Type", "application/smil");
- http_header_add(sm->headers, "Content-ID", "");
- sm->body = octstr_create_from_data((char *)buf, bsize);
- list_append(me->multiparts, sm);
- me->start = sm;
+ List *xh = http_create_empty_headers();
+ Octstr *s;
+
+ http_header_add(xh, "Content-Type", "application/smil");
+ http_header_add(xh, "Content-ID", ""); /* identify it as start element. */
+ s = octstr_create_from_data((char *)buf, bsize);
+
+ mime_replace_headers(sm, xh);
+ mime_entity_set_body(sm, s);
+
+ mime_entity_add_part(me, sm);
+
+ mime_entity_destroy(sm);
+ http_destroy_headers(xh);
+ octstr_destroy(s);
+
xmlFree(buf);
} else {
*err = octstr_format("MMSBox: Error writing converted SMIL "
@@ -934,8 +989,12 @@ static int make_and_queue_msg(Octstr *data, Octstr *ctype, List *reply_headers,
goto done;
}
} else { /* all others, make the message as-is and hope for the best! */
- http_header_add(me->headers, "Content-Type", octstr_get_cstr(ctype));
- me->body = octstr_duplicate(data);
+ List *xh = http_create_empty_headers();
+ http_header_add(xh, "Content-Type", octstr_get_cstr(ctype));
+ mime_replace_headers(me, xh);
+
+ http_destroy_headers(xh);
+ mime_entity_set_body(me, data);
}
/* Get headers needed, if we are allowed to do so. */
@@ -949,7 +1008,7 @@ static int make_and_queue_msg(Octstr *data, Octstr *ctype, List *reply_headers,
if ((l = http_header_find_all(reply_headers, "X-Mbuni-To")) != NULL) {
int i, n;
- for (i = 0, n = list_len(l); ifrom)
- list_append(xto, octstr_duplicate(e->from));
+ if (gwlist_len(xto) == 0 && e && e->from)
+ gwlist_append(xto, octstr_duplicate(e->from));
if (!subject && e && e->subject)
subject = octstr_duplicate(e->subject);
@@ -985,25 +1044,28 @@ static int make_and_queue_msg(Octstr *data, Octstr *ctype, List *reply_headers,
mmc = e->fromproxy;
/* Add some nice headers. */
- http_header_add(me->headers, "From", octstr_get_cstr(from));
+ xheaders = _x_mime_entity_headers(me);
+ http_header_add(xheaders, "From", octstr_get_cstr(from));
- for (i = 0, n = list_len(xto); i < n; i++) {
+ for (i = 0, n = gwlist_len(xto); i < n; i++) {
Octstr *v;
- v = list_get(xto, i);
- http_header_add(me->headers, "To", octstr_get_cstr(v));
+ v = gwlist_get(xto, i);
+ http_header_add(xheaders, "To", octstr_get_cstr(v));
}
if (dlr_url)
- http_header_add(me->headers, "X-Mms-Delivery-Report", "Yes");
+ http_header_add(xheaders, "X-Mms-Delivery-Report", "Yes");
if (rr_url)
- http_header_add(me->headers, "X-Mms-Read-Report", "Yes");
+ http_header_add(xheaders, "X-Mms-Read-Report", "Yes");
if (subject)
- http_header_add(me->headers, "Subject", octstr_get_cstr(subject));
+ http_header_add(xheaders, "Subject", octstr_get_cstr(subject));
if (expiryt > 0) {
Octstr *x = date_format_http(expiryt);
- http_header_add(me->headers, "X-Mms-Expiry", octstr_get_cstr(x));
+ http_header_add(xheaders, "X-Mms-Expiry", octstr_get_cstr(x));
octstr_destroy(x);
}
+ mime_replace_headers(me, xheaders);
+ http_destroy_headers(xheaders);
if (me && !m) /* Set m if it hasn't been set yet. */
m = mms_frommime(me);
@@ -1014,7 +1076,7 @@ static int make_and_queue_msg(Octstr *data, Octstr *ctype, List *reply_headers,
}
if (passthro_headers && reply_headers) { /* if user wants passthro headers, get them and add them. */
- int n = list_len(reply_headers);
+ int n = gwlist_len(reply_headers);
int i;
hdrs = http_create_empty_headers();
@@ -1028,8 +1090,8 @@ static int make_and_queue_msg(Octstr *data, Octstr *ctype, List *reply_headers,
/* Check for this header in
* pass thro list.
*/
- for (j = 0; j < list_len(passthro_headers); j++)
- if (octstr_case_compare(h, list_get(passthro_headers, j)) == 0) {
+ for (j = 0; j < gwlist_len(passthro_headers); j++)
+ if (octstr_case_compare(h, gwlist_get(passthro_headers, j)) == 0) {
http_header_add(hdrs, octstr_get_cstr(h), octstr_get_cstr(v));
break;
}
@@ -1074,7 +1136,7 @@ done:
if (m)
mms_destroy(m);
if (xto)
- list_destroy(xto, (list_item_destructor_t *)octstr_destroy);
+ gwlist_destroy(xto, (gwlist_item_destructor_t *)octstr_destroy);
if (hdrs)
http_destroy_headers(hdrs);
@@ -1091,8 +1153,8 @@ static SendMmsUser *auth_user(Octstr *user, Octstr *pass)
if (!user || !pass)
return NULL;
- for (i = 0, n = list_len(sendmms_users); i < n; i++)
- if ((u = list_get(sendmms_users, i)) != NULL &&
+ for (i = 0, n = gwlist_len(sendmms_users); i < n; i++)
+ if ((u = gwlist_get(sendmms_users, i)) != NULL &&
octstr_compare(u->user, user) == 0 &&
octstr_compare(u->pass, pass) == 0)
return u;
@@ -1185,11 +1247,11 @@ static void sendmms_func(void *unused)
rb = octstr_imm("Missing Sender address");
if (lto) {
- for (i = 0, n = list_len(lto); i < n; i++) {
- Octstr *x = list_get(lto, i);
+ for (i = 0, n = gwlist_len(lto); i < n; i++) {
+ Octstr *x = gwlist_get(lto, i);
http_header_add(rh, "X-Mbuni-To", octstr_get_cstr(x));
}
- list_destroy(lto, (list_item_destructor_t *)octstr_destroy);
+ gwlist_destroy(lto, (gwlist_item_destructor_t *)octstr_destroy);
}
if (dlr_url)
http_header_add(rh, "X-Mbuni-DLR-Url", octstr_get_cstr(dlr_url));
diff --git a/mbuni/mmsbox/mmsbox_cfg.c b/mbuni/mmsbox/mmsbox_cfg.c
index ce2acb3..600f041 100644
--- a/mbuni/mmsbox/mmsbox_cfg.c
+++ b/mbuni/mmsbox/mmsbox_cfg.c
@@ -49,9 +49,9 @@ int mms_load_mmsbox_settings(mCfg *cfg, gwthread_func_t *mmsc_handler_func)
mms_load_core_settings(cgrp);
- sendmms_users = list_create();
- mms_services = list_create();
- mmscs = list_create();
+ sendmms_users = gwlist_create();
+ mms_services = gwlist_create();
+ mmscs = gwlist_create();
gdir = mms_cfg_get(grp, octstr_imm("storage-directory"));
@@ -119,8 +119,8 @@ int mms_load_mmsbox_settings(mCfg *cfg, gwthread_func_t *mmsc_handler_func)
/* Now get sendmms users. */
l = mms_cfg_get_multi(cfg, octstr_imm("send-mms-user"));
- for (i = 0, n = list_len(l); i < n; i++) {
- mCfgGrp *x = list_get(l, i);
+ for (i = 0, n = gwlist_len(l); i < n; i++) {
+ mCfgGrp *x = gwlist_get(l, i);
SendMmsUser *u = gw_malloc(sizeof *u);
memset(u, 0, sizeof *u);
@@ -130,14 +130,14 @@ int mms_load_mmsbox_settings(mCfg *cfg, gwthread_func_t *mmsc_handler_func)
u->faked_sender = mms_cfg_get(x, octstr_imm("faked-sender"));
u->dlr_url = _mms_cfg_getx(x, octstr_imm("delivery-report-url"));
u->rr_url = _mms_cfg_getx(x, octstr_imm("read-report-url"));
- list_append(sendmms_users, u);
+ gwlist_append(sendmms_users, u);
}
- list_destroy(l, NULL);
+ gwlist_destroy(l, NULL);
/* Get mmsc list. */
l = mms_cfg_get_multi(cfg, octstr_imm("mmsc"));
- for (i = 0, n = list_len(l); i < n; i++) {
- mCfgGrp *x = list_get(l, i);
+ for (i = 0, n = gwlist_len(l); i < n; i++) {
+ mCfgGrp *x = gwlist_get(l, i);
MmscGrp *m = gw_malloc(sizeof *m);
int ssl = 0;
Octstr *type;
@@ -189,14 +189,14 @@ int mms_load_mmsbox_settings(mCfg *cfg, gwthread_func_t *mmsc_handler_func)
m->threadid = -1;
m->mutex = mutex_create();
- list_append(mmscs, m);
+ gwlist_append(mmscs, m);
}
- list_destroy(l, NULL);
+ gwlist_destroy(l, NULL);
l = mms_cfg_get_multi(cfg, octstr_imm("mms-service"));
- for (i = 0, n = list_len(l); i < n; i++) {
- mCfgGrp *x = list_get(l, i);
+ for (i = 0, n = gwlist_len(l); i < n; i++) {
+ mCfgGrp *x = gwlist_get(l, i);
MmsService *m = gw_malloc(sizeof *m);
Octstr *s;
@@ -254,23 +254,23 @@ int mms_load_mmsbox_settings(mCfg *cfg, gwthread_func_t *mmsc_handler_func)
m->keywords = octstr_split(s, octstr_imm(";"));
octstr_destroy(s);
} else
- m->keywords = list_create();
+ m->keywords = gwlist_create();
s = mms_cfg_get(x, octstr_imm("keyword"));
if (!s)
panic(0, "MMSBox: Service [%s] has no keyword!", octstr_get_cstr(m->name));
else
- list_append(m->keywords, s);
+ gwlist_append(m->keywords, s);
if ((s = mms_cfg_get(x, octstr_imm("http-post-parameters"))) != NULL) {
List *r = octstr_split(s, octstr_imm("&"));
int i, n;
- m->params = list_create();
+ m->params = gwlist_create();
if (m->type != TRANS_TYPE_POST_URL)
warning(0, "MMSBox: Service [%s] specifies HTTP Post parameters "
"without specifying post-url type/url!", octstr_get_cstr(m->name));
- for (i = 0, n = list_len(r); i < n; i++) {
- Octstr *y = list_get(r, i);
+ for (i = 0, n = gwlist_len(r); i < n; i++) {
+ Octstr *y = gwlist_get(r, i);
int ii = octstr_search_char(y, '=', 0);
if (ii < 0)
ii = octstr_len(y);
@@ -311,21 +311,21 @@ int mms_load_mmsbox_settings(mCfg *cfg, gwthread_func_t *mmsc_handler_func)
p->value = octstr_copy(y, ii+3, octstr_len(y));
} else /* No conversion spec. */
p->value = octstr_copy(y, ii+1, octstr_len(y));
- list_append(m->params, p);
+ gwlist_append(m->params, p);
} else
warning(0, "MMSBox: Missing http-post-parameter name? Service [%s]!",
octstr_get_cstr(m->name));
}
- list_destroy(r, (list_item_destructor_t *)octstr_destroy);
+ gwlist_destroy(r, (gwlist_item_destructor_t *)octstr_destroy);
octstr_destroy(s);
} else
m->params = NULL;
m->service_code = mms_cfg_get(x, octstr_imm("service-code"));
- list_append(mms_services, m);
+ gwlist_append(mms_services, m);
}
- list_destroy(l, NULL);
+ gwlist_destroy(l, NULL);
return 0;
}
diff --git a/mbuni/mmsc/mms_billing_shell.c b/mbuni/mmsc/mms_billing_shell.c
index 8d8e05d..cd6c530 100644
--- a/mbuni/mmsc/mms_billing_shell.c
+++ b/mbuni/mmsc/mms_billing_shell.c
@@ -39,9 +39,9 @@ static int mms_billmsg(Octstr *from, List *to, unsigned long msg_size, Octstr *v
if (script == NULL || octstr_len(script) == 0)
return 0;
- for (i=0;ilocal_prefix, phonenum)) {
return settings->hostname ? octstr_duplicate(settings->hostname) : NULL;
- } else if (proxyrelays && list_len(proxyrelays) > 0) /* Step through proxies. */
- for (j = 0, m = list_len(proxyrelays); j < m; j++) {
- MmsProxyRelay *mp = list_get(proxyrelays, j);
+ } else if (proxyrelays && gwlist_len(proxyrelays) > 0) /* Step through proxies. */
+ for (j = 0, m = gwlist_len(proxyrelays); j < m; j++) {
+ MmsProxyRelay *mp = gwlist_get(proxyrelays, j);
if (does_prefix_match(mp->allowed_prefix, phonenum) &&
!does_prefix_match(mp->denied_prefix, phonenum)) {
return octstr_duplicate(mp->host);
diff --git a/mbuni/mmsc/mmsc_cfg.c b/mbuni/mmsc/mmsc_cfg.c
index ab56238..b684703 100644
--- a/mbuni/mmsc/mmsc_cfg.c
+++ b/mbuni/mmsc/mmsc_cfg.c
@@ -274,9 +274,9 @@ MmscSettings *mms_load_mmsc_settings(mCfg *cfg, List **proxyrelays)
/* Now load the VASP list. */
l = mms_cfg_get_multi(cfg, octstr_imm("mms-vasp"));
- m->vasp_list = list_create();
- for (i=0, n=list_len(l); ivasp_list = gwlist_create();
+ for (i=0, n=gwlist_len(l); imms2mobile = mv;
}
- list_append(m->vasp_list, mv);
+ gwlist_append(m->vasp_list, mv);
}
- list_destroy(l, NULL);
+ gwlist_destroy(l, NULL);
return m;
}
@@ -323,10 +323,10 @@ List *mms_proxy_relays(mCfg *cfg)
{
List *gl = mms_cfg_get_multi(cfg, octstr_imm("mmsproxy"));
int i, n;
- List *l = list_create();
+ List *l = gwlist_create();
- for (i = 0, n = list_len(gl); i < n; i++) {
- mCfgGrp *grp = list_get(gl, i);
+ for (i = 0, n = gwlist_len(gl); i < n; i++) {
+ mCfgGrp *grp = gwlist_get(gl, i);
MmsProxyRelay *m = gw_malloc(sizeof *m);
m->host = _mms_cfg_getx(grp, octstr_imm("host"));
@@ -334,10 +334,10 @@ List *mms_proxy_relays(mCfg *cfg)
m->allowed_prefix = _mms_cfg_getx(grp, octstr_imm("allowed-prefix"));
m->denied_prefix = _mms_cfg_getx(grp, octstr_imm("denied-prefix"));
- list_append(l, m);
+ gwlist_append(l, m);
}
- list_destroy(gl, NULL);
+ gwlist_destroy(gl, NULL);
return l;
}
@@ -405,13 +405,13 @@ Octstr *mms_find_sender_msisdn(Octstr *send_url,
requestip_header);
if (xip == NULL)
xip = ip ? octstr_duplicate(ip) : NULL;
- if (detokenizerfuncs && ((l && list_len(l) > 1) || xip))
- phonenum = detokenizerfuncs->mms_detokenize((l && list_len(l) > 1) ?
- list_get(l, list_len(l) - 1) :
+ if (detokenizerfuncs && ((l && gwlist_len(l) > 1) || xip))
+ phonenum = detokenizerfuncs->mms_detokenize((l && gwlist_len(l) > 1) ?
+ gwlist_get(l, gwlist_len(l) - 1) :
send_url,
xip);
if (l)
- list_destroy(l, (list_item_destructor_t *)octstr_destroy);
+ gwlist_destroy(l, (gwlist_item_destructor_t *)octstr_destroy);
if (xip)
octstr_destroy(xip);
}
diff --git a/mbuni/mmsc/mmsfromemail.c b/mbuni/mmsc/mmsfromemail.c
index c5f7f5d..86afc84 100644
--- a/mbuni/mmsc/mmsfromemail.c
+++ b/mbuni/mmsc/mmsfromemail.c
@@ -40,7 +40,8 @@ int main(int argc, char *argv[])
Octstr *email;
Octstr *home_mmsc = NULL;
-
+ List *headers;
+
mms_lib_init();
srandom(time(NULL));
@@ -115,9 +116,12 @@ int main(int argc, char *argv[])
unpack_mimeheaders(mm);
/* Delete some headers... */
- http_header_remove_all(mm->headers, "Received");
- http_header_remove_all(mm->headers, "X-MimeOLE");
- http_header_remove_all(mm->headers, "X-Mailer");
+ headers = _x_mime_entity_headers(mm);
+ http_header_remove_all(headers, "Received");
+ http_header_remove_all(headers, "X-MimeOLE");
+ http_header_remove_all(headers, "X-Mailer");
+ mime_replace_headers(mm, headers);
+ http_destroy_headers(headers);
/* Now convert from mime to MMS message. */
msg = mms_frommime(mm);
@@ -133,8 +137,9 @@ int main(int argc, char *argv[])
case MMS_MSGTYPE_SEND_REQ:
if (ttype != TPLMN)
error(0, "Not allowed to send to non-phone recipient, to=%s!", octstr_get_cstr(xto));
+
else {
- List *lto = list_create();
+ List *lto = gwlist_create();
Octstr *qf;
Octstr *msgid = mms_get_header_value(msg, octstr_imm("Message-ID"));
Octstr *transid = mms_get_header_value(msg, octstr_imm("X-Mms-Transaction-ID"));
@@ -145,7 +150,7 @@ int main(int argc, char *argv[])
int dlr;
octstr_format_append(xto, "/TYPE=PLMN");
- list_append(lto, xto);
+ gwlist_append(lto, xto);
if (dreport &&
octstr_case_compare(dreport, octstr_imm("Yes")) == 0)
@@ -180,8 +185,8 @@ int main(int argc, char *argv[])
0,MS_1_1);
rto = octstr_format("system-user@%S", xproxy);
- xlto = list_create();
- list_append(xlto, rto);
+ xlto = gwlist_create();
+ gwlist_append(xlto, rto);
qf = mms_queue_add(settings->system_user, xlto, NULL,
xproxy, NULL,
@@ -194,7 +199,7 @@ int main(int argc, char *argv[])
octstr_get_cstr(settings->global_queuedir),
settings->host_alias);
- list_destroy(xlto, (list_item_destructor_t *)octstr_destroy);
+ gwlist_destroy(xlto, (gwlist_item_destructor_t *)octstr_destroy);
mms_destroy(mresp);
octstr_destroy(qf);
}
@@ -202,7 +207,7 @@ int main(int argc, char *argv[])
mms_log("Received", xfrom, lto,
-1, msgid, NULL, xproxy, xproxy ? "MM4" : "MM3", NULL,NULL);
- list_destroy(lto,NULL);
+ gwlist_destroy(lto,NULL);
octstr_destroy(transid);
octstr_destroy(msgid);
if (dreport)
@@ -229,8 +234,8 @@ int main(int argc, char *argv[])
MmsEnvelopeTo *t;
int i, n;
- for (i = 0, n = list_len(e->to); ito, i)) != NULL)
+ for (i = 0, n = gwlist_len(e->to); ito, i)) != NULL)
t->process = 0; /* Should make it go away. */
mms_queue_update(e);
info(0, "Email2MMS received send conf from proxy %s to %s from %s => %s",
@@ -248,12 +253,12 @@ int main(int argc, char *argv[])
if (ttype != TPLMN) /* We only send to phones from this interface */
error(0, "Not allowed to send to %s!", octstr_get_cstr(xto));
else {
- List *lto = list_create();
+ List *lto = gwlist_create();
Octstr *qf;
octstr_format_append(xto, "/TYPE=PLMN");
- list_append(lto, xto);
+ gwlist_append(lto, xto);
qf = mms_queue_add(xfrom, lto, NULL,
xproxy, NULL,
0, time(NULL) + settings->default_msgexpiry, msg, NULL,
@@ -263,7 +268,7 @@ int main(int argc, char *argv[])
0,
octstr_get_cstr(settings->global_queuedir),
settings->host_alias);
- list_destroy(lto, NULL);
+ gwlist_destroy(lto, NULL);
if (qf) {
info(0, "Email2MMS Queued DLR from proxy %s to %s from %s => %s",
octstr_get_cstr(xproxy), octstr_get_cstr(xto), octstr_get_cstr(xfrom),
@@ -272,7 +277,7 @@ int main(int argc, char *argv[])
octstr_destroy(qf);
}
- list_destroy(lto, NULL);
+ gwlist_destroy(lto, NULL);
}
break;
@@ -285,11 +290,11 @@ int main(int argc, char *argv[])
if (ttype != TPLMN) /* We only send to phones from this interface */
error(0, "Not allowed to send to %s!", octstr_get_cstr(xto));
else {
- List *lto = list_create();
+ List *lto = gwlist_create();
Octstr *qf;
octstr_format_append(xto, "/TYPE=PLMN");
- list_append(lto, xto);
+ gwlist_append(lto, xto);
qf = mms_queue_add(xfrom, lto, NULL,
xproxy, NULL,
0, time(NULL) + settings->default_msgexpiry, msg, NULL,
@@ -299,7 +304,7 @@ int main(int argc, char *argv[])
0,
octstr_get_cstr(settings->global_queuedir),
settings->host_alias);
- list_destroy(lto, NULL);
+ gwlist_destroy(lto, NULL);
if (qf) {
info(0, "Email2MMS Queued read report from proxy %s to %s from %s => %s",
octstr_get_cstr(xproxy), octstr_get_cstr(xto), octstr_get_cstr(xfrom),
@@ -309,7 +314,7 @@ int main(int argc, char *argv[])
}
- list_destroy(lto, NULL);
+ gwlist_destroy(lto, NULL);
}
default:
{
diff --git a/mbuni/mmsc/mmsglobalsender.c b/mbuni/mmsc/mmsglobalsender.c
index bca87d3..f4a3dd3 100644
--- a/mbuni/mmsc/mmsglobalsender.c
+++ b/mbuni/mmsc/mmsglobalsender.c
@@ -72,27 +72,27 @@ static int sendMsg(MmsEnvelope *e)
if (e->msgtype == MMS_MSGTYPE_SEND_REQ &&
!e->bill.billed) { /* Attempt to bill if not already billed */
- List *l = list_create();
+ List *l = gwlist_create();
double amt;
- for (i = 0, n = list_len(e->to); i < n; i++) {
- MmsEnvelopeTo *to = list_get(e->to, i);
- list_append(l, to->rcpt);
+ for (i = 0, n = gwlist_len(e->to); i < n; i++) {
+ MmsEnvelopeTo *to = gwlist_get(e->to, i);
+ gwlist_append(l, to->rcpt);
}
amt = settings->mms_billfuncs->mms_billmsg(e->from, l,
e->msize,
e->vaspid,
settings->mms_bill_module_data);
- list_destroy(l, NULL);
+ gwlist_destroy(l, NULL);
info(0, "Global Queue MMS Bill: From %s, to_count=%ld, msgid=%s, msgsize=%ld: returned=%.2f",
- octstr_get_cstr(e->from), list_len(e->to), e->msgId ? octstr_get_cstr(e->msgId) : "",
+ octstr_get_cstr(e->from), gwlist_len(e->to), e->msgId ? octstr_get_cstr(e->msgId) : "",
e->msize, amt);
if (amt == -1) { /* Delete message. */
- for (i = 0, n = list_len(e->to); i < n; i++) {
- MmsEnvelopeTo *to = list_get(e->to, i);
+ for (i = 0, n = gwlist_len(e->to); i < n; i++) {
+ MmsEnvelopeTo *to = gwlist_get(e->to, i);
to->process = 0;
}
} else if (amt >= 0) {
@@ -117,10 +117,10 @@ static int sendMsg(MmsEnvelope *e)
#endif
- for (i = 0, n = list_len(e->to); i < n; i++) {
+ for (i = 0, n = gwlist_len(e->to); i < n; i++) {
Octstr *err = NULL;
int res = MMS_SEND_OK, m;
- MmsEnvelopeTo *to = list_get(e->to, i);
+ MmsEnvelopeTo *to = gwlist_get(e->to, i);
time_t tnow = time(NULL);
@@ -208,8 +208,8 @@ static int sendMsg(MmsEnvelope *e)
}
/* Search VASP list, see what you can find... */
- for (j = 0, m = list_len(settings->vasp_list); j < m; j++)
- if ((vasp = list_get(settings->vasp_list, j)) != NULL &&
+ for (j = 0, m = gwlist_len(settings->vasp_list); j < m; j++)
+ if ((vasp = gwlist_get(settings->vasp_list, j)) != NULL &&
_x_octstr_int_compare(vasp->short_code, phonenum) == 0) {
res = mms_sendtovasp(vasp, e->from, to->rcpt,
e->msgId,
@@ -251,9 +251,9 @@ static int sendMsg(MmsEnvelope *e)
e->msgId, e->expiryt, msg, e->dlr,
&err);
sent = 1;
- } else if (proxyrelays && list_len(proxyrelays) > 0) /* Step through proxies. */
- for (j = 0, m = list_len(proxyrelays); j 0) /* Step through proxies. */
+ for (j = 0, m = gwlist_len(proxyrelays); jhost, mmsc)) {
res = mms_sendtoproxy(e->from, to->rcpt,
@@ -287,9 +287,9 @@ static int sendMsg(MmsEnvelope *e)
octstr_imm("Expired") : octstr_imm("Rejected"));
- List *l = list_create();
+ List *l = gwlist_create();
- list_append(l, octstr_duplicate(e->from));
+ gwlist_append(l, octstr_duplicate(e->from));
/* Add to queue, switch via proxy to be from proxy. */
qfs = mms_queue_add(settings->system_user, l,
@@ -302,7 +302,7 @@ static int sendMsg(MmsEnvelope *e)
qdir,
settings->host_alias);
octstr_destroy(qfs);
- list_destroy(l, NULL);
+ gwlist_destroy(l, NULL);
mms_destroy(m);
}
@@ -327,7 +327,7 @@ static int sendMsg(MmsEnvelope *e)
strncpy(cdr->vaspid, e->vaspid ? octstr_get_cstr(e->vaspid) : "", sizeof cdr->vaspid);
cdr->msg_size = e->msize;
- list_produce(cdr_list, cdr); /* Put it on list so sending thread sends it. */
+ gwlist_produce(cdr_list, cdr); /* Put it on list so sending thread sends it. */
}
/* Update queue entry so that we know which ones have been processed. */
@@ -358,7 +358,7 @@ static void cdr_thread(void *unused)
{
MmsCdrStruct *cdr;
- while ((cdr = list_consume(cdr_list)) != NULL) {
+ while ((cdr = gwlist_consume(cdr_list)) != NULL) {
settings->mms_billfuncs->mms_logcdr(cdr);
/* We should probably write to log here... */
gw_free(cdr);
@@ -377,15 +377,15 @@ void mbuni_global_queue_runner(int *rstop)
/* Start the thread for CDR */
- cdr_list = list_create();
- list_add_producer(cdr_list);
+ cdr_list = gwlist_create();
+ gwlist_add_producer(cdr_list);
gwthread_create(cdr_thread, NULL);
mms_queue_run(qdir, sendMsg, settings->queue_interval, settings->maxthreads, rstop);
/* When it ends, wait a little for other stuff to stop... */
sleep(2);
- list_remove_producer(cdr_list); /* Stop CDR thread. */
+ gwlist_remove_producer(cdr_list); /* Stop CDR thread. */
return;
}
@@ -421,10 +421,10 @@ int mms_sendtomobile(Octstr *from, Octstr *to,
{
Octstr *ret, *x;
- List *l = list_create();
+ List *l = gwlist_create();
char tokenstr[128];
- list_append(l, to);
+ gwlist_append(l, to);
/* We generate a special token that will be added to message ID to make
* stealing messages a bit harder.
@@ -443,7 +443,7 @@ int mms_sendtomobile(Octstr *from, Octstr *to,
settings->host_alias);
octstr_destroy(x);
- list_destroy(l, NULL);
+ gwlist_destroy(l, NULL);
octstr_destroy(ret);
if (ret == NULL)
return MMS_SEND_ERROR_TRANSIENT;
@@ -474,16 +474,16 @@ static int mms_sendtoproxy(Octstr *from, Octstr *to,
}
if (mms_messagetype(msg) == MMS_MSGTYPE_SEND_REQ) { /* Only queue these ones for future response. */
- List *l = list_create();
+ List *l = gwlist_create();
Octstr *ret;
- list_append(l, to);
+ gwlist_append(l, to);
ret = mms_queue_add(from, l, subject, NULL, proxy, 0, expires, msg,NULL,
NULL, NULL,
NULL, NULL,
NULL,
dlr, mm4_qdir,
settings->host_alias);
- list_destroy(l, NULL);
+ gwlist_destroy(l, NULL);
if (ret == NULL) {
*error = octstr_format("MM4: Failed to queue message to %S for future tracking. ", to);
@@ -524,7 +524,7 @@ static int mm7soap_send(MmsVasp *vasp, Octstr *from, Octstr *to, Octstr *msgId,
int ret = MMS_SEND_ERROR_TRANSIENT;
int mtype = mms_messagetype(m);
int hstatus = HTTP_OK, tstatus;
- List *xto = list_create();
+ List *xto = gwlist_create();
MSoapMsg_t *mreq = NULL, *mresp = NULL;
List *rh = NULL, *ph = NULL;
Octstr *body = NULL, *rbody = NULL, *url = NULL;
@@ -536,7 +536,7 @@ static int mm7soap_send(MmsVasp *vasp, Octstr *from, Octstr *to, Octstr *msgId,
vasp ? octstr_get_cstr(vasp->id) : "",
mms_message_type_to_cstr(mtype), octstr_get_cstr(from), octstr_get_cstr(to));
- list_append(xto, to);
+ gwlist_append(xto, to);
if ((mreq = mm7_mmsmsg_to_soap(m, from, xto, msgId, settings->host_alias,
@@ -554,8 +554,8 @@ static int mm7soap_send(MmsVasp *vasp, Octstr *from, Octstr *to, Octstr *msgId,
http_start_request(caller, HTTP_METHOD_POST, vasp->vasp_url, rh, body, 1, NULL, NULL);
- if ((xx = http_receive_result(caller, &hstatus, &url, &ph, &rbody)) == NULL ||
- hstatus != HTTP_OK) {
+ if ((xx = http_receive_result_real(caller, &hstatus, &url, &ph, &rbody,1)) == NULL ||
+ http_status_class(hstatus) != HTTP_STATUS_SUCCESSFUL) {
*error = octstr_format("Failed to contact VASP[url=%s] => HTTP returned status = %d, id=%s !",
octstr_get_cstr(vasp->vasp_url), hstatus, xx ? "Ok" : "not OK");
goto done1;
@@ -612,7 +612,7 @@ static int mm7soap_send(MmsVasp *vasp, Octstr *from, Octstr *to, Octstr *msgId,
if (url)
octstr_destroy(url);
http_caller_destroy(caller);
- list_destroy(xto, NULL);
+ gwlist_destroy(xto, NULL);
return ret;
}
@@ -656,7 +656,7 @@ static int mm7eaif_send(MmsVasp *vasp, Octstr *from, Octstr *to, Octstr *msgid,
body = mms_tobinary(m);
http_start_request(caller, HTTP_METHOD_POST, vasp->vasp_url, rh, body, 1, NULL, NULL);
- if ((xx = http_receive_result(caller, &hstatus, &url, &ph, &rbody)) == NULL ||
+ if ((xx = http_receive_result_real(caller, &hstatus, &url, &ph, &rbody,1)) == NULL ||
http_status_class(hstatus) != HTTP_STATUS_SUCCESSFUL) {
*error = octstr_format("Failed to contact VASP[url=%s] => HTTP returned status = %d, id=%s !",
octstr_get_cstr(vasp->vasp_url), hstatus, xx ? "Ok" : "not OK");
diff --git a/mbuni/mmsc/mmsmobilesender.c b/mbuni/mmsc/mmsmobilesender.c
index 611f19e..bcd52da 100644
--- a/mbuni/mmsc/mmsmobilesender.c
+++ b/mbuni/mmsc/mmsmobilesender.c
@@ -125,7 +125,7 @@ static void start_push(Octstr *rcpt_to, int isphonenum, MmsEnvelope *e, MmsMsg *
int sock = udp_client_socket();
if (sock > 0) {
- MmsEnvelopeTo *xto = list_get(e->to,0);
+ MmsEnvelopeTo *xto = gwlist_get(e->to,0);
octstr_append(pduhdr, s);
#if 0
octstr_dump(pduhdr, 0);
@@ -161,8 +161,8 @@ static int receive_push_reply(HTTPCaller *caller)
http_status = HTTP_UNAUTHORIZED;
- while ((env = http_receive_result(caller, &http_status, &final_url, &reply_headers,
- &reply_body)) != NULL) {
+ while ((env = http_receive_result_real(caller, &http_status, &final_url, &reply_headers,
+ &reply_body,1)) != NULL) {
MmsEnvelopeTo *xto = NULL;
Octstr *to = NULL;
@@ -173,7 +173,7 @@ static int receive_push_reply(HTTPCaller *caller)
if (env == &edummy) /* Skip this one it is a dummy. */
goto push_free_env;
- xto = list_get(env->to, 0);
+ xto = gwlist_get(env->to, 0);
if (xto)
to = xto->rcpt;
else {
@@ -228,7 +228,7 @@ static int sendNotify(MmsEnvelope *e)
{
Octstr *to;
MmsMsg *msg, *smsg = NULL;
- MmsEnvelopeTo *xto = list_get(e->to, 0);
+ MmsEnvelopeTo *xto = gwlist_get(e->to, 0);
Octstr *err = NULL;
time_t tnow = time(NULL);
int j, k, len;
@@ -240,8 +240,10 @@ static int sendNotify(MmsEnvelope *e)
char *rtype = NULL;
- if (e->lastaccess != 0) { /* This message has been fetched at least once, no more signals. */
- e->sendt = e->expiryt + 3600*24*30*12;
+ if (e->lastaccess != 0) { /* This message has been fetched at least once, no more signals. */
+ e->sendt = e->expiryt + 3600*24*30*12;
+ info(0, "MM1: Message [ID: %s] fetched/touched at least once. Skipping",
+ e->xqfname);
return mms_queue_update(e);
}
@@ -408,9 +410,9 @@ static int sendNotify(MmsEnvelope *e)
rtype ? octstr_imm(rtype) :
octstr_imm("Indeterminate"));
- List *l = list_create();
+ List *l = gwlist_create();
Octstr *res;
- list_append(l, from);
+ gwlist_append(l, from);
/* Add to queue, switch via proxy to be from proxy. */
res = mms_queue_add(settings->system_user, l, err,
@@ -422,7 +424,7 @@ static int sendNotify(MmsEnvelope *e)
0,
octstr_get_cstr(settings->mm1_queuedir),
settings->host_alias);
- list_destroy(l, NULL);
+ gwlist_destroy(l, NULL);
mms_destroy(m);
octstr_destroy(res);
}
diff --git a/mbuni/mmsc/mmsproxy.c b/mbuni/mmsc/mmsproxy.c
index 8c16b68..cd7303b 100644
--- a/mbuni/mmsc/mmsproxy.c
+++ b/mbuni/mmsc/mmsproxy.c
@@ -128,15 +128,25 @@ int main(int argc, char *argv[])
h.vasp = NULL;
h.profile_url = NULL;
h.ua = http_header_value(h.headers, octstr_imm("User-Agent"));
-
+
+ http_header_dump(h.headers);
/* Get the profile URL and store it. Has effect of fetching if missing. */
if ((h.profile_url = http_header_value(h.headers,
octstr_imm("X-Wap-Profile"))) == NULL)
h.profile_url = http_header_value(h.headers, octstr_imm("Profile"));
- if (h.profile_url)
+ if (h.profile_url) {
+ /* If quoted, get first quoted string */
+ if (octstr_get_char(h.profile_url, 0) == '"') {
+ int x;
+ octstr_delete(h.profile_url, 0, 1);
+ x = octstr_search_char(h.profile_url, '"', 0);
+ if (x >= 0)
+ octstr_delete(h.profile_url, x, octstr_len(h.profile_url));
+ }
octstr_strip_nonalphanums(h.profile_url);
-
+ }
+
/* Get the sender address. */
h.base_client_addr = mms_find_sender_msisdn(h.url,
h.ip,
@@ -482,7 +492,7 @@ static void sendmms_proxy(MmsHTTPClientInfo *h)
Octstr *qf;
List *mh = mms_message_headers(m);
Octstr *from = h->client_addr ? octstr_duplicate(h->client_addr) : NULL;
- List *to = list_create();
+ List *to = gwlist_create();
Octstr *subject = NULL;
time_t expiryt, deliveryt;
@@ -597,7 +607,7 @@ static void sendmms_proxy(MmsHTTPClientInfo *h)
octstr_destroy(subject);
if (mh)
http_destroy_headers(mh);
- list_destroy(to, (list_item_destructor_t *)octstr_destroy);
+ gwlist_destroy(to, (gwlist_item_destructor_t *)octstr_destroy);
notify_cmd = "sent";
reply_body = mms_tobinary(mresp);
@@ -608,7 +618,7 @@ static void sendmms_proxy(MmsHTTPClientInfo *h)
Octstr *qf = NULL, *token = NULL;
List *mh = mms_message_headers(m);
Octstr *from = h->client_addr ? octstr_duplicate(h->client_addr) : NULL;
- List *to = list_create();
+ List *to = gwlist_create();
Octstr *subject;
time_t expiryt, deliveryt;
MmsMsg *mfwd = NULL;
@@ -823,8 +833,8 @@ static void sendmms_proxy(MmsHTTPClientInfo *h)
MmsMsg *mrep = mms_deliveryreport(pmsgid, h->client_addr, time(NULL), octstr_imm("Forwarded"));
Octstr *x;
- List *l = list_create();
- list_append(l, pfrom);
+ List *l = gwlist_create();
+ gwlist_append(l, pfrom);
x = mms_queue_add(settings->system_user, l, NULL, NULL, NULL, 0,
time(NULL) + settings->default_msgexpiry,
@@ -838,7 +848,7 @@ static void sendmms_proxy(MmsHTTPClientInfo *h)
if (x)
octstr_destroy(x);
- list_destroy(l, NULL);
+ gwlist_destroy(l, NULL);
mms_destroy(mrep);
}
if (pfrom)
@@ -854,7 +864,7 @@ static void sendmms_proxy(MmsHTTPClientInfo *h)
if (xstate)
octstr_destroy(xstate);
if (xflags)
- list_destroy(xflags, (list_item_destructor_t *)octstr_destroy);
+ gwlist_destroy(xflags, (gwlist_item_destructor_t *)octstr_destroy);
}
forward_done:
@@ -881,7 +891,7 @@ static void sendmms_proxy(MmsHTTPClientInfo *h)
if (mh)
http_destroy_headers(mh);
if (to)
- list_destroy(to, (list_item_destructor_t *)octstr_destroy);
+ gwlist_destroy(to, (gwlist_item_destructor_t *)octstr_destroy);
if (otransid)
octstr_destroy(otransid);
if (url)
@@ -934,7 +944,7 @@ static void sendmms_proxy(MmsHTTPClientInfo *h)
}
if (octstr_str_compare(status, "Retrieved") == 0) {
- MmsEnvelopeTo *t = list_get(e->to, 0);
+ MmsEnvelopeTo *t = gwlist_get(e->to, 0);
if (t)
t->process = 0;
} else
@@ -948,10 +958,10 @@ static void sendmms_proxy(MmsHTTPClientInfo *h)
|| octstr_case_compare(allow_report, octstr_imm("Yes")) == 0) &&
e->dlr) {
Octstr *x;
- List *l = list_create();
+ List *l = gwlist_create();
mrpt = mms_deliveryreport(e->msgId, h->client_addr, time(NULL), status);
- list_append(l, octstr_duplicate(e->from));
+ gwlist_append(l, octstr_duplicate(e->from));
x = mms_queue_add(settings->system_user, l, NULL, NULL, NULL, 0,
time(NULL) + settings->default_msgexpiry, mrpt, NULL,
@@ -964,7 +974,7 @@ static void sendmms_proxy(MmsHTTPClientInfo *h)
if (x)
octstr_destroy(x);
- list_destroy(l, (list_item_destructor_t *)octstr_destroy);
+ gwlist_destroy(l, (gwlist_item_destructor_t *)octstr_destroy);
mms_destroy(mrpt);
}
@@ -998,7 +1008,7 @@ static void sendmms_proxy(MmsHTTPClientInfo *h)
{
List *mh = mms_message_headers(m);
Octstr *from = h->client_addr ? octstr_duplicate(h->client_addr) : octstr_create("anon@anon");
- List *to = list_create();
+ List *to = gwlist_create();
Octstr *x;
@@ -1031,7 +1041,7 @@ static void sendmms_proxy(MmsHTTPClientInfo *h)
if (mh)
http_destroy_headers(mh);
- list_destroy(to, (list_item_destructor_t *)octstr_destroy);
+ gwlist_destroy(to, (gwlist_item_destructor_t *)octstr_destroy);
http_header_add(rh, "Content-Type", "text/plain");
ctype_set = 1;
reply_body = octstr_imm("Received");
@@ -1136,7 +1146,7 @@ static void sendmms_proxy(MmsHTTPClientInfo *h)
if (xstate)
octstr_destroy(xstate);
if (xflags)
- list_destroy(xflags, (list_item_destructor_t *)octstr_destroy);
+ gwlist_destroy(xflags, (gwlist_item_destructor_t *)octstr_destroy);
if (mstore)
mms_destroy(mstore);
@@ -1260,8 +1270,8 @@ static void sendmms_proxy(MmsHTTPClientInfo *h)
List *lh = mms_get_header_values(m, octstr_imm("X-Mms-Content-Location"));
Octstr *otransid = mms_get_header_value(m, octstr_imm("X-Mms-Transaction-ID"));
int i;
- List *cls = list_create();
- List *rss = list_create();
+ List *cls = gwlist_create();
+ List *rss = gwlist_create();
@@ -1275,8 +1285,8 @@ static void sendmms_proxy(MmsHTTPClientInfo *h)
goto delete_done;
}
- for (i = 0; i < list_len(lh); i++) {
- Octstr *url = list_get(lh,i);
+ for (i = 0; i < gwlist_len(lh); i++) {
+ Octstr *url = gwlist_get(lh,i);
int mloc;
Octstr *qf = NULL, *token = NULL;
Octstr *cl, *rs = NULL;
@@ -1295,8 +1305,8 @@ static void sendmms_proxy(MmsHTTPClientInfo *h)
if (!e)
rs = octstr_format("%dError-permanent-message-not-found", i);
else {
- for (j = 0, m = (e->to ? list_len(e->to) : 0); j < m; j++) {
- MmsEnvelopeTo *x = list_get(e->to,j);
+ for (j = 0, m = (e->to ? gwlist_len(e->to) : 0); j < m; j++) {
+ MmsEnvelopeTo *x = gwlist_get(e->to,j);
if (x) x->process = 0;
}
if (mms_queue_update(e) != 1) /* Should be freed. */
@@ -1315,8 +1325,8 @@ static void sendmms_proxy(MmsHTTPClientInfo *h)
if (!rs)
rs = octstr_format("%dError-permanent-message-not-found", i);
- list_append(rss, rs);
- list_append(cls, cl);
+ gwlist_append(rss, rs);
+ gwlist_append(cls, cl);
if (qf)
octstr_destroy(qf);
@@ -1329,9 +1339,9 @@ static void sendmms_proxy(MmsHTTPClientInfo *h)
mms_replace_header_values(mresp, "X-Mms-Response-Status", rss);
delete_done:
- list_destroy(cls, (list_item_destructor_t *)octstr_destroy);
- list_destroy(rss, (list_item_destructor_t *)octstr_destroy);
- list_destroy(lh, (list_item_destructor_t *)octstr_destroy);
+ gwlist_destroy(cls, (gwlist_item_destructor_t *)octstr_destroy);
+ gwlist_destroy(rss, (gwlist_item_destructor_t *)octstr_destroy);
+ gwlist_destroy(lh, (gwlist_item_destructor_t *)octstr_destroy);
if (otransid)
octstr_destroy(otransid);
@@ -1414,14 +1424,14 @@ static void sendmms_proxy(MmsHTTPClientInfo *h)
(prof = mms_get_ua_profile(octstr_get_cstr(h->profile_url))) != NULL) {
int i, n;
- for (i = 0, n = msgs ? list_len(msgs) : 0; iclient_addr), xstates,
xflags, start, limit, msgs);
/* Make the locations. */
- msglocs = list_create();
- for (i = 0, n = list_len(msgrefs); i < n; i++) {
- Octstr *sdf = list_get(msgrefs, i);
- list_append(msglocs,
+ msglocs = gwlist_create();
+ for (i = 0, n = gwlist_len(msgrefs); i < n; i++) {
+ Octstr *sdf = gwlist_get(msgrefs, i);
+ gwlist_append(msglocs,
mms_makefetchurl(octstr_get_cstr(sdf),
NULL, MMS_LOC_MMBOX, h->client_addr, settings));
}
@@ -1461,20 +1471,20 @@ static void sendmms_proxy(MmsHTTPClientInfo *h)
notify_cmd = "deleted";
if (xflags)
- list_destroy(xflags, (list_item_destructor_t *)octstr_destroy);
+ gwlist_destroy(xflags, (gwlist_item_destructor_t *)octstr_destroy);
if (xstates)
- list_destroy(xstates, (list_item_destructor_t *)octstr_destroy);
+ gwlist_destroy(xstates, (gwlist_item_destructor_t *)octstr_destroy);
if (required_headers)
- list_destroy(required_headers, (list_item_destructor_t *)octstr_destroy);
+ gwlist_destroy(required_headers, (gwlist_item_destructor_t *)octstr_destroy);
if (msgrefs)
- list_destroy(msgrefs, (list_item_destructor_t *)octstr_destroy);
+ gwlist_destroy(msgrefs, (gwlist_item_destructor_t *)octstr_destroy);
if (msglocs)
- list_destroy(msglocs, (list_item_destructor_t *)octstr_destroy);
+ gwlist_destroy(msglocs, (gwlist_item_destructor_t *)octstr_destroy);
if (msgs)
- list_destroy(msgs, (list_item_destructor_t *)octstr_destroy);
+ gwlist_destroy(msgs, (gwlist_item_destructor_t *)octstr_destroy);
if (otherhdrs)
http_destroy_headers(otherhdrs);
@@ -1531,7 +1541,7 @@ static MmsVasp *find_mm7sender(List *headers, List *vasps)
int i, n;
#if 0
- return list_get(vasps,0); /* XXX for testing... */
+ return gwlist_get(vasps,0); /* XXX for testing... */
#endif
if (!v ||
octstr_search(v, octstr_imm("Basic "), 0) != 0)
@@ -1544,8 +1554,8 @@ static MmsVasp *find_mm7sender(List *headers, List *vasps)
octstr_delete(p, i, octstr_len(p));
/* p = user, q = pass. */
- for (i = 0, n = list_len(vasps); ivasp_username, p) == 0 &&
octstr_compare(x->vasp_password, q) == 0) {
@@ -1715,8 +1725,8 @@ static void mm7soap_dispatch(MmsHTTPClientInfo *h)
octstr_get_cstr(msgid), octstr_get_cstr(h->vasp->id));
} else { /* Kill it. */
int i, n;
- for (i = 0, n = list_len(e->to); ito,i);
+ for (i = 0, n = gwlist_len(e->to); ito,i);
xto->process = 0;
}
mms_queue_update(e); /* Will clear it. */
@@ -1781,7 +1791,7 @@ static void mm7soap_dispatch(MmsHTTPClientInfo *h)
mm7_soap_destroy(mreq);
if (to)
- list_destroy(to, (list_item_destructor_t *)octstr_destroy);
+ gwlist_destroy(to, (gwlist_item_destructor_t *)octstr_destroy);
free_clientInfo(h,1);
}
@@ -1795,7 +1805,7 @@ static void mm7eaif_dispatch(MmsHTTPClientInfo *h)
List *rh = http_create_empty_headers();
Octstr *reply_body = NULL, *value;
- List *to = list_create(), *hto = NULL;
+ List *to = gwlist_create(), *hto = NULL;
Octstr *subject = NULL, *otransid = NULL, *msgid = NULL;
Octstr *hfrom = NULL;
time_t expiryt = -1, deliveryt = -1;
@@ -1826,13 +1836,13 @@ static void mm7eaif_dispatch(MmsHTTPClientInfo *h)
if ((hto = http_header_find_all(h->headers, "X-NOKIA-MMSC-To")) != NULL &&
- list_len(hto) > 0) { /* To address is in headers. */
+ gwlist_len(hto) > 0) { /* To address is in headers. */
int i, n;
if (to)
- list_destroy(to, (list_item_destructor_t *)octstr_destroy);
- to = list_create();
- for (i = 0, n = list_len(hto); i < n; i++) {
+ gwlist_destroy(to, (gwlist_item_destructor_t *)octstr_destroy);
+ to = gwlist_create();
+ for (i = 0, n = gwlist_len(hto); i < n; i++) {
Octstr *h = NULL, *v = NULL;
List *l;
int j, m;
@@ -1840,10 +1850,10 @@ static void mm7eaif_dispatch(MmsHTTPClientInfo *h)
http_header_get(hto,i, &h, &v);
l = http_header_split_value(v);
- for (j = 0, m = list_len(l); j < m; j++)
- list_append(to, list_get(l, j));
+ for (j = 0, m = gwlist_len(l); j < m; j++)
+ gwlist_append(to, gwlist_get(l, j));
- list_destroy(l, NULL);
+ gwlist_destroy(l, NULL);
if (h) octstr_destroy(h);
if (v) octstr_destroy(v);
}
@@ -1905,7 +1915,7 @@ static void mm7eaif_dispatch(MmsHTTPClientInfo *h)
if (hto)
http_destroy_headers(hto);
if (to)
- list_destroy(to, (list_item_destructor_t *)octstr_destroy);
+ gwlist_destroy(to, (gwlist_item_destructor_t *)octstr_destroy);
if (hfrom)
octstr_destroy(hfrom);
if (subject)
diff --git a/mbuni/mmsc/mmssend.c b/mbuni/mmsc/mmssend.c
index 83af939..998992a 100644
--- a/mbuni/mmsc/mmssend.c
+++ b/mbuni/mmsc/mmssend.c
@@ -46,12 +46,12 @@ static int find_own(int i, int argc, char *argv[])
int j, m;
List *l = octstr_split(octstr_create(argv[i+1]),
octstr_imm(":"));
- for (j = 0, m = list_len(l); j < m; j++) {
- Octstr *x = list_get(l, j);
+ for (j = 0, m = gwlist_len(l); j < m; j++) {
+ Octstr *x = gwlist_get(l, j);
_mms_fixup_address(x);
- list_append(to, x);
+ gwlist_append(to, x);
}
- list_destroy(l, NULL);
+ gwlist_destroy(l, NULL);
return 1;
} else
return -1;
@@ -83,7 +83,7 @@ int main(int argc, char *argv[])
return -1;
mms_lib_init();
- to = list_create();
+ to = gwlist_create();
srandom(time(NULL));
cfidx = get_and_set_debugs(argc, argv, find_own);