Index: src/OFXMLFactory.h ================================================================== --- src/OFXMLFactory.h +++ src/OFXMLFactory.h @@ -13,8 +13,8 @@ @interface OFXMLFactory: OFObject + (char*)escapeCString: (const char*)s; + (char*)createStanza: (const char*)name withCloseTag: (BOOL)close - andCData: (const char*)cdata, ...; + andData: (const char*)data, ...; + (char*)concatAndFreeCStrings: (char **)strs; @end Index: src/OFXMLFactory.m ================================================================== --- src/OFXMLFactory.m +++ src/OFXMLFactory.m @@ -128,11 +128,11 @@ return ret; } + (char*)createStanza: (const char*)name withCloseTag: (BOOL)close - andCData: (const char*)cdata, ... + andData: (const char*)data, ... { char *arg, *val, *xml; size_t i, len; va_list args; @@ -148,11 +148,11 @@ xml[i++] = '<'; memcpy(xml + i, name, strlen(name)); i += strlen(name); /* Arguments */ - va_start(args, cdata); + va_start(args, data); while ((arg = va_arg(args, char*)) != NULL && (val = va_arg(args, char*)) != NULL) { char *esc_val; if ((esc_val = [OFXMLFactory escapeCString: val]) == NULL) { @@ -188,11 +188,11 @@ } va_end(args); /* End of tag */ if (close) { - if (cdata == NULL) { + if (data == NULL) { if (!xmlfactory_resize(&xml, &len, 2 - 1)) { [[OFNoMemException newWithObject: nil andSize: len + 2 - 1] raise]; return NULL; @@ -199,26 +199,25 @@ } xml[i++] = '/'; xml[i++] = '>'; } else { - if (!xmlfactory_resize(&xml, &len, 1 + strlen(cdata) + + if (!xmlfactory_resize(&xml, &len, 1 + strlen(data) + 2 + strlen(name) + 1 - 1)) { [[OFNoMemException newWithObject: nil andSize: len + 1 + - strlen( - cdata) + + strlen(data) + 2 + strlen(name) + 1 - 1] raise]; return NULL; } xml[i++] = '>'; - memcpy(xml + i, cdata, strlen(cdata)); - i += strlen(cdata); + memcpy(xml + i, data, strlen(data)); + i += strlen(data); xml[i++] = '<'; xml[i++] = '/'; memcpy(xml + i, name, strlen(name)); i += strlen(name); xml[i++] = '>'; Index: tests/OFXMLFactory/OFXMLFactory.m ================================================================== --- tests/OFXMLFactory/OFXMLFactory.m +++ tests/OFXMLFactory/OFXMLFactory.m @@ -56,53 +56,53 @@ inline void test_create_stanza() { check_result([OFXMLFactory createStanza: "foo" withCloseTag: NO - andCData: NULL, + andData: NULL, NULL], ""); check_result([OFXMLFactory createStanza: "foo" withCloseTag: NO - andCData: NULL, + andData: NULL, "bar", "baz", "blub", "asd", NULL], ""); check_result([OFXMLFactory createStanza: "foo" withCloseTag: YES - andCData: NULL, + andData: NULL, NULL], ""); check_result([OFXMLFactory createStanza: "foo" withCloseTag: YES - andCData: "bar", + andData: "bar", NULL], "bar"); check_result([OFXMLFactory createStanza: "foo" withCloseTag: YES - andCData: NULL, + andData: NULL, "bar", "b&az", NULL], ""); check_result([OFXMLFactory createStanza: "foo" withCloseTag: YES - andCData: "bar", + andData: "bar", "bar", "b'az", NULL], "bar"); check_result([OFXMLFactory createStanza: "foo" withCloseTag: YES - andCData: NULL, + andData: NULL, "bar", "b&az", "x", "asd\"", NULL], ""); check_result([OFXMLFactory createStanza: "foo" withCloseTag: YES - andCData: "bar", + andData: "bar", "bar", "b'az", "x", "y", "a", "b", NULL], "bar");