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