#include <stdio.h>
#include <ctl/serial.h>
Go to the source code of this file.
Data Structures | |
struct | ctl_xmlwrite |
XML File writer. Always expects to dump to FILE pointer Really not much to it, as we just format text to dump to file. More... | |
struct | ctl_xmlread |
XML Parser data. More... | |
Defines | |
#define | XML_TAB_DEPTH 4 |
#define | CTL_LABEL_TYPE szconst(char,"type") |
Functions | |
bool | ctl_xmlwrite_create (ctl_xmlwrite *self, const char *szPath) |
Open an XML stream for writing, setting everything up for its output. | |
void | ctl_xmlwrite_close (ctl_xmlwrite *self) |
Finish an XML stream for writing. | |
void | ctl_xmlwrite_addheader (ctl_xmlwrite *self) |
Slap a header onto (presumably the start) of an XML file. | |
void | ctl_xmlwrite_newline (ctl_xmlwrite *self) |
Write a newline into pretty-printed file. | |
void | ctl_xmlwrite_indent (ctl_xmlwrite *self) |
Write a newline and indent following blocks. | |
void | ctl_xmlwrite_outdent (ctl_xmlwrite *self) |
Write a newline and remove one level of indent from following blocks. | |
void | ctl_xmlwrite_generaltag (ctl_xmlwrite *self, const char *type, const char *label) |
Write our most common tag opening for single members. | |
void | ctl_xmlwrite_containertag (ctl_xmlwrite *self, const char *type, size_t count, const char *label) |
Write our most common tag opening for containers. | |
void | ctl_xmlwrite_endtag (ctl_xmlwrite *self, const char *type, const char *label) |
Close our most common tag for containers or members. | |
void | ctl_xmlwrite_string_char (ctl_xmlwrite *self, const char *begin, const char *end) |
Write a string of characters, translating escaped things. | |
void | ctl_xmlwrite_string_wchar_t (ctl_xmlwrite *self, const wchar_t *begin, const wchar_t *end) |
Write a string of characters, translating escaped things. | |
bool | ctl_xmlread_init (ctl_xmlread *self, const char *begin, const char *end, ctl_xmlread_exception except, void *exceptParam) |
Initialize an XML reader given begin/end string pointers. | |
void | ctl_xmlread_rewind (ctl_xmlread *self) |
Set XML read point to beginning. | |
bool | ctl_xmlread_next (ctl_xmlread *self) |
Set XML read point to next block. | |
bool | ctl_xmlread_find (ctl_xmlread *self, const char *type) |
Search this block for a particular kind of tag. | |
bool | ctl_xmlread_findnext (ctl_xmlread *self, const char *type) |
Search this block for a particular kind of tag, starting after current one. | |
bool | ctl_xmlread_canrecurse (ctl_xmlread *self) |
Tell us if this block contains more blocks. | |
bool | ctl_xmlread_recurse (ctl_xmlread *newself, const ctl_xmlread *self) |
Initialize a new XML parser to parse inside the current block. | |
bool | ctl_xmlread_is (const ctl_xmlread *self, const char *str) |
See if the name of the current tag matches a NUL terminated string. | |
bool | ctl_xmlread_getattribute_int (ctl_xmlread *self, const char *label, int32 *value) |
Get an attribute known to be an integer of some sort. | |
const char * | ctl_xmlread_translate_char (const ctl_xmlread *self, char *begin, const char *end, bool bEatWhite) |
Translate a string of text in-place in its own buffer. | |
const wchar_t * | ctl_xmlread_translate_wchar_t (const ctl_xmlread *self, wchar_t *begin, const wchar_t *end, bool bEatWhite) |
Translate a string of text in-place in its own buffer. | |
void | char_xml_write_string (const char *buff, size_t size, ctl_xmlwrite *xml, const char *label) |
Write a string of unicode characters. | |
void | wchar_t_xml_write_string (const wchar_t *buff, size_t size, ctl_xmlwrite *xml, const char *label) |
Write a string of unicode characters. | |
void | char_xml_write_gstring (ctl_gstring(char)*str, ctl_xmlwrite *xml, const char *label) |
bool | char_xml_read_string (char *buff, size_t size, ctl_xmlread *self, const char *label) |
Read a string into fixed length C string buffer. | |
bool | wchar_t_xml_read_string (wchar_t *buff, size_t size, ctl_xmlread *self, const char *label) |
Read a string into fixed length C string buffer. | |
bool | char_xml_read_gstring (ctl_gstring(char)*str, ctl_xmlread *self, const char *label) |
void | raw_xml_writebytes (const ctl_serial *serial, ctl_xmlwrite *xml, const char *label) |
Write raw serial data as XML record. | |
bool | raw_xml_readbytes (ctl_serial *serial, ctl_xmlread *self, const char *label) |
Read raw serial data from XML record. |
Definition in file xml.h.
#define CTL_LABEL_TYPE szconst(char,"type") |
What I want to call stuff
Definition at line 17 of file xml.h.
Referenced by ctl_xmlwrite_containertag(), and ctl_xmlwrite_generaltag().
#define XML_TAB_DEPTH 4 |
Define how far to indent at a time
Definition at line 14 of file xml.h.
Referenced by ctl_xmlwrite_indent(), and ctl_xmlwrite_outdent().
bool char_xml_read_gstring | ( | ctl_gstring(char)* | str, | |
ctl_xmlread * | self, | |||
const char * | label | |||
) |
Write a growable string of whatever type
void char_xml_write_gstring | ( | ctl_gstring(char)* | str, | |
ctl_xmlwrite * | xml, | |||
const char * | label | |||
) |
Write a growable string of whatever type
bool raw_xml_readbytes | ( | ctl_serial * | serial, | |
ctl_xmlread * | self, | |||
const char * | label | |||
) |
Read raw serial data from XML record.
serial | Points at ctl_serial to receive data | |
self | XML reader to get it from | |
label | What the record was called |
Definition at line 1688 of file xml.c.
References assertconst, assertobjptr, ctl_sconst, ctl_sconst_getxuint8, ctl_serial_alloc, ctl_xmlread_find(), ctl_xmlread_getattribute_int(), ctl_xmlread_rawcontent(), and uint8_serial_write().
01689 { 01690 int32 size; 01691 assertobjptr(serial);/* Inputs should be valid-looking */ 01692 assertobjptr(self); 01693 assertconst( label,1 ); 01694 if( ctl_xmlread_find( self, label ) ) 01695 { 01696 if( ctl_xmlread_getattribute_int( self, CTL_LABEL_COUNT, &size ) ) 01697 { 01698 ctl_sconst(char) body; 01699 ctl_xmlread_rawcontent( self, &body, true ); 01700 ctl_serial_alloc( serial, size ); 01701 { 01702 uint8 v; 01703 while( ctl_sconst_getxuint8(char, &body, &v ) ) 01704 uint8_serial_write( &v, serial ); 01705 } 01706 return true; 01707 } 01708 } 01709 return false; 01710 }
void raw_xml_writebytes | ( | const ctl_serial * | serial, | |
ctl_xmlwrite * | self, | |||
const char * | label | |||
) |
Write raw serial data as XML record.
serial | Points at raw data to write | |
self | XML writer to write it to | |
label | What to call the record |
Definition at line 1658 of file xml.c.
References assertconst, assertobjconst, assertobjptr, ctl_serial::begin, ctl_serial_total, ctl_xmlwrite_containertag(), ctl_xmlwrite_endtag(), ctl_xmlwrite_indent(), ctl_xmlwrite_newline(), and ctl_xmlwrite_outdent().
01659 { 01660 size_t count; 01661 assertobjconst(serial);/* Inputs should be valid-looking */ 01662 assertobjptr(self); 01663 assertconst( label,1 ); 01664 count = ctl_serial_total( serial ); 01665 ctl_xmlwrite_containertag( self, "raw", count, label ); 01666 ctl_xmlwrite_indent( self ); 01667 { 01668 const uint8* p = serial->begin; 01669 while( p < serial->end ) 01670 { 01671 if( 0 == ((p-serial->begin)&0xf) ) 01672 ctl_xmlwrite_newline( self ); 01673 xml_printf( self, " %02x", (unsigned)*p ); 01674 p++; 01675 } 01676 } 01677 ctl_xmlwrite_outdent( self ); 01678 ctl_xmlwrite_endtag( self, "raw", label ); 01679 01680 }