Use a local sax handler.
2000-09-20 JP Rosevear <jpr@helixcode.com> * pcs/cal-backend.c (cal_backend_get_log_entries): Use a local sax handler. * conduits/todo/todo-conduit.c (pre_sync): Use xmlSAXParseFile (map_sax_parse): Delete svn path=/trunk/; revision=5524
This commit is contained in:
@ -1,3 +1,11 @@
|
||||
2000-09-20 JP Rosevear <jpr@helixcode.com>
|
||||
|
||||
* pcs/cal-backend.c (cal_backend_get_log_entries): Use a local
|
||||
sax handler.
|
||||
|
||||
* conduits/todo/todo-conduit.c (pre_sync): Use xmlSAXParseFile
|
||||
(map_sax_parse): Delete
|
||||
|
||||
2000-09-20 JP Rosevear <jpr@helixcode.com>
|
||||
|
||||
* pcs/cal-backend.c (cal_backend_log_sax_start_element): Properly
|
||||
|
||||
@ -186,36 +186,6 @@ map_sax_start_element (void *data, const xmlChar *name,
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
map_sax_parse (xmlSAXHandler *handler, EToDoConduitContext *ctxt, const char *filename)
|
||||
{
|
||||
int ret = 0;
|
||||
xmlParserCtxtPtr xc;
|
||||
|
||||
if (!g_file_exists (filename))
|
||||
return 0;
|
||||
|
||||
xc = xmlCreateFileParserCtxt (filename);
|
||||
if (xc == NULL)
|
||||
return -1;
|
||||
|
||||
xc->sax = handler;
|
||||
xc->userData = (void *)ctxt;
|
||||
|
||||
xmlParseDocument (xc);
|
||||
|
||||
if (xc->wellFormed)
|
||||
ret = 0;
|
||||
else
|
||||
ret = -1;
|
||||
|
||||
if (handler != NULL)
|
||||
xc->sax = NULL;
|
||||
xmlFreeParserCtxt(xc);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void
|
||||
map_write_foreach (gpointer key, gpointer value, gpointer data)
|
||||
{
|
||||
@ -615,9 +585,8 @@ pre_sync (GnomePilotConduit *conduit,
|
||||
handler.startElement = map_sax_start_element;
|
||||
|
||||
filename = map_name (ctxt);
|
||||
ret = map_sax_parse (&handler, ctxt, filename);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
if (xmlSAXUserParseFile (&logSAXParser, ctxt, filename) < 0)
|
||||
return -1;
|
||||
|
||||
g_free (filename);
|
||||
|
||||
|
||||
@ -637,36 +637,10 @@ cal_backend_log_sax_end_element (CalBackendParseState *state, const CHAR *name)
|
||||
}
|
||||
}
|
||||
|
||||
static xmlSAXHandler logSAXParser = {
|
||||
0, /* internalSubset */
|
||||
0, /* isStandalone */
|
||||
0, /* hasInternalSubset */
|
||||
0, /* hasExternalSubset */
|
||||
0, /* resolveEntity */
|
||||
0, /* getEntity */
|
||||
0, /* entityDecl */
|
||||
0, /* notationDecl */
|
||||
0, /* attributeDecl */
|
||||
0, /* elementDecl */
|
||||
0, /* unparsedEntityDecl */
|
||||
0, /* setDocumentLocator */
|
||||
0, /* startDocument */
|
||||
0, /* endDocument */
|
||||
(startElementSAXFunc)cal_backend_log_sax_start_element, /* startElement */
|
||||
(endElementSAXFunc)cal_backend_log_sax_end_element, /* endElement */
|
||||
0, /* reference */
|
||||
0, /* characters */
|
||||
0, /* ignorableWhitespace */
|
||||
0, /* processingInstruction */
|
||||
0, /* comment */
|
||||
0, /* warning */
|
||||
0, /* error */
|
||||
0, /* fatalError */
|
||||
};
|
||||
|
||||
static GHashTable *
|
||||
cal_backend_get_log_entries (CalBackend *backend, CalObjType type, time_t since)
|
||||
{
|
||||
xmlSAXHandler handler;
|
||||
CalBackendParseState state;
|
||||
GHashTable *hash;
|
||||
char *filename;
|
||||
@ -678,7 +652,9 @@ cal_backend_get_log_entries (CalBackend *backend, CalObjType type, time_t since)
|
||||
if (!cal_backend_log_sync (backend))
|
||||
return NULL;
|
||||
|
||||
filename = cal_backend_log_name (backend->uri);
|
||||
memset (&handler, 0, sizeof (xmlSAXHandler));
|
||||
handler.startElement = (startElementSAXFunc)cal_backend_log_sax_start_element;
|
||||
handler.endElement = (endElementSAXFunc)cal_backend_log_sax_end_element;
|
||||
|
||||
hash = g_hash_table_new (g_str_hash, g_str_equal);
|
||||
|
||||
@ -687,6 +663,7 @@ cal_backend_get_log_entries (CalBackend *backend, CalObjType type, time_t since)
|
||||
state.in_valid_timestamp = FALSE;
|
||||
state.hash = hash;
|
||||
|
||||
filename = cal_backend_log_name (backend->uri);
|
||||
if (xmlSAXUserParseFile (&logSAXParser, &state, filename) < 0)
|
||||
return NULL;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user