/home/dko/projects/mobilec/trunk/src/mxml-2.2.2/mxml-private.c

Go to the documentation of this file.
00001 /*
00002  * "$Id: mxml-private.c,v 1.1 2007/05/23 20:43:27 david_ko Exp $"
00003  *
00004  * Private functions for Mini-XML, a small XML-like file parsing library.
00005  *
00006  * Copyright 2003-2005 by Michael Sweet.
00007  *
00008  * This program is free software; you can redistribute it and/or
00009  * modify it under the terms of the GNU Library General Public
00010  * License as published by the Free Software Foundation; either
00011  * version 2, or (at your option) any later version.
00012  *
00013  * This program is distributed in the hope that it will be useful,
00014  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00015  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016  * GNU General Public License for more details.
00017  *
00018  * Contents:
00019  *
00020  *   mxml_error()      - Display an error message.
00021  *   mxml_integer_cb() - Default callback for integer values.
00022  *   mxml_opaque_cb()  - Default callback for opaque values.
00023  *   mxml_real_cb()    - Default callback for real number values.
00024  */
00025 
00026 /*
00027  * Include necessary headers...
00028  */
00029 
00030 #include "config.h"
00031 #include "mxml.h"
00032 
00033 
00034 /*
00035  * Error callback function...
00036  */
00037 
00038 void    (*mxml_error_cb)(const char *) = NULL;
00039 
00040 
00041 /*
00042  * 'mxml_error()' - Display an error message.
00043  */
00044 
00045 void
00046 mxml_error(const char *format,          /* I - Printf-style format string */
00047            ...)                         /* I - Additional arguments as needed */
00048 {
00049   va_list       ap;                     /* Pointer to arguments */
00050   char          *s;                     /* Message string */
00051 
00052 
00053  /*
00054   * Range check input...
00055   */
00056 
00057   if (!format)
00058     return;
00059 
00060  /*
00061   * Format the error message string...
00062   */
00063 
00064   va_start(ap, format);
00065 
00066   s = mxml_strdupf(format, ap);
00067 
00068   va_end(ap);
00069 
00070  /*
00071   * And then display the error message...
00072   */
00073 
00074   if (mxml_error_cb)
00075     (*mxml_error_cb)(s);
00076   else
00077     fprintf(stderr, "mxml: %s\n", s);
00078 
00079  /*
00080   * Free the string...
00081   */
00082 
00083   free(s);
00084 }
00085 
00086 
00087 /*
00088  * 'mxml_integer_cb()' - Default callback for integer values.
00089  */
00090 
00091 mxml_type_t                             /* O - Node type */
00092 mxml_integer_cb(mxml_node_t *node)      /* I - Current node */
00093 {
00094   (void)node;
00095 
00096   return (MXML_INTEGER);
00097 }
00098 
00099 
00100 /*
00101  * 'mxml_opaque_cb()' - Default callback for opaque values.
00102  */
00103 
00104 mxml_type_t                             /* O - Node type */
00105 mxml_opaque_cb(mxml_node_t *node)       /* I - Current node */
00106 {
00107   (void)node;
00108 
00109   return (MXML_OPAQUE);
00110 }
00111 
00112 
00113 /*
00114  * 'mxml_real_cb()' - Default callback for real number values.
00115  */
00116 
00117 mxml_type_t                             /* O - Node type */
00118 mxml_real_cb(mxml_node_t *node)         /* I - Current node */
00119 {
00120   (void)node;
00121 
00122   return (MXML_REAL);
00123 }
00124 
00125 
00126 /*
00127  * End of "$Id: mxml-private.c,v 1.1 2007/05/23 20:43:27 david_ko Exp $".
00128  */

Generated on Fri May 16 14:49:54 2008 for Mobile-C by  doxygen 1.5.4