#include "load_features.h" #include #include #include #include /* * An NCBI GBSeq structure to hold the data for the current record. */ GBSeqPtr g; bool in_element; static void lf_startDocument (void *ctx ATTRIBUTE_UNUSED) { printf ("SAX.startDocument()\n"); return; } static void lf_endDocument (void *ctx ATTRIBUTE_UNUSED) { printf ("SAX.endDocument()\n"); return; } static xmlEntityPtr lf_getEntity (void *ctx ATTRIBUTE_UNUSED, const xmlChar *name) { printf("SAX.getEntity(%s)\n", name); return (NULL); } static void lf_startElement(void *ctx ATTRIBUTE_UNUSED, const xmlChar *name, const xmlChar **atts) { int i; fprintf(stdout, "SAX.startElement(%s", (char *) name); if (atts != NULL) { for (i = 0;(atts[i] != NULL);i++) { fprintf(stdout, ", %s='", atts[i++]); if (atts[i] != NULL) fprintf(stdout, "%s'", atts[i]); } } fprintf(stdout, ")\n"); in_element = true; return; } static void lf_endElement(void *ctx ATTRIBUTE_UNUSED, const xmlChar *name) { printf("SAX.endElement(%s)\n", (char *) name); in_element = false; return; } static void lf_characters(void *ctx ATTRIBUTE_UNUSED, const xmlChar *ch, int len) { if (!in_element) return; char output[40]; int i; for (i = 0;(i 0) { ctxt = xmlCreatePushParserCtxt (emptySAXHandler, NULL, chars, ret, file_name); while ((ret = fread(chars, 1, 3, f)) > 0) { xmlParseChunk (ctxt, chars, ret, 0); } xmlParseChunk (ctxt, chars, 0, 1); xmlFreeParserCtxt(ctxt); } fclose (f); } else { xmlGenericError (xmlGenericErrorContext, "Cannot read file."); } GBSeqFree (g); return; }