]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
XML: Remove now unused code
authorJouni Malinen <quic_jouni@quicinc.com>
Sat, 22 Feb 2025 18:55:37 +0000 (20:55 +0200)
committerJouni Malinen <j@w1.fi>
Sat, 22 Feb 2025 20:10:46 +0000 (22:10 +0200)
OSU removal from hs20-osu-client removed need for quite a bit of the
XML wrapper functionality.

Signed-off-by: Jouni Malinen <quic_jouni@quicinc.com>
src/utils/xml-utils.c
src/utils/xml-utils.h
src/utils/xml_libxml2.c

index dae91fee46f6c6af13c807f3a17a6ebb98f14e87..52803827e68e036e2e90bff0c83281b79e5ea4ef 100644 (file)
@@ -438,34 +438,3 @@ xml_node_t * tnds_to_mo(struct xml_node_ctx *ctx, xml_node_t *tnds)
                return NULL;
        return tnds_to_mo_iter(ctx, NULL, node, NULL);
 }
-
-
-xml_node_t * soap_build_envelope(struct xml_node_ctx *ctx, xml_node_t *node)
-{
-       xml_node_t *envelope, *body;
-       xml_namespace_t *ns;
-
-       envelope = xml_node_create_root(
-               ctx, "http://www.w3.org/2003/05/soap-envelope", "soap12", &ns,
-               "Envelope");
-       if (envelope == NULL)
-               return NULL;
-       body = xml_node_create(ctx, envelope, ns, "Body");
-       xml_node_add_child(ctx, body, node);
-       return envelope;
-}
-
-
-xml_node_t * soap_get_body(struct xml_node_ctx *ctx, xml_node_t *soap)
-{
-       xml_node_t *body, *child;
-
-       body = get_node_uri(ctx, soap, "Envelope/Body");
-       if (body == NULL)
-               return NULL;
-       xml_node_for_each_child(ctx, child, body) {
-               xml_node_for_each_check(ctx, child);
-               return child;
-       }
-       return NULL;
-}
index fb6208cdac323dbbe3a976d575ed2856dd0bdb7b..eb83bd45ac497d18d631eabd92ca9aaad170633c 100644 (file)
@@ -15,19 +15,11 @@ typedef struct xml_namespace_foo xml_namespace_t;
 
 /* XML library wrappers */
 
-int xml_validate(struct xml_node_ctx *ctx, xml_node_t *node,
-                const char *xml_schema_fname, char **ret_err);
-int xml_validate_dtd(struct xml_node_ctx *ctx, xml_node_t *node,
-                    const char *dtd_fname, char **ret_err);
 void xml_node_free(struct xml_node_ctx *ctx, xml_node_t *node);
-xml_node_t * xml_node_get_parent(struct xml_node_ctx *ctx, xml_node_t *node);
 xml_node_t * xml_node_from_buf(struct xml_node_ctx *ctx, const char *buf);
 const char * xml_node_get_localname(struct xml_node_ctx *ctx,
                                    xml_node_t *node);
 char * xml_node_to_str(struct xml_node_ctx *ctx, xml_node_t *node);
-void xml_node_detach(struct xml_node_ctx *ctx, xml_node_t *node);
-void xml_node_add_child(struct xml_node_ctx *ctx, xml_node_t *parent,
-                       xml_node_t *child);
 xml_node_t * xml_node_create_root(struct xml_node_ctx *ctx, const char *ns_uri,
                                  const char *ns_prefix,
                                  xml_namespace_t **ret_ns, const char *name);
@@ -41,13 +33,6 @@ xml_node_t * xml_node_create_text_ns(struct xml_node_ctx *ctx,
                                     const char *name, const char *value);
 void xml_node_set_text(struct xml_node_ctx *ctx, xml_node_t *node,
                       const char *value);
