/*
- * (LIBGLABELS) Template library for GLABELS
+ * xml.c
+ * Copyright (C) 2003-2009 Jim Evins <evins@snaught.com>.
*
- * xml.c: GLabels xml utilities module
+ * This file is part of libglabels.
*
- * Copyright (C) 2003, 2004 Jim Evins <evins@snaught.com>.
+ * libglabels is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
*
- * This file is part of the LIBGLABELS library.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
+ * libglabels is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
*
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the Free
- * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
- * MA 02111-1307, USA
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with libglabels. If not, see <http://www.gnu.org/licenses/>.
*/
+
#include <config.h>
#include "xml.h"
#include <glib/gi18n.h>
-#include <glib/gstrfuncs.h>
-#include <glib/gmessages.h>
+#include <glib.h>
#include <string.h>
#include "libglabels-private.h"
/* These names are identical to the absolute length units supported in
the CSS2 Specification (Section 4.3.2) */
- /* This table must be sorted exactly as the enumerations in glUnitsType */
+ /* This table must be sorted exactly as the enumerations in lglUnitsType */
- /* [GL_UNITS_POINT] */ {(xmlChar *)"pt", POINTS_PER_POINT},
- /* [GL_UNITS_INCH] */ {(xmlChar *)"in", POINTS_PER_INCH},
- /* [GL_UNITS_MM] */ {(xmlChar *)"mm", POINTS_PER_MM},
- /* [GL_UNITS_CM] */ {(xmlChar *)"cm", POINTS_PER_CM},
- /* [GL_UNITS_PICA] */ {(xmlChar *)"pc", POINTS_PER_PICA},
+ /* [LGL_UNITS_POINT] */ {(xmlChar *)"pt", POINTS_PER_POINT},
+ /* [LGL_UNITS_INCH] */ {(xmlChar *)"in", POINTS_PER_INCH},
+ /* [LGL_UNITS_MM] */ {(xmlChar *)"mm", POINTS_PER_MM},
+ /* [LGL_UNITS_CM] */ {(xmlChar *)"cm", POINTS_PER_CM},
+ /* [LGL_UNITS_PICA] */ {(xmlChar *)"pc", POINTS_PER_PICA},
};
-static glUnitsType default_units = GL_UNITS_POINT;
+static lglUnitsType default_units = LGL_UNITS_POINT;
/****************************************************************************/
/**
- * gl_xml_get_prop_string:
+ * lgl_xml_get_prop_string:
* @node: the libxml2 #xmlNodePtr of the node
* @property: the property name
* @default_val: a default value to return if property not found
*
*/
gchar *
-gl_xml_get_prop_string (xmlNodePtr node,
- const gchar *property,
- const gchar *default_val)
+lgl_xml_get_prop_string (xmlNodePtr node,
+ const gchar *property,
+ const gchar *default_val)
{
gchar *val;
xmlChar *string;
/**
- * gl_xml_get_prop_i18n_string:
+ * lgl_xml_get_prop_i18n_string:
* @node: the libxml2 #xmlNodePtr of the node
* @property: the property name
* @default_val: a default value to return if property not found
*
*/
gchar *
-gl_xml_get_prop_i18n_string (xmlNodePtr node,
- const gchar *property,
- const gchar *default_val)
+lgl_xml_get_prop_i18n_string (xmlNodePtr node,
+ const gchar *property,
+ const gchar *default_val)
{
gchar *_property;
gchar *val;
/**
- * gl_xml_get_prop_double:
+ * lgl_xml_get_prop_double:
* @node: the libxml2 #xmlNodePtr of the node
* @property: the property name
* @default_val: a default value to return if property not found
*
*/
gdouble
-gl_xml_get_prop_double (xmlNodePtr node,
- const gchar *property,
- gdouble default_val)
+lgl_xml_get_prop_double (xmlNodePtr node,
+ const gchar *property,
+ gdouble default_val)
{
gdouble val;
xmlChar *string;
/**
- * gl_xml_get_prop_boolean:
+ * lgl_xml_get_prop_boolean:
* @node: the libxml2 #xmlNodePtr of the node
* @property: the property name
* @default_val: a default value to return if property not found
*
*/
gboolean
-gl_xml_get_prop_boolean (xmlNodePtr node,
+lgl_xml_get_prop_boolean (xmlNodePtr node,
const gchar *property,
gboolean default_val)
{
/**
- * gl_xml_get_prop_int:
+ * lgl_xml_get_prop_int:
* @node: the libxml2 #xmlNodePtr of the node
* @property: the property name
* @default_val: a default value to return if property not found
*
*/
gint
-gl_xml_get_prop_int (xmlNodePtr node,
- const gchar *property,
- gint default_val)
+lgl_xml_get_prop_int (xmlNodePtr node,
+ const gchar *property,
+ gint default_val)
{
gint val;
xmlChar *string;
/**
- * gl_xml_get_prop_uint:
+ * lgl_xml_get_prop_uint:
* @node: the libxml2 #xmlNodePtr of the node
* @property: the property name
* @default_val: a default value to return if property not found
*
*/
guint
-gl_xml_get_prop_uint (xmlNodePtr node,
- const gchar *property,
- guint default_val)
+lgl_xml_get_prop_uint (xmlNodePtr node,
+ const gchar *property,
+ guint default_val)
{
guint val;
xmlChar *string;
/**
- * gl_xml_get_prop_length:
+ * lgl_xml_get_prop_length:
* @node: the libxml2 #xmlNodePtr of the node
* @property: the property name
* @default_val: a default value to return if property not found
*
*/
gdouble
-gl_xml_get_prop_length (xmlNodePtr node,
- const gchar *property,
- gdouble default_val)
+lgl_xml_get_prop_length (xmlNodePtr node,
+ const gchar *property,
+ gdouble default_val)
{
gdouble val;
xmlChar *string;
if (unit != string) {
unit = (xmlChar *)g_strchug ((gchar *)unit);
if (strlen ((char *)unit) > 0 ) {
- for (i=GL_UNITS_FIRST; i<=GL_UNITS_LAST; i++) {
+ for (i=LGL_UNITS_FIRST; i<=LGL_UNITS_LAST; i++) {
if (xmlStrcasecmp (unit, unit_table[i].name) == 0) {
val *= unit_table[i].points_per_unit;
break;
}
}
- if (i>GL_UNITS_LAST) {
- g_message ("Line %d, Node \"%s\", Property \"%s\": Unknown unit \"%s\", assuming points",
+ if (i>LGL_UNITS_LAST) {
+ g_message ("Line %ld, Node \"%s\", Property \"%s\": Unknown unit \"%s\", assuming points",
xmlGetLineNo (node), node->name, property,
unit);
}
/**
- * gl_xml_set_prop_string:
+ * lgl_xml_set_prop_string:
* @node: the libxml2 #xmlNodePtr of the node
* @property: the property name
* @val: the value to set
*
*/
void
-gl_xml_set_prop_string (xmlNodePtr node,
- const gchar *property,
- const gchar *val)
+lgl_xml_set_prop_string (xmlNodePtr node,
+ const gchar *property,
+ const gchar *val)
{
if (val != NULL) {
xmlSetProp (node, (xmlChar *)property, (xmlChar *)val);
/**
- * gl_xml_set_prop_double:
+ * lgl_xml_set_prop_double:
* @node: the libxml2 #xmlNodePtr of the node
* @property: the property name
* @val: the value to set
*
*/
void
-gl_xml_set_prop_double (xmlNodePtr node,
- const gchar *property,
- gdouble val)
+lgl_xml_set_prop_double (xmlNodePtr node,
+ const gchar *property,
+ gdouble val)
{
gchar *string, buffer[G_ASCII_DTOSTR_BUF_SIZE];
/**
- * gl_xml_set_prop_boolean:
+ * lgl_xml_set_prop_boolean:
* @node: the libxml2 #xmlNodePtr of the node
* @property: the property name
* @val: the value to set
*
*/
void
-gl_xml_set_prop_boolean (xmlNodePtr node,
- const gchar *property,
- gboolean val)
+lgl_xml_set_prop_boolean (xmlNodePtr node,
+ const gchar *property,
+ gboolean val)
{
xmlSetProp (node, (xmlChar *)property, (xmlChar *)(val ? "True" : "False"));
}
/**
- * gl_xml_set_prop_int:
+ * lgl_xml_set_prop_int:
* @node: the libxml2 #xmlNodePtr of the node
* @property: the property name
* @val: the value to set
*
*/
void
-gl_xml_set_prop_int (xmlNodePtr node,
- const gchar *property,
- gint val)
+lgl_xml_set_prop_int (xmlNodePtr node,
+ const gchar *property,
+ gint val)
{
gchar *string;
}
/**
- * gl_xml_set_prop_uint_hex:
+ * lgl_xml_set_prop_uint_hex:
* @node: the libxml2 #xmlNodePtr of the node
* @property: the property name
* @val: the value to set
*
*/
void
-gl_xml_set_prop_uint_hex (xmlNodePtr node,
- const gchar *property,
- guint val)
+lgl_xml_set_prop_uint_hex (xmlNodePtr node,
+ const gchar *property,
+ guint val)
{
gchar *string;
}
/**
- * gl_xml_set_prop_length:
+ * lgl_xml_set_prop_length:
* @node: the libxml2 #xmlNodePtr of the node
* @property: the property name
* @val: the length to set in internal units (points)
* Set a property from a length, performing any necessary conversion.
* Length properties are formatted as a number followed by a units string.
* The units of the formatted property is determined by the most recent call to
- * gl_xml_set_default_units().
+ * lgl_xml_set_default_units().
*
*/
void
-gl_xml_set_prop_length (xmlNodePtr node,
- const gchar *property,
- gdouble val)
+lgl_xml_set_prop_length (xmlNodePtr node,
+ const gchar *property,
+ gdouble val)
{
gchar *string, buffer[G_ASCII_DTOSTR_BUF_SIZE];
gchar *string_unit;
}
/**
- * gl_xml_is_node
+ * lgl_xml_is_node
* @node: the libxml2 #xmlNodePtr of the node
- * @property: the node name
+ * @name : the node name
*
* Test if a node name matches given name.
*
*
*/
gboolean
-gl_xml_is_node (xmlNodePtr node,
- const gchar *name)
+lgl_xml_is_node (xmlNodePtr node,
+ const gchar *name)
{
return xmlStrEqual (node->name, (xmlChar *)name);
}
/**
- * gl_xml_get_node_content
+ * lgl_xml_get_node_content
* @node: the libxml2 #xmlNodePtr of the node
*
* Get the content of a node.
* be freed with g_free().
*/
gchar *
-gl_xml_get_node_content (xmlNodePtr node)
+lgl_xml_get_node_content (xmlNodePtr node)
{
xmlChar *xml_content;
gchar *g_content;
/**
- * gl_xml_set_default_units:
- * @units: default units selection (#glUnitsType)
+ * lgl_xml_set_default_units:
+ * @units: default units selection (#lglUnitsType)
*
* Set the default units when formatting lengths. See
- * gl_xml_set_prop_length().
+ * lgl_xml_set_prop_length().
*
*/
void
-gl_xml_set_default_units (glUnitsType units)
+lgl_xml_set_default_units (lglUnitsType units)
{
- g_return_if_fail ((units >= GL_UNITS_FIRST) && (units <= GL_UNITS_LAST));
+ g_return_if_fail ((units >= LGL_UNITS_FIRST) && (units <= LGL_UNITS_LAST));
default_units = units;
}
+
+/*
+ * Local Variables: -- emacs
+ * mode: C -- emacs
+ * c-basic-offset: 8 -- emacs
+ * tab-width: 8 -- emacs
+ * indent-tabs-mode: nil -- emacs
+ * End: -- emacs
+ */