Instrument Neutral Distributed Interface INDI
2.0.2
|
#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include "lilxml.h"
Go to the source code of this file.
Classes | |
struct | String |
struct | LilXML_ |
struct | xml_ele_ |
struct | xml_att_ |
class | XMLOutput |
class | FileXMLOutput |
class | BufferXMLOutput |
class | NullXMLOutput |
Macros | |
#define | MINMEM 64 /* starting string length */ |
#define | PRINDENT 4 /* sample print indent each level */ |
#define | PRINDENTSTR " " /* sample print indent each level */ |
Enumerations | |
enum | State { LOOK4START = 0 , LOOK4TAG , INTAG , LOOK4ATTRN , INATTRN , LOOK4ATTRV , SAWSLASH , INATTRV , ENTINATTRV , LOOK4CON , INCON , ENTINCON , SAWLTINCON , LOOK4CLOSETAG , INCLOSETAG } |
Functions | |
void | lilxmlMalloc (void *(*newmalloc)(size_t size), void *(*newrealloc)(void *ptr, size_t size), void(*newfree)(void *ptr)) |
LilXML * | newLilXML () |
Create a new lilxml parser. More... | |
void | delLilXML (LilXML *lp) |
Delete a lilxml parser. More... | |
void | delXMLEle (XMLEle *ep) |
delXMLEle Delete XML element. More... | |
XMLEle ** | parseXMLChunk (LilXML *lp, char *buf, int size, char ynot[]) |
Process an XML chunk. More... | |
XMLEle * | readXMLEle (LilXML *lp, int newc, char ynot[]) |
Process an XML one char at a time. More... | |
XMLEle * | parseXML (char buf[], char ynot[]) |
XMLEle * | cloneXMLEle (XMLEle *ep) |
XMLEle * | cloneXMLEle (XMLEle *ep, int(*replace)(void *self, XMLEle *source, XMLEle **replace), void *self) |
clone (deep) a xmlEle. Optional replacement function can be passed, to replace a whole subtree instead of copying More... | |
XMLAtt * | findXMLAtt (XMLEle *ep, const char *name) |
Find an XML attribute within an XML element. More... | |
XMLEle * | findXMLEle (XMLEle *ep, const char *tag) |
Find an XML element within an XML element. More... | |
XMLEle * | nextXMLEle (XMLEle *ep, int init) |
Iterate an XML element for a list of nesetd XML elements. More... | |
XMLAtt * | nextXMLAtt (XMLEle *ep, int init) |
Iterate an XML element for a list of XML attributes. More... | |
XMLEle * | parentXMLEle (XMLEle *ep) |
Return the parent of an XML element. More... | |
XMLEle * | parentXMLAtt (XMLAtt *ap) |
Return the parent of an XML attribute. More... | |
char * | tagXMLEle (XMLEle *ep) |
Return the tag of an XML element. More... | |
char * | pcdataXMLEle (XMLEle *ep) |
Return the pcdata of an XML element. More... | |
int | pcdatalenXMLEle (XMLEle *ep) |
Return the number of characters in pcdata in an XML element. More... | |
char * | nameXMLAtt (XMLAtt *ap) |
Return the name of an XML attribute. More... | |
char * | valuXMLAtt (XMLAtt *ap) |
Return the value of an XML attribute. More... | |
int | nXMLEle (XMLEle *ep) |
Return the number of nested XML elements in a parent XML element. More... | |
int | nXMLAtt (XMLEle *ep) |
Return the number of XML attributes in a parent XML element. More... | |
const char * | findXMLAttValu (XMLEle *ep, const char *name) |
Find an XML element's attribute value. More... | |
XMLEle * | readXMLFile (FILE *fp, LilXML *lp, char ynot[]) |
Handy wrapper to read one xml file. More... | |
XMLEle * | addXMLEle (XMLEle *parent, const char *tag) |
add an element with the given tag to the given element. parent can be NULL to make a new root. More... | |
XMLEle * | setXMLEleTag (XMLEle *ep, const char *tag) |
Update the tag of an element. More... | |
void | editXMLEle (XMLEle *ep, const char *pcdata) |
set the pcdata of the given element More... | |
XMLAtt * | addXMLAtt (XMLEle *ep, const char *name, const char *valu) |
Add an XML attribute to an existing XML element. More... | |
void | rmXMLAtt (XMLEle *ep, const char *name) |
Remove an XML attribute from an XML element. More... | |
XMLEle * | shallowCloneXMLEle (XMLEle *ele) |
return a surface copy of a node. Don't copy childs or cdata. More... | |
void | editXMLAtt (XMLAtt *ap, const char *str) |
change the value of an attribute to str. More... | |
void | prXMLEle (FILE *fp, XMLEle *ep, int level) |
Print an XML element. More... | |
size_t | sprXMLEle (char *s, XMLEle *ep, int level) |
sample print ep to string s. N.B. s must be at least as large as that reported by sprlXMLEle()+1. N.B. set level = 0 on first call. More... | |
size_t | sprlXMLEle (XMLEle *ep, int level) |
return number of bytes in a string guaranteed able to hold result of sprXLMEle(ep) (sans trailing \0@). N.B. set level = 0 on first call. More... | |
size_t | sprXMLCDataOffset (XMLEle *root, XMLEle *ep, int level) |
return exact position of cdata of child in printed representation of root N.B. set level = 0 on first call. More... | |
char * | entityXML (char *s) |
return a string with all xml-sensitive characters within the passed string replaced with their entity sequence equivalents. N.B. caller must use the returned string before calling us again. Warning: This will sometime fail in impredictible way when used from multiple thread contexts More... | |
#define MINMEM 64 /* starting string length */ |
Definition at line 55 of file lilxml.cpp.
#define PRINDENT 4 /* sample print indent each level */ |
Definition at line 751 of file lilxml.cpp.
#define PRINDENTSTR " " /* sample print indent each level */ |
Definition at line 752 of file lilxml.cpp.
enum State |
Enumerator | |
---|---|
LOOK4START | |
LOOK4TAG | |
INTAG | |
LOOK4ATTRN | |
INATTRN | |
LOOK4ATTRV | |
SAWSLASH | |
INATTRV | |
ENTINATTRV | |
LOOK4CON | |
INCON | |
ENTINCON | |
SAWLTINCON | |
LOOK4CLOSETAG | |
INCLOSETAG |
Definition at line 73 of file lilxml.cpp.
Add an XML attribute to an existing XML element.
ep | pointer to an XML element |
name | the name of the XML attribute to add. |
value | the value of the XML attribute to add. |
Definition at line 706 of file lilxml.cpp.
add an element with the given tag to the given element. parent can be NULL to make a new root.
Definition at line 670 of file lilxml.cpp.
Definition at line 479 of file lilxml.cpp.
XMLEle* cloneXMLEle | ( | XMLEle * | ep, |
int(*)(void *self, XMLEle *source, XMLEle **replace) | replace, | ||
void * | self | ||
) |
clone (deep) a xmlEle. Optional replacement function can be passed, to replace a whole subtree instead of copying
ele | the original tree |
replace | function which can provide replacement. Return 1 & set replace for replacement. Optional |
self | additional value passed to replace function |
Definition at line 493 of file lilxml.cpp.
void delLilXML | ( | LilXML * | lp | ) |
Delete a lilxml parser.
lp | a pointer to a lilxml parser to be deleted. |
Definition at line 159 of file lilxml.cpp.
void delXMLEle | ( | XMLEle * | e | ) |
delXMLEle Delete XML element.
e | Pointer to XML element to delete. If nullptr, no action is taken. |
Definition at line 167 of file lilxml.cpp.
void editXMLAtt | ( | XMLAtt * | ap, |
const char * | str | ||
) |
change the value of an attribute to str.
ap | pointer to XML attribute |
str | new attribute value |
Definition at line 745 of file lilxml.cpp.
void editXMLEle | ( | XMLEle * | ep, |
const char * | pcdata | ||
) |
set the pcdata of the given element
ep | pointer to an XML element. |
pcdata | pcdata to set. |
Definition at line 698 of file lilxml.cpp.
char* entityXML | ( | char * | s | ) |
return a string with all xml-sensitive characters within the passed string replaced with their entity sequence equivalents. N.B. caller must use the returned string before calling us again. Warning: This will sometime fail in impredictible way when used from multiple thread contexts
Definition at line 975 of file lilxml.cpp.
Find an XML attribute within an XML element.
e | a pointer to the XML element to search. |
name | the attribute name to search for. |
Definition at line 524 of file lilxml.cpp.
const char* findXMLAttValu | ( | XMLEle * | ep, |
const char * | name | ||
) |
Find an XML element's attribute value.
ep | a pointer to an XML element. |
name | the name of the XML attribute to retrieve its value. |
Definition at line 644 of file lilxml.cpp.
Find an XML element within an XML element.
e | a pointer to the XML element to search. |
tag | the element tag to search for. |
Definition at line 537 of file lilxml.cpp.
void lilxmlMalloc | ( | void *(*)(size_t size) | newmalloc, |
void *(*)(void *ptr, size_t size) | newrealloc, | ||
void(*)(void *ptr) | newfree | ||
) |
Definition at line 141 of file lilxml.cpp.
char* nameXMLAtt | ( | XMLAtt * | ap | ) |
Return the name of an XML attribute.
ap | a pointer to an XML attribute. |
Definition at line 618 of file lilxml.cpp.
LilXML* newLilXML | ( | ) |
Create a new lilxml parser.
Definition at line 150 of file lilxml.cpp.
Iterate an XML element for a list of XML attributes.
ep | a pointer to the XML element to iterate. |
first | the index of the starting XML attribute. Pass 1 to start iteration from the beginning of the XML element. Pass 0 to get the next attribute thereater. |
Definition at line 572 of file lilxml.cpp.
Iterate an XML element for a list of nesetd XML elements.
ep | a pointer to the XML element to iterate. |
first | the index of the starting XML element. Pass 1 to start iteration from the beginning of the XML element. Pass 0 to get the next element thereater. |
Definition at line 555 of file lilxml.cpp.
int nXMLAtt | ( | XMLEle * | ep | ) |
Return the number of XML attributes in a parent XML element.
ep | a pointer to an XML element. |
Definition at line 636 of file lilxml.cpp.
int nXMLEle | ( | XMLEle * | ep | ) |
Return the number of nested XML elements in a parent XML element.
ep | a pointer to an XML element. |
Definition at line 630 of file lilxml.cpp.
Return the parent of an XML attribute.
Definition at line 592 of file lilxml.cpp.
Return the parent of an XML element.
Definition at line 586 of file lilxml.cpp.
XMLEle* parseXML | ( | char | buf[], |
char | ynot[] | ||
) |
Definition at line 461 of file lilxml.cpp.
Process an XML chunk.
lp | a pointer to a lilxml parser. |
buf | buffer to process. |
size | size of buf |
errmsg | a buffer to store error messages if an error in parsing is encountered. |
Definition at line 215 of file lilxml.cpp.
int pcdatalenXMLEle | ( | XMLEle * | ep | ) |
Return the number of characters in pcdata in an XML element.
ep | a pointer to an XML element. |
Definition at line 612 of file lilxml.cpp.
char* pcdataXMLEle | ( | XMLEle * | ep | ) |
Return the pcdata of an XML element.
ep | a pointer to an XML element. |
Definition at line 606 of file lilxml.cpp.
void prXMLEle | ( | FILE * | fp, |
XMLEle * | e, | ||
int | level | ||
) |
Print an XML element.
fp | a pointer to FILE where the print output is directed. |
e | the XML element to print. |
level | the printing level, set to 0 to print the whole element. |
Definition at line 844 of file lilxml.cpp.
Process an XML one char at a time.
lp | a pointer to a lilxml parser. |
c | one character to process. |
errmsg | a buffer to store error messages if an error in parsing is encounterd. |
Definition at line 385 of file lilxml.cpp.
Handy wrapper to read one xml file.
fp | pointer to FILE to read. |
lp | pointer to lilxml parser. |
errmsg | a buffer to store error messages on failure. |
Definition at line 653 of file lilxml.cpp.
void rmXMLAtt | ( | XMLEle * | ep, |
const char * | name | ||
) |
Remove an XML attribute from an XML element.
ep | pointer to an XML element. |
name | the name of the XML attribute to remove |
Definition at line 715 of file lilxml.cpp.
Update the tag of an element.
ep | pointer to an XML element |
tag | the new tag value to set |
Definition at line 688 of file lilxml.cpp.
return a surface copy of a node. Don't copy childs or cdata.
Definition at line 731 of file lilxml.cpp.
size_t sprlXMLEle | ( | XMLEle * | ep, |
int | level | ||
) |
return number of bytes in a string guaranteed able to hold result of sprXLMEle(ep) (sans trailing \0@). N.B. set level = 0 on first call.
Definition at line 922 of file lilxml.cpp.
return exact position of cdata of child in printed representation of root N.B. set level = 0 on first call.
Definition at line 930 of file lilxml.cpp.
size_t sprXMLEle | ( | char * | s, |
XMLEle * | ep, | ||
int | level | ||
) |
sample print ep to string s. N.B. s must be at least as large as that reported by sprlXMLEle()+1. N.B. set level = 0 on first call.
Definition at line 874 of file lilxml.cpp.
char* tagXMLEle | ( | XMLEle * | ep | ) |
Return the tag of an XML element.
ep | a pointer to an XML element. |
Definition at line 600 of file lilxml.cpp.
char* valuXMLAtt | ( | XMLAtt * | ap | ) |
Return the value of an XML attribute.
ap | a pointer to an XML attribute. |
Definition at line 624 of file lilxml.cpp.