-int xml_node_add_attr(struct xml_node_ctx *ctx, xml_node_t *node,
-                     xml_namespace_t *ns, const char *name, const char *value);
-char * xml_node_get_attr_value(struct xml_node_ctx *ctx, xml_node_t *node,
-                              char *name);
-char * xml_node_get_attr_value_ns(struct xml_node_ctx *ctx, xml_node_t *node,
-                                 const char *ns_uri, char *name);
-void xml_node_get_attr_value_free(struct xml_node_ctx *ctx, char *val);
 xml_node_t * xml_node_first_child(struct xml_node_ctx *ctx,
                                  xml_node_t *parent);
 xml_node_t * xml_node_next_sibling(struct xml_node_ctx *ctx,
@@ -57,7 +42,6 @@ char * xml_node_get_text(struct xml_node_ctx *ctx, xml_node_t *node);
 void xml_node_get_text_free(struct xml_node_ctx *ctx, char *val);
 char * xml_node_get_base64_text(struct xml_node_ctx *ctx, xml_node_t *node,
                                int *ret_len);
-xml_node_t * xml_node_copy(struct xml_node_ctx *ctx, xml_node_t *node);
 
 #define xml_node_for_each_child(ctx, child, parent) \
 for (child = xml_node_first_child(ctx, parent); \
@@ -91,7 +75,4 @@ xml_node_t * mo_to_tnds(struct xml_node_ctx *ctx, xml_node_t *mo,
                        int use_path, const char *urn, const char *ns_uri);
 xml_node_t * tnds_to_mo(struct xml_node_ctx *ctx, xml_node_t *tnds);
 
-xml_node_t * soap_build_envelope(struct xml_node_ctx *ctx, xml_node_t *node);
-xml_node_t * soap_get_body(struct xml_node_ctx *ctx, xml_node_t *soap);
-
 #endif /* XML_UTILS_H */
index d73654eb522def8a39348d186b788c979fedd411..50630a92549d7655e789194897ea04a139642bcc 100644 (file)
@@ -21,161 +21,12 @@ struct xml_node_ctx {
 };
 
 
-struct str_buf {
-       char *buf;
-       size_t len;
-};
-
-#define MAX_STR 1000
-
-static void add_str(void *ctx_ptr, const char *fmt, ...)
-{
-       struct str_buf *str = ctx_ptr;
-       va_list ap;
-       char *n;
-       int len;
-
-       n = os_realloc(str->buf, str->len + MAX_STR + 2);
-       if (n == NULL)
-               return;
-       str->buf = n;
-
-       va_start(ap, fmt);
-       len = vsnprintf(str->buf + str->len, MAX_STR, fmt, ap);
-       va_end(ap);
-       if (len >= MAX_STR)
-               len = MAX_STR - 1;
-       str->len += len;
-       str->buf[str->len] = '\0';
-}
-
-
-int xml_validate(struct xml_node_ctx *ctx, xml_node_t *node,
-                const char *xml_schema_fname, char **ret_err)
-{
-       xmlDocPtr doc;
-       xmlNodePtr n;
-       xmlSchemaParserCtxtPtr pctx;
-       xmlSchemaValidCtxtPtr vctx;
-       xmlSchemaPtr schema;
-       int ret;
-       struct str_buf errors;
-
-       if (ret_err)
-               *ret_err = NULL;
-
-       doc = xmlNewDoc((xmlChar *) "1.0");
-       if (doc == NULL)
-               return -1;
-       n = xmlDocCopyNode((xmlNodePtr) node, doc, 1);
-       if (n == NULL) {
-               xmlFreeDoc(doc);
-               return -1;
-       }
-       xmlDocSetRootElement(doc, n);
-
-       os_memset(&errors, 0, sizeof(errors));
-
-       pctx = xmlSchemaNewParserCtxt(xml_schema_fname);
-       xmlSchemaSetParserErrors(pctx, (xmlSchemaValidityErrorFunc) add_str,
-                                (xmlSchemaValidityWarningFunc) add_str,
-                                &errors);
-       schema = xmlSchemaParse(pctx);
-       xmlSchemaFreeParserCtxt(pctx);
-
-       vctx = xmlSchemaNewValidCtxt(schema);
-       xmlSchemaSetValidErrors(vctx, (xmlSchemaValidityErrorFunc) add_str,
-                               (xmlSchemaValidityWarningFunc) add_str,
-                               &errors);
-
-       ret = xmlSchemaValidateDoc(vctx, doc);
-       xmlSchemaFreeValidCtxt(vctx);
-       xmlFreeDoc(doc);
-       xmlSchemaFree(schema);
-
-       if (ret == 0) {
-               os_free(errors.buf);
-               return 0;
-       } else if (ret > 0) {
-               if (ret_err)
-                       *ret_err = errors.buf;
-               else
-                       os_free(errors.buf);
-               return -1;
-       } else {
-               if (ret_err)
-                       *ret_err = errors.buf;
-               else
-                       os_free(errors.buf);
-               return -1;
-       }
-}
-
-
-int xml_validate_dtd(struct xml_node_ctx *ctx, xml_node_t *node,
-                    const char *dtd_fname, char **ret_err)
-{
-       xmlDocPtr doc;
-       xmlNodePtr n;
-       xmlValidCtxt vctx;
-       xmlDtdPtr dtd;
-       int ret;
-       struct str_buf errors;
-
-       if (ret_err)
-               *ret_err = NULL;
-
-       doc = xmlNewDoc((xmlChar *) "1.0");
-       if (doc == NULL)
-               return -1;
-       n = xmlDocCopyNode((xmlNodePtr) node, doc, 1);
-       if (n == NULL) {
-               xmlFreeDoc(doc);
-               return -1;
-       }
-       xmlDocSetRootElement(doc, n);
-
-       os_memset(&errors, 0, sizeof(errors));
-
-       dtd = xmlParseDTD(NULL, (const xmlChar *) dtd_fname);
-       if (dtd == NULL) {
-               xmlFreeDoc(doc);
-               return -1;
-       }
-
-       os_memset(&vctx, 0, sizeof(vctx));
-       vctx.userData = &errors;
-       vctx.error = add_str;
-       vctx.warning = add_str;
-       ret = xmlValidateDtd(&vctx, doc, dtd);
-       xmlFreeDoc(doc);
-       xmlFreeDtd(dtd);
-
-       if (ret == 1) {
-               os_free(errors.buf);
-               return 0;
-       } else {
-               if (ret_err)
-                       *ret_err = errors.buf;
-               else
-                       os_free(errors.buf);
-               return -1;
-       }
-}
-
-
 void xml_node_free(struct xml_node_ctx *ctx, xml_node_t *node)
 {
        xmlFreeNode((xmlNodePtr) node);
 }
 
 
-xml_node_t * xml_node_get_parent(struct xml_node_ctx *ctx, xml_node_t *node)
-{
-       return (xml_node_t *) ((xmlNodePtr) node)->parent;
-}
-
-
 xml_node_t * xml_node_from_buf(struct xml_node_ctx *ctx, const char *buf)
 {
        xmlDocPtr doc;
@@ -242,19 +93,6 @@ char * xml_node_to_str(struct xml_node_ctx *ctx, xml_node_t *node)
 }
 
 
-void xml_node_detach(struct xml_node_ctx *ctx, xml_node_t *node)
-{
-       xmlUnlinkNode((xmlNodePtr) node);
-}
-
-
-void xml_node_add_child(struct xml_node_ctx *ctx, xml_node_t *parent,
-                       xml_node_t *child)
-{
-       xmlAddChild((xmlNodePtr) parent, (xmlNodePtr) child);
-}
-
-
 xml_node_t * xml_node_create_root(struct xml_node_ctx *ctx, const char *ns_uri,
                                  const char *ns_prefix,
                                  xml_namespace_t **ret_ns, const char *name)
@@ -322,47 +160,6 @@ void xml_node_set_text(struct xml_node_ctx *ctx, xml_node_t *node,
 }
 
 
-int xml_node_add_attr(struct xml_node_ctx *ctx, xml_node_t *node,
-                     xml_namespace_t *ns, const char *name, const char *value)
-{
-       xmlAttrPtr attr;
-
-       if (ns) {
-               attr = xmlNewNsProp((xmlNodePtr) node, (xmlNsPtr) ns,
-                                   (const xmlChar *) name,
-                                   (const xmlChar *) value);
-       } else {
-               attr = xmlNewProp((xmlNodePtr) node, (const xmlChar *) name,
-                                 (const xmlChar *) value);
-       }
-
-       return attr ? 0 : -1;
-}
-
-
-char * xml_node_get_attr_value(struct xml_node_ctx *ctx, xml_node_t *node,
-                              char *name)
-{
-       return (char *) xmlGetNoNsProp((xmlNodePtr) node,
-                                      (const xmlChar *) name);
-}
-
-
-char * xml_node_get_attr_value_ns(struct xml_node_ctx *ctx, xml_node_t *node,
-                                 const char *ns_uri, char *name)
-{
-       return (char *) xmlGetNsProp((xmlNodePtr) node, (const xmlChar *) name,
-                                    (const xmlChar *) ns_uri);
-}
-
-
-void xml_node_get_attr_value_free(struct xml_node_ctx *ctx, char *val)
-{
-       if (val)
-               xmlFree((xmlChar *) val);
-}
-
-
 xml_node_t * xml_node_first_child(struct xml_node_ctx *ctx,
                                  xml_node_t *parent)
 {
@@ -426,14 +223,6 @@ char * xml_node_get_base64_text(struct xml_node_ctx *ctx, xml_node_t *node,
 }
 
 
-xml_node_t * xml_node_copy(struct xml_node_ctx *ctx, xml_node_t *node)
-{
-       if (node == NULL)
-               return NULL;
-       return (xml_node_t *) xmlCopyNode((xmlNodePtr) node, 1);
-}
-
-
 struct xml_node_ctx * xml_node_init_ctx(void *upper_ctx,
                                        const void *env)
 {