2003-09-28 21:09:04 +00:00
|
|
|
/*
|
2005-01-29 07:21:44 +00:00
|
|
|
* "$Id$"
|
2003-09-28 21:09:04 +00:00
|
|
|
*
|
2004-05-02 16:04:40 +00:00
|
|
|
* Private functions for Mini-XML, a small XML-like file parsing library.
|
2003-09-28 21:09:04 +00:00
|
|
|
*
|
2005-01-29 07:21:44 +00:00
|
|
|
* Copyright 2003-2005 by Michael Sweet.
|
2003-09-28 21:09:04 +00:00
|
|
|
*
|
|
|
|
* This program 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, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program 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 General Public License for more details.
|
|
|
|
*
|
|
|
|
* Contents:
|
|
|
|
*
|
2003-12-03 03:59:04 +00:00
|
|
|
* mxml_error() - Display an error message.
|
2003-09-28 21:09:04 +00:00
|
|
|
* mxml_integer_cb() - Default callback for integer values.
|
|
|
|
* mxml_opaque_cb() - Default callback for opaque values.
|
|
|
|
* mxml_real_cb() - Default callback for real number values.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Include necessary headers...
|
|
|
|
*/
|
|
|
|
|
2003-12-03 03:59:04 +00:00
|
|
|
#include "config.h"
|
2003-09-28 21:09:04 +00:00
|
|
|
#include "mxml.h"
|
|
|
|
|
|
|
|
|
2003-12-03 03:59:04 +00:00
|
|
|
/*
|
|
|
|
* Error callback function...
|
|
|
|
*/
|
|
|
|
|
|
|
|
void (*mxml_error_cb)(const char *) = NULL;
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* 'mxml_error()' - Display an error message.
|
|
|
|
*/
|
|
|
|
|
|
|
|
void
|
|
|
|
mxml_error(const char *format, /* I - Printf-style format string */
|
|
|
|
...) /* I - Additional arguments as needed */
|
|
|
|
{
|
|
|
|
va_list ap; /* Pointer to arguments */
|
|
|
|
char *s; /* Message string */
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Range check input...
|
|
|
|
*/
|
|
|
|
|
|
|
|
if (!format)
|
|
|
|
return;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Format the error message string...
|
|
|
|
*/
|
|
|
|
|
|
|
|
va_start(ap, format);
|
|
|
|
|
|
|
|
s = mxml_strdupf(format, ap);
|
|
|
|
|
|
|
|
va_end(ap);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* And then display the error message...
|
|
|
|
*/
|
|
|
|
|
|
|
|
if (mxml_error_cb)
|
|
|
|
(*mxml_error_cb)(s);
|
|
|
|
else
|
2004-06-01 20:19:34 +00:00
|
|
|
fprintf(stderr, "mxml: %s\n", s);
|
2003-12-03 03:59:04 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Free the string...
|
|
|
|
*/
|
|
|
|
|
|
|
|
free(s);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-09-28 21:09:04 +00:00
|
|
|
/*
|
|
|
|
* 'mxml_integer_cb()' - Default callback for integer values.
|
|
|
|
*/
|
|
|
|
|
|
|
|
mxml_type_t /* O - Node type */
|
|
|
|
mxml_integer_cb(mxml_node_t *node) /* I - Current node */
|
|
|
|
{
|
|
|
|
(void)node;
|
|
|
|
|
|
|
|
return (MXML_INTEGER);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* 'mxml_opaque_cb()' - Default callback for opaque values.
|
|
|
|
*/
|
|
|
|
|
|
|
|
mxml_type_t /* O - Node type */
|
|
|
|
mxml_opaque_cb(mxml_node_t *node) /* I - Current node */
|
|
|
|
{
|
|
|
|
(void)node;
|
|
|
|
|
|
|
|
return (MXML_OPAQUE);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* 'mxml_real_cb()' - Default callback for real number values.
|
|
|
|
*/
|
|
|
|
|
|
|
|
mxml_type_t /* O - Node type */
|
|
|
|
mxml_real_cb(mxml_node_t *node) /* I - Current node */
|
|
|
|
{
|
|
|
|
(void)node;
|
|
|
|
|
|
|
|
return (MXML_REAL);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
2005-01-29 07:21:44 +00:00
|
|
|
* End of "$Id$".
|
2003-09-28 21:09:04 +00:00
|
|
|
*/
|