|
|
#include "libjwgc.h"
#include "libxode.h"
Go to the source code of this file.
Functions | |
void | expat_startElement (void *userdata, const char *name, const char **atts) |
void | expat_endElement (void *userdata, const char *name) |
void | expat_charData (void *userdata, const char *s, int len) |
xode | xode_str (char *str, int len) |
xode | xode_file (char *file) |
char * | xode_file_borked (char *file) |
int | xode2file (char *file, xode node) |
void | xode_put_expat_attribs (xode owner, const char **atts) |
|
Definition at line 81 of file JExpat.c. References xode, and xode_insert_cdata(). Referenced by xode_file(), and xode_str(). 00082 { 00083 xode *x = userdata; 00084 xode current = *x; 00085 00086 xode_insert_cdata(current, s, len); 00087 }
|
|
Definition at line 67 of file JExpat.c. References xode_struct::complete, xode, and xode_get_parent(). Referenced by xode_file(), and xode_str(). 00068 { 00069 xode *x = userdata; 00070 xode current = *x; 00071 00072 current->complete = 1; 00073 current = xode_get_parent(current); 00074 00075 /* if it's NULL we've hit the top folks, otherwise back up a level */ 00076 if (current != NULL) 00077 *x = current; 00078 }
|
|
Definition at line 48 of file JExpat.c. References atts, xode, xode_insert_tag(), xode_new(), and xode_put_expat_attribs(). Referenced by xode_file(), and xode_str(). 00049 { 00050 /* get the xode pointed to by the userdata */ 00051 xode *x = userdata; 00052 xode current = *x; 00053 00054 if (current == NULL) { 00055 /* allocate a base node */ 00056 current = xode_new(name); 00057 xode_put_expat_attribs(current, atts); 00058 *x = current; 00059 } 00060 else { 00061 *x = xode_insert_tag(current, name); 00062 xode_put_expat_attribs(*x, atts); 00063 } 00064 }
|
|
Definition at line 192 of file JExpat.c. References NULL, spools(), xode, xode_get_pool(), and xode_to_str(). 00193 { 00194 char *doc, *ftmp; 00195 int fd, i; 00196 00197 if (file == NULL || node == NULL) 00198 return -1; 00199 00200 ftmp = spools(xode_get_pool(node), file, ".t.m.p", xode_get_pool(node)); 00201 fd = open(ftmp, O_CREAT | O_WRONLY | O_TRUNC, 0600); 00202 if (fd < 0) 00203 return -1; 00204 00205 doc = xode_to_str(node); 00206 i = write(fd, doc, strlen(doc)); 00207 if (i < 0) 00208 return -1; 00209 00210 close(fd); 00211 00212 if (rename(ftmp, file) < 0) { 00213 unlink(ftmp); 00214 return -1; 00215 } 00216 return 1; 00217 }
|
|
Definition at line 121 of file JExpat.c. References expat_charData(), expat_endElement(), expat_startElement(), NULL, XML_Parse(), XML_Parser, XML_ParserCreate(), XML_ParserFree(), XML_SetCharacterDataHandler(), XML_SetElementHandler(), XML_SetUserData(), xode, and xode_free(). 00122 { 00123 XML_Parser p; 00124 xode *x, node; /* pointer to an xode */ 00125 char buf[BUFSIZ]; 00126 int done, fd, len; 00127 00128 if (NULL == file) 00129 return NULL; 00130 00131 fd = open(file, O_RDONLY); 00132 if (fd < 0) 00133 return NULL; 00134 00135 x = malloc(sizeof(void *)); 00136 00137 *x = NULL; /* pointer to NULL */ 00138 p = XML_ParserCreate(NULL); 00139 XML_SetUserData(p, x); 00140 XML_SetElementHandler(p, expat_startElement, expat_endElement); 00141 XML_SetCharacterDataHandler(p, expat_charData); 00142 do { 00143 len = read(fd, buf, BUFSIZ); 00144 done = len < BUFSIZ; 00145 if (!XML_Parse(p, buf, len, done)) { 00146 /* 00147 * jdebug(ZONE,"xode_file_parseerror: %s",(char 00148 * *)XML_ErrorString(XML_GetErrorCode(p))); 00149 */ 00150 xode_free(*x); 00151 *x = NULL; 00152 done = 1; 00153 } 00154 } while (!done); 00155 00156 node = *x; 00157 XML_ParserFree(p); 00158 free(x); 00159 close(fd); 00160 return node; /* return the xode x points to */ 00161 }
|
|
Definition at line 164 of file JExpat.c. References NULL, snprintf, XML_ErrorString(), XML_GetErrorCode(), XML_GetErrorColumnNumber, XML_GetErrorLineNumber, XML_Parse(), XML_Parser, XML_ParserCreate(), and XML_ParserFree(). 00165 { 00166 XML_Parser p; 00167 char buf[BUFSIZ]; 00168 static char err[1024]; 00169 int fd, len, done; 00170 00171 if (NULL == file) 00172 return "no file specified"; 00173 00174 fd = open(file, O_RDONLY); 00175 if (fd < 0) 00176 return "unable to open file"; 00177 00178 p = XML_ParserCreate(NULL); 00179 while (1) { 00180 len = read(fd, buf, BUFSIZ); 00181 done = len < BUFSIZ; 00182 if (!XML_Parse(p, buf, len, done)) { 00183 snprintf(err, 1023, "%s at line %d and column %d", XML_ErrorString(XML_GetErrorCode(p)), XML_GetErrorLineNumber(p), XML_GetErrorColumnNumber(p)); 00184 XML_ParserFree(p); 00185 close(fd); 00186 return err; 00187 } 00188 } 00189 }
|
|
Definition at line 220 of file JExpat.c. References atts, xode, and xode_put_attrib(). Referenced by expat_startElement(). 00221 { 00222 int i = 0; 00223 if (atts == NULL) 00224 return; 00225 while (atts[i] != '\0') { 00226 xode_put_attrib(owner, atts[i], atts[i + 1]); 00227 i += 2; 00228 } 00229 }
|
|
Definition at line 91 of file JExpat.c. References expat_charData(), expat_endElement(), expat_startElement(), NULL, XML_Parse(), XML_Parser, XML_ParserCreate(), XML_ParserFree(), XML_SetCharacterDataHandler(), XML_SetElementHandler(), XML_SetUserData(), xode, and xode_free(). 00092 { 00093 XML_Parser p; 00094 xode *x, node; /* pointer to an xode */ 00095 00096 if (NULL == str) 00097 return NULL; 00098 00099 x = malloc(sizeof(void *)); 00100 00101 *x = NULL; /* pointer to NULL */ 00102 p = XML_ParserCreate(NULL); 00103 XML_SetUserData(p, x); 00104 XML_SetElementHandler(p, expat_startElement, expat_endElement); 00105 XML_SetCharacterDataHandler(p, expat_charData); 00106 if (!XML_Parse(p, str, len, 1)) { 00107 /* 00108 * jdebug(ZONE,"xode_str_error: %s",(char 00109 * *)XML_ErrorString(XML_GetErrorCode(p))); 00110 */ 00111 xode_free(*x); 00112 *x = NULL; 00113 } 00114 node = *x; 00115 free(x); 00116 XML_ParserFree(p); 00117 return node; /* return the xode x points to */ 00118 }
|
Last updated at Tue Dec 18 21:07:42 PST 2007. | This site and project hosted by... |