CTL Data Patterns


Files

file  algorithm.h
 Algorithm generation templates.
file  algorithm.temp.h
 Algorithm generation templates.
file  datagen.c
 Data generator support functions.
file  blank.h
 Blank Datagen Pattern.
file  patterns.temp.h
 Bind together all the littler files into one.
file  xml.c
 XML IO implementation.
file  xml.h
 Handle simple data XML I/O as used by this system.

Data Structures

struct  ctl_serial
 Serial parser This provides a simplified interface to raw serial data. It only keeps track of a start/end of data owned by something else to pass around to other functions. More...
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 ctl_array_qsort_declare(type)   void ppConcat(type,_array_qsort)( type* low, type* high, int (*compare)(const type* p1, const type* p2) )
 Declare a quicker sort for a particular data type.
#define ctl_array_bsort_declare(type)   void ppConcat(type,_array_bsort)( type* low, type* high, int (*compare)(const type* p1, const type* p2) )
 Declare a bubble sort for a particular data type.
#define ctl_array_qsort_implement(type)
 Manufacture a quicker sort for a particular data type.
#define ctl_array_bsort_implement(type)
 Manufacture a quicker sort for a particular data type.
#define ctl_cooked(text)   text
 Vector initializes and de-initializes members Pass without the parenthetical portion, like: ctl_implement_array(mycompounds,foobar,ctl_cooked).
#define ctl_raw(text)
 Vector members are not initialized/de-initialized Pass without the parenthetical portion, like: ctl_implement_array(myints,int32,ctl_raw).
#define ctl_datagen_declare_functions(label)
 Declare functions for a record that is fully integrated into ctl_datagen pattern. Like a 'To Do' list for what to implement.
#define enum_count(enum)   ppConcat(enum,_COUNT)
 Get count of an enumeration's members.
#define enum_isvalid(enum, value)   ( ((unsigned)(value)) < ((unsigned)ppConcat(enum,_COUNT)) )
 Do bounds check on enumeration type value.
#define enum_itemname(enum, value)   ( enum_isvalid(enum,value) ? ppConcat(szz,enum)[(value)] : #enum "INVALID" )
 Get an enumeration's item name from an EDEF.
#define enum_itemnames(enum)   ppConcat(szz,enum)
 Get count of an enumeration's members.
#define enum_rand(enum)   ((enum)(rand() % enum_count( enum )))
 Generate a random enumeration value.
#define enum_foreach(enum, iterator)   enum iterator; for ( iterator = (enum)0; iterator < enum_count( enum ); iterator = (enum)(1 + iterator) )
 Iterate enumerated items forwards.
#define enum_foreach_reverse(enum, iterator)   enum iterator = enum_count( enum ); while( iterator-- )
 Iterate enumerated items backwards.
#define protocol_begin(label)
 Begin a protocol enumeration.
#define protocol_begin(label)   typedef enum label {
 Begin a protocol enumeration.
#define enum_begin(label)   typedef enum {
 Begin an enumeration declaration.
#define enum_begin(label)
 Begin an enumeration declaration.
#define enum_item(label)   label,
 Add an enumerated item.
#define enum_item(label)
 Add an enumerated item.
#define enum_end(label)
 End an enumeration declaration.
#define enum_end(label)
 End an enumeration declaration.
#define record_begin(label)   typedef struct label {
 Begin a record declaration.
#define record_begin(label)   ppConcat(e,label),
 Begin a record declaration.
#define record_var(label, type, val)   type label;
 Declare a scalar member.
#define record_var(label, type, val)
 Declare a scalar member.
#define record_varok(label, type, val, min, max)   type label;
 Declare a validated scalar member.
#define record_varok(label, type, val, min, max)
 Declare a validated scalar member.
#define record_array(label, type, alen, val)   type label[alen];
 Declare an array of scalars.
#define record_array(label, type, alen, val)
 Declare an array of scalars.
#define record_arrayok(label, type, alen, val, min, max)   type label[alen];
 Declare an array of scalars.
#define record_arrayok(label, type, alen, val, min, max)
 Declare an array of scalars.
#define record_objarray(label, type, alen)   type label[alen];
 Declare an array of record types, as generated with this system.
#define record_objarray(label, type, alen)
 Declare an array of record types, as generated with this system.
#define record_achar(label, type, alen, val)   type label[alen];
 Declare a string array member.
#define record_achar(label, type, alen, val)
 Declare a string array member.
#define record_string(label, type)   ctl_gstring(type) label;
 Declare a string array member.
#define record_string(label, type)
 Declare a string array member.
#define record_obj(label, type)   type label;
 Declare a record type member, as generated with this system.
#define record_obj(label, type)
 Declare a record type member, as generated with this system.
#define record_ref(label, type)   type* label;
 Declare a reference to a dynamically allocated record, initially NULL.
#define record_ref(label, type)
 Declare a reference to a dynamically allocated record, initially NULL.
#define record_preref(label, type)   type* label;
 Declare a reference to a dynamically allocated record, initially allocated.
#define record_preref(label, type)
 Declare a reference to a dynamically allocated record, initially allocated.
#define record_enum(label, type, val)   type label;
 Declare an enumeration.
#define record_enum(label, type, val)
 Declare an enumeration.
#define record_serial(label)   ctl_serial label;
 Define serial data.
#define record_serial(label)
 Define serial data.
#define record_serialref(label)   ctl_serial label;
 Define a REFERENCE to serial data Only suitable in messaging protocols where packet is turned around before the data it points at goes away.
#define record_serialref(label)
 Define a REFERENCE to serial data Only suitable in messaging protocols where packet is turned around before the data it points at goes away.
#define record_member(stuff)   stuff
 Define some data to be expanded in the record declaration.
#define record_member(stuff)
 Define some data to be expanded in the record declaration.
#define record_atinit(stuff)
 Code to execute when initialization happens.
#define record_atinit(stuff)
 Code to execute when initialization happens.
#define record_atdestroy(stuff)
 Code to execute when destruction happens.
#define record_atdestroy(stuff)
 Code to execute when destruction happens.
#define record_atcopy(stuff)
 Code to execute when copy operations happen.
#define record_atcopy(stuff)
 Code to execute when copy operations happen.
#define record_atmove(stuff)
 Code to execute when move operations happen.
#define record_atmove(stuff)
 Code to execute when move operations happen.
#define record_atswap(stuff)
 Code to execute when swap operations happen.
#define record_atswap(stuff)
 Code to execute when swap operations happen.
#define record_end(label)
 End a record definition.
#define record_end(label)
 End a record definition.
#define record_alias(label, type)
 Assign another protocol value to the same record type.
#define record_alias(label, type)   ppConcat(e,label),
 Assign another protocol value to the same record type.
#define union_alias(type, enum)
 Declare an enumerated union member that uses the same kind of data as a later definition. Since the enumeration is notionally for a switch, this is for a 'fall-through' Keeps unions with common/re-used member types from becomming bloated switch( enum ) { case sometype: // union_member(something,somethingtype,sometype) dosomething(&self.something); break; case aliastype: // union_alias(somethingelsetype,aliastype) case anothertype: // union_member(anothersomething,somethingelsetype,anothertype) doanothersomething(&self.anothersomething); break; ... }.
#define union_alias(type, enum)
 Declare an enumerated union member that uses the same kind of data as a later definition. Since the enumeration is notionally for a switch, this is for a 'fall-through' Keeps unions with common/re-used member types from becomming bloated switch( enum ) { case sometype: // union_member(something,somethingtype,sometype) dosomething(&self.something); break; case aliastype: // union_alias(somethingelsetype,aliastype) case anothertype: // union_member(anothersomething,somethingelsetype,anothertype) doanothersomething(&self.anothersomething); break; ... }.
#define union_member(label, type, enum)   type label;
 Declare an enumerated union member.
#define union_member(label, type, enum)
 Declare an enumerated union member.
#define union_end(label, etype)
 Complete an enumerated union.
#define union_end(label, etype)
 Complete an enumerated union.
#define container_list(label, type)   ctl_declare_list(label,type);
 Declare a doubly-linked list Like stl std::list, allocates objects by list membership, and frees them when removed from list.
#define container_list(label, type)
 Declare a doubly-linked list Like stl std::list, allocates objects by list membership, and frees them when removed from list.
#define container_map(label, keytype, type)   ctl_declare_map(label,keytype,type);
 Declare a map (a container of sorted, unique kes with objects) Like stl std::map, allocates objects by list membership, and frees them when removed from list. By defaultt, sorts by keytype_compare, use the label_sort function to change that.
#define container_map(label, keytype, type)
 Declare a map (a container of sorted, unique kes with objects) Like stl std::map, allocates objects by list membership, and frees them when removed from list. By defaultt, sorts by keytype_compare, use the label_sort function to change that.
#define container_multimap(label, keytype, type)   ctl_declare_multimap(label,keytype,type);
 Declare a multimap (a container of sorted, NON-unique keys with objects) Like stl std::multimap, allocates objects by list membership, and frees them when removed from list. By defaultt, sorts by keytype_compare, use the label_sort function to change that.
#define container_multimap(label, keytype, type)
 Declare a multimap (a container of sorted, NON-unique keys with objects) Like stl std::multimap, allocates objects by list membership, and frees them when removed from list. By defaultt, sorts by keytype_compare, use the label_sort function to change that.
#define container_set(label, type)   ctl_declare_set(label,type);
 Declare a set (a container of sorted, unique objects) Like stl std::set, allocates objects by list membership, and frees them when removed from list. By defaultt, sorts by type_compare, use the label_sort function to change that.
#define container_set(label, type)
 Declare a set (a container of sorted, unique objects) Like stl std::set, allocates objects by list membership, and frees them when removed from list. By defaultt, sorts by type_compare, use the label_sort function to change that.
#define container_multiset(label, type)   ctl_declare_multiset(label,type);
 Declare a multimap (a container of sorted, NON-unique objects) Like stl std::multiset, allocates objects by list membership, and frees them when removed from list. By defaultt, sorts by type_compare, use the label_sort function to change that.
#define container_multiset(label, type)
 Declare a multimap (a container of sorted, NON-unique objects) Like stl std::multiset, allocates objects by list membership, and frees them when removed from list. By defaultt, sorts by type_compare, use the label_sort function to change that.
#define protocol_end(label)
 Complete a protocol enumeration.
#define protocol_end(label)
 Complete a protocol enumeration.
#define ctl_cooked(text)   text
 Vector initializes and de-initializes members Pass without the parenthetical portion, like: ctl_implement_vector(mycompounds,foobar,ctl_cooked).
#define ctl_raw(text)
 Vector members are not initialized/de-initialized Pass without the parenthetical portion, like: ctl_implement_vector(myints,int32,ctl_raw).
#define ctl_serial_auto(label, begin, end)   ctl_serial label = { begin, curr, end, NULL }
 Manufacture a serial parser on the stack.
#define ctl_serial_init(serial, _begin, _end)   { (serial)->begin = (serial)->curr = (uint8*)(_begin); (serial)->end = (uint8*)(_end); (serial)->buff = NULL; }
 Initialize an existin serial parser.
#define ctl_serial_alloc(serial, size)
 Allocate 'size' bytes of serial data.
#define ctl_serial_free(serial)   ctl_free( (serial)->buff )
 Free allocated serial data (if any).
#define ctl_serial_total(serial)   ( (serial)->end - (serial)->begin )
 Tell us how much a serial parser has in it.
#define ctl_serial_remain(serial)   ( (serial)->end - (serial)->curr )
 Tell us how much a serial parser has left in it.
#define ctl_serial_consumed(serial)   ( (serial)->curr - (serial)->begin )
 Tell us how much a serial parser has used.
#define ctl_serial_rewind(serial)   ( (serial)->curr = (uint8*)(serial)->begin )
 Rewind parsed serial back to beginning.
#define ctl_serial_auto_vector(label, vec)   ctl_serial label = { (vec)->array, (vec)->array, (vec)->array+(vec)->count }
 Manufacture a serial parser on the stack from a uint8 vector.
#define ctl_serial_init_vector(serial, vec, _except)   { (serial)->begin = (serial)->curr = (vec)->array; (vec)->array+(vec)->count; (serial)->except = (_except); }
 Initialize a serial parser from a uint8 vector.
#define ctl_serial_size_size(size)   uint16_serial_size(size)
 Determine how big a size will be in the stream.
#define ctl_serial_size_size_size(size)   (ctl_serial_size_size(size) + (size))
 Return how big a size will be in a serial stream, including the passed size.
#define DECL_DEF(type, unused)
 Template: Write a scalar of whatever type.
#define DECL_DEF(type, unused)
 Template: Write a scalar of whatever type.
#define DECL_DEF(type, unused)
 Template: Write a scalar of whatever type.
#define DECL_DEF(type, unused)
 Template: Write a scalar of whatever type.

Functions

void spew (void)
int bool_compare (const bool *p1, const bool *p2)
 Compare two scalar types for qsort, least-to-greatest.
int bool_rcompare (const bool *p1, const bool *p2)
 Compare two scalar types for qsort, greatest-to-least.
int int8_compare (const int8 *p1, const int8 *p2)
 Compare two scalar types for qsort, least-to-greatest.
int int8_rcompare (const int8 *p1, const int8 *p2)
 Compare two scalar types for qsort, greatest-to-least.
int uint8_compare (const uint8 *p1, const uint8 *p2)
 Compare two scalar types for qsort, least-to-greatest.
int uint8_rcompare (const uint8 *p1, const uint8 *p2)
 Compare two scalar types for qsort, greatest-to-least.
int int16_compare (const int16 *p1, const int16 *p2)
 Compare two scalar types for qsort, least-to-greatest.
int int16_rcompare (const int16 *p1, const int16 *p2)
 Compare two scalar types for qsort, greatest-to-least.
int uint16_compare (const uint16 *p1, const uint16 *p2)
 Compare two scalar types for qsort, least-to-greatest.
int uint16_rcompare (const uint16 *p1, const uint16 *p2)
 Compare two scalar types for qsort, greatest-to-least.
int int32_compare (const int32 *p1, const int32 *p2)
 Compare two scalar types for qsort, least-to-greatest.
int int32_rcompare (const int32 *p1, const int32 *p2)
 Compare two scalar types for qsort, greatest-to-least.
int uint32_compare (const uint32 *p1, const uint32 *p2)
 Compare two scalar types for qsort, least-to-greatest.
int uint32_rcompare (const uint32 *p1, const uint32 *p2)
 Compare two scalar types for qsort, greatest-to-least.
int int64_compare (const int64 *p1, const int64 *p2)
 Compare two scalar types for qsort, least-to-greatest.
int int64_rcompare (const int64 *p1, const int64 *p2)
 Compare two scalar types for qsort, greatest-to-least.
int uint64_compare (const uint64 *p1, const uint64 *p2)
 Compare two scalar types for qsort, least-to-greatest.
int uint64_rcompare (const uint64 *p1, const uint64 *p2)
 Compare two scalar types for qsort, greatest-to-least.
int float32_compare (const float32 *p1, const float32 *p2)
 Compare two scalar types for qsort, least-to-greatest Note: values nearly the same are treated as 'same'.
int float32_rcompare (const float32 *p1, const float32 *p2)
 Compare two scalar types for qsort, greatest-to-least Note: values nearly the same are treated as 'same'.
int float64_compare (const float64 *p1, const float64 *p2)
 Compare two scalar types for qsort, least-to-greatest Note: values nearly the same are treated as 'same'.
int float64_rcompare (const float64 *p1, const float64 *p2)
 Compare two scalar types for qsort, greatest-to-least Note: values nearly the same are treated as 'same'.
void char_string_swap (char *s1, char *s2, size_t count)
 Exchange the contents of two character arrays.
void wchar_t_string_swap (wchar_t *s1, wchar_t *s2, size_t count)
 Exchange the contents of two character arrays.
size_t ctl_record_head_size (const char *label, const char *type)
 Determine size of a record header.
size_t ctl_record_objarray_head_size (const char *label, const char *type, const char *mbrtype)
 Determine size of a record container header.
bool ctl_record_valid (const ctl_serial *serial)
 Look at a record and see if it's valid-looking.
bool ctl_record_next (ctl_serial *serial)
 Skip to next record header.
bool ctl_record_find (ctl_serial *serial, const char *label)
 Look for a record header, that might be current.
bool ctl_record_find_next (ctl_serial *serial, const char *label)
 Look for a record header, skipping current.
size_t ctl_record_getdata (ctl_serial *serial)
 Skip over a record header to get at the data.
size_t ctl_record_container_validatedata (ctl_serial *serial, const char *type, const char *mbrtype)
 Validate header against any given types, then get the data into serial and return the COUNT.
const uint8 * ctl_record_end (const ctl_serial *serial)
 Tell us where the next record starts.
bool ctl_record_is (const char *label, const ctl_serial *serial)
 See if current record header is a particular type.
const char * ctl_record_label (const ctl_serial *serial)
 Get a serial record's label.
const char * ctl_record_type (const ctl_serial *serial)
 Get a serial record's type.
bool ctl_record_type_is (const char *label, const ctl_serial *serial)
 See if a serial record's type matches the given label.
const char * ctl_record_contained_type (const ctl_serial *serial)
 Get a serial record's contained type.
bool ctl_record_contained_type_is (const char *label, const ctl_serial *serial)
 See if a serial record's contained type matches an expected type.
size_t ctl_record_count (const ctl_serial *serial)
 Get count of items in a container.
uint8 * ctl_record_write_begin (const char *type, size_t size, ctl_serial *serial, const char *label)
 Write record header to be finished later.
uint8 * ctl_record_write_container_begin (const char *containertype, const char *contenttype, size_t size, size_t count, ctl_serial *serial, const char *label)
 Write record header to be finished later.
void ctl_record_write_end (uint8 *begret, ctl_serial *serial)
 Complete record begun with ctl_record_write_begin or ctl_record_write_container_begin.
size_t ctl_serial_record_size (const ctl_serial *serial, const char *label)
 Calculate how many bytes it will take to store a raw serial reference.
void ctl_serial_record_write (const ctl_serial *from, ctl_serial *to, const char *label)
 Write raw serial data to stream.
bool ctl_serial_record_read (ctl_serial *to, ctl_serial *from, const char *label)
 Read raw serial data from stream.
size_t char_record_size_string (const char *str, size_t maxsize, const char *label)
 Measure string size for record output.
size_t wchar_t_record_size_string (const wchar_t *str, size_t maxsize, const char *label)
 Measure string size for record output.
size_t char_record_size_gstring (const ctl_mstring_char_grow *str, const char *label)
 Measure string size for record output.
size_t wchar_t_record_size_gstring (const ctl_mstring_wchar_t_grow *str, const char *label)
 Measure string size for record output.
void char_record_write_string (const char *sz, size_t size, ctl_serial *serial, const char *label)
 Write a string.
void wchar_t_record_write_string (const wchar_t *sz, size_t size, ctl_serial *serial, const char *label)
 Write a wide character string.
bool char_record_read_string (char *sz, size_t size, const ctl_serial *serial, const char *label)
 Read a string.
bool wchar_t_record_read_string (wchar_t *sz, size_t size, const ctl_serial *serial, const char *label)
 Read a string.
bool char_record_read_gstring (ctl_mstring_char_grow *str, const ctl_serial *serial, const char *label)
 Read a string.
bool wchar_t_record_read_gstring (ctl_mstring_wchar_t_grow *str, const ctl_serial *serial, const char *label)
 Read a wide character string.
bool bool_record_read (bool *pdata, const ctl_serial *serial, const char *label)
bool int8_record_read (int8 *pdata, const ctl_serial *serial, const char *label)
bool uint8_record_read (uint8 *pdata, const ctl_serial *serial, const char *label)
bool int16_record_read (int16 *pdata, const ctl_serial *serial, const char *label)
bool uint16_record_read (uint16 *pdata, const ctl_serial *serial, const char *label)
bool int32_record_read (int32 *pdata, const ctl_serial *serial, const char *label)
bool uint32_record_read (uint32 *pdata, const ctl_serial *serial, const char *label)
bool int64_record_read (int64 *pdata, const ctl_serial *serial, const char *label)
bool uint64_record_read (uint64 *pdata, const ctl_serial *serial, const char *label)
bool float32_record_read (float32 *pdata, const ctl_serial *serial, const char *label)
bool float64_record_read (float64 *pdata, const ctl_serial *serial, const char *label)
bool bool_record_readarray (bool *pdata, size_t count, const ctl_serial *serial, const char *label)
bool int8_record_readarray (int8 *pdata, size_t count, const ctl_serial *serial, const char *label)
bool uint8_record_readarray (uint8 *pdata, size_t count, const ctl_serial *serial, const char *label)
bool int16_record_readarray (int16 *pdata, size_t count, const ctl_serial *serial, const char *label)
bool uint16_record_readarray (uint16 *pdata, size_t count, const ctl_serial *serial, const char *label)
bool int32_record_readarray (int32 *pdata, size_t count, const ctl_serial *serial, const char *label)
bool uint32_record_readarray (uint32 *pdata, size_t count, const ctl_serial *serial, const char *label)
bool int64_record_readarray (int64 *pdata, size_t count, const ctl_serial *serial, const char *label)
bool uint64_record_readarray (uint64 *pdata, size_t count, const ctl_serial *serial, const char *label)
bool float32_record_readarray (float32 *pdata, size_t count, const ctl_serial *serial, const char *label)
bool float64_record_readarray (float64 *pdata, size_t count, const ctl_serial *serial, const char *label)
ctl_serial_exception ctl_serial_setexception (ctl_serial_exception except)
 Set an exception handler for serial exceptions.
void serial_log (const ctl_serial *serial, unsigned mask, const char *fmt,...)
 Log a serial message through debug_log system Parse position is pointed at with '>' in the output text.
void ctl_serial_copy (ctl_serial *dst, const ctl_serial *src)
 Duplicate serial data. If src is a reference, dst will be a reference. If src is allocated, dst will be allocated.
void ctl_serial_deref (ctl_serial *serial)
 Turn a reference to serial data into buffered serial.
void ctl_serial_writesize (size_t size, ctl_serial *serial)
 Write a size into stream.
size_t ctl_serial_peeksize (const ctl_serial *serial)
 Read a size from stream without modifying parse point.
size_t ctl_serial_readsize (ctl_serial *serial)
 Read a size from stream, validate it against remainder.
size_t ctl_serial_calc_size (const ctl_serial *serial)
 Work out how many bytes serial will consume if written as serial.
void ctl_serial_write_serial (ctl_serial *dst, const ctl_serial *src)
 Write serial to serial.
bool ctl_serial_read_serial (ctl_serial *dst, ctl_serial *src)
 Read serial to initialize serial.
bool ctl_serial_peek_serial (ctl_serial *dst, const ctl_serial *src)
 Just like ctl_serial_refserial, except src->curr doesn't get modified.
void uint8_serial_write (const uint8 *pdata, ctl_serial *serial)
 Write an 8-bit scalar.
void uint8_serial_read (uint8 *pdata, ctl_serial *serial)
 Read an 8-bit scalar.
void uint8_serial_peek (uint8 *pdata, const ctl_serial *serial)
 Read an 8-bit scalar without chaning curr.
size_t uint8_serial_sizearray (const uint8 *array, size_t count)
 Calculate how big an array of scalars will be when serialized.
void uint8_serial_writearray (const uint8 *array, size_t count, ctl_serial *serial)
 Write an array of scalars.
void uint8_serial_readarray (uint8 *array, size_t count, ctl_serial *serial)
 Read an array of scalars.
void uint16_serial_write (const uint16 *pdata, ctl_serial *serial)
 Write a 16-bit scalar.
void uint16_serial_read (uint16 *pdata, ctl_serial *serial)
 Read a 16-bit scalar.
void uint16_serial_peek (uint16 *pdata, const ctl_serial *serial)
 Read a 16-bit scalar without chaning 'curr'.
size_t uint16_serial_sizearray (const uint16 *array, size_t count)
 Calculate how big an array of scalars will be when serialized.
void uint16_serial_writearray (const uint16 *array, size_t count, ctl_serial *serial)
 Write an array of scalars.
void uint16_serial_readarray (uint16 *array, size_t count, ctl_serial *serial)
 Read an array of scalars.
void uint32_serial_write (const uint32 *pdata, ctl_serial *serial)
 Write a 32-bit scalar.
void uint32_serial_read (uint32 *pdata, ctl_serial *serial)
 Read a 32-bit scalar.
void uint32_serial_peek (uint32 *pdata, ctl_serial *serial)
 Read a 32-bit scalar without chaning 'curr'.
size_t uint32_serial_sizearray (const uint32 *array, size_t count)
 Calculate how big an array of scalars will be when serialized.
void uint32_serial_writearray (const uint32 *array, size_t count, ctl_serial *serial)
 Write an array of scalars.
void uint32_serial_readarray (uint32 *array, size_t count, ctl_serial *serial)
 Read an array of scalars.
void uint64_serial_write (const uint64 *pdata, ctl_serial *serial)
 Write a 64-bit scalar.
void uint64_serial_read (uint64 *pdata, ctl_serial *serial)
 Read a 64-bit scalar.
void uint64_serial_peek (uint64 *pdata, ctl_serial *serial)
 Read a 64-bit scalar without changing parse point 'curr'.
size_t uint64_serial_sizearray (const uint64 *array, size_t count)
 Calculate how big an array of scalars will be when serialized.
void uint64_serial_writearray (const uint64 *array, size_t count, ctl_serial *serial)
 Write an array of scalars.
void uint64_serial_readarray (uint64 *array, size_t count, ctl_serial *serial)
 Read an array of scalars.
size_t char_serial_size_string (const char *sz, size_t szmax)
 Measure a character string bound for serial data.
size_t wchar_t_serial_size_string (const wchar_t *sz, size_t szmax)
 Measure a wide character string bound for serial data.
void char_serial_write_string (const char *sz, size_t szmax, ctl_serial *serial)
 Write a string to pre-allocated serial buffer.
void wchar_t_serial_write_string (const wchar_t *sz, size_t szmax, ctl_serial *serial)
 Write a string to pre-allocated serial buffer.
void char_serial_read_string (char *sz, size_t szmax, ctl_serial *serial)
 Read a serialized character string.
void wchar_t_serial_read_string (wchar_t *sz, size_t count, ctl_serial *serial)
 Read a serialized wide character string.
void char_serial_read_gstring (ctl_mstring_char_grow *str, ctl_serial *serial)
 Read a serialized wide character string.
void wchar_t_serial_read_gstring (ctl_mstring_wchar_t_grow *str, ctl_serial *serial)
 Read a serialized wide character string.
void char_serial_read_fstring (ctl_mstring_char_grow *str, ctl_serial *serial)
 Read a serialized character string.
void wchar_t_serial_read_fstring (ctl_mstring_wchar_t_grow *str, ctl_serial *serial)
 Read a serialized wide character string.
void char_serial_peek_sconst (ctl_sconst_char *str, ctl_serial *serial)
 Peek at a serialized character string, pointing at data in ctl_serial.
void wchar_t_serial_peek_sconst (ctl_sconst_wchar_t *str, ctl_serial *serial)
 Peek at a serialized wide character string, pointing at data in ctl_serial.
void char_serial_read_sconst (ctl_sconst_char *str, ctl_serial *serial)
 Read a serialized character string, pointing at data in ctl_serial.
void wchar_t_serial_read_sconst (ctl_sconst_wchar_t *str, ctl_serial *serial)
 Read a serialized wide character string, pointing at data in ctl_serial.
bool ctl_xmlwrite_begin (ctl_xmlwrite *self, ctl_mstring_char_grow *stringbuff)
 Open an XML stream for writing, setting everything up for its output.
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.
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.
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_getname (const ctl_xmlread *self, ctl_mstring_char_grow *str)
 Get the name of the current tag.
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 (ctl_xmlread *self, ctl_mstring_char_grow *str, const char *label)
 Get an attribute.
bool ctl_xmlread_getcontent (const ctl_xmlread *self, ctl_mstring_char_grow *str, bool eatWhite)
 Get the content;.
bool ctl_xmlread_gettextbefore (const ctl_xmlread *self, ctl_mstring_char_grow *str, bool eatWhite)
 Get text before the current block;.
bool ctl_xmlread_gettextafter (const ctl_xmlread *self, ctl_mstring_char_grow *str, bool eatWhite)
 Get text after the current block;.
bool ctl_xmlread_rawname (const ctl_xmlread *self, ctl_sconst_char *str)
 Get the name of the current tag.
bool ctl_xmlread_rawattribute (ctl_xmlread *self, ctl_sconst_char *str, const char *label)
 Get an attribute.
bool ctl_xmlread_getattribute_int (ctl_xmlread *self, const char *label, int32 *value)
 Get an attribute known to be an integer of some sort.
bool ctl_xmlread_rawcontent (const ctl_xmlread *self, ctl_sconst_char *str, bool eatWhite)
 Get the content;.
bool ctl_xmlread_rawtextbefore (const ctl_xmlread *self, ctl_sconst_char *str, bool eatWhite)
 Get text after the current block;.
bool ctl_xmlread_rawtextafter (const ctl_xmlread *self, ctl_sconst_char *str, bool eatWhite)
 Get text after the current block;.
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.
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_mstring_char_grow *str, ctl_xmlread *self, const char *label)
 Read a string into fixed length C string buffer.
bool wchar_t_xml_read_gstring (ctl_mstring_wchar_t_grow *str, ctl_xmlread *self, const char *label)
 Read a string into fixed length C string buffer.

Detailed Description


Define Documentation

#define container_list ( label,
type   ) 

