*status = XML_LABEL_OK;
- if (g_strcasecmp (root->name, "Label") != 0) {
+ if (!xmlStrEqual (root->name, "Label")) {
g_warning (_("Bad root node = \"%s\""), root->name);
*status = XML_LABEL_ERROR_OPEN_PARSE;
return NULL;
gl_debug (DEBUG_XML, "node name = \"%s\"", node->name);
if (!xmlNodeIsText (node)) {
- if (g_strcasecmp (node->name, "Media_Type") == 0) {
+ if (xmlStrEqual (node->name, "Media_Type")) {
if (!xml04_parse_media_description (node, label)) {
*status = XML_LABEL_UNKNOWN_MEDIA;
}
- } else if (g_strcasecmp (node->name, "Text") == 0) {
+ } else if (xmlStrEqual (node->name, "Text")) {
object = gl_label_text_new (label);
xml04_parse_object (node, GL_LABEL_OBJECT(object));
xml04_parse_text_props (node, GL_LABEL_TEXT(object));
- } else if (g_strcasecmp (node->name, "Box") == 0) {
+ } else if (xmlStrEqual (node->name, "Box")) {
object = gl_label_box_new (label);
xml04_parse_object (node, GL_LABEL_OBJECT(object));
xml04_parse_box_props (node, GL_LABEL_BOX(object));
- } else if (g_strcasecmp (node->name, "Line") == 0) {
+ } else if (xmlStrEqual (node->name, "Line")) {
object = gl_label_line_new (label);
xml04_parse_object (node, GL_LABEL_OBJECT(object));
xml04_parse_line_props (node, GL_LABEL_LINE(object));
- } else if (g_strcasecmp (node->name, "Ellipse") == 0) {
+ } else if (xmlStrEqual (node->name, "Ellipse")) {
object = gl_label_ellipse_new (label);
xml04_parse_object (node, GL_LABEL_OBJECT(object));
xml04_parse_ellipse_props (node,
GL_LABEL_ELLIPSE(object));
- } else if (g_strcasecmp (node->name, "Image") == 0) {
+ } else if (xmlStrEqual (node->name, "Image")) {
object = gl_label_image_new (label);
xml04_parse_object (node, GL_LABEL_OBJECT(object));
xml04_parse_image_props (node, GL_LABEL_IMAGE(object));
- } else if (g_strcasecmp (node->name, "Barcode") == 0) {
+ } else if (xmlStrEqual (node->name, "Barcode")) {
object = gl_label_barcode_new (label);
xml04_parse_object (node, GL_LABEL_OBJECT(object));
xml04_parse_barcode_props (node,
GL_LABEL_BARCODE(object));
- } else if (g_strcasecmp (node->name, "Merge_Properties") == 0) {
+ } else if (xmlStrEqual (node->name, "Merge_Properties")) {
xml04_parse_merge_properties (node, label);
} else {
g_warning (_("bad node = \"%s\""), node->name);
for (line_node = object_node->xmlChildrenNode; line_node != NULL;
line_node = line_node->next) {
- if (g_strcasecmp (line_node->name, "Line") == 0) {
+ if (xmlStrEqual (line_node->name, "Line")) {
nodes = NULL;
for (text_node = line_node->xmlChildrenNode;
text_node != NULL; text_node = text_node->next) {
- if (g_strcasecmp (text_node->name, "Field") ==
+ if (xmlStrEqual (text_node->name, "Field") ==
0) {
node_text = g_new0 (glTextNode, 1);
node_text->field_flag = TRUE;
child = node->xmlChildrenNode;
text_node = g_new0 (glTextNode, 1);
- if (g_strcasecmp (child->name, "Field") == 0) {
+ if (xmlStrEqual (child->name, "Field")) {
text_node->field_flag = TRUE;
text_node->data = xmlGetProp (child, "name");
} else if (xmlNodeIsText (child)) {
xmlFreeDoc (doc);
- gl_label_set_filename (label, filename);
- gl_label_clear_modified (label);
+ if (label) {
+ gl_label_set_filename (label, filename);
+ gl_label_clear_modified (label);
+ }
gl_debug (DEBUG_XML, "END");
label = xml_doc_to_label (doc, status);
- gl_label_clear_modified (label);
-
xmlFreeDoc (doc);
+ if (label) {
+ gl_label_clear_modified (label);
+ }
+
gl_debug (DEBUG_XML, "END");
return label;
*status = XML_LABEL_OK;
- if (g_strcasecmp (root->name, "Document") != 0) {
+ if (!xmlStrEqual (root->name, "Document")) {
g_warning (_("Bad root node = \"%s\""), root->name);
*status = XML_LABEL_ERROR_OPEN_PARSE;
return NULL;
/* Pass 1, extract data nodes to pre-load cache. */
for (node = root->xmlChildrenNode; node != NULL; node = node->next) {
- if (g_strcasecmp (node->name, "Data") == 0) {
+ if (xmlStrEqual (node->name, "Data")) {
xml_parse_data (node, label);
}
}
/* Pass 2, now extract everything else. */
for (node = root->xmlChildrenNode; node != NULL; node = node->next) {
- if (g_strcasecmp (node->name, "Sheet") == 0) {
+ if (xmlStrEqual (node->name, "Sheet")) {
template = gl_xml_template_parse_sheet (node);
if (!template) {
*status = XML_LABEL_UNKNOWN_MEDIA;
}
gl_label_set_template (label, template);
gl_template_free (&template);
- } else if (g_strcasecmp (node->name, "Objects") == 0) {
+ } else if (xmlStrEqual (node->name, "Objects")) {
xml_parse_objects (node, label);
- } else if (g_strcasecmp (node->name, "Merge_Fields") == 0) {
+ } else if (xmlStrEqual (node->name, "Merge_Fields")) {
xml_parse_merge_fields (node, label);
- } else if (g_strcasecmp (node->name, "Data") == 0) {
+ } else if (xmlStrEqual (node->name, "Data")) {
/* Handled in pass 1. */
} else {
if (!xmlNodeIsText (node)) {
for (node = objects_node->xmlChildrenNode; node != NULL; node = node->next) {
- if (g_strcasecmp (node->name, "Object") == 0) {
+ if (xmlStrEqual (node->name, "Object")) {
xml_parse_object (node, label);
} else {
if (!xmlNodeIsText (node)) {
string = xmlGetProp (object_node, "type");
- if ( g_strcasecmp (string, "text") == 0 ) {
+ if ( xmlStrEqual (string, "Text") ) {
object = xml_parse_text_props (object_node, label);
- } else if ( g_strcasecmp (string, "box") == 0 ) {
+ } else if ( xmlStrEqual (string, "Box") ) {
object = xml_parse_box_props (object_node, label);
- } else if ( g_strcasecmp (string, "line") == 0 ) {
+ } else if ( xmlStrEqual (string, "Line") ) {
object = xml_parse_line_props (object_node, label);
- } else if ( g_strcasecmp (string, "ellipse") == 0 ) {
+ } else if ( xmlStrEqual (string, "Ellipse") ) {
object = xml_parse_ellipse_props (object_node, label);
- } else if ( g_strcasecmp (string, "image") == 0 ) {
+ } else if ( xmlStrEqual (string, "Image") ) {
object = xml_parse_image_props (object_node, label);
- } else if ( g_strcasecmp (string, "barcode") == 0 ) {
+ } else if ( xmlStrEqual (string, "Barcode") ) {
object = xml_parse_barcode_props (object_node, label);
} else {
g_warning ("Unknown label object type \"%s\"", string);
line_node != NULL;
line_node = line_node->next) {
- if (g_strcasecmp (line_node->name, "Line") == 0) {
+ if (xmlStrEqual (line_node->name, "Line")) {
nodes = NULL;
for (text_node = line_node->xmlChildrenNode;
text_node != NULL; text_node = text_node->next) {
- if (g_strcasecmp (text_node->name, "Field") == 0) {
+ if (xmlStrEqual (text_node->name, "Field")) {
node_text = g_new0 (glTextNode, 1);
node_text->field_flag = TRUE;
node_text->data = xmlGetProp (text_node, "name");
nodes = g_list_append (nodes, node_text);
- } else if (g_strcasecmp (text_node->name, "Literal") == 0) {
+ } else if (xmlStrEqual (text_node->name, "Literal")) {
node_text = g_new0 (glTextNode, 1);
node_text->field_flag = FALSE;
node_text->data =
filename = g_new0 (glTextNode, 1);
for (child = node->xmlChildrenNode; child != NULL; child = child->next) {
- if (g_strcasecmp (child->name, "Field") == 0) {
+ if (xmlStrEqual (child->name, "Field")) {
filename->field_flag = TRUE;
filename->data = xmlGetProp (child, "name");
- } else if (g_strcasecmp (child->name, "File") == 0) {
+ } else if (xmlStrEqual (child->name, "File")) {
filename->field_flag = FALSE;
filename->data = xmlGetProp (child, "src");
} else if (!xmlNodeIsText (child)) {
text_node = g_new0 (glTextNode, 1);
for (child = node->xmlChildrenNode; child != NULL; child = child->next) {
- if (g_strcasecmp (child->name, "Field") == 0) {
+ if (xmlStrEqual (child->name, "Field")) {
text_node->field_flag = TRUE;
text_node->data = xmlGetProp (child, "name");
- } else if (g_strcasecmp (child->name, "Literal") == 0) {
+ } else if (xmlStrEqual (child->name, "Literal")) {
text_node->field_flag = FALSE;
text_node->data = xmlNodeGetContent (child);
} else if (!xmlNodeIsText (child)) {
for (child = node->xmlChildrenNode; child != NULL; child = child->next) {
- if (g_strcasecmp (child->name, "Pixdata") == 0) {
+ if (xmlStrEqual (child->name, "Pixdata")) {
xml_parse_pixdata (child, label);
} else {
if (!xmlNodeIsText (child)) {
xmlFreeDoc (doc);
return templates;
}
- if (g_strcasecmp (root->name, "glabels-templates") != 0) {
+ if (!xmlStrEqual (root->name, "GLabels-templates")) {
g_warning ("\"%s\" is not a glabels template file (wrong root node)",
xml_filename);
xmlFreeDoc (doc);
for (node = root->xmlChildrenNode; node != NULL; node = node->next) {
- if (g_strcasecmp (node->name, "Sheet") == 0) {
+ if (xmlStrEqual (node->name, "Sheet")) {
template = gl_xml_template_parse_sheet (node);
templates = g_list_append (templates, template);
} else {
if ( !xmlNodeIsText(node) ) {
- if (g_strcasecmp (node->name,"comment") != 0) {
+ if (!xmlStrEqual (node->name,"comment")) {
g_warning ("bad node = \"%s\"",node->name);
}
}
gl_debug (DEBUG_TEMPLATE, "Sheet = %s", template->name->data);
template->page_size = xmlGetProp (sheet_node, "size");
- if ( strcmp (template->page_size,"US-Letter") == 0 ) {
+ if ( xmlStrEqual (template->page_size,"US-Letter")) {
template->page_size = "US Letter";
}
- if (g_strcasecmp (template->page_size, "Other") == 0) {
+ if (xmlStrEqual (template->page_size, "Other")) {
template->page_width = gl_xml_get_prop_double (sheet_node, "width", 0);
template->page_height = gl_xml_get_prop_double (sheet_node, "height", 0);
for (node = sheet_node->xmlChildrenNode; node != NULL;
node = node->next) {
- if (g_strcasecmp (node->name, "Label") == 0) {
+ if (xmlStrEqual (node->name, "Label")) {
xml_parse_label (node, template);
- } else if (g_strcasecmp (node->name, "Alias") == 0) {
+ } else if (xmlStrEqual (node->name, "Alias")) {
xml_parse_alias (node, template);
} else {
- if (g_strcasecmp (node->name, "text") != 0) {
+ if (!xmlNodeIsText (node)) {
g_warning ("bad node = \"%s\"", node->name);
}
}
gl_debug (DEBUG_TEMPLATE, "START");
style = xmlGetProp (label_node, "style");
- if (g_strcasecmp (style, "rectangle") == 0) {
+ if (xmlStrEqual (style, "rectangle")) {
template->label.style = GL_TEMPLATE_STYLE_RECT;
- } else if (g_strcasecmp (style, "round") == 0) {
+ } else if (xmlStrEqual (style, "round")) {
template->label.style = GL_TEMPLATE_STYLE_ROUND;
- } else if (g_strcasecmp (style, "cd") == 0) {
+ } else if (xmlStrEqual (style, "cd")) {
template->label.style = GL_TEMPLATE_STYLE_CD;
} else {
template->label.style = GL_TEMPLATE_STYLE_RECT;
for (node = label_node->xmlChildrenNode; node != NULL;
node = node->next) {
- if (g_strcasecmp (node->name, "Layout") == 0) {
+ if (xmlStrEqual (node->name, "Layout")) {
xml_parse_layout (node, template);
- } else if (g_strcasecmp (node->name, "Markup") == 0) {
+ } else if (xmlStrEqual (node->name, "Markup")) {
xml_parse_markup (node, template);
- } else if (g_strcasecmp (node->name, "text") != 0) {
+ } else if (!xmlNodeIsText (node)) {
g_warning ("bad node = \"%s\"", node->name);
}
}
for (node = layout_node->xmlChildrenNode; node != NULL;
node = node->next) {
- if (g_strcasecmp (node->name, "text") != 0) {
+ if (!xmlNodeIsText (node)) {
g_warning ("bad node = \"%s\"", node->name);
}
}
gl_debug (DEBUG_TEMPLATE, "START");
type = xmlGetProp (markup_node, "type");
- if (g_strcasecmp (type, "margin") == 0) {
+ if (xmlStrEqual (type, "margin")) {
size = gl_xml_get_prop_double (markup_node, "size", 0);
g_list_append (template->label.any.markups,
gl_template_markup_margin_new (size));
- } else if (g_strcasecmp (type, "line") == 0) {
+ } else if (xmlStrEqual (type, "line")) {
x1 = gl_xml_get_prop_double (markup_node, "x1", 0);
y1 = gl_xml_get_prop_double (markup_node, "y1", 0);
for (node = markup_node->xmlChildrenNode; node != NULL;
node = node->next) {
- if (g_strcasecmp (node->name, "text") != 0) {
+ if (!xmlNodeIsText (node)) {
g_warning ("bad node = \"%s\"", node->name);
}
}
xmlSetProp (node, "name", template->name->data);
xmlSetProp (node, "size", template->page_size);
- if (g_strcasecmp (template->page_size, "Other") == 0) {
+ if (xmlStrEqual (template->page_size, "Other")) {
gl_xml_set_prop_double (node, "width", template->page_width);
gl_xml_set_prop_double (node, "height", template->page_height);
string = xmlGetProp (node, property);
if ( string != NULL ) {
- val = !(g_strcasecmp (string, "false") == 0);
+ val = !((xmlStrcasecmp (string, "false") == 0) ||
+ xmlStrEqual (string, "0"));;
g_free (string);
return val;
}