18 #define realpath( a, b ) GetFullPathName( a, PATH_MAX, b, NULL )
19 #define strtoll _strtoi64
20 typedef SSIZE_T ssize_t;
27 #if defined __cplusplus
96 ssize_t count,
n =
sizeof(
buffer ) - 1;
102 f =
open( fileName, O_RDONLY );
107 while( ( count = read( f, buffer, n ) ) > 0 ) {
176 "status = %d\nXML_Error code = %d\nXML_ErrorString = %s\nerror line, column = %d, %d",
xDataXML_errXMLParser,
205 for( ; element != NULL; element = next ) {
206 next = element->
next;
263 size_t needSize = text->
length + len + 1, l;
267 if( needSize < 8 ) needSize = 8;
271 if( l < 100 ) l = 100;
279 strncpy( p, s, len );
315 int i,
n, status = 1;
318 char const **pAttris;
323 if( element == NULL )
return( 1 );
330 element->
next = NULL;
331 if( ( element->
name = (
char *)
smr_malloc2( doc->
smr, strlen( name ) + 1, 0,
"name" ) ) == NULL ) {
335 strcpy( element->
name, name );
341 for( i = 0, lens = 0, pAttris = attris; *pAttris; i++, pAttris++ ) lens += strlen( *pAttris ) + 1;
353 for( i = 0, pAttris = attris; ( i <
n ) && status; i++, a++, pAttris++ ) {
354 lens = strlen( *pAttris ) + 1;
356 strcpy( p, *pAttris );
359 lens = strlen( *pAttris ) + 1;
361 strcpy( p, *pAttris );
363 if( !strcmp(
"index", a->name ) ) {
364 element->
index = (
int) strtoll( a->value, &e, 10 );
434 return( item->
mode );
462 return( item->
mode );
471 for( i = 0; i < attributes->
number; i++ ) {
472 if( !strcmp( attributes->
attributes[i].
name, name ) )
return( 1 );
490 for( i = 0; i < attributes->
number; i++ ) {
507 return( attributes->
number );
514 if( index >= attributes->
number )
return( NULL );
547 "element %s is not xData", element->
fullName );
583 if( xDT->
start < 0 ) {
610 "missing required attribute '%s'", name );
616 "could not convert attribute %s's value = %s to an integer", name, value );
633 "missing required attribute '%s'", name );
636 *d = strtod( value, &e );
639 "could not convert attribute %s's values = %s to a double", name, value );
672 if( !strcmp( child->
name, tagName ) ) {
692 1,
"element %s does not have sub-element named %s", element->
fullName, name ); }
693 else if( list->
n > 1 ) {
695 "element %s contains more than one sub-element named %s", element->
fullName, name ); }
720 name = element->
name;
721 size = (
int) strlen( name ) + 1;
737 s = (
char *)
smr_malloc2( smr, n + 1, 0,
"traceback string" );
741 size = (
int) strlen( name ) + 1;
755 if( xDT->
ID == NULL ) {
758 else if( xDT->
ID != ID ) {
760 "Element %s is not xData object of ID %s but %s", xDT->
element->
fullName, ID, xDT->
ID );
762 return( xDT->
ID == ID );
787 if( fileName != NULL ) {
789 if( realpath( fileName, realPath ) != NULL ) {
810 if( doc == NULL )
return( NULL );
849 else if( smrUserInterface->
doc->
fileName != NULL ) {
862 int status = 1,
n =
sizeof(
tmp );
864 for( s = c; *s != 0; s++ )
if( !isspace( *s ) )
break;
869 if( *endings == 0 )
while( isspace( **e ) ) (*e)++;
873 if( *endings == 0 ) {
877 if( strchr( endings, **e ) == NULL ) {
895 int status = 1,
n =
sizeof(
tmp );
897 for( s = c; *s != 0; s++ )
if( !isspace( *s ) )
break;
898 *value = strtod( s, e );
903 if( *endings == 0 )
while( isspace( **e ) ) (*e)++;
907 if( *endings == 0 ) {
911 if( strchr( endings, **e ) == NULL ) {
942 if( strlen( In ) > size ) {
943 strncpy( Out, In, size - 5 );
945 strcat( Out,
" ..." );
963 for( i = 0; 1; i++ ) {
972 if( xDataValue == NULL ) {
996 printf(
"Unsupported xData type '%s' in element '%s'\n", xDataValue, XE->
name );
999 "Unsupported xData type = \"%s\"", xDataValue );
1015 return( xDI->
data );
1018 #if defined __cplusplus
int xDataXML_stringTo_double(statusMessageReporting *smr, void *smrUserInterface, char const *c, double *value, char const *endings, char **e)
char const * xDataTOM_KalbachMann_ID
int xDataXML_xDataTypeConvertAttributes(statusMessageReporting *smr, xDataXML_element *element)
xDataTOM_Int xDataXML_convertAttributeTo_xDataTOM_Int(statusMessageReporting *smr, xDataXML_element *element, char const *name, xDataTOM_Int *n, int required)
int xDataXML_axesElememtToTOM(statusMessageReporting *smr, xDataXML_element *XE, xDataTOM_axes *axes)
int xDataXML_XYsToTOM(statusMessageReporting *smr, xDataXML_element *XE, xDataTOM_element *TE)
XML_ParserFree(XML_Parser parser)
XML_ParserCreate(const XML_Char *encoding)
char const * xDataXML_getFileName(xDataXML_document *doc)
xDataXML_element * parentElement
char const * xDataTOM_regionsW_XYs_LegendreSeries_ID
std::vector< ExP01TrackerHit * > a
XML_Size XMLCALL XML_GetCurrentLineNumber(XML_Parser parser)
xDataXML_element * xDataXML_getFirstElement(xDataXML_element *element)
void xDataXML_freeElementList(statusMessageReporting *smr, xDataXML_elementList *list)
static char * xDataXML_getTraceback(statusMessageReporting *smr, xDataXML_element *element)
static void * xDataXML_freeElement(statusMessageReporting *smr, xDataXML_element *element)
static enum xDataXML_errorCodes xDataXML_parseGetCurrentPosition(xDataXML_document *doc, xDataXML_docInfo *docInfo)
#define smr_allocateCopyString2(smr, s, forItem)
#define smr_realloc2(smr, old, size, forItem)
#define smr_setReportError2(smr, libraryID, code, fmt,...)
XML_SetUserData(XML_Parser parser, void *userData)
char const * xDataXML_getRealFileName(xDataXML_document *doc)
void * xDataXML_initializeData(statusMessageReporting *smr, xDataXML_element *XE, xDataTOM_element *TE, char const *ID, size_t size)
static int xDataXML_addElementToRoot(statusMessageReporting *smr, xDataXML_rootElement *parentRoot, char const *name, char const **attris)
struct xDataXML_elementList_s xDataXML_elementList
xDataXML_element * xDataXML_getNextElement(xDataXML_element *element)
XML_Size XMLCALL XML_GetCurrentColumnNumber(XML_Parser parser)
XML_ErrorString(enum XML_Error code)
xDataXMLType xDataTypeInfo
int xDataXML_addToAccessed(statusMessageReporting *smr, xDataXML_element *element, int increment)
struct xDataXML_attribute_s xDataXML_attribute
xDataXML_rootElement root
static void xDataXML_freeElementItems(statusMessageReporting *smr, xDataXML_element *element)
char const * xDataTOM_XYs_ID
xDataXML_rootElement * currentRoot
int xDataXML_stringTo_xDataTOM_Int(statusMessageReporting *smr, void *smrUserInterface, char const *c, xDataTOM_Int *value, char const *endings, char **e)
static void XMLCALL xDataXML_parseEndElement(void *userData, char const *name)
enum xDataXML_errorCodes error
xDataXML_element * element
int xDataXML_numberOfElementsByTagName(statusMessageReporting *smr, xDataXML_element *element, char const *tagName)
void * xDataXML_get_smrUserInterfaceFromElement(xDataXML_element *element)
enum xDataXML_itemMode mode
void * xDataTOM_freeTOM(statusMessageReporting *smr, xDataTOM_TOM **TOM)
static int xDataXML_smrUserInterfaceFree(xDataXML_document *doc)
xDataXML_document * xDataXML_importFile2(statusMessageReporting *smr, char const *fileName)
xDataTOM_xDataInfo xDataInfo
xDataXML_rootElement childrenRoot
int xDataXML_V_W_XYsToTOM(statusMessageReporting *smr, xDataXML_element *XE, xDataTOM_element *TE)
xDataXML_element * currentChild
int xDataXML_isAttributeInList(xDataXML_attributionList *attributes, char const *name)
static char const * xDataXML_shortStringForMessage(size_t size, char *Out, char const *In)
char const * xDataTOM_polynomial_ID
xDataXML_element * parentElement
#define smr_malloc2(smr, size, zero, forItem)
int xDataXML_W_XYsToTOM(statusMessageReporting *smr, xDataXML_element *XE, xDataTOM_element *TE)
xDataXML_elementListItem * items
XML_SetCharacterDataHandler(XML_Parser parser, XML_CharacterDataHandler handler)
void * xData_initializeData(statusMessageReporting *smr, xDataTOM_element *TE, char const *ID, size_t size)
const XML_Char int const XML_Char * value
int xDataXML_getAccessed(statusMessageReporting *smr, xDataXML_element *element)
xDTXML_toStringFunction toString
enum xDataXML_status status
enum xDataXML_itemMode xDataXML_getFirstItem(xDataXML_element *element, xDataXML_item *item)
int smr_isOk(statusMessageReporting *smr)
xDataXML_document * xData_doc
int xDataXML_W_XYs_LegendreSeriesToTOM(statusMessageReporting *smr, xDataXML_element *XE, xDataTOM_element *TE)
char * xDataXML_getAttributesValue(xDataXML_attributionList *attributes, char const *name)
xDataXML_rootElement * parentRoot
static xDataXML_document * xDataXML_mallocDoc(statusMessageReporting *smr)
static int xDataXML_smrUserInterfaceInitialize(xDataXML_document *doc)
enum xDataXML_xDataType status
printf("%d Experimental points found\n", nlines)
typedef int(XMLCALL *XML_NotStandaloneHandler)(void *userData)
int xDataXML_attributeListLength(xDataXML_attributionList *attributes)
static void xDataXML_initializeRootElement(xDataXML_document *doc, xDataXML_rootElement *re, xDataXML_element *parentElement, int depth)
char const * xDataTOM_V_W_XYs_ID
xDataXML_smr smrUserInterface
XML_Parse(XML_Parser parser, const char *s, int len, int isFinal)
xDataXML_element * element
xDataXML_document * xDataXML_getElementsDocument(xDataXML_element *element)
void * xDataXML_freeDoc(statusMessageReporting *smr, xDataXML_document *doc)
#define smr_setReportError2p(smr, libraryID, code, fmt)
void * xDataXML_get_smrUserInterfaceFromDocument(xDataXML_document *doc)
char const * xDataTOM_regionsXYs_ID
int xDataXML_isAttributeInElement(xDataXML_element *element, char const *name)
static void XMLCALL xDataXML_parseStartElement(void *userData, char const *name, char const **attris)
xDataTOM_TOM * xDataXML_importFile(statusMessageReporting *smr, char const *fileName)
xDTXML_toDataFunction toData
xDataXML_attributionList attributes
void * smr_freeMemory(void **p)
static char * xDataXML_getTraceback2(statusMessageReporting *smr, xDataXML_rootElement *parentRoot, int n)
static int xDataXML_parse(xDataXML_document *doc, char const *s)
int xDataXML_regionsW_XYs_LegendreSeriesToTOM(statusMessageReporting *smr, xDataXML_element *XE, xDataTOM_element *TE)
static int xDataXML_endXMLParsing(statusMessageReporting *smr, xDataXML_document *doc)
static char * xDataXML_smrUserInterface(void *userData)
static int xDataXML_parseInitializeText(xDataXML_document *doc, xDataXML_text *text)
int xDataTOME_addAttribute(statusMessageReporting *smr, xDataTOM_element *element, char const *name, char const *value)
static int xDataXML_initializeDoc(statusMessageReporting *smr, xDataXML_document *doc)
int xDataXML_KalbachMannToTOM(statusMessageReporting *smr, xDataXML_element *XE, xDataTOM_element *TE)
static int xDataXML_init_xDataTypeNone(xDataXMLType *xDT, xDataXML_element *element)
xDataXML_attribute * xDataXML_attributeByIndex(xDataXML_attributionList *attributes, int index)
int xDataXML_is_xDataType(statusMessageReporting *smr, xDataXMLType *xDT, char const *const type, int setMsg)
static int xDataXML_setFileName(statusMessageReporting *smr, xDataXML_document *doc, char const *fileName)
xDataXML_element * xDataXML_getDocumentsElement(xDataXML_document *doc)
xDataXML_element * element
int xDataXML_convertAttributeToDouble(statusMessageReporting *smr, xDataXML_element *element, char const *name, double *d, int required)
int xDataXML_parseIsError(xDataXML_document *doc)
xDataTOM_element * xDataTOM_addElementInElement(statusMessageReporting *smr, xDataTOM_element *parent, int index, char const *name)
char * smr_allocateFormatMessage(char const *fmt,...)
static void XMLCALL xDataXML_parseCharacterData(void *userData, XML_Char const *s, int len)
int xDataXML_regionsXYsToTOM(statusMessageReporting *smr, xDataXML_element *XE, xDataTOM_element *TE)
xDataXML_elementList * xDataXML_getElementsByTagName(statusMessageReporting *smr, xDataXML_element *element, char const *tagName)
xDataXML_rootElement * parentRoot
xDataXML_attribute * attributes
enum xDataXML_itemMode xDataXML_getNextItem(xDataXML_item *item)
static int xDataXML_constructTOM(statusMessageReporting *smr, xDataTOM_element *TE, xDataXML_element *element)
char const * xDataTOM_W_XYs_ID
XML_GetErrorCode(XML_Parser parser)
char const * xDataTOM_W_XYs_LegendreSeries_ID
int xDataXML_polynomialToTOM(statusMessageReporting *smr, xDataXML_element *XE, xDataTOM_element *TE)
statusMessageReporting * smr
#define smr_setReportError3p(smr, userInterface, libraryID, code, fmt)
xDataXML_element * children
#define smr_setReportError3(smr, userInterface, libraryID, code, fmt,...)
smr_userInterface smrUserInterface
xDataTOM_TOM * xDataTOM_mallocTOM(statusMessageReporting *smr)
int xDataTOM_setFileNameTOM(statusMessageReporting *smr, xDataTOM_TOM *doc, const char *fileName)
char const * xDataXML_getAttributesValueInElement(xDataXML_element *element, char const *name)
int xDataTOM_smrLibraryID
xDataXML_element * xDataXML_getOneElementByTagName(statusMessageReporting *smr, xDataXML_element *element, char *name, int required)
int xDataXML_getCommonData(statusMessageReporting *smr, xDataXML_element *element, xDataTOM_Int *index, xDataTOM_Int *start, xDataTOM_Int *end, xDataTOM_Int *length)
xDTXML_releaseFunction release
int xDataXML_V_W_XYs_LegendreSeriesToTOM(statusMessageReporting *smr, xDataXML_element *XE, xDataTOM_element *TE)
char const * xDataTOM_V_W_XYs_LegendreSeries_ID
XML_SetElementHandler(XML_Parser parser, XML_StartElementHandler start, XML_EndElementHandler end)