Declare a doubly-linked list Like stl std::list, allocates objects by list membership, and frees them when removed from list.

Parameters:
label What to call the member
type Type for vector contents

Definition at line 520 of file patterns.h.

#define container_list ( label,
type   )     ctl_declare_list(label,type);

Declare a doubly-linked list Like stl std::list, allocates objects by list membership, and frees them when removed from list.

Parameters:
label What to call the member
type Type for vector contents

Definition at line 520 of file patterns.h.

#define container_map ( label,
keytype,
type   ) 

Declare a map (a container of sorted, unique kes with objects) Like stl std::map, allocates objects by list membership, and frees them when removed from list. By defaultt, sorts by keytype_compare, use the label_sort function to change that.

Parameters:
label What to call the member
keytype Type for key lookup
type Type for object

Definition at line 521 of file patterns.h.

#define container_map ( label,
keytype,
type   )     ctl_declare_map(label,keytype,type);

Declare a map (a container of sorted, unique kes with objects) Like stl std::map, allocates objects by list membership, and frees them when removed from list. By defaultt, sorts by keytype_compare, use the label_sort function to change that.

Parameters:
label What to call the member
keytype Type for key lookup
type Type for object

Definition at line 521 of file patterns.h.

#define container_multimap ( label,
keytype,
type   ) 

Declare a multimap (a container of sorted, NON-unique keys with objects) Like stl std::multimap, allocates objects by list membership, and frees them when removed from list. By defaultt, sorts by keytype_compare, use the label_sort function to change that.

Parameters:
label What to call the member
keytype Type for key lookup
type Type for object

Definition at line 522 of file patterns.h.

#define container_multimap ( label,
keytype,
type   )     ctl_declare_multimap(label,keytype,type);

Declare a multimap (a container of sorted, NON-unique keys with objects) Like stl std::multimap, allocates objects by list membership, and frees them when removed from list. By defaultt, sorts by keytype_compare, use the label_sort function to change that.

Parameters:
label What to call the member
keytype Type for key lookup
type Type for object

Definition at line 522 of file patterns.h.

#define container_multiset ( label,
type   ) 

Declare a multimap (a container of sorted, NON-unique objects) Like stl std::multiset, allocates objects by list membership, and frees them when removed from list. By defaultt, sorts by type_compare, use the label_sort function to change that.

Parameters:
label What to call the member
type Type for contents

Definition at line 524 of file patterns.h.

#define container_multiset ( label,
type   )     ctl_declare_multiset(label,type);

Declare a multimap (a container of sorted, NON-unique objects) Like stl std::multiset, allocates objects by list membership, and frees them when removed from list. By defaultt, sorts by type_compare, use the label_sort function to change that.

Parameters:
label What to call the member
type Type for contents

Definition at line 524 of file patterns.h.

#define container_set ( label,
type   ) 

Declare a set (a container of sorted, unique objects) Like stl std::set, allocates objects by list membership, and frees them when removed from list. By defaultt, sorts by type_compare, use the label_sort function to change that.

Parameters:
label What to call the member
type Type for contents

Definition at line 523 of file patterns.h.

#define container_set ( label,
type   )     ctl_declare_set(label,type);

Declare a set (a container of sorted, unique objects) Like stl std::set, allocates objects by list membership, and frees them when removed from list. By defaultt, sorts by type_compare, use the label_sort function to change that.

Parameters:
label What to call the member
type Type for contents

Definition at line 523 of file patterns.h.

#define ctl_array_bsort_declare ( type   )     void ppConcat(type,_array_bsort)( type* low, type* high, int (*compare)(const type* p1, const type* p2) )

Declare a bubble sort for a particular data type.

Parameters:
type Type of data to sort

Definition at line 24 of file algorithm.h.

#define ctl_array_bsort_implement ( type   ) 

Value:

ctl_array_bsort_declare(type)\
{\
    bool bSwap;\
    do\
    {\
        bSwap = false;\
        while( low < high )\
        {\
            if( compare( low,low+1 ) > 0 )\
            {\
                ppConcat( type,_swap )( low,low+1 );\
                bSwap = true;\
            }\
            low++;\
        }\
    } while( bSwap );\
}
Manufacture a quicker sort for a particular data type.

Parameters:
type Type of data to sort

Definition at line 64 of file algorithm.temp.h.

#define ctl_array_qsort_declare ( type   )     void ppConcat(type,_array_qsort)( type* low, type* high, int (*compare)(const type* p1, const type* p2) )

Declare a quicker sort for a particular data type.

Parameters:
type Type of data to sort

Definition at line 16 of file algorithm.h.

#define ctl_array_qsort_implement ( type   ) 

Manufacture a quicker sort for a particular data type.

Parameters:
type Type of data to sort

Definition at line 25 of file algorithm.temp.h.

#define ctl_serial_alloc ( serial,
size   ) 

Value:

{\
        ctl_serial* tser = (serial);\
        size_t tsize = (size);\
        ctl_malloc(tser->buff,tsize);\
        tser->begin = tser->curr = (uint8*)tser->buff;\
        tser->end = tser->begin + tsize;\
    }
Allocate 'size' bytes of serial data.

Parameters:
serial Instance to initialize
size Size of serial data we want

Definition at line 62 of file serial.h.

Referenced by ctl_serial_copy(), ctl_serial_deref(), and raw_xml_readbytes().

#define ctl_serial_auto ( label,
begin,
end   )     ctl_serial label = { begin, curr, end, NULL }

Manufacture a serial parser on the stack.

Parameters:
label What to call the instance we're making
begin First byte in serial data
end First byte AFTER serial data

Definition at line 45 of file serial.h.

#define ctl_serial_auto_vector ( label,
vec   )     ctl_serial label = { (vec)->array, (vec)->array, (vec)->array+(vec)->count }

Manufacture a serial parser on the stack from a uint8 vector.

Parameters:
label What to call the serial we're making
vec vector to get data from/write data to

Definition at line 112 of file serial.h.

#define ctl_serial_consumed ( serial   )     ( (serial)->curr - (serial)->begin )

Tell us how much a serial parser has used.

Parameters:
serial Instance to test

Definition at line 98 of file serial.h.

#define ctl_serial_free ( serial   )     ctl_free( (serial)->buff )

Free allocated serial data (if any).

Parameters:
serial Instance to initialize

Definition at line 76 of file serial.h.

#define ctl_serial_init ( serial,
_begin,
_end   )     { (serial)->begin = (serial)->curr = (uint8*)(_begin); (serial)->end = (uint8*)(_end); (serial)->buff = NULL; }

Initialize an existin serial parser.

Parameters:
serial Instance to initialize
_begin First byte in serial data
_end First byte AFTER serial data

Definition at line 54 of file serial.h.

Referenced by ctl_serial_record_read(), RingBuff_AddSerial(), RingBuff_PeekSerial(), and RingBuff_PopSerial().

#define ctl_serial_init_vector ( serial,
vec,
_except   )     { (serial)->begin = (serial)->curr = (vec)->array; (vec)->array+(vec)->count; (serial)->except = (_except); }

Initialize a serial parser from a uint8 vector.

Parameters:
serial Instance to initialize
vec vector to get data from/write data to

Definition at line 119 of file serial.h.

#define ctl_serial_remain ( serial   )     ( (serial)->end - (serial)->curr )

Tell us how much a serial parser has left in it.

Parameters:
serial Instance to test

Definition at line 92 of file serial.h.

Referenced by ctl_record_contained_type(), and ctl_record_type().

#define ctl_serial_rewind ( serial   )     ( (serial)->curr = (uint8*)(serial)->begin )

Rewind parsed serial back to beginning.

Parameters:
serial Instance to rewind

Definition at line 104 of file serial.h.

#define ctl_serial_size_size ( size   )     uint16_serial_size(size)

Determine how big a size will be in the stream.

Parameters:
size Size to measure
Returns:
Number of bytes consumed to store this measurement

Definition at line 127 of file serial.h.

Referenced by char_serial_peek_sconst(), ctl_serial_peek_serial(), and wchar_t_serial_peek_sconst().

#define ctl_serial_size_size_size ( size   )     (ctl_serial_size_size(size) + (size))

Return how big a size will be in a serial stream, including the passed size.

Parameters:
size Size to measure
Returns:
Number of bytes consumed to store this measurement, plus that number of bytes

Definition at line 135 of file serial.h.

Referenced by char_serial_size_string(), ctl_serial_calc_size(), ctl_serial_writesize(), uint16_serial_sizearray(), uint32_serial_sizearray(), uint64_serial_sizearray(), uint8_serial_sizearray(), and wchar_t_serial_size_string().

#define ctl_serial_total ( serial   )     ( (serial)->end - (serial)->begin )

Tell us how much a serial parser has in it.

Parameters:
serial Instance to test

Definition at line 86 of file serial.h.

Referenced by ctl_serial_calc_size(), ctl_serial_copy(), ctl_serial_deref(), ctl_serial_record_size(), ctl_serial_record_write(), ctl_serial_write_serial(), raw_xml_writebytes(), and Socket_Write_Serial().

#define DECL_DEF ( type,
unused   ) 

Value:

bool ppConcat(type,_xml_read_array)( type* ptr, size_t count, ctl_xmlread* self, const char* label )\
{\
    int remain = (int)count;\
    bool ret = false;\
    assertptr(ptr,sizeof(*ptr));/* Inputs should be valid-looking */\
    assertobjptr(self);\
    if( ctl_xmlread_find( self, label ) )\
    {\
        ctl_sconst(char) body;\
        ctl_xmlread_rawcontent( self, &body, true );\
        while( remain-- && ppConcat(ctl_sconst_get,type)(char, &body, ptr ) )\
            ptr++;\
        ret = true;\
    }\
    return ret;\
}
Template: Write a scalar of whatever type.

Read an array of whatever scalar type.

Template: Read a scalar of whatever scalar type.

Write an array of type

Definition at line 1468 of file xml.c.

#define DECL_DEF ( type,
unused   ) 

Value:

bool ppConcat(type,_xml_read)( type* val, ctl_xmlread* self, const char* label )\
{\
    assertptr(val,sizeof(*val));\
    assertobjptr(self);\
    if( label ? ctl_xmlread_find( self, label ) : ctl_xmlread_is( self, #type ) )\
    {\
        ctl_sconst(char) body;\
        ctl_xmlread_rawcontent( self, &body, true );\
        ppConcat(ctl_sconst_get,type)(char, &body, val );\
        return true;\
    }\
    return false;\
}
Template: Write a scalar of whatever type.

Read an array of whatever scalar type.

Template: Read a scalar of whatever scalar type.

Write an array of type

Definition at line 1468 of file xml.c.

#define DECL_DEF ( type,
unused   ) 

Value:

void ppConcat(type,_xml_write_array)( const type* ptr, size_t count, ctl_xmlwrite* self, const char* label )\
{\
    if( NULL == label )\
        label = #type;\
    assertconst(label,1);   /* Inputs should be valid-looking */\
    assertconst(ptr,sizeof(*ptr));/* Inputs should be valid-looking */\
    assertobjptr(self);\
    ctl_xmlwrite_containertag( self, szconst(char,#type), count, label );\
    while( count-- ) \
        xml_printf( self, szconst(char," %") type_printf(char,type), typecast_printf(type)*ptr++ );\
    ctl_xmlwrite_endtag( self, szconst(char,#type), label );\
}
Template: Write a scalar of whatever type.

Read an array of whatever scalar type.

Template: Read a scalar of whatever scalar type.

Write an array of type

Definition at line 1468 of file xml.c.

#define DECL_DEF ( type,
unused   ) 

Value:

void ppConcat(type,_xml_write)( const type* val, ctl_xmlwrite* self, const char* label )\
{\
    if( NULL == label )\
        label = #type;\
    assertconst(label,1);   /* Inputs should be valid-looking */\
    assertobjconst(val);\
    assertobjptr(self);\
    ctl_xmlwrite_generaltag( self, szconst(char,#type), label );\
    xml_printf( self, szconst(char,"%") type_printf(char,type), typecast_printf(type)*val );\
    ctl_xmlwrite_endtag( self, szconst(char,#type), label );\
}
Template: Write a scalar of whatever type.

Read an array of whatever scalar type.

Template: Read a scalar of whatever scalar type.

Write an array of type

Definition at line 1468 of file xml.c.

#define enum_begin ( label   ) 

Begin an enumeration declaration.

Parameters:
label What to call the enumeration

Definition at line 484 of file patterns.h.

#define enum_begin ( label   )     typedef enum {

Begin an enumeration declaration.

Parameters:
label What to call the enumeration

Definition at line 484 of file patterns.h.

#define enum_count ( enum   )     ppConcat(enum,_COUNT)

Get count of an enumeration's members.

Parameters:
enum The enumeration name

Definition at line 121 of file datagen.h.

#define enum_end ( label   ) 

End an enumeration declaration.

Parameters:
label What to call the enumeration; must be same as enum_begin

Definition at line 486 of file patterns.h.

#define enum_end ( label   ) 

Value:

enum_count( label )\
                                        } label;\
                                        extern const bool ppConcat(label,_isscalar);\
                                        extern const char* const ppConcat(szz,label)[];
End an enumeration declaration.

Parameters:
label What to call the enumeration; must be same as enum_begin

Definition at line 486 of file patterns.h.

#define enum_foreach ( enum,
iterator   )     enum iterator; for ( iterator = (enum)0; iterator < enum_count( enum ); iterator = (enum)(1 + iterator) )

Iterate enumerated items forwards.

Parameters:
enum The enumeration name
iterator The variable that will assume each state

Definition at line 162 of file datagen.h.

#define enum_foreach_reverse ( enum,
iterator   )     enum iterator = enum_count( enum ); while( iterator-- )

Iterate enumerated items backwards.

Parameters:
enum The enumeration name
iterator The variable that will assume each state

Definition at line 170 of file datagen.h.

#define enum_isvalid ( enum,
value   )     ( ((unsigned)(value)) < ((unsigned)ppConcat(enum,_COUNT)) )

Do bounds check on enumeration type value.

Parameters:
enum The enumeration name
value The value we want to check for validity
Returns:
true if value is within the valid range of an enum

Definition at line 130 of file datagen.h.

#define enum_item ( label   ) 

Add an enumerated item.

Parameters:
label Name of item

Definition at line 485 of file patterns.h.

#define enum_item ( label   )     label,

Add an enumerated item.

Parameters:
label Name of item

Definition at line 485 of file patterns.h.

#define enum_itemname ( enum,
value   )     ( enum_isvalid(enum,value) ? ppConcat(szz,enum)[(value)] : #enum "INVALID" )

Get an enumeration's item name from an EDEF.

Parameters:
enum The enumeration name
value The enumeration value, NOTE it will be evalueuated by macro up to three times.
Returns:
String label representing this item

Definition at line 139 of file datagen.h.

#define enum_itemnames ( enum   )     ppConcat(szz,enum)

Get count of an enumeration's members.

Parameters:
enum The enumeration name

Definition at line 146 of file datagen.h.

#define enum_rand ( enum   )     ((enum)(rand() % enum_count( enum )))

Generate a random enumeration value.

Parameters:
enum The enumeration name
Returns:
A randomly selected value from the enumerated range

Definition at line 154 of file datagen.h.

#define protocol_begin ( label   )     typedef enum label {

Begin a protocol enumeration.

Parameters:
label What to call the enumeration
This generates an enumeration of all the types

Definition at line 482 of file patterns.h.

#define protocol_begin ( label   ) 

Begin a protocol enumeration.

Parameters:
label What to call the enumeration
This generates an enumeration of all the types

Definition at line 482 of file patterns.h.

#define protocol_end ( label   ) 

Value:

enum_count( label )\
                                        } label;\
                                        extern const bool ppConcat(label,_isscalar);\
                                        extern const char* const ppConcat(szz,label)[];
Complete a protocol enumeration.

Parameters:
label Same as protocol_begin

Definition at line 526 of file patterns.h.

#define protocol_end ( label   ) 

Complete a protocol enumeration.

Parameters:
label Same as protocol_begin

Definition at line 526 of file patterns.h.

#define record_achar ( label,
type,
alen,
val   ) 

Declare a string array member.

Parameters:
label What to call the member
type Type of character (char, wchar_t)
alen Maximum length of string
val Initial string value

Definition at line 494 of file patterns.h.

#define record_achar ( label,
type,
alen,
val   )     type label[alen];

Declare a string array member.

Parameters:
label What to call the member
type Type of character (char, wchar_t)
alen Maximum length of string
val Initial string value

Definition at line 494 of file patterns.h.

#define record_alias ( label,
type   )     ppConcat(e,label),

Assign another protocol value to the same record type.

Parameters:
label What to call the protocol value
type Existing type to alias to this value

Definition at line 510 of file patterns.h.

#define record_alias ( label,
type   ) 

Assign another protocol value to the same record type.

Parameters:
label What to call the protocol value
type Existing type to alias to this value

Definition at line 510 of file patterns.h.

#define record_array ( label,
type,
alen,
val   ) 

Declare an array of scalars.

Parameters:
label What to call the member
type Type of scalar (bool, int8, uint8, int16, uint16, int32, uint32, int64, uint64, float32, float64)
alen Size of array
val Initial value

Definition at line 491 of file patterns.h.

#define record_array ( label,
type,
alen,
val   )     type label[alen];

Declare an array of scalars.

Parameters:
label What to call the member
type Type of scalar (bool, int8, uint8, int16, uint16, int32, uint32, int64, uint64, float32, float64)
alen Size of array
val Initial value

Definition at line 491 of file patterns.h.

#define record_arrayok ( label,
type,
alen,
val,
min,
max   ) 

