From 85c5e09eacc5c89eda6e1ffa6f039fa1e8dd7221 Mon Sep 17 00:00:00 2001 From: Marc Cromme Date: Wed, 14 Feb 2007 15:42:24 +0000 Subject: [PATCH] removed wanings by zillions of (const char *) casts and the like --- index/mod_dom.c | 117 ++++++++++++++++++++++++++----------------------------- 1 file changed, 56 insertions(+), 61 deletions(-) diff --git a/index/mod_dom.c b/index/mod_dom.c index 90bec9f..d36c7e8 100644 --- a/index/mod_dom.c +++ b/index/mod_dom.c @@ -1,4 +1,4 @@ -/* $Id: mod_dom.c,v 1.6 2007-02-14 15:23:33 marc Exp $ +/* $Id: mod_dom.c,v 1.7 2007-02-14 15:42:24 marc Exp $ Copyright (C) 1995-2007 Index Data ApS @@ -756,7 +756,7 @@ static void extract_doc_alvis(struct filter_info *tinfo, static int attr_content_xml(struct _xmlAttr *attr, const char *name, xmlChar **dst_content) { - if (0 == strcmp(attr->name, name) && attr->children + if (0 == XML_STRCMP(attr->name, name) && attr->children && attr->children->type == XML_TEXT_NODE) { *dst_content = (attr->children->content); @@ -778,12 +778,12 @@ static const char *zebra_pi_name = ZEBRA_PI_NAME; void index_value_of(xmlNodePtr node, xmlChar * index_p){ xmlChar *text = xmlNodeGetContent(node); - const char *look = index_p; - const char *bval; - const char *eval; + xmlChar *look = index_p; + xmlChar *bval; + xmlChar *eval; - char index[256]; - char type[256]; + xmlChar index[256]; + xmlChar type[256]; /* parsing all index name/type pairs - may not start with ' ' or ':' */ while (*look && ' ' != *look && ':' != *look){ @@ -798,7 +798,7 @@ void index_value_of(xmlNodePtr node, xmlChar * index_p){ look++; } eval = look; - strncpy(index, bval, eval - bval); + strncpy((char *)index, (const char *)bval, eval - bval); index[eval - bval] = '\0'; @@ -811,7 +811,7 @@ void index_value_of(xmlNodePtr node, xmlChar * index_p){ look++; } eval = look; - strncpy(type, bval, eval - bval); + strncpy((char *)type, (const char *)bval, eval - bval); type[eval - bval] = '\0'; } @@ -842,12 +842,10 @@ void set_record_info(xmlChar * id_p, xmlChar * rank_p, xmlChar * action_p){ /* DOM filter style indexing */ void process_xml_element_zebra_node(xmlNodePtr node, xmlChar **record_p) { - xmlChar *err_p = 0; - if (node->type == XML_ELEMENT_NODE - && node->ns && 0 == strcmp(node->ns->href, zebra_xslt_ns)){ + && node->ns && 0 == XML_STRCMP(node->ns->href, zebra_xslt_ns)){ - if (0 == strcmp(node->name, "index")){ + if (0 == XML_STRCMP(node->name, "index")){ xmlChar *index_p = 0; struct _xmlAttr *attr; @@ -862,7 +860,7 @@ void process_xml_element_zebra_node(xmlNodePtr node, xmlChar **record_p) xmlGetNodePath(node), attr->name); } } - else if (0 == strcmp(node->name, "record")){ + else if (0 == XML_STRCMP(node->name, "record")){ xmlChar *id_p = 0; xmlChar *rank_p = 0; xmlChar *action_p = 0; @@ -882,7 +880,7 @@ void process_xml_element_zebra_node(xmlNodePtr node, xmlChar **record_p) " expected @id|@rank|@action\n", xmlGetNodePath(node), attr->name); - if (action_p && 0 != strcmp("update", action_p)) + if (action_p && 0 != strcmp("update", (const char *)action_p)) printf("dom filter: %s attribute @%s," " only implemented '@action=\"update\"\n", xmlGetNodePath(node), attr->name); @@ -903,57 +901,21 @@ void process_xml_element_zebra_node(xmlNodePtr node, xmlChar **record_p) /* DOM filter style indexing */ -void process_xml_element_node(xmlNodePtr node, xmlChar **record_pp) -{ - /* remember indexing instruction from PI to next element node */ - xmlChar *index_p = 0; - - printf("ELEM %s\n", xmlGetNodePath(node)); - - /* check if we are an element node in the special zebra namespace - and either set record data or index value-of node content*/ - process_xml_element_zebra_node(node, record_pp); - - /* loop through kid nodes */ - for (node = node->children; node; node = node->next) - { - /* check and set PI record and index index instructions */ - if (node->type == XML_PI_NODE){ - process_xml_pi_node(node, record_pp, &index_p); - } - else if (node->type == XML_ELEMENT_NODE){ - /* if there was a PI index instruction before this element node */ - if (index_p){ - index_value_of(node, index_p); - index_p = 0; - } - process_xml_element_node(node, record_pp); - } - else - continue; - } -} - - -/* DOM filter style indexing */ -int process_xml_pi_node(xmlNodePtr node, xmlChar **record_pp, +void process_xml_pi_node(xmlNodePtr node, xmlChar **record_pp, xmlChar **index_pp) { - printf("PI %s\n", xmlGetNodePath(node)); + printf("PI %s\n", xmlGetNodePath(node)); /* if right PI name, continue parsing PI */ - if (0 == strcmp("zebra-2.0", node->name)){ + if (0 == strcmp(zebra_pi_name, (const char *)node->name)){ xmlChar *pi_p = node->content; xmlChar *look = pi_p; xmlChar *bval; xmlChar *eval; - xmlChar *index_p = 0; - - /* parsing PI record instructions */ - if (0 == strncmp(look, "record", 6)){ + if (0 == strncmp((const char *)look, "record", 6)){ xmlChar id[256]; xmlChar rank[256]; xmlChar action[256]; @@ -969,13 +931,13 @@ int process_xml_pi_node(xmlNodePtr node, xmlChar **record_pp, look++; /* parse possible id */ - if (*look && 0 == strncmp(look, "id=", 3)){ + if (*look && 0 == strncmp((const char *)look, "id=", 3)){ look += 3; bval = look; while (*look && ' ' != *look) look++; eval = look; - strncpy(id, bval, eval - bval); + strncpy((char *)id, (const char *)bval, eval - bval); id[eval - bval] = '\0'; } @@ -984,13 +946,13 @@ int process_xml_pi_node(xmlNodePtr node, xmlChar **record_pp, look++; /* parse possible rank */ - if (*look && 0 == strncmp(look, "rank=", 5)){ + if (*look && 0 == strncmp((const char *)look, "rank=", 5)){ look += 6; bval = look; while (*look && ' ' != *look) look++; eval = look; - strncpy(rank, bval, eval - bval); + strncpy((char *)rank, (const char *)bval, eval - bval); rank[eval - bval] = '\0'; } @@ -1009,7 +971,7 @@ int process_xml_pi_node(xmlNodePtr node, xmlChar **record_pp, } /* parsing index instruction */ - else if (0 == strncmp(look, "index", 5)){ + else if (0 == strncmp((const char *)look, "index", 5)){ look += 5; /* eat whitespace */ @@ -1028,13 +990,46 @@ int process_xml_pi_node(xmlNodePtr node, xmlChar **record_pp, } } +/* DOM filter style indexing */ +void process_xml_element_node(xmlNodePtr node, xmlChar **record_pp) +{ + /* remember indexing instruction from PI to next element node */ + xmlChar *index_p = 0; + + printf("ELEM %s\n", xmlGetNodePath(node)); + + /* check if we are an element node in the special zebra namespace + and either set record data or index value-of node content*/ + process_xml_element_zebra_node(node, record_pp); + + /* loop through kid nodes */ + for (node = node->children; node; node = node->next) + { + /* check and set PI record and index index instructions */ + if (node->type == XML_PI_NODE){ + process_xml_pi_node(node, record_pp, &index_p); + } + else if (node->type == XML_ELEMENT_NODE){ + /* if there was a PI index instruction before this element node */ + if (index_p){ + index_value_of(node, index_p); + index_p = 0; + } + process_xml_element_node(node, record_pp); + } + else + continue; + } +} + + /* DOM filter style indexing */ void process_xml_doc_node(xmlDocPtr doc) { xmlChar *record_pp; - printf("DOC %s\n", xmlGetNodePath(doc)); + printf("DOC %s\n", xmlGetNodePath((xmlNodePtr)doc)); process_xml_element_node((xmlNodePtr)doc, &record_pp); } -- 1.7.10.4