64#define NAME_EXT_SIZE 128
65#define ATTR_EXT_SIZE 4096
66#define DATA_EXT_SIZE 4096
67#define LINE_BUF_SIZE 8192
69#define xmlError(a, b) xmlErrmsg(a, b, FALSE, __FILE__, __LINE__)
121 assert( ppos !=
NULL );
125 ret = fprintf(stderr,
"%s(%d) Error in file %s line %d\n", file, line, ppos->
filename, ppos->
lineno);
128 ret = fprintf(stderr,
"%s", ppos->
buf);
131 if ( strchr(ppos->
buf,
'\n') ==
NULL )
135 retc = fputc(
'\n', stderr);
139 ret = fprintf(stderr,
"%*s\n", ppos->
pos,
"^");
142 ret = fprintf(stderr,
"%s\n\n", msg);
149 (void) fprintf(stderr,
"%s(%d) Error in file %s line %d\n", file, line, ppos->
filename, ppos->
lineno);
151 (void) fprintf(stderr,
"%s", ppos->
buf);
153 if ( strchr(ppos->
buf,
'\n') ==
NULL )
155 (void) fputc(
'\n', stderr);
158 (void) fprintf(stderr,
"%*s\n", ppos->
pos,
"^");
160 (void) fprintf(stderr,
"%s\n\n", msg);
177 assert(ppos !=
NULL);
178 assert(node !=
NULL);
198 assert(ppos !=
NULL);
216 assert(ppos !=
NULL);
241 assert(ppos !=
NULL);
253 assert(ppos !=
NULL);
257 if ( ppos->
buf[ppos->
pos] ==
'\0' )
259#ifdef SCIP_DISABLED_CODE
264 size_t len = (size_t)
FREAD(ppos->
buf,
sizeof(ppos->
buf) - 1, ppos->
fp);
266 if( len == 0 || len >
sizeof(ppos->
buf) - 1 )
269 ppos->
buf[len] =
'\0';
273 return (
unsigned char)ppos->
buf[ppos->
pos++];
277#ifdef SPEC_LIKE_SPACE_HANDLING
290 assert(ppos !=
NULL);
301 if (((c ==
'\n') && (ppos->
lastsym ==
'\r')) || ((c ==
'\r') && (ppos->
lastsym ==
'\n')))
329 assert(ppos !=
NULL);
345 if ((c ==
'\n') || (c ==
'\r'))
347 }
while((c ==
' ') && (ppos->
lastsym == c));
364 assert(ppos !=
NULL);
378 assert(ppos !=
NULL);
384 while(isspace((
unsigned char)c));
404 assert(ppos !=
NULL);
408 if ( ! isalpha((
unsigned char)c) && (c !=
'_') && (c !=
':') )
410 xmlError(ppos,
"Name starting with illegal charater");
415 while ( isalnum((
unsigned char)c) || (c ==
'_') || (c ==
':') || (c ==
'.') || (c ==
'-') )
417 if ( len + 1 >= size )
430 assert(name !=
NULL);
433 name[len++] = (char)c;
440 assert(name !=
NULL);
470 assert(ppos !=
NULL);
476 if ( (c !=
'"') && (c !=
'\'') )
478 xmlError(ppos,
"Atribute value does not start with \" or \'");
498 assert(attr !=
NULL);
503 if ( (c == stop) || (c == EOF) )
506 attr[len++] = (char)c;
532 assert(ppos !=
NULL);
541 if ( (c ==
'>') && (state >= 2) )
544 state = (c ==
'-') ? state + 1 : 0;
548 xmlError(ppos,
"Unexpected EOF in comment");
570 assert(ppos !=
NULL);
582 if ( (c ==
'>') && (state >= 2) )
600 assert(data !=
NULL);
603 data[len++] = (char)c;
605 assert(data !=
NULL);
611 assert(data !=
NULL);
613 data[len - 2] =
'\0';
619 xmlError(ppos,
"Unexpected EOF in CDATA");
632 assert(ppos !=
NULL);
639 while ( (c != EOF) && (c !=
'>') );
645 xmlError(ppos,
"Unexpected EOF in PI");
669 typedef enum XmlSection XMLSECTION;
677 {
"--", IS_COMMENT },
678 {
"ATTLIST", IS_ATTLIST },
679 {
"DOCTYPE", IS_DOCTYPE },
680 {
"ELEMENT", IS_ELEMENT },
681 {
"ENTITY", IS_ENTITY },
682 {
"NOTATION", IS_NOTATION },
683 {
"[CDATA[", IS_CDATA }
692 assert(ppos !=
NULL);
695 end = (int) (
sizeof(key) /
sizeof(key[0])) - 1;
700 for(; (beg <= end) && (c != key[beg].name[k]); beg++)
702 for(; (end >= beg) && (c != key[end].name[k]); end--)
710 xmlError(ppos,
"Unknown declaration");
712 while ( (c != EOF) && (c !=
'>') )
718 assert(beg < (
int)(
sizeof(key) /
sizeof(*key)));
721 switch(key[beg].what)
734 xmlError(ppos,
"Can't create new node");
766 assert(ppos !=
NULL);
769 xmlError(ppos,
"Missing name in endtag");
776 xmlError(ppos,
"Missing '>' in endtag");
781 if ( strcmp(name,
topPstack(ppos)->name) )
783 xmlError(ppos,
"Name of endtag does not match starttag");
808 assert(ppos !=
NULL);
813 xmlError(ppos,
"Missing name in tagstart");
821 xmlError(ppos,
"Can't create new node");
845 assert(ppos !=
NULL);
894 assert(ppos !=
NULL);
899 if ( (c ==
'/') || (c ==
'>') || (c == EOF) )
909 xmlError(ppos,
"Unexpected EOF while in a tag");
922 xmlError(ppos,
"Expected tag end marker '>'");
933 xmlError(ppos,
"No name for attribute");
942 xmlError(ppos,
"Missing attribute value");
951 xmlError(ppos,
"Can't create new attribute");
977 assert(ppos !=
NULL);
980#ifndef SPEC_LIKE_SPACE_HANDLING
987 while ( (c != EOF) && (c !=
'<') )
989 if ( len + 1 >= size )
1002 assert(data !=
NULL);
1003 assert(size > len + 1);
1005 data[len++] = (char)c;
1034 xmlError(ppos,
"Can't create new node");
1061 switch (ppos->
state)
1079 xmlError(ppos,
"Internal Error, illegal state");
1090 const char* filename
1101 assert( filename !=
NULL );
1102 filenamelen = strlen(filename);
1107#ifdef SCIP_WITH_ZLIB
1108 if ( access(filename, R_OK) != 0 )
1110 strcat(myfilename,
".gz");
1115 if ( access(myfilename, R_OK) != 0 )
1116 (void)
SCIPstrncpy(myfilename, filename, (
int)filenamelen + 5);
1119 ppos.
fp =
FOPEN(myfilename,
"r");
1136 xmlError(&ppos,
"Can't create new node");
1142 xmlError(&ppos,
"Can't create new attribute");
1157 if ( ! result && (node !=
NULL) )
1159 xmlErrmsg(&ppos,
"Parsing error, processing stopped",
TRUE, __FILE__, __LINE__);
1179 assert(name !=
NULL);
1198 assert(name !=
NULL);
1199 assert(value !=
NULL);
1219 a->next = n->attrlist;
1229 assert(parent !=
NULL);
1230 assert(child !=
NULL);
1232 child->parent = parent;
1233 child->prevsibl = parent->lastchild;
1234 child->nextsibl =
NULL;
1235 parent->lastchild = child;
1237 if ( child->prevsibl !=
NULL )
1238 child->prevsibl->nextsibl = child;
1240 if ( parent->firstchild ==
NULL )
1241 parent->firstchild = child;
1261 assert(
a->value !=
NULL);
1283 n = node->lastchild;
1294 if ( node->data !=
NULL )
1298 assert(node->name !=
NULL);
1312 assert(root !=
NULL);
1314 for (n = root; n !=
NULL; n = n->nextsibl)
1320 for (
a = n->attrlist;
a !=
NULL;
a =
a->next)
1323 if ( n->firstchild !=
NULL )
1340 assert(node !=
NULL);
1341 assert(name !=
NULL);
1343 for (
a = node->attrlist;
a !=
NULL;
a =
a->next)
1345 if ( ! strcmp(name,
a->
name) )
1351 infoMessage(
"Error: Attribute %s in TAG <%s> not found\n", name, node->name);
1365 assert(node !=
NULL);
1366 assert(name !=
NULL);
1368 for (n = node; n !=
NULL; n = n->nextsibl)
1370 if ( ! strcmp(name, n->name) )
1383 assert(node !=
NULL);
1384 assert(name !=
NULL);
1398 assert(node !=
NULL);
1399 assert(name !=
NULL);
1401 if ( ! strcmp(name, node->name) )
1404 for (n = node->firstchild; n !=
NULL; n = n->nextsibl)
1425 assert(node !=
NULL);
1426 assert(name !=
NULL);
1428 if ( ! strcmp(name, node->name) )
1431 if ( depth < maxdepth )
1433 for (n = node->firstchild; n !=
NULL; n = n->nextsibl)
1449 assert(node !=
NULL);
1451 return node->nextsibl;
1459 assert(node !=
NULL);
1461 return node->prevsibl;
1469 assert(node !=
NULL);
1471 return node->firstchild;
1479 assert(node !=
NULL);
1481 return node->lastchild;
1489 assert(node !=
NULL);
1499 assert(node !=
NULL);
1501 return node->lineno;
1509 assert(node !=
NULL);
1522 assert(node !=
NULL);
1523 assert(name !=
NULL);
1529 if ( ! strcmp(n->firstchild->name,
"#PCDATA") )
1530 return n->firstchild->data;
int SCIPstrncpy(char *t, const char *s, int size)
memory allocation routines
#define BMSfreeMemory(ptr)
#define BMSreallocMemoryArray(ptr, num)
#define BMSduplicateMemoryArray(ptr, source, num)
#define BMSclearMemory(ptr)
#define BMSallocMemoryArray(ptr, num)
#define BMSfreeMemoryArray(ptr)
#define BMScopyMemoryArray(ptr, source, num)
#define BMSallocMemory(ptr)
internal miscellaneous methods
declarations for XML parsing
struct XML_ATTR_struct XML_ATTR
struct XML_NODE_struct XML_NODE
definitions for XML parsing
#define FGETS(buf, len, fp)
#define FOPEN(file, mode)
#define FREAD(buf, len, fp)
const char * SCIPxmlFindPcdata(const XML_NODE *node, const char *name)
static void ungetsymbol(PPOS *ppos, int c)
static XML_Bool pushPstack(PPOS *ppos, XML_NODE *node)
XML_NODE * SCIPxmlNewNode(const char *name, int lineno)
const char * SCIPxmlGetAttrval(const XML_NODE *node, const char *name)
const XML_NODE * SCIPxmlFirstChild(const XML_NODE *node)
const XML_NODE * SCIPxmlFindNodeMaxdepth(const XML_NODE *node, const char *name, int depth, int maxdepth)
void SCIPxmlAddAttr(XML_NODE *n, XML_ATTR *a)
const XML_NODE * SCIPxmlFindNode(const XML_NODE *node, const char *name)
static XML_Bool xmlParse(PPOS *ppos)
const XML_NODE * SCIPxmlNextNode(const XML_NODE *node, const char *name)
static void handlePi(PPOS *ppos)
void SCIPxmlShowNode(const XML_NODE *root)
const char * SCIPxmlGetData(const XML_NODE *node)
static int mygetc(PPOS *ppos)
const XML_NODE * SCIPxmlFirstNode(const XML_NODE *node, const char *name)
static XML_Bool doComment(PPOS *ppos)
const XML_NODE * SCIPxmlNextSibl(const XML_NODE *node)
static void xmlErrmsg(PPOS *ppos, const char *msg, XML_Bool msg_only, const char *file, int line)
void SCIPxmlFreeNode(XML_NODE *node)
static char * doCdata(PPOS *ppos)
static int getsymbol(PPOS *ppos)
const XML_NODE * SCIPxmlLastChild(const XML_NODE *node)
static XML_Bool popPstack(PPOS *ppos)
static void handleStarttag(PPOS *ppos)
void SCIPxmlAppendChild(XML_NODE *parent, XML_NODE *child)
static void procPcdata(PPOS *ppos)
static void handleDecl(PPOS *ppos)
enum parse_state_enum PSTATE
static int skipSpace(PPOS *ppos)
const char * SCIPxmlGetName(const XML_NODE *node)
static void clearPstack(PPOS *ppos)
static char * getName(PPOS *ppos)
const XML_NODE * SCIPxmlPrevSibl(const XML_NODE *node)
static void xmlFreeAttr(XML_ATTR *attr)
int SCIPxmlGetLine(const XML_NODE *node)
static void handleEndtag(PPOS *ppos)
XML_NODE * SCIPxmlProcess(const char *filename)
static XML_NODE * topPstack(const PPOS *ppos)
XML_ATTR * SCIPxmlNewAttr(const char *name, const char *value)
static void procInTag(PPOS *ppos)
static char * getAttrval(PPOS *ppos)
static void procBefore(PPOS *ppos)