Declare an array of scalars.

Parameters:
label What to call the member
type Type of scalar (bool, int8, uint8, int16, uint16, int32, uint32, int64, uint64, float32, float64)
alen Size of array
val Initial value
min Minimum valid value
max Maximum valid value

Definition at line 492 of file patterns.h.

#define record_arrayok ( label,
type,
alen,
val,
min,
max   )     type label[alen];

Declare an array of scalars.

Parameters:
label What to call the member
type Type of scalar (bool, int8, uint8, int16, uint16, int32, uint32, int64, uint64, float32, float64)
alen Size of array
val Initial value
min Minimum valid value
max Maximum valid value

Definition at line 492 of file patterns.h.

#define record_atcopy ( stuff   ) 

Code to execute when copy operations happen.

Parameters:
stuff Stuff to be copied verbatim 'stuff' has dst and src available to it

Definition at line 505 of file patterns.h.

#define record_atcopy ( stuff   ) 

Code to execute when copy operations happen.

Parameters:
stuff Stuff to be copied verbatim 'stuff' has dst and src available to it

Definition at line 505 of file patterns.h.

#define record_atdestroy ( stuff   ) 

Code to execute when destruction happens.

Parameters:
stuff Stuff to be copied verbatim 'stuff' has 'self' available to it

Definition at line 504 of file patterns.h.

#define record_atdestroy ( stuff   ) 

Code to execute when destruction happens.

Parameters:
stuff Stuff to be copied verbatim 'stuff' has 'self' available to it

Definition at line 504 of file patterns.h.

#define record_atinit ( stuff   ) 

Code to execute when initialization happens.

Parameters:
stuff Stuff to be copied verbatim 'stuff' has 'self' available to it

Definition at line 503 of file patterns.h.

#define record_atinit ( stuff   ) 

Code to execute when initialization happens.

Parameters:
stuff Stuff to be copied verbatim 'stuff' has 'self' available to it

Definition at line 503 of file patterns.h.

#define record_atmove ( stuff   ) 

Code to execute when move operations happen.

Parameters:
stuff Stuff to be copied verbatim 'stuff' has dst and src available to it

Definition at line 506 of file patterns.h.

#define record_atmove ( stuff   ) 

Code to execute when move operations happen.

Parameters:
stuff Stuff to be copied verbatim 'stuff' has dst and src available to it

Definition at line 506 of file patterns.h.

#define record_atswap ( stuff   ) 

Code to execute when swap operations happen.

Parameters:
stuff Stuff to be copied verbatim 'stuff' has p1 and p2 available to it

Definition at line 507 of file patterns.h.

#define record_atswap ( stuff   ) 

Code to execute when swap operations happen.

Parameters:
stuff Stuff to be copied verbatim 'stuff' has p1 and p2 available to it

Definition at line 507 of file patterns.h.

#define record_begin ( label   )     ppConcat(e,label),

Begin a record declaration.

Parameters:
label What to call the enumeration

Definition at line 488 of file patterns.h.

#define record_begin ( label   )     typedef struct label {

Begin a record declaration.

Parameters:
label What to call the enumeration

Definition at line 488 of file patterns.h.

#define record_end ( label   ) 

End a record definition.

Parameters:
label What to call the record; must be same as record_begin

Definition at line 508 of file patterns.h.

#define record_end ( label   ) 

Value:

ppCPP( public: )    /* C++ code generated if we're building under C++ */\
                                                        ppCPP( const classname& operator=( const label& src ) { ppConcat(label,_destroy)(this); ppConcat(label,_copy)(this,&src); return *this; } )\
                                                    } label;\
                                                    /* These functions are bundled up so we can semi-trivially manufacture record declarations for extensions */\
                                                    ctl_datagen_declare_functions(label);\
                                                    /* Unit test optional randomizer */\
                                                    RANDOMIZER( void ppConcat(label,_randomize)( label* self ); )\
End a record definition.

Parameters:
label What to call the record; must be same as record_begin

Definition at line 508 of file patterns.h.

#define record_enum ( label,
type,
val   ) 

Declare an enumeration.

Parameters:
label What to call the member
type Type of enumeration
val Default value

Definition at line 499 of file patterns.h.

#define record_enum ( label,
type,
val   )     type label;

Declare an enumeration.

Parameters:
label What to call the member
type Type of enumeration
val Default value

Definition at line 499 of file patterns.h.

#define record_member ( stuff   ) 

Define some data to be expanded in the record declaration.

Parameters:
stuff Stuff to be copied verbatim

Definition at line 502 of file patterns.h.

#define record_member ( stuff   )     stuff

Define some data to be expanded in the record declaration.

Parameters:
stuff Stuff to be copied verbatim

Definition at line 502 of file patterns.h.

#define record_obj ( label,
type   ) 

Declare a record type member, as generated with this system.

Parameters:
label What to call the member
type Type of class/struct

Definition at line 496 of file patterns.h.

#define record_obj ( label,
type   )     type label;

Declare a record type member, as generated with this system.

Parameters:
label What to call the member
type Type of class/struct

Definition at line 496 of file patterns.h.

#define record_objarray ( label,
type,
alen   ) 

Declare an array of record types, as generated with this system.

Parameters:
label What to call the member
type Type of class/struct
alen Size of array

Definition at line 493 of file patterns.h.

#define record_objarray ( label,
type,
alen   )     type label[alen];

Declare an array of record types, as generated with this system.

Parameters:
label What to call the member
type Type of class/struct
alen Size of array

Definition at line 493 of file patterns.h.

#define record_preref ( label,
type   ) 

Declare a reference to a dynamically allocated record, initially allocated.

Parameters:
label What to call the member
type Type of class/struct

Definition at line 498 of file patterns.h.

#define record_preref ( label,
type   )     type* label;

Declare a reference to a dynamically allocated record, initially allocated.

Parameters:
label What to call the member
type Type of class/struct

Definition at line 498 of file patterns.h.

#define record_ref ( label,
type   ) 

Declare a reference to a dynamically allocated record, initially NULL.

Parameters:
label What to call the member
type Type of class/struct

Definition at line 497 of file patterns.h.

#define record_ref ( label,
type   )     type* label;

Declare a reference to a dynamically allocated record, initially NULL.

Parameters:
label What to call the member
type Type of class/struct

Definition at line 497 of file patterns.h.

#define record_serial ( label   ) 

Define serial data.

Parameters:
label What to call the member
bcopy true=make a copy of serial data to store, false=make a reference.

Definition at line 500 of file patterns.h.

#define record_serial ( label   )     ctl_serial label;

Define serial data.

Parameters:
label What to call the member
bcopy true=make a copy of serial data to store, false=make a reference.

Definition at line 500 of file patterns.h.

#define record_serialref ( label   ) 

Define a REFERENCE to serial data Only suitable in messaging protocols where packet is turned around before the data it points at goes away.

Parameters:
label What to call the member
bcopy true=make a copy of serial data to store, false=make a reference.

Definition at line 501 of file patterns.h.

#define record_serialref ( label   )     ctl_serial label;

Define a REFERENCE to serial data Only suitable in messaging protocols where packet is turned around before the data it points at goes away.

Parameters:
label What to call the member
bcopy true=make a copy of serial data to store, false=make a reference.

Definition at line 501 of file patterns.h.

#define record_string ( label,
type   ) 

Declare a string array member.

Parameters:
label What to call the member
type Type of character (char, wchar_t)

Definition at line 495 of file patterns.h.

#define record_string ( label,
type   )     ctl_gstring(type) label;

Declare a string array member.

Parameters:
label What to call the member
type Type of character (char, wchar_t)

Definition at line 495 of file patterns.h.

#define record_var ( label,
type,
val   ) 

Declare a scalar member.

Parameters:
label What to call the member
type Type of scalar (bool, int8, uint8, int16, uint16, int32, uint32, int64, uint64, float32, float64)
val Initial value

Definition at line 489 of file patterns.h.

#define record_var ( label,
type,
val   )     type label;

Declare a scalar member.

Parameters:
label What to call the member
type Type of scalar (bool, int8, uint8, int16, uint16, int32, uint32, int64, uint64, float32, float64)
val Initial value

Definition at line 489 of file patterns.h.

#define record_varok ( label,
type,
val,
min,
max   ) 

Declare a validated scalar member.

Parameters:
label What to call the member
type Type of scalar (bool, int8, uint8, int16, uint16, int32, uint32, int64, uint64, float32, float64)
val Initial value
min Minimum valid value
max Maximum valid value

Definition at line 490 of file patterns.h.

#define record_varok ( label,
type,
val,
min,
max   )     type label;

Declare a validated scalar member.

Parameters:
label What to call the member
type Type of scalar (bool, int8, uint8, int16, uint16, int32, uint32, int64, uint64, float32, float64)
val Initial value
min Minimum valid value
max Maximum valid value

Definition at line 490 of file patterns.h.

#define union_alias ( type,
enum   ) 

Declare an enumerated union member that uses the same kind of data as a later definition. Since the enumeration is notionally for a switch, this is for a 'fall-through' Keeps unions with common/re-used member types from becomming bloated switch( enum ) { case sometype: // union_member(something,somethingtype,sometype) dosomething(&self.something); break; case aliastype: // union_alias(somethingelsetype,aliastype) case anothertype: // union_member(anothersomething,somethingelsetype,anothertype) doanothersomething(&self.anothersomething); break; ... }.

Parameters:
type What the data type is
enum Enumeration value for this type (must be unique)

Definition at line 513 of file patterns.h.

#define union_alias ( type,
enum   ) 

Declare an enumerated union member that uses the same kind of data as a later definition. Since the enumeration is notionally for a switch, this is for a 'fall-through' Keeps unions with common/re-used member types from becomming bloated switch( enum ) { case sometype: // union_member(something,somethingtype,sometype) dosomething(&self.something); break; case aliastype: // union_alias(somethingelsetype,aliastype) case anothertype: // union_member(anothersomething,somethingelsetype,anothertype) doanothersomething(&self.anothersomething); break; ... }.

Parameters:
type What the data type is
enum Enumeration value for this type (must be unique)

Definition at line 513 of file patterns.h.

#define union_end ( label,
etype   ) 

Complete an enumerated union.

Parameters:
label Same as label in union_begin

Definition at line 515 of file patterns.h.

#define union_end ( label,
etype   ) 

Value:

}   obj;\
                                            } label;\
                                            /* These functions are bundled up so we can semi-trivially manufacture record declarations for extensions */\
                                            ctl_datagen_declare_functions(label);\
                                            /* Unit test optional randomizer */\
                                            RANDOMIZER( void ppConcat(label,_randomize)( label* self ); )\
                                            void ppConcat(label,_setup)( label* self, etype which );\
                                            void ppConcat(label,_reset)( label* self, etype which );
Complete an enumerated union.

Parameters:
label Same as label in union_begin

Definition at line 515 of file patterns.h.

#define union_member ( label,
type,
enum   ) 

Declare an enumerated union member.

Parameters:
label What to call the item in the union
type What the data type is (can repeat)
enum Enumeration value for this type (must be unique)

Definition at line 514 of file patterns.h.

#define union_member ( label,
type,
enum   )     type label;

Declare an enumerated union member.

Parameters:
label What to call the item in the union
type What the data type is (can repeat)
enum Enumeration value for this type (must be unique)

Definition at line 514 of file patterns.h.


Function Documentation

bool bool_record_read ( bool *  pdata,
const ctl_serial serial,
const char *  label 
)

\

\ \ \ \

  • .

Definition at line 892 of file record.c.

00901 {\

bool bool_record_readarray ( bool *  pdata,
size_t  count,
const ctl_serial serial,
const char *  label 
)

\

\ \ \ \ \

  • .

Definition at line 1048 of file record.c.

bool char_record_read_gstring ( ctl_mstring_char_grow *  str,
const ctl_serial serial,
const char *  label 
)

Read a string.

Parameters:
str Dsetination to read to
serial Serial data to find string in and load it from
label Name of string

Definition at line 751 of file record.c.

References assertconst, assertobjconst, assertobjptr, chslength, ctl_chlength, ctl_gstring_resize, ctl_record_contained_type(), ctl_record_find(), ctl_record_getdata(), ctl_record_type(), ctl_serial::curr, ctl_serial::end, and uint16_serial_read().

00752 {
00753     ctl_serial tmp;
00754     assertobjptr(str);
00755     assertconst(label,1);
00756     assertobjconst(serial);
00757     tmp = *serial;
00758     if( ctl_record_find( &tmp, label ) )
00759     {
00760         const char* szcontainer = ctl_record_type( &tmp );
00761         if( cstrcmp(char)(szcontainer,"string") )
00762             ctl_serial_except( serial, "char_record_read_string: Not a string" );
00763         {
00764             const char* sz = ctl_record_contained_type( &tmp );
00765             size_t rsize = ctl_record_getdata( &tmp );
00766             if( !cstrcmp(char)(sz,"char") )
00767             {
00768                 ctl_gstring_resize(char, str, ctl_chlength(char,rsize) );
00769                 memcpy( str->begin, tmp.curr, rsize );
00770             }
00771             else if( !cstrcmp(char)(sz,"wchar_t") )
00772             {
00773                 char* sz;
00774                 if( rsize & 1 )
00775                     ctl_serial_except( serial, "char_record_read_string: Odd string length" );
00776                 ctl_gstring_resize(char, str, chslength(wchar_t,rsize) );
00777                 sz = str->begin;
00778                 while( tmp.curr < tmp.end )
00779                 {
00780                     uint16 ch;
00781                     uint16_serial_read( &ch, &tmp );
00782                     *sz++ = (char)ch;
00783                 }
00784             }
00785             else
00786             {
00787                 ctl_serial_except( serial, "char_record_read_string: Unknown character type" );
00788             }
00789         }
00790         return true;
00791     }
00792     return false;
00793 }

Here is the call graph for this function:

bool char_record_read_string ( char *  sz,
size_t  size,
const ctl_serial serial,
const char *  label 
)

Read a string.

Parameters:
sz Beginning of string to read into
size Maximum size to store there
serial Serial data to find string in and load it from
label Name of string

Definition at line 650 of file record.c.

References assertconst, assertobjconst, assertptr, ctl_record_contained_type(), ctl_record_find(), ctl_record_getdata(), ctl_record_type(), ctl_serial::curr, ctl_serial::end, and uint16_serial_read().

00651 {
00652     ctl_serial tmp;
00653     assertptr(sz,size);
00654     assertconst(label,1);
00655     assertobjconst(serial);
00656     tmp = *serial;
00657     if( ctl_record_find( &tmp, label ) )
00658     {
00659         const char* szcontainer = ctl_record_type( &tmp );
00660         if( cstrcmp(char)(szcontainer,"string") )
00661             ctl_serial_except( serial, "char_record_read_string: Not a string" );
00662         {
00663             const char* szt = ctl_record_contained_type( &tmp );
00664             size_t rsize = ctl_record_getdata( &tmp );
00665             if( !cstrcmp(char)(szt,"char") )
00666             {
00667                 memcpy( sz, tmp.curr, min(size,rsize) );
00668                 if( size > rsize )
00669                     sz[rsize] = 0;
00670             }
00671             else if( !cstrcmp(char)(szt,"type") )
00672             {
00673                 while( size-- && tmp.curr < tmp.end )
00674                 {
00675                     uint16 ch;
00676                     uint16_serial_read( &ch, &tmp );
00677                     *sz++ = (char)ch;
00678                 }
00679                 if( size > 0 )
00680                     *sz++ = 0;
00681             }
00682             else
00683             {
00684                 ctl_serial_except( serial, "char_record_read_string: Unknown character type" );
00685             }
00686         }
00687         return true;
00688     }
00689     return false;
00690 }

Here is the call graph for this function:

size_t char_record_size_gstring ( const ctl_mstring_char_grow *  str,
const char *  label 
)

Measure string size for record output.

Parameters:
str string to measure
label Label for string

Definition at line 577 of file record.c.

References assertconst, assertobjconst, chssize, ctl_gstring_size, and ctl_record_objarray_head_size().

00578 {
00579     assertconst(label,1);
00580     assertobjconst(str);
00581     return ctl_record_objarray_head_size( label,"string","char" ) + chssize(char,ctl_gstring_size(char,str));
00582 }

Here is the call graph for this function:

size_t char_record_size_string ( const char *  str,
size_t  maxsize,
const char *  label 
)

Measure string size for record output.

Predicted record size.

Parameters:
str string to measure
maxsize Biggest string can be
label Label for string

Definition at line 552 of file record.c.

References assertconst, chssize, and ctl_record_objarray_head_size().

00553 {
00554     assertconst(label,1);
00555     assertconst(str,1);
00556     return ctl_record_objarray_head_size( label,"string","char" ) + chssize(char,cstrnlen(char)(str,maxsize));
00557 }

Here is the call graph for this function:

void char_record_write_string ( const char *  sz,
size_t  size,
ctl_serial serial,
const char *  label 
)

Write a string.

Parameters:
sz Start of string
size Maximum length of string
serial Serial data to put record in
label Label for record

Definition at line 605 of file record.c.

References assert, assertconst, assertobjptr, ctl_record_write_container_begin(), and ctl_serial::curr.

00606 {
00607     size_t storesize;
00608     assertconst(sz,1);
00609     assertconst(label,1);
00610     assertobjptr(serial);
00611     storesize = cstrnlen(char)(sz,size);
00612     assert( serial->curr + storesize <= serial->end );
00613     ctl_record_write_container_begin( "string", "char", storesize,storesize, serial, label );
00614     memcpy( serial->curr, sz, storesize );
00615     serial->curr += storesize;
00616 }

Here is the call graph for this function:

void char_serial_peek_sconst ( ctl_sconst_char *  str,
ctl_serial serial 
)

Peek at a serialized character string, pointing at data in ctl_serial.

Parameters:
str String constant type to receive beginning/ense of string
serial Serial parser

Definition at line 1187 of file serial.c.

References assertobjptr, ctl_sconst_init_pointers, ctl_serial_peeksize(), ctl_serial_size_size, and ctl_serial::curr.

01188 {
01189     size_t size;
01190     const char* pStr;
01191     assertobjptr(str);
01192     assertobjptr(serial);
01193     size = ctl_serial_peeksize( serial );
01194     pStr = (const char*)serial->curr + ctl_serial_size_size( size );
01195     ctl_sconst_init_pointers(char, str, pStr, pStr + size );
01196 }

Here is the call graph for this function:

void char_serial_read_fstring ( ctl_mstring_char_grow *  str,
ctl_serial serial 
)

Read a serialized character string.

Parameters:
str Fixed length string to read into
serial Serial parser

Definition at line 1150 of file serial.c.

References assertobjptr, chslength, ctl_fstring_maxsize, ctl_serial_peeksize(), and ppConcat.

01151 {
01152     size_t msize;
01153     size_t maxsize;
01154     assertobjptr(str);
01155     assertobjptr(serial);
01156     msize = chslength(char,ctl_serial_peeksize( serial ));
01157     maxsize = ctl_fstring_maxsize(char,str);
01158     if( msize > maxsize )
01159         msize = maxsize;
01160     ppConcat(char,_serial_read_string)( str->begin, msize, serial );
01161 }

Here is the call graph for this function:

void char_serial_read_gstring ( ctl_mstring_char_grow *  str,
ctl_serial serial 
)

Read a serialized wide character string.

Parameters:
str Dynamically allocated string to read into
serial Serial parser

Definition at line 1118 of file serial.c.

References assertobjptr, chslength, ctl_gstring_resize, ctl_serial_peeksize(), and ppConcat.

01119 {
01120     size_t msize;
01121     assertobjptr(str);
01122     assertobjptr(serial);
01123     msize = chslength(char,ctl_serial_peeksize( serial ));
01124     ctl_gstring_resize(char, str, msize );
01125     ppConcat(char,_serial_read_string)( str->begin, msize, serial );
01126 }

Here is the call graph for this function:

void char_serial_read_sconst ( ctl_sconst_char *  str,
ctl_serial serial 
)

Read a serialized character string, pointing at data in ctl_serial.

Parameters:
str ctl_sconst constant string type to receive beginning/end of string
serial Serial parser

Definition at line 1222 of file serial.c.

References assertobjptr, ctl_sconst_init_pointers, ctl_serial_readsize(), and ctl_serial::curr.

01223 {
01224     size_t size;
01225     const char* pStr;
01226     assertobjptr(str);
01227     assertobjptr(serial);
01228     size = ctl_serial_readsize( serial );
01229     pStr = (const char*)serial->curr;
01230     ctl_sconst_init_pointers(char, str, pStr, pStr + size );
01231     serial->curr += size;
01232 }

Here is the call graph for this function:

void char_serial_read_string ( char *  sz,
size_t  szmax,
ctl_serial serial 
)

Read a serialized character string.

Parameters:
sz Pointer to the string, which will either be NUL terminated, or end at szmax characters
szmax Maximum length of string
serial Serial parser

Definition at line 1067 of file serial.c.

References assertconst, assertobjptr, ctl_serial_readsize(), and ctl_serial::curr.

01068 {
01069     size_t len;
01070     size_t toget;
01071     assertconst(sz,sizeof(char));
01072     assertobjptr(serial);
01073     len = ctl_serial_readsize( serial );
01074     toget = min(len,szmax);
01075     memcpy(sz,serial->curr,toget);
01076     if( toget < szmax )
01077         sz[toget] = 0;
01078     serial->curr += len;
01079 }

Here is the call graph for this function:

size_t char_serial_size_string ( const char *  sz,
size_t  szmax 
)

Measure a character string bound for serial data.

Parameters:
sz Pointer to the string, which will either be NUL terminated, or end at szmax characters
szmax Maximum length of string
Returns:
Number of bytes to store the string

Definition at line 991 of file serial.c.

References assertconst, and ctl_serial_size_size_size.

00992 {
00993     assertconst(sz,1);
00994     {
00995         size_t len = cstrnlen(char)(sz,szmax);
00996         return ctl_serial_size_size_size( len );
00997     }
00998 }

void char_serial_write_string ( const char *  sz,
size_t  szmax,
ctl_serial serial 
)

Write a string to pre-allocated serial buffer.

Parameters:
sz String to write
szmax Maximum length of this string
serial Buffer/parse pointer

Definition at line 1023 of file serial.c.

References assert, assertconst, assertobjptr, ctl_serial_writesize(), and ctl_serial::curr.

01024 {
01025     size_t len;
01026     assertconst(sz,sizeof(char));
01027     assertobjptr(serial);
01028     len = cstrnlen(char)(sz,szmax);
01029     ctl_serial_writesize( (uint32)len, serial );
01030     assert( serial->curr + len <= serial->end );
01031     memcpy( serial->curr, sz, len );
01032     serial->curr += len;
01033 }

Here is the call graph for this function:

void char_string_swap ( char *  s1,
char *  s2,
size_t  count 
)

Exchange the contents of two character arrays.

Exchange contents of p1 and p2

Definition at line 315 of file datagen.c.

References assertptr.

00316 {
00317     assertptr(s1,count);
00318     assertptr(s2,count);
00319     {
00320         uint32* p1 = (uint32*)s1;
00321         uint32* p2 = (uint32*)s2;
00322         size_t u32count = count>>2;
00323         size_t leftover = count&3;
00324         while( u32count-- )
00325         {
00326             uint32 tmp = *p1;
00327             *p1 = *p2;
00328             *p2 = tmp;
00329             p1++;
00330             p2++;
00331         }
00332         s1 = (char*)p1;
00333         s2 = (char*)p2;
00334         while( leftover-- )
00335         {
00336             char tmp = *s1;
00337             *s1 = *s2;
00338             *s2 = tmp;
00339         }
00340     }
00341 }

bool char_xml_read_gstring ( ctl_mstring_char_grow *  str,
ctl_xmlread self,
const char *  label 
)

Read a string into fixed length C string buffer.

Parameters:
str String we're reading
self XML handler
label What this record is called
Returns:
true if the string was found

Definition at line 1599 of file xml.c.

References assertconst, assertobjptr, ctl_chsize, ctl_gstring_resize, ctl_sconst, ctl_sconst_size, ctl_xmlread_find(), ctl_xmlread_rawcontent(), and ctl_xmlread_translate_char().

01600 {
01601     assertobjptr(str);/* Inputs should be valid-looking */
01602     assertobjptr(self);
01603     assertconst( label,1 );
01604     if( ctl_xmlread_find( self, label ) )
01605     {
01606         ctl_sconst(char) body;
01607         size_t readsize;
01608         ctl_xmlread_rawcontent( self, &body, true );
01609         readsize = ctl_sconst_size(char,&body);
01610         ctl_gstring_resize(char, str, readsize );
01611         memcpy( str->begin, body.begin, ctl_chsize(char,readsize) );
01612         ctl_xmlread_translate_char( self, str->begin, str->end, true );
01613         str->end = str->begin + cstrlen(char)(str->begin);
01614         return true;
01615     }
01616     return false;
01617 }

Here is the call graph for this function:

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.

Parameters:
buff Buffer for string
size Maximum size string may be
self XML handler
label What this record is called
Returns:
true if the string was found

Definition at line 1534 of file xml.c.

References assertconst, assertobjptr, assertptr, cmemcpy, ctl_sconst, ctl_sconst_size, ctl_xmlread_find(), ctl_xmlread_rawcontent(), and ctl_xmlread_translate_char().

01535 {
01536     assertptr(buff,size*sizeof(char));/* Inputs should be valid-looking */
01537     assertobjptr( self );
01538     assertconst( label,1 );
01539     if( ctl_xmlread_find( self, label ) )
01540     {
01541         ctl_sconst(char) body;
01542         size_t readsize;
01543         ctl_xmlread_rawcontent( self, &body, true );
01544         readsize = min( ctl_sconst_size(char,&body), size );
01545         cmemcpy( char, buff, body.begin, readsize );
01546         if( readsize < size )
01547             buff[readsize] = 0;
01548         ctl_xmlread_translate_char( self, buff, buff+readsize, true );
01549         return true;
01550     }
01551     return false;
01552 }

Here is the call graph for this function:

void char_xml_write_string ( const char *  buff,
size_t  size,
ctl_xmlwrite xml,
const char *  label 
)

Write a string of unicode characters.

Parameters:
buff Buffer for string
size Maximum size string may be
xml XML handler
label What this record is called

Definition at line 1497 of file xml.c.

References assertconst, assertobjptr, ctl_xmlwrite_endtag(), ctl_xmlwrite_generaltag(), and ctl_xmlwrite_string_char().

01498 {
01499     assertconst(buff,size);/* Inputs should be valid-looking */
01500     assertobjptr( xml );
01501     assertconst( label,1 );
01502     ctl_xmlwrite_generaltag( xml, "string_char", label );
01503     ctl_xmlwrite_string_char( xml, buff, buff+size );
01504     ctl_xmlwrite_endtag( xml, "string_char", label );
01505 }

Here is the call graph for this function:

const char* ctl_record_contained_type ( const ctl_serial serial  ) 

Get a serial record's contained type.

Parameters:
serial Serial parse point
Returns:
NUL terminated string

Definition at line 342 of file record.c.

References assertobjconst, ctl_record_type(), ctl_serial_remain, and ctl_serial::end.

Referenced by char_record_read_gstring(), char_record_read_string(), ctl_record_contained_type_is(), wchar_t_record_read_gstring(), and wchar_t_record_read_string().

00343 {
00344     const char* type;
00345     assertobjconst(serial);
00346     type = ctl_record_type( serial );
00347     type += cstrnlen(char)(type,ctl_serial_remain(serial))+1;
00348     if( (uint8*)type >= serial->end )
00349         ctl_serial_except( serial, "ctl_record_contained_type: Truncated" );
00350     return type;
00351 }

Here is the call graph for this function:

bool ctl_record_contained_type_is ( const char *  label,
const ctl_serial serial 
)

See if a serial record's contained type matches an expected type.

Parameters:
label Label to check
serial Serial parse point
Returns:
true if label matches

Definition at line 360 of file record.c.

References assertconst, assertobjconst, and ctl_record_contained_type().

Referenced by ctl_record_container_validatedata().

00361 {
00362     assertconst(label,1);
00363     assertobjconst(serial);
00364     return !cstrcmp(char)(label,ctl_record_contained_type( serial ) );
00365 }

Here is the call graph for this function:

size_t ctl_record_container_validatedata ( ctl_serial serial,
const char *  type,
const char *  mbrtype 
)

Validate header against any given types, then get the data into serial and return the COUNT.

Parameters:
serial Serial parse point that will be affected
type Container type to check
mbrtype Member type to check
Returns:
Count of items stored in record header data

Definition at line 230 of file record.c.

References assertconst, assertobjptr, ctl_record_contained_type_is(), ctl_record_type_is(), ctl_serial::curr, ctl_serial::end, uint16_serial_read(), and uint32_serial_read().

00231 {
00232     assertobjptr(serial);
00233     assertconst(type,1);
00234     assertconst(mbrtype,1);
00235     if( type && !ctl_record_type_is( type, serial ) )
00236         ctl_serial_except( serial, "ctl_record_container_validatedata: Mismatched container type" );
00237     if( mbrtype && !ctl_record_contained_type_is( mbrtype, serial ) )
00238         ctl_serial_except( serial, "ctl_record_container_validatedata: Mismatched content type" );
00239     {
00240         uint8* curr = serial->curr;
00241         uint32 offset;
00242         uint16 dataoffset;
00243         uint32 count;
00244         uint32_serial_read(&offset, serial );
00245         uint16_serial_read(&dataoffset, serial );
00246         if( dataoffset > offset )
00247             ctl_serial_except( serial, "ctl_record_container_validatedata: Bad offset" );
00248         if( curr + offset > serial->end )
00249             ctl_serial_except( serial, "ctl_record_container_validatedata: Offset exceeds serial data" );
00250         serial->end = curr + offset;
00251         serial->curr = curr + dataoffset - 4;
00252         uint32_serial_read(&count, serial );
00253         return count;
00254     }
00255 }

Here is the call graph for this function:

size_t ctl_record_count ( const ctl_serial serial  ) 

Get count of items in a container.

Parameters:
serial Serial parse point
Returns:
Count of units in container

Definition at line 373 of file record.c.

References assertobjconst, ctl_serial::curr, uint16_serial_read(), and uint32_serial_read().

00374 {
00375     ctl_serial pserial;
00376     uint16 dataoffset;
00377     uint32 count;
00378     assertobjconst(serial);
00379     pserial = *serial;
00380     pserial.curr += 4;
00381     uint16_serial_read(&dataoffset, &pserial );
00382     pserial.curr = serial->curr + dataoffset - 4;
00383     uint32_serial_read(&count, &pserial );
00384     return count;
00385 }

Here is the call graph for this function:

const uint8* ctl_record_end ( const ctl_serial serial  ) 

Tell us where the next record starts.

Parameters:
serial Serial parse point
Returns:
Pointer to first byte following the current record

Definition at line 264 of file record.c.

References assertobjconst, ctl_serial::curr, ctl_serial::end, and uint32_serial_read().

00265 {
00266     uint32 offset;
00267     ctl_serial tmp;
00268     assertobjconst(serial);
00269     tmp = *serial;
00270     uint32_serial_read(&offset, &tmp );
00271     if( serial->curr + offset > serial->end )
00272         ctl_serial_except( serial, "ctl_record_next: Bad offset" );
00273     return serial->curr + offset;;
00274 }

Here is the call graph for this function:

bool ctl_record_find ( ctl_serial serial,
const char *  label 
)

Look for a record header, that might be current.

Parameters:
label Label we're scanning for
serial Serial parse point that will be affected
Returns:
true if the record was found, false (and serial pointer unmodified) if record was not

Definition at line 157 of file record.c.

References assertobjptr, ctl_record_label(), ctl_record_next(), and ctl_serial::curr.

Referenced by char_record_read_gstring(), char_record_read_string(), ctl_serial_record_read(), wchar_t_record_read_gstring(), and wchar_t_record_read_string().

00158 {
00159     ctl_serial search;
00160     assertobjptr(serial);
00161     search = *serial;
00162     do
00163     {
00164         const char *szcurr = ctl_record_label( &search );
00165         if( !cstrcmp(char)( label, szcurr ) )
00166         {
00167             serial->curr = search.curr;
00168             return true;
00169         }
00170     }
00171     while( ctl_record_next( &search ) );
00172     return false;
00173 }

Here is the call graph for this function:

bool ctl_record_find_next ( ctl_serial serial,
const char *  label 
)

Look for a record header, skipping current.

Parameters:
label Label we're scanning for
serial Serial parse point that will be affected
Returns:
true if the record was found, false (and serial pointer unmodified) if record was not

Definition at line 182 of file record.c.

References assertobjptr, ctl_record_label(), ctl_record_next(), and ctl_serial::curr.

00183 {
00184     ctl_serial search;
00185     assertobjptr(serial);
00186     search = *serial;
00187     while( ctl_record_next( &search ) )
00188     {
00189         if( !cstrcmp(char)( label, ctl_record_label( &search ) ) )
00190         {
00191             serial->curr = search.curr;
00192             return true;
00193         }
00194     }
00195     return false;
00196 }

Here is the call graph for this function:

size_t ctl_record_getdata ( ctl_serial serial  ) 

Skip over a record header to get at the data.

Parameters:
serial Serial parse point that will be affected
Returns:
Size of record data

Definition at line 204 of file record.c.

References assertobjptr, ctl_serial::curr, ctl_serial::end, uint16_serial_read(), and uint32_serial_read().

Referenced by char_record_read_gstring(), char_record_read_string(), ctl_serial_record_read(), wchar_t_record_read_gstring(), and wchar_t_record_read_string().

00205 {
00206     uint8* curr;
00207     uint32 offset;
00208     uint16 dataoffset;
00209     assertobjptr(serial);
00210     curr = serial->curr;
00211     uint32_serial_read(&offset, serial );
00212     uint16_serial_read(&dataoffset, serial );
00213     if( dataoffset > offset )
00214         ctl_serial_except( serial, "ctl_record_getdata: Bad offset" );
00215     if( curr + offset > serial->end )
00216         ctl_serial_except( serial, "ctl_record_getdata: Offset exceeds serial data" );
00217     serial->end = curr + offset;
00218     serial->curr = curr + dataoffset;
00219     return offset - dataoffset;
00220 }

Here is the call graph for this function:

size_t ctl_record_head_size ( const char *  label,
const char *  type 
)

Determine size of a record header.

Parameters:
label What to call this record
type Type of data this label contains
Returns:
Total size of the header

Definition at line 46 of file record.c.

References assertconst.

Referenced by ctl_serial_record_size().

00047 {
00048     assertconst(label,1);
00049     assertconst(type,1);
00050     return 
00051         sizeof(uint32) +                /* Record size */
00052         sizeof(uint16) +                /* Header size */
00053         cstrlen(char)( label ) + 1 +    /* NUL terminated record label string */
00054         cstrlen(char)( type ) + 1;      /* NUL terminated record type string */
00055 }

bool ctl_record_is ( const char *  label,
const ctl_serial serial 
)

See if current record header is a particular type.

Parameters:
label Label we're scanning for
serial Serial parse point that will be affected
Returns:
true if the current record matches

Definition at line 283 of file record.c.

References assertconst, assertobjconst, and ctl_record_label().

00284 {
00285     assertconst(label,1);
00286     assertobjconst(serial);
00287     return !cstrcmp(char)( label, ctl_record_label( serial ) );
00288 }

Here is the call graph for this function:

const char* ctl_record_label ( const ctl_serial serial  ) 

Get a serial record's label.

Parameters:
serial Serial parse point
Returns:
NUL terminated string

Definition at line 297 of file record.c.

References assertobjconst, ctl_serial::curr, and ctl_serial::end.

Referenced by ctl_record_find(), ctl_record_find_next(), ctl_record_is(), and ctl_record_type().

00298 {
00299     assertobjconst(serial);
00300     if( serial->curr + 7 > serial->end )
00301         ctl_serial_except( serial, "ctl_record_label: Truncated" );
00302     return (const char*)(serial->curr + 6);
00303 }

bool ctl_record_next ( ctl_serial serial  ) 

Skip to next record header.

Parameters:
serial Serial parse point that will be affected
Returns:
true if next record, false if end of data

Definition at line 137 of file record.c.

References assertobjptr, ctl_serial::curr, ctl_serial::end, and uint32_serial_read().

Referenced by ctl_record_find(), and ctl_record_find_next().

00138 {
00139     uint8* curr;
00140     uint32 offset;
00141     assertobjptr(serial);
00142     curr = serial->curr;
00143     uint32_serial_read(&offset, serial );
00144     if( curr + offset > serial->end )
00145         ctl_serial_except( serial, "ctl_record_next: Bad offset" );
00146     serial->curr = curr + offset;
00147     return serial->curr < serial->end;
00148 }

Here is the call graph for this function:

size_t ctl_record_objarray_head_size ( const char *  label,
const char *  type,
const char *  mbrtype 
)

Determine size of a record container header.

Parameters:
label What to call this record
type Type of container this label is for
mbrtype Type of data contained in the array
Returns:
Total size of the header

Definition at line 65 of file record.c.

References assertconst.

Referenced by char_record_size_gstring(), char_record_size_string(), wchar_t_record_size_gstring(), and wchar_t_record_size_string().

00066 {
00067     assertconst(label,1);
00068     assertconst(type,1);
00069     assertconst(mbrtype,1);
00070     return 
00071         sizeof(uint32) +                /* Record size */
00072         sizeof(uint16) +                /* Header size */
00073         cstrlen(char)( label ) + 1 +    /* NUL terminated record label string */
00074         cstrlen(char)( type ) + 1 +     /* NUL terminated record type string */
00075         cstrlen(char)( mbrtype ) + 1 +  /* NUL terminated record member type string */
00076         sizeof(uint32);                 /* Record count */
00077 }

const char* ctl_record_type ( const ctl_serial serial  ) 

Get a serial record's type.

Parameters:
serial Serial parse point
Returns:
NUL terminated string

Definition at line 311 of file record.c.

References assertobjconst, ctl_record_label(), ctl_serial_remain, and ctl_serial::end.

Referenced by char_record_read_gstring(), char_record_read_string(), ctl_record_contained_type(), ctl_record_type_is(), ctl_serial_record_read(), wchar_t_record_read_gstring(), and wchar_t_record_read_string().

00312 {
00313     const char* label;
00314     assertobjconst(serial);
00315     label = ctl_record_label( serial );
00316     label += cstrnlen(char)(label,ctl_serial_remain(serial))+1;
00317     if( (uint8*)label >= serial->end )
00318         ctl_serial_except( serial, "ctl_record_type: Truncated" );
00319     return label;
00320 }

Here is the call graph for this function:

bool ctl_record_type_is ( const char *  label,
const ctl_serial serial 
)

See if a serial record's type matches the given label.

Parameters:
label Label to check
serial Serial parse point
Returns:
true if label matches

Definition at line 329 of file record.c.

References assertconst, assertobjconst, and ctl_record_type().

Referenced by ctl_record_container_validatedata().

00330 {
00331     assertconst(label,1);
00332     assertobjconst(serial);
00333     return !cstrcmp(char)( label, ctl_record_type( serial ) );
00334 }

Here is the call graph for this function:

bool ctl_record_valid ( const ctl_serial serial  ) 

Look at a record and see if it's valid-looking.

Parameters:
serial Serial parse point that will be checked
Returns:
true if record looks valid

Definition at line 85 of file record.c.

References assertobjconst, ctl_serial::curr, ctl_serial::end, uint16_serial_read(), and uint32_serial_read().

00086 {
00087     uint32 size;
00088     uint16 headersize;
00089     size_t labellen;
00090     size_t typelen;
00091     ctl_serial parse;
00092     assertobjconst(serial);
00093     parse = *serial;
00094     /* We should have AT LEAST a header with one-byte label/type */
00095     if( serial->end - serial->curr < 10 )
00096         return false;
00097     uint32_serial_read(&size, &parse );
00098     /* Size should be within bounds */
00099     if( serial->curr + size > serial->end )
00100         return false;
00101     uint16_serial_read(&headersize, &parse );
00102     /* Data offset should be within bounds */
00103     if( serial->curr + headersize > serial->end )
00104         return false;
00105     /* Data offset should be smaller than size */
00106     if( headersize > size )
00107         return false;
00108     labellen = cstrnlen(char)((char*)parse.curr,headersize-6);
00109     /* Label length isn't NUL terminated, or it consumes type string space */
00110     if( labellen >= (size_t)(headersize-6) )
00111         return false;
00112     parse.curr += labellen;
00113     /* Needed to be NUL terminated */
00114     if( *parse.curr )
00115         return false;
00116     parse.curr++;
00117     typelen = cstrnlen(char)((char*)parse.curr,headersize-(6+labellen));
00118     parse.curr += labellen;
00119     /* Needed to be NUL terminated */
00120     if( *parse.curr )
00121         return false;
00122     parse.curr++;
00123     /* Should add up to the header size */
00124     if( 6 + labellen + 1 + typelen + 1 != headersize )
00125         return false;
00126 
00127     /* Didn't find any problem */
00128     return true;
00129 }

Here is the call graph for this function:

uint8 * ctl_record_write_begin ( const char *  type,
size_t  size,
ctl_serial serial,
const char *  label 
)

Write record header to be finished later.

Parameters:
label Label for record
type Type for record
size If size is known, pass it here and you don't need to ctl_record_write_end
serial Serial data to put record in
Returns:
Pointer to be passed to ctl_record_write_end, to finish length with

Definition at line 396 of file record.c.

References assert, assertconst, assertobjptr, ctl_serial::curr, uint16_serial_write(), and uint32_serial_write().

Referenced by ctl_serial_record_write().

00397 {
00398     assertobjptr(serial);
00399     assertconst(type,1);
00400     assertconst(label,1);
00401     {
00402         uint8* ret = serial->curr;
00403         size_t lenLabel = cstrlen(char)(label)+1;
00404         size_t lenType = cstrlen(char)(type)+1;
00405         uint16 offData = (uint16)(lenLabel + lenType + 6);
00406         uint32 reserve = (uint32)size + offData;
00407         /* This should fit into the reported space */
00408         assert( serial->curr + offData + size <= serial->end );
00409         uint32_serial_write(&reserve, serial );
00410         uint16_serial_write(&offData, serial );
00411         memcpy(serial->curr, label, lenLabel);
00412         serial->curr += lenLabel;
00413         memcpy(serial->curr, type, lenType);
00414         serial->curr += lenType;
00415         return ret;
00416     }
00417 }

Here is the call graph for this function:

uint8 * ctl_record_write_container_begin ( const char *  containertype,
const char *  contenttype,
size_t  size,
size_t  count,
ctl_serial serial,
const char *  label 
)

Write record header to be finished later.

Parameters:
containertype Type for container
contenttype Type for container content
size If size is known, pass it here and you don't need to ctl_record_write_end
count Count of items in container - if it's zero, you shouldn't write the container at all.
serial Serial data to put record in
label Label for record
Returns:
Pointer to be passed to ctl_record_write_end, to finish length with

Definition at line 431 of file record.c.

References assert, assertconst, assertobjptr, ctl_serial::curr, uint16_serial_write(), and uint32_serial_write().

Referenced by char_record_write_string(), and wchar_t_record_write_string().

00432 {
00433     assertobjptr(serial);
00434     assertconst(containertype,1);
00435     assertconst(contenttype,1);
00436     assertconst(label,1);
00437     {
00438         uint8* ret = serial->curr;
00439         size_t lenLabel = cstrlen(char)(label)+1;
00440         size_t lenType = cstrlen(char)(containertype)+1;
00441         size_t lenContent = cstrlen(char)(contenttype)+1;
00442         uint16 offData = (uint16)(lenLabel + lenType + lenContent + 10);
00443         uint32 reserve = (uint32)size + offData;
00444         uint32 mbrcount = (uint32)count;
00445         /* This should fit into the reported space */
00446         assert( serial->curr + offData + size <= serial->end );
00447         uint32_serial_write(&reserve, serial );
00448         uint16_serial_write(&offData, serial );
00449         memcpy(serial->curr, label, lenLabel);
00450         serial->curr += lenLabel;
00451         memcpy(serial->curr, containertype, lenType);
00452         serial->curr += lenType;
00453         memcpy(serial->curr, contenttype, lenContent);
00454         serial->curr += lenContent;
00455         uint32_serial_write(&mbrcount, serial );
00456         return ret;
00457     }
00458 }

Here is the call graph for this function:

void ctl_record_write_end ( uint8 *  begret,
ctl_serial serial 
)

Complete record begun with ctl_record_write_begin or ctl_record_write_container_begin.

Parameters:
begret Result saved from ctl_record_write_begin
serial Serial data to put record in

Definition at line 466 of file record.c.

References assertobjptr, assertptr, ctl_serial::curr, and uint32_serial_write().

00467 {
00468     assertobjptr(serial);
00469     assertptr(begret,1);
00470     {
00471         uint8* tmp = serial->curr;
00472         uint32 size = (uint32)(serial->curr - begret);
00473         serial->curr = begret;
00474         uint32_serial_write( &size, serial );
00475         serial->curr = tmp;
00476     }
00477 }

Here is the call graph for this function:

size_t ctl_serial_calc_size ( const ctl_serial serial  ) 

Work out how many bytes serial will consume if written as serial.

Parameters:
serial ctl_serial to measure
Size of serial data with length encoded

Definition at line 240 of file serial.c.

References assertobjconst, ctl_serial_size_size_size, and ctl_serial_total.

00241 {
00242     assertobjconst(serial);
00243     return ctl_serial_size_size_size( ctl_serial_total( serial ) );
00244 }

void ctl_serial_copy ( ctl_serial dst,
const ctl_serial src 
)

Duplicate serial data. If src is a reference, dst will be a reference. If src is allocated, dst will be allocated.

Parameters:
dst Instance to initialize
src Instance to copy from

Definition at line 148 of file serial.c.

References assertobjconst, assertobjptr, ctl_serial::begin, ctl_serial::buff, ctl_serial_alloc, ctl_serial_total, and ctl_serial::curr.

00149 {
00150     assertobjptr(dst);
00151     assertobjconst(src);
00152     if( src->buff )
00153     {
00154         size_t size = ctl_serial_total( src );
00155         ctl_serial_alloc( dst, size );
00156         memcpy( dst->buff, src->begin, size );
00157         dst->curr = (uint8*)dst->begin + (src->curr-src->begin);
00158     }
00159     else
00160     {
00161         *dst = *src;
00162         dst->buff = NULL;
00163     }
00164 }

void ctl_serial_deref ( ctl_serial serial  ) 

Turn a reference to serial data into buffered serial.

Parameters:
serial Instance to modify

Definition at line 171 of file serial.c.

References assertobjptr, ctl_serial::begin, ctl_serial::buff, ctl_serial_alloc, ctl_serial_total, and ctl_serial::curr.

00172 {
00173     assertobjptr(serial);
00174     if( NULL == serial->buff )
00175     {   /* Only operate if not already a reference */
00176         ctl_serial tmp = *serial;
00177         size_t size = ctl_serial_total( &tmp );
00178         ctl_serial_alloc( serial, size );
00179         memcpy( serial->buff, tmp.begin, size );
00180         serial->curr = (uint8*)serial->begin + (tmp.curr-tmp.begin);
00181     }
00182 }

bool ctl_serial_peek_serial ( ctl_serial dst,
const ctl_serial src 
)

Just like ctl_serial_refserial, except src->curr doesn't get modified.

Parameters:
dst serial that gets initialized referencing src
src serial that has its data copied referenced (must not be discarded before 'dst' is finished with it)

Definition at line 289 of file serial.c.

References assertobjconst, assertobjptr, ctl_serial::begin, ctl_serial_peeksize(), ctl_serial_size_size, ctl_serial::curr, and ctl_serial::end.

00290 {
00291     assertobjptr(dst);
00292     assertobjconst(src);
00293     {
00294         size_t total = ctl_serial_peeksize( src );
00295         dst->begin = dst->curr = (uint8*)src->curr + ctl_serial_size_size( total );
00296         dst->end = dst->begin + total;
00297         return 0 != total;
00298     }
00299 }

Here is the call graph for this function:

size_t ctl_serial_peeksize ( const ctl_serial serial  ) 

Read a size from stream without modifying parse point.

Parameters:
serial Serial parser
Returns:
Size encoded in stream

Definition at line 207 of file serial.c.

References assertobjconst, and uint16_serial_peek().

Referenced by char_serial_peek_sconst(), char_serial_read_fstring(), char_serial_read_gstring(), ctl_serial_peek_serial(), wchar_t_serial_peek_sconst(), wchar_t_serial_read_fstring(), and wchar_t_serial_read_gstring().

00208 {
00209     uint16 wsize = 0;
00210     assertobjconst(serial);
00211     uint16_serial_peek( &wsize, serial );
00212     return wsize;
00213 }

Here is the call graph for this function:

bool ctl_serial_read_serial ( ctl_serial dst,
ctl_serial src 
)

Read serial to initialize serial.

Parameters:
dst serial that gets initialized referencing src
src serial that has its data copied referenced (must not be discarded before 'dst' is finished with it)

Definition at line 270 of file serial.c.

References assertobjptr, ctl_serial::begin, ctl_serial_readsize(), ctl_serial::curr, and ctl_serial::end.

00271 {
00272     assertobjptr(dst);
00273     assertobjptr(src);
00274     {
00275         size_t total = ctl_serial_readsize( src );
00276         dst->begin = dst->curr = (uint8*)src->curr;
00277         dst->end = dst->begin + total;
00278         src->curr += total;
00279         return 0 != total;
00280     }
00281 }

Here is the call graph for this function:

size_t ctl_serial_readsize ( ctl_serial serial  ) 

Read a size from stream, validate it against remainder.

Parameters:
serial Serial parser
Returns:
Size encoded in stream

Definition at line 221 of file serial.c.

References assertobjptr, ctl_serial::curr, ctl_serial::end, and uint16_serial_read().

Referenced by char_serial_read_sconst(), char_serial_read_string(), ctl_serial_read_serial(), uint16_serial_readarray(), uint32_serial_readarray(), uint64_serial_readarray(), uint8_serial_readarray(), wchar_t_serial_read_sconst(), and wchar_t_serial_read_string().

00222 {
00223     uint16 wsize = 0;
00224     assertobjptr(serial);
00225     uint16_serial_read( &wsize, serial );
00226     if( serial->curr + wsize > serial->end )
00227     {
00228         ctl_serial_except( serial, "Bound check failure getting size" );
00229         return 0;
00230     }
00231     return wsize;
00232 }

Here is the call graph for this function:

bool ctl_serial_record_read ( ctl_serial to,
ctl_serial from,
const char *  label 
)

Read raw serial data from stream.

Parameters:
to Serial data to read to
from Stream to read from
label Name of data

Definition at line 525 of file record.c.

References assertconst, assertobjptr, ctl_record_find(), ctl_record_getdata(), ctl_record_type(), ctl_serial_init, ctl_serial::curr, and ctl_serial::end.

00526 {
00527     ctl_serial tmp;
00528     assertobjptr(from);
00529     assertobjptr(to);
00530     assertconst(label,1);
00531     tmp = *from;
00532     if( ctl_record_find( &tmp, label ) )
00533     {
00534         const char* szcontainer = ctl_record_type( &tmp );
00535         if( cstrcmp(char)(szcontainer,"raw") )
00536             ctl_serial_except( from, "ctl_serial_record_read: Not raw data" );
00537         ctl_record_getdata( &tmp );
00538         ctl_serial_init( to, tmp.curr, tmp.end );
00539         return true;
00540     }
00541     return false;
00542 }

Here is the call graph for this function:

size_t ctl_serial_record_size ( const ctl_serial serial,
const char *  label 
)

Calculate how many bytes it will take to store a raw serial reference.

Parameters:
serial Serial data to measure
label Name of data

Definition at line 485 of file record.c.

References assertconst, assertobjconst, ctl_record_head_size(), and ctl_serial_total.

00486 {
00487     size_t size;
00488     assertconst(label,1);
00489     assertobjconst(serial);
00490     size = ctl_serial_total( serial );
00491     if( 0 == size )
00492         return 0;
00493     size += ctl_record_head_size( label, "raw" );
00494     return size;
00495 }

Here is the call graph for this function:

void ctl_serial_record_write ( const ctl_serial from,
ctl_serial to,
const char *  label 
)

Write raw serial data to stream.

Parameters:
from Serial data to write
to Stream to write to
label Name of data

Definition at line 503 of file record.c.

References assertconst, assertobjconst, assertobjptr, ctl_serial::begin, ctl_record_write_begin(), ctl_serial_total, and ctl_serial::curr.

00504 {
00505     size_t total;
00506     assertobjconst(from);
00507     assertobjptr(to);
00508     assertconst(label,1);
00509     total = ctl_serial_total( from );
00510     if( 0 != total )
00511     {
00512         size_t total = ctl_serial_total( from );
00513         ctl_record_write_begin( "raw", total, to, label );
00514         memcpy( to->curr, from->begin, total );
00515         to->curr += total;
00516     }
00517 }

Here is the call graph for this function:

ctl_serial_exception ctl_serial_setexception ( ctl_serial_exception  except  ) 

Set an exception handler for serial exceptions.

Parameters:
except Function to get called when ctl_serial has a problem
Returns:
Previous exception function

Definition at line 67 of file serial.c.

References assertcodeptr.

00068 {
00069     ctl_serial_exception ctl_serial_except_prev = ctl_serial_except;
00070     ctl_serial_except = NULL == except ? def_serial_exception : except;
00071     assertcodeptr(ctl_serial_except);
00072     return ctl_serial_except_prev;
00073 }

void ctl_serial_write_serial ( ctl_serial dst,
const ctl_serial src 
)

Write serial to serial.

Parameters:
dst serial that gets data written to it
src serial that gets data copied from it

Definition at line 252 of file serial.c.

References assertobjconst, assertobjptr, ctl_serial::begin, ctl_serial_total, ctl_serial_writesize(), and ctl_serial::curr.

00253 {
00254     assertobjptr(dst);
00255     assertobjconst(src);
00256     {
00257         size_t total = ctl_serial_total( src );
00258         ctl_serial_writesize( total, dst );
00259         memcpy( dst->curr, src->begin, total );
00260         dst->curr += total;
00261     }
00262 }

Here is the call graph for this function:

void ctl_serial_writesize ( size_t  size,
ctl_serial serial 
)

Write a size into stream.

Parameters:
size Size we are recording
serial Serial parser

Definition at line 191 of file serial.c.

References assert, assertobjptr, ctl_serial_size_size_size, ctl_serial::curr, ctl_serial::end, and uint16_serial_write().

Referenced by char_serial_write_string(), ctl_serial_write_serial(), uint16_serial_writearray(), uint32_serial_writearray(), uint64_serial_writearray(), uint8_serial_writearray(), and wchar_t_serial_write_string().

00192 {
00193     /* There SHOULD have been enough pre-allocated */
00194     uint16 wsize = (uint16)size;
00195     assertobjptr(serial);
00196     assert( size < 65536 );
00197     assert( serial->curr + ctl_serial_size_size_size( size ) <= serial->end );
00198     uint16_serial_write( &wsize, serial );
00199 }

Here is the call graph for this function:

bool ctl_xmlread_canrecurse ( ctl_xmlread self  ) 

Tell us if this block contains more blocks.

Parameters:
self ctl_xmlread we're operating on
Returns:
true if there are more inside this

Definition at line 1076 of file xml.c.

References assertobjptr.

01077 {
01078     assertobjptr(self);
01079     return self->bRecursible;
01080 }

bool ctl_xmlread_find ( ctl_xmlread self,
const char *  type 
)

Search this block for a particular kind of tag.

Parameters:
self ctl_xmlread we're operating on
type string to match block against
Returns:
true if we found a block of that type, and seek is set to that block, false (and seek unchanged) if we did not.

Definition at line 1029 of file xml.c.

References assertconst, assertobjptr, ctl_xmlread_findnext(), ctl_xmlread_is(), and ctl_xmlread_rewind().

Referenced by char_xml_read_gstring(), char_xml_read_string(), raw_xml_readbytes(), wchar_t_xml_read_gstring(), and wchar_t_xml_read_string().

01030 {
01031     assertobjptr(self);
01032     assertconst(type,1);
01033     ctl_xmlread_rewind(self);
01034     if( ctl_xmlread_is( self, type ) )
01035         return true;
01036     return ctl_xmlread_findnext( self,type );
01037 }

Here is the call graph for this function:

bool ctl_xmlread_findnext ( ctl_xmlread self,
const char *  type 
)

Search this block for a particular kind of tag, starting after current one.

Parameters:
self ctl_xmlread we're operating on
type string to match block against
Returns:
true if we found a block of that type, and seek is set to that block, false (and seek unchanged) if we did not.

Definition at line 1046 of file xml.c.

References assertconst, assertobjptr, ctl_xmlread_is(), and ctl_xmlread_next().

Referenced by ctl_xmlread_find().

01047 {
01048     /* Backup current state */
01049     const char* bszpCurr     = self->szpCurr;
01050     const char* bszpEnd      = self->szpEnd;
01051     const char* bszcCurr     = self->szcCurr;
01052     const char* bszcEnd      = self->szcEnd;
01053     bool        bbRecursible = self->bRecursible;
01054     assertobjptr(self);
01055     assertconst(type,1);
01056     while ( ctl_xmlread_next(self) )
01057     {
01058         if( ctl_xmlread_is( self, type ) )
01059             return true;
01060     }
01061     /* Restore to backup state */
01062     self->szpCurr = bszpCurr;
01063     self->szpEnd = bszpEnd;
01064     self->szcCurr = bszcCurr;
01065     self->szcEnd = bszcEnd;
01066     self->bRecursible = bbRecursible;
01067     return false;
01068 }

Here is the call graph for this function:

bool ctl_xmlread_getattribute ( ctl_xmlread self,
ctl_mstring_char_grow *  str,
const char *  label 
)

Get an attribute.

<blah attrib="something&amp;" > ... </blah> 
returns something&, if str is "attrib"
Parameters:
self ctl_xmlread we're examining
str String receive the data
label Label of the attrib we're getting
Returns:
true if we match, false if we didn't

Definition at line 1151 of file xml.c.

References assertconst, assertobjptr, ctl_gstring_reset, ctl_sconst, ctl_xmlread_rawattribute(), and ctl_xmlread_string().

01152 {
01153     assertobjptr(self);
01154     assertobjptr( str );
01155     assertconst( label,1 );
01156     {
01157         ctl_sconst( char ) raw;
01158         ctl_gstring_reset(char, str );
01159         if( ctl_xmlread_rawattribute( self, &raw, label ) )
01160             return 0 != ctl_xmlread_string( self, str, raw.begin, raw.end, true );;
01161         return false;
01162     }
01163 }

Here is the call graph for this function:

bool ctl_xmlread_getattribute_int ( ctl_xmlread self,
const char *  label,
int32 *  value 
)

Get an attribute known to be an integer of some sort.

Parameters:
self ctl_xmlread we're examining
label Name of attribute
value Pointer to value to read
Returns:
true if we copied content

Definition at line 1336 of file xml.c.

References ctl_sconst, ctl_sconst_getint32, and ctl_xmlread_rawattribute().

Referenced by raw_xml_readbytes().

01337 {
01338     ctl_sconst( char ) tmp;
01339     if( ctl_xmlread_rawattribute( self, &tmp, label ) )
01340         return ctl_sconst_getint32(char, &tmp, value );
01341     return false;
01342 }

Here is the call graph for this function:

bool ctl_xmlread_getcontent ( const ctl_xmlread self,
ctl_mstring_char_grow *  str,
bool  eatWhite 
)

Get the content;.

<blah> &quot;CONTENT&quot; </blah> 
returns "CONTENT"
Parameters:
self ctl_xmlread we're examining
str String receive the data
eatWhite If true, we want leading/trailing white space removed
Returns:
true if we copied content

Definition at line 1173 of file xml.c.

References assertobjconst, assertobjptr, ctl_gstring_reset, and ctl_xmlread_string().

01174 {
01175     assertobjconst(self);
01176     assertobjptr( str );
01177     {
01178         const char* p = self->szcCurr;
01179         ctl_gstring_reset(char, str );
01180         return 0 != ctl_xmlread_string( self, str, p, self->szcEnd, eatWhite );
01181     }
01182 }

Here is the call graph for this function:

bool ctl_xmlread_getname ( const ctl_xmlread self,
ctl_mstring_char_grow *  str 
)

Get the name of the current tag.

<blah> ... </blah> 
Parameters:
self ctl_xmlread we're examining
str Substring to receive the name begin/end
Returns:
true if we were on a valid block to return the name of

Definition at line 1107 of file xml.c.

References assertobjconst, assertobjptr, chconst, ctl_gstring_add, and ctl_gstring_reset.

01108 {
01109     assertobjconst(self);
01110     assertobjptr( str );
01111     {
01112         const char* p = self->szpCurr+1;
01113         ctl_gstring_reset(char, str );
01114         while ( *p != chconst(char,'>') && (*p != chconst(char,'/') || p[1] != chconst(char,'>')) && !cisspace(char)(*p) )
01115             ctl_gstring_add(char, str, *p++ );
01116         return true;
01117     }
01118 }

bool ctl_xmlread_gettextafter ( const ctl_xmlread self,
ctl_mstring_char_grow *  str,
bool  eatWhite 
)

Get text after the current block;.

<blah> ... </blah> something else <ni /> 
returns something else
Parameters:
self ctl_xmlread we're examining
str String receive the data
eatWhite If true, we want leading/trailing white space removed
Returns:
true if we copied content

Definition at line 1216 of file xml.c.

References assertobjconst, assertobjptr, ctl_gstring_reset, and ctl_xmlread_string().

01217 {
01218     assertobjconst(self);
01219     assertobjptr( str );
01220     {
01221         const char* p = self->szpEnd;
01222         const char* p2 = FindLT(p, self->szEnd);
01223         ctl_gstring_reset(char, str );
01224         if ( p2 )
01225             return 0 != ctl_xmlread_string( self, str, p, p2, eatWhite );
01226     }
01227     return false;
01228 }

Here is the call graph for this function:

bool ctl_xmlread_gettextbefore ( const ctl_xmlread self,
ctl_mstring_char_grow *  str,
bool  eatWhite 
)

Get text before the current block;.

<ni /> something  <blah> ... </blah> 
returns something
Parameters:
self ctl_xmlread we're examining
str String receive the data
eatWhite If true, we want leading/trailing white space removed
Returns:
true if we copied content

Definition at line 1192 of file xml.c.

References assertobjconst, assertobjptr, chconst, ctl_gstring_reset, and ctl_xmlread_string().

01193 {
01194     assertobjconst(self);
01195     assertobjptr( str );
01196     {
01197         const char* pBegin = self->szpCurr-1;
01198         const char* pEnd = pBegin;
01199         ctl_gstring_reset(char, str );
01200         while ( pBegin > self->szBegin && *pBegin != chconst(char,'>') )
01201             pBegin--;
01202         if ( pBegin++ > self->szBegin )
01203             return 0 != ctl_xmlread_string( self, str, pBegin, pEnd, eatWhite );
01204     }
01205     return false;
01206 }

Here is the call graph for this function:

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.

Parameters:
self ctl_xmlread we're operating on
begin Beginning of string
end End of string
except Exception handler for problems in the script
exceptParam Parameter for exception handler
Returns:
true if string contains valid-looking XML data

Definition at line 868 of file xml.c.

References assert, assertcodeptr, assertconst, assertobjptr, chconst, ctl_xmlread_next(), and szconst.

Referenced by ctl_xmlread_recurse(), and ctl_xmlread_rewind().

00869 {
00870     assertobjptr(self);
00871     assertconst( begin,1 );
00872     assertconst( end,1 );
00873     assert( end >= begin );
00874     self->szBegin = begin;
00875     self->szEnd = end;
00876     self->szpCurr = self->szBegin;
00877     self->szpEnd = self->szBegin;
00878     self->szcCurr = self->szBegin;
00879     self->szcEnd = self->szEnd;
00880     self->bRecursible = false;
00881     self->except = except ? except : DefaultXMLException;
00882     assertcodeptr(self->except);
00883     self->exceptParam = exceptParam;
00884 
00885     {
00886         const char* found = FindLT( self->szBegin, self->szEnd );
00887         if ( found && !cstrncmp(char)( found+1, szconst(char,"?xml"), 4 ) )
00888         {
00889             self->szBegin = self->szpCurr = found;
00890             self->szpEnd = FindGT( self->szpCurr+5, self->szEnd );
00891             if ( self->szpEnd && *(self->szpEnd-1) != chconst(char,'?') )
00892             {
00893                 self->except( self, szconst(char,"Bad XML: '<?xml' does not end with '?>'"), self->szpCurr, self->szpEnd );
00894                 return false;
00895             }
00896             self->szcCurr = self->szpEnd = self->szpCurr = self->szBegin = SkipSpace(self->szpEnd+1,self->szEnd);
00897         }
00898     }
00899     return ctl_xmlread_next( self );
00900 }

Here is the call graph for this function:

bool ctl_xmlread_is ( const ctl_xmlread self,
const char *  str 
)

See if the name of the current tag matches a NUL terminated string.

Parameters:
self ctl_xmlread we're examining
str String to check against
Returns:
true if we match, false if we didn't

Definition at line 1127 of file xml.c.

References assertconst, assertobjconst, and chconst.

Referenced by ctl_xmlread_find(), and ctl_xmlread_findnext().

01128 {
01129     assertobjconst(self);
01130     assertconst( str, 1 );
01131     {
01132         const char* pStr = str;
01133         const char* p = self->szpCurr+1;
01134         while ( *p != chconst(char,'>') && (*p != chconst(char,'/') || p[1] != chconst(char,'>')) && !cisspace(char)(*p) )
01135             if ( *p++ != *pStr++ )
01136                 return false;
01137         return !*pStr;
01138     }
01139 }

bool ctl_xmlread_next ( ctl_xmlread self  ) 

Set XML read point to next block.

Parameters:
self ctl_xmlread we're operating on
Returns:
true if there is a next, false if there was not

Definition at line 922 of file xml.c.

References assertobjptr, chconst, and szconst.

Referenced by ctl_xmlread_findnext(), and ctl_xmlread_init().

00923 {
00924     assertobjptr(self);
00925     self->szpCurr = FindLT( self->szpEnd, self->szEnd );
00926     /* Eat the whole set of warts that begin with an '!'*/
00927     while ( self->szpCurr && self->szpCurr[1] == chconst(char,'!') )
00928     {
00929         /* If we encounter <![CDATA[ ... ]]>, skip it*/
00930         if ( !cstrncmp(char)( self->szpCurr, szconst(char,"<![CDATA["), 9 ) )
00931         {
00932             const char* szGT = cstrstr(char)(self->szpCurr+9, szconst(char,"]]>"));
00933             if ( szGT && szGT < self->szEnd )
00934             {
00935                 /* Look for next thing*/
00936                 self->szpCurr = FindLT( szGT+3, self->szEnd );
00937             }
00938             else
00939             {
00940                 self->except( self, szconst(char,"Bad XML: <![CDATA[ doesn't have a ']]>'"), self->szpCurr, NULL );
00941                 return false;
00942             }
00943         }
00944         else if ( !cstrncmp(char)( self->szpCurr, szconst(char,"<!--"), 4 ) )
00945         {
00946             const char* pGT = cstrstr(char)(self->szpCurr+4, szconst(char,"-->"));
00947             if ( pGT && pGT < self->szEnd )
00948             {
00949                 self->szpCurr = FindLT( pGT+3, self->szEnd );
00950                 continue;
00951             }
00952             else
00953             {
00954                 self->except( self, szconst(char,"Bad XML: '<!--' comment doesn't have a '-->'"), self->szpCurr, pGT );
00955                 return false;
00956             }
00957         }
00958         else
00959         {
00960             const char* szGT = FindGT( self->szpCurr+1, self->szEnd );
00961             if ( szGT )
00962             {
00963                 /* Look for next thing*/
00964                 self->szpCurr = FindLT( szGT+1, self->szEnd );
00965             }
00966             else
00967             {
00968                 self->except( self, szconst(char,"Bad XML: <! data doesn't have a '>'"), self->szpCurr, szGT );
00969                 return false;
00970             }
00971         }
00972     }
00973     if ( self->szpCurr )
00974     {
00975         /* Found a tag.*/
00976         self->szcCurr = FindGT(self->szpCurr+1, self->szEnd);
00977         if ( self->szcCurr )
00978         {
00979             /* See if it's an empty element tag <data stuff="stuff" />*/
00980             if ( *(self->szcCurr - 1) == chconst(char,'/') )
00981             {
00982                 self->szcCurr++;
00983                 self->szcEnd = self->szpEnd = self->szcCurr;
00984                 self->bRecursible = false;
00985                 return true;
00986             }
00987             else
00988             {
00989                 self->szcCurr++;
00990                 self->bRecursible = false;
00991                 self->szcEnd = MatchTag( self, self->szpCurr );
00992                 if ( self->szcEnd )
00993                 {
00994                     self->szpEnd = FindGT(self->szcEnd+1, self->szEnd);
00995                     if ( self->szpEnd )
00996                     {
00997                         self->szpEnd++;
00998                         return true;
00999                     }
01000                     else
01001                     {
01002                         self->except( self, szconst(char,"Bad XML: </tag> doesn't have a '>'"), self->szcCurr, self->szcEnd );
01003                         return false;
01004                     }
01005                 }
01006                 else
01007                 {
01008                     self->except( self, szconst(char,"Bad XML: Tag doesn't end with '</tag>', or same </tag>"), self->szcCurr, NULL );
01009                     return false;
01010                 }
01011             }
01012         }
01013         else
01014         {
01015             self->except( self, szconst(char,"Bad XML: Tag doesn't end with '>'"), self->szpCurr, NULL );
01016             return false;
01017         }
01018     }
01019     return false;
01020 }

bool ctl_xmlread_rawattribute ( ctl_xmlread self,
ctl_sconst_char *  str,
const char *  label 
)

Get an attribute.

<blah attrib="something&amp;" > ... </blah> returns something&amp;
, if str is "attrib"
Parameters:
self ctl_xmlread we're examining
str String receive the data
label Label of the attrib we're getting
Returns:
true if we match, false if we didn't

Definition at line 1260 of file xml.c.

References assertconst, assertobjptr, chconst, and szconst.

Referenced by ctl_xmlread_getattribute(), and ctl_xmlread_getattribute_int().

01261 {
01262     assertobjptr(self);
01263     assertobjptr( str );
01264     assertconst( label,1 );
01265     {
01266         /* Skip over tag*/
01267         const char* p = self->szpCurr+1;
01268         const char* tagEnd = self->szcCurr-1;
01269         p = SkipSpace(p,tagEnd);
01270         if ( *p == chconst(char,'>') )
01271             return false;
01272         while ( p < tagEnd )
01273         {
01274             /* At first attribute*/
01275             p = FindSpace(p,tagEnd);
01276             p = SkipSpace(p,tagEnd);
01277             if ( *p == chconst(char,'>') )
01278                 return false;
01279             if ( !cstrncmp(char)(p,label,cstrlen(char)(label)) )
01280             {
01281                 const char* end;
01282                 /* Found the label, so now find '='*/
01283                 p = FindChar( p, tagEnd, chconst(char,'=') );
01284                 if ( NULL == p )
01285                 {
01286                     self->except( self, szconst(char,"Bad XML: Expected an '=' in an attribute."), self->szpCurr, p );
01287                     return false;
01288                 }
01289 
01290                 
01291                 /* Found the '=', so now find quote*/
01292                 p++;
01293                 p = SkipSpace(p,tagEnd);
01294                 end = MatchQuote( self, p, tagEnd );
01295                 if( NULL == end )
01296                 {
01297                     return false;
01298                 }
01299                 p++;
01300                 /* And we got the string*/
01301                 str->begin = str->parse = p;
01302                 str->end = end;
01303                 return true;
01304             }
01305             else
01306             {
01307                 /* Found a label, so now find '='*/
01308                 p = FindChar( p, tagEnd, chconst(char,'=') );
01309                 if ( NULL == p )
01310                 {
01311                     self->except( self, szconst(char,"Bad XML: Expected an '=' in an attribute."), self->szpCurr, p );
01312                     return false;
01313                 }
01314                 /* Found the '=', so now find quote*/
01315                 p++;
01316                 p = SkipSpace(p,tagEnd);
01317                 p = MatchQuote( self, p, tagEnd ) + 1;
01318                 if( NULL == p )
01319                 {
01320                     return false;
01321                 }
01322             }
01323         }
01324     }
01325     return false;
01326 }

bool ctl_xmlread_rawcontent ( const ctl_xmlread self,
ctl_sconst_char *  str,
bool  eatWhite 
)

Get the content;.

<blah> &quot;CONTENT&quot; </blah> returns &quot;CONTENT&quot;
Parameters:
self ctl_xmlread we're examining
str String receive the data
eatWhite If true, we want leading/trailing white space removed
Returns:
true if we copied content

Definition at line 1353 of file xml.c.

References assertobjconst, and assertobjptr.

Referenced by char_xml_read_gstring(), char_xml_read_string(), raw_xml_readbytes(), wchar_t_xml_read_gstring(), and wchar_t_xml_read_string().

01354 {
01355     assertobjconst(self);
01356     assertobjptr( str );
01357     str->begin = str->parse = self->szcCurr;
01358     str->end = self->szcEnd;
01359     return str->end > str->begin;
01360 }

bool ctl_xmlread_rawname ( const ctl_xmlread self,
ctl_sconst_char *  str 
)

Get the name of the current tag.

<blah> ... </blah> 
Parameters:
self ctl_xmlread we're examining
str Substring to receive the name begin/end
Returns:
true if we were on a valid block to return the name of

Definition at line 1239 of file xml.c.

References assertobjconst, assertobjptr, and chconst.

01240 {
01241     assertobjconst(self);
01242     assertobjptr( str );
01243     {
01244         const char* p = str->begin = str->parse = self->szpCurr+1;
01245         while ( *p != chconst(char,'>') && (*p != chconst(char,'/') || p[1] != chconst(char,'>')) && !cisspace(char)(*p) )
01246             p++;
01247         str->end = p;
01248         return true;
01249     }
01250 }

bool ctl_xmlread_rawtextafter ( const ctl_xmlread self,
ctl_sconst_char *  str,
bool  eatWhite 
)

Get text after the current block;.

<blah> ... </blah> something else <ni /> 
returns something else
Parameters:
self ctl_xmlread we're examining
str String receive the data
eatWhite If true, we want leading/trailing white space removed
Returns:
true if we copied content

Definition at line 1397 of file xml.c.

References assertobjconst, and assertobjptr.

01398 {
01399     assertobjconst(self);
01400     assertobjptr( str );
01401     str->begin = str->parse = self->szpEnd;
01402     str->end = FindLT(str->begin, self->szEnd);
01403     return str->end > str->begin;
01404 }

bool ctl_xmlread_rawtextbefore ( const ctl_xmlread self,
ctl_sconst_char *  str,
bool  eatWhite 
)

Get text after the current block;.

<blah> ... </blah> something else <ni /> 
returns something else
Parameters:
self ctl_xmlread we're examining
str String receive the data
eatWhite If true, we want leading/trailing white space removed
Returns:
true if we copied content

Definition at line 1370 of file xml.c.

References assertobjconst, assertobjptr, and chconst.

01371 {
01372     assertobjconst(self);
01373     assertobjptr( str );
01374     {
01375         const char* pBegin = self->szpCurr-1;
01376         const char* pEnd = pBegin;
01377         while ( pBegin > self->szBegin && *pBegin != chconst(char,'>') )
01378             pBegin--;
01379         if ( pBegin++ > self->szBegin )
01380         {
01381             str->begin = str->parse = pBegin;
01382             str->end = pEnd;
01383             return str->end > str->begin;
01384         }
01385     }
01386     return false;
01387 }

bool ctl_xmlread_recurse ( ctl_xmlread newself,
const ctl_xmlread self 
)

Initialize a new XML parser to parse inside the current block.

Parameters:
newself ctl_xmlread we're making
self ctl_xmlread we're recursing into
Returns:
true if this block has valid-looking XML data

Definition at line 1089 of file xml.c.

References assertobjconst, assertobjptr, and ctl_xmlread_init().

01090 {
01091     assertobjconst(self);
01092     assertobjptr( newself );
01093     if( self->bRecursible )
01094         return ctl_xmlread_init( newself, self->szcCurr, self->szcEnd, self->except, self->exceptParam );
01095     return false;
01096 }

Here is the call graph for this function:

void ctl_xmlread_rewind ( ctl_xmlread self  ) 

Set XML read point to beginning.

Parameters:
self ctl_xmlread we're operating on
Returns:
true if string contains valid-looking XML data

Definition at line 910 of file xml.c.

References assertobjptr, and ctl_xmlread_init().

Referenced by ctl_xmlread_find().

00911 {
00912     assertobjptr(self);
00913     ctl_xmlread_init( self, self->szBegin, self->szEnd, self->except, self->exceptParam );
00914 }

Here is the call graph for this function:

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.

Parameters:
self xml reader to pass exceptions to
begin Start of text to translate
end End of text to translate
bEatWhite true if you want white space eaten off start/end of text

Definition at line 561 of file xml.c.

References assert, assertobjconst, assertptr, chconst, and szconst.

Referenced by char_xml_read_gstring(), char_xml_read_string(), and ctl_xmlread_string().

00562 {
00563     assertobjconst(self);
00564     assertptr( begin,end-begin );
00565     assert( end >= begin );
00566     {
00567         const char* text = begin;
00568         char* outtext = begin;
00569         /* Gnaw off leading spaces (note: not good for mixed/embedded text)*/
00570         if ( bEatWhite )
00571         {
00572             while( cisspace(char)(*text) )
00573                 text++;
00574         }
00575         while ( text < end )
00576         {
00577             if ( text[0] == chconst(char,'&') )
00578             {
00579                 if ( text[1] == chconst(char,'#') )
00580                 {
00581                     char *p;
00582                     char ret;
00583                     if ( text[2] == chconst(char,'x') )
00584                         ret = (char)cstrtol(char)(text+3,&p,16);
00585                     else
00586                         ret = (char)cstrtol(char)(text+2,&p,10);
00587                     if ( *p++ != chconst(char,';') )
00588                     {
00589                         self->except( self,szconst(char,"Bad XML: Bad character Reference"), begin, text );
00590                         return NULL;
00591                     }
00592                     text = p;
00593                     *outtext++ = ret;
00594                 }
00595                 else
00596                 {
00597                     /* Get label*/
00598                     text++;
00599                     /* Next parse point after ';'*/
00600                     if( !cstrncmp(char)(text,szconst(char,"amp;"),4) )
00601                     {
00602                         *outtext++ = chconst(char,'&');
00603                         text += 4;
00604                     }
00605                     else if( !cstrncmp(char)(text,szconst(char,"apos;"),5) )
00606                     {
00607                         *outtext++ = chconst(char,'\'');
00608                         text += 5;
00609                     }
00610                     else if( !cstrncmp(char)(text,szconst(char,"lt;"),3) )
00611                     {
00612                         *outtext++ = chconst(char,'<');
00613                         text += 3;
00614                     }
00615                     else if( !cstrncmp(char)(text,szconst(char,"gt;"),3) )
00616                     {
00617                         *outtext++ = chconst(char,'>');
00618                         text += 3;
00619                     }
00620                     else if( !cstrncmp(char)(text,szconst(char,"quot;"),5) )
00621                     {
00622                         *outtext++ = chconst(char,'\"');
00623                         text += 5;
00624                     }
00625                     else
00626                     {
00627                         self->except( self,szconst(char,"Bad XML: Unknown entity reference"), begin, text );
00628                         return NULL;
00629                     }
00630                 }
00631             }
00632             else if ( text[0] == chconst(char,'<') )
00633             {
00634                 /* Handle CDATA*/
00635                 if ( !cstrncmp(char)( text, szconst(char,"<![CDATA["), 9 ) )
00636                 {
00637                     const char* szGT = cstrstr(char)(text+9, szconst(char,"]]>"));
00638                     if ( szGT && szGT < end )
00639                     {
00640                         /* + "<![CDATA["*/
00641                         text += 9;
00642                         if ( bEatWhite )
00643                         {
00644                             text=SkipSpace(text,szGT);
00645                         }
00646                         while ( text < szGT )
00647                         {
00648                             *outtext++ = *text++;
00649                         }
00650                         /* + "]]>"*/
00651                         text += 3;
00652                     }
00653                     else
00654                     {
00655                         self->except( self,szconst(char,"Bad XML: <![CDATA[ doesn't have a ']]>'"), text, NULL );
00656                         return NULL;
00657                     }
00658                 }
00659                 else
00660                 {
00661                     /* If we encounter embedded tags (and comments) in the body text we're reading, skip over it recursively.*/
00662                     int count = 0;
00663                     text++;
00664                     while ( text < end )
00665                     {
00666                         if ( *text == chconst(char,'<') )
00667                             count++;
00668                         else if ( *text == chconst(char,'>') && !count-- )
00669                         {
00670                             text++;
00671                             break;
00672                         }
00673                         text++;
00674                     }
00675                 }
00676             }
00677             else
00678             {
00679                 *outtext++ = *text++;
00680             }
00681         }
00682         /* Chew off trailing spaces */
00683         if ( bEatWhite )
00684         {
00685             while( outtext > begin && cisspace(char)(*(outtext-1)) )
00686                 outtext--;
00687         }
00688         /* NUL terminate, where possible */
00689         if( outtext < end )
00690             *outtext = 0;
00691         return outtext;
00692     }
00693 }

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.

Parameters:
self xml reader to pass exceptions to
begin Start of text to translate
end End of text to translate
bEatWhite true if you want white space eaten off start/end of text

Definition at line 703 of file xml.c.

References assert, assertobjconst, assertptr, chconst, and szconst.

Referenced by wchar_t_xml_read_gstring(), and wchar_t_xml_read_string().

00704 {
00705     assertobjconst(self);
00706     assertptr( begin, sizeof(wchar_t)*(end-begin) );
00707     assert( end >= begin );
00708     {
00709         const wchar_t* text = begin;
00710         wchar_t* outtext = begin;
00711         /* Gnaw off leading spaces (note: not good for mixed/embedded text)*/
00712         if ( bEatWhite )
00713         {
00714             while( cisspace(wchar_t)(*text) )
00715                 text++;
00716         }
00717         while ( text < end )
00718         {
00719             if ( text[0] == chconst(wchar_t,'&') )
00720             {
00721                 if ( text[1] == chconst(wchar_t,'#') )
00722                 {
00723                     wchar_t *p;
00724                     wchar_t ret;
00725                     if ( text[2] == chconst(wchar_t,'x') )
00726                         ret = (wchar_t)cstrtol(wchar_t)(text+3,&p,16);
00727                     else
00728                         ret = (wchar_t)cstrtol(wchar_t)(text+2,&p,10);
00729                     if ( *p++ != chconst(wchar_t,';') )
00730                     {
00731                         self->except( self,szconst(char,"Bad XML: Bad character Reference"), NULL, NULL );
00732                         return NULL;
00733                     }
00734                     text = p;
00735                     *outtext++ = ret;
00736                 }
00737                 else
00738                 {
00739                     /* Get label*/
00740                     text++;
00741                     /* Next parse point after ';'*/
00742                     if( !cstrncmp(wchar_t)(text,szconst(wchar_t,"amp;"),4) )
00743                     {
00744                         *outtext++ = chconst(wchar_t,'&');
00745                         text += 4;
00746                     }
00747                     else if( !cstrncmp(wchar_t)(text,szconst(wchar_t,"apos;"),5) )
00748                     {
00749                         *outtext++ = chconst(wchar_t,'\'');
00750                         text += 5;
00751                     }
00752                     else if( !cstrncmp(wchar_t)(text,szconst(wchar_t,"lt;"),3) )
00753                     {
00754                         *outtext++ = chconst(wchar_t,'<');
00755                         text += 3;
00756                     }
00757                     else if( !cstrncmp(wchar_t)(text,szconst(wchar_t,"gt;"),3) )
00758                     {
00759                         *outtext++ = chconst(wchar_t,'>');
00760                         text += 3;
00761                     }
00762                     else if( !cstrncmp(wchar_t)(text,szconst(wchar_t,"quot;"),5) )
00763                     {
00764                         *outtext++ = chconst(wchar_t,'\"');
00765                         text += 5;
00766                     }
00767                     else
00768                     {
00769                         self->except( self,szconst(char,"Bad XML: Unknown entity reference"), NULL, NULL );
00770                         return NULL;
00771                     }
00772                 }
00773             }
00774             else if ( text[0] == chconst(wchar_t,'<') )
00775             {
00776                 /* Handle CDATA*/
00777                 if ( !cstrncmp(wchar_t)( text, szconst(wchar_t,"<![CDATA["), 9 ) )
00778                 {
00779                     const wchar_t* szGT = cstrstr(wchar_t)(text+9, szconst(wchar_t,"]]>"));
00780                     if ( szGT && szGT < end )
00781                     {
00782                         /* + "<![CDATA["*/
00783                         text += 9;
00784                         if ( bEatWhite )
00785                         {
00786                             while( cisspace(wchar_t)(*text) )
00787                                 text++;
00788                         }
00789                         while ( text < szGT )
00790                         {
00791                             *outtext++ = *text++;
00792                         }
00793                         /* + "]]>"*/
00794                         text += 3;
00795                     }
00796                     else
00797                     {
00798                         self->except( self,szconst(char,"Bad XML: <![CDATA[ doesn't have a ']]>'"), NULL, NULL );
00799                         return NULL;
00800                     }
00801                 }
00802                 else
00803                 {
00804                     /* If we encounter embedded tags (and comments) in the body text we're reading, skip over it recursively.*/
00805                     int count = 0;
00806                     text++;
00807                     while ( text < end )
00808                     {
00809                         if ( *text == chconst(wchar_t,'<') )
00810                             count++;
00811                         else if ( *text == chconst(wchar_t,'>') && !count-- )
00812                         {
00813                             text++;
00814                             break;
00815                         }
00816                         text++;
00817                     }
00818                 }
00819             }
00820             else
00821             {
00822                 *outtext++ = *text++;
00823             }
00824         }
00825         /* Chew off trailing spaces */
00826         if ( bEatWhite )
00827         {
00828             while( outtext > begin && cisspace(wchar_t)(*(outtext-1)) )
00829                 outtext--;
00830         }
00831         /* NUL terminate, where possible */
00832         if( outtext < end )
00833             *outtext = 0;
00834         return outtext;
00835     }
00836 }

void ctl_xmlwrite_addheader ( ctl_xmlwrite self  ) 

Slap a header onto (presumably the start) of an XML file.

Parameters:
self XML Writer we're closing

Definition at line 126 of file xml.c.

References szconst.

Referenced by ctl_xmlwrite_create().

00127 {
00128     xml_puts( self, szconst(char,"<?xml version=\"1.0\" ?>") );
00129 }

bool ctl_xmlwrite_begin ( ctl_xmlwrite self,
ctl_mstring_char_grow *  stringbuff 
)

Open an XML stream for writing, setting everything up for its output.

Parameters:
self XML Writer we're initializing
stringbuff The string buffer to have the xml data appended

Definition at line 73 of file xml.c.

References assertobjptr.

00074 {
00075     assertobjptr(self);
00076     assertobjptr( stringbuff );
00077     self->indent = 0;
00078     self->pretty = true;
00079     self->buff = stringbuff;
00080     self->fp = NULL;
00081     return true;
00082 }

void ctl_xmlwrite_close ( ctl_xmlwrite self  ) 

Finish an XML stream for writing.

Parameters:
self XML Writer we're closing

Definition at line 111 of file xml.c.

References assertobjptr.

00112 {
00113     assertobjptr(self);
00114     if( NULL != self->fp )
00115     {
00116         fclose( self->fp );
00117         self->fp = NULL;
00118     }
00119 }

void ctl_xmlwrite_containertag ( ctl_xmlwrite self,
const char *  type,
size_t  count,
const char *  label 
)

Write our most common tag opening for containers.

Parameters:
self XML Writer we're closing
type Type of object we're writing
count Count of items
label Label for what we're writing

Definition at line 192 of file xml.c.

References assertconst, assertobjptr, CTL_LABEL_TYPE, ctl_xmlwrite_newline(), and szconst.

Referenced by raw_xml_writebytes().

00193 {
00194     assertobjptr(self);
00195     assertconst(type,1);
00196     assertconst(label,1);
00197     ctl_xmlwrite_newline( self );
00198     xml_printf( self, szconst(char,"<%s ") CTL_LABEL_TYPE szconst(char,"=\"container\" ") CTL_LABEL_MBRTYPE szconst(char,"=\"%s\" ") CTL_LABEL_COUNT szconst(char,"=\"%d\">"), label, type, count );
00199 }

Here is the call graph for this function:

bool ctl_xmlwrite_create ( ctl_xmlwrite self,
const char *  szPath 
)

Open an XML stream for writing, setting everything up for its output.

Parameters:
self XML Writer we're initializing
szPath The file name to save it under

Definition at line 90 of file xml.c.

References assertconst, assertobjptr, and ctl_xmlwrite_addheader().

00091 {
00092     assertobjptr(self);
00093     assertconst(szPath,1);
00094     self->indent = 0;
00095     self->pretty = true;
00096     self->buff = NULL;
00097     self->fp = fopen( szPath, "wb" );
00098     if( NULL != self->fp )
00099     {
00100         ctl_xmlwrite_addheader( self );
00101         return true;
00102     }
00103     return false;
00104 }

Here is the call graph for this function:

void ctl_xmlwrite_endtag ( ctl_xmlwrite self,
const char *  type,
const char *  label 
)

Close our most common tag for containers or members.

Parameters:
self XML Writer we're closing
type Type of object we're writing
label Label for what we're writing; if label is NULL, uses type as label

Definition at line 208 of file xml.c.

References assertconst, assertobjptr, and szconst.

Referenced by char_xml_write_string(), raw_xml_writebytes(), and wchar_t_xml_write_string().

00209 {
00210     assertobjptr(self);
00211     assertconst(type,1);
00212     assertconst(label,1);
00213     xml_printf( self, szconst(char,"</%s>"), label );
00214 
00215 }

void ctl_xmlwrite_generaltag ( ctl_xmlwrite self,
const char *  type,
const char *  label 
)

Write our most common tag opening for single members.

Parameters:
self XML Writer we're closing
type Type of object we're writing
label Label for what we're writing; if label is NULL, uses type as label

Definition at line 175 of file xml.c.

References assertconst, assertobjptr, CTL_LABEL_TYPE, ctl_xmlwrite_newline(), and szconst.

Referenced by char_xml_write_string(), and wchar_t_xml_write_string().

00176 {
00177     assertobjptr(self);
00178     assertconst(type,1);
00179     assertconst(label,1);
00180     ctl_xmlwrite_newline( self );
00181     xml_printf( self, szconst(char,"<%s ") CTL_LABEL_TYPE szconst(char,"=\"%s\">"), label, type );
00182 }

Here is the call graph for this function:

void ctl_xmlwrite_indent ( ctl_xmlwrite self  ) 

Write a newline and indent following blocks.

Parameters:
self XML Writer we're closing

Definition at line 150 of file xml.c.

References assertobjptr, and XML_TAB_DEPTH.

Referenced by raw_xml_writebytes().

00151 {
00152     assertobjptr(self);
00153     self->indent += XML_TAB_DEPTH;
00154 }

void ctl_xmlwrite_newline ( ctl_xmlwrite self  ) 

Write a newline into pretty-printed file.

Parameters:
self XML Writer we're closing

Definition at line 136 of file xml.c.

References assertobjptr, and szconst.

Referenced by ctl_xmlwrite_containertag(), ctl_xmlwrite_generaltag(), ctl_xmlwrite_outdent(), and raw_xml_writebytes().

00137 {
00138     assertobjptr(self);
00139     if( self->pretty )
00140     {
00141         xml_printf( self, szconst(char,"\n%*s"), self->indent,szconst(char,"") );
00142     }
00143 }

void ctl_xmlwrite_outdent ( ctl_xmlwrite self  ) 

Write a newline and remove one level of indent from following blocks.

Parameters:
self XML Writer we're closing

Definition at line 161 of file xml.c.

References assertobjptr, ctl_xmlwrite_newline(), and XML_TAB_DEPTH.

Referenced by raw_xml_writebytes().

00162 {
00163     assertobjptr(self);
00164     self->indent -= XML_TAB_DEPTH;
00165     ctl_xmlwrite_newline( self );
00166 }

Here is the call graph for this function:

bool float32_record_read ( float32 *  pdata,
const ctl_serial serial,
const char *  label 
)

\

\ \ \ \

  • .

Definition at line 955 of file record.c.

00957 {\

bool float32_record_readarray ( float32 *  pdata,
size_t  count,
const ctl_serial serial,
const char *  label 
)

\

\ \ \ \ \

  • .

Definition at line 1120 of file record.c.

bool float64_record_read ( float64 *  pdata,
const ctl_serial serial,
const char *  label 
)

\

\ \ \ \

  • .

Definition at line 962 of file record.c.

00964 {\

bool float64_record_readarray ( float64 *  pdata,
size_t  count,
const ctl_serial serial,
const char *  label 
)

\

\ \ \ \ \

  • .

Definition at line 1128 of file record.c.

bool int16_record_read ( int16 *  pdata,
const ctl_serial serial,
const char *  label 
)

\

\ \ \ \

  • .

Definition at line 913 of file record.c.

00913 {\

bool int16_record_readarray ( int16 *  pdata,
size_t  count,
const ctl_serial serial,
const char *  label 
)

\

\ \ \ \ \

  • .

Definition at line 1072 of file record.c.

bool int32_record_read ( int32 *  pdata,
const ctl_serial serial,
const char *  label 
)

\

\ \ \ \

  • .

Definition at line 927 of file record.c.

00937 {\

bool int32_record_readarray ( int32 *  pdata,
size_t  count,
const ctl_serial serial,
const char *  label 
)

\

\ \ \ \ \

  • .

Definition at line 1088 of file record.c.

bool int64_record_read ( int64 *  pdata,
const ctl_serial serial,
const char *  label 
)

\

\ \ \ \

  • .

Definition at line 941 of file record.c.

00944 {\

bool int64_record_readarray ( int64 *  pdata,
size_t  count,
const ctl_serial serial,
const char *  label 
)

\

\ \ \ \ \

  • .

Definition at line 1104 of file record.c.

bool int8_record_read ( int8 *  pdata,
const ctl_serial serial,
const char *  label 
)

\

\ \ \ \

  • .

Definition at line 899 of file record.c.

00901 {\

bool int8_record_readarray ( int8 *  pdata,
size_t  count,
const ctl_serial serial,
const char *  label 
)

\

\ \ \ \ \

  • .

Definition at line 1056 of file record.c.

void serial_log ( const ctl_serial serial,
unsigned  mask,
const char *  fmt,
  ... 
)

Log a serial message through debug_log system Parse position is pointed at with '>' in the output text.

Parameters:
serial Serial data to dump; will be cropped if it's bigger than SERIAL_MAX_DUMP
mask LOG_ERROR,LOG_INFO, etc. mask for logging
fmt printf format for title and/or additional debug details

Definition at line 83 of file serial.c.

References ctl_serial::begin, ctl_serial::curr, debug_getlogmask(), debug_logalways(), debug_vlogalways(), and ctl_serial::end.

00084 {
00085     if( (mask & debug_getlogmask()) || 0 == mask )
00086     {
00087         ctl_serial dumpit = *serial;
00088         char printable[16];
00089         const uint8* pBuff;
00090         size_t size = serial->end - serial->begin;
00091         size_t curr = 0;
00092         size_t offAddress = 0;
00093         /* Attach whatever other diagnostic info */
00094         va_list args;
00095         va_start( args, fmt );
00096         debug_vlogalways( fmt, args );
00097         /* Clip dump down to a maximum size of dump, so we don't cripple ourselves reporting problems */
00098 #ifndef SERIAL_MAX_DUMP
00099 #define SERIAL_MAX_DUMP 80
00100 #endif
00101         if( size > SERIAL_MAX_DUMP )
00102         {
00103             dumpit.begin = (uint8*)max(dumpit.begin,dumpit.curr-(SERIAL_MAX_DUMP/2));
00104             dumpit.end = (uint8*)min(dumpit.end,dumpit.curr+(SERIAL_MAX_DUMP/2));
00105             offAddress = dumpit.begin - serial->begin;
00106             size = SERIAL_MAX_DUMP;
00107         }
00108         /* Do hex dump */
00109         pBuff = (const uint8*)dumpit.begin;
00110         while( pBuff < dumpit.end )
00111         {
00112             unsigned ch = *pBuff++;
00113             if( 0 == (curr & 0xf) )
00114             {
00115                 debug_logalways( "%08x:%c", curr+offAddress, pBuff == dumpit.curr-1 ? '>' : ' ' );
00116             }
00117             printable[curr&0xf] = isprint(ch) ? ch : '.';
00118             if( 0xf == (curr++ & 0xf) )
00119             {
00120                 debug_logalways( "%02x | %16.16s\n", ch, printable );
00121             }
00122             else
00123             {
00124                 debug_logalways( "%02x%c", ch, pBuff == dumpit.curr ? '>' : ' ' );
00125             }
00126         }
00127         /* Leftovers */
00128         if( 0 != (size & 0xf) )
00129         {
00130             for( curr = curr & 0xf; curr < 16; ++curr )
00131             {
00132                 debug_logalways( "-- " );
00133                 printable[curr] = ' ';
00134             }
00135             debug_logalways( "| %16.16s\n", printable );
00136         }
00137     }
00138 }

Here is the call graph for this function:

void spew ( void   ) 

bool uint16_record_read ( uint16 *  pdata,
const ctl_serial serial,
const char *  label 
)

\

\ \ \ \

  • .

Definition at line 920 of file record.c.

00937 {\

bool uint16_record_readarray ( uint16 *  pdata,
size_t  count,
const ctl_serial serial,
const char *  label 
)

\

\ \ \ \ \

  • .

Definition at line 1080 of file record.c.

void uint16_serial_peek ( uint16 *  pdata,
const ctl_serial serial 
)

Read a 16-bit scalar without chaning 'curr'.

Parameters:
pdata Pointer to item we're writing
serial Serial parser

Definition at line 525 of file serial.c.

References assertobjconst, assertptr, and uint16_serial_read().

Referenced by ctl_serial_peeksize().

00526 {
00527     assertobjconst(serial);
00528     assertptr(pdata,sizeof(*pdata));
00529     {
00530         ctl_serial temp = *serial;
00531         uint16_serial_read( pdata, &temp );
00532     }
00533 }

Here is the call graph for this function:

void uint16_serial_read ( uint16 *  pdata,
ctl_serial serial 
)

Read a 16-bit scalar.

Parameters:
pdata Pointer to item we're writing
serial Serial parser

Definition at line 490 of file serial.c.

References assertobjptr, assertptr, ctl_serial::curr, and ctl_serial::end.

Referenced by char_record_read_gstring(), char_record_read_string(), ctl_record_container_validatedata(), ctl_record_count(), ctl_record_getdata(), ctl_record_valid(), ctl_serial_readsize(), RingBuff_PeekSerial(), RingBuff_PopSerial(), uint16_serial_peek(), uint16_serial_readarray(), wchar_t_record_read_gstring(), wchar_t_record_read_string(), and wchar_t_serial_read_string().

00491 {
00492     assertobjptr(serial);
00493     assertptr(pdata,sizeof(*pdata));
00494     if( serial->curr + 2 <= serial->end )
00495     {
00496 #if defined(SERIAL_LITTLE_ENDIAN)
00497         const uint8* curr = serial->curr + 1;
00498         *pdata = (uint16)*curr--;
00499         *pdata <<= 8;
00500         *pdata |= (uint16)*curr;
00501         serial->curr += 2;
00502 #elif defined(SERIAL_BIG_ENDIAN)
00503         const uint8* curr = serial->curr;
00504         *pdata = (uint16)*curr++;
00505         *pdata <<= 8;
00506         *pdata |= (uint16)*curr++;
00507         serial->curr = (uint8*)curr;
00508 #elif defined(SERIAL_NATIVE)
00509         *pdata = *((uint16*)serial->curr);
00510         serial->curr += 2;
00511 #endif
00512     }
00513     else
00514     {
00515         ctl_serial_except( serial, "ctl_serial_read: Bound check failure" );
00516     }
00517 }

void uint16_serial_readarray ( uint16 *  array,
size_t  count,
ctl_serial serial 
)

Read an array of scalars.

Parameters:
array Pointer to beginning of array
count Count of array items
serial Buffer/parse pointer

Definition at line 576 of file serial.c.

References assertobjptr, assertptr, ctl_serial_readsize(), ctl_serial::curr, pointer_foreach, and uint16_serial_read().

00577 {
00578     size_t size;
00579     size_t serialCount;
00580     assertobjptr(serial);
00581     assertptr(array,count*sizeof(array));
00582     size = ctl_serial_readsize( serial );
00583     serialCount = size>>1;
00584     if( size & 1 )
00585         ctl_serial_except( serial, "uint16_serial_readarray: Odd size" );
00586     if( serialCount > count )
00587         serialCount = count;
00588     {
00589         pointer_foreach(uint16,array,serialCount, curr )
00590             uint16_serial_read(curr,serial);
00591     }
00592     if( serialCount < count )
00593     {
00594         size_t leftover = size - (count<<1);
00595         serial->curr += size - (count<<1);
00596         memset( array + count, 0, leftover );
00597     }
00598     else
00599     {
00600         serial->curr += size - (count<<1);
00601     }
00602 }

Here is the call graph for this function:

size_t uint16_serial_sizearray ( const uint16 *  array,
size_t  count 
)

Calculate how big an array of scalars will be when serialized.

Parameters:
array Pointer to beginning of array
count Count of array items
Returns:
Size of array

Definition at line 542 of file serial.c.

References assertconst, and ctl_serial_size_size_size.

00543 {
00544     size_t size = count * sizeof(uint16);
00545     assertconst(array,count*sizeof(array));
00546     return ctl_serial_size_size_size( size );
00547 }

void uint16_serial_write ( const uint16 *  pdata,
ctl_serial serial 
)

Write a 16-bit scalar.

Parameters:
pdata Pointer to item we're writing
serial Serial parser

Definition at line 459 of file serial.c.

References assert, assertconst, assertobjptr, ctl_serial::curr, and ctl_serial::end.

Referenced by ctl_record_write_begin(), ctl_record_write_container_begin(), ctl_serial_writesize(), RingBuff_AddSerial(), uint16_serial_writearray(), wchar_t_record_write_string(), and wchar_t_serial_write_string().

00460 {
00461     assertobjptr(serial);
00462     assertconst(pdata,sizeof(*pdata));
00463     assert( serial->curr+2 <= serial->end );
00464 #if defined(SERIAL_LITTLE_ENDIAN)
00465     {
00466         uint8* curr = serial->curr;
00467         *curr++ = (uint8)(*pdata);
00468         *curr++ = (uint8)(*pdata>>8);
00469         serial->curr = curr;
00470     }
00471 #elif defined(SERIAL_BIG_ENDIAN)
00472     {
00473         uint8* curr = serial->curr+1;
00474         *curr-- = (uint8)(*pdata);
00475         *curr = (uint8)(*pdata>>8);
00476         serial->curr += 2;
00477     }
00478 #elif defined(SERIAL_NATIVE)
00479     *((uint16*)serial->curr) = *pdata;
00480     serial->curr += 2;
00481 #endif
00482 }

void uint16_serial_writearray ( const uint16 *  array,
size_t  count,
ctl_serial serial 
)

Write an array of scalars.

Parameters:
array Pointer to beginning of array
count Count of array items
serial Buffer/parse pointer

Definition at line 556 of file serial.c.

References assert, assertconst, assertobjptr, ctl_serial_writesize(), ctl_serial::curr, pointer_foreach_const, and uint16_serial_write().

00557 {
00558     size_t size = count<<1;
00559     assertobjptr(serial);
00560     assertconst(array,count*sizeof(array));
00561     ctl_serial_writesize( size, serial );
00562     assert( serial->curr + size <= serial->end );
00563     {
00564         pointer_foreach_const(uint16,array,count, curr )
00565             uint16_serial_write(curr,serial);
00566     }
00567 }

Here is the call graph for this function:

bool uint32_record_read ( uint32 *  pdata,
const ctl_serial serial,
const char *  label 
)

\

\ \ \ \

  • .

Definition at line 934 of file record.c.

00937 {\

bool uint32_record_readarray ( uint32 *  pdata,
size_t  count,
const ctl_serial serial,
const char *  label 
)

\

\ \ \ \ \

  • .

Definition at line 1096 of file record.c.

void uint32_serial_peek ( uint32 *  pdata,
ctl_serial serial 
)

Read a 32-bit scalar without chaning 'curr'.

Parameters:
pdata Pointer to item we're writing
serial Serial parser

Definition at line 698 of file serial.c.

References assertobjptr, assertptr, and uint32_serial_read().

00699 {
00700     assertobjptr(serial);
00701     assertptr(pdata,sizeof(*pdata));
00702     {
00703         ctl_serial temp = *serial;
00704         uint32_serial_read( pdata, &temp );
00705     }
00706 }

Here is the call graph for this function:

void uint32_serial_read ( uint32 *  pdata,
ctl_serial serial 
)

Read a 32-bit scalar.

Parameters:
pdata Pointer to item we're writing
serial Serial parser

Definition at line 653 of file serial.c.

References assertobjptr, assertptr, ctl_serial::curr, and ctl_serial::end.

Referenced by ctl_record_container_validatedata(), ctl_record_count(), ctl_record_end(), ctl_record_getdata(), ctl_record_next(), ctl_record_valid(), uint32_serial_peek(), and uint32_serial_readarray().

00654 {
00655     assertobjptr(serial);
00656     assertptr(pdata,sizeof(*pdata));
00657     if( serial->curr + 4 <= serial->end )
00658     {
00659 #if defined(SERIAL_LITTLE_ENDIAN)
00660         register const uint8* curr = serial->curr + 3;
00661         register uint32 tmp = (uint32)*curr--;
00662         tmp <<= 8;
00663         tmp |= (uint32)*curr--;
00664         tmp <<= 8;
00665         tmp |= (uint32)*curr--;
00666         tmp <<= 8;
00667         tmp |= (uint32)*curr;
00668         *pdata = tmp;
00669         serial->curr += 4;
00670 #elif defined(SERIAL_BIG_ENDIAN)
00671         register const uint8* curr = serial->curr;
00672         register uint32 tmp = (uint32)*curr++;
00673         tmp <<= 8;
00674         tmp |= (uint32)*curr++;
00675         tmp <<= 8;
00676         tmp |= (uint32)*curr++;
00677         tmp <<= 8;
00678         tmp |= (uint32)*curr++;
00679         *pdata = tmp;
00680         serial->curr = (uint8*)curr;
00681 #elif defined(SERIAL_NATIVE)
00682         *pdata = *((uint32*)serial->curr);
00683         serial->curr += 4;
00684 #endif
00685     }
00686     else
00687     {
00688         ctl_serial_except( serial, "ctl_serial_read: Bound check failure" );
00689     }
00690 }

void uint32_serial_readarray ( uint32 *  array,
size_t  count,
ctl_serial serial 
)

Read an array of scalars.

Parameters:
array Pointer to beginning of array
count Count of array items
serial Buffer/parse pointer

Definition at line 750 of file serial.c.

References assertobjptr, assertptr, ctl_serial_readsize(), ctl_serial::curr, pointer_foreach, and uint32_serial_read().

00751 {
00752     size_t size;
00753     size_t serialCount;
00754     assertobjptr(serial);
00755     assertptr(array,count*sizeof(array));
00756     size = ctl_serial_readsize( serial );
00757     serialCount = size>>2;
00758     if( size & 3 )
00759         ctl_serial_except( serial, "uint32_serial_readarray: Odd size" );
00760     if( serialCount > count )
00761         serialCount = count;
00762     {
00763         pointer_foreach(uint32,array,serialCount, curr )
00764             uint32_serial_read(curr,serial);
00765     }
00766     if( serialCount < count )
00767     {
00768         size_t leftover = size - (count<<2);
00769         serial->curr += size - (count<<2);
00770         memset( array + count, 0, leftover );
00771     }
00772     else
00773     {
00774         serial->curr += size - (count<<2);
00775     }
00776 }

Here is the call graph for this function:

size_t uint32_serial_sizearray ( const uint32 *  array,
size_t  count 
)

Calculate how big an array of scalars will be when serialized.

Parameters:
array Pointer to beginning of array
count Count of array items
Returns:
Size of array

Definition at line 716 of file serial.c.

References assertconst, and ctl_serial_size_size_size.

00717 {
00718     size_t size = count * sizeof(uint32);
00719     assertconst(array,count*sizeof(array));
00720     return ctl_serial_size_size_size( size );
00721 }

void uint32_serial_write ( const uint32 *  pdata,
ctl_serial serial 
)

Write a 32-bit scalar.

Parameters:
pdata Pointer to item we're writing
serial Serial parser

Definition at line 610 of file serial.c.

References assert, assertconst, assertobjptr, ctl_serial::curr, and ctl_serial::end.

Referenced by ctl_record_write_begin(), ctl_record_write_container_begin(), ctl_record_write_end(), and uint32_serial_writearray().

00611 {
00612     assertobjptr(serial);
00613     assertconst(pdata,sizeof(*pdata));
00614     assert( serial->curr+4 <= serial->end );
00615 #if defined(SERIAL_LITTLE_ENDIAN)
00616     {
00617         register uint8* curr = serial->curr;
00618         register uint32 val = *pdata;
00619         *curr++ = (uint8)(val);
00620         val >>= 8;
00621         *curr++ = (uint8)(val);
00622         val >>= 8;
00623         *curr++ = (uint8)(val);
00624         val >>= 8;
00625         *curr++ = (uint8)(val);
00626         serial->curr = curr;
00627     }
00628 #elif defined(SERIAL_BIG_ENDIAN)
00629     {
00630         register uint8* curr = serial->curr+3;
00631         register uint32 val = *pdata;
00632         *curr-- = (uint8)(val);
00633         val >>= 8;
00634         *curr-- = (uint8)(val);
00635         val >>= 8;
00636         *curr-- = (uint8)(val);
00637         val >>= 8;
00638         *curr = (uint8)(val);
00639         serial->curr += 4;
00640     }
00641 #elif defined(SERIAL_NATIVE)
00642     *((uint32*)serial->curr) = *pdata;
00643     serial->curr += 4;
00644 #endif
00645 }

void uint32_serial_writearray ( const uint32 *  array,
size_t  count,
ctl_serial serial 
)

Write an array of scalars.

Parameters:
array Pointer to beginning of array
count Count of array items
serial Buffer/parse pointer

Definition at line 730 of file serial.c.

References assert, assertconst, assertobjptr, ctl_serial_writesize(), ctl_serial::curr, pointer_foreach_const, and uint32_serial_write().

00731 {
00732     size_t size = count<<2;
00733     assertobjptr(serial);
00734     assertconst(array,count*sizeof(array));
00735     ctl_serial_writesize( size, serial );
00736     assert( serial->curr + size <= serial->end );
00737     {
00738         pointer_foreach_const(uint32,array,count, curr )
00739             uint32_serial_write(curr,serial);
00740     }
00741 }

Here is the call graph for this function:

bool uint64_record_read ( uint64 *  pdata,
const ctl_serial serial,
const char *  label 
)

\

\ \ \ \

  • .

Definition at line 948 of file record.c.

00949 {\

bool uint64_record_readarray ( uint64 *  pdata,
size_t  count,
const ctl_serial serial,
const char *  label 
)

\

\ \ \ \ \

  • .

Definition at line 1112 of file record.c.

void uint64_serial_peek ( uint64 *  pdata,
ctl_serial serial 
)

Read a 64-bit scalar without changing parse point 'curr'.

Parameters:
pdata Pointer to item we're writing
serial Serial parser

Definition at line 904 of file serial.c.

References assertobjptr, assertptr, and uint64_serial_read().

00905 {
00906     assertobjptr(serial);
00907     assertptr(pdata,sizeof(*pdata));
00908     {
00909         ctl_serial temp = *serial;
00910         uint64_serial_read( pdata, &temp );
00911     }
00912 }

Here is the call graph for this function:

void uint64_serial_read ( uint64 *  pdata,
ctl_serial serial 
)

Read a 64-bit scalar.

Parameters:
pdata Pointer to item we're writing
serial Serial parser

Definition at line 843 of file serial.c.

References assertobjptr, assertptr, ctl_serial::curr, and ctl_serial::end.

Referenced by uint64_serial_peek(), and uint64_serial_readarray().

00844 {
00845     assertobjptr(serial);
00846     assertptr(pdata,sizeof(*pdata));
00847     if( serial->curr + 8 <= serial->end )
00848     {
00849 #if defined(SERIAL_LITTLE_ENDIAN)
00850         register const uint8* curr = serial->curr + 7;
00851         register uint64 tmp = (uint64)*curr--;
00852         tmp <<= 8;
00853         tmp |= (uint64)*curr--;
00854         tmp <<= 8;
00855         tmp |= (uint64)*curr--;
00856         tmp <<= 8;
00857         tmp |= (uint64)*curr--;
00858         tmp <<= 8;
00859         tmp |= (uint64)*curr--;
00860         tmp <<= 8;
00861         tmp |= (uint64)*curr--;
00862         tmp <<= 8;
00863         tmp |= (uint64)*curr--;
00864         tmp <<= 8;
00865         tmp |= (uint64)*curr;
00866         *pdata = tmp;
00867         serial->curr += 8;
00868 #elif defined(SERIAL_BIG_ENDIAN)
00869         register const uint8* curr = serial->curr;
00870         register uint64 tmp = (uint64)*curr++;
00871         tmp <<= 8;
00872         tmp |= (uint64)*curr++;
00873         tmp <<= 8;
00874         tmp |= (uint64)*curr++;
00875         tmp <<= 8;
00876         tmp |= (uint64)*curr++;
00877         tmp <<= 8;
00878         tmp |= (uint64)*curr++;
00879         tmp <<= 8;
00880         tmp |= (uint64)*curr++;
00881         tmp <<= 8;
00882         tmp |= (uint64)*curr++;
00883         tmp <<= 8;
00884         tmp |= (uint64)*curr++;
00885         *pdata = tmp;
00886         serial->curr = (uint8*)curr;
00887 #elif defined(SERIAL_NATIVE)
00888         *pdata = *((uint64*)serial->curr);
00889         serial->curr += 8;
00890 #endif
00891     }
00892     else
00893     {
00894         ctl_serial_except( serial, "ctl_serial_read: Bound check failure" );
00895     }
00896 }

void uint64_serial_readarray ( uint64 *  array,
size_t  count,
ctl_serial serial 
)

Read an array of scalars.

Parameters:
array Pointer to beginning of array
count Count of array items
serial Buffer/parse pointer

Definition at line 956 of file serial.c.

References assertobjptr, assertptr, ctl_serial_readsize(), ctl_serial::curr, pointer_foreach, and uint64_serial_read().

00957 {
00958     size_t size;
00959     size_t serialCount;
00960     assertobjptr(serial);
00961     assertptr(array,count*sizeof(array));
00962     size = ctl_serial_readsize( serial );
00963     serialCount = size>>3;
00964     if( size & 7 )
00965         ctl_serial_except( serial, "uint64_serial_readarray: Odd size" );
00966     if( serialCount > count )
00967         serialCount = count;
00968     {
00969         pointer_foreach(uint64,array,serialCount, curr )
00970             uint64_serial_read(curr,serial);
00971     }
00972     if( serialCount < count )
00973     {
00974         size_t leftover = size - (count<<3);
00975         serial->curr += size - (count<<3);
00976         memset( array + count, 0, leftover );
00977     }
00978     else
00979     {
00980         serial->curr += size - (count<<3);
00981     }
00982 }

Here is the call graph for this function:

size_t uint64_serial_sizearray ( const uint64 *  array,
size_t  count 
)

Calculate how big an array of scalars will be when serialized.

Parameters:
array Pointer to beginning of array
count Count of array items
Returns:
Size of array

Definition at line 921 of file serial.c.

References assertconst, and ctl_serial_size_size_size.

00922 {
00923     size_t size = count * sizeof(uint64);
00924     assertconst(array,count*sizeof(array));
00925     return ctl_serial_size_size_size( size );
00926 }

void uint64_serial_write ( const uint64 *  pdata,
ctl_serial serial 
)

Write a 64-bit scalar.

Parameters:
pdata Pointer to item we're writing
serial Serial parser

Definition at line 784 of file serial.c.

References assert, assertconst, assertobjptr, ctl_serial::curr, and ctl_serial::end.

Referenced by uint64_serial_writearray().

00785 {
00786     assertobjptr(serial);
00787     assertconst(pdata,sizeof(*pdata));
00788     assert( serial->curr+8 <= serial->end );
00789 #if defined(SERIAL_LITTLE_ENDIAN)
00790     {
00791         register uint8* curr = serial->curr;
00792         register uint64 val = *pdata;
00793         *curr++ = (uint8)(val);
00794         val >>= 8;
00795         *curr++ = (uint8)(val);
00796         val >>= 8;
00797         *curr++ = (uint8)(val);
00798         val >>= 8;
00799         *curr++ = (uint8)(val);
00800         val >>= 8;
00801         *curr++ = (uint8)(val);
00802         val >>= 8;
00803         *curr++ = (uint8)(val);
00804         val >>= 8;
00805         *curr++ = (uint8)(val);
00806         val >>= 8;
00807         *curr++ = (uint8)(val);
00808         serial->curr = curr;
00809     }
00810 #elif defined(SERIAL_BIG_ENDIAN)
00811     {
00812         register uint8* curr = serial->curr+7;
00813         register uint64 val = *pdata;
00814         *curr-- = (uint8)(val);
00815         val >>= 8;
00816         *curr-- = (uint8)(val);
00817         val >>= 8;
00818         *curr-- = (uint8)(val);
00819         val >>= 8;
00820         *curr-- = (uint8)(val);
00821         val >>= 8;
00822         *curr-- = (uint8)(val);
00823         val >>= 8;
00824         *curr-- = (uint8)(val);
00825         val >>= 8;
00826         *curr-- = (uint8)(val);
00827         val >>= 8;
00828         *curr = (uint8)(val);
00829         serial->curr += 8;
00830     }
00831 #elif defined(SERIAL_NATIVE)
00832     *((uint64*)serial->curr) = *pdata;
00833     serial->curr += 8;
00834 #endif
00835 }

void uint64_serial_writearray ( const uint64 *  array,
size_t  count,
ctl_serial serial 
)

Write an array of scalars.

Parameters:
array Pointer to beginning of array
count Count of array items
serial Buffer/parse pointer

Definition at line 935 of file serial.c.

References assert, assertconst, assertobjptr, ctl_serial_writesize(), ctl_serial::curr, pointer_foreach_const, and uint64_serial_write().

00936 {
00937     size_t size = count << 3;
00938     assertobjptr(serial);
00939     assertconst(array,count*sizeof(array));
00940     ctl_serial_writesize( size, serial );
00941     assert( serial->curr + size <= serial->end );
00942     {
00943         pointer_foreach_const(uint64,array,count, curr )
00944             uint64_serial_write(curr,serial);
00945     }
00946 }

Here is the call graph for this function:

bool uint8_record_read ( uint8 *  pdata,
const ctl_serial serial,
const char *  label 
)

\

\ \ \ \

  • .

Definition at line 906 of file record.c.

00913 {\

bool uint8_record_readarray ( uint8 *  pdata,
size_t  count,
const ctl_serial serial,
const char *  label 
)

\

\ \ \ \ \

  • .

Definition at line 1064 of file record.c.

void uint8_serial_peek ( uint8 *  pdata,
const ctl_serial serial 
)

Read an 8-bit scalar without chaning curr.

Parameters:
pdata Pointer to item we're writing
serial Serial parser

Definition at line 393 of file serial.c.

References assertobjconst, assertptr, ctl_serial::curr, and ctl_serial::end.

00394 {
00395     assertobjconst(serial);
00396     assertptr(pdata,sizeof(*pdata));
00397     if( serial->curr < serial->end )
00398         *pdata = *serial->curr;
00399     else
00400         ctl_serial_except( serial, "ctl_serial_read: Bound check failure" );
00401 }

void uint8_serial_read ( uint8 *  pdata,
ctl_serial serial 
)

Read an 8-bit scalar.

Parameters:
pdata Pointer to item we're writing
serial Serial parser

Definition at line 377 of file serial.c.

References assertobjptr, assertptr, ctl_serial::curr, and ctl_serial::end.

00378 {
00379     assertobjptr(serial);
00380     assertptr(pdata,sizeof(*pdata));
00381     if( serial->curr < serial->end )
00382         *pdata = *serial->curr++;
00383     else
00384         ctl_serial_except( serial, "ctl_serial_read: Bound check failure" );
00385 }

void uint8_serial_readarray ( uint8 *  array,
size_t  count,
ctl_serial serial 
)

Read an array of scalars.

Parameters:
array Pointer to beginning of array
count Count of array items
serial Buffer/parse pointer

Definition at line 441 of file serial.c.

References assertobjptr, assertptr, ctl_serial_readsize(), and ctl_serial::curr.

00442 {
00443     size_t size = ctl_serial_readsize( serial );
00444     assertobjptr(serial);
00445     assertptr(array,count*sizeof(array));
00446     if( size > count )
00447         ctl_serial_except( serial, "serial_readarray: Too big" );
00448     count = min(count,size);
00449     memcpy( array, serial->curr, count );
00450     serial->curr += size;
00451 }

Here is the call graph for this function:

size_t uint8_serial_sizearray ( const uint8 *  array,
size_t  count 
)

Calculate how big an array of scalars will be when serialized.

Parameters:
array Pointer to beginning of array
count Count of array items
Returns:
Size of array

Definition at line 410 of file serial.c.

References assertconst, and ctl_serial_size_size_size.

00411 {
00412     size_t size = count;
00413     assertconst(array,count*sizeof(array));
00414     return ctl_serial_size_size_size( size );
00415 }

void uint8_serial_write ( const uint8 *  pdata,
ctl_serial serial 
)

Write an 8-bit scalar.

Parameters:
pdata Pointer to item we're writing
serial Serial parser

Definition at line 363 of file serial.c.

References assert, assertconst, assertobjptr, ctl_serial::curr, and ctl_serial::end.

Referenced by raw_xml_readbytes().

00364 {
00365     assertobjptr(serial);
00366     assertconst(pdata,sizeof(*pdata));
00367     assert( serial->curr < serial->end );
00368     *serial->curr++ = *pdata;
00369 }

void uint8_serial_writearray ( const uint8 *  array,
size_t  count,
ctl_serial serial 
)

Write an array of scalars.

Parameters:
array Pointer to beginning of array
count Count of array items
serial Buffer/parse pointer

Definition at line 423 of file serial.c.

References assert, assertconst, assertobjptr, ctl_serial_writesize(), and ctl_serial::curr.

00424 {
00425     size_t size = count;
00426     assertobjptr(serial);
00427     assertconst(array,count*sizeof(array));
00428     ctl_serial_writesize( size, serial );
00429     assert( serial->curr + size <= serial->end );
00430     memcpy( serial->curr, array, size );
00431     serial->curr += size;
00432 }

Here is the call graph for this function:

bool wchar_t_record_read_gstring ( ctl_mstring_wchar_t_grow *  str,
const ctl_serial serial,
const char *  label 
)

Read a wide character string.

Parameters:
str Dsetination to read to
serial Serial data to find string in and load it from
label Name of string

Definition at line 802 of file record.c.

References assertconst, assertobjconst, assertobjptr, chslength, ctl_gstring_resize, ctl_record_contained_type(), ctl_record_find(), ctl_record_getdata(), ctl_record_type(), ctl_serial::curr, ctl_serial::end, and uint16_serial_read().

00803 {
00804     ctl_serial tmp;
00805     assertobjptr(str);
00806     assertconst(label,1);
00807     assertobjconst(serial);
00808     tmp = *serial;
00809     if( ctl_record_find( &tmp, label ) )
00810     {
00811         const char* szcontainer = ctl_record_type( &tmp );
00812         if( cstrcmp(char)(szcontainer,"string") )
00813             ctl_serial_except( serial, "wchar_t_record_read_string: Not a string" );
00814         {
00815             const char* szwchar_t = ctl_record_contained_type( &tmp );
00816             size_t rsize = ctl_record_getdata( &tmp );
00817             if( !cstrcmp(char)(szwchar_t,"char") )
00818             {
00819                 wchar_t* sz;
00820                 const char* psz = (const char*)tmp.curr;
00821                 ctl_gstring_resize(wchar_t, str, rsize );
00822                 sz = str->begin;
00823                 while( tmp.curr < tmp.end )
00824                     *sz++ = (wchar_t)*psz++;
00825             }
00826             else if( !cstrcmp(char)(szwchar_t,"wchar_t") )
00827             {
00828                 wchar_t* sz;
00829                 if( rsize & 1 )
00830                     ctl_serial_except( serial, "wchar_t_record_read_string: Odd string length" );
00831                 rsize = chslength(wchar_t,rsize);
00832                 ctl_gstring_resize(wchar_t, str, rsize );
00833                 sz = str->begin;
00834                 while( tmp.curr < tmp.end )
00835                 {
00836                     uint16 ch;
00837                     uint16_serial_read( &ch, &tmp );
00838                     *sz++ = (wchar_t)ch;
00839                 }
00840             }
00841             else
00842             {
00843                 ctl_serial_except( serial, "wchar_t_record_read_string: Unknown character wchar_t" );
00844             }
00845         }
00846         return true;
00847     }
00848     return false;
00849 }

Here is the call graph for this function:

bool wchar_t_record_read_string ( wchar_t *  sz,
size_t  size,
const ctl_serial serial,
const char *  label 
)

Read a string.

Parameters:
sz Beginning of string to read into
size Maximum size to store there
serial Serial data to find string in and load it from
label Name of string

Definition at line 700 of file record.c.

References assertconst, assertobjconst, ctl_record_contained_type(), ctl_record_find(), ctl_record_getdata(), ctl_record_type(), ctl_serial::curr, ctl_serial::end, and uint16_serial_read().

00701 {
00702     ctl_serial tmp;
00703     assertconst(sz,1);
00704     assertconst(label,1);
00705     assertobjconst(serial);
00706     tmp = *serial;
00707     if( ctl_record_find( &tmp, label ) )
00708     {
00709         const char* szcontainer = ctl_record_type( &tmp );
00710         if( cstrcmp(char)(szcontainer,"string") )
00711             ctl_serial_except( serial, "wchar_t_record_read_string: Not a string" );
00712         {
00713             const char* szwchar_t = ctl_record_contained_type( &tmp );
00714             ctl_record_getdata( &tmp );
00715             if( !cstrcmp(char)(szwchar_t,"char") )
00716             {
00717                 const char* psz = (const char*)tmp.curr;
00718                 while( size-- && tmp.curr < tmp.end )
00719                     *sz++ = (wchar_t)*psz++;
00720                 if( size > 0 )
00721                     *sz++ = 0;
00722             }
00723             else if( !cstrcmp(char)(szwchar_t,"wchar_t") )
00724             {
00725                 while( size-- && tmp.curr < tmp.end )
00726                 {
00727                     uint16 ch;
00728                     uint16_serial_read( &ch, &tmp );
00729                     *sz++ = (wchar_t)ch;
00730                 }
00731                 if( size > 0 )
00732                     *sz++ = 0;
00733             }
00734             else
00735             {
00736                 ctl_serial_except( serial, "wchar_t_record_read_string: Unknown character wchar_t" );
00737             }
00738         }
00739         return true;
00740     }
00741     return false;
00742 }

Here is the call graph for this function:

size_t wchar_t_record_size_gstring ( const ctl_mstring_wchar_t_grow *  str,
const char *  label 
)

Measure string size for record output.

Parameters:
str string to measure
label Label for string

Definition at line 589 of file record.c.

References assertconst, assertobjconst, chssize, ctl_gstring_size, and ctl_record_objarray_head_size().

00590 {
00591     assertconst(label,1);
00592     assertobjconst(str);
00593     return ctl_record_objarray_head_size( label,"string","wchar_t" ) + chssize(wchar_t,ctl_gstring_size(wchar_t,str));
00594 }

Here is the call graph for this function:

size_t wchar_t_record_size_string ( const wchar_t *  str,
size_t  maxsize,
const char *  label 
)

Measure string size for record output.

Parameters:
str string to measure
maxsize Biggest string can be
label Label for string

Definition at line 565 of file record.c.

References assertconst, chssize, and ctl_record_objarray_head_size().

00566 {
00567     assertconst(label,1);
00568     assertconst(str,1);
00569     return ctl_record_objarray_head_size( label,"string","wchar_t" ) + chssize(wchar_t,cstrnlen(wchar_t)(str,maxsize));
00570 }

Here is the call graph for this function:

void wchar_t_record_write_string ( const wchar_t *  sz,
size_t  size,
ctl_serial serial,
const char *  label 
)

Write a wide character string.

Parameters:
sz Start of string
size Maximum length of string
serial Serial data to put record in
label Label for record

Definition at line 625 of file record.c.

References assertconst, assertobjptr, chssize, ctl_record_write_container_begin(), pointer_foreach_const, and uint16_serial_write().

00626 {
00627     size_t storesize;
00628     assertconst(sz,1);
00629     assertconst(label,1);
00630     assertobjptr(serial);
00631     storesize = cstrnlen(wchar_t)(sz,size);
00632     ctl_record_write_container_begin( "string", "wchar_t", chssize(wchar_t,storesize),storesize, serial, label );
00633     {
00634         pointer_foreach_const( wchar_t, sz, storesize, curr )
00635         {
00636             uint16 ch = (uint16)*curr;
00637             uint16_serial_write( &ch, serial );
00638         }
00639     }
00640 }

Here is the call graph for this function:

void wchar_t_serial_peek_sconst ( ctl_sconst_wchar_t *  str,
ctl_serial serial 
)

Peek at a serialized wide character string, pointing at data in ctl_serial.

Parameters:
str ctl_sconst constant string type to receive beginning/end of string
serial Serial parser

Definition at line 1203 of file serial.c.

References assertobjptr, ctl_sconst_init_pointers, ctl_serial_peeksize(), ctl_serial_size_size, and ctl_serial::curr.

01204 {
01205     size_t size;
01206     const uint8* pStr;
01207     assertobjptr(str);
01208     assertobjptr(serial);
01209     size = ctl_serial_peeksize( serial );
01210     pStr = serial->curr + ctl_serial_size_size( size );
01211     if( size & 1 )
01212         ctl_serial_except( serial, "ctl_serial_peek_string: Odd size" );
01213     size>>=1;
01214     ctl_sconst_init_pointers(wchar_t, str, (wchar_t*)pStr, (wchar_t*)pStr + size );
01215 }

Here is the call graph for this function:

void wchar_t_serial_read_fstring ( ctl_mstring_wchar_t_grow *  str,
ctl_serial serial 
)

Read a serialized wide character string.

Parameters:
str Fixed length string to read into
serial Serial parser

Definition at line 1168 of file serial.c.

References assertobjptr, chslength, ctl_fstring_maxsize, ctl_serial_peeksize(), and ppConcat.

01169 {
01170     size_t msize;
01171     size_t maxsize;
01172     assertobjptr(str);
01173     assertobjptr(serial);
01174     msize = chslength(wchar_t,ctl_serial_peeksize( serial ));
01175     maxsize = ctl_fstring_maxsize(char,str);
01176     if( msize > maxsize )
01177         msize = maxsize;
01178     ppConcat(wchar_t,_serial_read_string)( str->begin, msize, serial );
01179 }

Here is the call graph for this function:

void wchar_t_serial_read_gstring ( ctl_mstring_wchar_t_grow *  str,
ctl_serial serial 
)

Read a serialized wide character string.

Parameters:
str Dynamically allocated string to read into
serial Serial parser

Definition at line 1134 of file serial.c.

References assertobjptr, chslength, ctl_gstring_resize, ctl_serial_peeksize(), and ppConcat.

01135 {
01136     size_t msize;
01137     assertobjptr(str);
01138     assertobjptr(serial);
01139     msize = chslength(wchar_t,ctl_serial_peeksize( serial ));
01140     ctl_gstring_resize(wchar_t, str, msize );
01141     ppConcat(wchar_t,_serial_read_string)( str->begin, msize, serial );
01142 }

Here is the call graph for this function:

void wchar_t_serial_read_sconst ( ctl_sconst_wchar_t *  str,
ctl_serial serial 
)

Read a serialized wide character string, pointing at data in ctl_serial.

Parameters:
str String constant type to receive beginning/ense of string
serial Serial parser

Definition at line 1239 of file serial.c.

References assertobjptr, ctl_sconst_init_pointers, ctl_serial_readsize(), and ctl_serial::curr.

01240 {
01241     size_t size;
01242     const uint8* pStr;
01243     assertobjptr(str);
01244     assertobjptr(serial);
01245     size = ctl_serial_readsize( serial );
01246     pStr = serial->curr;
01247     if( size & 1 )
01248         ctl_serial_except( serial, "ctl_serial_read_string: Odd size" );
01249     size>>=1;
01250     ctl_sconst_init_pointers(wchar_t, str, (wchar_t*)pStr, (wchar_t*)pStr + size );
01251     serial->curr += size;
01252 }

Here is the call graph for this function:

void wchar_t_serial_read_string ( wchar_t *  sz,
size_t  count,
ctl_serial serial 
)

Read a serialized wide character string.

Parameters:
sz Pointer to the string, which will either be NUL terminated, or end at szmax characters
count Maximum length of string
serial Serial parser

Definition at line 1088 of file serial.c.

References assertconst, assertobjptr, ctl_serial_readsize(), ctl_serial::curr, pointer_foreach, and uint16_serial_read().

01089 {
01090     size_t size;
01091     size_t readcount;
01092     assertconst(sz,sizeof(wchar_t));
01093     assertobjptr(serial);
01094     size = ctl_serial_readsize( serial );
01095     if( size & 1 )
01096         ctl_serial_except( serial, "ctl_serial_read_string: Odd size" );
01097     size>>=1;
01098     readcount = min(count,size);
01099     {
01100         pointer_foreach(wchar_t, sz, readcount, curr )
01101         {
01102             uint16 ch = 0;
01103             uint16_serial_read( &ch, serial );
01104             *curr = (wchar_t)ch;
01105         }
01106     }
01107     if( readcount < count )
01108         sz[readcount] = 0;
01109     serial->curr += (size-readcount)<<1;
01110 }

Here is the call graph for this function:

size_t wchar_t_serial_size_string ( const wchar_t *  sz,
size_t  szmax 
)

Measure a wide character string bound for serial data.

Parameters:
sz Pointer to the string, which will either be NUL terminated, or end at szmax characters
szmax Maximum length of string
Returns:
Number of bytes necessary to store the string

Definition at line 1007 of file serial.c.

References assertconst, and ctl_serial_size_size_size.

01008 {
01009     assertconst(sz,sizeof(wchar_t));
01010     {
01011         size_t len = cstrnlen(wchar_t)(sz,szmax) * 2;
01012         return ctl_serial_size_size_size( len );
01013     }
01014 }

void wchar_t_serial_write_string ( const wchar_t *  sz,
size_t  szmax,
ctl_serial serial 
)

Write a string to pre-allocated serial buffer.

Parameters:
sz String to write
szmax Maximum length of this string
serial Buffer/parse pointer

Definition at line 1042 of file serial.c.

References assert, assertconst, assertobjptr, ctl_serial_writesize(), ctl_serial::curr, ctl_serial::end, pointer_foreach_const, and uint16_serial_write().

01043 {
01044     size_t count;
01045     assertconst(sz,sizeof(wchar_t));
01046     assertobjptr(serial);
01047     count = cstrnlen(wchar_t)(sz,szmax);
01048     ctl_serial_writesize( count*2, serial );
01049     assert( serial->curr + (count*2) <= serial->end );
01050     {
01051         uint16 ch;
01052         pointer_foreach_const(wchar_t,sz,count, curr )
01053         {
01054             ch = *curr;
01055             uint16_serial_write( &ch, serial );
01056         }
01057     }
01058 }

Here is the call graph for this function:

bool wchar_t_xml_read_gstring ( ctl_mstring_wchar_t_grow *  str,
ctl_xmlread self,
const char *  label 
)

Read a string into fixed length C string buffer.

Parameters:
str String we're reading
self XML handler
label What this record is called
Returns:
true if the string was found

Definition at line 1627 of file xml.c.

References assertconst, assertobjptr, ctl_gstring_add, ctl_gstring_reset, ctl_sconst, ctl_sconst_foreach, ctl_xmlread_find(), ctl_xmlread_rawcontent(), and ctl_xmlread_translate_wchar_t().

01628 {
01629     assertobjptr(str);/* Inputs should be valid-looking */
01630     assertobjptr(self);
01631     assertconst( label,1 );
01632     if( ctl_xmlread_find( self, label ) )
01633     {
01634         ctl_sconst(char) body;
01635         ctl_xmlread_rawcontent( self, &body, true );
01636         {
01637             ctl_gstring_reset(wchar_t, str );
01638             {
01639                 ctl_sconst_foreach(char,&body,curr)
01640                 {
01641                     ctl_gstring_add(wchar_t, str, (wchar_t)*curr );
01642                 }
01643             }
01644             ctl_xmlread_translate_wchar_t( self, str->begin, str->end, true );
01645             str->end = str->begin + cstrlen(wchar_t)(str->begin);
01646         }
01647         return true;
01648     }
01649     return false;
01650 }

Here is the call graph for this function:

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.

Parameters:
buff Buffer for string
size Maximum size string may be
self XML handler
label What this record is called
Returns:
true if the string was found

Definition at line 1563 of file xml.c.

References assertconst, assertobjptr, assertptr, ctl_gstring, ctl_gstring_add, ctl_gstring_destroy, ctl_gstring_init, ctl_sconst, ctl_sconst_foreach, ctl_xmlread_find(), ctl_xmlread_rawcontent(), and ctl_xmlread_translate_wchar_t().

01564 {
01565     assertptr(buff,size*sizeof(wchar_t));/* Inputs should be valid-looking */
01566     assertobjptr( self );
01567     assertconst( label,1 );
01568     if( ctl_xmlread_find( self, label ) )
01569     {
01570         ctl_sconst(char) body;
01571         ctl_xmlread_rawcontent( self, &body, true );
01572         /*size = min( ctl_sconst_size(char,&body), size ); */
01573         {
01574             ctl_gstring(wchar_t) tmp;
01575             ctl_gstring_init(wchar_t, &tmp);
01576             {
01577                 ctl_sconst_foreach(char,&body,curr)
01578                 {
01579                     ctl_gstring_add(wchar_t, &tmp, (wchar_t)*curr );
01580                 }
01581             }
01582             ctl_xmlread_translate_wchar_t( self, tmp.begin, tmp.end, true );
01583             cstrncpy(wchar_t)(buff,tmp.begin,size);
01584             ctl_gstring_destroy(wchar_t, &tmp);
01585         }
01586         return true;
01587     }
01588     return false;
01589 }

Here is the call graph for this function:

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.

Parameters:
buff Buffer for string
size Maximum size string may be
xml XML handler
label What this record is called

Definition at line 1515 of file xml.c.

References assertconst, assertobjptr, ctl_xmlwrite_endtag(), ctl_xmlwrite_generaltag(), and ctl_xmlwrite_string_wchar_t().

01516 {
01517     assertconst(buff,size*sizeof(wchar_t));/* Inputs should be valid-looking */
01518     assertobjptr( xml );
01519     assertconst( label,1 );
01520     ctl_xmlwrite_generaltag( xml, "string_wchar_t", label );
01521     ctl_xmlwrite_string_wchar_t( xml, buff, buff+size );
01522     ctl_xmlwrite_endtag( xml, "string_wchar_t", label );
01523 }

Here is the call graph for this function:


Generated on Fri Jan 2 15:28:36 2009 for Squat by  doxygen 1.5.6