/** * VTF3 - Vampir Trace Format handling 3.

* * Copyright (c) 1999-2004 TU Dresden * Center for High Performance Computing (ZHR) * * @name vtf3.c * * @version $Revision: 1.5 $
* $Date: 2005/10/24 17:07:56 $
* $Author: amorris $ * * @author Stephan Seidl (ZHR)
* Sven Bauer (ZHR) */ /*****************************************************************************/ /* It is exciting to be fast, and, it is easy, if the teacher was the time. Compile with `-O3' or an appropriate level. For some application hints, perform `grep -n Note ...'. */ /*****************************************************************************/ #ifdef __linux #define _LARGEFILE_SOURCE #define _FILE_OFFSET_BITS 64 #endif /* __linux */ #include #include #include /* This is for `size_t'. */ #include #include "vtf3.h" /*****************************************************************************/ /* Note for VAMPIR, VPTMERGE and other applications. On memory allocation failures, VTF3 executes a statement sequence, which is defined by the following macro. After that, VTF3 does unconditionally exit with 127. */ #if (1) #ifndef VTF3_NOMEM_GOOD_BYE_INFO #define VTF3_NOMEM_GOOD_BYE_INFO \ { \ (void) fprintf (stderr, "VTF3: No more memory\n"); \ (void) fflush (stderr); \ } #endif #endif /* Another example could be the following one, but, of course, suppress `-Wnested-externs' warning types when using the GCC. */ #if (0) #ifndef VTF3_NOMEM_GOOD_BYE_INFO #define VTF3_NOMEM_GOOD_BYE_INFO \ { \ extern void vampir_nomem_good_bye_info (void); \ (void) vampir_nomem_good_bye_info (); \ } #endif #endif /*****************************************************************************/ /* Note for VAMPIR, VPTMERGE and other applications. For strict output conformance, define this, but, it is not a good idea. Especially, the new standard ASCII format has some advantages, and the the parsers here are well-prepared to manage all the situations. */ #if (0) #ifndef VTF3_LEGACY_OUTPUT #define VTF3_LEGACY_OUTPUT #endif #endif /*****************************************************************************/ /* The buffer dimensions. */ #define VTF3_CONST_IOBUF_DIM ( 2097152) #define VTF3_CONST_MAX_RECBUF_DIM (10000000) #define VTF3_CONST_MAX_STACK_DIM ( 200) /*****************************************************************************/ static char rcsid[] = "@(#) $Id: vtf3.c,v 1.5 2005/10/24 17:07:56 amorris Exp $"; /*****************************************************************************/ /* The VTF3 version string buffer. */ static char vtfversionbuf [sizeof (rcsid) / sizeof (rcsid[0]) + 26]; /* Global character translation tables. */ static int vtfdigit [256]; static unsigned int vtfhexdig [256]; static int vtfletter [256]; static int vtfspace [256]; static char vtfupper [256]; /* Global control values. */ static unsigned int vtfbinaryheaderasrecordlength = 0; static int vtfisinitialized = 0; static int vtffprtype = 0; static int vtfunrecognizablehandlerindex = 0; static int vtfuptohandlerindex = 0; static int vtfversionnumber = 0; static unsigned int vtfzebra = 0; /* The array containing all the define-type record types, except `DEFUNMERGED'. */ static int defrecordtypes [] = { VTF3_RECTYPE_DEFVERSION, VTF3_RECTYPE_DEFCREATOR, VTF3_RECTYPE_DEFSYSCPUNUMS, VTF3_RECTYPE_DEFSYSCPUNAMES, VTF3_RECTYPE_DEFTHREADNUMS, VTF3_RECTYPE_DEFCPUNAME, VTF3_RECTYPE_DEFCLSTR, VTF3_RECTYPE_DEFCPUGRP, VTF3_RECTYPE_DEFSCLFILE, VTF3_RECTYPE_DEFSCL, VTF3_RECTYPE_DEFACT, VTF3_RECTYPE_DEFSTATE, VTF3_RECTYPE_DEFACT_OBSOL, VTF3_RECTYPE_DEFSTATE_OBSOL, VTF3_RECTYPE_DEFCPUREGCLASS, VTF3_RECTYPE_DEFCLSTRREGCLASS, VTF3_RECTYPE_DEFSAMPCLASS, VTF3_RECTYPE_DEFCPUREG, VTF3_RECTYPE_DEFCLSTRREG, VTF3_RECTYPE_DEFSAMP, VTF3_RECTYPE_DEFCOMMUNICATOR, VTF3_RECTYPE_DEFMSGNAME, VTF3_RECTYPE_DEFDATASTRUC, VTF3_RECTYPE_DEFGLOBALOP, VTF3_RECTYPE_DEFHIST, VTF3_RECTYPE_DEFHISTGRP, VTF3_RECTYPE_DEFREDFUNC_OBSOL, VTF3_RECTYPE_DEFIOFILE, VTF3_RECTYPE_DEFKPARREG, VTF3_RECTYPE_DEFCLKPERIOD, VTF3_RECTYPE_DEFTIMEOFFSET, VTF3_RECTYPE_DEFPATTERNSHAPE, VTF3_RECTYPE_DEFPATTERN, VTF3_RECTYPE_DEFOPENMPTYPE, VTF3_RECTYPE_DEFOPENMPNAME, VTF3_RECTYPE_DEFDATASTRUC, VTF3_RECTYPE_DEFHIST, VTF3_RECTYPE_DEFHISTGRP }; /* The array containing all the record types. */ static int recordtypes [] = { VTF3_RECTYPE_CLSTRREGVAL, VTF3_RECTYPE_COMMENT, VTF3_RECTYPE_CPUREGVAL, VTF3_RECTYPE_DEFACT, VTF3_RECTYPE_DEFACT_OBSOL, VTF3_RECTYPE_DEFCLKPERIOD, VTF3_RECTYPE_DEFCLSTR, VTF3_RECTYPE_DEFCLSTRREG, VTF3_RECTYPE_DEFCLSTRREGCLASS, VTF3_RECTYPE_DEFCOMMUNICATOR, VTF3_RECTYPE_DEFCPUGRP, VTF3_RECTYPE_DEFCPUNAME, VTF3_RECTYPE_DEFCPUREG, VTF3_RECTYPE_DEFCPUREGCLASS, VTF3_RECTYPE_DEFCREATOR, VTF3_RECTYPE_DEFDATASTRUC, VTF3_RECTYPE_DEFGLOBALOP, VTF3_RECTYPE_DEFHIST, VTF3_RECTYPE_DEFHISTGRP, VTF3_RECTYPE_DEFIOFILE, VTF3_RECTYPE_DEFKPARREG, VTF3_RECTYPE_DEFMSGNAME, VTF3_RECTYPE_DEFOPENMPNAME, VTF3_RECTYPE_DEFOPENMPTYPE, VTF3_RECTYPE_DEFPATTERN, VTF3_RECTYPE_DEFPATTERNSHAPE, VTF3_RECTYPE_DEFREDFUNC_OBSOL, VTF3_RECTYPE_DEFSAMP, VTF3_RECTYPE_DEFSAMPCLASS, VTF3_RECTYPE_DEFSCL, VTF3_RECTYPE_DEFSCLFILE, VTF3_RECTYPE_DEFSTATE, VTF3_RECTYPE_DEFSTATE_OBSOL, VTF3_RECTYPE_DEFSYSCPUNAMES, VTF3_RECTYPE_DEFSYSCPUNUMS, VTF3_RECTYPE_DEFTHREADNUMS, VTF3_RECTYPE_DEFTIMEOFFSET, VTF3_RECTYPE_DEFUNMERGED, VTF3_RECTYPE_DEFVERSION, VTF3_RECTYPE_DOWNTO, VTF3_RECTYPE_EXCHANGE, VTF3_RECTYPE_EXCHANGE_OBSOL, VTF3_RECTYPE_FILEIOBEGIN, VTF3_RECTYPE_FILEIOEND, VTF3_RECTYPE_GLOBALOP, VTF3_RECTYPE_HIST, VTF3_RECTYPE_KPARREGBARSUM, VTF3_RECTYPE_KPARREGBEGIN, VTF3_RECTYPE_KPARREGEND, VTF3_RECTYPE_MUTEXACQUIRE, VTF3_RECTYPE_MUTEXRELEASE, VTF3_RECTYPE_OPENMPENTER, VTF3_RECTYPE_OPENMPLEAVE, VTF3_RECTYPE_PARREG, VTF3_RECTYPE_PATTERN, VTF3_RECTYPE_RECVMSG, VTF3_RECTYPE_SAMP, VTF3_RECTYPE_SENDMSG, VTF3_RECTYPE_SRCINFO_OBSOL, VTF3_RECTYPE_UNRECOGNIZABLE, VTF3_RECTYPE_UPFROM, VTF3_RECTYPE_UPTO }; /* The array containing all the standard ASCII record keywords. */ static const char *stdasciikeywords [sizeof (recordtypes) / sizeof (recordtypes[0])] = { /* CLSTRREGVAL */ "CLSTRREGVAL", /* COMMENT */ "C", /* CPUREGVAL */ "CPUREGVAL", /* DEFACT */ "DEFACT", /* DEFACT_OBSOL */ "DEFTOKEN", /* DEFCLKPERIOD */ "CLKPERIOD", /* DEFCLSTR */ "DEFCLUSTER", /* DEFCLSTRREG */ "DEFCLSTRREG", /* DEFCLSTRREGCLASS */ "DEFCLSTRREGCLASS", /* DEFCOMMUNICATOR */ "COMDEF", /* DEFCPUGRP */ "DEFGROUP", /* DEFCPUNAME */ "CPUSYM", /* DEFCPUREG */ "DEFCPUREG", /* DEFCPUREGCLASS */ "DEFCPUREGCLASS", /* DEFCREATOR */ "CREATOR", /* DEFDATASTRUC */ "DEFDATASTRUC", /* DEFGLOBALOP */ "GLOBALOPTOKEN", /* DEFHIST */ "DEFHIST", /* DEFHISTGRP */ "DEFHISTGRP", /* DEFIOFILE */ "IOFILE", /* DEFKPARREG */ "DEFKPARREG", /* DEFMSGNAME */ "MSGTYPE", /* DEFOPENMPNAME */ "DEFOPENMPNAME", /* DEFOPENMPTYPE */ "DEFOPENMP", /* DEFPATTERN */ "DEFPATTERN", /* DEFPATTERNSHAPE */ "DEFPATTERNSHAPE", /* DEFREDFUNC_OBSOL */ "REDFUNC", /* DEFSAMP */ "DEFSAMP", /* DEFSAMPCLASS */ "DEFSAMPCLASS", /* DEFSCL */ "DEFSCL", /* DEFSCLFILE */ "FILETOKEN", /* DEFSTATE */ "DEFSTATE", /* DEFSTATE_OBSOL */ "SYMBOL", /* DEFSYSCPUNAMES */ "CPUNAMES", /* DEFSYSCPUNUMS */ "NCPUS", /* DEFTHREADNUMS */ "DEFTHREADNUMS", /* DEFTIMEOFFSET */ "TIMEOFFSET", /* DEFUNMERGED */ "UNMERGED", /* DEFVERSION */ "VERSION", /* DOWNTO */ "DOWNTO", /* EXCHANGE */ "EXCHEXT", /* EXCHANGE_OBSOL */ "EXCHANGE", /* FILEIOBEGIN */ "FILEIOBEGIN", /* FILEIOEND */ "FILEIOEND", /* GLOBALOP */ "GLOBALOP", /* HIST */ "HIST", /* KPARREGBARSUM */ "KPARREGBARSUM", /* KPARREGBEGIN */ "KPARREGBEGIN", /* KPARREGEND */ "KPARREGEND", /* MUTEXACQUIRE */ "MUTEXACQUIRE", /* MUTEXRELEASE */ "MUTEXRELEASE", /* OPENMPENTER */ "OPENMPENTER", /* OPENMPLEAVE */ "OPENMPLEAVE", /* PARREG */ "PARREG", /* PATTERN */ "PATTERN", /* RECVMSG */ "RECVMSG", /* SAMP */ "SAMP", /* SENDMSG */ "SENDMSG", /* SRCINFO_OBSOL */ "SRC", /* UNRECOGNIZABLE */ "UNRECOGNIZABLE", /* UPFROM */ "UPFROM", /* UPTO */ "UPTO" }; /* The standard ASCII parser keyword array. */ static const char *stdasciikwparser [sizeof (recordtypes) / sizeof (recordtypes[0])]; /* Maps standard ASCII parser keyword index to handler index. */ static int stdasciikwparser2hi [sizeof (recordtypes) / sizeof (recordtypes[0])]; /* The array containing all the fast ASCII record keywords. */ static const char *fstasciikeywords [sizeof (recordtypes) / sizeof (recordtypes[0])] = { /* CLSTRREGVAL */ "VC", /* COMMENT */ "CC", /* CPUREGVAL */ "VP", /* DEFACT */ "DEFACT", /* DEFACT_OBSOL */ "DEFTOKEN", /* DEFCLKPERIOD */ "CLKPERIOD", /* DEFCLSTR */ "DEFCLUSTER", /* DEFCLSTRREG */ "DEFCLSTRREG", /* DEFCLSTRREGCLASS */ "DEFCLSTRREGCLASS", /* DEFCOMMUNICATOR */ "COMDEF", /* DEFCPUGRP */ "DEFGROUP", /* DEFCPUNAME */ "CPUSYM", /* DEFCPUREG */ "DEFCPUREG", /* DEFCPUREGCLASS */ "DEFCPUREGCLASS", /* DEFCREATOR */ "CREATOR", /* DEFDATASTRUC */ "DEFDATASTRUC", /* DEFGLOBALOP */ "GLOBALOPTOKEN", /* DEFHIST */ "DEFHIST", /* DEFHISTGRP */ "DEFHISTGRP", /* DEFIOFILE */ "IOFILE", /* DEFKPARREG */ "DEFKPARREG", /* DEFMSGNAME */ "MSGTYPE", /* DEFOPENMPNAME */ "DEFOPENMPNAME", /* DEFOPENMPTYPE */ "DEFOPENMP", /* DEFPATTERN */ "DEFPATTERN", /* DEFPATTERNSHAPE */ "DEFPATTERNSHAPE", /* DEFREDFUNC_OBSOL */ "REDFUNC", /* DEFSAMP */ "DEFSAMP", /* DEFSAMPCLASS */ "DEFSAMPCLASS", /* DEFSCL */ "DEFSCL", /* DEFSCLFILE */ "FILETOKEN", /* DEFSTATE */ "DEFSTATE", /* DEFSTATE_OBSOL */ "SYMBOL", /* DEFSYSCPUNAMES */ "CPUNAMES", /* DEFSYSCPUNUMS */ "NCPUS", /* DEFTHREADNUMS */ "DEFTHREADNUMS", /* DEFTIMEOFFSET */ "TIMEOFFSET", /* DEFUNMERGED */ "UNMERGED", /* DEFVERSION */ "VERSION", /* DOWNTO */ "XD", /* EXCHANGE */ "XX", /* EXCHANGE_OBSOL */ "EXCHANGE", /* FILEIOBEGIN */ "FB", /* FILEIOEND */ "FE", /* GLOBALOP */ "GO", /* HIST */ "HIST", /* KPARREGBARSUM */ "KPARREGBARSUM", /* KPARREGBEGIN */ "KPARREGBEGIN", /* KPARREGEND */ "KPARREGEND", /* MUTEXACQUIRE */ "MUTEXACQUIRE", /* MUTEXRELEASE */ "MUTEXRELEASE", /* OPENMPENTER */ "OPENMPENTER", /* OPENMPLEAVE */ "OPENMPLEAVE", /* PARREG */ "PARREG", /* PATTERN */ "PATTERN", /* RECVMSG */ "MR", /* SAMP */ "VS", /* SENDMSG */ "MS", /* SRCINFO_OBSOL */ "SRC", /* UNRECOGNIZABLE */ "UR", /* UPFROM */ "XF", /* UPTO */ "XU" }; /* The fast ASCII parser keyword array. */ static const char *fstasciikwparser [sizeof (recordtypes) / sizeof (recordtypes[0])]; /* Maps fast ASCII parser keyword index to handler index. */ static int fstasciikwparser2hi [sizeof (recordtypes) / sizeof (recordtypes[0])]; /* The array containing all the default handlers, i.e. the copy handlers. */ static VTF3_handler_t copyhandlers [sizeof (recordtypes) / sizeof (recordtypes[0])] = { (VTF3_handler_t) VTF3_WriteClstrregval, (VTF3_handler_t) VTF3_WriteComment, (VTF3_handler_t) VTF3_WriteCpuregval, (VTF3_handler_t) VTF3_WriteDefact, (VTF3_handler_t) VTF3_WriteDefact_obsol, (VTF3_handler_t) VTF3_WriteDefclkperiod, (VTF3_handler_t) VTF3_WriteDefclstr, (VTF3_handler_t) VTF3_WriteDefclstrreg, (VTF3_handler_t) VTF3_WriteDefclstrregclass, (VTF3_handler_t) VTF3_WriteDefcommunicator, (VTF3_handler_t) VTF3_WriteDefcpugrp, (VTF3_handler_t) VTF3_WriteDefcpuname, (VTF3_handler_t) VTF3_WriteDefcpureg, (VTF3_handler_t) VTF3_WriteDefcpuregclass, (VTF3_handler_t) VTF3_WriteDefcreator, (VTF3_handler_t) VTF3_WriteDefdatastruc, (VTF3_handler_t) VTF3_WriteDefglobalop, (VTF3_handler_t) VTF3_WriteDefhist, (VTF3_handler_t) VTF3_WriteDefhistgrp, (VTF3_handler_t) VTF3_WriteDefiofile, (VTF3_handler_t) VTF3_WriteDefkparreg, (VTF3_handler_t) VTF3_WriteDefmsgname, (VTF3_handler_t) VTF3_WriteDefopenmpname, (VTF3_handler_t) VTF3_WriteDefopenmptype, (VTF3_handler_t) VTF3_WriteDefpattern, (VTF3_handler_t) VTF3_WriteDefpatternshape, (VTF3_handler_t) VTF3_WriteDefredfunc_obsol, (VTF3_handler_t) VTF3_WriteDefsamp, (VTF3_handler_t) VTF3_WriteDefsampclass, (VTF3_handler_t) VTF3_WriteDefscl, (VTF3_handler_t) VTF3_WriteDefsclfile, (VTF3_handler_t) VTF3_WriteDefstate, (VTF3_handler_t) VTF3_WriteDefstate_obsol, (VTF3_handler_t) VTF3_WriteDefsyscpunames, (VTF3_handler_t) VTF3_WriteDefsyscpunums, (VTF3_handler_t) VTF3_WriteDefthreadnums, (VTF3_handler_t) VTF3_WriteDeftimeoffset, (VTF3_handler_t) VTF3_WriteDefunmerged, (VTF3_handler_t) VTF3_WriteDefversion, (VTF3_handler_t) VTF3_WriteDownto, (VTF3_handler_t) VTF3_WriteExchange, (VTF3_handler_t) VTF3_WriteExchange_obsol, (VTF3_handler_t) VTF3_WriteFileiobegin, (VTF3_handler_t) VTF3_WriteFileioend, (VTF3_handler_t) VTF3_WriteGlobalop, (VTF3_handler_t) VTF3_WriteHist, (VTF3_handler_t) VTF3_WriteKparregbarsum, (VTF3_handler_t) VTF3_WriteKparregbegin, (VTF3_handler_t) VTF3_WriteKparregend, (VTF3_handler_t) VTF3_WriteMutexacquire, (VTF3_handler_t) VTF3_WriteMutexrelease, (VTF3_handler_t) VTF3_WriteOpenmpenter, (VTF3_handler_t) VTF3_WriteOpenmpleave, (VTF3_handler_t) VTF3_WriteParreg, (VTF3_handler_t) VTF3_WritePattern, (VTF3_handler_t) VTF3_WriteRecvmsg, (VTF3_handler_t) VTF3_WriteSamp, (VTF3_handler_t) VTF3_WriteSendmsg, (VTF3_handler_t) VTF3_WriteSrcinfo_obsol, (VTF3_handler_t) VTF3_WriteUnrecognizable, (VTF3_handler_t) VTF3_WriteUpfrom, (VTF3_handler_t) VTF3_WriteUpto }; /* The stack head cell. */ typedef struct { unsigned int cpuid; int stackcurr; int *stack0; } stackhead_t; /* The file control block (FCB). */ typedef struct { unsigned int zebra1; char **charptrvector; char *charvector; void **firsthandlerargs; VTF3_handler_t *handlers; int *intvector; int *intvector2; char *iobuffer; char *iobufferbeyond; char *iobuffereof; char *iobufferpos; FILE *pfile; char *recbuffer; char *recbufferbeyond; char *recbufferpos; stackhead_t *stackhead0; int *stroffsetvectorbeyond; int *stroffsetvectorstart; unsigned char *u4vector; unsigned int *uintvector; void *zfile; struct { int type; int numchars; char *record; } rcb; double lastvalidtime; int charptrvectordim; unsigned int charvectordim; int didupfromsubstitution; int filecompressiontype; int fileformat; int filehasbeenclosed; size_t headerbytesnotcounted; int intvector2dim; int intvectordim; int isawexchangetypeto; int isawgroupexchanges; int isoutput; int legacyascii; unsigned int stackheaddim; unsigned int stackheaddimalloced; int stroffsetvectordim; int substitudeupfrom; int u4vectordim; int uintvectordim; size_t zfileposition; size_t zfilepositionfrmr; unsigned int zebra2; } fcb_t; /* The prototypes for the standard ASCII format parsers. */ static void StdAsciiParserClstrregval (fcb_t *, int, int, int, double); static void StdAsciiParserComment (fcb_t *, int, int, int, double); static void StdAsciiParserCpuregval (fcb_t *, int, int, int, double); static void StdAsciiParserDefact (fcb_t *, int, int, int, double); static void StdAsciiParserDefact_obsol (fcb_t *, int, int, int, double); static void StdAsciiParserDefclkperiod (fcb_t *, int, int, int, double); static void StdAsciiParserDefclstr (fcb_t *, int, int, int, double); static void StdAsciiParserDefclstrreg (fcb_t *, int, int, int, double); static void StdAsciiParserDefclstrregclass (fcb_t *, int, int, int, double); static void StdAsciiParserDefcommunicator (fcb_t *, int, int, int, double); static void StdAsciiParserDefcpugrp (fcb_t *, int, int, int, double); static void StdAsciiParserDefcpuname (fcb_t *, int, int, int, double); static void StdAsciiParserDefcpureg (fcb_t *, int, int, int, double); static void StdAsciiParserDefcpuregclass (fcb_t *, int, int, int, double); static void StdAsciiParserDefcreator (fcb_t *, int, int, int, double); static void StdAsciiParserDefdatastruc (fcb_t *, int, int, int, double); static void StdAsciiParserDefglobalop (fcb_t *, int, int, int, double); static void StdAsciiParserDefhist (fcb_t *, int, int, int, double); static void StdAsciiParserDefhistgrp (fcb_t *, int, int, int, double); static void StdAsciiParserDefiofile (fcb_t *, int, int, int, double); static void StdAsciiParserDefkparreg (fcb_t *, int, int, int, double); static void StdAsciiParserDefmsgname (fcb_t *, int, int, int, double); static void StdAsciiParserDefopenmpname (fcb_t *, int, int, int, double); static void StdAsciiParserDefopenmptype (fcb_t *, int, int, int, double); static void StdAsciiParserDefpattern (fcb_t *, int, int, int, double); static void StdAsciiParserDefpatternshape (fcb_t *, int, int, int, double); static void StdAsciiParserDefredfunc_obsol (fcb_t *, int, int, int, double); static void StdAsciiParserDefsamp (fcb_t *, int, int, int, double); static void StdAsciiParserDefsampclass (fcb_t *, int, int, int, double); static void StdAsciiParserDefscl (fcb_t *, int, int, int, double); static void StdAsciiParserDefsclfile (fcb_t *, int, int, int, double); static void StdAsciiParserDefstate (fcb_t *, int, int, int, double); static void StdAsciiParserDefstate_obsol (fcb_t *, int, int, int, double); static void StdAsciiParserDefsyscpunames (fcb_t *, int, int, int, double); static void StdAsciiParserDefsyscpunums (fcb_t *, int, int, int, double); static void StdAsciiParserDefthreadnums (fcb_t *, int, int, int, double); static void StdAsciiParserDeftimeoffset (fcb_t *, int, int, int, double); static void StdAsciiParserDefunmerged (fcb_t *, int, int, int, double); static void StdAsciiParserDefversion (fcb_t *, int, int, int, double); static void StdAsciiParserDownto (fcb_t *, int, int, int, double); static void StdAsciiParserExchange (fcb_t *, int, int, int, double); static void StdAsciiParserExchange_obsol (fcb_t *, int, int, int, double); static void StdAsciiParserFileiobegin (fcb_t *, int, int, int, double); static void StdAsciiParserFileioend (fcb_t *, int, int, int, double); static void StdAsciiParserGlobalop (fcb_t *, int, int, int, double); static void StdAsciiParserHist (fcb_t *, int, int, int, double); static void StdAsciiParserKparregbarsum (fcb_t *, int, int, int, double); static void StdAsciiParserKparregbegin (fcb_t *, int, int, int, double); static void StdAsciiParserKparregend (fcb_t *, int, int, int, double); static void StdAsciiParserMutexacquire (fcb_t *, int, int, int, double); static void StdAsciiParserMutexrelease (fcb_t *, int, int, int, double); static void StdAsciiParserOpenmpenter (fcb_t *, int, int, int, double); static void StdAsciiParserOpenmpleave (fcb_t *, int, int, int, double); static void StdAsciiParserParreg (fcb_t *, int, int, int, double); static void StdAsciiParserPattern (fcb_t *, int, int, int, double); static void StdAsciiParserRecvmsg (fcb_t *, int, int, int, double); static void StdAsciiParserSamp (fcb_t *, int, int, int, double); static void StdAsciiParserSendmsg (fcb_t *, int, int, int, double); static void StdAsciiParserSrcinfo_obsol (fcb_t *, int, int, int, double); static void StdAsciiParserUnrecognizable (fcb_t *, int, int, int, double); static void StdAsciiParserUpfrom (fcb_t *, int, int, int, double); static void StdAsciiParserUpto (fcb_t *, int, int, int, double); /* The type of the parsers for the standard ASCII format. */ typedef void (*stdasciiparser_t) (fcb_t *, int, int, int, double); /* The array containing all the parsers for the standard ASCII format. */ static stdasciiparser_t stdasciiparsers [sizeof (recordtypes) / sizeof (recordtypes[0])] = { StdAsciiParserClstrregval, StdAsciiParserComment, StdAsciiParserCpuregval, StdAsciiParserDefact, StdAsciiParserDefact_obsol, StdAsciiParserDefclkperiod, StdAsciiParserDefclstr, StdAsciiParserDefclstrreg, StdAsciiParserDefclstrregclass, StdAsciiParserDefcommunicator, StdAsciiParserDefcpugrp, StdAsciiParserDefcpuname, StdAsciiParserDefcpureg, StdAsciiParserDefcpuregclass, StdAsciiParserDefcreator, StdAsciiParserDefdatastruc, StdAsciiParserDefglobalop, StdAsciiParserDefhist, StdAsciiParserDefhistgrp, StdAsciiParserDefiofile, StdAsciiParserDefkparreg, StdAsciiParserDefmsgname, StdAsciiParserDefopenmpname, StdAsciiParserDefopenmptype, StdAsciiParserDefpattern, StdAsciiParserDefpatternshape, StdAsciiParserDefredfunc_obsol, StdAsciiParserDefsamp, StdAsciiParserDefsampclass, StdAsciiParserDefscl, StdAsciiParserDefsclfile, StdAsciiParserDefstate, StdAsciiParserDefstate_obsol, StdAsciiParserDefsyscpunames, StdAsciiParserDefsyscpunums, StdAsciiParserDefthreadnums, StdAsciiParserDeftimeoffset, StdAsciiParserDefunmerged, StdAsciiParserDefversion, StdAsciiParserDownto, StdAsciiParserExchange, StdAsciiParserExchange_obsol, StdAsciiParserFileiobegin, StdAsciiParserFileioend, StdAsciiParserGlobalop, StdAsciiParserHist, StdAsciiParserKparregbarsum, StdAsciiParserKparregbegin, StdAsciiParserKparregend, StdAsciiParserMutexacquire, StdAsciiParserMutexrelease, StdAsciiParserOpenmpenter, StdAsciiParserOpenmpleave, StdAsciiParserParreg, StdAsciiParserPattern, StdAsciiParserRecvmsg, StdAsciiParserSamp, StdAsciiParserSendmsg, StdAsciiParserSrcinfo_obsol, StdAsciiParserUnrecognizable, StdAsciiParserUpfrom, StdAsciiParserUpto }; /* The prototypes for the standard binary format parsers. */ static void StdBinaryParserClstrregval (fcb_t *, int, int); static void StdBinaryParserComment (fcb_t *, int, int); static void StdBinaryParserCpuregval (fcb_t *, int, int); static void StdBinaryParserDefact (fcb_t *, int, int); static void StdBinaryParserDefact_obsol (fcb_t *, int, int); static void StdBinaryParserDefclkperiod (fcb_t *, int, int); static void StdBinaryParserDefclstr (fcb_t *, int, int); static void StdBinaryParserDefclstrreg (fcb_t *, int, int); static void StdBinaryParserDefclstrregclass (fcb_t *, int, int); static void StdBinaryParserDefcommunicator (fcb_t *, int, int); static void StdBinaryParserDefcpugrp (fcb_t *, int, int); static void StdBinaryParserDefcpuname (fcb_t *, int, int); static void StdBinaryParserDefcpureg (fcb_t *, int, int); static void StdBinaryParserDefcpuregclass (fcb_t *, int, int); static void StdBinaryParserDefcreator (fcb_t *, int, int); static void StdBinaryParserDefdatastruc (fcb_t *, int, int); static void StdBinaryParserDefglobalop (fcb_t *, int, int); static void StdBinaryParserDefhist (fcb_t *, int, int); static void StdBinaryParserDefhistgrp (fcb_t *, int, int); static void StdBinaryParserDefiofile (fcb_t *, int, int); static void StdBinaryParserDefkparreg (fcb_t *, int, int); static void StdBinaryParserDefmsgname (fcb_t *, int, int); static void StdBinaryParserDefopenmpname (fcb_t *, int, int); static void StdBinaryParserDefopenmptype (fcb_t *, int, int); static void StdBinaryParserDefpattern (fcb_t *, int, int); static void StdBinaryParserDefpatternshape (fcb_t *, int, int); static void StdBinaryParserDefredfunc_obsol (fcb_t *, int, int); static void StdBinaryParserDefsamp (fcb_t *, int, int); static void StdBinaryParserDefsampclass (fcb_t *, int, int); static void StdBinaryParserDefscl (fcb_t *, int, int); static void StdBinaryParserDefsclfile (fcb_t *, int, int); static void StdBinaryParserDefstate (fcb_t *, int, int); static void StdBinaryParserDefstate_obsol (fcb_t *, int, int); static void StdBinaryParserDefsyscpunames (fcb_t *, int, int); static void StdBinaryParserDefsyscpunums (fcb_t *, int, int); static void StdBinaryParserDefthreadnums (fcb_t *, int, int); static void StdBinaryParserDeftimeoffset (fcb_t *, int, int); static void StdBinaryParserDefunmerged (fcb_t *, int, int); static void StdBinaryParserDefversion (fcb_t *, int, int); static void StdBinaryParserDownto (fcb_t *, int, int); static void StdBinaryParserExchange (fcb_t *, int, int); static void StdBinaryParserExchange_obsol (fcb_t *, int, int); static void StdBinaryParserFileiobegin (fcb_t *, int, int); static void StdBinaryParserFileioend (fcb_t *, int, int); static void StdBinaryParserGlobalop (fcb_t *, int, int); static void StdBinaryParserHist (fcb_t *, int, int); static void StdBinaryParserKparregbarsum (fcb_t *, int, int); static void StdBinaryParserKparregbegin (fcb_t *, int, int); static void StdBinaryParserKparregend (fcb_t *, int, int); static void StdBinaryParserMutexacquire (fcb_t *, int, int); static void StdBinaryParserMutexrelease (fcb_t *, int, int); static void StdBinaryParserOpenmpenter (fcb_t *, int, int); static void StdBinaryParserOpenmpleave (fcb_t *, int, int); static void StdBinaryParserParreg (fcb_t *, int, int); static void StdBinaryParserPattern (fcb_t *, int, int); static void StdBinaryParserRecvmsg (fcb_t *, int, int); static void StdBinaryParserSamp (fcb_t *, int, int); static void StdBinaryParserSendmsg (fcb_t *, int, int); static void StdBinaryParserSrcinfo_obsol (fcb_t *, int, int); static void StdBinaryParserUnrecognizable (fcb_t *, int, int); static void StdBinaryParserUpfrom (fcb_t *, int, int); static void StdBinaryParserUpto (fcb_t *, int, int); /* The type of the parsers for the standard binary format. */ typedef void (*stdbinaryparser_t) (fcb_t *, int, int); /* The array containing all the parsers for the standard binary format. */ static stdbinaryparser_t stdbinaryparsers [sizeof (recordtypes) / sizeof (recordtypes[0])] = { StdBinaryParserClstrregval, StdBinaryParserComment, StdBinaryParserCpuregval, StdBinaryParserDefact, StdBinaryParserDefact_obsol, StdBinaryParserDefclkperiod, StdBinaryParserDefclstr, StdBinaryParserDefclstrreg, StdBinaryParserDefclstrregclass, StdBinaryParserDefcommunicator, StdBinaryParserDefcpugrp, StdBinaryParserDefcpuname, StdBinaryParserDefcpureg, StdBinaryParserDefcpuregclass, StdBinaryParserDefcreator, StdBinaryParserDefdatastruc, StdBinaryParserDefglobalop, StdBinaryParserDefhist, StdBinaryParserDefhistgrp, StdBinaryParserDefiofile, StdBinaryParserDefkparreg, StdBinaryParserDefmsgname, StdBinaryParserDefopenmpname, StdBinaryParserDefopenmptype, StdBinaryParserDefpattern, StdBinaryParserDefpatternshape, StdBinaryParserDefredfunc_obsol, StdBinaryParserDefsamp, StdBinaryParserDefsampclass, StdBinaryParserDefscl, StdBinaryParserDefsclfile, StdBinaryParserDefstate, StdBinaryParserDefstate_obsol, StdBinaryParserDefsyscpunames, StdBinaryParserDefsyscpunums, StdBinaryParserDefthreadnums, StdBinaryParserDeftimeoffset, StdBinaryParserDefunmerged, StdBinaryParserDefversion, StdBinaryParserDownto, StdBinaryParserExchange, StdBinaryParserExchange_obsol, StdBinaryParserFileiobegin, StdBinaryParserFileioend, StdBinaryParserGlobalop, StdBinaryParserHist, StdBinaryParserKparregbarsum, StdBinaryParserKparregbegin, StdBinaryParserKparregend, StdBinaryParserMutexacquire, StdBinaryParserMutexrelease, StdBinaryParserOpenmpenter, StdBinaryParserOpenmpleave, StdBinaryParserParreg, StdBinaryParserPattern, StdBinaryParserRecvmsg, StdBinaryParserSamp, StdBinaryParserSendmsg, StdBinaryParserSrcinfo_obsol, StdBinaryParserUnrecognizable, StdBinaryParserUpfrom, StdBinaryParserUpto }; /* The prototypes for the fast ASCII format parsers. */ static void FstAsciiParserClstrregval (fcb_t *, int, int, int, double); static void FstAsciiParserComment (fcb_t *, int, int, int, double); static void FstAsciiParserCpuregval (fcb_t *, int, int, int, double); static void FstAsciiParserDefact (fcb_t *, int, int, int, double); static void FstAsciiParserDefact_obsol (fcb_t *, int, int, int, double); static void FstAsciiParserDefclkperiod (fcb_t *, int, int, int, double); static void FstAsciiParserDefclstr (fcb_t *, int, int, int, double); static void FstAsciiParserDefclstrreg (fcb_t *, int, int, int, double); static void FstAsciiParserDefclstrregclass (fcb_t *, int, int, int, double); static void FstAsciiParserDefcommunicator (fcb_t *, int, int, int, double); static void FstAsciiParserDefcpugrp (fcb_t *, int, int, int, double); static void FstAsciiParserDefcpuname (fcb_t *, int, int, int, double); static void FstAsciiParserDefcpureg (fcb_t *, int, int, int, double); static void FstAsciiParserDefcpuregclass (fcb_t *, int, int, int, double); static void FstAsciiParserDefcreator (fcb_t *, int, int, int, double); static void FstAsciiParserDefdatastruc (fcb_t *, int, int, int, double); static void FstAsciiParserDefglobalop (fcb_t *, int, int, int, double); static void FstAsciiParserDefhist (fcb_t *, int, int, int, double); static void FstAsciiParserDefhistgrp (fcb_t *, int, int, int, double); static void FstAsciiParserDefiofile (fcb_t *, int, int, int, double); static void FstAsciiParserDefkparreg (fcb_t *, int, int, int, double); static void FstAsciiParserDefmsgname (fcb_t *, int, int, int, double); static void FstAsciiParserDefopenmpname (fcb_t *, int, int, int, double); static void FstAsciiParserDefopenmptype (fcb_t *, int, int, int, double); static void FstAsciiParserDefpattern (fcb_t *, int, int, int, double); static void FstAsciiParserDefpatternshape (fcb_t *, int, int, int, double); static void FstAsciiParserDefredfunc_obsol (fcb_t *, int, int, int, double); static void FstAsciiParserDefsamp (fcb_t *, int, int, int, double); static void FstAsciiParserDefsampclass (fcb_t *, int, int, int, double); static void FstAsciiParserDefscl (fcb_t *, int, int, int, double); static void FstAsciiParserDefsclfile (fcb_t *, int, int, int, double); static void FstAsciiParserDefstate (fcb_t *, int, int, int, double); static void FstAsciiParserDefstate_obsol (fcb_t *, int, int, int, double); static void FstAsciiParserDefsyscpunames (fcb_t *, int, int, int, double); static void FstAsciiParserDefsyscpunums (fcb_t *, int, int, int, double); static void FstAsciiParserDefthreadnums (fcb_t *, int, int, int, double); static void FstAsciiParserDeftimeoffset (fcb_t *, int, int, int, double); static void FstAsciiParserDefunmerged (fcb_t *, int, int, int, double); static void FstAsciiParserDefversion (fcb_t *, int, int, int, double); static void FstAsciiParserDownto (fcb_t *, int, int, int, double); static void FstAsciiParserExchange (fcb_t *, int, int, int, double); static void FstAsciiParserExchange_obsol (fcb_t *, int, int, int, double); static void FstAsciiParserFileiobegin (fcb_t *, int, int, int, double); static void FstAsciiParserFileioend (fcb_t *, int, int, int, double); static void FstAsciiParserGlobalop (fcb_t *, int, int, int, double); static void FstAsciiParserHist (fcb_t *, int, int, int, double); static void FstAsciiParserKparregbarsum (fcb_t *, int, int, int, double); static void FstAsciiParserKparregbegin (fcb_t *, int, int, int, double); static void FstAsciiParserKparregend (fcb_t *, int, int, int, double); static void FstAsciiParserMutexacquire (fcb_t *, int, int, int, double); static void FstAsciiParserMutexrelease (fcb_t *, int, int, int, double); static void FstAsciiParserOpenmpenter (fcb_t *, int, int, int, double); static void FstAsciiParserOpenmpleave (fcb_t *, int, int, int, double); static void FstAsciiParserParreg (fcb_t *, int, int, int, double); static void FstAsciiParserPattern (fcb_t *, int, int, int, double); static void FstAsciiParserRecvmsg (fcb_t *, int, int, int, double); static void FstAsciiParserSamp (fcb_t *, int, int, int, double); static void FstAsciiParserSendmsg (fcb_t *, int, int, int, double); static void FstAsciiParserSrcinfo_obsol (fcb_t *, int, int, int, double); static void FstAsciiParserUnrecognizable (fcb_t *, int, int, int, double); static void FstAsciiParserUpfrom (fcb_t *, int, int, int, double); static void FstAsciiParserUpto (fcb_t *, int, int, int, double); /* The type of the parsers for the fast ASCII format. */ typedef void (*fstasciiparser_t) (fcb_t *, int, int, int, double); /* The array containing all the parsers for the fast ASCII format. */ static fstasciiparser_t fstasciiparsers [sizeof (recordtypes) / sizeof (recordtypes[0])] = { FstAsciiParserClstrregval, FstAsciiParserComment, FstAsciiParserCpuregval, FstAsciiParserDefact, FstAsciiParserDefact_obsol, FstAsciiParserDefclkperiod, FstAsciiParserDefclstr, FstAsciiParserDefclstrreg, FstAsciiParserDefclstrregclass, FstAsciiParserDefcommunicator, FstAsciiParserDefcpugrp, FstAsciiParserDefcpuname, FstAsciiParserDefcpureg, FstAsciiParserDefcpuregclass, FstAsciiParserDefcreator, FstAsciiParserDefdatastruc, FstAsciiParserDefglobalop, FstAsciiParserDefhist, FstAsciiParserDefhistgrp, FstAsciiParserDefiofile, FstAsciiParserDefkparreg, FstAsciiParserDefmsgname, FstAsciiParserDefopenmpname, FstAsciiParserDefopenmptype, FstAsciiParserDefpattern, FstAsciiParserDefpatternshape, FstAsciiParserDefredfunc_obsol, FstAsciiParserDefsamp, FstAsciiParserDefsampclass, FstAsciiParserDefscl, FstAsciiParserDefsclfile, FstAsciiParserDefstate, FstAsciiParserDefstate_obsol, FstAsciiParserDefsyscpunames, FstAsciiParserDefsyscpunums, FstAsciiParserDefthreadnums, FstAsciiParserDeftimeoffset, FstAsciiParserDefunmerged, FstAsciiParserDefversion, FstAsciiParserDownto, FstAsciiParserExchange, FstAsciiParserExchange_obsol, FstAsciiParserFileiobegin, FstAsciiParserFileioend, FstAsciiParserGlobalop, FstAsciiParserHist, FstAsciiParserKparregbarsum, FstAsciiParserKparregbegin, FstAsciiParserKparregend, FstAsciiParserMutexacquire, FstAsciiParserMutexrelease, FstAsciiParserOpenmpenter, FstAsciiParserOpenmpleave, FstAsciiParserParreg, FstAsciiParserPattern, FstAsciiParserRecvmsg, FstAsciiParserSamp, FstAsciiParserSendmsg, FstAsciiParserSrcinfo_obsol, FstAsciiParserUnrecognizable, FstAsciiParserUpfrom, FstAsciiParserUpto }; /*****************************************************************************/ /* The magic numbers to specify the `double' representation type. */ #define VTF3_CONST_FPNRT_CRAY_NATIVE_TYPE (1) #define VTF3_CONST_FPNRT_IEEE754_DOUBLE_BIGEND (2) #define VTF3_CONST_FPNRT_IEEE754_DOUBLE_LITEND (3) /*****************************************************************************/ /* Some macro stuff. */ #define VTF3_CHAR2INDEX(c) \ ((unsigned int) (unsigned char) (c) & (unsigned int) 0xff) #define VTF3_ASCIIPARSER_CHECK_AND_PASS_BLANK \ if (vtfspace[VTF3_CHAR2INDEX (*fcb->recbufferpos++)] == 0) \ goto Error #define VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR(c) \ if (vtfupper[VTF3_CHAR2INDEX (*fcb->recbufferpos++)] != (c)) \ goto Error #define VTF3_ASCIIPARSER_PASS_BLANKS(p) \ while (vtfspace[VTF3_CHAR2INDEX (*(p))] != 0) \ (p)++ #define VTF3_ASCIIPARSER_TEST_CHAR(c) \ (vtfupper[VTF3_CHAR2INDEX (*fcb->recbufferpos)] == (c) ? 1 : 0) #define VTF3_PARSER_LAST_VALID_TIME_MANAGEMENT \ if (time < fcb->lastvalidtime && fcb->substitudeupfrom != 0) { \ if (fcb->didupfromsubstitution != 0) \ (void) fprintf (stderr, "VTF3: Out-of-order record prevents " \ "further UPFROM substitution\n"); \ else \ (void) fprintf (stderr, "VTF3: Out-of-order record prevents " \ "UPFROM substitution\n"); \ (void) fflush (stderr); \ fcb->substitudeupfrom = 0; \ } \ fcb->lastvalidtime = time #define VTF3_PARSER_HANDLER_CALL_PROLOGUE(handler_t,handler) \ (handler) = (handler_t) *(fcb->handlers + handlerindex); \ if ((handler) == 0) \ return; \ if ((handler) == (handler_t) VTF3_DebugHandler) { \ (void) fprintf (stderr, "VTF3: Will not invoke VTF3_DebugHandler() " \ "for %s\n", stdasciikeywords[handlerindex]); \ (void) fflush (stderr); \ (void) exit (127); \ } #define VTF3_PARSER_HANDLER_CALL_EPILOGUE \ if (rc < 0) { \ (void) fprintf (stderr, "VTF3: %s handler returned %d\n", \ stdasciikeywords[handlerindex], rc); \ (void) fflush (stderr); \ (void) exit (127); \ } /*****************************************************************************/ /* More macro stuff. */ #define VTF3_STDBINARYCOMPOSE_WRITEI1(i) \ { \ unsigned char *macro_t; \ int macro_iout; \ unsigned int macro_uout; \ if (fcb->recbufferpos + 1 > fcb->recbufferbeyond) \ (void) ReallocRecord (fcb, 1); \ macro_t = (unsigned char *) fcb->recbufferpos; \ fcb->recbufferpos += 1; \ macro_iout = (i); \ if (macro_iout > 0) { \ if (macro_iout > 126) \ macro_iout = 127; \ } \ else if (macro_iout + 127 < 0) \ macro_iout = -128; \ macro_uout = * (unsigned int *) ¯o_iout; \ macro_uout = (macro_uout >> (sizeof (int) * 8 - 8) & (unsigned int) 0x80) \ + (macro_uout >> (sizeof (int) * 0 - 0) & (unsigned int) 0x7f); \ *(macro_t + 0) = (unsigned char) (macro_uout >> 0 & (unsigned int) 0xff); \ } /** * write out a signed integer in binary format * the integer is split into 4 bytes by hand written out separately */ #define VTF3_STDBINARYCOMPOSE_WRITEI4(i) \ { \ unsigned char *macro_t; \ int macro_iout; \ unsigned int macro_uout; \ if (fcb->recbufferpos + 4 > fcb->recbufferbeyond) \ (void) ReallocRecord (fcb, 4); \ macro_t = (unsigned char *) fcb->recbufferpos; \ fcb->recbufferpos += 4; \ macro_iout = (i); \ if (macro_iout > 0) { \ if (macro_iout > 2147483646) \ macro_iout = 2147483647; \ } \ else if (macro_iout + 2147483647 < 0) { \ macro_iout = -2147483647; \ macro_iout--; \ } \ macro_uout = * (unsigned int *) ¯o_iout; \ macro_uout = (macro_uout >> (sizeof (int) * 8 - 32) & \ (unsigned int) 0x80000000) \ + (macro_uout >> (sizeof (int) * 0 - 0) & \ (unsigned int) 0x7fffffff); \ *(macro_t + 0) = (unsigned char) (macro_uout >> 0 & (unsigned int) 0xff); \ *(macro_t + 1) = (unsigned char) (macro_uout >> 8 & (unsigned int) 0xff); \ *(macro_t + 2) = (unsigned char) (macro_uout >> 16 & (unsigned int) 0xff); \ *(macro_t + 3) = (unsigned char) (macro_uout >> 24 & (unsigned int) 0xff); \ } #define VTF3_STDBINARYCOMPOSE_WRITEU4(u) \ { \ unsigned char *macro_t; \ unsigned int macro_uout; \ if (fcb->recbufferpos + 4 > fcb->recbufferbeyond) \ (void) ReallocRecord (fcb, 4); \ macro_t = (unsigned char *) fcb->recbufferpos; \ fcb->recbufferpos += 4; \ macro_uout = (u); \ if (macro_uout > (unsigned int) 0xfffffffe) \ macro_uout = (unsigned int) 0xffffffff; \ *(macro_t + 0) = (unsigned char) (macro_uout >> 0 & (unsigned int) 0xff); \ *(macro_t + 1) = (unsigned char) (macro_uout >> 8 & (unsigned int) 0xff); \ *(macro_t + 2) = (unsigned char) (macro_uout >> 16 & (unsigned int) 0xff); \ *(macro_t + 3) = (unsigned char) (macro_uout >> 24 & (unsigned int) 0xff); \ } \ #define VTF3_FSTASCIICOMPOSE_WRITEC1(c1) \ if (fcb->recbufferpos + 1 > fcb->recbufferbeyond) \ (void) ReallocRecord (fcb, 1); \ *(fcb->recbufferpos + 0) = (c1); \ fcb->recbufferpos += 1 #define VTF3_FSTASCIICOMPOSE_WRITEC2(c1,c2) \ if (fcb->recbufferpos + 2 > fcb->recbufferbeyond) \ (void) ReallocRecord (fcb, 2); \ *(fcb->recbufferpos + 0) = (c1); \ *(fcb->recbufferpos + 1) = (c2); \ fcb->recbufferpos += 2 #define VTF3_FSTASCIICOMPOSE_WRITEC3(c1,c2,c3) \ if (fcb->recbufferpos + 3 > fcb->recbufferbeyond) \ (void) ReallocRecord (fcb, 3); \ *(fcb->recbufferpos + 0) = (c1); \ *(fcb->recbufferpos + 1) = (c2); \ *(fcb->recbufferpos + 2) = (c3); \ fcb->recbufferpos += 3 #define VTF3_FSTASCIICOMPOSE_WRITEI4(i) \ { \ static char macro_dig [10] \ = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9'}; \ char macro_convbuf [16]; \ int macro_iout, macro_withminus, macro_idig; \ char *macro_p; \ if (fcb->recbufferpos + sizeof (macro_convbuf) / \ sizeof (macro_convbuf[0]) > fcb->recbufferbeyond) \ (void) ReallocRecord (fcb, (unsigned int) (sizeof (macro_convbuf) / \ sizeof (macro_convbuf[0]))); \ macro_iout = (i); \ if (macro_iout == 0) \ *fcb->recbufferpos++ = '0'; \ else if (macro_iout > 2147483646) \ (void) StdAsciiWriteSu (fcb, "2147483647"); \ else if (macro_iout < 0 && macro_iout + 2147483647 < 0) \ (void) StdAsciiWriteSu (fcb, "-2147483648"); \ else { \ if (macro_iout < 0) { \ macro_iout = -macro_iout; \ macro_withminus = 1; \ } \ else \ macro_withminus = 0; \ macro_p = ¯o_convbuf[sizeof (macro_convbuf) / \ sizeof (macro_convbuf[0]) - 1]; \ *macro_p-- = '\0'; \ while (macro_iout != 0) { \ macro_idig = macro_iout % 10; \ *macro_p-- = macro_dig[macro_idig]; \ macro_iout -= macro_idig; \ macro_iout /= 10; \ } \ if (macro_withminus != 0) \ *macro_p-- = '-'; \ macro_p++; \ while (*macro_p != '\0') \ *fcb->recbufferpos++ = *macro_p++; \ } \ } #define VTF3_FSTASCIICOMPOSE_WRITEU4(u) \ { \ static char macro_dig [10] \ = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9'}; \ char macro_convbuf [16]; \ unsigned int macro_uout, macro_udig; \ char *macro_p; \ if (fcb->recbufferpos + sizeof (macro_convbuf) / \ sizeof (macro_convbuf[0]) > fcb->recbufferbeyond) \ (void) ReallocRecord (fcb, (unsigned int) (sizeof (macro_convbuf) / \ sizeof (macro_convbuf[0]))); \ macro_uout = (u); \ if (macro_uout == 0) \ *fcb->recbufferpos++ = '0'; \ else if (macro_uout > (unsigned int) 0xfffffffe) \ (void) StdAsciiWriteSu (fcb, "4294967295"); \ else { \ macro_p = ¯o_convbuf[sizeof (macro_convbuf) / \ sizeof (macro_convbuf[0]) - 1]; \ *macro_p-- = '\0'; \ while (macro_uout != 0) { \ macro_udig = macro_uout % 10; \ *macro_p-- = macro_dig[macro_udig]; \ macro_uout -= macro_udig; \ macro_uout /= 10; \ } \ macro_p++; \ while (*macro_p != '\0') \ *fcb->recbufferpos++ = *macro_p++; \ } \ } #define VTF3_STDASCIIPARSER_READI4(i) \ { \ char *macro_p; \ unsigned int macro_withminus, macro_urefmax, macro_uout, macro_u, \ macro_uref; \ int macro_i; \ macro_p = fcb->recbufferpos; \ VTF3_ASCIIPARSER_PASS_BLANKS (macro_p); \ fcb->recbufferpos = macro_p; \ if (*macro_p == '-') { \ macro_p++; \ macro_withminus = 1; \ macro_urefmax = (unsigned int) 0x80000000; \ } \ else if (*macro_p == '+') { \ macro_p++; \ macro_withminus = 0; \ macro_urefmax = (unsigned int) 0x7fffffff; \ } \ else { \ macro_withminus = 0; \ macro_urefmax = (unsigned int) 0x7fffffff; \ } \ macro_uout = 0; \ macro_i = vtfdigit[VTF3_CHAR2INDEX (*macro_p)]; \ if (macro_i > 9) \ goto Error; \ while ((macro_u = (unsigned int) macro_i) < 10) { \ macro_p++; \ macro_i = vtfdigit[VTF3_CHAR2INDEX (*macro_p)]; \ macro_uref = macro_urefmax - macro_u; \ macro_uref = macro_uref - macro_uref % 10; \ macro_uref /= 10; \ if (macro_uout > macro_uref) { \ macro_uout = macro_urefmax; \ continue; \ } \ macro_uout = macro_uout * 10 + macro_u; \ } \ if (macro_uout != 0 && macro_withminus != 0) { \ macro_uout--; \ macro_uout = ~macro_uout; \ } \ (i) = * (int *) ¯o_uout; \ if (vtfspace[VTF3_CHAR2INDEX (*macro_p)] == 0 && *macro_p != '\n') \ goto Error; \ VTF3_ASCIIPARSER_PASS_BLANKS (macro_p); \ fcb->recbufferpos = macro_p; \ } #define VTF3_STDASCIIPARSER_READU4(u) \ { \ char *macro_p; \ unsigned int macro_withminus, macro_urefmax, macro_uout, macro_u, \ macro_uref; \ int macro_i; \ macro_p = fcb->recbufferpos; \ VTF3_ASCIIPARSER_PASS_BLANKS (macro_p); \ fcb->recbufferpos = macro_p; \ if (*macro_p == '-') { \ macro_p++; \ macro_withminus = 1; \ } \ else if (*macro_p == '+') { \ macro_p++; \ macro_withminus = 0; \ } \ else \ macro_withminus = 0; \ macro_urefmax = (unsigned int) 0xffffffff; \ macro_uout = 0; \ macro_i = vtfdigit[VTF3_CHAR2INDEX (*macro_p)]; \ if (macro_i > 9) \ goto Error; \ while ((macro_u = (unsigned int) macro_i) < 10) { \ macro_p++; \ macro_i = vtfdigit[VTF3_CHAR2INDEX (*macro_p)]; \ macro_uref = macro_urefmax - macro_u; \ macro_uref = macro_uref - macro_uref % 10; \ macro_uref /= 10; \ if (macro_uout > macro_uref) { \ macro_uout = macro_urefmax; \ continue; \ } \ macro_uout = macro_uout * 10 + macro_u; \ } \ if (macro_withminus != 0) \ macro_uout = 0; \ (u) = macro_uout; \ if (vtfspace[VTF3_CHAR2INDEX (*macro_p)] == 0 && *macro_p != '\n') \ goto Error; \ VTF3_ASCIIPARSER_PASS_BLANKS (macro_p); \ fcb->recbufferpos = macro_p; \ } #define VTF3_STDASCIIPARSER_READSCL \ { \ scltoken = VTF3_SCLNONE; \ if (VTF3_ASCIIPARSER_TEST_CHAR ('S') != 0) { \ fcb->recbufferpos++; \ /* Firstly, look for old style `SRC #:# [SRC #:# ...]' sequences. */ \ if (VTF3_ASCIIPARSER_TEST_CHAR ('R') != 0) { \ fcb->recbufferpos++; \ VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('C'); \ VTF3_ASCIIPARSER_CHECK_AND_PASS_BLANK; \ /* It seems to be one, ignore the remaining line contents. */ \ while (*fcb->recbufferpos != '\n') \ fcb->recbufferpos++; \ } \ else { \ VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('C'); \ VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('L'); \ VTF3_ASCIIPARSER_CHECK_AND_PASS_BLANK; \ VTF3_ASCIIPARSER_PASS_BLANKS (fcb->recbufferpos); \ if (VTF3_ASCIIPARSER_TEST_CHAR ('R') != 0) { \ fcb->recbufferpos++; \ VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('E'); \ VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('S'); \ VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('E'); \ VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('T'); \ scltoken = VTF3_SCLRESET; \ if (VTF3_ASCIIPARSER_TEST_CHAR ('\n') == 0) { \ VTF3_ASCIIPARSER_CHECK_AND_PASS_BLANK; \ VTF3_ASCIIPARSER_PASS_BLANKS (fcb->recbufferpos); \ } \ } \ else { \ VTF3_STDASCIIPARSER_READI4 (scltoken); \ } \ } \ } \ } #define VTF3_STDBINARYPARSER_READI1(i) \ { \ unsigned char *macro_from; \ unsigned int macro_u; \ macro_from = (unsigned char *) fcb->recbufferpos; \ fcb->recbufferpos += 1; \ macro_u = ((unsigned int) (unsigned char) *(macro_from + 0) << 0); \ if ((macro_u & (unsigned int) 0x80) != 0) { \ if ((macro_u & (unsigned int) 0x7f) != 0) { \ macro_u--; \ macro_u = ~macro_u; \ macro_u &= (unsigned int) 0xff; \ macro_u = ~macro_u; \ macro_u++; \ } \ else { \ macro_u = ~macro_u; \ macro_u &= (unsigned int) 0xff; \ macro_u = ~macro_u; \ } \ } \ (i) = * (int *) ¯o_u; \ } #define VTF3_STDBINARYPARSER_READI4(i) \ { \ unsigned char *macro_from; \ unsigned int macro_u; \ macro_from = (unsigned char *) fcb->recbufferpos; \ fcb->recbufferpos += 4; \ macro_u = ((unsigned int) (unsigned char) *(macro_from + 0) << 0) \ + ((unsigned int) (unsigned char) *(macro_from + 1) << 8) \ + ((unsigned int) (unsigned char) *(macro_from + 2) << 16) \ + ((unsigned int) (unsigned char) *(macro_from + 3) << 24); \ if ((macro_u & (unsigned int) 0x80000000) != 0) { \ if ((macro_u & (unsigned int) 0x7fffffff) != 0) { \ macro_u--; \ macro_u = ~macro_u; \ macro_u &= (unsigned int) 0xffffffff; \ macro_u = ~macro_u; \ macro_u++; \ } \ else { \ macro_u = ~macro_u; \ macro_u &= (unsigned int) 0xffffffff; \ macro_u = ~macro_u; \ } \ } \ (i) = * (int *) ¯o_u; \ } #define VTF3_STDBINARYPARSER_READU4(u) \ { \ unsigned char *macro_from; \ unsigned int macro_u; \ macro_from = (unsigned char *) fcb->recbufferpos; \ fcb->recbufferpos += 4; \ macro_u = ((unsigned int) (unsigned char) *(macro_from + 0) << 0) \ + ((unsigned int) (unsigned char) *(macro_from + 1) << 8) \ + ((unsigned int) (unsigned char) *(macro_from + 2) << 16) \ + ((unsigned int) (unsigned char) *(macro_from + 3) << 24); \ (u) = macro_u; \ } #define VTF3_FSTASCIIPARSER_READI4(i) \ { \ char *macro_p; \ unsigned int macro_withminus, macro_urefmax, macro_uout, macro_u, \ macro_uref; \ int macro_i; \ macro_p = fcb->recbufferpos; \ if (*macro_p == '-') { \ macro_p++; \ macro_withminus = 1; \ macro_urefmax = (unsigned int) 0x80000000; \ } \ else if (*macro_p == '+') { \ macro_p++; \ macro_withminus = 0; \ macro_urefmax = (unsigned int) 0x7fffffff; \ } \ else { \ macro_withminus = 0; \ macro_urefmax = (unsigned int) 0x7fffffff; \ } \ macro_uout = 0; \ macro_i = vtfdigit[VTF3_CHAR2INDEX (*macro_p)]; \ if (macro_i > 9) \ goto Error; \ while ((macro_u = (unsigned int) macro_i) < 10) { \ macro_p++; \ macro_i = vtfdigit[VTF3_CHAR2INDEX (*macro_p)]; \ macro_uref = macro_urefmax - macro_u; \ macro_uref = macro_uref - macro_uref % 10; \ macro_uref /= 10; \ if (macro_uout > macro_uref) { \ macro_uout = macro_urefmax; \ continue; \ } \ macro_uout = macro_uout * 10 + macro_u; \ } \ if (macro_uout != 0 && macro_withminus != 0) { \ macro_uout--; \ macro_uout = ~macro_uout; \ } \ (i) = * (int *) ¯o_uout; \ fcb->recbufferpos = macro_p; \ } #define VTF3_FSTASCIIPARSER_READTS(ts) \ { \ static double macro_fdig [10] = { \ 0.0e+0, 1.0e+0, 2.0e+0, 3.0e+0, 4.0e+0, 5.0e+0, 6.0e+0, 7.0e+0, 8.0e+0, \ 9.0e+0}; \ char *macro_p; \ unsigned int macro_withminus; \ double macro_tsout; \ int macro_d; \ macro_p = fcb->recbufferpos; \ if (*macro_p == '-') { \ macro_withminus = 1; \ macro_p++; \ } \ else if (*macro_p == '+') { \ macro_withminus = 0; \ macro_p++; \ } \ else \ macro_withminus = 0; \ macro_tsout = 0.0e+0; \ macro_d = vtfdigit[VTF3_CHAR2INDEX (*macro_p)]; \ if (macro_d > 9) \ goto Error; \ while (macro_d < 10) { \ macro_tsout = macro_tsout * 10.0e+0 + macro_fdig[macro_d]; \ if (macro_tsout > 1.0e+30) \ macro_tsout = 1.0e+30; \ macro_d = vtfdigit[VTF3_CHAR2INDEX (*++macro_p)]; \ } \ if (macro_withminus != 0 && macro_tsout > 0.5e+0) \ macro_tsout = -macro_tsout; \ (ts) = macro_tsout; \ fcb->recbufferpos = macro_p; \ } #define VTF3_FSTASCIIPARSER_READU4(u) \ { \ char *macro_p; \ unsigned int macro_withminus, macro_urefmax, macro_uout, macro_u, \ macro_uref; \ int macro_i; \ macro_p = fcb->recbufferpos; \ if (*macro_p == '-') { \ macro_p++; \ macro_withminus = 1; \ } \ else if (*macro_p == '+') { \ macro_p++; \ macro_withminus = 0; \ } \ else \ macro_withminus = 0; \ macro_urefmax = (unsigned int) 0xffffffff; \ macro_uout = 0; \ macro_i = vtfdigit[VTF3_CHAR2INDEX (*macro_p)]; \ if (macro_i > 9) \ goto Error; \ while ((macro_u = (unsigned int) macro_i) < 10) { \ macro_p++; \ macro_i = vtfdigit[VTF3_CHAR2INDEX (*macro_p)]; \ macro_uref = macro_urefmax - macro_u; \ macro_uref = macro_uref - macro_uref % 10; \ macro_uref /= 10; \ if (macro_uout > macro_uref) { \ macro_uout = macro_urefmax; \ continue; \ } \ macro_uout = macro_uout * 10 + macro_u; \ } \ if (macro_withminus != 0) \ macro_uout = 0; \ (u) = macro_uout; \ fcb->recbufferpos = macro_p; \ } #define VTF3_STORE_ONTO_INT_VECTOR(index,value) \ { \ int macro_index; \ size_t macro_size; \ macro_index = (index); \ if (fcb->intvector == 0) { \ fcb->intvectordim = macro_index + 1 + 10; \ macro_size = (size_t) fcb->intvectordim * sizeof (int); \ fcb->intvector = (int *) malloc (macro_size); \ if (fcb->intvector == 0) { \ VTF3_NOMEM_GOOD_BYE_INFO; \ (void) exit (127); \ } \ } \ if (macro_index + 1 > fcb->intvectordim) { \ fcb->intvectordim = 2 * (macro_index + 1); \ macro_size = (size_t) fcb->intvectordim * sizeof (int); \ fcb->intvector = (int *) realloc (fcb->intvector, macro_size); \ if (fcb->intvector == 0) { \ VTF3_NOMEM_GOOD_BYE_INFO; \ (void) exit (127); \ } \ } \ *(fcb->intvector + macro_index) = (value); \ } #define VTF3_STORE_ONTO_INT_VECTOR2(index,value) \ { \ int macro_index; \ size_t macro_size; \ macro_index = (index); \ if (fcb->intvector2 == 0) { \ fcb->intvector2dim = macro_index + 1 + 10; \ macro_size = (size_t) fcb->intvector2dim * sizeof (int); \ fcb->intvector2 = (int *) malloc (macro_size); \ if (fcb->intvector2 == 0) { \ VTF3_NOMEM_GOOD_BYE_INFO; \ (void) exit (127); \ } \ } \ if (macro_index + 1 > fcb->intvector2dim) { \ fcb->intvector2dim = 2 * (macro_index + 1); \ macro_size = (size_t) fcb->intvector2dim * sizeof (int); \ fcb->intvector2 = (int *) realloc (fcb->intvector2, macro_size); \ if (fcb->intvector2 == 0) { \ VTF3_NOMEM_GOOD_BYE_INFO; \ (void) exit (127); \ } \ } \ *(fcb->intvector2 + macro_index) = (value); \ } #define VTF3_STORE_ONTO_UINT_VECTOR(index,value) \ { \ int macro_index; \ size_t macro_size; \ macro_index = (index); \ if (fcb->uintvector == 0) { \ fcb->uintvectordim = macro_index + 1 + 10; \ macro_size = (size_t) fcb->uintvectordim * sizeof (unsigned int); \ fcb->uintvector = (unsigned int *) malloc (macro_size); \ if (fcb->uintvector == 0) { \ VTF3_NOMEM_GOOD_BYE_INFO; \ (void) exit (127); \ } \ } \ if (macro_index + 1 > fcb->uintvectordim) { \ fcb->uintvectordim = 2 * (macro_index + 1); \ macro_size = (size_t) fcb->uintvectordim * sizeof (unsigned int); \ fcb->uintvector = (unsigned int *) realloc (fcb->uintvector, \ macro_size); \ if (fcb->uintvector == 0) { \ VTF3_NOMEM_GOOD_BYE_INFO; \ (void) exit (127); \ } \ } \ *(fcb->uintvector + macro_index) = (value); \ } #define VTF3_STORE_UINT_ONTO_U4VECTOR(index,value) \ { \ int macro_index; \ size_t macro_size; \ unsigned int macro_value; \ unsigned char macro_c0, macro_c1, macro_c2, macro_c3; \ macro_index = (index); \ if (fcb->u4vector == 0) { \ fcb->u4vectordim = macro_index + 1 + 10; \ macro_size = (size_t) fcb->u4vectordim * 4 * sizeof (unsigned char); \ fcb->u4vector = (unsigned char *) malloc (macro_size); \ if (fcb->u4vector == 0) { \ VTF3_NOMEM_GOOD_BYE_INFO; \ (void) exit (127); \ } \ } \ if (macro_index + 1 > fcb->u4vectordim) { \ fcb->u4vectordim = 2 * (macro_index + 1); \ macro_size = (size_t) fcb->u4vectordim * 4 * sizeof (unsigned char); \ fcb->u4vector = (unsigned char *) realloc (fcb->u4vector, macro_size); \ if (fcb->u4vector == 0) { \ VTF3_NOMEM_GOOD_BYE_INFO; \ (void) exit (127); \ } \ } \ macro_value = (value); \ if (vtffprtype == VTF3_CONST_FPNRT_IEEE754_DOUBLE_LITEND) { \ macro_c0 = (unsigned char) (macro_value >> 0 & (unsigned int) 0xff); \ macro_c1 = (unsigned char) (macro_value >> 8 & (unsigned int) 0xff); \ macro_c2 = (unsigned char) (macro_value >> 16 & (unsigned int) 0xff); \ macro_c3 = (unsigned char) (macro_value >> 24 & (unsigned int) 0xff); \ } \ else { \ macro_c3 = (unsigned char) (macro_value >> 0 & (unsigned int) 0xff); \ macro_c2 = (unsigned char) (macro_value >> 8 & (unsigned int) 0xff); \ macro_c1 = (unsigned char) (macro_value >> 16 & (unsigned int) 0xff); \ macro_c0 = (unsigned char) (macro_value >> 24 & (unsigned int) 0xff); \ } \ *(fcb->u4vector + (macro_index << 2) + 0) = macro_c0; \ *(fcb->u4vector + (macro_index << 2) + 1) = macro_c1; \ *(fcb->u4vector + (macro_index << 2) + 2) = macro_c2; \ *(fcb->u4vector + (macro_index << 2) + 3) = macro_c3; \ } /*****************************************************************************/ /* The remaining prototypes. */ static fcb_t *AllocFcb (void); static void CheckFcb (const fcb_t *); static void CheckFcbIn (const fcb_t *); static void CheckFcbOut (const fcb_t *); static void CheckVtfInitialization (void); static unsigned int ConvertDoubleToU4 (double); static void FillIoBuffer (fcb_t *); static void FlushIoBuffer (fcb_t *); static void FreeFcb (fcb_t *); static void FstAsciiParser (fcb_t *, int); static void FstAsciiWriteXy (fcb_t *, double); static double GetDoubleFromXy (unsigned int, unsigned int); static int GetFileCompressionType (const char *); static int GetStringLength (fcb_t *, int); static void HandleBadRecord (fcb_t *, int, int); static const char *KeyWordByRecType (int); static int KeyWordComp (const char *, const char *); static double LoadDoubleFromU4Array (const void *, int); static unsigned int LoadUintFromU4Array (const void *, int); static int MemCmp (const void *, const void *, size_t); static double PassF (double); static int PassI (int); static const void *PassP (const void *); static unsigned int PassU (unsigned int); static void PrepVersion (void); static void PrepVersionNumber (void); static void QuickSortKeyWords (const char **, int *, unsigned int, unsigned int); static void QuickSortRecTypes (int *, const char **, const char **, VTF3_handler_t *, stdasciiparser_t *, stdbinaryparser_t *, fstasciiparser_t *, unsigned int, unsigned int); static void ReadInputLtd (fcb_t *, size_t *, int *); static void ReallocRecord (fcb_t *, unsigned int); static void SetFprType (void); static int SignOfDouble (double); static const char *StdAsciiGetSeparatedString (fcb_t *, int); static void StdAsciiParser (fcb_t *, int); static char *StdAsciiReadF8 (fcb_t *, double *); static char *StdAsciiReadI4 (fcb_t *, int *); static char *StdAsciiReadI4ColonTrailing (fcb_t *, int *); static int StdAsciiReadRecord (fcb_t *); static char *StdAsciiReadTs (fcb_t *, double *); static char *StdAsciiReadU4ColonTrailing (fcb_t *, unsigned int *); static char *StdAsciiStoreBuggyStringOffsets (fcb_t *, int); static char *StdAsciiStoreOldStyleStringOffsets (fcb_t *, int); static char *StdAsciiStoreStringOffsets (fcb_t *, int); static VTF3_rec_t *StdAsciiWriteEp (fcb_t *, int); static void StdAsciiWriteF8 (fcb_t *, double); static void StdAsciiWriteI4 (fcb_t *, int); static void StdAsciiWriteSc (fcb_t *, const char *); static void StdAsciiWriteSp (fcb_t *, const char *); static void StdAsciiWriteSu (fcb_t *, const char *); static void StdAsciiWriteTs (fcb_t *, double); static void StdAsciiWriteU4 (fcb_t *, unsigned int); static const char *StdBinaryGetSeparatedString (fcb_t *, int); static void StdBinaryParser (fcb_t *, int); static double StdBinaryReadF8 (fcb_t *); static int StdBinaryReadI2 (fcb_t *); static int StdBinaryReadRecord (fcb_t *); static double StdBinaryReadTs (fcb_t *); static void StdBinaryStoreStringOffsets (fcb_t *, int); static void StdBinaryWriteCa (fcb_t *, const char *, int); static VTF3_rec_t *StdBinaryWriteEp (fcb_t *, int); static void StdBinaryWriteF8 (fcb_t *, double); static void StdBinaryWriteI2 (fcb_t *, int); static void StdBinaryWriteSv (fcb_t *, const char *); static void StdBinaryWriteTs (fcb_t *, double); static void StoreDoubleOntoU4Vector (fcb_t *, int, double); static void StoreOntoCharPtrVector (fcb_t *, int, const char *); static void SubstitudeUpFrom (fcb_t *, unsigned int, int *, int *); static const char *TransHexToMem (fcb_t *, const char *, unsigned int); static int TransMemToHexLower (fcb_t *, const void *, size_t); static int TransMemToHexUpper (fcb_t *, const void *, size_t); static void WriteRecord (fcb_t *); /*****************************************************************************/ static fcb_t * AllocFcb (void) { fcb_t *fcb; if ((fcb = (fcb_t *) malloc (sizeof (fcb_t))) == 0) { VTF3_NOMEM_GOOD_BYE_INFO; (void) exit (127); } (void) memset (fcb, 0, sizeof (fcb_t)); fcb->zebra1 = vtfzebra; fcb->lastvalidtime = 0.0e+0; fcb->zebra2 = vtfzebra; return (fcb); } static void CheckFcb (const fcb_t *fcb) { if (vtfisinitialized == 0) { (void) fprintf (stderr, "VTF3: VTF3_InitTables() never invoked\n"); (void) fflush (stderr); (void) exit (127); } if (fcb == 0) { (void) fprintf (stderr, "VTF3: NULL as FCB address\n"); (void) fflush (stderr); (void) exit (127); } if (fcb->zebra1 != vtfzebra || fcb->zebra2 != vtfzebra) { (void) fprintf (stderr, "VTF3: Invalid FCB\n"); (void) fflush (stderr); (void) exit (127); } return; } static void CheckFcbIn (const fcb_t *fcb) { if (vtfisinitialized == 0) { (void) fprintf (stderr, "VTF3: VTF3_InitTables() never invoked\n"); (void) fflush (stderr); (void) exit (127); } if (fcb == 0) { (void) fprintf (stderr, "VTF3: NULL as FCB address\n"); (void) fflush (stderr); (void) exit (127); } if (fcb->zebra1 != vtfzebra || fcb->zebra2 != vtfzebra) { (void) fprintf (stderr, "VTF3: Invalid FCB\n"); (void) fflush (stderr); (void) exit (127); } if (fcb->isoutput != 0) { (void) fprintf (stderr, "VTF3: FCB isn't for input\n"); (void) fflush (stderr); (void) exit (127); } return; } static void CheckFcbOut (const fcb_t *fcb) { if (vtfisinitialized == 0) { (void) fprintf (stderr, "VTF3: VTF3_InitTables() never invoked\n"); (void) fflush (stderr); (void) exit (127); } if (fcb == 0) { (void) fprintf (stderr, "VTF3: NULL as FCB address\n"); (void) fflush (stderr); (void) exit (127); } if (fcb->zebra1 != vtfzebra || fcb->zebra2 != vtfzebra) { (void) fprintf (stderr, "VTF3: Invalid FCB\n"); (void) fflush (stderr); (void) exit (127); } if (fcb->isoutput == 0) { (void) fprintf (stderr, "VTF3: FCB isn't for output\n"); (void) fflush (stderr); (void) exit (127); } return; } static void CheckVtfInitialization (void) { if (vtfisinitialized == 0) { (void) fprintf (stderr, "VTF3: VTF3_InitTables() never invoked\n"); (void) fflush (stderr); (void) exit (127); } return; } static unsigned int ConvertDoubleToU4 (double f) { union { double f; struct { unsigned int ns:1; unsigned int ex:15; unsigned int m2:16; unsigned int m1:16; unsigned int m0:16; } cray_native_type; struct { unsigned int ns:1; unsigned int ex:11; unsigned int m3:4; unsigned int m2:16; unsigned int m1:16; unsigned int m0:16; } ieee754_double_bigend; struct { unsigned int m0:16; unsigned int m1:16; unsigned int m2:16; unsigned int m3:4; unsigned int ex:11; unsigned int ns:1; } ieee754_double_litend; } fp; unsigned int ns, ex, m2, m1, m0, m3; fp.f = f; if (vtffprtype == VTF3_CONST_FPNRT_CRAY_NATIVE_TYPE) { ns = fp.cray_native_type.ns; ex = fp.cray_native_type.ex; m2 = fp.cray_native_type.m2; m1 = fp.cray_native_type.m1; m0 = fp.cray_native_type.m0; if (ns != 0) return (0); if (ex == 0 && m2 == 0 && m1 == 0 && m0 == 0) return (0); if (ex < (unsigned int) 0x2003) { fp.cray_native_type.ex = (unsigned int) 0x2003; fp.cray_native_type.m2 = (unsigned int) 0x8000; fp.cray_native_type.m1 = (unsigned int) 0x0000; fp.cray_native_type.m0 = (unsigned int) 0x0000; } else if (ex > (unsigned int) 0x5fff) { fp.cray_native_type.ex = (unsigned int) 0x5fff; fp.cray_native_type.m2 = (unsigned int) 0x8000; fp.cray_native_type.m1 = (unsigned int) 0x0000; fp.cray_native_type.m0 = (unsigned int) 0x0000; } if (fp.f < 0.5e+0) return (0); if (fp.f > (double) (unsigned int) 0xfffffffe + (double) 0.5e+0) return ((unsigned int) 0xffffffff); if (fp.f > (double) (unsigned int) 0xfffffffd + (double) 0.5e+0) return ((unsigned int) 0xfffffffe); return ((unsigned int) (fp.f + 0.5e+0)); } if (vtffprtype == VTF3_CONST_FPNRT_IEEE754_DOUBLE_BIGEND) { ns = fp.ieee754_double_bigend.ns; ex = fp.ieee754_double_bigend.ex; m3 = fp.ieee754_double_bigend.m3; m2 = fp.ieee754_double_bigend.m2; m1 = fp.ieee754_double_bigend.m1; m0 = fp.ieee754_double_bigend.m0; if (ns != 0) return (0); if (ex == 0 && m3 == 0 && m2 == 0 && m1 == 0 && m0 == 0) return (0); if (ex < (unsigned int) 0x002) { fp.ieee754_double_bigend.ex = (unsigned int) 0x002; fp.ieee754_double_bigend.m3 = (unsigned int) 0x0; fp.ieee754_double_bigend.m2 = (unsigned int) 0x0000; fp.ieee754_double_bigend.m1 = (unsigned int) 0x0000; fp.ieee754_double_bigend.m0 = (unsigned int) 0x0000; } else if (ex > (unsigned int) 0x7fd) { fp.ieee754_double_bigend.ex = (unsigned int) 0x7fd; fp.ieee754_double_bigend.m3 = (unsigned int) 0xf; fp.ieee754_double_bigend.m2 = (unsigned int) 0xffff; fp.ieee754_double_bigend.m1 = (unsigned int) 0xffff; fp.ieee754_double_bigend.m0 = (unsigned int) 0xffff; } if (fp.f < 0.5e+0) return (0); if (fp.f > (double) (unsigned int) 0xfffffffe + (double) 0.5e+0) return ((unsigned int) 0xffffffff); if (fp.f > (double) (unsigned int) 0xfffffffd + (double) 0.5e+0) return ((unsigned int) 0xfffffffe); return ((unsigned int) (fp.f + 0.5e+0)); } if (vtffprtype == VTF3_CONST_FPNRT_IEEE754_DOUBLE_LITEND) { ns = fp.ieee754_double_litend.ns; ex = fp.ieee754_double_litend.ex; m3 = fp.ieee754_double_litend.m3; m2 = fp.ieee754_double_litend.m2; m1 = fp.ieee754_double_litend.m1; m0 = fp.ieee754_double_litend.m0; if (ns != 0) return (0); if (ex == 0 && m3 == 0 && m2 == 0 && m1 == 0 && m0 == 0) return (0); if (ex < (unsigned int) 0x002) { fp.ieee754_double_litend.ex = (unsigned int) 0x002; fp.ieee754_double_litend.m3 = (unsigned int) 0x0; fp.ieee754_double_litend.m2 = (unsigned int) 0x0000; fp.ieee754_double_litend.m1 = (unsigned int) 0x0000; fp.ieee754_double_litend.m0 = (unsigned int) 0x0000; } else if (ex > (unsigned int) 0x7fd) { fp.ieee754_double_litend.ex = (unsigned int) 0x7fd; fp.ieee754_double_litend.m3 = (unsigned int) 0xf; fp.ieee754_double_litend.m2 = (unsigned int) 0xffff; fp.ieee754_double_litend.m1 = (unsigned int) 0xffff; fp.ieee754_double_litend.m0 = (unsigned int) 0xffff; } if (fp.f < 0.5e+0) return (0); if (fp.f > (double) (unsigned int) 0xfffffffe + (double) 0.5e+0) return ((unsigned int) 0xffffffff); if (fp.f > (double) (unsigned int) 0xfffffffd + (double) 0.5e+0) return ((unsigned int) 0xfffffffe); return ((unsigned int) (fp.f + 0.5e+0)); } (void) fprintf (stderr, "VTF3: Unknown FP representation type\n"); (void) fflush (stderr); (void) exit (127); return (0); } static void FillIoBuffer (fcb_t *fcb) { size_t numchars; int numbytes; if (fcb->pfile == 0) { (void) fprintf (stderr, "VTF3: FillIoBuffer(): Unrecoverable error\n"); (void) fflush (stderr); (void) exit (127); } if (fcb->iobuffer == 0) { fcb->iobuffer = (char *) malloc (VTF3_CONST_IOBUF_DIM * sizeof (char)); if (fcb->iobuffer == 0) { VTF3_NOMEM_GOOD_BYE_INFO; (void) exit (127); } fcb->iobufferbeyond = fcb->iobuffer + VTF3_CONST_IOBUF_DIM; } if (fcb->filecompressiontype == VTF3_FILECOMPRESSION_NONE) { numchars = fread (fcb->iobuffer, sizeof (char), VTF3_CONST_IOBUF_DIM, fcb->pfile); if (numchars == VTF3_CONST_IOBUF_DIM) ; else if (numchars > VTF3_CONST_IOBUF_DIM) { numchars = 0; (void) fprintf (stderr, "VTF3: Error in library function fread()\n"); (void) fflush (stderr); } else if (ferror (fcb->pfile) != 0) { numchars = 0; (void) fprintf (stderr, "VTF3: I/O error on input\n"); (void) fflush (stderr); } else if (feof (fcb->pfile) == 0) { numchars = 0; (void) fprintf (stderr, "VTF3: Error in library function feof()\n"); (void) fflush (stderr); } if (numchars < VTF3_CONST_IOBUF_DIM) { if (fclose (fcb->pfile) != 0) { (void) fprintf (stderr, "VTF3: Error while closing input\n"); (void) fflush (stderr); } fcb->pfile = 0; fcb->filehasbeenclosed = 1; } fcb->iobuffereof = fcb->iobuffer + numchars; fcb->iobufferpos = fcb->iobuffer + 0; return; } if (fcb->filecompressiontype == VTF3_FILECOMPRESSION_ZLIB) { fcb->zfilepositionfrmr = fcb->zfileposition; numbytes = VTF3_GzRead (&fcb->pfile, &fcb->zfile, fcb->iobuffer, VTF3_CONST_IOBUF_DIM * sizeof (char), &fcb->zfileposition); if (fcb->zfileposition < fcb->zfilepositionfrmr) fcb->zfileposition = fcb->zfilepositionfrmr; if (numbytes == (-2)) { VTF3_NOMEM_GOOD_BYE_INFO; (void) exit (127); } else if (numbytes > VTF3_CONST_IOBUF_DIM * (int) sizeof (char)) { numbytes = 0; (void) fprintf (stderr, "VTF3: I/O error or Z-stream problem " "on input\n"); (void) fflush (stderr); } else if (numbytes < 0) { numbytes = 0; (void) fprintf (stderr, "VTF3: I/O error or Z-stream problem " "on input\n"); (void) fflush (stderr); } if (fcb->pfile == 0) fcb->filehasbeenclosed = 1; fcb->iobuffereof = fcb->iobuffer + (size_t) numbytes / sizeof (char); fcb->iobufferpos = fcb->iobuffer + 0; return; } (void) fprintf (stderr, "VTF3: FillIoBuffer(): Unrecoverable error\n"); (void) fflush (stderr); (void) exit (127); return; } static void FlushIoBuffer (fcb_t *fcb) { size_t numchars, rc; int numbytes; numchars = (size_t) (fcb->iobufferpos - fcb->iobuffer); fcb->iobufferpos = fcb->iobuffer; if (fcb->filehasbeenclosed != 0) return; if (fcb->pfile == 0) { (void) fprintf (stderr, "VTF3: FlushIoBuffer(): Unrecoverable error\n"); (void) fflush (stderr); (void) exit (127); } if (fcb->filecompressiontype == VTF3_FILECOMPRESSION_NONE) { if (numchars != 0) { rc = fwrite (fcb->iobuffer, sizeof (char), numchars, fcb->pfile); if (rc != numchars) { numchars = 0; (void) fprintf (stderr, "VTF3: I/O error on output\n"); (void) fflush (stderr); } } if (numchars < VTF3_CONST_IOBUF_DIM) { if (fclose (fcb->pfile) != 0) { (void) fprintf (stderr, "VTF3: Error while closing output\n"); (void) fflush (stderr); } fcb->pfile = 0; fcb->filehasbeenclosed = 1; } return; } if (fcb->filecompressiontype == VTF3_FILECOMPRESSION_ZLIB) { numbytes = VTF3_GzWrite (&fcb->pfile, &fcb->zfile, fcb->iobuffer, numchars * sizeof (char)); if (numbytes == (-2)) { VTF3_NOMEM_GOOD_BYE_INFO; (void) exit (127); } else if (numbytes != (int) (numchars * sizeof (char))) { numbytes = 0; (void) fprintf (stderr, "VTF3: I/O error on Z-stream output\n"); (void) fflush (stderr); } if (fcb->pfile == 0) fcb->filehasbeenclosed = 1; else if (numbytes < (int) (VTF3_CONST_IOBUF_DIM * sizeof (char))) { if (VTF3_GzWrite (&fcb->pfile, &fcb->zfile, fcb->iobuffer, 0) != 0) { (void) fprintf (stderr, "VTF3: Error while closing " "Z-stream output\n"); (void) fflush (stderr); } if (fcb->pfile == 0) fcb->filehasbeenclosed = 1; else { (void) fprintf (stderr, "VTF3: FlushIoBuffer(): " "Unrecoverable error\n"); (void) fflush (stderr); (void) exit (127); } } return; } (void) fprintf (stderr, "VTF3: FlushIoBuffer(): Unrecoverable error\n"); (void) fflush (stderr); (void) exit (127); return; } static void FreeFcb (fcb_t *fcb) { unsigned int j; if (fcb->charptrvector != 0) (void) free (fcb->charptrvector); if (fcb->charvector != 0) (void) free (fcb->charvector); if (fcb->firsthandlerargs != 0) (void) free (fcb->firsthandlerargs); if (fcb->handlers != 0) (void) free (fcb->handlers); if (fcb->intvector != 0) (void) free (fcb->intvector); if (fcb->intvector2 != 0) (void) free (fcb->intvector2); if (fcb->iobuffer != 0) (void) free (fcb->iobuffer); if (fcb->recbuffer != 0) (void) free (fcb->recbuffer); if (fcb->stackhead0 != 0) { for (j = 0; j < fcb->stackheaddim; j++) (void) free ((fcb->stackhead0 + j)->stack0); (void) free (fcb->stackhead0); } if (fcb->stroffsetvectorbeyond != 0) (void) free (fcb->stroffsetvectorbeyond); if (fcb->stroffsetvectorstart != 0) (void) free (fcb->stroffsetvectorstart); if (fcb->u4vector != 0) (void) free (fcb->u4vector); if (fcb->uintvector != 0) (void) free (fcb->uintvector); /* This will kill them, if they accidently try to reuse it. */ (void) memset (fcb, 0, sizeof (fcb_t)); (void) free (fcb); return; } static void FstAsciiParser (fcb_t *fcb, int numcharsdata) { static double fdig [10] = { 0.0e+0, 1.0e+0, 2.0e+0, 3.0e+0, 4.0e+0, 5.0e+0, 6.0e+0, 7.0e+0, 8.0e+0, 9.0e+0}; char *p; int withminus, d, havetime, jp0, jp1, jp2, jk0, jk1, jk2, handlerindex; double time; unsigned int i1, i2, i; const char *pkw; fstasciiparser_t fstasciiparser; if (numcharsdata < 1) return; p = fcb->recbuffer + 0; if (*p == '-') { withminus = 1; d = vtfdigit[VTF3_CHAR2INDEX (*++p)]; if (d > 9) { (void) StdAsciiParser (fcb, numcharsdata); return; } } else if (*p == '+') { withminus = 0; d = vtfdigit[VTF3_CHAR2INDEX (*++p)]; if (d > 9) { (void) StdAsciiParser (fcb, numcharsdata); return; } } else { withminus = 0; d = vtfdigit[VTF3_CHAR2INDEX (*p)]; } time = 0.0e+0; if (d < 10) { havetime = 1; while (d < 10) { time = time * 10.0e+0 + fdig[d]; if (time > 1.0e+30) time = 1.0e+30; d = vtfdigit[VTF3_CHAR2INDEX (*++p)]; } if (withminus != 0 && time > 0.5e+0) time = -time; } else havetime = 0; jp0 = vtfletter[VTF3_CHAR2INDEX (*(p + 0))]; if (jp0 != 0) jp1 = vtfletter[VTF3_CHAR2INDEX (*(p + 1))]; else jp1 = 0; if (jp1 != 0) jp2 = vtfletter[VTF3_CHAR2INDEX (*(p + 2))]; else jp2 = 0; if (jp1 == 0 || jp2 != 0) { (void) StdAsciiParser (fcb, numcharsdata); return; } i1 = 0; i2 = (unsigned int) (sizeof (recordtypes) / sizeof (recordtypes[0])) - 1; while (i1 != i2) { i = (i1 + i2) >> 1; pkw = fstasciikwparser[i]; jk0 = vtfletter[VTF3_CHAR2INDEX (*(pkw + 0))]; if (jk0 != 0) jk1 = vtfletter[VTF3_CHAR2INDEX (*(pkw + 1))]; else jk1 = 0; if (jk1 != 0) jk2 = vtfletter[VTF3_CHAR2INDEX (*(pkw + 2))]; else jk2 = 0; if (jk0 < jp0) i1 = i + 1; else if (jk0 > jp0) i2 = i; else if (jk1 < jp1) i1 = i + 1; else if (jk1 > jp1) i2 = i; else if (jk2 < jp2) i1 = i + 1; else i2 = i; } i = i1; pkw = fstasciikwparser[i]; jk0 = vtfletter[VTF3_CHAR2INDEX (*(pkw + 0))]; if (jk0 != 0) jk1 = vtfletter[VTF3_CHAR2INDEX (*(pkw + 1))]; else jk1 = 0; if (jk1 != 0) jk2 = vtfletter[VTF3_CHAR2INDEX (*(pkw + 2))]; else jk2 = 0; if (jk0 != jp0 || jk1 != jp1 || jk2 != jp2) { (void) StdAsciiParser (fcb, numcharsdata); return; } fcb->recbufferpos = p + 2; handlerindex = fstasciikwparser2hi[i]; fstasciiparser = fstasciiparsers[handlerindex]; (void) (fstasciiparser) (fcb, numcharsdata, handlerindex, havetime, time); return; } static void FstAsciiWriteXy (fcb_t *fcb, double f) { static char dig [10] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9'}; unsigned int increment, ns, ex, m3, m2, m1, m0, ux, uy, udig; char convbuf [16]; union { unsigned char c [8]; double f; struct { unsigned int ns:1; unsigned int ex:15; unsigned int m3:5; unsigned int m2:16; unsigned int m1:16; unsigned int m0:11; } cray_native_type; struct { unsigned int ns:1; unsigned int ex:11; unsigned int m3:4; unsigned int m2:16; unsigned int m1:16; unsigned int m0:16; } ieee754_double_bigend; struct { unsigned int m0:16; unsigned int m1:16; unsigned int m2:16; unsigned int m3:4; unsigned int ex:11; unsigned int ns:1; } ieee754_double_litend; } fp; char *p; increment = (unsigned int) (sizeof (convbuf) / sizeof (convbuf[0])); increment++; increment *= 2; if (fcb->recbufferpos + increment > fcb->recbufferbeyond) (void) ReallocRecord (fcb, increment); fp.f = f; if (vtffprtype == VTF3_CONST_FPNRT_CRAY_NATIVE_TYPE) { ns = fp.cray_native_type.ns; ex = fp.cray_native_type.ex; m3 = fp.cray_native_type.m3; m2 = fp.cray_native_type.m2; m1 = fp.cray_native_type.m1; m0 = fp.cray_native_type.m0; if (ex == 0 && m3 == 0 && m2 == 0 && m1 == 0 && m0 == 0) { *fcb->recbufferpos++ = 'Y'; *fcb->recbufferpos++ = '0'; return; } if (ex < (unsigned int) 0x2003) { fp.cray_native_type.ex = (unsigned int) 0x2003; fp.cray_native_type.m3 = (unsigned int) 0x10; fp.cray_native_type.m2 = (unsigned int) 0x0000; fp.cray_native_type.m1 = (unsigned int) 0x0000; fp.cray_native_type.m0 = (unsigned int) 0x000; } else if (ex > (unsigned int) 0x5fff) { fp.cray_native_type.ex = (unsigned int) 0x5fff; fp.cray_native_type.m3 = (unsigned int) 0x10; fp.cray_native_type.m2 = (unsigned int) 0x0000; fp.cray_native_type.m1 = (unsigned int) 0x0000; fp.cray_native_type.m0 = (unsigned int) 0x000; } fp.cray_native_type.ns = 0; if (fp.f < 1.0e-300) fp.f = 1.0e-300; else if (fp.f > 1.0e+300) fp.f = 1.0e+300; fp.cray_native_type.ns = ns; ex = fp.cray_native_type.ex; m3 = fp.cray_native_type.m3; m2 = fp.cray_native_type.m2; m1 = fp.cray_native_type.m1; m0 = fp.cray_native_type.m0; ex -= (unsigned int) 0x3c02; m3 &= (unsigned int) 0xf; m0 <<= 5; fp.ieee754_double_bigend.ex = ex; fp.ieee754_double_bigend.m3 = m3; fp.ieee754_double_bigend.m2 = m2; fp.ieee754_double_bigend.m1 = m1; fp.ieee754_double_bigend.m0 = m0; /* Storing in little endian mode is a good idea. The exponent is always active, therefore it should go into the lower bytes. */ ux = ((unsigned int) fp.c[4] << 0) + ((unsigned int) fp.c[5] << 8) + ((unsigned int) fp.c[6] << 16) + ((unsigned int) fp.c[7] << 24); uy = ((unsigned int) fp.c[0] << 0) + ((unsigned int) fp.c[1] << 8) + ((unsigned int) fp.c[2] << 16) + ((unsigned int) fp.c[3] << 24); if (ux != 0) { *fcb->recbufferpos++ = 'X'; p = &convbuf[sizeof (convbuf) / sizeof (convbuf[0]) - 1]; *p-- = '\0'; while (ux != 0) { udig = ux % 10; *p-- = dig[udig]; ux -= udig; ux /= 10; } p++; while (*p != '\0') *fcb->recbufferpos++ = *p++; } if (uy != 0) { *fcb->recbufferpos++ = 'Y'; p = &convbuf[sizeof (convbuf) / sizeof (convbuf[0]) - 1]; *p-- = '\0'; while (uy != 0) { udig = uy % 10; *p-- = dig[udig]; uy -= udig; uy /= 10; } p++; while (*p != '\0') *fcb->recbufferpos++ = *p++; } return; } if (vtffprtype == VTF3_CONST_FPNRT_IEEE754_DOUBLE_BIGEND) { ns = fp.ieee754_double_bigend.ns; ex = fp.ieee754_double_bigend.ex; m3 = fp.ieee754_double_bigend.m3; m2 = fp.ieee754_double_bigend.m2; m1 = fp.ieee754_double_bigend.m1; m0 = fp.ieee754_double_bigend.m0; if (ex == 0 && m3 == 0 && m2 == 0 && m1 == 0 && m0 == 0) { *fcb->recbufferpos++ = 'Y'; *fcb->recbufferpos++ = '0'; return; } if (ex < (unsigned int) 0x002) { fp.ieee754_double_bigend.ex = (unsigned int) 0x002; fp.ieee754_double_bigend.m3 = (unsigned int) 0x0; fp.ieee754_double_bigend.m2 = (unsigned int) 0x0000; fp.ieee754_double_bigend.m1 = (unsigned int) 0x0000; fp.ieee754_double_bigend.m0 = (unsigned int) 0x0000; } else if (ex > (unsigned int) 0x7fd) { fp.ieee754_double_bigend.ex = (unsigned int) 0x7fd; fp.ieee754_double_bigend.m3 = (unsigned int) 0xf; fp.ieee754_double_bigend.m2 = (unsigned int) 0xffff; fp.ieee754_double_bigend.m1 = (unsigned int) 0xffff; fp.ieee754_double_bigend.m0 = (unsigned int) 0xffff; } fp.ieee754_double_bigend.ns = 0; if (fp.f < 1.0e-300) fp.f = 1.0e-300; else if (fp.f > 1.0e+300) fp.f = 1.0e+300; fp.ieee754_double_bigend.ns = ns; /* Storing in little endian mode is a good idea. The exponent is always active, therefore it should go into the lower bytes. */ ux = ((unsigned int) fp.c[4] << 0) + ((unsigned int) fp.c[5] << 8) + ((unsigned int) fp.c[6] << 16) + ((unsigned int) fp.c[7] << 24); uy = ((unsigned int) fp.c[0] << 0) + ((unsigned int) fp.c[1] << 8) + ((unsigned int) fp.c[2] << 16) + ((unsigned int) fp.c[3] << 24); if (ux != 0) { *fcb->recbufferpos++ = 'X'; p = &convbuf[sizeof (convbuf) / sizeof (convbuf[0]) - 1]; *p-- = '\0'; while (ux != 0) { udig = ux % 10; *p-- = dig[udig]; ux -= udig; ux /= 10; } p++; while (*p != '\0') *fcb->recbufferpos++ = *p++; } if (uy != 0) { *fcb->recbufferpos++ = 'Y'; p = &convbuf[sizeof (convbuf) / sizeof (convbuf[0]) - 1]; *p-- = '\0'; while (uy != 0) { udig = uy % 10; *p-- = dig[udig]; uy -= udig; uy /= 10; } p++; while (*p != '\0') *fcb->recbufferpos++ = *p++; } return; } if (vtffprtype == VTF3_CONST_FPNRT_IEEE754_DOUBLE_LITEND) { ns = fp.ieee754_double_litend.ns; ex = fp.ieee754_double_litend.ex; m3 = fp.ieee754_double_litend.m3; m2 = fp.ieee754_double_litend.m2; m1 = fp.ieee754_double_litend.m1; m0 = fp.ieee754_double_litend.m0; if (ex == 0 && m3 == 0 && m2 == 0 && m1 == 0 && m0 == 0) { *fcb->recbufferpos++ = 'Y'; *fcb->recbufferpos++ = '0'; return; } if (ex < (unsigned int) 0x002) { fp.ieee754_double_litend.ex = (unsigned int) 0x002; fp.ieee754_double_litend.m3 = (unsigned int) 0x0; fp.ieee754_double_litend.m2 = (unsigned int) 0x0000; fp.ieee754_double_litend.m1 = (unsigned int) 0x0000; fp.ieee754_double_litend.m0 = (unsigned int) 0x0000; } else if (ex > (unsigned int) 0x7fd) { fp.ieee754_double_litend.ex = (unsigned int) 0x7fd; fp.ieee754_double_litend.m3 = (unsigned int) 0xf; fp.ieee754_double_litend.m2 = (unsigned int) 0xffff; fp.ieee754_double_litend.m1 = (unsigned int) 0xffff; fp.ieee754_double_litend.m0 = (unsigned int) 0xffff; } fp.ieee754_double_litend.ns = 0; if (fp.f < 1.0e-300) fp.f = 1.0e-300; else if (fp.f > 1.0e+300) fp.f = 1.0e+300; fp.ieee754_double_litend.ns = ns; /* Storing in little endian mode is a good idea. The exponent is always active, therefore it should go into the lower bytes. */ ux = ((unsigned int) fp.c[3] << 0) + ((unsigned int) fp.c[2] << 8) + ((unsigned int) fp.c[1] << 16) + ((unsigned int) fp.c[0] << 24); uy = ((unsigned int) fp.c[7] << 0) + ((unsigned int) fp.c[6] << 8) + ((unsigned int) fp.c[5] << 16) + ((unsigned int) fp.c[4] << 24); if (ux != 0) { *fcb->recbufferpos++ = 'X'; p = &convbuf[sizeof (convbuf) / sizeof (convbuf[0]) - 1]; *p-- = '\0'; while (ux != 0) { udig = ux % 10; *p-- = dig[udig]; ux -= udig; ux /= 10; } p++; while (*p != '\0') *fcb->recbufferpos++ = *p++; } if (uy != 0) { *fcb->recbufferpos++ = 'Y'; p = &convbuf[sizeof (convbuf) / sizeof (convbuf[0]) - 1]; *p-- = '\0'; while (uy != 0) { udig = uy % 10; *p-- = dig[udig]; uy -= udig; uy /= 10; } p++; while (*p != '\0') *fcb->recbufferpos++ = *p++; } return; } (void) fprintf (stderr, "VTF3: Unknown FP representation type\n"); (void) fflush (stderr); (void) exit (127); return; } static double GetDoubleFromXy (unsigned int ux, unsigned int uy) { union { unsigned char c [8]; double f; struct { unsigned int ns:1; unsigned int ex:15; unsigned int m3:5; unsigned int m2:16; unsigned int m1:16; unsigned int m0:11; } cray_native_type; struct { unsigned int ns:1; unsigned int ex:11; unsigned int m3:4; unsigned int m2:16; unsigned int m1:16; unsigned int m0:16; } ieee754_double_bigend; struct { unsigned int m0:16; unsigned int m1:16; unsigned int m2:16; unsigned int m3:4; unsigned int ex:11; unsigned int ns:1; } ieee754_double_litend; } fp; unsigned int ex, m3, m2, m1, m0, ns; if (vtffprtype == VTF3_CONST_FPNRT_CRAY_NATIVE_TYPE) { fp.c[4] = (unsigned char) (ux >> 0 & (unsigned int) 0xff); fp.c[5] = (unsigned char) (ux >> 8 & (unsigned int) 0xff); fp.c[6] = (unsigned char) (ux >> 16 & (unsigned int) 0xff); fp.c[7] = (unsigned char) (ux >> 24 & (unsigned int) 0xff); fp.c[0] = (unsigned char) (uy >> 0 & (unsigned int) 0xff); fp.c[1] = (unsigned char) (uy >> 8 & (unsigned int) 0xff); fp.c[2] = (unsigned char) (uy >> 16 & (unsigned int) 0xff); fp.c[3] = (unsigned char) (uy >> 24 & (unsigned int) 0xff); ex = fp.ieee754_double_bigend.ex; m3 = fp.ieee754_double_bigend.m3; m2 = fp.ieee754_double_bigend.m2; m1 = fp.ieee754_double_bigend.m1; m0 = fp.ieee754_double_bigend.m0; if (ex == 0 && m3 == 0 && m2 == 0 && m1 == 0 && m0 == 0) return (0.0e+0); if (ex < (unsigned int) 0x002) { ex = (unsigned int) 0x002; m3 = (unsigned int) 0x0; m2 = (unsigned int) 0x0000; m1 = (unsigned int) 0x0000; m0 = (unsigned int) 0x0000; } else if (ex > (unsigned int) 0x7fd) { ex = (unsigned int) 0x7fd; m3 = (unsigned int) 0xf; m2 = (unsigned int) 0xffff; m1 = (unsigned int) 0xffff; m0 = (unsigned int) 0xffff; } ex += (unsigned int) 0x3c02; m3 += (unsigned int) 0x10; m0 >>= 5; fp.cray_native_type.ex = ex; fp.cray_native_type.m3 = m3; fp.cray_native_type.m2 = m2; fp.cray_native_type.m1 = m1; fp.cray_native_type.m0 = m0; ns = fp.cray_native_type.ns; fp.cray_native_type.ns = 0; if (fp.f < 1.0e-300) fp.f = 1.0e-300; else if (fp.f > 1.0e+300) fp.f = 1.0e+300; fp.cray_native_type.ns = ns; return (fp.f); } if (vtffprtype == VTF3_CONST_FPNRT_IEEE754_DOUBLE_BIGEND) { fp.c[4] = (unsigned char) (ux >> 0 & (unsigned int) 0xff); fp.c[5] = (unsigned char) (ux >> 8 & (unsigned int) 0xff); fp.c[6] = (unsigned char) (ux >> 16 & (unsigned int) 0xff); fp.c[7] = (unsigned char) (ux >> 24 & (unsigned int) 0xff); fp.c[0] = (unsigned char) (uy >> 0 & (unsigned int) 0xff); fp.c[1] = (unsigned char) (uy >> 8 & (unsigned int) 0xff); fp.c[2] = (unsigned char) (uy >> 16 & (unsigned int) 0xff); fp.c[3] = (unsigned char) (uy >> 24 & (unsigned int) 0xff); ex = fp.ieee754_double_bigend.ex; m3 = fp.ieee754_double_bigend.m3; m2 = fp.ieee754_double_bigend.m2; m1 = fp.ieee754_double_bigend.m1; m0 = fp.ieee754_double_bigend.m0; if (ex == 0 && m3 == 0 && m2 == 0 && m1 == 0 && m0 == 0) return (0.0e+0); if (ex < (unsigned int) 0x002) { fp.ieee754_double_bigend.ex = (unsigned int) 0x002; fp.ieee754_double_bigend.m3 = (unsigned int) 0x0; fp.ieee754_double_bigend.m2 = (unsigned int) 0x0000; fp.ieee754_double_bigend.m1 = (unsigned int) 0x0000; fp.ieee754_double_bigend.m0 = (unsigned int) 0x0000; } else if (ex > (unsigned int) 0x7fd) { fp.ieee754_double_bigend.ex = (unsigned int) 0x7fd; fp.ieee754_double_bigend.m3 = (unsigned int) 0xf; fp.ieee754_double_bigend.m2 = (unsigned int) 0xffff; fp.ieee754_double_bigend.m1 = (unsigned int) 0xffff; fp.ieee754_double_bigend.m0 = (unsigned int) 0xffff; } ns = fp.ieee754_double_bigend.ns; fp.ieee754_double_bigend.ns = 0; if (fp.f < 1.0e-300) fp.f = 1.0e-300; else if (fp.f > 1.0e+300) fp.f = 1.0e+300; fp.ieee754_double_bigend.ns = ns; return (fp.f); } if (vtffprtype == VTF3_CONST_FPNRT_IEEE754_DOUBLE_LITEND) { fp.c[3] = (unsigned char) (ux >> 0 & (unsigned int) 0xff); fp.c[2] = (unsigned char) (ux >> 8 & (unsigned int) 0xff); fp.c[1] = (unsigned char) (ux >> 16 & (unsigned int) 0xff); fp.c[0] = (unsigned char) (ux >> 24 & (unsigned int) 0xff); fp.c[7] = (unsigned char) (uy >> 0 & (unsigned int) 0xff); fp.c[6] = (unsigned char) (uy >> 8 & (unsigned int) 0xff); fp.c[5] = (unsigned char) (uy >> 16 & (unsigned int) 0xff); fp.c[4] = (unsigned char) (uy >> 24 & (unsigned int) 0xff); ex = fp.ieee754_double_litend.ex; m3 = fp.ieee754_double_litend.m3; m2 = fp.ieee754_double_litend.m2; m1 = fp.ieee754_double_litend.m1; m0 = fp.ieee754_double_litend.m0; if (ex == 0 && m3 == 0 && m2 == 0 && m1 == 0 && m0 == 0) return (0.0e+0); if (ex < (unsigned int) 0x002) { fp.ieee754_double_litend.ex = (unsigned int) 0x002; fp.ieee754_double_litend.m3 = (unsigned int) 0x0; fp.ieee754_double_litend.m2 = (unsigned int) 0x0000; fp.ieee754_double_litend.m1 = (unsigned int) 0x0000; fp.ieee754_double_litend.m0 = (unsigned int) 0x0000; } else if (ex > (unsigned int) 0x7fd) { fp.ieee754_double_litend.ex = (unsigned int) 0x7fd; fp.ieee754_double_litend.m3 = (unsigned int) 0xf; fp.ieee754_double_litend.m2 = (unsigned int) 0xffff; fp.ieee754_double_litend.m1 = (unsigned int) 0xffff; fp.ieee754_double_litend.m0 = (unsigned int) 0xffff; } ns = fp.ieee754_double_litend.ns; fp.ieee754_double_litend.ns = 0; if (fp.f < 1.0e-300) fp.f = 1.0e-300; else if (fp.f > 1.0e+300) fp.f = 1.0e+300; fp.ieee754_double_litend.ns = ns; return (fp.f); } (void) fprintf (stderr, "VTF3: Unknown FP representation type\n"); (void) fflush (stderr); (void) exit (127); return (0.0e+0); } static int GetFileCompressionType (const char *filename) { const char *p; p = filename; while (*p != '\0') p++; if (p > filename) p--; if (p > filename) p--; if (p > filename) p--; if (p == filename) goto NoCompression; if (vtfupper[VTF3_CHAR2INDEX (*p++)] != '.') goto NoCompression; if (vtfupper[VTF3_CHAR2INDEX (*p++)] != 'G') goto NoCompression; if (vtfupper[VTF3_CHAR2INDEX (*p++)] != 'Z') goto NoCompression; return (VTF3_FILECOMPRESSION_ZLIB); /* LABEL */ NoCompression: return (VTF3_FILECOMPRESSION_NONE); } static int GetStringLength (fcb_t *fcb, int index) { int start, beyond; if (fcb->stroffsetvectorstart == 0) { (void) fprintf (stderr, "VTF3: GetStringLength(): Unrecoverable error\n"); (void) fflush (stderr); (void) exit (127); } if (fcb->stroffsetvectorbeyond == 0) { (void) fprintf (stderr, "VTF3: GetStringLength(): Unrecoverable error\n"); (void) fflush (stderr); (void) exit (127); } if (index + 1 > fcb->stroffsetvectordim) { (void) fprintf (stderr, "VTF3: GetStringLength(): Unrecoverable error\n"); (void) fflush (stderr); (void) exit (127); } start = *(fcb->stroffsetvectorstart + index); beyond = *(fcb->stroffsetvectorbeyond + index); return (beyond - start); } static void HandleBadRecord (fcb_t *fcb, int numcharsdata, int handlerindex) { VTF3_DCL_UNRECOGNIZABLE (typedef, (*handler_t)); handler_t handler; int numcharsrecord, rc; handler = (handler_t) *(fcb->handlers + vtfunrecognizablehandlerindex); if (handler == 0) return; if (handler == (handler_t) VTF3_DebugHandler) { (void) fprintf (stderr, "VTF3: Will not invoke VTF3_DebugHandler() " "for %s\n", stdasciikeywords[vtfunrecognizablehandlerindex]); (void) fflush (stderr); (void) exit (127); } if (fcb->fileformat == VTF3_FILEFORMAT_STD_ASCII) numcharsrecord = numcharsdata + 1; else if (fcb->fileformat == VTF3_FILEFORMAT_STD_BINARY) numcharsrecord = numcharsdata + 6; else if (fcb->fileformat == VTF3_FILEFORMAT_FST_ASCII) numcharsrecord = numcharsdata + 1; else { numcharsrecord = 0; (void) fprintf (stderr, "VTF3: HandleBadRecord(): " "Unrecoverable error\n"); (void) fflush (stderr); (void) exit (127); } rc = (handler) (*(fcb->firsthandlerargs + vtfunrecognizablehandlerindex), fcb->lastvalidtime, numcharsrecord, recordtypes[handlerindex], fcb->recbuffer); if (rc < 0) { (void) fprintf (stderr, "VTF3: %s handler returned %d\n", stdasciikeywords[vtfunrecognizablehandlerindex], rc); (void) fflush (stderr); (void) exit (127); } return; } static const char * KeyWordByRecType (int recordtype) { unsigned int i1, i2, i; i1 = 0; i2 = (unsigned int) (sizeof (recordtypes) / sizeof (recordtypes[0])) - 1; while (i1 != i2) { i = (i1 + i2) >> 1; if (recordtypes[i] < recordtype) i1 = i + 1; else i2 = i; } i = i1; if (recordtype != recordtypes[i]) { (void) fprintf (stderr, "VTF3: KeyWordByRecType(): " "Unrecoverable error\n"); (void) fflush (stderr); (void) exit (127); } return (stdasciikeywords[i]); } static int KeyWordComp (const char *key1, const char *key2) { int k1, k2, dk; k1 = vtfletter[VTF3_CHAR2INDEX (*key1++)]; k2 = vtfletter[VTF3_CHAR2INDEX (*key2++)]; dk = k1 - k2; while (dk == 0 && k1 != 0) { k1 = vtfletter[VTF3_CHAR2INDEX (*key1++)]; k2 = vtfletter[VTF3_CHAR2INDEX (*key2++)]; dk = k1 - k2; } return (dk); } static double LoadDoubleFromU4Array (const void *u4array, int index) { union { unsigned char c [8]; double f; } fp; fp.c[0] = *((unsigned char *) u4array + (index << 2) + 0); fp.c[1] = *((unsigned char *) u4array + (index << 2) + 1); fp.c[2] = *((unsigned char *) u4array + (index << 2) + 2); fp.c[3] = *((unsigned char *) u4array + (index << 2) + 3); fp.c[4] = *((unsigned char *) u4array + (index << 2) + 4); fp.c[5] = *((unsigned char *) u4array + (index << 2) + 5); fp.c[6] = *((unsigned char *) u4array + (index << 2) + 6); fp.c[7] = *((unsigned char *) u4array + (index << 2) + 7); return (fp.f); } static unsigned int LoadUintFromU4Array (const void *u4array, int index) { unsigned char c0, c1, c2, c3; unsigned int u; c0 = *((unsigned char *) u4array + (index << 2) + 0); c1 = *((unsigned char *) u4array + (index << 2) + 1); c2 = *((unsigned char *) u4array + (index << 2) + 2); c3 = *((unsigned char *) u4array + (index << 2) + 3); if (vtffprtype == VTF3_CONST_FPNRT_IEEE754_DOUBLE_LITEND) u = ((unsigned int) c0 << 0) + ((unsigned int) c1 << 8) + ((unsigned int) c2 << 16) + ((unsigned int) c3 << 24); else u = ((unsigned int) c3 << 0) + ((unsigned int) c2 << 8) + ((unsigned int) c1 << 16) + ((unsigned int) c0 << 24); return (u); } static int MemCmp (const void *m1, const void *m2, size_t n) { const unsigned char *s1, *s2; size_t i; int delta; s1 = (const unsigned char *) m1; s2 = (const unsigned char *) m2; for (i = 0; i < n / sizeof (unsigned char); i++) { delta = (int) (unsigned int) *(s1 + i) - (int) (unsigned int) *(s2 + i); if (delta != 0) return (delta); } return (0); } static double PassF (double f) { return (f); } static int PassI (int i) { return (i); } static const void * PassP (const void *p) { return (p); } static unsigned int PassU (unsigned int u) { return (u); } static void PrepVersion (void) { char *p1, *p2; const char *constp1; vtfversionbuf[0] = 'T'; vtfversionbuf[1] = 'U'; vtfversionbuf[2] = 'D'; vtfversionbuf[3] = '/'; vtfversionbuf[4] = 'Z'; vtfversionbuf[5] = 'H'; vtfversionbuf[6] = 'R'; vtfversionbuf[7] = ' '; p1 = &rcsid[0]; p2 = &vtfversionbuf[8]; while (*p1 != ':' && *p1 != '\0') p1++; while (*p1 == ':') p1++; while (*p1 == ' ') p1++; while (*p1 != '.' && *p1 != '\0') *p2++ = *p1++; *p2++ = ' '; while (*p1 != ' ' && *p1 != '\0') p1++; while (*p1 == ' ') p1++; while (*p1 != ' ' && *p1 != '\0') *p2++ = *p1++; *p2++ = ' '; while (*p1 == ' ') p1++; while (*p1 != '2' && *p1 != '\0') p1++; while (*p1 != ' ' && *p1 != '\0') *p2++ = *p1++; *p2++ = ' '; while (*p1 == ' ') p1++; while (*p1 != ' ' && *p1 != '\0') *p2++ = *p1++; *p2 = '\0'; if (VTF3_HaveZlib () == 0) return; *p2++ = ' '; *p2++ = 'w'; *p2++ = 'i'; *p2++ = 't'; *p2++ = 'h'; *p2++ = ' '; *p2++ = 'z'; *p2++ = 'l'; *p2++ = 'i'; *p2++ = 'b'; *p2++ = ' '; constp1 = VTF3_GetZlibVersion (); while (*constp1 != '\0') *p2++ = *constp1++; *p2 = '\0'; return; } /* the version number is construced from the rcsid of this file which is inserted by cvs */ static void PrepVersionNumber (void) { char *p; unsigned int n1, urefmax, uout, u, uref, n2, n3; p = &vtfversionbuf[0]; while (*p != '3' && *p != '\0') p++; if (*p++ != '3') return; n1 = 3; if (*p++ != ' ') return; while (*p == ' ') p++; if (vtfdigit[VTF3_CHAR2INDEX (*p)] > 9) return; urefmax = (unsigned int) 0xffffffff; uout = 0; while ((u = (unsigned int) vtfdigit[VTF3_CHAR2INDEX (*p)]) < 10) { p++; uref = urefmax - u; uref = uref - uref % 10; uref /= 10; if (uout > uref) { uout = urefmax; continue; } uout = uout * 10 + u; } n2 = uout; if (*p++ != '.') return; if (vtfdigit[VTF3_CHAR2INDEX (*p)] > 9) return; uout = 0; while ((u = (unsigned int) vtfdigit[VTF3_CHAR2INDEX (*p)]) < 10) { p++; uref = urefmax - u; uref = uref - uref % 10; uref /= 10; if (uout > uref) { uout = urefmax; continue; } uout = uout * 10 + u; } n3 = uout; if (*p != ' ') return; if (n2 > 999) return; if (n3 > 9999) return; n1 *= 1000; n1 += n2; n1 *= 10000; n1 += n3; vtfversionnumber = PassI (* (int *) &n1); return; } static void QuickSortKeyWords (const char **keywords, int *kw2hi, unsigned int left, unsigned int right) { unsigned int l1, r1, c1; const char *keywordref, *keywordaux; int kw2hiaux; l1 = left + 1; r1 = right + 1; c1 = (l1 + r1) >> 1; keywordref = *(keywords + c1 - 1); while (l1 <= r1) { while (KeyWordComp (*(keywords + l1 - 1), keywordref) < 0) l1++; while (KeyWordComp (keywordref, *(keywords + r1 - 1)) < 0) r1--; if (l1 < r1) { keywordaux = *(keywords + l1 - 1); *(keywords + l1 - 1) = *(keywords + r1 - 1); *(keywords + r1 - 1) = keywordaux; kw2hiaux = *(kw2hi + l1 - 1); *(kw2hi + l1 - 1) = *(kw2hi + r1 - 1); *(kw2hi + r1 - 1) = kw2hiaux; } if (l1 <= r1) { l1++; r1--; } } if (left + 1 < r1) (void) QuickSortKeyWords (keywords, kw2hi, left, r1 - 1); if (l1 < right + 1) (void) QuickSortKeyWords (keywords, kw2hi, l1 - 1, right); return; } static void QuickSortRecTypes (int *recordtypes, const char **stdasciikeywords, const char **fstasciikeywords, VTF3_handler_t *copyhandlers, stdasciiparser_t *stdasciiparsers, stdbinaryparser_t *stdbinaryparsers, fstasciiparser_t *fstasciiparsers, unsigned int left, unsigned int right) { unsigned int l1, r1, c1; int recordtyperef, recordtypeaux; const char *stdasciikeywordaux, *fstasciikeywordaux; VTF3_handler_t copyhandleraux; stdasciiparser_t stdasciiparseraux; stdbinaryparser_t stdbinaryparseraux; fstasciiparser_t fstasciiparseraux; l1 = left + 1; r1 = right + 1; c1 = (l1 + r1) >> 1; recordtyperef = *(recordtypes + c1 - 1); while (l1 <= r1) { while (*(recordtypes + l1 - 1) < recordtyperef) l1++; while (recordtyperef < *(recordtypes + r1 - 1)) r1--; if (l1 < r1) { recordtypeaux = *(recordtypes + l1 - 1); *(recordtypes + l1 - 1) = *(recordtypes + r1 - 1); *(recordtypes + r1 - 1) = recordtypeaux; stdasciikeywordaux = *(stdasciikeywords + l1 - 1); *(stdasciikeywords + l1 - 1) = *(stdasciikeywords + r1 - 1); *(stdasciikeywords + r1 - 1) = stdasciikeywordaux; fstasciikeywordaux = *(fstasciikeywords + l1 - 1); *(fstasciikeywords + l1 - 1) = *(fstasciikeywords + r1 - 1); *(fstasciikeywords + r1 - 1) = fstasciikeywordaux; copyhandleraux = *(copyhandlers + l1 - 1); *(copyhandlers + l1 - 1) = *(copyhandlers + r1 - 1); *(copyhandlers + r1 - 1) = copyhandleraux; stdasciiparseraux = *(stdasciiparsers + l1 - 1); *(stdasciiparsers + l1 - 1) = *(stdasciiparsers + r1 - 1); *(stdasciiparsers + r1 - 1) = stdasciiparseraux; stdbinaryparseraux = *(stdbinaryparsers + l1 - 1); *(stdbinaryparsers + l1 - 1) = *(stdbinaryparsers + r1 - 1); *(stdbinaryparsers + r1 - 1) = stdbinaryparseraux; fstasciiparseraux = *(fstasciiparsers + l1 - 1); *(fstasciiparsers + l1 - 1) = *(fstasciiparsers + r1 - 1); *(fstasciiparsers + r1 - 1) = fstasciiparseraux; } if (l1 <= r1) { l1++; r1--; } } if (left + 1 < r1) (void) QuickSortRecTypes (recordtypes, stdasciikeywords, fstasciikeywords, copyhandlers, stdasciiparsers, stdbinaryparsers, fstasciiparsers, left, r1 - 1); if (l1 < right + 1) (void) QuickSortRecTypes (recordtypes, stdasciikeywords, fstasciikeywords, copyhandlers, stdasciiparsers, stdbinaryparsers, fstasciiparsers, l1 - 1, right); return; } static void ReadInputLtd (fcb_t *fcb, size_t *pbytestoberead, int *precordstoberead) { static unsigned int first = 1; static const unsigned char stdbinaryheader [] = VTF3_HEADER_STD_BINARY; size_t bytestoberead, bytesread, zfilepositionfrmr; int recordstoberead, recordsread, numcharsrecord; if (first != 0) { first = 0; (void) PassP (stdbinaryheader); } if (fcb->filecompressiontype == VTF3_FILECOMPRESSION_NONE) { bytestoberead = fcb->headerbytesnotcounted != 0 && fcb->headerbytesnotcounted >= *pbytestoberead ? fcb->headerbytesnotcounted + 1 : *pbytestoberead; recordstoberead = *precordstoberead; bytesread = fcb->headerbytesnotcounted; recordsread = 0; fcb->headerbytesnotcounted = 0; if (fcb->fileformat == VTF3_FILEFORMAT_STD_ASCII) while (bytesread < bytestoberead && recordsread < recordstoberead) { numcharsrecord = StdAsciiReadRecord (fcb); if (numcharsrecord == 0) break; else if (numcharsrecord > 0) { (void) StdAsciiParser (fcb, numcharsrecord - 1); bytesread += (size_t) numcharsrecord * sizeof (char); } else { /* Repaired EOF without '\n'. */ numcharsrecord = -numcharsrecord; (void) StdAsciiParser (fcb, numcharsrecord - 1); bytesread += (size_t) (numcharsrecord - 1) * sizeof (char); } recordsread++; } else if (fcb->fileformat == VTF3_FILEFORMAT_STD_BINARY) while (bytesread < bytestoberead && recordsread < recordstoberead) { numcharsrecord = StdBinaryReadRecord (fcb); if (numcharsrecord == (-1)) { /* Standard binary format header found. */ bytesread += sizeof (stdbinaryheader); continue; } if (numcharsrecord < 6) break; (void) StdBinaryParser (fcb, numcharsrecord - 6); bytesread += (size_t) numcharsrecord * sizeof (char); recordsread++; } else if (fcb->fileformat == VTF3_FILEFORMAT_FST_ASCII) while (bytesread < bytestoberead && recordsread < recordstoberead) { numcharsrecord = StdAsciiReadRecord (fcb); if (numcharsrecord == 0) break; else if (numcharsrecord > 0) { (void) FstAsciiParser (fcb, numcharsrecord - 1); bytesread += (size_t) numcharsrecord * sizeof (char); } else { /* Repaired EOF without '\n'. */ numcharsrecord = -numcharsrecord; (void) FstAsciiParser (fcb, numcharsrecord - 1); bytesread += (size_t) (numcharsrecord - 1) * sizeof (char); } recordsread++; } else { (void) fprintf (stderr, "VTF3: File format %d not yet implemented\n", fcb->fileformat); (void) fflush (stderr); } *pbytestoberead = bytesread; *precordstoberead = recordsread; return; } if (fcb->filecompressiontype == VTF3_FILECOMPRESSION_ZLIB) { zfilepositionfrmr = fcb->zfilepositionfrmr == 0 ? 0 : fcb->zfileposition; bytestoberead = fcb->zfilepositionfrmr == 0 && fcb->zfileposition >= *pbytestoberead ? fcb->zfileposition + 1 : *pbytestoberead; recordstoberead = *precordstoberead; bytesread = 0; recordsread = 0; if (fcb->fileformat == VTF3_FILEFORMAT_STD_ASCII) while (bytesread < bytestoberead && recordsread < recordstoberead) { numcharsrecord = StdAsciiReadRecord (fcb); bytesread = fcb->zfileposition - zfilepositionfrmr; if (numcharsrecord == 0) break; if (numcharsrecord < 0) numcharsrecord = -numcharsrecord; (void) StdAsciiParser (fcb, numcharsrecord - 1); recordsread++; } else if (fcb->fileformat == VTF3_FILEFORMAT_STD_BINARY) while (bytesread < bytestoberead && recordsread < recordstoberead) { numcharsrecord = StdBinaryReadRecord (fcb); bytesread = fcb->zfileposition - zfilepositionfrmr; if (numcharsrecord == (-1)) /* Standard binary format header found. */ continue; if (numcharsrecord < 6) break; (void) StdBinaryParser (fcb, numcharsrecord - 6); recordsread++; } else if (fcb->fileformat == VTF3_FILEFORMAT_FST_ASCII) while (bytesread < bytestoberead && recordsread < recordstoberead) { numcharsrecord = StdAsciiReadRecord (fcb); bytesread = fcb->zfileposition - zfilepositionfrmr; if (numcharsrecord == 0) break; if (numcharsrecord < 0) numcharsrecord = -numcharsrecord; (void) FstAsciiParser (fcb, numcharsrecord - 1); recordsread++; } else { (void) fprintf (stderr, "VTF3: File format %d not yet implemented\n", fcb->fileformat); (void) fflush (stderr); } fcb->zfilepositionfrmr = fcb->zfileposition; *pbytestoberead = bytesread; *precordstoberead = recordsread; return; } (void) fprintf (stderr, "VTF3: ReadInputLtd(): Unrecoverable error\n"); (void) fflush (stderr); (void) exit (127); return; } static void ReallocRecord (fcb_t *fcb, unsigned int increment) { unsigned int beyondoffset, posoffset, newdim; size_t size; beyondoffset = (unsigned int) (fcb->recbufferbeyond - fcb->recbuffer); posoffset = (unsigned int) (fcb->recbufferpos - fcb->recbuffer); newdim = posoffset + increment; if (newdim <= beyondoffset) { (void) fprintf (stderr, "VTF3: ReallocRecord(): Unrecoverable error\n"); (void) fflush (stderr); (void) exit (127); } size = (size_t) newdim * sizeof (char); if (newdim > VTF3_CONST_MAX_RECBUF_DIM) { (void) fprintf (stderr, "VTF3: Too long record, %lu bytes\n", (unsigned long) size); (void) fflush (stderr); VTF3_NOMEM_GOOD_BYE_INFO; (void) exit (127); } if (fcb->recbuffer == 0) fcb->recbuffer = (char *) malloc (size); else fcb->recbuffer = (char *) realloc (fcb->recbuffer, size); if (fcb->recbuffer == 0) { VTF3_NOMEM_GOOD_BYE_INFO; (void) exit (127); } fcb->recbufferbeyond = fcb->recbuffer + newdim; fcb->recbufferpos = fcb->recbuffer + posoffset; return; } static void SetFprType (void) { double f; union { double f; struct { unsigned int ns:1; unsigned int ex:15; unsigned int m2:16; unsigned int m1:16; unsigned int m0:16; } cray_native_type; struct { unsigned int ns:1; unsigned int ex:11; unsigned int m3:4; unsigned int m2:16; unsigned int m1:16; unsigned int m0:16; } ieee754_double_bigend; struct { unsigned int m0:16; unsigned int m1:16; unsigned int m2:16; unsigned int m3:4; unsigned int ex:11; unsigned int ns:1; } ieee754_double_litend; } fp; f = PassF (-30.0e+0); vtffprtype = VTF3_CONST_FPNRT_CRAY_NATIVE_TYPE; fp.cray_native_type.ns = (unsigned int) 0x1; fp.cray_native_type.ex = (unsigned int) 0x4005; fp.cray_native_type.m2 = (unsigned int) 0xf000; fp.cray_native_type.m1 = (unsigned int) 0x0000; fp.cray_native_type.m0 = (unsigned int) 0x0000; if (MemCmp (&fp.f, &f, sizeof (double)) == 0) return; vtffprtype = VTF3_CONST_FPNRT_IEEE754_DOUBLE_BIGEND; fp.ieee754_double_bigend.ns = (unsigned int) 0x1; fp.ieee754_double_bigend.ex = (unsigned int) 0x403; fp.ieee754_double_bigend.m3 = (unsigned int) 0xe; fp.ieee754_double_bigend.m2 = (unsigned int) 0x0000; fp.ieee754_double_bigend.m1 = (unsigned int) 0x0000; fp.ieee754_double_bigend.m0 = (unsigned int) 0x0000; if (MemCmp (&fp.f, &f, sizeof (double)) == 0) return; vtffprtype = VTF3_CONST_FPNRT_IEEE754_DOUBLE_LITEND; fp.ieee754_double_litend.ns = (unsigned int) 0x1; fp.ieee754_double_litend.ex = (unsigned int) 0x403; fp.ieee754_double_litend.m3 = (unsigned int) 0xe; fp.ieee754_double_litend.m2 = (unsigned int) 0x0000; fp.ieee754_double_litend.m1 = (unsigned int) 0x0000; fp.ieee754_double_litend.m0 = (unsigned int) 0x0000; if (MemCmp (&fp.f, &f, sizeof (double)) == 0) return; (void) fprintf (stderr, "VTF3: Unknown FP representation type\n"); (void) fflush (stderr); (void) exit (127); return; } static int SignOfDouble (double f) { union { double f; struct { unsigned int ns:1; unsigned int ex:15; unsigned int m2:16; unsigned int m1:16; unsigned int m0:16; } cray_native_type; struct { unsigned int ns:1; unsigned int ex:11; unsigned int m3:4; unsigned int m2:16; unsigned int m1:16; unsigned int m0:16; } ieee754_double_bigend; struct { unsigned int m0:16; unsigned int m1:16; unsigned int m2:16; unsigned int m3:4; unsigned int ex:11; unsigned int ns:1; } ieee754_double_litend; } fp; unsigned int ns, ex, m2, m1, m0, m3; fp.f = f; if (vtffprtype == VTF3_CONST_FPNRT_CRAY_NATIVE_TYPE) { ns = fp.cray_native_type.ns; ex = fp.cray_native_type.ex; m2 = fp.cray_native_type.m2; m1 = fp.cray_native_type.m1; m0 = fp.cray_native_type.m0; if (ex == 0 && m2 == 0 && m1 == 0 && m0 == 0) return (0); if (ns == 0) return (1); return (-1); } if (vtffprtype == VTF3_CONST_FPNRT_IEEE754_DOUBLE_BIGEND) { ns = fp.ieee754_double_bigend.ns; ex = fp.ieee754_double_bigend.ex; m3 = fp.ieee754_double_bigend.m3; m2 = fp.ieee754_double_bigend.m2; m1 = fp.ieee754_double_bigend.m1; m0 = fp.ieee754_double_bigend.m0; if (ex == 0 && m3 == 0 && m2 == 0 && m1 == 0 && m0 == 0) return (0); if (ns == 0) return (1); return (-1); } if (vtffprtype == VTF3_CONST_FPNRT_IEEE754_DOUBLE_LITEND) { ns = fp.ieee754_double_litend.ns; ex = fp.ieee754_double_litend.ex; m3 = fp.ieee754_double_litend.m3; m2 = fp.ieee754_double_litend.m2; m1 = fp.ieee754_double_litend.m1; m0 = fp.ieee754_double_litend.m0; if (ex == 0 && m3 == 0 && m2 == 0 && m1 == 0 && m0 == 0) return (0); if (ns == 0) return (1); return (-1); } (void) fprintf (stderr, "VTF3: Unknown FP representation type\n"); (void) fflush (stderr); (void) exit (127); return (0); } static const char * StdAsciiGetSeparatedString (fcb_t *fcb, int index) { static unsigned char uchar80h = (unsigned char) 0x80; int start, beyond; char *p1, *p2; if (fcb->stroffsetvectorstart == 0) { (void) fprintf (stderr, "VTF3: StdAsciiGetSeparatedString(): " "Unrecoverable error\n"); (void) fflush (stderr); (void) exit (127); } if (fcb->stroffsetvectorbeyond == 0) { (void) fprintf (stderr, "VTF3: StdAsciiGetSeparatedString(): " "Unrecoverable error\n"); (void) fflush (stderr); (void) exit (127); } if (index + 1 > fcb->stroffsetvectordim) { (void) fprintf (stderr, "VTF3: StdAsciiGetSeparatedString(): " "Unrecoverable error\n"); (void) fflush (stderr); (void) exit (127); } start = *(fcb->stroffsetvectorstart + index); beyond = *(fcb->stroffsetvectorbeyond + index); p1 = p2 = fcb->recbuffer + start; while (p1 < fcb->recbuffer + beyond) { if (p2 >= fcb->recbuffer + start + (int) (unsigned int) 0x7fff) break; if (*p1 == '\0') { p1++; *p2++ = (char) * (char *) (unsigned char *) &uchar80h; continue; } if (*p1 == '\\') if (*(p1 + 1) == '\\' || *(p1 + 1) == '"') p1++; *p2++ = *p1++; } *p2 = '\0'; return ((const char *) (fcb->recbuffer + start)); } static void StdAsciiParser (fcb_t *fcb, int numcharsdata) { static double fdig [10] = { 0.0e+0, 1.0e+0, 2.0e+0, 3.0e+0, 4.0e+0, 5.0e+0, 6.0e+0, 7.0e+0, 8.0e+0, 9.0e+0}; char *p, *pp; int withminus, d, handlerindex, error, havetime, k1, k2, dk; double time; unsigned int i1, i2, i; const char *pk; stdasciiparser_t stdasciiparser; if (numcharsdata < 1) return; p = fcb->recbuffer + 0; VTF3_ASCIIPARSER_PASS_BLANKS (p); if (*p == '\n') /* Blank line. */ return; if (*p == '-') { withminus = 1; d = vtfdigit[VTF3_CHAR2INDEX (*++p)]; if (d > 9) { handlerindex = vtfunrecognizablehandlerindex; (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } } else if (*p == '+') { withminus = 0; d = vtfdigit[VTF3_CHAR2INDEX (*++p)]; if (d > 9) { handlerindex = vtfunrecognizablehandlerindex; (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } } else { withminus = 0; d = vtfdigit[VTF3_CHAR2INDEX (*p)]; } error = 0; time = 0.0e+0; if (d < 10) { havetime = 1; while (d < 10) { time = time * 10.0e+0 + fdig[d]; if (time > 1.0e+30) time = 1.0e+30; d = vtfdigit[VTF3_CHAR2INDEX (*++p)]; } if (withminus != 0 && time > 0.5e+0) time = -time; if (vtfspace[VTF3_CHAR2INDEX (*p)] != 0) p++; else error = 1; VTF3_ASCIIPARSER_PASS_BLANKS (p); } else havetime = 0; i1 = 0; i2 = (unsigned int) (sizeof (recordtypes) / sizeof (recordtypes[0])) - 1; while (i1 != i2) { i = (i1 + i2) >> 1; pk = stdasciikwparser[i]; pp = p; k1 = vtfletter[VTF3_CHAR2INDEX (*pk++)]; k2 = vtfletter[VTF3_CHAR2INDEX (*pp++)]; dk = k1 - k2; while (dk == 0 && k1 != 0) { k1 = vtfletter[VTF3_CHAR2INDEX (*pk++)]; k2 = vtfletter[VTF3_CHAR2INDEX (*pp++)]; dk = k1 - k2; } if (dk < 0) i1 = i + 1; else i2 = i; } i = i1; pk = stdasciikwparser[i]; pp = p; k1 = vtfletter[VTF3_CHAR2INDEX (*pk++)]; k2 = vtfletter[VTF3_CHAR2INDEX (*pp++)]; dk = k1 - k2; while (dk == 0 && k1 != 0) { k1 = vtfletter[VTF3_CHAR2INDEX (*pk++)]; k2 = vtfletter[VTF3_CHAR2INDEX (*pp++)]; dk = k1 - k2; } if (dk != 0) { handlerindex = vtfunrecognizablehandlerindex; (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } p = pp - 1; if (*p == '\n') ; else if (vtfspace[VTF3_CHAR2INDEX (*p)] != 0) p++; else error = 1; VTF3_ASCIIPARSER_PASS_BLANKS (p); handlerindex = stdasciikwparser2hi[i]; if (error != 0) { (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } fcb->recbufferpos = p; stdasciiparser = stdasciiparsers[handlerindex]; (void) (stdasciiparser) (fcb, numcharsdata, handlerindex, havetime, time); return; } static char * StdAsciiReadF8 (fcb_t *fcb, double *foutcaller) { char *p, *pretval, c, *endptr; union { double f; struct { unsigned int ns:1; unsigned int ex:15; unsigned int m2:16; unsigned int m1:16; unsigned int m0:16; } cray_native_type; struct { unsigned int ns:1; unsigned int ex:11; unsigned int m3:4; unsigned int m2:16; unsigned int m1:16; unsigned int m0:16; } ieee754_double_bigend; struct { unsigned int m0:16; unsigned int m1:16; unsigned int m2:16; unsigned int m3:4; unsigned int ex:11; unsigned int ns:1; } ieee754_double_litend; } fp; unsigned int ns, ex, m2, m1, m0, m3; p = fcb->recbufferpos; VTF3_ASCIIPARSER_PASS_BLANKS (p); pretval = fcb->recbufferpos = p; while (vtfspace[VTF3_CHAR2INDEX (*p)] == 0 && *p != '\n') p++; c = *p; *p = '\0'; fp.f = strtod (pretval, &endptr); *p = c; if (endptr == pretval) /* Error */ return (0); VTF3_ASCIIPARSER_PASS_BLANKS (p); fcb->recbufferpos = p; if (vtffprtype == VTF3_CONST_FPNRT_CRAY_NATIVE_TYPE) { ns = fp.cray_native_type.ns; ex = fp.cray_native_type.ex; m2 = fp.cray_native_type.m2; m1 = fp.cray_native_type.m1; m0 = fp.cray_native_type.m0; if (ex == 0 && m2 == 0 && m1 == 0 && m0 == 0) { *foutcaller = 0.0e+0; return (pretval); } if (ex < (unsigned int) 0x2003) { fp.cray_native_type.ex = (unsigned int) 0x2003; fp.cray_native_type.m2 = (unsigned int) 0x8000; fp.cray_native_type.m1 = (unsigned int) 0x0000; fp.cray_native_type.m0 = (unsigned int) 0x0000; } else if (ex > (unsigned int) 0x5fff) { fp.cray_native_type.ex = (unsigned int) 0x5fff; fp.cray_native_type.m2 = (unsigned int) 0x8000; fp.cray_native_type.m1 = (unsigned int) 0x0000; fp.cray_native_type.m0 = (unsigned int) 0x0000; } fp.cray_native_type.ns = 0; if (fp.f < 1.0e-300) fp.f = 1.0E-300; else if (fp.f > 1.0e+300) fp.f = 1.0E+300; fp.cray_native_type.ns = ns; *foutcaller = fp.f; return (pretval); } if (vtffprtype == VTF3_CONST_FPNRT_IEEE754_DOUBLE_BIGEND) { ns = fp.ieee754_double_bigend.ns; ex = fp.ieee754_double_bigend.ex; m3 = fp.ieee754_double_bigend.m3; m2 = fp.ieee754_double_bigend.m2; m1 = fp.ieee754_double_bigend.m1; m0 = fp.ieee754_double_bigend.m0; if (ex == 0 && m3 == 0 && m2 == 0 && m1 == 0 && m0 == 0) { *foutcaller = 0.0e+0; return (pretval); } if (ex < (unsigned int) 0x002) { fp.ieee754_double_bigend.ex = (unsigned int) 0x002; fp.ieee754_double_bigend.m3 = (unsigned int) 0x0; fp.ieee754_double_bigend.m2 = (unsigned int) 0x0000; fp.ieee754_double_bigend.m1 = (unsigned int) 0x0000; fp.ieee754_double_bigend.m0 = (unsigned int) 0x0000; } else if (ex > (unsigned int) 0x7fd) { fp.ieee754_double_bigend.ex = (unsigned int) 0x7fd; fp.ieee754_double_bigend.m3 = (unsigned int) 0xf; fp.ieee754_double_bigend.m2 = (unsigned int) 0xffff; fp.ieee754_double_bigend.m1 = (unsigned int) 0xffff; fp.ieee754_double_bigend.m0 = (unsigned int) 0xffff; } fp.ieee754_double_bigend.ns = 0; if (fp.f < 1.0e-300) fp.f = 1.0E-300; else if (fp.f > 1.0e+300) fp.f = 1.0E+300; fp.ieee754_double_bigend.ns = ns; *foutcaller = fp.f; return (pretval); } if (vtffprtype == VTF3_CONST_FPNRT_IEEE754_DOUBLE_LITEND) { ns = fp.ieee754_double_litend.ns; ex = fp.ieee754_double_litend.ex; m3 = fp.ieee754_double_litend.m3; m2 = fp.ieee754_double_litend.m2; m1 = fp.ieee754_double_litend.m1; m0 = fp.ieee754_double_litend.m0; if (ex == 0 && m3 == 0 && m2 == 0 && m1 == 0 && m0 == 0) { *foutcaller = 0.0e+0; return (pretval); } if (ex < (unsigned int) 0x002) { fp.ieee754_double_litend.ex = (unsigned int) 0x002; fp.ieee754_double_litend.m3 = (unsigned int) 0x0; fp.ieee754_double_litend.m2 = (unsigned int) 0x0000; fp.ieee754_double_litend.m1 = (unsigned int) 0x0000; fp.ieee754_double_litend.m0 = (unsigned int) 0x0000; } else if (ex > (unsigned int) 0x7fd) { fp.ieee754_double_litend.ex = (unsigned int) 0x7fd; fp.ieee754_double_litend.m3 = (unsigned int) 0xf; fp.ieee754_double_litend.m2 = (unsigned int) 0xffff; fp.ieee754_double_litend.m1 = (unsigned int) 0xffff; fp.ieee754_double_litend.m0 = (unsigned int) 0xffff; } fp.ieee754_double_litend.ns = 0; if (fp.f < 1.0e-300) fp.f = 1.0E-300; else if (fp.f > 1.0e+300) fp.f = 1.0E+300; fp.ieee754_double_litend.ns = ns; *foutcaller = fp.f; return (pretval); } (void) fprintf (stderr, "VTF3: Unknown FP representation type\n"); (void) fflush (stderr); (void) exit (127); return (0); } static char * StdAsciiReadI4 (fcb_t *fcb, int *ioutcaller) { char *p, *pretval; unsigned int withminus, urefmax, uout, u, uref; int iout; p = fcb->recbufferpos; VTF3_ASCIIPARSER_PASS_BLANKS (p); pretval = fcb->recbufferpos = p; if (*p == '-') { p++; withminus = 1; urefmax = (unsigned int) 0x80000000; } else if (*p == '+') { p++; withminus = 0; urefmax = (unsigned int) 0x7fffffff; } else { withminus = 0; urefmax = (unsigned int) 0x7fffffff; } if (vtfdigit[VTF3_CHAR2INDEX (*p)] > 9) return (0); uout = 0; while ((u = (unsigned int) vtfdigit[VTF3_CHAR2INDEX (*p)]) < 10) { p++; uref = urefmax - u; uref = uref - uref % 10; uref /= 10; if (uout > uref) { uout = urefmax; continue; } uout = uout * 10 + u; } if (uout != 0 && withminus != 0) { uout--; uout = ~uout; } iout = * (int *) &uout; if (vtfspace[VTF3_CHAR2INDEX (*p)] == 0 && *p != '\n') return (0); *ioutcaller = iout; VTF3_ASCIIPARSER_PASS_BLANKS (p); fcb->recbufferpos = p; return (pretval); } static char * StdAsciiReadI4ColonTrailing (fcb_t *fcb, int *ioutcaller) { char *p, *pretval; unsigned int withminus, urefmax, uout, u, uref; int iout; p = fcb->recbufferpos; VTF3_ASCIIPARSER_PASS_BLANKS (p); pretval = fcb->recbufferpos = p; if (*p == '-') { p++; withminus = 1; urefmax = (unsigned int) 0x80000000; } else if (*p == '+') { p++; withminus = 0; urefmax = (unsigned int) 0x7fffffff; } else { withminus = 0; urefmax = (unsigned int) 0x7fffffff; } if (vtfdigit[VTF3_CHAR2INDEX (*p)] > 9) return (0); uout = 0; while ((u = (unsigned int) vtfdigit[VTF3_CHAR2INDEX (*p)]) < 10) { p++; uref = urefmax - u; uref = uref - uref % 10; uref /= 10; if (uout > uref) { uout = urefmax; continue; } uout = uout * 10 + u; } if (uout != 0 && withminus != 0) { uout--; uout = ~uout; } iout = * (int *) &uout; VTF3_ASCIIPARSER_PASS_BLANKS (p); if (*p != ':') return (0); p++; *ioutcaller = iout; VTF3_ASCIIPARSER_PASS_BLANKS (p); fcb->recbufferpos = p; return (pretval); } static int StdAsciiReadRecord (fcb_t *fcb) { int numcharsrecord; char *t, *s; unsigned int j, i, r0, r1, r2, r3, r4, r5, r6, r7; numcharsrecord = 0; fcb->recbufferpos = fcb->recbuffer + 0; /* LABEL */ Continue: if (fcb->recbufferpos + 200 > fcb->recbufferbeyond) (void) ReallocRecord (fcb, 200); if (fcb->iobufferpos + 200 <= fcb->iobuffereof) { t = fcb->recbufferpos; s = fcb->iobufferpos; j = 0; for (i = 0; i < 200; i += 8) { r0 = (*(t + i + 0) = *(s + i + 0)) == '\n' ? 1 : 0; r1 = (*(t + i + 1) = *(s + i + 1)) == '\n' ? 1 : 0; r2 = (*(t + i + 2) = *(s + i + 2)) == '\n' ? 1 : 0; r3 = (*(t + i + 3) = *(s + i + 3)) == '\n' ? 1 : 0; r4 = (*(t + i + 4) = *(s + i + 4)) == '\n' ? 1 : 0; r5 = (*(t + i + 5) = *(s + i + 5)) == '\n' ? 1 : 0; r6 = (*(t + i + 6) = *(s + i + 6)) == '\n' ? 1 : 0; r7 = (*(t + i + 7) = *(s + i + 7)) == '\n' ? 1 : 0; if (r0 + r1 + r2 + r3 + r4 + r5 + r6 + r7 != 0) break; j = i + 8; } fcb->recbufferpos += j; fcb->iobufferpos += j; numcharsrecord += j; if (j == 200) goto Continue; s += j; if (*(s + 0) == '\n') { fcb->recbufferpos += 0 + 1; fcb->iobufferpos += 0 + 1; return (numcharsrecord + 0 + 1); } if (*(s + 1) == '\n') { fcb->recbufferpos += 1 + 1; fcb->iobufferpos += 1 + 1; return (numcharsrecord + 1 + 1); } if (*(s + 2) == '\n') { fcb->recbufferpos += 2 + 1; fcb->iobufferpos += 2 + 1; return (numcharsrecord + 2 + 1); } if (*(s + 3) == '\n') { fcb->recbufferpos += 3 + 1; fcb->iobufferpos += 3 + 1; return (numcharsrecord + 3 + 1); } if (*(s + 4) == '\n') { fcb->recbufferpos += 4 + 1; fcb->iobufferpos += 4 + 1; return (numcharsrecord + 4 + 1); } if (*(s + 5) == '\n') { fcb->recbufferpos += 5 + 1; fcb->iobufferpos += 5 + 1; return (numcharsrecord + 5 + 1); } if (*(s + 6) == '\n') { fcb->recbufferpos += 6 + 1; fcb->iobufferpos += 6 + 1; return (numcharsrecord + 6 + 1); } if (*(s + 7) == '\n') { fcb->recbufferpos += 7 + 1; fcb->iobufferpos += 7 + 1; return (numcharsrecord + 7 + 1); } (void) fprintf (stderr, "VTF3: StdAsciiReadRecord(): " "Unrecoverable error\n"); (void) fflush (stderr); (void) exit (127); } while (fcb->iobufferpos < fcb->iobuffereof) { numcharsrecord++; if ((*fcb->recbufferpos++ = *fcb->iobufferpos++) == '\n') return (numcharsrecord); } if (fcb->iobuffereof < fcb->iobufferbeyond) { if (numcharsrecord != 0) { /* EOF without '\n', repair it, flag the situation. */ numcharsrecord++; *fcb->recbufferpos++ = '\n'; return (-numcharsrecord); } /* Normal EOF. */ return (0); } /* Try to read a new buffer. */ (void) FillIoBuffer (fcb); goto Continue; } static char * StdAsciiReadTs (fcb_t *fcb, double *tsoutcaller) { static double fdig [10] = { 0.0e+0, 1.0e+0, 2.0e+0, 3.0e+0, 4.0e+0, 5.0e+0, 6.0e+0, 7.0e+0, 8.0e+0, 9.0e+0}; char *p, *pretval; unsigned int withminus; double tsout; int d; p = fcb->recbufferpos; VTF3_ASCIIPARSER_PASS_BLANKS (p); pretval = fcb->recbufferpos = p; if (*p == '-') { withminus = 1; p++; } else if (*p == '+') { withminus = 0; p++; } else withminus = 0; tsout = 0.0e+0; d = vtfdigit[VTF3_CHAR2INDEX (*p)]; if (d > 9) return (0); while (d < 10) { tsout = tsout * 10.0e+0 + fdig[d]; if (tsout > 1.0e+30) tsout = 1.0e+30; d = vtfdigit[VTF3_CHAR2INDEX (*++p)]; } if (withminus != 0 && tsout > 0.5e+0) tsout = -tsout; if (vtfspace[VTF3_CHAR2INDEX (*p)] == 0 && *p != '\n') return (0); *tsoutcaller = tsout; VTF3_ASCIIPARSER_PASS_BLANKS (p); fcb->recbufferpos = p; return (pretval); } static char * StdAsciiReadU4ColonTrailing (fcb_t *fcb, unsigned int *uoutcaller) { char *p, *pretval; unsigned int withminus, urefmax, uout, u, uref; p = fcb->recbufferpos; VTF3_ASCIIPARSER_PASS_BLANKS (p); pretval = fcb->recbufferpos = p; if (*p == '-') { p++; withminus = 1; } else if (*p == '+') { p++; withminus = 0; } else withminus = 0; if (vtfdigit[VTF3_CHAR2INDEX (*p)] > 9) return (0); urefmax = (unsigned int) 0xffffffff; uout = 0; while ((u = (unsigned int) vtfdigit[VTF3_CHAR2INDEX (*p)]) < 10) { p++; uref = urefmax - u; uref = uref - uref % 10; uref /= 10; if (uout > uref) { uout = urefmax; continue; } uout = uout * 10 + u; } if (withminus != 0) uout = 0; VTF3_ASCIIPARSER_PASS_BLANKS (p); if (*p != ':') return (0); p++; *uoutcaller = uout; VTF3_ASCIIPARSER_PASS_BLANKS (p); fcb->recbufferpos = p; return (pretval); } static char * StdAsciiStoreBuggyStringOffsets (fcb_t *fcb, int index) { size_t size; char *p, *pretval; int start, beyond; if (fcb->stroffsetvectorstart == 0) { fcb->stroffsetvectordim = index + 1 + 10; size = (size_t) fcb->stroffsetvectordim * sizeof (int); fcb->stroffsetvectorstart = (int *) malloc (size); if (fcb->stroffsetvectorstart == 0) { VTF3_NOMEM_GOOD_BYE_INFO; (void) exit (127); } fcb->stroffsetvectorbeyond = (int *) malloc (size); if (fcb->stroffsetvectorbeyond == 0) { VTF3_NOMEM_GOOD_BYE_INFO; (void) exit (127); } } if (index + 1 > fcb->stroffsetvectordim) { fcb->stroffsetvectordim = 2 * (index + 1); size = (size_t) fcb->stroffsetvectordim * sizeof (int); fcb->stroffsetvectorstart = (int *) realloc (fcb->stroffsetvectorstart, size); if (fcb->stroffsetvectorstart == 0) { VTF3_NOMEM_GOOD_BYE_INFO; (void) exit (127); } fcb->stroffsetvectorbeyond = (int *) realloc (fcb->stroffsetvectorbeyond, size); if (fcb->stroffsetvectorbeyond == 0) { VTF3_NOMEM_GOOD_BYE_INFO; (void) exit (127); } } p = fcb->recbufferpos; VTF3_ASCIIPARSER_PASS_BLANKS (p); pretval = fcb->recbufferpos = p; if (*p++ != '"') return (0); if (*p++ != '"') return (0); while (*p != '"') { if (*p == '\n') return (0); if (*p == '\\') if (*(p + 1) == '\\' || *(p + 1) == '"') p++; p++; } start = (int) (pretval + 2 - fcb->recbuffer); beyond = (int) (p + 0 - fcb->recbuffer); p++; if (*p++ != '"') return (0); if (vtfspace[VTF3_CHAR2INDEX (*p)] == 0 && *p != '\n') return (0); VTF3_ASCIIPARSER_PASS_BLANKS (p); fcb->recbufferpos = p; *(fcb->stroffsetvectorstart + index) = start; *(fcb->stroffsetvectorbeyond + index) = beyond; return (pretval); } static char * StdAsciiStoreOldStyleStringOffsets (fcb_t *fcb, int index) { size_t size; char *p, *pretval; int start, beyond; if (fcb->stroffsetvectorstart == 0) { fcb->stroffsetvectordim = index + 1 + 10; size = (size_t) fcb->stroffsetvectordim * sizeof (int); fcb->stroffsetvectorstart = (int *) malloc (size); if (fcb->stroffsetvectorstart == 0) { VTF3_NOMEM_GOOD_BYE_INFO; (void) exit (127); } fcb->stroffsetvectorbeyond = (int *) malloc (size); if (fcb->stroffsetvectorbeyond == 0) { VTF3_NOMEM_GOOD_BYE_INFO; (void) exit (127); } } if (index + 1 > fcb->stroffsetvectordim) { fcb->stroffsetvectordim = 2 * (index + 1); size = (size_t) fcb->stroffsetvectordim * sizeof (int); fcb->stroffsetvectorstart = (int *) realloc (fcb->stroffsetvectorstart, size); if (fcb->stroffsetvectorstart == 0) { VTF3_NOMEM_GOOD_BYE_INFO; (void) exit (127); } fcb->stroffsetvectorbeyond = (int *) realloc (fcb->stroffsetvectorbeyond, size); if (fcb->stroffsetvectorbeyond == 0) { VTF3_NOMEM_GOOD_BYE_INFO; (void) exit (127); } } p = fcb->recbufferpos; VTF3_ASCIIPARSER_PASS_BLANKS (p); pretval = fcb->recbufferpos = p; if (vtfletter[VTF3_CHAR2INDEX (*p)] == 0 && *p != '_') return (0); p++; for (;;) { while (vtfletter[VTF3_CHAR2INDEX (*p)] != 0 || vtfdigit [VTF3_CHAR2INDEX (*p)] <= 9 || *p == '_') p++; if (*(p + 0) != ':') break; if (*(p + 1) != ':') break; if (vtfletter[VTF3_CHAR2INDEX (*(p + 2))] == 0 && *(p + 2) != '_') break; p += 3; } start = (int) (pretval + 0 - fcb->recbuffer); beyond = (int) (p + 0 - fcb->recbuffer); if (vtfspace[VTF3_CHAR2INDEX (*p)] == 0 && *p != '\n') return (0); VTF3_ASCIIPARSER_PASS_BLANKS (p); fcb->recbufferpos = p; *(fcb->stroffsetvectorstart + index) = start; *(fcb->stroffsetvectorbeyond + index) = beyond; return (pretval); } static char * StdAsciiStoreStringOffsets (fcb_t *fcb, int index) { size_t size; char *p, *pretval; int start, beyond; if (fcb->stroffsetvectorstart == 0) { fcb->stroffsetvectordim = index + 1 + 10; size = (size_t) fcb->stroffsetvectordim * sizeof (int); fcb->stroffsetvectorstart = (int *) malloc (size); if (fcb->stroffsetvectorstart == 0) { VTF3_NOMEM_GOOD_BYE_INFO; (void) exit (127); } fcb->stroffsetvectorbeyond = (int *) malloc (size); if (fcb->stroffsetvectorbeyond == 0) { VTF3_NOMEM_GOOD_BYE_INFO; (void) exit (127); } } if (index + 1 > fcb->stroffsetvectordim) { fcb->stroffsetvectordim = 2 * (index + 1); size = (size_t) fcb->stroffsetvectordim * sizeof (int); fcb->stroffsetvectorstart = (int *) realloc (fcb->stroffsetvectorstart, size); if (fcb->stroffsetvectorstart == 0) { VTF3_NOMEM_GOOD_BYE_INFO; (void) exit (127); } fcb->stroffsetvectorbeyond = (int *) realloc (fcb->stroffsetvectorbeyond, size); if (fcb->stroffsetvectorbeyond == 0) { VTF3_NOMEM_GOOD_BYE_INFO; (void) exit (127); } } p = fcb->recbufferpos; VTF3_ASCIIPARSER_PASS_BLANKS (p); pretval = fcb->recbufferpos = p; if (*p++ != '"') return (0); while (*p != '"') { if (*p == '\n') return (0); if (*p == '\\') if (*(p + 1) == '\\' || *(p + 1) == '"') p++; p++; } start = (int) (pretval + 1 - fcb->recbuffer); beyond = (int) (p + 0 - fcb->recbuffer); p++; if (vtfspace[VTF3_CHAR2INDEX (*p)] == 0 && *p != '\n') return (0); VTF3_ASCIIPARSER_PASS_BLANKS (p); fcb->recbufferpos = p; *(fcb->stroffsetvectorstart + index) = start; *(fcb->stroffsetvectorbeyond + index) = beyond; return (pretval); } static VTF3_rec_t * StdAsciiWriteEp (fcb_t *fcb, int type) { if (fcb->recbufferpos + 1 > fcb->recbufferbeyond) (void) ReallocRecord (fcb, 1); *fcb->recbufferpos++ = '\0'; fcb->rcb.type = type; fcb->rcb.numchars = (int) (fcb->recbufferpos - fcb->recbuffer); fcb->rcb.record = fcb->recbuffer; return ((VTF3_rec_t *) &fcb->rcb); } static void StdAsciiWriteF8 (fcb_t *fcb, double f) { static const char *zero = "0.0E+0"; char convbuf [32]; union { double f; struct { unsigned int ns:1; unsigned int ex:15; unsigned int m2:16; unsigned int m1:16; unsigned int m0:16; } cray_native_type; struct { unsigned int ns:1; unsigned int ex:11; unsigned int m3:4; unsigned int m2:16; unsigned int m1:16; unsigned int m0:16; } ieee754_double_bigend; struct { unsigned int m0:16; unsigned int m1:16; unsigned int m2:16; unsigned int m3:4; unsigned int ex:11; unsigned int ns:1; } ieee754_double_litend; } fp; unsigned int ns, ex, m2, m1, m0, m3; const char *pc; char *p, *p1, *p2, *p3; if (fcb->recbufferpos + sizeof (convbuf) / sizeof (convbuf[0]) > fcb->recbufferbeyond) (void) ReallocRecord (fcb, (unsigned int) (sizeof (convbuf) / sizeof (convbuf[0]))); fp.f = f; if (vtffprtype == VTF3_CONST_FPNRT_CRAY_NATIVE_TYPE) { ns = fp.cray_native_type.ns; ex = fp.cray_native_type.ex; m2 = fp.cray_native_type.m2; m1 = fp.cray_native_type.m1; m0 = fp.cray_native_type.m0; if (ex == 0 && m2 == 0 && m1 == 0 && m0 == 0) { pc = zero; while (*pc != '\0') *fcb->recbufferpos++ = *pc++; return; } if (ex < (unsigned int) 0x2003) { fp.cray_native_type.ex = (unsigned int) 0x2003; fp.cray_native_type.m2 = (unsigned int) 0x8000; fp.cray_native_type.m1 = (unsigned int) 0x0000; fp.cray_native_type.m0 = (unsigned int) 0x0000; } else if (ex > (unsigned int) 0x5fff) { fp.cray_native_type.ex = (unsigned int) 0x5fff; fp.cray_native_type.m2 = (unsigned int) 0x8000; fp.cray_native_type.m1 = (unsigned int) 0x0000; fp.cray_native_type.m0 = (unsigned int) 0x0000; } fp.cray_native_type.ns = 0; if (fp.f < 1.0e-300) { if (ns != 0) (void) StdAsciiWriteSu (fcb, "-1.0E-300"); else (void) StdAsciiWriteSu (fcb, "1.0E-300"); return; } if (fp.f > 1.0e+300) { if (ns != 0) (void) StdAsciiWriteSu (fcb, "-1.0E+300"); else (void) StdAsciiWriteSu (fcb, "1.0E+300"); return; } fp.cray_native_type.ns = ns; } else if (vtffprtype == VTF3_CONST_FPNRT_IEEE754_DOUBLE_BIGEND) { ns = fp.ieee754_double_bigend.ns; ex = fp.ieee754_double_bigend.ex; m3 = fp.ieee754_double_bigend.m3; m2 = fp.ieee754_double_bigend.m2; m1 = fp.ieee754_double_bigend.m1; m0 = fp.ieee754_double_bigend.m0; if (ex == 0 && m3 == 0 && m2 == 0 && m1 == 0 && m0 == 0) { pc = zero; while (*pc != '\0') *fcb->recbufferpos++ = *pc++; return; } if (ex < (unsigned int) 0x002) { fp.ieee754_double_bigend.ex = (unsigned int) 0x002; fp.ieee754_double_bigend.m3 = (unsigned int) 0x0; fp.ieee754_double_bigend.m2 = (unsigned int) 0x0000; fp.ieee754_double_bigend.m1 = (unsigned int) 0x0000; fp.ieee754_double_bigend.m0 = (unsigned int) 0x0000; } else if (ex > (unsigned int) 0x7fd) { fp.ieee754_double_bigend.ex = (unsigned int) 0x7fd; fp.ieee754_double_bigend.m3 = (unsigned int) 0xf; fp.ieee754_double_bigend.m2 = (unsigned int) 0xffff; fp.ieee754_double_bigend.m1 = (unsigned int) 0xffff; fp.ieee754_double_bigend.m0 = (unsigned int) 0xffff; } fp.ieee754_double_bigend.ns = 0; if (fp.f < 1.0e-300) { if (ns != 0) (void) StdAsciiWriteSu (fcb, "-1.0E-300"); else (void) StdAsciiWriteSu (fcb, "1.0E-300"); return; } if (fp.f > 1.0e+300) { if (ns != 0) (void) StdAsciiWriteSu (fcb, "-1.0E+300"); else (void) StdAsciiWriteSu (fcb, "1.0E+300"); return; } fp.ieee754_double_bigend.ns = ns; } else if (vtffprtype == VTF3_CONST_FPNRT_IEEE754_DOUBLE_LITEND) { ns = fp.ieee754_double_litend.ns; ex = fp.ieee754_double_litend.ex; m3 = fp.ieee754_double_litend.m3; m2 = fp.ieee754_double_litend.m2; m1 = fp.ieee754_double_litend.m1; m0 = fp.ieee754_double_litend.m0; if (ex == 0 && m3 == 0 && m2 == 0 && m1 == 0 && m0 == 0) { pc = zero; while (*pc != '\0') *fcb->recbufferpos++ = *pc++; return; } if (ex < (unsigned int) 0x002) { fp.ieee754_double_litend.ex = (unsigned int) 0x002; fp.ieee754_double_litend.m3 = (unsigned int) 0x0; fp.ieee754_double_litend.m2 = (unsigned int) 0x0000; fp.ieee754_double_litend.m1 = (unsigned int) 0x0000; fp.ieee754_double_litend.m0 = (unsigned int) 0x0000; } else if (ex > (unsigned int) 0x7fd) { fp.ieee754_double_litend.ex = (unsigned int) 0x7fd; fp.ieee754_double_litend.m3 = (unsigned int) 0xf; fp.ieee754_double_litend.m2 = (unsigned int) 0xffff; fp.ieee754_double_litend.m1 = (unsigned int) 0xffff; fp.ieee754_double_litend.m0 = (unsigned int) 0xffff; } fp.ieee754_double_litend.ns = 0; if (fp.f < 1.0e-300) { if (ns != 0) (void) StdAsciiWriteSu (fcb, "-1.0E-300"); else (void) StdAsciiWriteSu (fcb, "1.0E-300"); return; } if (fp.f > 1.0e+300) { if (ns != 0) (void) StdAsciiWriteSu (fcb, "-1.0E+300"); else (void) StdAsciiWriteSu (fcb, "1.0E+300"); return; } fp.ieee754_double_litend.ns = ns; } else { (void) fprintf (stderr, "VTF3: Unknown FP representation type\n"); (void) fflush (stderr); (void) exit (127); } if (vtffprtype == VTF3_CONST_FPNRT_CRAY_NATIVE_TYPE) (void) sprintf (&convbuf[0], "%24.14e", fp.f); else (void) sprintf (&convbuf[0], "%24.15e", fp.f); p = &convbuf[0]; while (*p == ' ') p++; p1 = p; while (*p1 != '.' && *p1 != '\0') p1++; if (*p1 == '.') { p1++; p2 = p1; while (*p2 != 'e' && *p2 != 'E' && *p2 != '\0') p2++; if (*p2 == 'e') *p2 = 'E'; if (*p2 == 'E') { p3 = p2 - 1; if (p3 > p1) { while (p3 > p1 && *p3 == '0') p3--; p3++; if (*p3 == '0') { while (*p2 != '\0') *p3++ = *p2++; *p3 = *p2; } } p2 = p1; while (*p2 != 'E') p2++; p2++; if (*p2 == '+' || *p2 == '-') p2++; p3 = p2; while (*(p3 + 0) == '0' && *(p3 + 1) != '\0') p3++; if (p3 != p2) { while (*p3 != '\0') *p2++ = *p3++; *p2 = *p3; } } } while (*p != '\0') *fcb->recbufferpos++ = *p++; return; } static void StdAsciiWriteI4 (fcb_t *fcb, int i) { static char dig [10] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9'}; char convbuf [16]; int withminus, idig; char *p; if (fcb->recbufferpos + sizeof (convbuf) / sizeof (convbuf[0]) > fcb->recbufferbeyond) (void) ReallocRecord (fcb, (unsigned int) (sizeof (convbuf) / sizeof (convbuf[0]))); if (i == 0) { *fcb->recbufferpos++ = '0'; return; } if (i > 2147483646) { (void) StdAsciiWriteSu (fcb, "2147483647"); return; } if (i < 0) { if (i + 2147483647 < 0) { (void) StdAsciiWriteSu (fcb, "-2147483648"); return; } i = -i; withminus = 1; } else withminus = 0; p = &convbuf[sizeof (convbuf) / sizeof (convbuf[0]) - 1]; *p-- = '\0'; while (i != 0) { idig = i % 10; *p-- = dig[idig]; i -= idig; i /= 10; } if (withminus != 0) *p-- = '-'; p++; while (*p != '\0') *fcb->recbufferpos++ = *p++; return; } static void StdAsciiWriteSc (fcb_t *fcb, const char *s) { char *t, c, c00, c01, c02, c03, c04, c05, c06, c07, c10, c11, c12, c13, c20, c21, c30; unsigned int i, n, j0, j1, j2, j3; const char *p; if (fcb->recbufferpos + 100 > fcb->recbufferbeyond) (void) ReallocRecord (fcb, 100); t = fcb->recbufferpos; for (i = 0; i < 100; i++) { c = *(s + i); if (c == '\0') { fcb->recbufferpos = t + i; return; } else if (c == '\n') c = ' '; *(t + i) = c; } fcb->recbufferpos = t + 100; s += 100; p = s; n = (unsigned int) 0x7fff - (unsigned int) 100; while (*p != '\0' && n != 0) { p++; n--; } n = (unsigned int) (p - s); if (n == 0) return; if (fcb->recbufferpos + n > fcb->recbufferbeyond) (void) ReallocRecord (fcb, n); t = fcb->recbufferpos; fcb->recbufferpos += n; for (j0 = 0; j0 < n >> 3 << 3; j0 += 8) { c00 = *(s + j0 + 0); c01 = *(s + j0 + 1); c02 = *(s + j0 + 2); c03 = *(s + j0 + 3); c04 = *(s + j0 + 4); c05 = *(s + j0 + 5); c06 = *(s + j0 + 6); c07 = *(s + j0 + 7); *(t + j0 + 0) = c00 == '\n' ? ' ' : c00; *(t + j0 + 1) = c01 == '\n' ? ' ' : c01; *(t + j0 + 2) = c02 == '\n' ? ' ' : c02; *(t + j0 + 3) = c03 == '\n' ? ' ' : c03; *(t + j0 + 4) = c04 == '\n' ? ' ' : c04; *(t + j0 + 5) = c05 == '\n' ? ' ' : c05; *(t + j0 + 6) = c06 == '\n' ? ' ' : c06; *(t + j0 + 7) = c07 == '\n' ? ' ' : c07; } for (j1 = n >> 3 << 3; j1 < n >> 2 << 2; j1 += 4) { c10 = *(s + j1 + 0); c11 = *(s + j1 + 1); c12 = *(s + j1 + 2); c13 = *(s + j1 + 3); *(t + j1 + 0) = c10 == '\n' ? ' ' : c10; *(t + j1 + 1) = c11 == '\n' ? ' ' : c11; *(t + j1 + 2) = c12 == '\n' ? ' ' : c12; *(t + j1 + 3) = c13 == '\n' ? ' ' : c13; } for (j2 = n >> 2 << 2; j2 < n >> 1 << 1; j2 += 2) { c20 = *(s + j2 + 0); c21 = *(s + j2 + 1); *(t + j2 + 0) = c20 == '\n' ? ' ' : c20; *(t + j2 + 1) = c21 == '\n' ? ' ' : c21; } for (j3 = n >> 1 << 1; j3 < n >> 0 << 0; j3 += 1) { c30 = *(s + j3 + 0); *(t + j3 + 0) = c30 == '\n' ? ' ' : c30; } return; } static void StdAsciiWriteSp (fcb_t *fcb, const char *s) { char *t, c; unsigned int i, n; const char *p; if (fcb->recbufferpos + 200 > fcb->recbufferbeyond) (void) ReallocRecord (fcb, 200); t = fcb->recbufferpos; for (i = 0; i < 100; i++) { c = *(s + i); if (c == '\0') { fcb->recbufferpos = t; return; } else if (c == '\n') c = ' '; else if (c == '\\' || c == '"') *t++ = '\\'; *t++ = c; } fcb->recbufferpos = t; s += 100; p = s; n = (unsigned int) 0x7fff - (unsigned int) 100; while (*p != '\0' && n != 0) { p++; n--; } n = (unsigned int) (p - s); if (n == 0) return; if (fcb->recbufferpos + n + n > fcb->recbufferbeyond) (void) ReallocRecord (fcb, n + n); t = fcb->recbufferpos; for (i = 0; i < n; i++) { c = *(s + i); if (c == '\n') c = ' '; else if (c == '\\' || c == '"') *t++ = '\\'; *t++ = c; } fcb->recbufferpos = t; return; } static void StdAsciiWriteSu (fcb_t *fcb, const char *s) { char *t, c; unsigned int i, n; const char *p; if (fcb->recbufferpos + 100 > fcb->recbufferbeyond) (void) ReallocRecord (fcb, 100); t = fcb->recbufferpos; for (i = 0; i < 100; i++) { c = *(s + i); if (c == '\0') { fcb->recbufferpos = t + i; return; } *(t + i) = c; } fcb->recbufferpos = t + 100; s += 100; p = s; n = (unsigned int) 0x7fff - (unsigned int) 100; while (*p != '\0' && n != 0) { p++; n--; } n = (unsigned int) (p - s); if (n == 0) return; if (fcb->recbufferpos + n > fcb->recbufferbeyond) (void) ReallocRecord (fcb, n); (void) memcpy (fcb->recbufferpos, s, (size_t) n * sizeof (char)); fcb->recbufferpos += n; return; } static void StdAsciiWriteTs (fcb_t *fcb, double f) { static double gpow10 [33] = { 1.0e-01, 1.0e+00, 1.0e+01, 1.0e+02, 1.0e+03, 1.0e+04, 1.0e+05, 1.0e+06, 1.0e+07, 1.0e+08, 1.0e+09, 1.0e+10, 1.0e+11, 1.0e+12, 1.0e+13, 1.0e+14, 1.0e+15, 1.0e+16, 1.0e+17, 1.0e+18, 1.0e+19, 1.0e+20, 1.0e+21, 1.0e+22, 1.0e+23, 1.0e+24, 1.0e+25, 1.0e+26, 1.0e+27, 1.0e+28, 1.0e+29, 1.0e+30, 1.0e+31}; static double gpow10r [33] = { 1.0e+01, 1.0e+00, 1.0e-01, 1.0e-02, 1.0e-03, 1.0e-04, 1.0e-05, 1.0e-06, 1.0e-07, 1.0e-08, 1.0e-09, 1.0e-10, 1.0e-11, 1.0e-12, 1.0e-13, 1.0e-14, 1.0e-15, 1.0e-16, 1.0e-17, 1.0e-18, 1.0e-19, 1.0e-20, 1.0e-21, 1.0e-22, 1.0e-23, 1.0e-24, 1.0e-25, 1.0e-26, 1.0e-27, 1.0e-28, 1.0e-29, 1.0e-30, 1.0e-31}; static double fdig [10] = { 0.0e+0, 1.0e+0, 2.0e+0, 3.0e+0, 4.0e+0, 5.0e+0, 6.0e+0, 7.0e+0, 8.0e+0, 9.0e+0}; static char dig [10] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9'}; union { double f; struct { unsigned int ns:1; unsigned int ex:15; unsigned int m2:16; unsigned int m1:16; unsigned int m0:16; } cray_native_type; struct { unsigned int ns:1; unsigned int ex:11; unsigned int m3:4; unsigned int m2:16; unsigned int m1:16; unsigned int m0:16; } ieee754_double_bigend; struct { unsigned int m0:16; unsigned int m1:16; unsigned int m2:16; unsigned int m3:4; unsigned int ex:11; unsigned int ns:1; } ieee754_double_litend; } fp; unsigned int ns, ex, m2, m1, m0, m3, i1, i2, i, numdigs, trustindigs, kbnd, k, j1, j2, j; double x, xnorm; char *p; if (fcb->recbufferpos + 40 > fcb->recbufferbeyond) (void) ReallocRecord (fcb, 40); fp.f = f; if (vtffprtype == VTF3_CONST_FPNRT_CRAY_NATIVE_TYPE) { ns = fp.cray_native_type.ns; ex = fp.cray_native_type.ex; m2 = fp.cray_native_type.m2; m1 = fp.cray_native_type.m1; m0 = fp.cray_native_type.m0; if (ns != 0) { *fcb->recbufferpos++ = '0'; return; } if (ex == 0 && m2 == 0 && m1 == 0 && m0 == 0) { *fcb->recbufferpos++ = '0'; return; } if (ex < (unsigned int) 0x2003) { *fcb->recbufferpos++ = '0'; return; } if (ex > (unsigned int) 0x5fff) { (void) StdAsciiWriteSu (fcb, "1000000000000000000000000000000"); return; } if (fp.f < 0.5e+0) { *fcb->recbufferpos++ = '0'; return; } if (fp.f > 1.0e+30) { (void) StdAsciiWriteSu (fcb, "1000000000000000000000000000000"); return; } } else if (vtffprtype == VTF3_CONST_FPNRT_IEEE754_DOUBLE_BIGEND) { ns = fp.ieee754_double_bigend.ns; ex = fp.ieee754_double_bigend.ex; m3 = fp.ieee754_double_bigend.m3; m2 = fp.ieee754_double_bigend.m2; m1 = fp.ieee754_double_bigend.m1; m0 = fp.ieee754_double_bigend.m0; if (ns != 0) { *fcb->recbufferpos++ = '0'; return; } if (ex == 0 && m3 == 0 && m2 == 0 && m1 == 0 && m0 == 0) { *fcb->recbufferpos++ = '0'; return; } if (ex < (unsigned int) 0x002) { *fcb->recbufferpos++ = '0'; return; } if (ex > (unsigned int) 0x7fd) { (void) StdAsciiWriteSu (fcb, "1000000000000000000000000000000"); return; } if (fp.f < 0.5e+0) { *fcb->recbufferpos++ = '0'; return; } if (fp.f > 1.0e+30) { (void) StdAsciiWriteSu (fcb, "1000000000000000000000000000000"); return; } } else if (vtffprtype == VTF3_CONST_FPNRT_IEEE754_DOUBLE_LITEND) { ns = fp.ieee754_double_litend.ns; ex = fp.ieee754_double_litend.ex; m3 = fp.ieee754_double_litend.m3; m2 = fp.ieee754_double_litend.m2; m1 = fp.ieee754_double_litend.m1; m0 = fp.ieee754_double_litend.m0; if (ns != 0) { *fcb->recbufferpos++ = '0'; return; } if (ex == 0 && m3 == 0 && m2 == 0 && m1 == 0 && m0 == 0) { *fcb->recbufferpos++ = '0'; return; } if (ex < (unsigned int) 0x002) { *fcb->recbufferpos++ = '0'; return; } if (ex > (unsigned int) 0x7fd) { (void) StdAsciiWriteSu (fcb, "1000000000000000000000000000000"); return; } if (fp.f < 0.5e+0) { *fcb->recbufferpos++ = '0'; return; } if (fp.f > 1.0e+30) { (void) StdAsciiWriteSu (fcb, "1000000000000000000000000000000"); return; } } else { (void) fprintf (stderr, "VTF3: Unknown FP representation type\n"); (void) fflush (stderr); (void) exit (127); } x = fp.f + 0.5e+0; i1 = 1; i2 = (unsigned int) (sizeof (gpow10) / sizeof (gpow10[0])) - 2; while (i1 != i2) { i = (i1 + i2) >> 1; if (gpow10[i] < x) i1 = i + 1; else i2 = i; } i = i1; numdigs = i - 1; xnorm = x * gpow10r[numdigs]; if (xnorm > 10.0e+0) { numdigs++; xnorm = x * gpow10r[numdigs]; } x = xnorm; if (numdigs == 0) { *fcb->recbufferpos++ = '0'; return; } if (vtffprtype == VTF3_CONST_FPNRT_CRAY_NATIVE_TYPE) { x += 0.5e-14; trustindigs = 14; } else { x += 0.5e-15; trustindigs = 15; } kbnd = numdigs < trustindigs ? numdigs : trustindigs; for (k = 0; k < kbnd; k++) { j1 = 0; j2 = (unsigned int) (sizeof (fdig) / sizeof (fdig[0])) - 1; while (j1 != j2) { j = (j1 + j2) >> 1; if (fdig[j] < x) j1 = j + 1; else j2 = j; } j = j1; if (fdig[j] > x) j--; x -= fdig[j]; x *= 10.0e+0; *fcb->recbufferpos++ = dig[j]; } if (kbnd < numdigs) { p = fcb->recbufferpos; fcb->recbufferpos += numdigs - kbnd; for (k = kbnd; k < numdigs; k++) *p++ = '0'; } return; } static void StdAsciiWriteU4 (fcb_t *fcb, unsigned int u) { static char dig [10] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9'}; char convbuf [16]; char *p; unsigned int udig; if (fcb->recbufferpos + sizeof (convbuf) / sizeof (convbuf[0]) > fcb->recbufferbeyond) (void) ReallocRecord (fcb, (unsigned int) (sizeof (convbuf) / sizeof (convbuf[0]))); if (u == 0) { *fcb->recbufferpos++ = '0'; return; } if (u > (unsigned int) 0xfffffffe) { (void) StdAsciiWriteSu (fcb, "4294967295"); return; } p = &convbuf[sizeof (convbuf) / sizeof (convbuf[0]) - 1]; *p-- = '\0'; while (u != 0) { udig = u % 10; *p-- = dig[udig]; u -= udig; u /= 10; } p++; while (*p != '\0') *fcb->recbufferpos++ = *p++; return; } /** * read a string from binary trace file * attention: strings need to be written at the end of a record, as this * function overwrites the stream with a "\0" at the end */ static const char * StdBinaryGetSeparatedString (fcb_t *fcb, int index) { static unsigned char uchar80h = (unsigned char) 0x80; int start, beyond, i; char *p, c; if (fcb->stroffsetvectorstart == 0) { (void) fprintf (stderr, "VTF3: StdBinaryGetSeparatedString(): " "Unrecoverable error\n"); (void) fflush (stderr); (void) exit (127); } if (fcb->stroffsetvectorbeyond == 0) { (void) fprintf (stderr, "VTF3: StdBinaryGetSeparatedString(): " "Unrecoverable error\n"); (void) fflush (stderr); (void) exit (127); } if (index + 1 > fcb->stroffsetvectordim) { (void) fprintf (stderr, "VTF3: StdBinaryGetSeparatedString(): " "Unrecoverable error\n"); (void) fflush (stderr); (void) exit (127); } start = *(fcb->stroffsetvectorstart + index); beyond = *(fcb->stroffsetvectorbeyond + index); p = fcb->recbuffer; for (i = start; i < beyond; i++) { c = *(p + i); if (c == '\n') *(p + i) = ' '; else if (c == '\0') *(p + i) = (char) * (char *) (unsigned char *) &uchar80h; } *(p + beyond) = '\0'; return ((const char *) (p + start)); } static void StdBinaryParser (fcb_t *fcb, int numcharsdata) { unsigned char *from; unsigned int u, i1, i2, i; int recordtype, handlerindex; stdbinaryparser_t stdbinaryparser; from = (unsigned char *) fcb->recbuffer + 4; u = ((unsigned int) (unsigned char) *(from + 0) << 0) + ((unsigned int) (unsigned char) *(from + 1) << 8); if ((u & (unsigned int) 0x8000) != 0) { if ((u & (unsigned int) 0x7fff) != 0) { u--; u = ~u; u &= (unsigned int) 0xffff; u = ~u; u++; } else { u = ~u; u &= (unsigned int) 0xffff; u = ~u; } } recordtype = * (int *) &u; i1 = 0; i2 = (unsigned int) (sizeof (recordtypes) / sizeof (recordtypes[0])) - 1; while (i1 != i2) { i = (i1 + i2) >> 1; if (recordtypes[i] < recordtype) i1 = i + 1; else i2 = i; } i = i1; if (recordtype != recordtypes[i]) { handlerindex = vtfunrecognizablehandlerindex; (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } handlerindex = (int) i; stdbinaryparser = stdbinaryparsers [handlerindex]; (void) (stdbinaryparser) (fcb, numcharsdata, handlerindex); return; } static double StdBinaryReadF8 (fcb_t *fcb) { unsigned char *from; union { unsigned char c [8]; double f; struct { unsigned int ns:1; unsigned int ex:15; unsigned int m3:5; unsigned int m2:16; unsigned int m1:16; unsigned int m0:11; } cray_native_type; struct { unsigned int ns:1; unsigned int ex:11; unsigned int m3:4; unsigned int m2:16; unsigned int m1:16; unsigned int m0:16; } ieee754_double_bigend; struct { unsigned int m0:16; unsigned int m1:16; unsigned int m2:16; unsigned int m3:4; unsigned int ex:11; unsigned int ns:1; } ieee754_double_litend; } fp; unsigned int ex, m3, m2, m1, m0, ns; from = (unsigned char *) fcb->recbufferpos; fcb->recbufferpos += 8; if (vtffprtype == VTF3_CONST_FPNRT_CRAY_NATIVE_TYPE) { fp.c[7] = *(from + 0); fp.c[6] = *(from + 1); fp.c[5] = *(from + 2); fp.c[4] = *(from + 3); fp.c[3] = *(from + 4); fp.c[2] = *(from + 5); fp.c[1] = *(from + 6); fp.c[0] = *(from + 7); ex = fp.ieee754_double_bigend.ex; m3 = fp.ieee754_double_bigend.m3; m2 = fp.ieee754_double_bigend.m2; m1 = fp.ieee754_double_bigend.m1; m0 = fp.ieee754_double_bigend.m0; if (ex == 0 && m3 == 0 && m2 == 0 && m1 == 0 && m0 == 0) return (0.0e+0); if (ex < (unsigned int) 0x002) { ex = (unsigned int) 0x002; m3 = (unsigned int) 0x0; m2 = (unsigned int) 0x0000; m1 = (unsigned int) 0x0000; m0 = (unsigned int) 0x0000; } else if (ex > (unsigned int) 0x7fd) { ex = (unsigned int) 0x7fd; m3 = (unsigned int) 0xf; m2 = (unsigned int) 0xffff; m1 = (unsigned int) 0xffff; m0 = (unsigned int) 0xffff; } ex += (unsigned int) 0x3c02; m3 += (unsigned int) 0x10; m0 >>= 5; fp.cray_native_type.ex = ex; fp.cray_native_type.m3 = m3; fp.cray_native_type.m2 = m2; fp.cray_native_type.m1 = m1; fp.cray_native_type.m0 = m0; ns = fp.cray_native_type.ns; fp.cray_native_type.ns = 0; if (fp.f < 1.0e-300) fp.f = 1.0e-300; else if (fp.f > 1.0e+300) fp.f = 1.0e+300; fp.cray_native_type.ns = ns; return (fp.f); } if (vtffprtype == VTF3_CONST_FPNRT_IEEE754_DOUBLE_BIGEND) { fp.c[7] = *(from + 0); fp.c[6] = *(from + 1); fp.c[5] = *(from + 2); fp.c[4] = *(from + 3); fp.c[3] = *(from + 4); fp.c[2] = *(from + 5); fp.c[1] = *(from + 6); fp.c[0] = *(from + 7); ex = fp.ieee754_double_bigend.ex; m3 = fp.ieee754_double_bigend.m3; m2 = fp.ieee754_double_bigend.m2; m1 = fp.ieee754_double_bigend.m1; m0 = fp.ieee754_double_bigend.m0; if (ex == 0 && m3 == 0 && m2 == 0 && m1 == 0 && m0 == 0) return (0.0e+0); if (ex < (unsigned int) 0x002) { fp.ieee754_double_bigend.ex = (unsigned int) 0x002; fp.ieee754_double_bigend.m3 = (unsigned int) 0x0; fp.ieee754_double_bigend.m2 = (unsigned int) 0x0000; fp.ieee754_double_bigend.m1 = (unsigned int) 0x0000; fp.ieee754_double_bigend.m0 = (unsigned int) 0x0000; } else if (ex > (unsigned int) 0x7fd) { fp.ieee754_double_bigend.ex = (unsigned int) 0x7fd; fp.ieee754_double_bigend.m3 = (unsigned int) 0xf; fp.ieee754_double_bigend.m2 = (unsigned int) 0xffff; fp.ieee754_double_bigend.m1 = (unsigned int) 0xffff; fp.ieee754_double_bigend.m0 = (unsigned int) 0xffff; } ns = fp.ieee754_double_bigend.ns; fp.ieee754_double_bigend.ns = 0; if (fp.f < 1.0e-300) fp.f = 1.0e-300; else if (fp.f > 1.0e+300) fp.f = 1.0e+300; fp.ieee754_double_bigend.ns = ns; return (fp.f); } if (vtffprtype == VTF3_CONST_FPNRT_IEEE754_DOUBLE_LITEND) { fp.c[0] = *(from + 0); fp.c[1] = *(from + 1); fp.c[2] = *(from + 2); fp.c[3] = *(from + 3); fp.c[4] = *(from + 4); fp.c[5] = *(from + 5); fp.c[6] = *(from + 6); fp.c[7] = *(from + 7); ex = fp.ieee754_double_litend.ex; m3 = fp.ieee754_double_litend.m3; m2 = fp.ieee754_double_litend.m2; m1 = fp.ieee754_double_litend.m1; m0 = fp.ieee754_double_litend.m0; if (ex == 0 && m3 == 0 && m2 == 0 && m1 == 0 && m0 == 0) return (0.0e+0); if (ex < (unsigned int) 0x002) { fp.ieee754_double_litend.ex = (unsigned int) 0x002; fp.ieee754_double_litend.m3 = (unsigned int) 0x0; fp.ieee754_double_litend.m2 = (unsigned int) 0x0000; fp.ieee754_double_litend.m1 = (unsigned int) 0x0000; fp.ieee754_double_litend.m0 = (unsigned int) 0x0000; } else if (ex > (unsigned int) 0x7fd) { fp.ieee754_double_litend.ex = (unsigned int) 0x7fd; fp.ieee754_double_litend.m3 = (unsigned int) 0xf; fp.ieee754_double_litend.m2 = (unsigned int) 0xffff; fp.ieee754_double_litend.m1 = (unsigned int) 0xffff; fp.ieee754_double_litend.m0 = (unsigned int) 0xffff; } ns = fp.ieee754_double_litend.ns; fp.ieee754_double_litend.ns = 0; if (fp.f < 1.0e-300) fp.f = 1.0e-300; else if (fp.f > 1.0e+300) fp.f = 1.0e+300; fp.ieee754_double_litend.ns = ns; return (fp.f); } (void) fprintf (stderr, "VTF3: Unknown FP representation type\n"); (void) fflush (stderr); (void) exit (127); return (0.0e+0); } static int StdBinaryReadI2 (fcb_t *fcb) { unsigned char *from; unsigned int u; from = (unsigned char *) fcb->recbufferpos; fcb->recbufferpos += 2; u = ((unsigned int) (unsigned char) *(from + 0) << 0) + ((unsigned int) (unsigned char) *(from + 1) << 8); if ((u & (unsigned int) 0x8000) != 0) { if ((u & (unsigned int) 0x7fff) != 0) { u--; u = ~u; u &= (unsigned int) 0xffff; u = ~u; u++; } else { u = ~u; u &= (unsigned int) 0xffff; u = ~u; } } return (* (int *) &u); } static int StdBinaryReadRecord (fcb_t *fcb) { static const unsigned char stdbinaryheader [] = VTF3_HEADER_STD_BINARY; size_t numchars, neededchars, nrb, nio, ncp; unsigned char *from; unsigned int u, n, j0, j1, j2, j3, i; int numcharsdata; char *pt, *pf; fcb->recbufferpos = fcb->recbuffer + 0; if (fcb->iobufferpos + 6 > fcb->iobuffereof) { if (fcb->iobuffereof < fcb->iobufferbeyond) /* EOF. */ return (0); if (fcb->iobufferpos < fcb->iobuffereof) { /* Copy the remainder. */ numchars = (size_t) (fcb->iobuffereof - fcb->iobufferpos); if (fcb->recbufferpos + numchars > fcb->recbufferbeyond) (void) ReallocRecord (fcb, (unsigned int) numchars); (void) memcpy (fcb->recbufferpos, fcb->iobufferpos, numchars * sizeof (char)); fcb->recbufferpos += numchars; fcb->iobufferpos += numchars; } /* Try to read a new buffer. */ (void) FillIoBuffer (fcb); numchars = (size_t) (fcb->iobuffereof - fcb->iobuffer); neededchars = (size_t) (fcb->recbuffer + 6 - fcb->recbufferpos); if (numchars < neededchars) /* EOF. */ return (0); if (fcb->recbufferpos + neededchars > fcb->recbufferbeyond) (void) ReallocRecord (fcb, (unsigned int) neededchars); (void) memcpy (fcb->recbufferpos, fcb->iobufferpos, neededchars * sizeof (char)); fcb->recbufferpos += neededchars; fcb->iobufferpos += neededchars; } else { if (fcb->recbufferpos + 6 > fcb->recbufferbeyond) (void) ReallocRecord (fcb, 6); *(fcb->recbufferpos + 0) = *(fcb->iobufferpos + 0); *(fcb->recbufferpos + 1) = *(fcb->iobufferpos + 1); *(fcb->recbufferpos + 2) = *(fcb->iobufferpos + 2); *(fcb->recbufferpos + 3) = *(fcb->iobufferpos + 3); *(fcb->recbufferpos + 4) = *(fcb->iobufferpos + 4); *(fcb->recbufferpos + 5) = *(fcb->iobufferpos + 5); fcb->recbufferpos += 6; fcb->iobufferpos += 6; } from = (unsigned char *) fcb->recbuffer; u = ((unsigned int) (unsigned char) *(from + 0) << 0) + ((unsigned int) (unsigned char) *(from + 1) << 8) + ((unsigned int) (unsigned char) *(from + 2) << 16) + ((unsigned int) (unsigned char) *(from + 3) << 24); if ((u & (unsigned int) 0x80000000) != 0) { if ((u & (unsigned int) 0x7fffffff) != 0) { u--; u = ~u; u &= (unsigned int) 0xffffffff; u = ~u; u++; } else { u = ~u; u &= (unsigned int) 0xffffffff; u = ~u; } } if (u == vtfbinaryheaderasrecordlength) /* Illegal value, try as standard binary format header. */ numcharsdata = (int) (sizeof (stdbinaryheader) / sizeof (unsigned char)) - 6; else numcharsdata = * (int *) &u; if (numcharsdata < 0) /* Corrupt file contents. Stop processing. */ return (0); while (fcb->recbufferpos < fcb->recbuffer + 6 + numcharsdata) { nrb = (size_t) (fcb->recbuffer + 6 + numcharsdata - fcb->recbufferpos); nio = (size_t) (fcb->iobuffereof - fcb->iobufferpos); ncp = nrb < nio ? nrb : nio; if (ncp == 0) { if (fcb->iobuffereof < fcb->iobufferbeyond) /* EOF. */ return (0); /* Try to read a new buffer. */ (void) FillIoBuffer (fcb); continue; } if (fcb->recbufferpos + ncp > fcb->recbufferbeyond) (void) ReallocRecord (fcb, (unsigned int) ncp); pt = fcb->recbufferpos; pf = fcb->iobufferpos; if (ncp < 100) { n = (unsigned int) ncp; for (j0 = 0; j0 < n >> 3 << 3; j0 += 8) { *(pt + j0 + 0) = *(pf + j0 + 0); *(pt + j0 + 1) = *(pf + j0 + 1); *(pt + j0 + 2) = *(pf + j0 + 2); *(pt + j0 + 3) = *(pf + j0 + 3); *(pt + j0 + 4) = *(pf + j0 + 4); *(pt + j0 + 5) = *(pf + j0 + 5); *(pt + j0 + 6) = *(pf + j0 + 6); *(pt + j0 + 7) = *(pf + j0 + 7); } for (j1 = n >> 3 << 3; j1 < n >> 2 << 2; j1 += 4) { *(pt + j1 + 0) = *(pf + j1 + 0); *(pt + j1 + 1) = *(pf + j1 + 1); *(pt + j1 + 2) = *(pf + j1 + 2); *(pt + j1 + 3) = *(pf + j1 + 3); } for (j2 = n >> 2 << 2; j2 < n >> 1 << 1; j2 += 2) { *(pt + j2 + 0) = *(pf + j2 + 0); *(pt + j2 + 1) = *(pf + j2 + 1); } for (j3 = n >> 1 << 1; j3 < n >> 0 << 0; j3 += 1) { *(pt + j3 + 0) = *(pf + j3 + 0); } } else (void) memcpy (pt, pf, ncp * sizeof (char)); fcb->recbufferpos += ncp; fcb->iobufferpos += ncp; } if (u == vtfbinaryheaderasrecordlength) { /* Check for standard binary format header. */ for (i = 0; i < (unsigned int) (sizeof (stdbinaryheader) / sizeof (unsigned char)); i++) { if ((unsigned char) *(fcb->recbuffer + i) != stdbinaryheader[i]) { /* Corrupt file contents. Stop processing. */ (void) fprintf (stderr, "VTF3: Too long record, %lu bytes\n", (unsigned long) u * (unsigned long) sizeof (char)); (void) fflush (stderr); VTF3_NOMEM_GOOD_BYE_INFO; (void) exit (127); } } /* Yes, standard binary format header. */ return (-1); } /* Ensure that StdBinaryGetSeparatedString() does not kill anything. */ if (fcb->recbufferpos + 1 > fcb->recbufferbeyond) (void) ReallocRecord (fcb, 1); return (numcharsdata + 6); } static double StdBinaryReadTs (fcb_t *fcb) { static unsigned int mfilters [212] = { 0x0, 0x0000, 0x0000, 0x0000, 0x8, 0x0000, 0x0000, 0x0000, 0xc, 0x0000, 0x0000, 0x0000, 0xe, 0x0000, 0x0000, 0x0000, 0xf, 0x0000, 0x0000, 0x0000, 0xf, 0x8000, 0x0000, 0x0000, 0xf, 0xc000, 0x0000, 0x0000, 0xf, 0xe000, 0x0000, 0x0000, 0xf, 0xf000, 0x0000, 0x0000, 0xf, 0xf800, 0x0000, 0x0000, 0xf, 0xfc00, 0x0000, 0x0000, 0xf, 0xfe00, 0x0000, 0x0000, 0xf, 0xff00, 0x0000, 0x0000, 0xf, 0xff80, 0x0000, 0x0000, 0xf, 0xffc0, 0x0000, 0x0000, 0xf, 0xffe0, 0x0000, 0x0000, 0xf, 0xfff0, 0x0000, 0x0000, 0xf, 0xfff8, 0x0000, 0x0000, 0xf, 0xfffc, 0x0000, 0x0000, 0xf, 0xfffe, 0x0000, 0x0000, 0xf, 0xffff, 0x0000, 0x0000, 0xf, 0xffff, 0x8000, 0x0000, 0xf, 0xffff, 0xc000, 0x0000, 0xf, 0xffff, 0xe000, 0x0000, 0xf, 0xffff, 0xf000, 0x0000, 0xf, 0xffff, 0xf800, 0x0000, 0xf, 0xffff, 0xfc00, 0x0000, 0xf, 0xffff, 0xfe00, 0x0000, 0xf, 0xffff, 0xff00, 0x0000, 0xf, 0xffff, 0xff80, 0x0000, 0xf, 0xffff, 0xffc0, 0x0000, 0xf, 0xffff, 0xffe0, 0x0000, 0xf, 0xffff, 0xfff0, 0x0000, 0xf, 0xffff, 0xfff8, 0x0000, 0xf, 0xffff, 0xfffc, 0x0000, 0xf, 0xffff, 0xfffe, 0x0000, 0xf, 0xffff, 0xffff, 0x0000, 0xf, 0xffff, 0xffff, 0x8000, 0xf, 0xffff, 0xffff, 0xc000, 0xf, 0xffff, 0xffff, 0xe000, 0xf, 0xffff, 0xffff, 0xf000, 0xf, 0xffff, 0xffff, 0xf800, 0xf, 0xffff, 0xffff, 0xfc00, 0xf, 0xffff, 0xffff, 0xfe00, 0xf, 0xffff, 0xffff, 0xff00, 0xf, 0xffff, 0xffff, 0xff80, 0xf, 0xffff, 0xffff, 0xffc0, 0xf, 0xffff, 0xffff, 0xffe0, 0xf, 0xffff, 0xffff, 0xfff0, 0xf, 0xffff, 0xffff, 0xfff8, 0xf, 0xffff, 0xffff, 0xfffc, 0xf, 0xffff, 0xffff, 0xfffe, 0xf, 0xffff, 0xffff, 0xffff }; unsigned char *from; union { unsigned char c [8]; double f; struct { unsigned int ns:1; unsigned int ex:15; unsigned int m3:5; unsigned int m2:16; unsigned int m1:16; unsigned int m0:11; } cray_native_type; struct { unsigned int ns:1; unsigned int ex:11; unsigned int m3:4; unsigned int m2:16; unsigned int m1:16; unsigned int m0:16; } ieee754_double_bigend; struct { unsigned int m0:16; unsigned int m1:16; unsigned int m2:16; unsigned int m3:4; unsigned int ex:11; unsigned int ns:1; } ieee754_double_litend; } fp; unsigned int ex, m3, m2, m1, m0, ns, mfiltergroup; from = (unsigned char *) fcb->recbufferpos; fcb->recbufferpos += 8; if (vtffprtype == VTF3_CONST_FPNRT_CRAY_NATIVE_TYPE) { fp.c[7] = *(from + 0); fp.c[6] = *(from + 1); fp.c[5] = *(from + 2); fp.c[4] = *(from + 3); fp.c[3] = *(from + 4); fp.c[2] = *(from + 5); fp.c[1] = *(from + 6); fp.c[0] = *(from + 7); ex = fp.ieee754_double_bigend.ex; m3 = fp.ieee754_double_bigend.m3; m2 = fp.ieee754_double_bigend.m2; m1 = fp.ieee754_double_bigend.m1; m0 = fp.ieee754_double_bigend.m0; if (ex == 0 && m3 == 0 && m2 == 0 && m1 == 0 && m0 == 0) return (0.0e+0); if (ex < (unsigned int) 0x002) { ex = (unsigned int) 0x002; m3 = (unsigned int) 0x0; m2 = (unsigned int) 0x0000; m1 = (unsigned int) 0x0000; m0 = (unsigned int) 0x0000; } else if (ex > (unsigned int) 0x7fd) { ex = (unsigned int) 0x7fd; m3 = (unsigned int) 0xf; m2 = (unsigned int) 0xffff; m1 = (unsigned int) 0xffff; m0 = (unsigned int) 0xffff; } ex += (unsigned int) 0x3c02; m3 += (unsigned int) 0x10; m0 >>= 5; fp.cray_native_type.ex = ex; fp.cray_native_type.m3 = m3; fp.cray_native_type.m2 = m2; fp.cray_native_type.m1 = m1; fp.cray_native_type.m0 = m0; ns = fp.cray_native_type.ns; fp.cray_native_type.ns = 0; if (fp.f < 0.5e+0) fp.f = 0.0e+0; else if (fp.f > 1.0e+30) fp.f = 1.0e+30; fp.f += 0.5e+0; fp.cray_native_type.ns = ns; ex = fp.cray_native_type.ex; m3 = fp.cray_native_type.m3; m2 = fp.cray_native_type.m2; m1 = fp.cray_native_type.m1; m0 = fp.cray_native_type.m0; ex -= (unsigned int) 0x3c02; m3 &= (unsigned int) 0xf; m0 <<= 5; if (ex < (unsigned int) 0x3ff) mfiltergroup = 0; else mfiltergroup = ex - (unsigned int) 0x3ff; if (mfiltergroup > (unsigned int) (sizeof (mfilters) / (4 * sizeof (mfilters[0]))) - 1) mfiltergroup = (unsigned int) (sizeof (mfilters) / (4 * sizeof (mfilters[0]))) - 1; m3 &= mfilters[(mfiltergroup << 2) + 0]; m2 &= mfilters[(mfiltergroup << 2) + 1]; m1 &= mfilters[(mfiltergroup << 2) + 2]; m0 &= mfilters[(mfiltergroup << 2) + 3]; ex += (unsigned int) 0x3c02; m3 += (unsigned int) 0x10; m0 >>= 5; fp.cray_native_type.m3 = m3; fp.cray_native_type.m2 = m2; fp.cray_native_type.m1 = m1; fp.cray_native_type.m0 = m0; return (fp.f); } if (vtffprtype == VTF3_CONST_FPNRT_IEEE754_DOUBLE_BIGEND) { fp.c[7] = *(from + 0); fp.c[6] = *(from + 1); fp.c[5] = *(from + 2); fp.c[4] = *(from + 3); fp.c[3] = *(from + 4); fp.c[2] = *(from + 5); fp.c[1] = *(from + 6); fp.c[0] = *(from + 7); ex = fp.ieee754_double_bigend.ex; m3 = fp.ieee754_double_bigend.m3; m2 = fp.ieee754_double_bigend.m2; m1 = fp.ieee754_double_bigend.m1; m0 = fp.ieee754_double_bigend.m0; if (ex == 0 && m3 == 0 && m2 == 0 && m1 == 0 && m0 == 0) return (0.0e+0); if (ex < (unsigned int) 0x002) { fp.ieee754_double_bigend.ex = (unsigned int) 0x002; fp.ieee754_double_bigend.m3 = (unsigned int) 0x0; fp.ieee754_double_bigend.m2 = (unsigned int) 0x0000; fp.ieee754_double_bigend.m1 = (unsigned int) 0x0000; fp.ieee754_double_bigend.m0 = (unsigned int) 0x0000; } else if (ex > (unsigned int) 0x7fd) { fp.ieee754_double_bigend.ex = (unsigned int) 0x7fd; fp.ieee754_double_bigend.m3 = (unsigned int) 0xf; fp.ieee754_double_bigend.m2 = (unsigned int) 0xffff; fp.ieee754_double_bigend.m1 = (unsigned int) 0xffff; fp.ieee754_double_bigend.m0 = (unsigned int) 0xffff; } ns = fp.ieee754_double_bigend.ns; fp.ieee754_double_bigend.ns = 0; if (fp.f < 0.5e+0) fp.f = 0.0e+0; else if (fp.f > 1.0e+30) fp.f = 1.0e+30; fp.f += 0.5e+0; fp.ieee754_double_bigend.ns = ns; ex = fp.ieee754_double_bigend.ex; m3 = fp.ieee754_double_bigend.m3; m2 = fp.ieee754_double_bigend.m2; m1 = fp.ieee754_double_bigend.m1; m0 = fp.ieee754_double_bigend.m0; if (ex < (unsigned int) 0x3ff) mfiltergroup = 0; else mfiltergroup = ex - (unsigned int) 0x3ff; if (mfiltergroup > (unsigned int) (sizeof (mfilters) / (4 * sizeof (mfilters[0]))) - 1) mfiltergroup = (unsigned int) (sizeof (mfilters) / (4 * sizeof (mfilters[0]))) - 1; m3 &= mfilters[(mfiltergroup << 2) + 0]; m2 &= mfilters[(mfiltergroup << 2) + 1]; m1 &= mfilters[(mfiltergroup << 2) + 2]; m0 &= mfilters[(mfiltergroup << 2) + 3]; fp.ieee754_double_bigend.m3 = m3; fp.ieee754_double_bigend.m2 = m2; fp.ieee754_double_bigend.m1 = m1; fp.ieee754_double_bigend.m0 = m0; return (fp.f); } if (vtffprtype == VTF3_CONST_FPNRT_IEEE754_DOUBLE_LITEND) { fp.c[0] = *(from + 0); fp.c[1] = *(from + 1); fp.c[2] = *(from + 2); fp.c[3] = *(from + 3); fp.c[4] = *(from + 4); fp.c[5] = *(from + 5); fp.c[6] = *(from + 6); fp.c[7] = *(from + 7); ex = fp.ieee754_double_litend.ex; m3 = fp.ieee754_double_litend.m3; m2 = fp.ieee754_double_litend.m2; m1 = fp.ieee754_double_litend.m1; m0 = fp.ieee754_double_litend.m0; if (ex == 0 && m3 == 0 && m2 == 0 && m1 == 0 && m0 == 0) return (0.0e+0); if (ex < (unsigned int) 0x002) { fp.ieee754_double_litend.ex = (unsigned int) 0x002; fp.ieee754_double_litend.m3 = (unsigned int) 0x0; fp.ieee754_double_litend.m2 = (unsigned int) 0x0000; fp.ieee754_double_litend.m1 = (unsigned int) 0x0000; fp.ieee754_double_litend.m0 = (unsigned int) 0x0000; } else if (ex > (unsigned int) 0x7fd) { fp.ieee754_double_litend.ex = (unsigned int) 0x7fd; fp.ieee754_double_litend.m3 = (unsigned int) 0xf; fp.ieee754_double_litend.m2 = (unsigned int) 0xffff; fp.ieee754_double_litend.m1 = (unsigned int) 0xffff; fp.ieee754_double_litend.m0 = (unsigned int) 0xffff; } ns = fp.ieee754_double_litend.ns; fp.ieee754_double_litend.ns = 0; if (fp.f < 0.5e+0) fp.f = 0.0e+0; else if (fp.f > 1.0e+30) fp.f = 1.0e+30; fp.f += 0.5e+0; fp.ieee754_double_litend.ns = ns; ex = fp.ieee754_double_litend.ex; m3 = fp.ieee754_double_litend.m3; m2 = fp.ieee754_double_litend.m2; m1 = fp.ieee754_double_litend.m1; m0 = fp.ieee754_double_litend.m0; if (ex < (unsigned int) 0x3ff) mfiltergroup = 0; else mfiltergroup = ex - (unsigned int) 0x3ff; if (mfiltergroup > (unsigned int) (sizeof (mfilters) / (4 * sizeof (mfilters[0]))) - 1) mfiltergroup = (unsigned int) (sizeof (mfilters) / (4 * sizeof (mfilters[0]))) - 1; m3 &= mfilters[(mfiltergroup << 2) + 0]; m2 &= mfilters[(mfiltergroup << 2) + 1]; m1 &= mfilters[(mfiltergroup << 2) + 2]; m0 &= mfilters[(mfiltergroup << 2) + 3]; fp.ieee754_double_litend.m3 = m3; fp.ieee754_double_litend.m2 = m2; fp.ieee754_double_litend.m1 = m1; fp.ieee754_double_litend.m0 = m0; return (fp.f); } (void) fprintf (stderr, "VTF3: Unknown FP representation type\n"); (void) fflush (stderr); (void) exit (127); return (0.0e+0); } static void StdBinaryStoreStringOffsets (fcb_t *fcb, int index) { size_t size; unsigned char *from; unsigned int u; int length, start, beyond; if (fcb->stroffsetvectorstart == 0) { fcb->stroffsetvectordim = index + 1 + 10; size = (size_t) fcb->stroffsetvectordim * sizeof (int); fcb->stroffsetvectorstart = (int *) malloc (size); if (fcb->stroffsetvectorstart == 0) { VTF3_NOMEM_GOOD_BYE_INFO; (void) exit (127); } fcb->stroffsetvectorbeyond = (int *) malloc (size); if (fcb->stroffsetvectorbeyond == 0) { VTF3_NOMEM_GOOD_BYE_INFO; (void) exit (127); } } if (index + 1 > fcb->stroffsetvectordim) { fcb->stroffsetvectordim = 2 * (index + 1); size = (size_t) fcb->stroffsetvectordim * sizeof (int); fcb->stroffsetvectorstart = (int *) realloc (fcb->stroffsetvectorstart, size); if (fcb->stroffsetvectorstart == 0) { VTF3_NOMEM_GOOD_BYE_INFO; (void) exit (127); } fcb->stroffsetvectorbeyond = (int *) realloc (fcb->stroffsetvectorbeyond, size); if (fcb->stroffsetvectorbeyond == 0) { VTF3_NOMEM_GOOD_BYE_INFO; (void) exit (127); } } from = (unsigned char *) fcb->recbufferpos; u = ((unsigned int) (unsigned char) *(from + 0) << 0) + ((unsigned int) (unsigned char) *(from + 1) << 8); if ((u & (unsigned int) 0x8000) != 0) { if ((u & (unsigned int) 0x7fff) != 0) { u--; u = ~u; u &= (unsigned int) 0xffff; u = ~u; u++; } else { u = ~u; u &= (unsigned int) 0xffff; u = ~u; } } length = * (int *) &u; start = (int) (fcb->recbufferpos + 2 - fcb->recbuffer); beyond = start + length; fcb->recbufferpos += 2 + length; *(fcb->stroffsetvectorstart + index) = start; *(fcb->stroffsetvectorbeyond + index) = beyond; return; } static void StdBinaryWriteCa (fcb_t *fcb, const char *src, int numchars) { char *pt; const char *pf; unsigned int n, j0, j1, j2, j3; if (numchars < 1) return; if (fcb->recbufferpos + numchars > fcb->recbufferbeyond) (void) ReallocRecord (fcb, (unsigned int) numchars); pt = fcb->recbufferpos; pf = src; if (numchars < 100) { n = (unsigned int) numchars; for (j0 = 0; j0 < n >> 3 << 3; j0 += 8) { *(pt + j0 + 0) = *(pf + j0 + 0); *(pt + j0 + 1) = *(pf + j0 + 1); *(pt + j0 + 2) = *(pf + j0 + 2); *(pt + j0 + 3) = *(pf + j0 + 3); *(pt + j0 + 4) = *(pf + j0 + 4); *(pt + j0 + 5) = *(pf + j0 + 5); *(pt + j0 + 6) = *(pf + j0 + 6); *(pt + j0 + 7) = *(pf + j0 + 7); } for (j1 = n >> 3 << 3; j1 < n >> 2 << 2; j1 += 4) { *(pt + j1 + 0) = *(pf + j1 + 0); *(pt + j1 + 1) = *(pf + j1 + 1); *(pt + j1 + 2) = *(pf + j1 + 2); *(pt + j1 + 3) = *(pf + j1 + 3); } for (j2 = n >> 2 << 2; j2 < n >> 1 << 1; j2 += 2) { *(pt + j2 + 0) = *(pf + j2 + 0); *(pt + j2 + 1) = *(pf + j2 + 1); } for (j3 = n >> 1 << 1; j3 < n >> 0 << 0; j3 += 1) { *(pt + j3 + 0) = *(pf + j3 + 0); } } else (void) memcpy (pt, pf, (size_t) numchars * sizeof (char)); fcb->recbufferpos += numchars; return; } static VTF3_rec_t * StdBinaryWriteEp (fcb_t *fcb, int type) { unsigned int numchars, u; unsigned char *t; int i; /* Ensure that we have memory (DEFUNMERGED). */ if (fcb->recbufferpos + 1 > fcb->recbufferbeyond) (void) ReallocRecord (fcb, 1); numchars = (unsigned int) (fcb->recbufferpos - fcb->recbuffer); if (numchars < 6) { (void) fprintf (stderr, "VTF3: StdBinaryWriteEp(): " "Unrecoverable error\n"); (void) fflush (stderr); (void) exit (127); } u = numchars - 6; if (u > (unsigned int) 0xfffffffe) u = (unsigned int) 0xffffffff; t = (unsigned char *) fcb->recbuffer + 0; *(t + 0) = (unsigned char) (u >> 0 & (unsigned int) 0xff); *(t + 1) = (unsigned char) (u >> 8 & (unsigned int) 0xff); *(t + 2) = (unsigned char) (u >> 16 & (unsigned int) 0xff); *(t + 3) = (unsigned char) (u >> 24 & (unsigned int) 0xff); i = type; if (i > 0) { if (i > 32766) i = 32767; } else if (i + 32767 < 0) i = -32768; u = * (unsigned int *) &i; *(t + 4) = (unsigned char) (u >> 0 & (unsigned int) 0xff); *(t + 5) = (unsigned char) (u >> 8 & (unsigned int) 0xff); fcb->rcb.type = type; fcb->rcb.numchars = (int) numchars; fcb->rcb.record = fcb->recbuffer; return ((VTF3_rec_t *) &fcb->rcb); } static void StdBinaryWriteF8 (fcb_t *fcb, double f) { unsigned char *t; union { unsigned char c [8]; double f; struct { unsigned int ns:1; unsigned int ex:15; unsigned int m3:5; unsigned int m2:16; unsigned int m1:16; unsigned int m0:11; } cray_native_type; struct { unsigned int ns:1; unsigned int ex:11; unsigned int m3:4; unsigned int m2:16; unsigned int m1:16; unsigned int m0:16; } ieee754_double_bigend; struct { unsigned int m0:16; unsigned int m1:16; unsigned int m2:16; unsigned int m3:4; unsigned int ex:11; unsigned int ns:1; } ieee754_double_litend; } fp; unsigned int ns, ex, m3, m2, m1, m0; if (fcb->recbufferpos + 8 > fcb->recbufferbeyond) (void) ReallocRecord (fcb, 8); t = (unsigned char *) fcb->recbufferpos; fcb->recbufferpos += 8; fp.f = f; if (vtffprtype == VTF3_CONST_FPNRT_CRAY_NATIVE_TYPE) { ns = fp.cray_native_type.ns; ex = fp.cray_native_type.ex; m3 = fp.cray_native_type.m3; m2 = fp.cray_native_type.m2; m1 = fp.cray_native_type.m1; m0 = fp.cray_native_type.m0; if (ex == 0 && m3 == 0 && m2 == 0 && m1 == 0 && m0 == 0) { *(t + 0) = (unsigned char) 0x00; *(t + 1) = (unsigned char) 0x00; *(t + 2) = (unsigned char) 0x00; *(t + 3) = (unsigned char) 0x00; *(t + 4) = (unsigned char) 0x00; *(t + 5) = (unsigned char) 0x00; *(t + 6) = (unsigned char) 0x00; *(t + 7) = (unsigned char) 0x00; return; } if (ex < (unsigned int) 0x2003) { fp.cray_native_type.ex = (unsigned int) 0x2003; fp.cray_native_type.m3 = (unsigned int) 0x10; fp.cray_native_type.m2 = (unsigned int) 0x0000; fp.cray_native_type.m1 = (unsigned int) 0x0000; fp.cray_native_type.m0 = (unsigned int) 0x000; } else if (ex > (unsigned int) 0x5fff) { fp.cray_native_type.ex = (unsigned int) 0x5fff; fp.cray_native_type.m3 = (unsigned int) 0x10; fp.cray_native_type.m2 = (unsigned int) 0x0000; fp.cray_native_type.m1 = (unsigned int) 0x0000; fp.cray_native_type.m0 = (unsigned int) 0x000; } fp.cray_native_type.ns = 0; if (fp.f < 1.0e-300) fp.f = 1.0e-300; else if (fp.f > 1.0e+300) fp.f = 1.0e+300; fp.cray_native_type.ns = ns; ex = fp.cray_native_type.ex; m3 = fp.cray_native_type.m3; m2 = fp.cray_native_type.m2; m1 = fp.cray_native_type.m1; m0 = fp.cray_native_type.m0; ex -= (unsigned int) 0x3c02; m3 &= (unsigned int) 0xf; m0 <<= 5; fp.ieee754_double_bigend.ex = ex; fp.ieee754_double_bigend.m3 = m3; fp.ieee754_double_bigend.m2 = m2; fp.ieee754_double_bigend.m1 = m1; fp.ieee754_double_bigend.m0 = m0; *(t + 0) = fp.c[7]; *(t + 1) = fp.c[6]; *(t + 2) = fp.c[5]; *(t + 3) = fp.c[4]; *(t + 4) = fp.c[3]; *(t + 5) = fp.c[2]; *(t + 6) = fp.c[1]; *(t + 7) = fp.c[0]; return; } if (vtffprtype == VTF3_CONST_FPNRT_IEEE754_DOUBLE_BIGEND) { ns = fp.ieee754_double_bigend.ns; ex = fp.ieee754_double_bigend.ex; m3 = fp.ieee754_double_bigend.m3; m2 = fp.ieee754_double_bigend.m2; m1 = fp.ieee754_double_bigend.m1; m0 = fp.ieee754_double_bigend.m0; if (ex == 0 && m3 == 0 && m2 == 0 && m1 == 0 && m0 == 0) { *(t + 0) = (unsigned char) 0x00; *(t + 1) = (unsigned char) 0x00; *(t + 2) = (unsigned char) 0x00; *(t + 3) = (unsigned char) 0x00; *(t + 4) = (unsigned char) 0x00; *(t + 5) = (unsigned char) 0x00; *(t + 6) = (unsigned char) 0x00; *(t + 7) = (unsigned char) 0x00; return; } if (ex < (unsigned int) 0x002) { fp.ieee754_double_bigend.ex = (unsigned int) 0x002; fp.ieee754_double_bigend.m3 = (unsigned int) 0x0; fp.ieee754_double_bigend.m2 = (unsigned int) 0x0000; fp.ieee754_double_bigend.m1 = (unsigned int) 0x0000; fp.ieee754_double_bigend.m0 = (unsigned int) 0x0000; } else if (ex > (unsigned int) 0x7fd) { fp.ieee754_double_bigend.ex = (unsigned int) 0x7fd; fp.ieee754_double_bigend.m3 = (unsigned int) 0xf; fp.ieee754_double_bigend.m2 = (unsigned int) 0xffff; fp.ieee754_double_bigend.m1 = (unsigned int) 0xffff; fp.ieee754_double_bigend.m0 = (unsigned int) 0xffff; } fp.ieee754_double_bigend.ns = 0; if (fp.f < 1.0e-300) fp.f = 1.0e-300; else if (fp.f > 1.0e+300) fp.f = 1.0e+300; fp.ieee754_double_bigend.ns = ns; *(t + 0) = fp.c[7]; *(t + 1) = fp.c[6]; *(t + 2) = fp.c[5]; *(t + 3) = fp.c[4]; *(t + 4) = fp.c[3]; *(t + 5) = fp.c[2]; *(t + 6) = fp.c[1]; *(t + 7) = fp.c[0]; return; } if (vtffprtype == VTF3_CONST_FPNRT_IEEE754_DOUBLE_LITEND) { ns = fp.ieee754_double_litend.ns; ex = fp.ieee754_double_litend.ex; m3 = fp.ieee754_double_litend.m3; m2 = fp.ieee754_double_litend.m2; m1 = fp.ieee754_double_litend.m1; m0 = fp.ieee754_double_litend.m0; if (ex == 0 && m3 == 0 && m2 == 0 && m1 == 0 && m0 == 0) { *(t + 0) = (unsigned char) 0x00; *(t + 1) = (unsigned char) 0x00; *(t + 2) = (unsigned char) 0x00; *(t + 3) = (unsigned char) 0x00; *(t + 4) = (unsigned char) 0x00; *(t + 5) = (unsigned char) 0x00; *(t + 6) = (unsigned char) 0x00; *(t + 7) = (unsigned char) 0x00; return; } if (ex < (unsigned int) 0x002) { fp.ieee754_double_litend.ex = (unsigned int) 0x002; fp.ieee754_double_litend.m3 = (unsigned int) 0x0; fp.ieee754_double_litend.m2 = (unsigned int) 0x0000; fp.ieee754_double_litend.m1 = (unsigned int) 0x0000; fp.ieee754_double_litend.m0 = (unsigned int) 0x0000; } else if (ex > (unsigned int) 0x7fd) { fp.ieee754_double_litend.ex = (unsigned int) 0x7fd; fp.ieee754_double_litend.m3 = (unsigned int) 0xf; fp.ieee754_double_litend.m2 = (unsigned int) 0xffff; fp.ieee754_double_litend.m1 = (unsigned int) 0xffff; fp.ieee754_double_litend.m0 = (unsigned int) 0xffff; } fp.ieee754_double_litend.ns = 0; if (fp.f < 1.0e-300) fp.f = 1.0e-300; else if (fp.f > 1.0e+300) fp.f = 1.0e+300; fp.ieee754_double_litend.ns = ns; *(t + 0) = fp.c[0]; *(t + 1) = fp.c[1]; *(t + 2) = fp.c[2]; *(t + 3) = fp.c[3]; *(t + 4) = fp.c[4]; *(t + 5) = fp.c[5]; *(t + 6) = fp.c[6]; *(t + 7) = fp.c[7]; return; } (void) fprintf (stderr, "VTF3: Unknown FP representation type\n"); (void) fflush (stderr); (void) exit (127); return; } static void StdBinaryWriteI2 (fcb_t *fcb, int i) { unsigned char *t; unsigned int u; if (fcb->recbufferpos + 2 > fcb->recbufferbeyond) (void) ReallocRecord (fcb, 2); t = (unsigned char *) fcb->recbufferpos; fcb->recbufferpos += 2; if (i > 0) { if (i > 32766) i = 32767; } else if (i + 32767 < 0) i = -32768; u = * (unsigned int *) &i; *(t + 0) = (unsigned char) (u >> 0 & (unsigned int) 0xff); *(t + 1) = (unsigned char) (u >> 8 & (unsigned int) 0xff); return; } /** * Write a string in binary format * caveat: currently strings should be written at the end of a record */ static void StdBinaryWriteSv (fcb_t *fcb, const char *s) { unsigned int strlenoffset, i, n, j0, j1, j2, j3, finaloffset, u; char *t, c, c00, c01, c02, c03, c04, c05, c06, c07, c10, c11, c12, c13, c20, c21, c30; const char *p; if (fcb->recbufferpos + 102 > fcb->recbufferbeyond) (void) ReallocRecord (fcb, 102); strlenoffset = (unsigned int) (fcb->recbufferpos - fcb->recbuffer); t = fcb->recbufferpos + 2; for (i = 0; i < 100; i++) { c = *(s + i); if (c == '\0') { fcb->recbufferpos = t + i; goto InsertStringLength; } else if (c == '\n') c = ' '; *(t + i) = c; } fcb->recbufferpos = t + 100; s += 100; p = s; n = (unsigned int) 0x7fff - (unsigned int) 100; while (*p != '\0' && n != 0) { p++; n--; } n = (unsigned int) (p - s); if (n == 0) goto InsertStringLength; if (fcb->recbufferpos + n > fcb->recbufferbeyond) (void) ReallocRecord (fcb, n); t = fcb->recbufferpos; fcb->recbufferpos += n; for (j0 = 0; j0 < n >> 3 << 3; j0 += 8) { c00 = *(s + j0 + 0); c01 = *(s + j0 + 1); c02 = *(s + j0 + 2); c03 = *(s + j0 + 3); c04 = *(s + j0 + 4); c05 = *(s + j0 + 5); c06 = *(s + j0 + 6); c07 = *(s + j0 + 7); *(t + j0 + 0) = c00 == '\n' ? ' ' : c00; *(t + j0 + 1) = c01 == '\n' ? ' ' : c01; *(t + j0 + 2) = c02 == '\n' ? ' ' : c02; *(t + j0 + 3) = c03 == '\n' ? ' ' : c03; *(t + j0 + 4) = c04 == '\n' ? ' ' : c04; *(t + j0 + 5) = c05 == '\n' ? ' ' : c05; *(t + j0 + 6) = c06 == '\n' ? ' ' : c06; *(t + j0 + 7) = c07 == '\n' ? ' ' : c07; } for (j1 = n >> 3 << 3; j1 < n >> 2 << 2; j1 += 4) { c10 = *(s + j1 + 0); c11 = *(s + j1 + 1); c12 = *(s + j1 + 2); c13 = *(s + j1 + 3); *(t + j1 + 0) = c10 == '\n' ? ' ' : c10; *(t + j1 + 1) = c11 == '\n' ? ' ' : c11; *(t + j1 + 2) = c12 == '\n' ? ' ' : c12; *(t + j1 + 3) = c13 == '\n' ? ' ' : c13; } for (j2 = n >> 2 << 2; j2 < n >> 1 << 1; j2 += 2) { c20 = *(s + j2 + 0); c21 = *(s + j2 + 1); *(t + j2 + 0) = c20 == '\n' ? ' ' : c20; *(t + j2 + 1) = c21 == '\n' ? ' ' : c21; } for (j3 = n >> 1 << 1; j3 < n >> 0 << 0; j3 += 1) { c30 = *(s + j3 + 0); *(t + j3 + 0) = c30 == '\n' ? ' ' : c30; } /* LABEL */ InsertStringLength: t = fcb->recbuffer + strlenoffset; finaloffset = (unsigned int) (fcb->recbufferpos - fcb->recbuffer); u = finaloffset - (strlenoffset + 2); *(t + 0) = (unsigned char) (u >> 0 & (unsigned int) 0xff); *(t + 1) = (unsigned char) (u >> 8 & (unsigned int) 0xff); return; } static void StdBinaryWriteTs (fcb_t *fcb, double f) { static unsigned int mfilters [212] = { 0x0, 0x0000, 0x0000, 0x0000, 0x8, 0x0000, 0x0000, 0x0000, 0xc, 0x0000, 0x0000, 0x0000, 0xe, 0x0000, 0x0000, 0x0000, 0xf, 0x0000, 0x0000, 0x0000, 0xf, 0x8000, 0x0000, 0x0000, 0xf, 0xc000, 0x0000, 0x0000, 0xf, 0xe000, 0x0000, 0x0000, 0xf, 0xf000, 0x0000, 0x0000, 0xf, 0xf800, 0x0000, 0x0000, 0xf, 0xfc00, 0x0000, 0x0000, 0xf, 0xfe00, 0x0000, 0x0000, 0xf, 0xff00, 0x0000, 0x0000, 0xf, 0xff80, 0x0000, 0x0000, 0xf, 0xffc0, 0x0000, 0x0000, 0xf, 0xffe0, 0x0000, 0x0000, 0xf, 0xfff0, 0x0000, 0x0000, 0xf, 0xfff8, 0x0000, 0x0000, 0xf, 0xfffc, 0x0000, 0x0000, 0xf, 0xfffe, 0x0000, 0x0000, 0xf, 0xffff, 0x0000, 0x0000, 0xf, 0xffff, 0x8000, 0x0000, 0xf, 0xffff, 0xc000, 0x0000, 0xf, 0xffff, 0xe000, 0x0000, 0xf, 0xffff, 0xf000, 0x0000, 0xf, 0xffff, 0xf800, 0x0000, 0xf, 0xffff, 0xfc00, 0x0000, 0xf, 0xffff, 0xfe00, 0x0000, 0xf, 0xffff, 0xff00, 0x0000, 0xf, 0xffff, 0xff80, 0x0000, 0xf, 0xffff, 0xffc0, 0x0000, 0xf, 0xffff, 0xffe0, 0x0000, 0xf, 0xffff, 0xfff0, 0x0000, 0xf, 0xffff, 0xfff8, 0x0000, 0xf, 0xffff, 0xfffc, 0x0000, 0xf, 0xffff, 0xfffe, 0x0000, 0xf, 0xffff, 0xffff, 0x0000, 0xf, 0xffff, 0xffff, 0x8000, 0xf, 0xffff, 0xffff, 0xc000, 0xf, 0xffff, 0xffff, 0xe000, 0xf, 0xffff, 0xffff, 0xf000, 0xf, 0xffff, 0xffff, 0xf800, 0xf, 0xffff, 0xffff, 0xfc00, 0xf, 0xffff, 0xffff, 0xfe00, 0xf, 0xffff, 0xffff, 0xff00, 0xf, 0xffff, 0xffff, 0xff80, 0xf, 0xffff, 0xffff, 0xffc0, 0xf, 0xffff, 0xffff, 0xffe0, 0xf, 0xffff, 0xffff, 0xfff0, 0xf, 0xffff, 0xffff, 0xfff8, 0xf, 0xffff, 0xffff, 0xfffc, 0xf, 0xffff, 0xffff, 0xfffe, 0xf, 0xffff, 0xffff, 0xffff }; unsigned char *t; union { unsigned char c [8]; double f; struct { unsigned int ns:1; unsigned int ex:15; unsigned int m3:5; unsigned int m2:16; unsigned int m1:16; unsigned int m0:11; } cray_native_type; struct { unsigned int ns:1; unsigned int ex:11; unsigned int m3:4; unsigned int m2:16; unsigned int m1:16; unsigned int m0:16; } ieee754_double_bigend; struct { unsigned int m0:16; unsigned int m1:16; unsigned int m2:16; unsigned int m3:4; unsigned int ex:11; unsigned int ns:1; } ieee754_double_litend; } fp; unsigned int ns, ex, m3, m2, m1, m0, mfiltergroup; if (fcb->recbufferpos + 8 > fcb->recbufferbeyond) (void) ReallocRecord (fcb, 8); t = (unsigned char *) fcb->recbufferpos; fcb->recbufferpos += 8; fp.f = f; if (vtffprtype == VTF3_CONST_FPNRT_CRAY_NATIVE_TYPE) { ns = fp.cray_native_type.ns; ex = fp.cray_native_type.ex; m3 = fp.cray_native_type.m3; m2 = fp.cray_native_type.m2; m1 = fp.cray_native_type.m1; m0 = fp.cray_native_type.m0; if (ns != 0 || (ex == 0 && m3 == 0 && m2 == 0 && m1 == 0 && m0 == 0)) { *(t + 0) = (unsigned char) 0x00; *(t + 1) = (unsigned char) 0x00; *(t + 2) = (unsigned char) 0x00; *(t + 3) = (unsigned char) 0x00; *(t + 4) = (unsigned char) 0x00; *(t + 5) = (unsigned char) 0x00; *(t + 6) = (unsigned char) 0x00; *(t + 7) = (unsigned char) 0x00; return; } if (ex < (unsigned int) 0x2003) { fp.cray_native_type.ex = (unsigned int) 0x2003; fp.cray_native_type.m3 = (unsigned int) 0x10; fp.cray_native_type.m2 = (unsigned int) 0x0000; fp.cray_native_type.m1 = (unsigned int) 0x0000; fp.cray_native_type.m0 = (unsigned int) 0x000; } else if (ex > (unsigned int) 0x5fff) { fp.cray_native_type.ex = (unsigned int) 0x5fff; fp.cray_native_type.m3 = (unsigned int) 0x10; fp.cray_native_type.m2 = (unsigned int) 0x0000; fp.cray_native_type.m1 = (unsigned int) 0x0000; fp.cray_native_type.m0 = (unsigned int) 0x000; } if (fp.f < 0.5e+0) fp.f = 0.0e+0; else if (fp.f > 1.0e+30) fp.f = 1.0e+30; fp.f += 0.5e+0; ex = fp.cray_native_type.ex; m3 = fp.cray_native_type.m3; m2 = fp.cray_native_type.m2; m1 = fp.cray_native_type.m1; m0 = fp.cray_native_type.m0; ex -= (unsigned int) 0x3c02; m3 &= (unsigned int) 0xf; m0 <<= 5; if (ex < (unsigned int) 0x3ff) mfiltergroup = 0; else mfiltergroup = ex - (unsigned int) 0x3ff; if (mfiltergroup > (unsigned int) (sizeof (mfilters) / (4 * sizeof (mfilters[0]))) - 1) mfiltergroup = (unsigned int) (sizeof (mfilters) / (4 * sizeof (mfilters[0]))) - 1; m3 &= mfilters[(mfiltergroup << 2) + 0]; m2 &= mfilters[(mfiltergroup << 2) + 1]; m1 &= mfilters[(mfiltergroup << 2) + 2]; m0 &= mfilters[(mfiltergroup << 2) + 3]; fp.ieee754_double_bigend.ex = ex; fp.ieee754_double_bigend.m3 = m3; fp.ieee754_double_bigend.m2 = m2; fp.ieee754_double_bigend.m1 = m1; fp.ieee754_double_bigend.m0 = m0; *(t + 0) = fp.c[7]; *(t + 1) = fp.c[6]; *(t + 2) = fp.c[5]; *(t + 3) = fp.c[4]; *(t + 4) = fp.c[3]; *(t + 5) = fp.c[2]; *(t + 6) = fp.c[1]; *(t + 7) = fp.c[0]; return; } if (vtffprtype == VTF3_CONST_FPNRT_IEEE754_DOUBLE_BIGEND) { ns = fp.ieee754_double_bigend.ns; ex = fp.ieee754_double_bigend.ex; m3 = fp.ieee754_double_bigend.m3; m2 = fp.ieee754_double_bigend.m2; m1 = fp.ieee754_double_bigend.m1; m0 = fp.ieee754_double_bigend.m0; if (ns != 0 || (ex == 0 && m3 == 0 && m2 == 0 && m1 == 0 && m0 == 0)) { *(t + 0) = (unsigned char) 0x00; *(t + 1) = (unsigned char) 0x00; *(t + 2) = (unsigned char) 0x00; *(t + 3) = (unsigned char) 0x00; *(t + 4) = (unsigned char) 0x00; *(t + 5) = (unsigned char) 0x00; *(t + 6) = (unsigned char) 0x00; *(t + 7) = (unsigned char) 0x00; return; } if (ex < (unsigned int) 0x002) { fp.ieee754_double_bigend.ex = (unsigned int) 0x002; fp.ieee754_double_bigend.m3 = (unsigned int) 0x0; fp.ieee754_double_bigend.m2 = (unsigned int) 0x0000; fp.ieee754_double_bigend.m1 = (unsigned int) 0x0000; fp.ieee754_double_bigend.m0 = (unsigned int) 0x0000; } else if (ex > (unsigned int) 0x7fd) { fp.ieee754_double_bigend.ex = (unsigned int) 0x7fd; fp.ieee754_double_bigend.m3 = (unsigned int) 0xf; fp.ieee754_double_bigend.m2 = (unsigned int) 0xffff; fp.ieee754_double_bigend.m1 = (unsigned int) 0xffff; fp.ieee754_double_bigend.m0 = (unsigned int) 0xffff; } if (fp.f < 0.5e+0) fp.f = 0.0e+0; else if (fp.f > 1.0e+30) fp.f = 1.0e+30; fp.f += 0.5e+0; ex = fp.ieee754_double_bigend.ex; m3 = fp.ieee754_double_bigend.m3; m2 = fp.ieee754_double_bigend.m2; m1 = fp.ieee754_double_bigend.m1; m0 = fp.ieee754_double_bigend.m0; if (ex < (unsigned int) 0x3ff) mfiltergroup = 0; else mfiltergroup = ex - (unsigned int) 0x3ff; if (mfiltergroup > (unsigned int) (sizeof (mfilters) / (4 * sizeof (mfilters[0]))) - 1) mfiltergroup = (unsigned int) (sizeof (mfilters) / (4 * sizeof (mfilters[0]))) - 1; m3 &= mfilters[(mfiltergroup << 2) + 0]; m2 &= mfilters[(mfiltergroup << 2) + 1]; m1 &= mfilters[(mfiltergroup << 2) + 2]; m0 &= mfilters[(mfiltergroup << 2) + 3]; fp.ieee754_double_bigend.m3 = m3; fp.ieee754_double_bigend.m2 = m2; fp.ieee754_double_bigend.m1 = m1; fp.ieee754_double_bigend.m0 = m0; *(t + 0) = fp.c[7]; *(t + 1) = fp.c[6]; *(t + 2) = fp.c[5]; *(t + 3) = fp.c[4]; *(t + 4) = fp.c[3]; *(t + 5) = fp.c[2]; *(t + 6) = fp.c[1]; *(t + 7) = fp.c[0]; return; } if (vtffprtype == VTF3_CONST_FPNRT_IEEE754_DOUBLE_LITEND) { ns = fp.ieee754_double_litend.ns; ex = fp.ieee754_double_litend.ex; m3 = fp.ieee754_double_litend.m3; m2 = fp.ieee754_double_litend.m2; m1 = fp.ieee754_double_litend.m1; m0 = fp.ieee754_double_litend.m0; if (ns != 0 || (ex == 0 && m3 == 0 && m2 == 0 && m1 == 0 && m0 == 0)) { *(t + 0) = (unsigned char) 0x00; *(t + 1) = (unsigned char) 0x00; *(t + 2) = (unsigned char) 0x00; *(t + 3) = (unsigned char) 0x00; *(t + 4) = (unsigned char) 0x00; *(t + 5) = (unsigned char) 0x00; *(t + 6) = (unsigned char) 0x00; *(t + 7) = (unsigned char) 0x00; return; } if (ex < (unsigned int) 0x002) { fp.ieee754_double_litend.ex = (unsigned int) 0x002; fp.ieee754_double_litend.m3 = (unsigned int) 0x0; fp.ieee754_double_litend.m2 = (unsigned int) 0x0000; fp.ieee754_double_litend.m1 = (unsigned int) 0x0000; fp.ieee754_double_litend.m0 = (unsigned int) 0x0000; } else if (ex > (unsigned int) 0x7fd) { fp.ieee754_double_litend.ex = (unsigned int) 0x7fd; fp.ieee754_double_litend.m3 = (unsigned int) 0xf; fp.ieee754_double_litend.m2 = (unsigned int) 0xffff; fp.ieee754_double_litend.m1 = (unsigned int) 0xffff; fp.ieee754_double_litend.m0 = (unsigned int) 0xffff; } if (fp.f < 0.5e+0) fp.f = 0.0e+0; else if (fp.f > 1.0e+30) fp.f = 1.0e+30; fp.f += 0.5e+0; ex = fp.ieee754_double_litend.ex; m3 = fp.ieee754_double_litend.m3; m2 = fp.ieee754_double_litend.m2; m1 = fp.ieee754_double_litend.m1; m0 = fp.ieee754_double_litend.m0; if (ex < (unsigned int) 0x3ff) mfiltergroup = 0; else mfiltergroup = ex - (unsigned int) 0x3ff; if (mfiltergroup > (unsigned int) (sizeof (mfilters) / (4 * sizeof (mfilters[0]))) - 1) mfiltergroup = (unsigned int) (sizeof (mfilters) / (4 * sizeof (mfilters[0]))) - 1; m3 &= mfilters[(mfiltergroup << 2) + 0]; m2 &= mfilters[(mfiltergroup << 2) + 1]; m1 &= mfilters[(mfiltergroup << 2) + 2]; m0 &= mfilters[(mfiltergroup << 2) + 3]; fp.ieee754_double_litend.m3 = m3; fp.ieee754_double_litend.m2 = m2; fp.ieee754_double_litend.m1 = m1; fp.ieee754_double_litend.m0 = m0; *(t + 0) = fp.c[0]; *(t + 1) = fp.c[1]; *(t + 2) = fp.c[2]; *(t + 3) = fp.c[3]; *(t + 4) = fp.c[4]; *(t + 5) = fp.c[5]; *(t + 6) = fp.c[6]; *(t + 7) = fp.c[7]; return; } (void) fprintf (stderr, "VTF3: Unknown FP representation type\n"); (void) fflush (stderr); (void) exit (127); return; } static void StoreDoubleOntoU4Vector (fcb_t *fcb, int index, double value) { size_t size; union { double f; unsigned char c [8]; } fp; if (fcb->u4vector == 0) { fcb->u4vectordim = index + 1 + 1 + 10; size = (size_t) fcb->u4vectordim * 4 * sizeof (unsigned char); fcb->u4vector = (unsigned char *) malloc (size); if (fcb->u4vector == 0) { VTF3_NOMEM_GOOD_BYE_INFO; (void) exit (127); } } if (index + 1 + 1 > fcb->u4vectordim) { fcb->u4vectordim = 2 * (index + 1 + 1); size = (size_t) fcb->u4vectordim * 4 * sizeof (unsigned char); fcb->u4vector = (unsigned char *) realloc (fcb->u4vector, size); if (fcb->u4vector == 0) { VTF3_NOMEM_GOOD_BYE_INFO; (void) exit (127); } } fp.f = value; *(fcb->u4vector + (index << 2) + 0) = fp.c[0]; *(fcb->u4vector + (index << 2) + 1) = fp.c[1]; *(fcb->u4vector + (index << 2) + 2) = fp.c[2]; *(fcb->u4vector + (index << 2) + 3) = fp.c[3]; *(fcb->u4vector + (index << 2) + 4) = fp.c[4]; *(fcb->u4vector + (index << 2) + 5) = fp.c[5]; *(fcb->u4vector + (index << 2) + 6) = fp.c[6]; *(fcb->u4vector + (index << 2) + 7) = fp.c[7]; return; } static void StoreOntoCharPtrVector (fcb_t *fcb, int index, const char *value) { size_t size; if (fcb->charptrvector == 0) { fcb->charptrvectordim = index + 1 + 10; size = (size_t) fcb->charptrvectordim * sizeof (char *); fcb->charptrvector = (char **) malloc (size); if (fcb->charptrvector == 0) { VTF3_NOMEM_GOOD_BYE_INFO; (void) exit (127); } } if (index + 1 > fcb->charptrvectordim) { fcb->charptrvectordim = 2 * (index + 1); size = (size_t) fcb->charptrvectordim * sizeof (char *); fcb->charptrvector = (char **) realloc (fcb->charptrvector, size); if (fcb->charptrvector == 0) { VTF3_NOMEM_GOOD_BYE_INFO; (void) exit (127); } } *(fcb->charptrvector + index) = (char *) (const char *) value; return; } static void SubstitudeUpFrom (fcb_t *fcb, unsigned int cpuid, int *exchangetype, int *statetoken) { stackhead_t *stackhead0, *stackhead; unsigned int j1, j2, j, i, k; int *stackedstatetoken; size_t size; if (fcb->substitudeupfrom == 0) return; if (exchangetype == 0 || statetoken == 0) goto UnrecoverableError; if (VTF3_IS_CPUGRP (cpuid) != 0) fcb->isawgroupexchanges = 1; if (*exchangetype == VTF3_EXCHANGETYPE_TO) { fcb->isawexchangetypeto = 1; return; } if (*exchangetype == VTF3_EXCHANGETYPE_UPFROM) { if (fcb->isawgroupexchanges != 0) goto PreventingGroupExchange; if (fcb->isawexchangetypeto != 0) goto PreventingToType; if (fcb->stackhead0 == 0) goto StackError; if (fcb->stackheaddim == 0) goto StackError; stackhead0 = fcb->stackhead0; j1 = 0; j2 = fcb->stackheaddim - 1; while (j1 != j2) { j = (j1 + j2) >> 1; if ((stackhead0 + j)->cpuid < cpuid) j1 = j + 1; else j2 = j; } j = j1; stackhead = stackhead0 + j; if (stackhead->cpuid != cpuid) goto StackError; if (stackhead->stackcurr == 0) goto StackError; stackedstatetoken = stackhead->stack0 + stackhead->stackcurr; if (*stackedstatetoken != *statetoken) goto StackError; stackhead->stackcurr--; stackedstatetoken--; *exchangetype = VTF3_EXCHANGETYPE_UPTO; *statetoken = *stackedstatetoken; fcb->didupfromsubstitution = 1; return; } if (fcb->isawgroupexchanges != 0) return; if (fcb->isawexchangetypeto != 0) return; if (*exchangetype == VTF3_EXCHANGETYPE_UPTO) { if (fcb->stackhead0 == 0) goto StackError; if (fcb->stackheaddim == 0) goto StackError; stackhead0 = fcb->stackhead0; j1 = 0; j2 = fcb->stackheaddim - 1; while (j1 != j2) { j = (j1 + j2) >> 1; if ((stackhead0 + j)->cpuid < cpuid) j1 = j + 1; else j2 = j; } j = j1; stackhead = stackhead0 + j; if (stackhead->cpuid != cpuid) goto StackError; if (stackhead->stackcurr == 0) goto StackError; stackhead->stackcurr--; stackedstatetoken = stackhead->stack0 + stackhead->stackcurr; if (*stackedstatetoken != *statetoken) goto StackError; return; } if (*exchangetype == VTF3_EXCHANGETYPE_DOWNTO) { if (fcb->stackhead0 == 0) { fcb->stackheaddimalloced = 100; size = (size_t) fcb->stackheaddimalloced * sizeof (stackhead_t); if ((fcb->stackhead0 = (stackhead_t *) malloc (size)) == 0) goto NoMoreMemory; fcb->stackheaddim = 1; stackhead0 = fcb->stackhead0; stackhead = stackhead0 + 0; stackhead->cpuid = cpuid; stackhead->stackcurr = 1; size = VTF3_CONST_MAX_STACK_DIM * sizeof (int); if ((stackhead->stack0 = (int *) malloc (size)) == 0) goto NoMoreMemory; *(stackhead->stack0 + 0) = VTF3_NOSTATE; *(stackhead->stack0 + 1) = *statetoken; return; } stackhead0 = fcb->stackhead0; j1 = 0; j2 = fcb->stackheaddim - 1; while (j1 != j2) { j = (j1 + j2) >> 1; if ((stackhead0 + j)->cpuid < cpuid) j1 = j + 1; else j2 = j; } j = j1; stackhead = stackhead0 + j; if (stackhead->cpuid == cpuid) { if (++stackhead->stackcurr < VTF3_CONST_MAX_STACK_DIM) { stackedstatetoken = stackhead->stack0 + stackhead->stackcurr; *stackedstatetoken = *statetoken; return; } goto StackOverflow; } if (fcb->stackheaddimalloced == fcb->stackheaddim) { fcb->stackheaddimalloced += 100; size = (size_t) fcb->stackheaddimalloced * sizeof (stackhead_t); fcb->stackhead0 = (stackhead_t *) realloc (fcb->stackhead0, size); if (fcb->stackhead0 == 0) goto NoMoreMemory; stackhead0 = fcb->stackhead0; stackhead = stackhead0 + j; } /* The j-th place is the one which will be made free. */ if (stackhead->cpuid < cpuid) { j++; stackhead = stackhead0 + j; } fcb->stackheaddim++; for (i = j + 1; i < fcb->stackheaddim; i++) { k = fcb->stackheaddim + j - i; (stackhead0 + k)->cpuid = (stackhead0 + k - 1)->cpuid; (stackhead0 + k)->stackcurr = (stackhead0 + k - 1)->stackcurr; (stackhead0 + k)->stack0 = (stackhead0 + k - 1)->stack0; } stackhead->cpuid = cpuid; stackhead->stackcurr = 1; size = VTF3_CONST_MAX_STACK_DIM * sizeof (int); if ((stackhead->stack0 = (int *) malloc (size)) == 0) goto NoMoreMemory; *(stackhead->stack0 + 0) = VTF3_NOSTATE; *(stackhead->stack0 + 1) = *statetoken; return; } /* LABEL */ UnrecoverableError: (void) fprintf (stderr, "VTF3: SubstitudeUpFrom(): " "Unrecoverable error\n"); (void) fflush (stderr); (void) exit (127); return; /* LABEL */ PreventingGroupExchange: if (fcb->didupfromsubstitution != 0) (void) fprintf (stderr, "VTF3: Group exchange prevents " "further UPFROM substitution\n"); else (void) fprintf (stderr, "VTF3: Group exchange prevents " "UPFROM substitution\n"); (void) fflush (stderr); fcb->substitudeupfrom = 0; return; /* LABEL */ PreventingToType: if (fcb->didupfromsubstitution != 0) (void) fprintf (stderr, "VTF3: Obsolete exchange type TO prevents " "further UPFROM substitution\n"); else (void) fprintf (stderr, "VTF3: Obsolete exchange type TO prevents " "UPFROM substitution\n"); (void) fflush (stderr); fcb->substitudeupfrom = 0; return; /* LABEL */ StackError: if (fcb->didupfromsubstitution != 0) (void) fprintf (stderr, "VTF3: Improper CPU %u CALL/RET stack " "prevents further UPFROM substitution\n", cpuid); else (void) fprintf (stderr, "VTF3: Improper CPU %u CALL/RET stack " "prevents UPFROM substitution\n", cpuid); (void) fflush (stderr); fcb->substitudeupfrom = 0; return; /* LABEL */ NoMoreMemory: VTF3_NOMEM_GOOD_BYE_INFO; (void) exit (127); return; /* LABEL */ StackOverflow: if (fcb->didupfromsubstitution != 0) (void) fprintf (stderr, "VTF3: CPU %u CALL/RET stack overflow " "prevents further UPFROM substitution\n", cpuid); else (void) fprintf (stderr, "VTF3: CPU %u CALL/RET stack overflow " "prevents UPFROM substitution\n", cpuid); (void) fflush (stderr); fcb->substitudeupfrom = 0; return; } static const char * TransHexToMem (fcb_t *fcb, const char *src, unsigned int n) { size_t size; const char *s; char *t; unsigned int j0, k00, k01, k02, k03, k04, k05, k06, k07, k08, k09, k0a, k0b, k0c, k0d, k0e, k0f, j1, k10, k11, k12, k13, k14, k15, k16, k17, j2, k20, k21, k22, k23, j3, k30, k31; if (fcb->charvector == 0) { fcb->charvectordim = n; size = (size_t) fcb->charvectordim * sizeof (char); fcb->charvector = (char *) malloc (size); if (fcb->charvector == 0) { VTF3_NOMEM_GOOD_BYE_INFO; (void) exit (127); } } if (n > fcb->charvectordim) { fcb->charvectordim = n; size = (size_t) fcb->charvectordim * sizeof (char); fcb->charvector = (char *) realloc (fcb->charvector, size); if (fcb->charvector == 0) { VTF3_NOMEM_GOOD_BYE_INFO; (void) exit (127); } } s = src; t = fcb->charvector; for (j0 = 0; j0 < n >> 3 << 3; j0 += 8) { k00 = vtfhexdig[VTF3_CHAR2INDEX (*(s + 2 * j0 + 0))]; k01 = vtfhexdig[VTF3_CHAR2INDEX (*(s + 2 * j0 + 1))]; k02 = vtfhexdig[VTF3_CHAR2INDEX (*(s + 2 * j0 + 2))]; k03 = vtfhexdig[VTF3_CHAR2INDEX (*(s + 2 * j0 + 3))]; k04 = vtfhexdig[VTF3_CHAR2INDEX (*(s + 2 * j0 + 4))]; k05 = vtfhexdig[VTF3_CHAR2INDEX (*(s + 2 * j0 + 5))]; k06 = vtfhexdig[VTF3_CHAR2INDEX (*(s + 2 * j0 + 6))]; k07 = vtfhexdig[VTF3_CHAR2INDEX (*(s + 2 * j0 + 7))]; k08 = vtfhexdig[VTF3_CHAR2INDEX (*(s + 2 * j0 + 8))]; k09 = vtfhexdig[VTF3_CHAR2INDEX (*(s + 2 * j0 + 9))]; k0a = vtfhexdig[VTF3_CHAR2INDEX (*(s + 2 * j0 + 10))]; k0b = vtfhexdig[VTF3_CHAR2INDEX (*(s + 2 * j0 + 11))]; k0c = vtfhexdig[VTF3_CHAR2INDEX (*(s + 2 * j0 + 12))]; k0d = vtfhexdig[VTF3_CHAR2INDEX (*(s + 2 * j0 + 13))]; k0e = vtfhexdig[VTF3_CHAR2INDEX (*(s + 2 * j0 + 14))]; k0f = vtfhexdig[VTF3_CHAR2INDEX (*(s + 2 * j0 + 15))]; *(t + j0 + 0) = (char) (unsigned char) ((k00 << 4) + (k01 << 0)); *(t + j0 + 1) = (char) (unsigned char) ((k02 << 4) + (k03 << 0)); *(t + j0 + 2) = (char) (unsigned char) ((k04 << 4) + (k05 << 0)); *(t + j0 + 3) = (char) (unsigned char) ((k06 << 4) + (k07 << 0)); *(t + j0 + 4) = (char) (unsigned char) ((k08 << 4) + (k09 << 0)); *(t + j0 + 5) = (char) (unsigned char) ((k0a << 4) + (k0b << 0)); *(t + j0 + 6) = (char) (unsigned char) ((k0c << 4) + (k0d << 0)); *(t + j0 + 7) = (char) (unsigned char) ((k0e << 4) + (k0f << 0)); if (k00 + k01 + k02 + k03 + k04 + k05 + k06 + k07 + k08 + k09 + k0a + k0b + k0c + k0d + k0e + k0f > 240) return (0); } for (j1 = n >> 3 << 3; j1 < n >> 2 << 2; j1 += 4) { k10 = vtfhexdig[VTF3_CHAR2INDEX (*(s + 2 * j1 + 0))]; k11 = vtfhexdig[VTF3_CHAR2INDEX (*(s + 2 * j1 + 1))]; k12 = vtfhexdig[VTF3_CHAR2INDEX (*(s + 2 * j1 + 2))]; k13 = vtfhexdig[VTF3_CHAR2INDEX (*(s + 2 * j1 + 3))]; k14 = vtfhexdig[VTF3_CHAR2INDEX (*(s + 2 * j1 + 4))]; k15 = vtfhexdig[VTF3_CHAR2INDEX (*(s + 2 * j1 + 5))]; k16 = vtfhexdig[VTF3_CHAR2INDEX (*(s + 2 * j1 + 6))]; k17 = vtfhexdig[VTF3_CHAR2INDEX (*(s + 2 * j1 + 7))]; *(t + j1 + 0) = (char) (unsigned char) ((k10 << 4) + (k11 << 0)); *(t + j1 + 1) = (char) (unsigned char) ((k12 << 4) + (k13 << 0)); *(t + j1 + 2) = (char) (unsigned char) ((k14 << 4) + (k15 << 0)); *(t + j1 + 3) = (char) (unsigned char) ((k16 << 4) + (k17 << 0)); if (k10 + k11 + k12 + k13 + k14 + k15 + k16 + k17 > 120) return (0); } for (j2 = n >> 2 << 2; j2 < n >> 1 << 1; j2 += 2) { k20 = vtfhexdig[VTF3_CHAR2INDEX (*(s + 2 * j2 + 0))]; k21 = vtfhexdig[VTF3_CHAR2INDEX (*(s + 2 * j2 + 1))]; k22 = vtfhexdig[VTF3_CHAR2INDEX (*(s + 2 * j2 + 2))]; k23 = vtfhexdig[VTF3_CHAR2INDEX (*(s + 2 * j2 + 3))]; *(t + j2 + 0) = (char) (unsigned char) ((k20 << 4) + (k21 << 0)); *(t + j2 + 1) = (char) (unsigned char) ((k22 << 4) + (k23 << 0)); if (k20 + k21 + k22 + k23 > 60) return (0); } for (j3 = n >> 1 << 1; j3 < n >> 0 << 0; j3 += 1) { k30 = vtfhexdig[VTF3_CHAR2INDEX (*(s + 2 * j3 + 0))]; k31 = vtfhexdig[VTF3_CHAR2INDEX (*(s + 2 * j3 + 1))]; *(t + j3 + 0) = (char) (unsigned char) ((k30 << 4) + (k31 << 0)); if (k30 + k31 > 30) return (0); } return (src + n + n); } static int TransMemToHexLower (fcb_t *fcb, const void *src, size_t size) { static char hex [16] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'}; unsigned int n, j0, k00, k01, k02, k03, k04, k05, k06, k07, j1, k10, k11, k12, k13, j2, k20, k21, j3, k30; const char *s; char *t; n = (unsigned int) size / (unsigned int) sizeof (char); if (fcb->charvector == 0) { fcb->charvectordim = n + n; size = (size_t) fcb->charvectordim * sizeof (char); fcb->charvector = (char *) malloc (size); if (fcb->charvector == 0) { VTF3_NOMEM_GOOD_BYE_INFO; (void) exit (127); } } if (n + n > fcb->charvectordim) { fcb->charvectordim = n + n; size = (size_t) fcb->charvectordim * sizeof (char); fcb->charvector = (char *) realloc (fcb->charvector, size); if (fcb->charvector == 0) { VTF3_NOMEM_GOOD_BYE_INFO; (void) exit (127); } } s = (const char *) src; t = fcb->charvector; for (j0 = 0; j0 < n >> 3 << 3; j0 += 8) { k00 = (unsigned int) (unsigned char) *(s + j0 + 0); k01 = (unsigned int) (unsigned char) *(s + j0 + 1); k02 = (unsigned int) (unsigned char) *(s + j0 + 2); k03 = (unsigned int) (unsigned char) *(s + j0 + 3); k04 = (unsigned int) (unsigned char) *(s + j0 + 4); k05 = (unsigned int) (unsigned char) *(s + j0 + 5); k06 = (unsigned int) (unsigned char) *(s + j0 + 6); k07 = (unsigned int) (unsigned char) *(s + j0 + 7); *(t + 2 * j0 + 0) = hex[k00 >> 4 & (unsigned int) 0xf]; *(t + 2 * j0 + 1) = hex[k00 >> 0 & (unsigned int) 0xf]; *(t + 2 * j0 + 2) = hex[k01 >> 4 & (unsigned int) 0xf]; *(t + 2 * j0 + 3) = hex[k01 >> 0 & (unsigned int) 0xf]; *(t + 2 * j0 + 4) = hex[k02 >> 4 & (unsigned int) 0xf]; *(t + 2 * j0 + 5) = hex[k02 >> 0 & (unsigned int) 0xf]; *(t + 2 * j0 + 6) = hex[k03 >> 4 & (unsigned int) 0xf]; *(t + 2 * j0 + 7) = hex[k03 >> 0 & (unsigned int) 0xf]; *(t + 2 * j0 + 8) = hex[k04 >> 4 & (unsigned int) 0xf]; *(t + 2 * j0 + 9) = hex[k04 >> 0 & (unsigned int) 0xf]; *(t + 2 * j0 + 10) = hex[k05 >> 4 & (unsigned int) 0xf]; *(t + 2 * j0 + 11) = hex[k05 >> 0 & (unsigned int) 0xf]; *(t + 2 * j0 + 12) = hex[k06 >> 4 & (unsigned int) 0xf]; *(t + 2 * j0 + 13) = hex[k06 >> 0 & (unsigned int) 0xf]; *(t + 2 * j0 + 14) = hex[k07 >> 4 & (unsigned int) 0xf]; *(t + 2 * j0 + 15) = hex[k07 >> 0 & (unsigned int) 0xf]; } for (j1 = n >> 3 << 3; j1 < n >> 2 << 2; j1 += 4) { k10 = (unsigned int) (unsigned char) *(s + j1 + 0); k11 = (unsigned int) (unsigned char) *(s + j1 + 1); k12 = (unsigned int) (unsigned char) *(s + j1 + 2); k13 = (unsigned int) (unsigned char) *(s + j1 + 3); *(t + 2 * j1 + 0) = hex[k10 >> 4 & (unsigned int) 0xf]; *(t + 2 * j1 + 1) = hex[k10 >> 0 & (unsigned int) 0xf]; *(t + 2 * j1 + 2) = hex[k11 >> 4 & (unsigned int) 0xf]; *(t + 2 * j1 + 3) = hex[k11 >> 0 & (unsigned int) 0xf]; *(t + 2 * j1 + 4) = hex[k12 >> 4 & (unsigned int) 0xf]; *(t + 2 * j1 + 5) = hex[k12 >> 0 & (unsigned int) 0xf]; *(t + 2 * j1 + 6) = hex[k13 >> 4 & (unsigned int) 0xf]; *(t + 2 * j1 + 7) = hex[k13 >> 0 & (unsigned int) 0xf]; } for (j2 = n >> 2 << 2; j2 < n >> 1 << 1; j2 += 2) { k20 = (unsigned int) (unsigned char) *(s + j2 + 0); k21 = (unsigned int) (unsigned char) *(s + j2 + 1); *(t + 2 * j2 + 0) = hex[k20 >> 4 & (unsigned int) 0xf]; *(t + 2 * j2 + 1) = hex[k20 >> 0 & (unsigned int) 0xf]; *(t + 2 * j2 + 2) = hex[k21 >> 4 & (unsigned int) 0xf]; *(t + 2 * j2 + 3) = hex[k21 >> 0 & (unsigned int) 0xf]; } for (j3 = n >> 1 << 1; j3 < n >> 0 << 0; j3 += 1) { k30 = (unsigned int) (unsigned char) *(s + j3 + 0); *(t + 2 * j3 + 0) = hex[k30 >> 4 & (unsigned int) 0xf]; *(t + 2 * j3 + 1) = hex[k30 >> 0 & (unsigned int) 0xf]; } return ((int) (n + n)); } static int TransMemToHexUpper (fcb_t *fcb, const void *src, size_t size) { static char hex [16] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'}; unsigned int n, j0, k00, k01, k02, k03, k04, k05, k06, k07, j1, k10, k11, k12, k13, j2, k20, k21, j3, k30; const char *s; char *t; n = (unsigned int) size / (unsigned int) sizeof (char); if (fcb->charvector == 0) { fcb->charvectordim = n + n; size = (size_t) fcb->charvectordim * sizeof (char); fcb->charvector = (char *) malloc (size); if (fcb->charvector == 0) { VTF3_NOMEM_GOOD_BYE_INFO; (void) exit (127); } } if (n + n > fcb->charvectordim) { fcb->charvectordim = n + n; size = (size_t) fcb->charvectordim * sizeof (char); fcb->charvector = (char *) realloc (fcb->charvector, size); if (fcb->charvector == 0) { VTF3_NOMEM_GOOD_BYE_INFO; (void) exit (127); } } s = (const char *) src; t = fcb->charvector; for (j0 = 0; j0 < n >> 3 << 3; j0 += 8) { k00 = (unsigned int) (unsigned char) *(s + j0 + 0); k01 = (unsigned int) (unsigned char) *(s + j0 + 1); k02 = (unsigned int) (unsigned char) *(s + j0 + 2); k03 = (unsigned int) (unsigned char) *(s + j0 + 3); k04 = (unsigned int) (unsigned char) *(s + j0 + 4); k05 = (unsigned int) (unsigned char) *(s + j0 + 5); k06 = (unsigned int) (unsigned char) *(s + j0 + 6); k07 = (unsigned int) (unsigned char) *(s + j0 + 7); *(t + 2 * j0 + 0) = hex[k00 >> 4 & (unsigned int) 0xf]; *(t + 2 * j0 + 1) = hex[k00 >> 0 & (unsigned int) 0xf]; *(t + 2 * j0 + 2) = hex[k01 >> 4 & (unsigned int) 0xf]; *(t + 2 * j0 + 3) = hex[k01 >> 0 & (unsigned int) 0xf]; *(t + 2 * j0 + 4) = hex[k02 >> 4 & (unsigned int) 0xf]; *(t + 2 * j0 + 5) = hex[k02 >> 0 & (unsigned int) 0xf]; *(t + 2 * j0 + 6) = hex[k03 >> 4 & (unsigned int) 0xf]; *(t + 2 * j0 + 7) = hex[k03 >> 0 & (unsigned int) 0xf]; *(t + 2 * j0 + 8) = hex[k04 >> 4 & (unsigned int) 0xf]; *(t + 2 * j0 + 9) = hex[k04 >> 0 & (unsigned int) 0xf]; *(t + 2 * j0 + 10) = hex[k05 >> 4 & (unsigned int) 0xf]; *(t + 2 * j0 + 11) = hex[k05 >> 0 & (unsigned int) 0xf]; *(t + 2 * j0 + 12) = hex[k06 >> 4 & (unsigned int) 0xf]; *(t + 2 * j0 + 13) = hex[k06 >> 0 & (unsigned int) 0xf]; *(t + 2 * j0 + 14) = hex[k07 >> 4 & (unsigned int) 0xf]; *(t + 2 * j0 + 15) = hex[k07 >> 0 & (unsigned int) 0xf]; } for (j1 = n >> 3 << 3; j1 < n >> 2 << 2; j1 += 4) { k10 = (unsigned int) (unsigned char) *(s + j1 + 0); k11 = (unsigned int) (unsigned char) *(s + j1 + 1); k12 = (unsigned int) (unsigned char) *(s + j1 + 2); k13 = (unsigned int) (unsigned char) *(s + j1 + 3); *(t + 2 * j1 + 0) = hex[k10 >> 4 & (unsigned int) 0xf]; *(t + 2 * j1 + 1) = hex[k10 >> 0 & (unsigned int) 0xf]; *(t + 2 * j1 + 2) = hex[k11 >> 4 & (unsigned int) 0xf]; *(t + 2 * j1 + 3) = hex[k11 >> 0 & (unsigned int) 0xf]; *(t + 2 * j1 + 4) = hex[k12 >> 4 & (unsigned int) 0xf]; *(t + 2 * j1 + 5) = hex[k12 >> 0 & (unsigned int) 0xf]; *(t + 2 * j1 + 6) = hex[k13 >> 4 & (unsigned int) 0xf]; *(t + 2 * j1 + 7) = hex[k13 >> 0 & (unsigned int) 0xf]; } for (j2 = n >> 2 << 2; j2 < n >> 1 << 1; j2 += 2) { k20 = (unsigned int) (unsigned char) *(s + j2 + 0); k21 = (unsigned int) (unsigned char) *(s + j2 + 1); *(t + 2 * j2 + 0) = hex[k20 >> 4 & (unsigned int) 0xf]; *(t + 2 * j2 + 1) = hex[k20 >> 0 & (unsigned int) 0xf]; *(t + 2 * j2 + 2) = hex[k21 >> 4 & (unsigned int) 0xf]; *(t + 2 * j2 + 3) = hex[k21 >> 0 & (unsigned int) 0xf]; } for (j3 = n >> 1 << 1; j3 < n >> 0 << 0; j3 += 1) { k30 = (unsigned int) (unsigned char) *(s + j3 + 0); *(t + 2 * j3 + 0) = hex[k30 >> 4 & (unsigned int) 0xf]; *(t + 2 * j3 + 1) = hex[k30 >> 0 & (unsigned int) 0xf]; } return ((int) (n + n)); } static void WriteRecord (fcb_t *fcb) { char *newlinepos, *recbufferpos, *recbufferbeyond, *pt, *pf; size_t nrb, nio, ncp; unsigned int n, j0, j1, j2, j3; if (fcb->pfile == 0) { (void) fprintf (stderr, "VTF3: WriteRecord(): " "FCB isn't for file processing\n"); (void) fflush (stderr); (void) exit (127); } if (fcb->rcb.numchars < 1) { (void) fprintf (stderr, "VTF3: WriteRecord(): " "Unrecoverable error\n"); (void) fflush (stderr); (void) exit (127); } newlinepos = 0; if (fcb->fileformat == VTF3_FILEFORMAT_STD_ASCII || fcb->fileformat == VTF3_FILEFORMAT_FST_ASCII) newlinepos = fcb->recbuffer + fcb->rcb.numchars - 1; if (newlinepos != 0) *newlinepos = '\n'; recbufferpos = fcb->recbuffer; recbufferbeyond = fcb->recbuffer + fcb->rcb.numchars; while (recbufferpos < recbufferbeyond) { nrb = (size_t) ( recbufferbeyond - recbufferpos); nio = (size_t) (fcb->iobufferbeyond - fcb->iobufferpos); ncp = nrb < nio ? nrb : nio; if (ncp == 0) { (void) FlushIoBuffer (fcb); continue; } pt = fcb->iobufferpos; pf = recbufferpos; if (ncp < 100) { n = (unsigned int) ncp; for (j0 = 0; j0 < n >> 3 << 3; j0 += 8) { *(pt + j0 + 0) = *(pf + j0 + 0); *(pt + j0 + 1) = *(pf + j0 + 1); *(pt + j0 + 2) = *(pf + j0 + 2); *(pt + j0 + 3) = *(pf + j0 + 3); *(pt + j0 + 4) = *(pf + j0 + 4); *(pt + j0 + 5) = *(pf + j0 + 5); *(pt + j0 + 6) = *(pf + j0 + 6); *(pt + j0 + 7) = *(pf + j0 + 7); } for (j1 = n >> 3 << 3; j1 < n >> 2 << 2; j1 += 4) { *(pt + j1 + 0) = *(pf + j1 + 0); *(pt + j1 + 1) = *(pf + j1 + 1); *(pt + j1 + 2) = *(pf + j1 + 2); *(pt + j1 + 3) = *(pf + j1 + 3); } for (j2 = n >> 2 << 2; j2 < n >> 1 << 1; j2 += 2) { *(pt + j2 + 0) = *(pf + j2 + 0); *(pt + j2 + 1) = *(pf + j2 + 1); } for (j3 = n >> 1 << 1; j3 < n >> 0 << 0; j3 += 1) { *(pt + j3 + 0) = *(pf + j3 + 0); } } else (void) memcpy (pt, pf, ncp * sizeof (char)); fcb->iobufferpos += ncp; recbufferpos += ncp; } if (newlinepos != 0) *newlinepos = '\0'; return; } /*****************************************************************************/ int VTF3_WriteClstrregval (void *fcb, double time, int clstrtoken, int clstrregarraydim, const int *clstrregtokenarray, const int *clstrregvaluetypearray, const void *clstrregvaluearray) { VTF3_rec_t *rec; int numchars; rec = VTF3_ComposeClstrregval (fcb, time, clstrtoken, clstrregarraydim, clstrregtokenarray, clstrregvaluetypearray, clstrregvaluearray); numchars = rec->numchars; (void) WriteRecord ((fcb_t *) fcb); return (numchars); } int VTF3_WriteComment (void *fcb, double time, const char *comment) { VTF3_rec_t *rec; int numchars; rec = VTF3_ComposeComment (fcb, time, comment); numchars = rec->numchars; (void) WriteRecord ((fcb_t *) fcb); return (numchars); } int VTF3_WriteCpuregval (void *fcb, double time, unsigned int cpuid, int cpuregarraydim, const int *cpuregtokenarray, const int *cpuregvaluetypearray, const void *cpuregvaluearray) { VTF3_rec_t *rec; int numchars; rec = VTF3_ComposeCpuregval (fcb, time, cpuid, cpuregarraydim, cpuregtokenarray, cpuregvaluetypearray, cpuregvaluearray); numchars = rec->numchars; (void) WriteRecord ((fcb_t *) fcb); return (numchars); } int VTF3_WriteDefact (void *fcb, int activitytoken, const char *activityname) { VTF3_rec_t *rec; int numchars; rec = VTF3_ComposeDefact (fcb, activitytoken, activityname); numchars = rec->numchars; (void) WriteRecord ((fcb_t *) fcb); return (numchars); } int VTF3_WriteDefact_obsol (void *fcb, int activitytoken, const char *activityname) { VTF3_rec_t *rec; int numchars; rec = VTF3_ComposeDefact_obsol (fcb, activitytoken, activityname); numchars = rec->numchars; (void) WriteRecord ((fcb_t *) fcb); return (numchars); } int VTF3_WriteDefclkperiod (void *fcb, double clkperiod) { VTF3_rec_t *rec; int numchars; rec = VTF3_ComposeDefclkperiod (fcb, clkperiod); numchars = rec->numchars; (void) WriteRecord ((fcb_t *) fcb); return (numchars); } int VTF3_WriteDefclstr (void *fcb, int clstrtoken, const char *clstrname, int cpuidarraydim, const unsigned int *cpuidarray) { VTF3_rec_t *rec; int numchars; rec = VTF3_ComposeDefclstr (fcb, clstrtoken, clstrname, cpuidarraydim, cpuidarray); numchars = rec->numchars; (void) WriteRecord ((fcb_t *) fcb); return (numchars); } int VTF3_WriteDefclstrreg (void *fcb, int clstrregtoken, int clstrregclasstoken, int valuetype, const void *valuebounds, const char *clstrregname, const char *clstrregunit) { VTF3_rec_t *rec; int numchars; rec = VTF3_ComposeDefclstrreg (fcb, clstrregtoken, clstrregclasstoken, valuetype, valuebounds, clstrregname, clstrregunit); numchars = rec->numchars; (void) WriteRecord ((fcb_t *) fcb); return (numchars); } int VTF3_WriteDefclstrregclass (void *fcb, int clstrregclasstoken, const char *clstrregclassname) { VTF3_rec_t *rec; int numchars; rec = VTF3_ComposeDefclstrregclass (fcb, clstrregclasstoken, clstrregclassname); numchars = rec->numchars; (void) WriteRecord ((fcb_t *) fcb); return (numchars); } int VTF3_WriteDefcommunicator (void *fcb, int communicator, int communicatorsize, int tripletarraydim, const unsigned int *tripletarray) { VTF3_rec_t *rec; int numchars; rec = VTF3_ComposeDefcommunicator (fcb, communicator, communicatorsize, tripletarraydim, tripletarray); numchars = rec->numchars; (void) WriteRecord ((fcb_t *) fcb); return (numchars); } int VTF3_WriteDefcpugrp (void *fcb, unsigned int cpugrpid, int cpuorcpugrpidarraydim, const unsigned int *cpuorcpugrpidarray, const char *cpugrpname) { VTF3_rec_t *rec; int numchars; rec = VTF3_ComposeDefcpugrp (fcb, cpugrpid, cpuorcpugrpidarraydim, cpuorcpugrpidarray, cpugrpname); numchars = rec->numchars; (void) WriteRecord ((fcb_t *) fcb); return (numchars); } int VTF3_WriteDefcpuname (void *fcb, unsigned int cpuid, const char *cpuname) { VTF3_rec_t *rec; int numchars; rec = VTF3_ComposeDefcpuname (fcb, cpuid, cpuname); numchars = rec->numchars; (void) WriteRecord ((fcb_t *) fcb); return (numchars); } int VTF3_WriteDefcpureg (void *fcb, int cpuregtoken, int cpuregclasstoken, int valuetype, const void *valuebounds, const char *cpuregname, const char *cpuregunit) { VTF3_rec_t *rec; int numchars; rec = VTF3_ComposeDefcpureg (fcb, cpuregtoken, cpuregclasstoken, valuetype, valuebounds, cpuregname, cpuregunit); numchars = rec->numchars; (void) WriteRecord ((fcb_t *) fcb); return (numchars); } int VTF3_WriteDefcpuregclass (void *fcb, int cpuregclasstoken, const char *cpuregclassname) { VTF3_rec_t *rec; int numchars; rec = VTF3_ComposeDefcpuregclass (fcb, cpuregclasstoken, cpuregclassname); numchars = rec->numchars; (void) WriteRecord ((fcb_t *) fcb); return (numchars); } int VTF3_WriteDefcreator (void *fcb, const char *creator) { VTF3_rec_t *rec; int numchars; rec = VTF3_ComposeDefcreator (fcb, creator); numchars = rec->numchars; (void) WriteRecord ((fcb_t *) fcb); return (numchars); } int VTF3_WriteDefdatastruc (void *fcb, int datastructoken, const char *datastrucname, int scltoken) { VTF3_rec_t *rec; int numchars; rec = VTF3_ComposeDefdatastruc (fcb, datastructoken, datastrucname, scltoken); numchars = rec->numchars; (void) WriteRecord ((fcb_t *) fcb); return (numchars); } int VTF3_WriteDefglobalop (void *fcb, int globaloptoken, const char *globalopname) { VTF3_rec_t *rec; int numchars; rec = VTF3_ComposeDefglobalop (fcb, globaloptoken, globalopname); numchars = rec->numchars; (void) WriteRecord ((fcb_t *) fcb); return (numchars); } int VTF3_WriteDefhist ( void *fcb, int histtoken, int nrelements, int histgrp, const char *histname ) { VTF3_rec_t *rec; int numchars; rec = VTF3_ComposeDefhist (fcb, histtoken, nrelements, histgrp, histname ); numchars = rec->numchars; (void) WriteRecord ((fcb_t *) fcb); return (numchars); } int VTF3_WriteDefhistgrp (void *fcb, int histgrptoken, const char *histgrpname) { VTF3_rec_t *rec; int numchars; rec = VTF3_ComposeDefhistgrp (fcb, histgrptoken, histgrpname); numchars = rec->numchars; (void) WriteRecord ((fcb_t *) fcb); return (numchars); } int VTF3_WriteDefiofile (void *fcb, int iofiletoken, int communicator, const char *iofilename) { VTF3_rec_t *rec; int numchars; rec = VTF3_ComposeDefiofile (fcb, iofiletoken, communicator, iofilename); numchars = rec->numchars; (void) WriteRecord ((fcb_t *) fcb); return (numchars); } int VTF3_WriteDefkparreg (void *fcb, int kparregtoken, const char *kparregname) { VTF3_rec_t *rec; int numchars; rec = VTF3_ComposeDefkparreg (fcb, kparregtoken, kparregname); numchars = rec->numchars; (void) WriteRecord ((fcb_t *) fcb); return (numchars); } int VTF3_WriteDefmsgname (void *fcb, int msgtype, int communicator, const char *msgname) { VTF3_rec_t *rec; int numchars; rec = VTF3_ComposeDefmsgname (fcb, msgtype, communicator, msgname); numchars = rec->numchars; (void) WriteRecord ((fcb_t *) fcb); return (numchars); } int VTF3_WriteDefopenmpname (void *fcb, unsigned int nametoken, const char *openmpname) { VTF3_rec_t *rec; int numchars; rec = VTF3_ComposeDefopenmpname (fcb, nametoken, openmpname); numchars = rec->numchars; (void) WriteRecord ((fcb_t *) fcb); return (numchars); } int VTF3_WriteDefopenmptype (void *fcb, unsigned int constructtypetoken, const char *constructtypename) { VTF3_rec_t *rec; int numchars; rec = VTF3_ComposeDefopenmptype (fcb, constructtypetoken, constructtypename); numchars = rec->numchars; (void) WriteRecord ((fcb_t *) fcb); return (numchars); } int VTF3_WriteDefpattern (void *fcb, int activitytoken, int pattoken, int patshptoken, double radius, int ratio, int timesteparraydim, const double *timesteparray) { VTF3_rec_t *rec; int numchars; rec = VTF3_ComposeDefpattern (fcb, activitytoken, pattoken, patshptoken, radius, ratio, timesteparraydim, timesteparray); numchars = rec->numchars; (void) WriteRecord ((fcb_t *) fcb); return (numchars); } int VTF3_WriteDefpatternshape (void *fcb, int activitytoken, int patshptoken, int patterntype, int patshptokenbref1, int patshptokenbref2) { VTF3_rec_t *rec; int numchars; rec = VTF3_ComposeDefpatternshape (fcb, activitytoken, patshptoken, patterntype, patshptokenbref1, patshptokenbref2); numchars = rec->numchars; (void) WriteRecord ((fcb_t *) fcb); return (numchars); } int VTF3_WriteDefredfunc_obsol (void *fcb, int redfunctoken, const char *redfuncname) { VTF3_rec_t *rec; int numchars; rec = VTF3_ComposeDefredfunc_obsol (fcb, redfunctoken, redfuncname); numchars = rec->numchars; (void) WriteRecord ((fcb_t *) fcb); return (numchars); } int VTF3_WriteDefsamp (void *fcb, int sampletoken, int sampleclasstoken, int iscpugrpsamp, unsigned int cpuorcpugrpid, int valuetype, const void *valuebounds, int dodifferentiation, int datarephint, const char *samplename, const char *sampleunit) { VTF3_rec_t *rec; int numchars; rec = VTF3_ComposeDefsamp (fcb, sampletoken, sampleclasstoken, iscpugrpsamp, cpuorcpugrpid, valuetype, valuebounds, dodifferentiation, datarephint, samplename, sampleunit); numchars = rec->numchars; (void) WriteRecord ((fcb_t *) fcb); return (numchars); } int VTF3_WriteDefsampclass (void *fcb, int sampleclasstoken, const char *sampleclassname) { VTF3_rec_t *rec; int numchars; rec = VTF3_ComposeDefsampclass (fcb, sampleclasstoken, sampleclassname); numchars = rec->numchars; (void) WriteRecord ((fcb_t *) fcb); return (numchars); } int VTF3_WriteDefscl (void *fcb, int scltoken, int sclarraydim, const int *sclfiletokenarray, const int *scllinepositionarray) { VTF3_rec_t *rec; int numchars; rec = VTF3_ComposeDefscl (fcb, scltoken, sclarraydim, sclfiletokenarray, scllinepositionarray); numchars = rec->numchars; (void) WriteRecord ((fcb_t *) fcb); return (numchars); } int VTF3_WriteDefsclfile (void *fcb, int sclfiletoken, const char *sclfilename) { VTF3_rec_t *rec; int numchars; rec = VTF3_ComposeDefsclfile (fcb, sclfiletoken, sclfilename); numchars = rec->numchars; (void) WriteRecord ((fcb_t *) fcb); return (numchars); } int VTF3_WriteDefstate (void *fcb, int activitytoken, int statetoken, const char *statename, int scltoken) { VTF3_rec_t *rec; int numchars; rec = VTF3_ComposeDefstate (fcb, activitytoken, statetoken, statename, scltoken); numchars = rec->numchars; (void) WriteRecord ((fcb_t *) fcb); return (numchars); } int VTF3_WriteDefstate_obsol (void *fcb, int activitytoken, const char *activityname, unsigned int activityvalidity, int statetoken, const char *statename) { VTF3_rec_t *rec; int numchars; rec = VTF3_ComposeDefstate_obsol (fcb, activitytoken, activityname, activityvalidity, statetoken, statename); numchars = rec->numchars; (void) WriteRecord ((fcb_t *) fcb); return (numchars); } int VTF3_WriteDefsyscpunames (void *fcb, int systemcpunamearraydim, char * const *systemcpunamearray) { VTF3_rec_t *rec; int numchars; rec = VTF3_ComposeDefsyscpunames (fcb, systemcpunamearraydim, systemcpunamearray); numchars = rec->numchars; (void) WriteRecord ((fcb_t *) fcb); return (numchars); } int VTF3_WriteDefsyscpunums (void *fcb, int systemcpunumberarraydim, const int *systemcpunumberarray) { VTF3_rec_t *rec; int numchars; rec = VTF3_ComposeDefsyscpunums (fcb, systemcpunumberarraydim, systemcpunumberarray); numchars = rec->numchars; (void) WriteRecord ((fcb_t *) fcb); return (numchars); } int VTF3_WriteDefthreadnums (void *fcb, int threadnumarraydim, const int *threadnumarray) { VTF3_rec_t *rec; int numchars; rec = VTF3_ComposeDefthreadnums (fcb, threadnumarraydim, threadnumarray); numchars = rec->numchars; (void) WriteRecord ((fcb_t *) fcb); return (numchars); } int VTF3_WriteDeftimeoffset (void *fcb, double timeoffset) { VTF3_rec_t *rec; int numchars; rec = VTF3_ComposeDeftimeoffset (fcb, timeoffset); numchars = rec->numchars; (void) WriteRecord ((fcb_t *) fcb); return (numchars); } int VTF3_WriteDefunmerged (void *fcb) { VTF3_rec_t *rec; int numchars; rec = VTF3_ComposeDefunmerged (fcb); numchars = rec->numchars; (void) WriteRecord ((fcb_t *) fcb); return (numchars); } int VTF3_WriteDefversion (void *fcb, int versionnumber) { VTF3_rec_t *rec; int numchars; rec = VTF3_ComposeDefversion (fcb, versionnumber); numchars = rec->numchars; (void) WriteRecord ((fcb_t *) fcb); return (numchars); } int VTF3_WriteDownto (void *fcb, double time, int statetoken, unsigned int cpuid, int scltoken) { VTF3_rec_t *rec; int numchars; rec = VTF3_ComposeDownto (fcb, time, statetoken, cpuid, scltoken); numchars = rec->numchars; (void) WriteRecord ((fcb_t *) fcb); return (numchars); } int VTF3_WriteExchange (void *fcb, double time, unsigned int cpuid, int exchangetype, int statetoken, int job, int scltoken) { VTF3_rec_t *rec; int numchars; rec = VTF3_ComposeExchange (fcb, time, cpuid, exchangetype, statetoken, job, scltoken); numchars = rec->numchars; (void) WriteRecord ((fcb_t *) fcb); return (numchars); } int VTF3_WriteExchange_obsol (void *fcb, double time, unsigned int cpuid, int exchangetype, int statetoken, int activitytoken, const char *activityname, unsigned int activityvalidity, int job) { VTF3_rec_t *rec; int numchars; rec = VTF3_ComposeExchange_obsol (fcb, time, cpuid, exchangetype, statetoken, activitytoken, activityname, activityvalidity, job); numchars = rec->numchars; (void) WriteRecord ((fcb_t *) fcb); return (numchars); } int VTF3_WriteFileiobegin (void *fcb, double time, unsigned int cpuid, int fileiotype, int iofiletoken, int bytescopied, int scltoken) { VTF3_rec_t *rec; int numchars; rec = VTF3_ComposeFileiobegin (fcb, time, cpuid, fileiotype, iofiletoken, bytescopied, scltoken); numchars = rec->numchars; (void) WriteRecord ((fcb_t *) fcb); return (numchars); } int VTF3_WriteFileioend (void *fcb, double time, unsigned int cpuid, int fileiotype, int iofiletoken, int bytescopied, int scltoken) { VTF3_rec_t *rec; int numchars; rec = VTF3_ComposeFileioend (fcb, time, cpuid, fileiotype, iofiletoken, bytescopied, scltoken); numchars = rec->numchars; (void) WriteRecord ((fcb_t *) fcb); return (numchars); } int VTF3_WriteGlobalop (void *fcb, double time, int globaloptoken, unsigned int cpuid, int communicator, unsigned int rootcpuid, int bytessent, int bytesreceived, double durationtimesteps, int scltoken) { VTF3_rec_t *rec; int numchars; rec = VTF3_ComposeGlobalop (fcb, time, globaloptoken, cpuid, communicator, rootcpuid, bytessent, bytesreceived, durationtimesteps, scltoken); numchars = rec->numchars; (void) WriteRecord ((fcb_t *) fcb); return (numchars); } int VTF3_WriteHist (void *fcb, double time, int histtoken, double starttime, unsigned int cpuid, int valuearraydim, int* numdatastrucperbin, const int* datastrucarray, const void *values) { VTF3_rec_t *rec; int numchars; rec = VTF3_ComposeHist (fcb, time, histtoken, starttime, cpuid, valuearraydim, numdatastrucperbin, datastrucarray, values); numchars = rec->numchars; (void) WriteRecord ((fcb_t *) fcb); return (numchars); } int VTF3_WriteKparregbarsum (void *fcb, double time, unsigned int cpuid, int kparregtoken, int seqn, int opasize, const void *opastream, int scltoken) { VTF3_rec_t *rec; int numchars; rec = VTF3_ComposeKparregbarsum (fcb, time, cpuid, kparregtoken, seqn, opasize, opastream, scltoken); numchars = rec->numchars; (void) WriteRecord ((fcb_t *) fcb); return (numchars); } int VTF3_WriteKparregbegin (void *fcb, double time, unsigned int cpuid, int kparregtoken, int seqn, int numthreads, int scltoken) { VTF3_rec_t *rec; int numchars; rec = VTF3_ComposeKparregbegin (fcb, time, cpuid, kparregtoken, seqn, numthreads, scltoken); numchars = rec->numchars; (void) WriteRecord ((fcb_t *) fcb); return (numchars); } int VTF3_WriteKparregend (void *fcb, double time, unsigned int cpuid, int kparregtoken, int seqn, int opasize, const void *opastream, int scltoken) { VTF3_rec_t *rec; int numchars; rec = VTF3_ComposeKparregend (fcb, time, cpuid, kparregtoken, seqn, opasize, opastream, scltoken); numchars = rec->numchars; (void) WriteRecord ((fcb_t *) fcb); return (numchars); } int VTF3_WriteMutexacquire (void *fcb, double time, unsigned int cpuid, int enterstatetoken, int leavestatetoken, int leavestatetokenisupfrom, double durationtimesteps, int mutexsize, const void *mutex, int scltoken) { VTF3_rec_t *rec; int numchars; rec = VTF3_ComposeMutexacquire (fcb, time, cpuid, enterstatetoken, leavestatetoken, leavestatetokenisupfrom, durationtimesteps, mutexsize, mutex, scltoken); numchars = rec->numchars; (void) WriteRecord ((fcb_t *) fcb); return (numchars); } int VTF3_WriteMutexrelease (void *fcb, double time, unsigned int cpuid, int enterstatetoken, int leavestatetoken, int leavestatetokenisupfrom, double durationtimesteps, int mutexsize, const void *mutex, int scltoken) { VTF3_rec_t *rec; int numchars; rec = VTF3_ComposeMutexrelease (fcb, time, cpuid, enterstatetoken, leavestatetoken, leavestatetokenisupfrom, durationtimesteps, mutexsize, mutex, scltoken); numchars = rec->numchars; (void) WriteRecord ((fcb_t *) fcb); return (numchars); } int VTF3_WriteOpenmpenter (void *fcb, double time, unsigned int cpuid, unsigned int constructtypetoken, unsigned int nametoken, int scltoken) { VTF3_rec_t *rec; int numchars; rec = VTF3_ComposeOpenmpenter (fcb, time, cpuid, constructtypetoken, nametoken, scltoken); numchars = rec->numchars; (void) WriteRecord ((fcb_t *) fcb); return (numchars); } int VTF3_WriteOpenmpleave (void *fcb, double time, unsigned int cpuid, int scltoken) { VTF3_rec_t *rec; int numchars; rec = VTF3_ComposeOpenmpleave (fcb, time, cpuid, scltoken); numchars = rec->numchars; (void) WriteRecord ((fcb_t *) fcb); return (numchars); } int VTF3_WriteParreg (void *fcb, double time, unsigned int cpugrpid, unsigned int nametoken, int sclstarttoken, int sclendtoken, int timearraydim, const double *timeoffsetanddurationarray) { VTF3_rec_t *rec; int numchars; rec = VTF3_ComposeParreg (fcb, time, cpugrpid, nametoken, sclstarttoken, sclendtoken, timearraydim, timeoffsetanddurationarray); numchars = rec->numchars; (void) WriteRecord ((fcb_t *) fcb); return (numchars); } int VTF3_WritePattern (void *fcb, double time, unsigned int cpuid, int patorpatshptoken, double durationtimesteps, int timesteparraydim, const double *timesteparray, const int *patchindexarray) { VTF3_rec_t *rec; int numchars; rec = VTF3_ComposePattern (fcb, time, cpuid, patorpatshptoken, durationtimesteps, timesteparraydim, timesteparray, patchindexarray); numchars = rec->numchars; (void) WriteRecord ((fcb_t *) fcb); return (numchars); } int VTF3_WriteRecvmsg (void *fcb, double time, unsigned int receiver, unsigned int sender, int communicator, int msgtype, int msglength, int scltoken) { VTF3_rec_t *rec; int numchars; rec = VTF3_ComposeRecvmsg (fcb, time, receiver, sender, communicator, msgtype, msglength, scltoken); numchars = rec->numchars; (void) WriteRecord ((fcb_t *) fcb); return (numchars); } int VTF3_WriteSamp (void *fcb, double time, unsigned int cpuorcpugrpid, int samplearraydim, const int *sampletokenarray, const int *samplevaluetypearray, const void *samplevaluearray) { VTF3_rec_t *rec; int numchars; rec = VTF3_ComposeSamp (fcb, time, cpuorcpugrpid, samplearraydim, sampletokenarray, samplevaluetypearray, samplevaluearray); numchars = rec->numchars; (void) WriteRecord ((fcb_t *) fcb); return (numchars); } int VTF3_WriteSendmsg (void *fcb, double time, unsigned int sender, unsigned int receiver, int communicator, int msgtype, int msglength, int scltoken) { VTF3_rec_t *rec; int numchars; rec = VTF3_ComposeSendmsg (fcb, time, sender, receiver, communicator, msgtype, msglength, scltoken); numchars = rec->numchars; (void) WriteRecord ((fcb_t *) fcb); return (numchars); } int VTF3_WriteSrcinfo_obsol (void *fcb, double time, int activitytoken, int statetoken, int scllineposition) { VTF3_rec_t *rec; int numchars; rec = VTF3_ComposeSrcinfo_obsol (fcb, time, activitytoken, statetoken, scllineposition); numchars = rec->numchars; (void) WriteRecord ((fcb_t *) fcb); return (numchars); } int VTF3_WriteUnrecognizable (void *fcb, double lastvalidtime, int numberofunrecognizablechars, int typeofunrecognizablerecord, const char *unrecognizablerecord) { VTF3_rec_t *rec; int numchars; rec = VTF3_ComposeUnrecognizable (fcb, lastvalidtime, numberofunrecognizablechars, typeofunrecognizablerecord, unrecognizablerecord); numchars = rec->numchars; (void) WriteRecord ((fcb_t *) fcb); return (numchars); } int VTF3_WriteUpfrom (void *fcb, double time, int statetoken, unsigned int cpuid, int scltoken) { VTF3_rec_t *rec; int numchars; rec = VTF3_ComposeUpfrom (fcb, time, statetoken, cpuid, scltoken); numchars = rec->numchars; (void) WriteRecord ((fcb_t *) fcb); return (numchars); } int VTF3_WriteUpto (void *fcb, double time, int statetoken, unsigned int cpuid, int scltoken) { VTF3_rec_t *rec; int numchars; rec = VTF3_ComposeUpto (fcb, time, statetoken, cpuid, scltoken); numchars = rec->numchars; (void) WriteRecord ((fcb_t *) fcb); return (numchars); } /*****************************************************************************/ VTF3_rec_t * VTF3_ComposeClstrregval (void *fcbcaller, double time, int clstrtoken, int clstrregarraydim, const int *clstrregtokenarray, const int *clstrregvaluetypearray, const void *clstrregvaluearray) { fcb_t *fcb; int i, vt; unsigned int ul, uh; double f; fcb = (fcb_t *) fcbcaller; (void) CheckFcbOut (fcb); fcb->lastvalidtime = time; if (clstrregarraydim < 0) { (void) fprintf (stderr, "VTF3: Bad dimension value %d to " "VTF3_ComposeClstrregval()\n", clstrregarraydim); (void) fflush (stderr); (void) exit (127); } if (fcb->fileformat == VTF3_FILEFORMAT_STD_BINARY) { fcb->recbufferpos = fcb->recbuffer + 6; (void) StdBinaryWriteTs (fcb, time); VTF3_STDBINARYCOMPOSE_WRITEI4 (clstrtoken); for (i = 0; i < clstrregarraydim; i++) { VTF3_STDBINARYCOMPOSE_WRITEI4 (*(clstrregtokenarray + i)); if (clstrregvaluetypearray == 0) vt = VTF3_VALUETYPE_UINT; else if (*(clstrregvaluetypearray + i) == VTF3_VALUETYPE_FLOAT) vt = VTF3_VALUETYPE_FLOAT; else vt = VTF3_VALUETYPE_UINT; VTF3_STDBINARYCOMPOSE_WRITEI1 (vt); if (vt == VTF3_VALUETYPE_UINT) { if (vtffprtype == VTF3_CONST_FPNRT_IEEE754_DOUBLE_LITEND) { ul = LoadUintFromU4Array (clstrregvaluearray, 2 * i + 0); uh = LoadUintFromU4Array (clstrregvaluearray, 2 * i + 1); } else { uh = LoadUintFromU4Array (clstrregvaluearray, 2 * i + 0); ul = LoadUintFromU4Array (clstrregvaluearray, 2 * i + 1); } VTF3_STDBINARYCOMPOSE_WRITEU4 (uh); VTF3_STDBINARYCOMPOSE_WRITEU4 (ul); } else { f = LoadDoubleFromU4Array (clstrregvaluearray, 2 * i + 0); (void) StdBinaryWriteF8 (fcb, f); } } return (StdBinaryWriteEp (fcb, VTF3_RECTYPE_CLSTRREGVAL)); } if (fcb->fileformat == VTF3_FILEFORMAT_FST_ASCII) { fcb->recbufferpos = fcb->recbuffer + 0; (void) StdAsciiWriteTs (fcb, time); VTF3_FSTASCIICOMPOSE_WRITEC2 ('V', 'C'); VTF3_FSTASCIICOMPOSE_WRITEI4 (clstrtoken); for (i = 0; i < clstrregarraydim; i++) { if (clstrregvaluetypearray == 0) vt = VTF3_VALUETYPE_UINT; else if (*(clstrregvaluetypearray + i) == VTF3_VALUETYPE_FLOAT) vt = VTF3_VALUETYPE_FLOAT; else vt = VTF3_VALUETYPE_UINT; if (vt == VTF3_VALUETYPE_UINT) { VTF3_FSTASCIICOMPOSE_WRITEC1 ('U'); VTF3_FSTASCIICOMPOSE_WRITEI4 (*(clstrregtokenarray + i)); if (vtffprtype == VTF3_CONST_FPNRT_IEEE754_DOUBLE_LITEND) { ul = LoadUintFromU4Array (clstrregvaluearray, 2 * i + 0); uh = LoadUintFromU4Array (clstrregvaluearray, 2 * i + 1); } else { uh = LoadUintFromU4Array (clstrregvaluearray, 2 * i + 0); ul = LoadUintFromU4Array (clstrregvaluearray, 2 * i + 1); } if (uh != 0) { VTF3_FSTASCIICOMPOSE_WRITEC1 ('H'); VTF3_FSTASCIICOMPOSE_WRITEU4 (uh); } if (ul != 0) { VTF3_FSTASCIICOMPOSE_WRITEC1 ('L'); VTF3_FSTASCIICOMPOSE_WRITEU4 (ul); } } else { VTF3_FSTASCIICOMPOSE_WRITEC1 ('F'); VTF3_FSTASCIICOMPOSE_WRITEI4 (*(clstrregtokenarray + i)); f = LoadDoubleFromU4Array (clstrregvaluearray, 2 * i + 0); (void) FstAsciiWriteXy (fcb, f); } } return (StdAsciiWriteEp (fcb, VTF3_RECTYPE_CLSTRREGVAL)); } fcb->recbufferpos = fcb->recbuffer + 0; (void) StdAsciiWriteTs (fcb, time); (void) StdAsciiWriteSu (fcb, " CLSTRREGVAL CLSTR "); (void) StdAsciiWriteI4 (fcb, clstrtoken); for (i = 0; i < clstrregarraydim; i++) { (void) StdAsciiWriteSu (fcb, " REG "); (void) StdAsciiWriteI4 (fcb, *(clstrregtokenarray + i)); if (clstrregvaluetypearray == 0) vt = VTF3_VALUETYPE_UINT; else if (*(clstrregvaluetypearray + i) == VTF3_VALUETYPE_FLOAT) vt = VTF3_VALUETYPE_FLOAT; else vt = VTF3_VALUETYPE_UINT; if (vt == VTF3_VALUETYPE_UINT) { (void) StdAsciiWriteSu (fcb, " UINT "); if (vtffprtype == VTF3_CONST_FPNRT_IEEE754_DOUBLE_LITEND) { ul = LoadUintFromU4Array (clstrregvaluearray, 2 * i + 0); uh = LoadUintFromU4Array (clstrregvaluearray, 2 * i + 1); } else { uh = LoadUintFromU4Array (clstrregvaluearray, 2 * i + 0); ul = LoadUintFromU4Array (clstrregvaluearray, 2 * i + 1); } (void) StdAsciiWriteU4 (fcb, uh); (void) StdAsciiWriteSu (fcb, " "); (void) StdAsciiWriteU4 (fcb, ul); } else { (void) StdAsciiWriteSu (fcb, " FLOAT "); f = LoadDoubleFromU4Array (clstrregvaluearray, 2 * i + 0); (void) StdAsciiWriteF8 (fcb, f); } } return (StdAsciiWriteEp (fcb, VTF3_RECTYPE_CLSTRREGVAL)); } VTF3_rec_t * VTF3_ComposeComment (void *fcbcaller, double time, const char *comment) { fcb_t *fcb; fcb = (fcb_t *) fcbcaller; (void) CheckFcbOut (fcb); fcb->lastvalidtime = time; if (fcb->fileformat == VTF3_FILEFORMAT_STD_BINARY) { fcb->recbufferpos = fcb->recbuffer + 6; (void) StdBinaryWriteTs (fcb, time); (void) StdBinaryWriteSv (fcb, comment); return (StdBinaryWriteEp (fcb, VTF3_RECTYPE_COMMENT)); } if (fcb->fileformat == VTF3_FILEFORMAT_FST_ASCII) { fcb->recbufferpos = fcb->recbuffer + 0; (void) StdAsciiWriteTs (fcb, time); VTF3_FSTASCIICOMPOSE_WRITEC3 ('C', 'C', ' '); (void) StdAsciiWriteSc (fcb, comment); return (StdAsciiWriteEp (fcb, VTF3_RECTYPE_COMMENT)); } fcb->recbufferpos = fcb->recbuffer + 0; (void) StdAsciiWriteTs (fcb, time); (void) StdAsciiWriteSu (fcb, " C "); (void) StdAsciiWriteSc (fcb, comment); return (StdAsciiWriteEp (fcb, VTF3_RECTYPE_COMMENT)); } VTF3_rec_t * VTF3_ComposeCpuregval (void *fcbcaller, double time, unsigned int cpuid, int cpuregarraydim, const int *cpuregtokenarray, const int *cpuregvaluetypearray, const void *cpuregvaluearray) { fcb_t *fcb; int i, vt; unsigned int ul, uh; double f; fcb = (fcb_t *) fcbcaller; (void) CheckFcbOut (fcb); fcb->lastvalidtime = time; if (cpuregarraydim < 0) { (void) fprintf (stderr, "VTF3: Bad dimension value %d to " "VTF3_ComposeCpuregval()\n", cpuregarraydim); (void) fflush (stderr); (void) exit (127); } if (fcb->fileformat == VTF3_FILEFORMAT_STD_BINARY) { fcb->recbufferpos = fcb->recbuffer + 6; (void) StdBinaryWriteTs (fcb, time); VTF3_STDBINARYCOMPOSE_WRITEU4 (cpuid); for (i = 0; i < cpuregarraydim; i++) { VTF3_STDBINARYCOMPOSE_WRITEI4 (*(cpuregtokenarray + i)); if (cpuregvaluetypearray == 0) vt = VTF3_VALUETYPE_UINT; else if (*(cpuregvaluetypearray + i) == VTF3_VALUETYPE_FLOAT) vt = VTF3_VALUETYPE_FLOAT; else vt = VTF3_VALUETYPE_UINT; VTF3_STDBINARYCOMPOSE_WRITEI1 (vt); if (vt == VTF3_VALUETYPE_UINT) { if (vtffprtype == VTF3_CONST_FPNRT_IEEE754_DOUBLE_LITEND) { ul = LoadUintFromU4Array (cpuregvaluearray, 2 * i + 0); uh = LoadUintFromU4Array (cpuregvaluearray, 2 * i + 1); } else { uh = LoadUintFromU4Array (cpuregvaluearray, 2 * i + 0); ul = LoadUintFromU4Array (cpuregvaluearray, 2 * i + 1); } VTF3_STDBINARYCOMPOSE_WRITEU4 (uh); VTF3_STDBINARYCOMPOSE_WRITEU4 (ul); } else { f = LoadDoubleFromU4Array (cpuregvaluearray, 2 * i + 0); (void) StdBinaryWriteF8 (fcb, f); } } return (StdBinaryWriteEp (fcb, VTF3_RECTYPE_CPUREGVAL)); } if (fcb->fileformat == VTF3_FILEFORMAT_FST_ASCII) { fcb->recbufferpos = fcb->recbuffer + 0; (void) StdAsciiWriteTs (fcb, time); VTF3_FSTASCIICOMPOSE_WRITEC2 ('V', 'P'); VTF3_FSTASCIICOMPOSE_WRITEU4 (cpuid); for (i = 0; i < cpuregarraydim; i++) { if (cpuregvaluetypearray == 0) vt = VTF3_VALUETYPE_UINT; else if (*(cpuregvaluetypearray + i) == VTF3_VALUETYPE_FLOAT) vt = VTF3_VALUETYPE_FLOAT; else vt = VTF3_VALUETYPE_UINT; if (vt == VTF3_VALUETYPE_UINT) { VTF3_FSTASCIICOMPOSE_WRITEC1 ('U'); VTF3_FSTASCIICOMPOSE_WRITEI4 (*(cpuregtokenarray + i)); if (vtffprtype == VTF3_CONST_FPNRT_IEEE754_DOUBLE_LITEND) { ul = LoadUintFromU4Array (cpuregvaluearray, 2 * i + 0); uh = LoadUintFromU4Array (cpuregvaluearray, 2 * i + 1); } else { uh = LoadUintFromU4Array (cpuregvaluearray, 2 * i + 0); ul = LoadUintFromU4Array (cpuregvaluearray, 2 * i + 1); } if (uh != 0) { VTF3_FSTASCIICOMPOSE_WRITEC1 ('H'); VTF3_FSTASCIICOMPOSE_WRITEU4 (uh); } if (ul != 0) { VTF3_FSTASCIICOMPOSE_WRITEC1 ('L'); VTF3_FSTASCIICOMPOSE_WRITEU4 (ul); } } else { VTF3_FSTASCIICOMPOSE_WRITEC1 ('F'); VTF3_FSTASCIICOMPOSE_WRITEI4 (*(cpuregtokenarray + i)); f = LoadDoubleFromU4Array (cpuregvaluearray, 2 * i + 0); (void) FstAsciiWriteXy (fcb, f); } } return (StdAsciiWriteEp (fcb, VTF3_RECTYPE_CPUREGVAL)); } fcb->recbufferpos = fcb->recbuffer + 0; (void) StdAsciiWriteTs (fcb, time); #if (defined (VTF3_LEGACY_OUTPUT)) (void) StdAsciiWriteSu (fcb, " CPUREGVAL CPU "); (void) StdAsciiWriteU4 (fcb, cpuid + 1); #else if (cpuid != 0) { (void) StdAsciiWriteSu (fcb, " CPUREGVAL CPU "); (void) StdAsciiWriteU4 (fcb, cpuid); } else (void) StdAsciiWriteSu (fcb, " CPUREGVAL"); #endif for (i = 0; i < cpuregarraydim; i++) { (void) StdAsciiWriteSu (fcb, " REG "); (void) StdAsciiWriteI4 (fcb, *(cpuregtokenarray + i)); if (cpuregvaluetypearray == 0) vt = VTF3_VALUETYPE_UINT; else if (*(cpuregvaluetypearray + i) == VTF3_VALUETYPE_FLOAT) vt = VTF3_VALUETYPE_FLOAT; else vt = VTF3_VALUETYPE_UINT; if (vt == VTF3_VALUETYPE_UINT) { (void) StdAsciiWriteSu (fcb, " UINT "); if (vtffprtype == VTF3_CONST_FPNRT_IEEE754_DOUBLE_LITEND) { ul = LoadUintFromU4Array (cpuregvaluearray, 2 * i + 0); uh = LoadUintFromU4Array (cpuregvaluearray, 2 * i + 1); } else { uh = LoadUintFromU4Array (cpuregvaluearray, 2 * i + 0); ul = LoadUintFromU4Array (cpuregvaluearray, 2 * i + 1); } (void) StdAsciiWriteU4 (fcb, uh); (void) StdAsciiWriteSu (fcb, " "); (void) StdAsciiWriteU4 (fcb, ul); } else { (void) StdAsciiWriteSu (fcb, " FLOAT "); f = LoadDoubleFromU4Array (cpuregvaluearray, 2 * i + 0); (void) StdAsciiWriteF8 (fcb, f); } } return (StdAsciiWriteEp (fcb, VTF3_RECTYPE_CPUREGVAL)); } VTF3_rec_t * VTF3_ComposeDefact (void *fcbcaller, int activitytoken, const char *activityname) { static const char *noact = "NOACT"; fcb_t *fcb; int isnoact, i; fcb = (fcb_t *) fcbcaller; (void) CheckFcbOut (fcb); if (activitytoken == VTF3_NOACT) { (void) fprintf (stderr, "VTF3: Bad value %d as activity token to " "VTF3_ComposeDefact()\n", VTF3_NOACT); (void) fflush (stderr); (void) exit (127); } if (activityname == 0) { (void) fprintf (stderr, "VTF3: NULL as activity name to " "VTF3_ComposeDefact()\n"); (void) fflush (stderr); (void) exit (127); } isnoact = 1; for (i = 0; i < 6; i++) if (*(activityname + i) != *(noact + i)) { isnoact = 0; break; } if (isnoact != 0) { (void) fprintf (stderr, "VTF3: NOACT as activity name to " "VTF3_ComposeDefact()\n"); (void) fflush (stderr); (void) exit (127); } if (fcb->fileformat == VTF3_FILEFORMAT_STD_BINARY) { fcb->recbufferpos = fcb->recbuffer + 6; VTF3_STDBINARYCOMPOSE_WRITEI4 (activitytoken); (void) StdBinaryWriteSv (fcb, activityname); return (StdBinaryWriteEp (fcb, VTF3_RECTYPE_DEFACT)); } fcb->recbufferpos = fcb->recbuffer + 0; (void) StdAsciiWriteSu (fcb, "DEFACT "); (void) StdAsciiWriteI4 (fcb, activitytoken); (void) StdAsciiWriteSu (fcb, " \""); (void) StdAsciiWriteSp (fcb, activityname); (void) StdAsciiWriteSu (fcb, "\""); return (StdAsciiWriteEp (fcb, VTF3_RECTYPE_DEFACT)); } VTF3_rec_t * VTF3_ComposeDefact_obsol (void *fcbcaller, int activitytoken, const char *activityname) { static const char *noact = "NOACT"; fcb_t *fcb; int isnoact, i; fcb = (fcb_t *) fcbcaller; (void) CheckFcbOut (fcb); if (activitytoken == VTF3_NOACT) { (void) fprintf (stderr, "VTF3: Bad value %d as activity token to " "VTF3_ComposeDefact_obsol()\n", VTF3_NOACT); (void) fflush (stderr); (void) exit (127); } if (activityname == 0) { (void) fprintf (stderr, "VTF3: NULL as activity name to " "VTF3_ComposeDefact_obsol()\n"); (void) fflush (stderr); (void) exit (127); } isnoact = 1; for (i = 0; i < 6; i++) if (*(activityname + i) != *(noact + i)) { isnoact = 0; break; } if (isnoact != 0) { (void) fprintf (stderr, "VTF3: NOACT as activity name to " "VTF3_ComposeDefact_obsol()\n"); (void) fflush (stderr); (void) exit (127); } if (fcb->fileformat == VTF3_FILEFORMAT_STD_BINARY) { fcb->recbufferpos = fcb->recbuffer + 6; VTF3_STDBINARYCOMPOSE_WRITEI4 (activitytoken); (void) StdBinaryWriteSv (fcb, activityname); return (StdBinaryWriteEp (fcb, VTF3_RECTYPE_DEFACT_OBSOL)); } fcb->recbufferpos = fcb->recbuffer + 0; #if (defined (VTF3_LEGACY_OUTPUT)) (void) StdAsciiWriteSu (fcb, "C DEFTOKEN "); (void) StdAsciiWriteI4 (fcb, activitytoken); (void) StdAsciiWriteSu (fcb, " \""); (void) StdAsciiWriteSp (fcb, activityname); (void) StdAsciiWriteSu (fcb, "\""); return (StdAsciiWriteEp (fcb, VTF3_RECTYPE_COMMENT)); #else (void) StdAsciiWriteSu (fcb, "DEFTOKEN "); (void) StdAsciiWriteI4 (fcb, activitytoken); (void) StdAsciiWriteSu (fcb, " \""); (void) StdAsciiWriteSp (fcb, activityname); (void) StdAsciiWriteSu (fcb, "\""); return (StdAsciiWriteEp (fcb, VTF3_RECTYPE_DEFACT_OBSOL)); #endif } VTF3_rec_t * VTF3_ComposeDefclkperiod (void *fcbcaller, double clkperiod) { fcb_t *fcb; fcb = (fcb_t *) fcbcaller; (void) CheckFcbOut (fcb); if (fcb->fileformat == VTF3_FILEFORMAT_STD_BINARY) { fcb->recbufferpos = fcb->recbuffer + 6; (void) StdBinaryWriteF8 (fcb, clkperiod); return (StdBinaryWriteEp (fcb, VTF3_RECTYPE_DEFCLKPERIOD)); } fcb->recbufferpos = fcb->recbuffer + 0; (void) StdAsciiWriteSu (fcb, "CLKPERIOD "); (void) StdAsciiWriteF8 (fcb, clkperiod); return (StdAsciiWriteEp (fcb, VTF3_RECTYPE_DEFCLKPERIOD)); } VTF3_rec_t * VTF3_ComposeDefclstr (void *fcbcaller, int clstrtoken, const char *clstrname, int cpuidarraydim, const unsigned int *cpuidarray) { fcb_t *fcb; int i; fcb = (fcb_t *) fcbcaller; (void) CheckFcbOut (fcb); if (cpuidarraydim < 0) { (void) fprintf (stderr, "VTF3: Bad dimension value %d to " "VTF3_ComposeDefclstr()\n", cpuidarraydim); (void) fflush (stderr); (void) exit (127); } if (fcb->fileformat == VTF3_FILEFORMAT_STD_BINARY) { fcb->recbufferpos = fcb->recbuffer + 6; VTF3_STDBINARYCOMPOSE_WRITEI4 (clstrtoken); (void) StdBinaryWriteSv (fcb, clstrname); VTF3_STDBINARYCOMPOSE_WRITEI4 (cpuidarraydim); for (i = 0; i < cpuidarraydim; i++) { VTF3_STDBINARYCOMPOSE_WRITEU4 (*(cpuidarray + i)); } return (StdBinaryWriteEp (fcb, VTF3_RECTYPE_DEFCLSTR)); } fcb->recbufferpos = fcb->recbuffer + 0; (void) StdAsciiWriteSu (fcb, "DEFCLUSTER "); (void) StdAsciiWriteI4 (fcb, clstrtoken); (void) StdAsciiWriteSu (fcb, " \""); (void) StdAsciiWriteSp (fcb, clstrname); (void) StdAsciiWriteSu (fcb, "\" NCPUS "); (void) StdAsciiWriteI4 (fcb, cpuidarraydim); if (cpuidarraydim > 0) (void) StdAsciiWriteSu (fcb, " CPUS"); #if (defined (VTF3_LEGACY_OUTPUT)) for (i = 0; i < cpuidarraydim; i++) { (void) StdAsciiWriteSu (fcb, " "); (void) StdAsciiWriteU4 (fcb, *(cpuidarray + i) + 1); } #else for (i = 0; i < cpuidarraydim; i++) { (void) StdAsciiWriteSu (fcb, " "); (void) StdAsciiWriteU4 (fcb, *(cpuidarray + i)); } #endif return (StdAsciiWriteEp (fcb, VTF3_RECTYPE_DEFCLSTR)); } VTF3_rec_t * VTF3_ComposeDefclstrreg (void *fcbcaller, int clstrregtoken, int clstrregclasstoken, int valuetype, const void *valuebounds, const char *clstrregname, const char *clstrregunit) { fcb_t *fcb; unsigned int uminl, uminh, umaxl, umaxh; double fmin, fmax; fcb = (fcb_t *) fcbcaller; (void) CheckFcbOut (fcb); if (fcb->fileformat == VTF3_FILEFORMAT_STD_BINARY) { fcb->recbufferpos = fcb->recbuffer + 6; VTF3_STDBINARYCOMPOSE_WRITEI4 (clstrregtoken); VTF3_STDBINARYCOMPOSE_WRITEI4 (clstrregclasstoken); VTF3_STDBINARYCOMPOSE_WRITEI1 (valuetype); if (valuetype == VTF3_VALUETYPE_UINT) { if (vtffprtype == VTF3_CONST_FPNRT_IEEE754_DOUBLE_LITEND) { uminl = LoadUintFromU4Array (valuebounds, 0); uminh = LoadUintFromU4Array (valuebounds, 1); umaxl = LoadUintFromU4Array (valuebounds, 2); umaxh = LoadUintFromU4Array (valuebounds, 3); } else { uminh = LoadUintFromU4Array (valuebounds, 0); uminl = LoadUintFromU4Array (valuebounds, 1); umaxh = LoadUintFromU4Array (valuebounds, 2); umaxl = LoadUintFromU4Array (valuebounds, 3); } VTF3_STDBINARYCOMPOSE_WRITEU4 (uminh); VTF3_STDBINARYCOMPOSE_WRITEU4 (uminl); VTF3_STDBINARYCOMPOSE_WRITEU4 (umaxh); VTF3_STDBINARYCOMPOSE_WRITEU4 (umaxl); } else if (valuetype == VTF3_VALUETYPE_FLOAT) { fmin = LoadDoubleFromU4Array (valuebounds, 0); fmax = LoadDoubleFromU4Array (valuebounds, 2); (void) StdBinaryWriteF8 (fcb, fmin); (void) StdBinaryWriteF8 (fcb, fmax); } else { (void) fprintf (stderr, "VTF3: Bad value type to " "VTF3_ComposeDefclstrreg()\n"); (void) fflush (stderr); (void) exit (127); } (void) StdBinaryWriteSv (fcb, clstrregname); (void) StdBinaryWriteSv (fcb, clstrregunit); return (StdBinaryWriteEp (fcb, VTF3_RECTYPE_DEFCLSTRREG)); } fcb->recbufferpos = fcb->recbuffer + 0; (void) StdAsciiWriteSu (fcb, "DEFCLSTRREG "); (void) StdAsciiWriteI4 (fcb, clstrregtoken); (void) StdAsciiWriteSu (fcb, " CLASS "); (void) StdAsciiWriteI4 (fcb, clstrregclasstoken); if (valuetype == VTF3_VALUETYPE_UINT) { if (vtffprtype == VTF3_CONST_FPNRT_IEEE754_DOUBLE_LITEND) { uminl = LoadUintFromU4Array (valuebounds, 0); uminh = LoadUintFromU4Array (valuebounds, 1); umaxl = LoadUintFromU4Array (valuebounds, 2); umaxh = LoadUintFromU4Array (valuebounds, 3); } else { uminh = LoadUintFromU4Array (valuebounds, 0); uminl = LoadUintFromU4Array (valuebounds, 1); umaxh = LoadUintFromU4Array (valuebounds, 2); umaxl = LoadUintFromU4Array (valuebounds, 3); } (void) StdAsciiWriteSu (fcb, " TYPE UINT MIN "); (void) StdAsciiWriteU4 (fcb, uminh); (void) StdAsciiWriteSu (fcb, " "); (void) StdAsciiWriteU4 (fcb, uminl); (void) StdAsciiWriteSu (fcb, " MAX "); (void) StdAsciiWriteU4 (fcb, umaxh); (void) StdAsciiWriteSu (fcb, " "); (void) StdAsciiWriteU4 (fcb, umaxl); } else if (valuetype == VTF3_VALUETYPE_FLOAT) { fmin = LoadDoubleFromU4Array (valuebounds, 0); fmax = LoadDoubleFromU4Array (valuebounds, 2); (void) StdAsciiWriteSu (fcb, " TYPE FLOAT MIN "); (void) StdAsciiWriteF8 (fcb, fmin); (void) StdAsciiWriteSu (fcb, " MAX "); (void) StdAsciiWriteF8 (fcb, fmax); } else { (void) fprintf (stderr, "VTF3: Bad value type to " "VTF3_ComposeDefclstrreg()\n"); (void) fflush (stderr); (void) exit (127); } (void) StdAsciiWriteSu (fcb, " NAME \""); (void) StdAsciiWriteSp (fcb, clstrregname); (void) StdAsciiWriteSu (fcb, "\" UNIT \""); (void) StdAsciiWriteSp (fcb, clstrregunit); (void) StdAsciiWriteSu (fcb, "\""); return (StdAsciiWriteEp (fcb, VTF3_RECTYPE_DEFCLSTRREG)); } VTF3_rec_t * VTF3_ComposeDefclstrregclass (void *fcbcaller, int clstrregclasstoken, const char *clstrregclassname) { fcb_t *fcb; fcb = (fcb_t *) fcbcaller; (void) CheckFcbOut (fcb); if (fcb->fileformat == VTF3_FILEFORMAT_STD_BINARY) { fcb->recbufferpos = fcb->recbuffer + 6; VTF3_STDBINARYCOMPOSE_WRITEI4 (clstrregclasstoken); (void) StdBinaryWriteSv (fcb, clstrregclassname); return (StdBinaryWriteEp (fcb, VTF3_RECTYPE_DEFCLSTRREGCLASS)); } fcb->recbufferpos = fcb->recbuffer + 0; (void) StdAsciiWriteSu (fcb, "DEFCLSTRREGCLASS "); (void) StdAsciiWriteI4 (fcb, clstrregclasstoken); (void) StdAsciiWriteSu (fcb, " \""); (void) StdAsciiWriteSp (fcb, clstrregclassname); (void) StdAsciiWriteSu (fcb, "\""); return (StdAsciiWriteEp (fcb, VTF3_RECTYPE_DEFCLSTRREGCLASS)); } VTF3_rec_t * VTF3_ComposeDefcommunicator (void *fcbcaller, int communicator, int communicatorsize, int tripletarraydim, const unsigned int *tripletarray) { fcb_t *fcb; int i; fcb = (fcb_t *) fcbcaller; (void) CheckFcbOut (fcb); if (tripletarraydim < 0) { (void) fprintf (stderr, "VTF3: Bad dimension value %d to " "VTF3_ComposeDefcommunicator()\n", tripletarraydim); (void) fflush (stderr); (void) exit (127); } if (fcb->fileformat == VTF3_FILEFORMAT_STD_BINARY) { fcb->recbufferpos = fcb->recbuffer + 6; VTF3_STDBINARYCOMPOSE_WRITEI4 (communicator); VTF3_STDBINARYCOMPOSE_WRITEI4 (communicatorsize); VTF3_STDBINARYCOMPOSE_WRITEI4 (tripletarraydim); for (i = 0; i < tripletarraydim; i++) { VTF3_STDBINARYCOMPOSE_WRITEU4 (*(tripletarray + 3 * i + 0)); VTF3_STDBINARYCOMPOSE_WRITEU4 (*(tripletarray + 3 * i + 1)); VTF3_STDBINARYCOMPOSE_WRITEU4 (*(tripletarray + 3 * i + 2)); } return (StdBinaryWriteEp (fcb, VTF3_RECTYPE_DEFCOMMUNICATOR)); } fcb->recbufferpos = fcb->recbuffer + 0; (void) StdAsciiWriteSu (fcb, "COMDEF "); (void) StdAsciiWriteI4 (fcb, communicator); #if (defined (VTF3_LEGACY_OUTPUT)) (void) StdAsciiWriteSu (fcb, " "); (void) StdAsciiWriteI4 (fcb, communicatorsize); for (i = 0; i < tripletarraydim; i++) { (void) StdAsciiWriteSu (fcb, " "); (void) StdAsciiWriteU4 (fcb, *(tripletarray + 3 * i + 0) + 0); (void) StdAsciiWriteSu (fcb, ":"); (void) StdAsciiWriteU4 (fcb, *(tripletarray + 3 * i + 1) + 0); (void) StdAsciiWriteSu (fcb, ":"); (void) StdAsciiWriteU4 (fcb, *(tripletarray + 3 * i + 2) + 0); } #else (void) StdAsciiWriteSu (fcb, " SIZE "); (void) StdAsciiWriteI4 (fcb, communicatorsize); if (tripletarraydim > 0) (void) StdAsciiWriteSu (fcb, " SPECS"); for (i = 0; i < tripletarraydim; i++) { (void) StdAsciiWriteSu (fcb, " "); (void) StdAsciiWriteU4 (fcb, *(tripletarray + 3 * i + 0) + 0); (void) StdAsciiWriteSu (fcb, ":"); (void) StdAsciiWriteU4 (fcb, *(tripletarray + 3 * i + 1) + 0); (void) StdAsciiWriteSu (fcb, ":"); (void) StdAsciiWriteU4 (fcb, *(tripletarray + 3 * i + 2) + 0); } #endif return (StdAsciiWriteEp (fcb, VTF3_RECTYPE_DEFCOMMUNICATOR)); } VTF3_rec_t * VTF3_ComposeDefcpugrp (void *fcbcaller, unsigned int cpugrpid, int cpuorcpugrpidarraydim, const unsigned int *cpuorcpugrpidarray, const char *cpugrpname) { fcb_t *fcb; int i; fcb = (fcb_t *) fcbcaller; (void) CheckFcbOut (fcb); if (cpuorcpugrpidarraydim < 0) { (void) fprintf (stderr, "VTF3: Bad dimension value %d to " "VTF3_ComposeDefcpugrp()\n", cpuorcpugrpidarraydim); (void) fflush (stderr); (void) exit (127); } if (fcb->fileformat == VTF3_FILEFORMAT_STD_BINARY) { fcb->recbufferpos = fcb->recbuffer + 6; VTF3_STDBINARYCOMPOSE_WRITEU4 (cpugrpid | VTF3_CPUGRP_MASK); (void) StdBinaryWriteSv (fcb, cpugrpname); for (i = 0; i < cpuorcpugrpidarraydim; i++) { VTF3_STDBINARYCOMPOSE_WRITEU4 (*(cpuorcpugrpidarray + i)); } return (StdBinaryWriteEp (fcb, VTF3_RECTYPE_DEFCPUGRP)); } fcb->recbufferpos = fcb->recbuffer + 0; (void) StdAsciiWriteSu (fcb, "DEFGROUP "); #if (defined (VTF3_LEGACY_OUTPUT)) (void) StdAsciiWriteU4 (fcb, (cpugrpid | VTF3_CPUGRP_MASK) + 1); (void) StdAsciiWriteSu (fcb, " \""); (void) StdAsciiWriteSp (fcb, cpugrpname); (void) StdAsciiWriteSu (fcb, "\" NMEMBS "); (void) StdAsciiWriteI4 (fcb, cpuorcpugrpidarraydim); for (i = 0; i < cpuorcpugrpidarraydim; i++) { (void) StdAsciiWriteSu (fcb, " "); (void) StdAsciiWriteU4 (fcb, *(cpuorcpugrpidarray + i) + 1); } #else (void) StdAsciiWriteU4 (fcb, (cpugrpid | VTF3_CPUGRP_MASK)); (void) StdAsciiWriteSu (fcb, " \""); (void) StdAsciiWriteSp (fcb, cpugrpname); (void) StdAsciiWriteSu (fcb, "\" NMEMBS "); (void) StdAsciiWriteI4 (fcb, cpuorcpugrpidarraydim); if (cpuorcpugrpidarraydim > 0) (void) StdAsciiWriteSu (fcb, " MEMBS"); for (i = 0; i < cpuorcpugrpidarraydim; i++) { (void) StdAsciiWriteSu (fcb, " "); (void) StdAsciiWriteU4 (fcb, *(cpuorcpugrpidarray + i)); } #endif return (StdAsciiWriteEp (fcb, VTF3_RECTYPE_DEFCPUGRP)); } VTF3_rec_t * VTF3_ComposeDefcpuname (void *fcbcaller, unsigned int cpuid, const char *cpuname) { fcb_t *fcb; fcb = (fcb_t *) fcbcaller; (void) CheckFcbOut (fcb); if (fcb->fileformat == VTF3_FILEFORMAT_STD_BINARY) { fcb->recbufferpos = fcb->recbuffer + 6; VTF3_STDBINARYCOMPOSE_WRITEU4 (cpuid); (void) StdBinaryWriteSv (fcb, cpuname); return (StdBinaryWriteEp (fcb, VTF3_RECTYPE_DEFCPUNAME)); } fcb->recbufferpos = fcb->recbuffer + 0; (void) StdAsciiWriteSu (fcb, "CPUSYM "); #if (defined (VTF3_LEGACY_OUTPUT)) (void) StdAsciiWriteU4 (fcb, cpuid + 1); #else (void) StdAsciiWriteU4 (fcb, cpuid); #endif (void) StdAsciiWriteSu (fcb, " \""); (void) StdAsciiWriteSp (fcb, cpuname); (void) StdAsciiWriteSu (fcb, "\""); return (StdAsciiWriteEp (fcb, VTF3_RECTYPE_DEFCPUNAME)); } VTF3_rec_t * VTF3_ComposeDefcpureg (void *fcbcaller, int cpuregtoken, int cpuregclasstoken, int valuetype, const void *valuebounds, const char *cpuregname, const char *cpuregunit) { fcb_t *fcb; unsigned int uminl, uminh, umaxl, umaxh; double fmin, fmax; fcb = (fcb_t *) fcbcaller; (void) CheckFcbOut (fcb); if (fcb->fileformat == VTF3_FILEFORMAT_STD_BINARY) { fcb->recbufferpos = fcb->recbuffer + 6; VTF3_STDBINARYCOMPOSE_WRITEI4 (cpuregtoken); VTF3_STDBINARYCOMPOSE_WRITEI4 (cpuregclasstoken); VTF3_STDBINARYCOMPOSE_WRITEI1 (valuetype); if (valuetype == VTF3_VALUETYPE_UINT) { if (vtffprtype == VTF3_CONST_FPNRT_IEEE754_DOUBLE_LITEND) { uminl = LoadUintFromU4Array (valuebounds, 0); uminh = LoadUintFromU4Array (valuebounds, 1); umaxl = LoadUintFromU4Array (valuebounds, 2); umaxh = LoadUintFromU4Array (valuebounds, 3); } else { uminh = LoadUintFromU4Array (valuebounds, 0); uminl = LoadUintFromU4Array (valuebounds, 1); umaxh = LoadUintFromU4Array (valuebounds, 2); umaxl = LoadUintFromU4Array (valuebounds, 3); } VTF3_STDBINARYCOMPOSE_WRITEU4 (uminh); VTF3_STDBINARYCOMPOSE_WRITEU4 (uminl); VTF3_STDBINARYCOMPOSE_WRITEU4 (umaxh); VTF3_STDBINARYCOMPOSE_WRITEU4 (umaxl); } else if (valuetype == VTF3_VALUETYPE_FLOAT) { fmin = LoadDoubleFromU4Array (valuebounds, 0); fmax = LoadDoubleFromU4Array (valuebounds, 2); (void) StdBinaryWriteF8 (fcb, fmin); (void) StdBinaryWriteF8 (fcb, fmax); } else { (void) fprintf (stderr, "VTF3: Bad value type to " "VTF3_ComposeDefcpureg()\n"); (void) fflush (stderr); (void) exit (127); } (void) StdBinaryWriteSv (fcb, cpuregname); (void) StdBinaryWriteSv (fcb, cpuregunit); return (StdBinaryWriteEp (fcb, VTF3_RECTYPE_DEFCPUREG)); } fcb->recbufferpos = fcb->recbuffer + 0; (void) StdAsciiWriteSu (fcb, "DEFCPUREG "); (void) StdAsciiWriteI4 (fcb, cpuregtoken); (void) StdAsciiWriteSu (fcb, " CLASS "); (void) StdAsciiWriteI4 (fcb, cpuregclasstoken); if (valuetype == VTF3_VALUETYPE_UINT) { if (vtffprtype == VTF3_CONST_FPNRT_IEEE754_DOUBLE_LITEND) { uminl = LoadUintFromU4Array (valuebounds, 0); uminh = LoadUintFromU4Array (valuebounds, 1); umaxl = LoadUintFromU4Array (valuebounds, 2); umaxh = LoadUintFromU4Array (valuebounds, 3); } else { uminh = LoadUintFromU4Array (valuebounds, 0); uminl = LoadUintFromU4Array (valuebounds, 1); umaxh = LoadUintFromU4Array (valuebounds, 2); umaxl = LoadUintFromU4Array (valuebounds, 3); } (void) StdAsciiWriteSu (fcb, " TYPE UINT MIN "); (void) StdAsciiWriteU4 (fcb, uminh); (void) StdAsciiWriteSu (fcb, " "); (void) StdAsciiWriteU4 (fcb, uminl); (void) StdAsciiWriteSu (fcb, " MAX "); (void) StdAsciiWriteU4 (fcb, umaxh); (void) StdAsciiWriteSu (fcb, " "); (void) StdAsciiWriteU4 (fcb, umaxl); } else if (valuetype == VTF3_VALUETYPE_FLOAT) { fmin = LoadDoubleFromU4Array (valuebounds, 0); fmax = LoadDoubleFromU4Array (valuebounds, 2); (void) StdAsciiWriteSu (fcb, " TYPE FLOAT MIN "); (void) StdAsciiWriteF8 (fcb, fmin); (void) StdAsciiWriteSu (fcb, " MAX "); (void) StdAsciiWriteF8 (fcb, fmax); } else { (void) fprintf (stderr, "VTF3: Bad value type to " "VTF3_ComposeDefcpureg()\n"); (void) fflush (stderr); (void) exit (127); } (void) StdAsciiWriteSu (fcb, " NAME \""); (void) StdAsciiWriteSp (fcb, cpuregname); (void) StdAsciiWriteSu (fcb, "\" UNIT \""); (void) StdAsciiWriteSp (fcb, cpuregunit); (void) StdAsciiWriteSu (fcb, "\""); return (StdAsciiWriteEp (fcb, VTF3_RECTYPE_DEFCPUREG)); } VTF3_rec_t * VTF3_ComposeDefcpuregclass (void *fcbcaller, int cpuregclasstoken, const char *cpuregclassname) { fcb_t *fcb; fcb = (fcb_t *) fcbcaller; (void) CheckFcbOut (fcb); if (fcb->fileformat == VTF3_FILEFORMAT_STD_BINARY) { fcb->recbufferpos = fcb->recbuffer + 6; VTF3_STDBINARYCOMPOSE_WRITEI4 (cpuregclasstoken); (void) StdBinaryWriteSv (fcb, cpuregclassname); return (StdBinaryWriteEp (fcb, VTF3_RECTYPE_DEFCPUREGCLASS)); } fcb->recbufferpos = fcb->recbuffer + 0; (void) StdAsciiWriteSu (fcb, "DEFCPUREGCLASS "); (void) StdAsciiWriteI4 (fcb, cpuregclasstoken); (void) StdAsciiWriteSu (fcb, " \""); (void) StdAsciiWriteSp (fcb, cpuregclassname); (void) StdAsciiWriteSu (fcb, "\""); return (StdAsciiWriteEp (fcb, VTF3_RECTYPE_DEFCPUREGCLASS)); } VTF3_rec_t * VTF3_ComposeDefcreator (void *fcbcaller, const char *creator) { fcb_t *fcb; fcb = (fcb_t *) fcbcaller; (void) CheckFcbOut (fcb); if (fcb->fileformat == VTF3_FILEFORMAT_STD_BINARY) { fcb->recbufferpos = fcb->recbuffer + 6; (void) StdBinaryWriteSv (fcb, creator); return (StdBinaryWriteEp (fcb, VTF3_RECTYPE_DEFCREATOR)); } fcb->recbufferpos = fcb->recbuffer + 0; (void) StdAsciiWriteSu (fcb, "CREATOR \""); (void) StdAsciiWriteSp (fcb, creator); (void) StdAsciiWriteSu (fcb, "\""); return (StdAsciiWriteEp (fcb, VTF3_RECTYPE_DEFCREATOR)); } VTF3_rec_t * VTF3_ComposeDefdatastruc (void *fcbcaller, int datastructoken, const char *datastrucname, int scltoken) { fcb_t *fcb; /*check the fcb */ fcb = (fcb_t *) fcbcaller; (void) CheckFcbOut (fcb); /*some checks of function arguments */ if (datastrucname == 0) { (void) fprintf (stderr, "VTF3: NULL as data structure name to " "VTF3_ComposeDefdatastruc()\n"); (void) fflush (stderr); (void) exit (127); } if (scltoken == VTF3_SCLNONE) { (void) fprintf (stderr, "VTF3: No source code location for data structure given to " "VTF3_ComposeDefdatastruc()\n"); (void) fflush (stderr); (void) exit (127); } /*binary format */ if (fcb->fileformat == VTF3_FILEFORMAT_STD_BINARY) { fcb->recbufferpos = fcb->recbuffer + 6; VTF3_STDBINARYCOMPOSE_WRITEI4 (datastructoken); VTF3_STDBINARYCOMPOSE_WRITEI4 (scltoken); (void) StdBinaryWriteSv (fcb, datastrucname); return (StdBinaryWriteEp (fcb, VTF3_RECTYPE_DEFDATASTRUC)); } /*ASCII format */ fcb->recbufferpos = fcb->recbuffer + 0; (void) StdAsciiWriteSu (fcb, "DEFDATASTRUC "); (void) StdAsciiWriteI4 (fcb, datastructoken); if (scltoken == VTF3_SCLRESET) (void) StdAsciiWriteSu (fcb, " SCL RESET"); else { (void) StdAsciiWriteSu (fcb, " SCL "); (void) StdAsciiWriteI4 (fcb, scltoken); } (void) StdAsciiWriteSu (fcb, " \""); (void) StdAsciiWriteSp (fcb, datastrucname); (void) StdAsciiWriteSu (fcb, "\""); return (StdAsciiWriteEp (fcb, VTF3_RECTYPE_DEFDATASTRUC)); } VTF3_rec_t * VTF3_ComposeDefglobalop (void *fcbcaller, int globaloptoken, const char *globalopname) { fcb_t *fcb; fcb = (fcb_t *) fcbcaller; (void) CheckFcbOut (fcb); if (fcb->fileformat == VTF3_FILEFORMAT_STD_BINARY) { fcb->recbufferpos = fcb->recbuffer + 6; VTF3_STDBINARYCOMPOSE_WRITEI4 (globaloptoken); (void) StdBinaryWriteSv (fcb, globalopname); return (StdBinaryWriteEp (fcb, VTF3_RECTYPE_DEFGLOBALOP)); } fcb->recbufferpos = fcb->recbuffer + 0; (void) StdAsciiWriteSu (fcb, "GLOBALOPTOKEN "); (void) StdAsciiWriteI4 (fcb, globaloptoken); (void) StdAsciiWriteSu (fcb, " \""); (void) StdAsciiWriteSp (fcb, globalopname); (void) StdAsciiWriteSu (fcb, "\""); return (StdAsciiWriteEp (fcb, VTF3_RECTYPE_DEFGLOBALOP)); } VTF3_rec_t * VTF3_ComposeDefhist (void *fcbcaller, int histtoken, int nrelements, int histgrp, const char *histname) { fcb_t *fcb; fcb = (fcb_t *) fcbcaller; (void) CheckFcbOut (fcb); /*initial checks */ if ( nrelements < 0) { (void) fprintf (stderr, "VTF3: Bad dimension value %d to " "VTF3_ComposeDefhist()\n", nrelements); (void) fflush (stderr); (void) exit (127); } /*binary format */ if (fcb->fileformat == VTF3_FILEFORMAT_STD_BINARY) { fcb->recbufferpos = fcb->recbuffer + 6; VTF3_STDBINARYCOMPOSE_WRITEI4 (histtoken); VTF3_STDBINARYCOMPOSE_WRITEI4 (histgrp); VTF3_STDBINARYCOMPOSE_WRITEI4 (nrelements); (void) StdBinaryWriteSv (fcb, histname); return (StdBinaryWriteEp (fcb, VTF3_RECTYPE_DEFHIST)); } /*ASCII format */ fcb->recbufferpos = fcb->recbuffer + 0; (void) StdAsciiWriteSu (fcb, "DEFHIST "); (void) StdAsciiWriteI4 (fcb, histtoken); (void) StdAsciiWriteSu (fcb, " HGRP "); (void) StdAsciiWriteI4 (fcb, histgrp); (void) StdAsciiWriteSu (fcb, " NBINS "); (void) StdAsciiWriteI4 (fcb, nrelements); (void) StdAsciiWriteSu (fcb, " \""); (void) StdAsciiWriteSp (fcb, histname); (void) StdAsciiWriteSu (fcb, "\""); return (StdAsciiWriteEp (fcb, VTF3_RECTYPE_DEFHIST)); } VTF3_rec_t * VTF3_ComposeDefhistgrp (void *fcbcaller, int histgrptoken, const char *histgrpname) { fcb_t *fcb; fcb = (fcb_t *) fcbcaller; (void) CheckFcbOut (fcb); /*binary format */ if (fcb->fileformat == VTF3_FILEFORMAT_STD_BINARY) { fcb->recbufferpos = fcb->recbuffer + 6; VTF3_STDBINARYCOMPOSE_WRITEI4 (histgrptoken); (void) StdBinaryWriteSv (fcb, histgrpname); return (StdBinaryWriteEp (fcb, VTF3_RECTYPE_DEFHISTGRP)); } /*ASCII format */ fcb->recbufferpos = fcb->recbuffer + 0; (void) StdAsciiWriteSu (fcb, "DEFHISTGRP "); (void) StdAsciiWriteI4 (fcb, histgrptoken); (void) StdAsciiWriteSu (fcb, " \""); (void) StdAsciiWriteSp (fcb, histgrpname); (void) StdAsciiWriteSu (fcb, "\""); return (StdAsciiWriteEp (fcb, VTF3_RECTYPE_DEFHISTGRP)); } VTF3_rec_t * VTF3_ComposeDefiofile (void *fcbcaller, int iofiletoken, int communicator, const char *iofilename) { fcb_t *fcb; fcb = (fcb_t *) fcbcaller; (void) CheckFcbOut (fcb); if (fcb->fileformat == VTF3_FILEFORMAT_STD_BINARY) { fcb->recbufferpos = fcb->recbuffer + 6; VTF3_STDBINARYCOMPOSE_WRITEI4 (iofiletoken); VTF3_STDBINARYCOMPOSE_WRITEI4 (communicator); (void) StdBinaryWriteSv (fcb, iofilename); return (StdBinaryWriteEp (fcb, VTF3_RECTYPE_DEFIOFILE)); } fcb->recbufferpos = fcb->recbuffer + 0; (void) StdAsciiWriteSu (fcb, "IOFILE "); (void) StdAsciiWriteI4 (fcb, iofiletoken); #if (defined (VTF3_LEGACY_OUTPUT)) (void) StdAsciiWriteSu (fcb, " "); (void) StdAsciiWriteI4 (fcb, communicator); #else if (communicator != VTF3_NOCOMMUNICATOR) { (void) StdAsciiWriteSu (fcb, " COM "); (void) StdAsciiWriteI4 (fcb, communicator); } #endif (void) StdAsciiWriteSu (fcb, " \""); (void) StdAsciiWriteSp (fcb, iofilename); (void) StdAsciiWriteSu (fcb, "\""); return (StdAsciiWriteEp (fcb, VTF3_RECTYPE_DEFIOFILE)); } VTF3_rec_t * VTF3_ComposeDefkparreg (void *fcbcaller, int kparregtoken, const char *kparregname) { fcb_t *fcb; fcb = (fcb_t *) fcbcaller; (void) CheckFcbOut (fcb); if (fcb->fileformat == VTF3_FILEFORMAT_STD_BINARY) { fcb->recbufferpos = fcb->recbuffer + 6; VTF3_STDBINARYCOMPOSE_WRITEI4 (kparregtoken); (void) StdBinaryWriteSv (fcb, kparregname); return (StdBinaryWriteEp (fcb, VTF3_RECTYPE_DEFKPARREG)); } fcb->recbufferpos = fcb->recbuffer + 0; (void) StdAsciiWriteSu (fcb, "DEFKPARREG "); (void) StdAsciiWriteI4 (fcb, kparregtoken); (void) StdAsciiWriteSu (fcb, " \""); (void) StdAsciiWriteSp (fcb, kparregname); (void) StdAsciiWriteSu (fcb, "\""); return (StdAsciiWriteEp (fcb, VTF3_RECTYPE_DEFKPARREG)); } VTF3_rec_t * VTF3_ComposeDefmsgname (void *fcbcaller, int msgtype, int communicator, const char *msgname) { fcb_t *fcb; fcb = (fcb_t *) fcbcaller; (void) CheckFcbOut (fcb); if (fcb->fileformat == VTF3_FILEFORMAT_STD_BINARY) { fcb->recbufferpos = fcb->recbuffer + 6; VTF3_STDBINARYCOMPOSE_WRITEI4 (msgtype); (void) StdBinaryWriteSv (fcb, msgname); if (communicator != VTF3_NOCOMMUNICATOR) { VTF3_STDBINARYCOMPOSE_WRITEI4 (communicator); } return (StdBinaryWriteEp (fcb, VTF3_RECTYPE_DEFMSGNAME)); } fcb->recbufferpos = fcb->recbuffer + 0; (void) StdAsciiWriteSu (fcb, "MSGTYPE "); #if (defined (VTF3_LEGACY_OUTPUT)) if (communicator != VTF3_NOCOMMUNICATOR) { (void) StdAsciiWriteI4 (fcb, communicator); (void) StdAsciiWriteSu (fcb, " "); } (void) StdAsciiWriteI4 (fcb, msgtype); #else (void) StdAsciiWriteI4 (fcb, msgtype); if (communicator != VTF3_NOCOMMUNICATOR) { (void) StdAsciiWriteSu (fcb, " COM "); (void) StdAsciiWriteI4 (fcb, communicator); } #endif (void) StdAsciiWriteSu (fcb, " \""); (void) StdAsciiWriteSp (fcb, msgname); (void) StdAsciiWriteSu (fcb, "\""); return (StdAsciiWriteEp (fcb, VTF3_RECTYPE_DEFMSGNAME)); } VTF3_rec_t * VTF3_ComposeDefopenmpname (void *fcbcaller, unsigned int nametoken, const char *openmpname) { fcb_t *fcb; fcb = (fcb_t *) fcbcaller; (void) CheckFcbOut (fcb); if (fcb->fileformat == VTF3_FILEFORMAT_STD_BINARY) { fcb->recbufferpos = fcb->recbuffer + 6; VTF3_STDBINARYCOMPOSE_WRITEU4 (nametoken); (void) StdBinaryWriteSv (fcb, openmpname); return (StdBinaryWriteEp (fcb, VTF3_RECTYPE_DEFOPENMPNAME)); } fcb->recbufferpos = fcb->recbuffer + 0; (void) StdAsciiWriteSu (fcb, "DEFOPENMPNAME "); (void) StdAsciiWriteU4 (fcb, nametoken); (void) StdAsciiWriteSu (fcb, " \""); (void) StdAsciiWriteSp (fcb, openmpname); (void) StdAsciiWriteSu (fcb, "\""); return (StdAsciiWriteEp (fcb, VTF3_RECTYPE_DEFOPENMPNAME)); } VTF3_rec_t * VTF3_ComposeDefopenmptype (void *fcbcaller, unsigned int constructtypetoken, const char *constructtypename) { fcb_t *fcb; fcb = (fcb_t *) fcbcaller; (void) CheckFcbOut (fcb); if (fcb->fileformat == VTF3_FILEFORMAT_STD_BINARY) { fcb->recbufferpos = fcb->recbuffer + 6; VTF3_STDBINARYCOMPOSE_WRITEU4 (constructtypetoken); (void) StdBinaryWriteSv (fcb, constructtypename); return (StdBinaryWriteEp (fcb, VTF3_RECTYPE_DEFOPENMPTYPE)); } fcb->recbufferpos = fcb->recbuffer + 0; #if (defined (VTF3_LEGACY_OUTPUT)) (void) StdAsciiWriteSu (fcb, "DEFOPENMP ID "); (void) StdAsciiWriteU4 (fcb, constructtypetoken); (void) StdAsciiWriteSu (fcb, " NAME \""); #else (void) StdAsciiWriteSu (fcb, "DEFOPENMP "); (void) StdAsciiWriteU4 (fcb, constructtypetoken); (void) StdAsciiWriteSu (fcb, " \""); #endif (void) StdAsciiWriteSp (fcb, constructtypename); (void) StdAsciiWriteSu (fcb, "\""); return (StdAsciiWriteEp (fcb, VTF3_RECTYPE_DEFOPENMPTYPE)); } VTF3_rec_t * VTF3_ComposeDefpattern (void *fcbcaller, int activitytoken, int pattoken, int patshptoken, double radius, int ratio, int timesteparraydim, const double *timesteparray) { fcb_t *fcb; int i; fcb = (fcb_t *) fcbcaller; (void) CheckFcbOut (fcb); if (activitytoken == VTF3_NOACT) { (void) fprintf (stderr, "VTF3: Bad value %d as activity token to " "VTF3_ComposeDefpattern()\n", VTF3_NOACT); (void) fflush (stderr); (void) exit (127); } if (pattoken == VTF3_NOSTATE) { (void) fprintf (stderr, "VTF3: Bad value %d as pattern token to " "VTF3_ComposeDefpattern()\n", VTF3_NOSTATE); (void) fflush (stderr); (void) exit (127); } if (patshptoken == VTF3_NOSTATE) { (void) fprintf (stderr, "VTF3: Bad value %d as pattern shape token to " "VTF3_ComposeDefpattern()\n", VTF3_NOSTATE); (void) fflush (stderr); (void) exit (127); } if (SignOfDouble (radius) < 0) { (void) fprintf (stderr, "VTF3: Negative radius to " "VTF3_ComposeDefpattern()\n"); (void) fflush (stderr); (void) exit (127); } if (ratio < 0) { (void) fprintf (stderr, "VTF3: Negative ratio value %d to " "VTF3_ComposeDefpattern()\n", ratio); (void) fflush (stderr); (void) exit (127); } if (timesteparraydim < 0) { (void) fprintf (stderr, "VTF3: Bad dimension value %d to " "VTF3_ComposeDefpattern()\n", timesteparraydim); (void) fflush (stderr); (void) exit (127); } if (fcb->fileformat == VTF3_FILEFORMAT_STD_BINARY) { fcb->recbufferpos = fcb->recbuffer + 6; VTF3_STDBINARYCOMPOSE_WRITEI4 (activitytoken); VTF3_STDBINARYCOMPOSE_WRITEI4 (pattoken); VTF3_STDBINARYCOMPOSE_WRITEI4 (patshptoken); (void) StdBinaryWriteTs (fcb, radius); VTF3_STDBINARYCOMPOSE_WRITEI4 (ratio); for (i = 0; i < timesteparraydim; i++) { if (SignOfDouble (*(timesteparray + i)) < 0) { (void) fprintf (stderr, "VTF3: Negative time step [%d] to " "VTF3_ComposeDefpattern()\n", i); (void) fflush (stderr); (void) exit (127); } (void) StdBinaryWriteTs (fcb, *(timesteparray + i)); } return (StdBinaryWriteEp (fcb, VTF3_RECTYPE_DEFPATTERN)); } fcb->recbufferpos = fcb->recbuffer + 0; (void) StdAsciiWriteSu (fcb, "DEFPATTERN "); (void) StdAsciiWriteI4 (fcb, pattoken); (void) StdAsciiWriteSu (fcb, " ACT "); (void) StdAsciiWriteI4 (fcb, activitytoken); (void) StdAsciiWriteSu (fcb, " SHAPE "); (void) StdAsciiWriteI4 (fcb, patshptoken); (void) StdAsciiWriteSu (fcb, " RADIUS "); (void) StdAsciiWriteTs (fcb, radius); (void) StdAsciiWriteSu (fcb, " RATIO "); (void) StdAsciiWriteI4 (fcb, ratio); (void) StdAsciiWriteSu (fcb, " NTSTEPS "); (void) StdAsciiWriteI4 (fcb, timesteparraydim); if (timesteparraydim > 0) (void) StdAsciiWriteSu (fcb, " TSTEPS"); for (i = 0; i < timesteparraydim; i++) { (void) StdAsciiWriteSu (fcb, " "); if (SignOfDouble (*(timesteparray + i)) < 0) { (void) fprintf (stderr, "VTF3: Negative time step [%d] to " "VTF3_ComposeDefpattern()\n", i); (void) fflush (stderr); (void) exit (127); } (void) StdAsciiWriteTs (fcb, *(timesteparray + i)); } return (StdAsciiWriteEp (fcb, VTF3_RECTYPE_DEFPATTERN)); } VTF3_rec_t * VTF3_ComposeDefpatternshape (void *fcbcaller, int activitytoken, int patshptoken, int patterntype, int patshptokenbref1, int patshptokenbref2) { static const char *patterntypename [] = VTF3_PATTERNTYPENAME_INIT; fcb_t *fcb; fcb = (fcb_t *) fcbcaller; (void) CheckFcbOut (fcb); if (activitytoken == VTF3_NOACT) { (void) fprintf (stderr, "VTF3: Bad value %d as activity token to " "VTF3_ComposeDefpatternshape()\n", VTF3_NOACT); (void) fflush (stderr); (void) exit (127); } if (patshptoken == VTF3_NOSTATE) { (void) fprintf (stderr, "VTF3: Bad value %d as pattern shape token to " "VTF3_ComposeDefpatternshape()\n", VTF3_NOSTATE); (void) fflush (stderr); (void) exit (127); } if (patterntype >= (int) (sizeof (patterntypename) / sizeof (patterntypename[0])) || patterntype < 0 || patterntype == VTF3_PATTERNTYPE_NOTYPE) { (void) fprintf (stderr, "VTF3: Bad value %d as pattern type to " "VTF3_ComposeDefpatternshape()\n", patterntype); (void) fflush (stderr); (void) exit (127); } if (patshptokenbref1 == VTF3_NOSTATE) { (void) fprintf (stderr, "VTF3: Bad value %d as 1-st pattern " "shape backwards-reference token to " "VTF3_ComposeDefpatternshape()\n", VTF3_NOSTATE); (void) fflush (stderr); (void) exit (127); } if (patshptokenbref2 == VTF3_NOSTATE) { (void) fprintf (stderr, "VTF3: Bad value %d as 2-nd pattern " "shape backwards-reference token to " "VTF3_ComposeDefpatternshape()\n", VTF3_NOSTATE); (void) fflush (stderr); (void) exit (127); } if (fcb->fileformat == VTF3_FILEFORMAT_STD_BINARY) { fcb->recbufferpos = fcb->recbuffer + 6; VTF3_STDBINARYCOMPOSE_WRITEI4 (activitytoken); VTF3_STDBINARYCOMPOSE_WRITEI4 (patshptoken); VTF3_STDBINARYCOMPOSE_WRITEI1 (patterntype); VTF3_STDBINARYCOMPOSE_WRITEI4 (patshptokenbref1); VTF3_STDBINARYCOMPOSE_WRITEI4 (patshptokenbref2); return (StdBinaryWriteEp (fcb, VTF3_RECTYPE_DEFPATTERNSHAPE)); } fcb->recbufferpos = fcb->recbuffer + 0; (void) StdAsciiWriteSu (fcb, "DEFPATTERNSHAPE "); (void) StdAsciiWriteI4 (fcb, patshptoken); (void) StdAsciiWriteSu (fcb, " ACT "); (void) StdAsciiWriteI4 (fcb, activitytoken); (void) StdAsciiWriteSu (fcb, " "); (void) StdAsciiWriteSp (fcb, patterntypename[patterntype]); (void) StdAsciiWriteSu (fcb, " "); (void) StdAsciiWriteI4 (fcb, patshptokenbref1); (void) StdAsciiWriteSu (fcb, " "); (void) StdAsciiWriteI4 (fcb, patshptokenbref2); return (StdAsciiWriteEp (fcb, VTF3_RECTYPE_DEFPATTERNSHAPE)); } VTF3_rec_t * VTF3_ComposeDefredfunc_obsol (void *fcbcaller, int redfunctoken, const char *redfuncname) { fcb_t *fcb; fcb = (fcb_t *) fcbcaller; (void) CheckFcbOut (fcb); if (fcb->fileformat == VTF3_FILEFORMAT_STD_BINARY) { fcb->recbufferpos = fcb->recbuffer + 6; VTF3_STDBINARYCOMPOSE_WRITEI4 (redfunctoken); (void) StdBinaryWriteSv (fcb, redfuncname); return (StdBinaryWriteEp (fcb, VTF3_RECTYPE_DEFREDFUNC_OBSOL)); } fcb->recbufferpos = fcb->recbuffer + 0; (void) StdAsciiWriteSu (fcb, "REDFUNC "); (void) StdAsciiWriteI4 (fcb, redfunctoken); (void) StdAsciiWriteSu (fcb, " \""); (void) StdAsciiWriteSp (fcb, redfuncname); (void) StdAsciiWriteSu (fcb, "\""); return (StdAsciiWriteEp (fcb, VTF3_RECTYPE_DEFREDFUNC_OBSOL)); } VTF3_rec_t * VTF3_ComposeDefsamp (void *fcbcaller, int sampletoken, int sampleclasstoken, int iscpugrpsamp, unsigned int cpuorcpugrpid, int valuetype, const void *valuebounds, int dodifferentiation, int datarephint, const char *samplename, const char *sampleunit) { fcb_t *fcb; unsigned int uminl, uminh, umaxl, umaxh; double fmin, fmax; fcb = (fcb_t *) fcbcaller; (void) CheckFcbOut (fcb); if (fcb->fileformat == VTF3_FILEFORMAT_STD_BINARY) { fcb->recbufferpos = fcb->recbuffer + 6; VTF3_STDBINARYCOMPOSE_WRITEI4 (sampletoken); VTF3_STDBINARYCOMPOSE_WRITEI4 (sampleclasstoken); if (iscpugrpsamp != 0) { VTF3_STDBINARYCOMPOSE_WRITEI1 (1); VTF3_STDBINARYCOMPOSE_WRITEU4 (cpuorcpugrpid | VTF3_CPUGRP_MASK); } else { VTF3_STDBINARYCOMPOSE_WRITEI1 (0); VTF3_STDBINARYCOMPOSE_WRITEU4 (cpuorcpugrpid); } VTF3_STDBINARYCOMPOSE_WRITEI1 (valuetype); if (valuetype == VTF3_VALUETYPE_UINT) { if (vtffprtype == VTF3_CONST_FPNRT_IEEE754_DOUBLE_LITEND) { uminl = LoadUintFromU4Array (valuebounds, 0); uminh = LoadUintFromU4Array (valuebounds, 1); umaxl = LoadUintFromU4Array (valuebounds, 2); umaxh = LoadUintFromU4Array (valuebounds, 3); } else { uminh = LoadUintFromU4Array (valuebounds, 0); uminl = LoadUintFromU4Array (valuebounds, 1); umaxh = LoadUintFromU4Array (valuebounds, 2); umaxl = LoadUintFromU4Array (valuebounds, 3); } VTF3_STDBINARYCOMPOSE_WRITEU4 (uminh); VTF3_STDBINARYCOMPOSE_WRITEU4 (uminl); VTF3_STDBINARYCOMPOSE_WRITEU4 (umaxh); VTF3_STDBINARYCOMPOSE_WRITEU4 (umaxl); } else if (valuetype == VTF3_VALUETYPE_FLOAT) { fmin = LoadDoubleFromU4Array (valuebounds, 0); fmax = LoadDoubleFromU4Array (valuebounds, 2); (void) StdBinaryWriteF8 (fcb, fmin); (void) StdBinaryWriteF8 (fcb, fmax); } else { (void) fprintf (stderr, "VTF3: Bad value type to " "VTF3_ComposeDefsamp()\n"); (void) fflush (stderr); (void) exit (127); } VTF3_STDBINARYCOMPOSE_WRITEI1 ((dodifferentiation != 0 ? 1 : 0)); VTF3_STDBINARYCOMPOSE_WRITEI4 (datarephint); (void) StdBinaryWriteSv (fcb, samplename); (void) StdBinaryWriteSv (fcb, sampleunit); return (StdBinaryWriteEp (fcb, VTF3_RECTYPE_DEFSAMP)); } fcb->recbufferpos = fcb->recbuffer + 0; (void) StdAsciiWriteSu (fcb, "DEFSAMP "); (void) StdAsciiWriteI4 (fcb, sampletoken); (void) StdAsciiWriteSu (fcb, " CLASS "); (void) StdAsciiWriteI4 (fcb, sampleclasstoken); #if (defined (VTF3_LEGACY_OUTPUT)) if (iscpugrpsamp != 0) { (void) StdAsciiWriteSu (fcb, " GROUPSAMP FOR "); (void) StdAsciiWriteU4 (fcb, (cpuorcpugrpid | VTF3_CPUGRP_MASK) + 1); } else { (void) StdAsciiWriteSu (fcb, " CPUSAMP FOR "); (void) StdAsciiWriteU4 (fcb, cpuorcpugrpid + 1); } #else if (iscpugrpsamp != 0) { (void) StdAsciiWriteSu (fcb, " GROUPSAMP FOR "); (void) StdAsciiWriteU4 (fcb, (cpuorcpugrpid | VTF3_CPUGRP_MASK)); } else { (void) StdAsciiWriteSu (fcb, " CPUSAMP FOR "); (void) StdAsciiWriteU4 (fcb, cpuorcpugrpid); } #endif if (valuetype == VTF3_VALUETYPE_UINT) { if (vtffprtype == VTF3_CONST_FPNRT_IEEE754_DOUBLE_LITEND) { uminl = LoadUintFromU4Array (valuebounds, 0); uminh = LoadUintFromU4Array (valuebounds, 1); umaxl = LoadUintFromU4Array (valuebounds, 2); umaxh = LoadUintFromU4Array (valuebounds, 3); } else { uminh = LoadUintFromU4Array (valuebounds, 0); uminl = LoadUintFromU4Array (valuebounds, 1); umaxh = LoadUintFromU4Array (valuebounds, 2); umaxl = LoadUintFromU4Array (valuebounds, 3); } (void) StdAsciiWriteSu (fcb, " TYPE UINT MIN "); (void) StdAsciiWriteU4 (fcb, uminh); (void) StdAsciiWriteSu (fcb, " "); (void) StdAsciiWriteU4 (fcb, uminl); (void) StdAsciiWriteSu (fcb, " MAX "); (void) StdAsciiWriteU4 (fcb, umaxh); (void) StdAsciiWriteSu (fcb, " "); (void) StdAsciiWriteU4 (fcb, umaxl); } else if (valuetype == VTF3_VALUETYPE_FLOAT) { fmin = LoadDoubleFromU4Array (valuebounds, 0); fmax = LoadDoubleFromU4Array (valuebounds, 2); (void) StdAsciiWriteSu (fcb, " TYPE FLOAT MIN "); (void) StdAsciiWriteF8 (fcb, fmin); (void) StdAsciiWriteSu (fcb, " MAX "); (void) StdAsciiWriteF8 (fcb, fmax); } else { (void) fprintf (stderr, "VTF3: Bad value type to " "VTF3_ComposeDefsamp()\n"); (void) fflush (stderr); (void) exit (127); } if (dodifferentiation != 0) (void) StdAsciiWriteSu (fcb, " DIFF 1 RHINT "); else (void) StdAsciiWriteSu (fcb, " DIFF 0 RHINT "); (void) StdAsciiWriteI4 (fcb, datarephint); (void) StdAsciiWriteSu (fcb, " NAME \""); (void) StdAsciiWriteSp (fcb, samplename); (void) StdAsciiWriteSu (fcb, "\" UNIT \""); (void) StdAsciiWriteSp (fcb, sampleunit); (void) StdAsciiWriteSu (fcb, "\""); return (StdAsciiWriteEp (fcb, VTF3_RECTYPE_DEFSAMP)); } VTF3_rec_t * VTF3_ComposeDefsampclass (void *fcbcaller, int sampleclasstoken, const char *sampleclassname) { fcb_t *fcb; fcb = (fcb_t *) fcbcaller; (void) CheckFcbOut (fcb); if (fcb->fileformat == VTF3_FILEFORMAT_STD_BINARY) { fcb->recbufferpos = fcb->recbuffer + 6; VTF3_STDBINARYCOMPOSE_WRITEI4 (sampleclasstoken); (void) StdBinaryWriteSv (fcb, sampleclassname); return (StdBinaryWriteEp (fcb, VTF3_RECTYPE_DEFSAMPCLASS)); } fcb->recbufferpos = fcb->recbuffer + 0; (void) StdAsciiWriteSu (fcb, "DEFSAMPCLASS "); (void) StdAsciiWriteI4 (fcb, sampleclasstoken); (void) StdAsciiWriteSu (fcb, " \""); (void) StdAsciiWriteSp (fcb, sampleclassname); (void) StdAsciiWriteSu (fcb, "\""); return (StdAsciiWriteEp (fcb, VTF3_RECTYPE_DEFSAMPCLASS)); } VTF3_rec_t * VTF3_ComposeDefscl (void *fcbcaller, int scltoken, int sclarraydim, const int *sclfiletokenarray, const int *scllinepositionarray) { fcb_t *fcb; int i; fcb = (fcb_t *) fcbcaller; (void) CheckFcbOut (fcb); if (sclarraydim < 0) { (void) fprintf (stderr, "VTF3: Bad dimension value %d to " "VTF3_ComposeDefscl()\n", sclarraydim); (void) fflush (stderr); (void) exit (127); } if (scltoken == VTF3_SCLNONE || scltoken == VTF3_SCLRESET) { (void) fprintf (stderr, "VTF3: Bad SCL token value %d to " "VTF3_ComposeDefscl()\n", scltoken); (void) fflush (stderr); (void) exit (127); } if (fcb->fileformat == VTF3_FILEFORMAT_STD_BINARY) { fcb->recbufferpos = fcb->recbuffer + 6; VTF3_STDBINARYCOMPOSE_WRITEI4 (scltoken); for (i = 0; i < sclarraydim; i++) { VTF3_STDBINARYCOMPOSE_WRITEI4 (*(sclfiletokenarray + i)); VTF3_STDBINARYCOMPOSE_WRITEI4 (*(scllinepositionarray + i)); } return (StdBinaryWriteEp (fcb, VTF3_RECTYPE_DEFSCL)); } fcb->recbufferpos = fcb->recbuffer + 0; (void) StdAsciiWriteSu (fcb, "DEFSCL "); (void) StdAsciiWriteI4 (fcb, scltoken); (void) StdAsciiWriteSu (fcb, " NLOCS "); (void) StdAsciiWriteI4 (fcb, sclarraydim); if (sclarraydim > 0) (void) StdAsciiWriteSu (fcb, " LOCS"); for (i = 0; i < sclarraydim; i++) { (void) StdAsciiWriteSu (fcb, " "); (void) StdAsciiWriteI4 (fcb, *(sclfiletokenarray + i)); (void) StdAsciiWriteSu (fcb, ":"); (void) StdAsciiWriteI4 (fcb, *(scllinepositionarray + i)); } return (StdAsciiWriteEp (fcb, VTF3_RECTYPE_DEFSCL)); } VTF3_rec_t * VTF3_ComposeDefsclfile (void *fcbcaller, int sclfiletoken, const char *sclfilename) { fcb_t *fcb; fcb = (fcb_t *) fcbcaller; (void) CheckFcbOut (fcb); if (fcb->fileformat == VTF3_FILEFORMAT_STD_BINARY) { fcb->recbufferpos = fcb->recbuffer + 6; VTF3_STDBINARYCOMPOSE_WRITEI4 (sclfiletoken); (void) StdBinaryWriteSv (fcb, sclfilename); return (StdBinaryWriteEp (fcb, VTF3_RECTYPE_DEFSCLFILE)); } fcb->recbufferpos = fcb->recbuffer + 0; (void) StdAsciiWriteSu (fcb, "FILETOKEN "); (void) StdAsciiWriteI4 (fcb, sclfiletoken); (void) StdAsciiWriteSu (fcb, " \""); (void) StdAsciiWriteSp (fcb, sclfilename); (void) StdAsciiWriteSu (fcb, "\""); return (StdAsciiWriteEp (fcb, VTF3_RECTYPE_DEFSCLFILE)); } VTF3_rec_t * VTF3_ComposeDefstate (void *fcbcaller, int activitytoken, int statetoken, const char *statename, int scltoken) { static const char *noact = "NOACT"; fcb_t *fcb; int isnoact, i; fcb = (fcb_t *) fcbcaller; (void) CheckFcbOut (fcb); if (activitytoken == VTF3_NOACT) { (void) fprintf (stderr, "VTF3: Bad value %d as activity token to " "VTF3_ComposeDefstate()\n", VTF3_NOACT); (void) fflush (stderr); (void) exit (127); } if (statetoken == VTF3_NOSTATE) { (void) fprintf (stderr, "VTF3: Bad value %d as state token to " "VTF3_ComposeDefstate()\n", VTF3_NOSTATE); (void) fflush (stderr); (void) exit (127); } if (statename == 0) { (void) fprintf (stderr, "VTF3: NULL as state name to " "VTF3_ComposeDefstate()\n"); (void) fflush (stderr); (void) exit (127); } isnoact = 1; for (i = 0; i < 6; i++) if (*(statename + i) != *(noact + i)) { isnoact = 0; break; } if (isnoact != 0) { (void) fprintf (stderr, "VTF3: NOACT as state name to " "VTF3_ComposeDefstate()\n"); (void) fflush (stderr); (void) exit (127); } if (fcb->fileformat == VTF3_FILEFORMAT_STD_BINARY) { fcb->recbufferpos = fcb->recbuffer + 6; VTF3_STDBINARYCOMPOSE_WRITEI4 (activitytoken); VTF3_STDBINARYCOMPOSE_WRITEI4 (statetoken); (void) StdBinaryWriteSv (fcb, statename); if (scltoken != VTF3_SCLNONE) { VTF3_STDBINARYCOMPOSE_WRITEI4 (scltoken); } return (StdBinaryWriteEp (fcb, VTF3_RECTYPE_DEFSTATE)); } fcb->recbufferpos = fcb->recbuffer + 0; (void) StdAsciiWriteSu (fcb, "DEFSTATE "); (void) StdAsciiWriteI4 (fcb, statetoken); (void) StdAsciiWriteSu (fcb, " ACT "); (void) StdAsciiWriteI4 (fcb, activitytoken); (void) StdAsciiWriteSu (fcb, " \""); (void) StdAsciiWriteSp (fcb, statename); (void) StdAsciiWriteSu (fcb, "\""); if (scltoken == VTF3_SCLRESET) (void) StdAsciiWriteSu (fcb, " SCL RESET"); else if (scltoken != VTF3_SCLNONE) { (void) StdAsciiWriteSu (fcb, " SCL "); (void) StdAsciiWriteI4 (fcb, scltoken); } return (StdAsciiWriteEp (fcb, VTF3_RECTYPE_DEFSTATE)); } VTF3_rec_t * VTF3_ComposeDefstate_obsol (void *fcbcaller, int activitytoken, const char *activityname, unsigned int activityvalidity, int statetoken, const char *statename) { static const char *noact = "NOACT"; fcb_t *fcb; int isnoact, i; fcb = (fcb_t *) fcbcaller; (void) CheckFcbOut (fcb); if (statetoken == VTF3_NOSTATE) { (void) fprintf (stderr, "VTF3: Bad value %d as state token to " "VTF3_ComposeDefstate_obsol()\n", VTF3_NOSTATE); (void) fflush (stderr); (void) exit (127); } if (statename == 0) { (void) fprintf (stderr, "VTF3: NULL as state name to " "VTF3_ComposeDefstate_obsol()\n"); (void) fflush (stderr); (void) exit (127); } isnoact = 1; for (i = 0; i < 6; i++) if (*(statename + i) != *(noact + i)) { isnoact = 0; break; } if (isnoact != 0) { (void) fprintf (stderr, "VTF3: NOACT as state name to " "VTF3_ComposeDefstate_obsol()\n"); (void) fflush (stderr); (void) exit (127); } if (fcb->fileformat == VTF3_FILEFORMAT_STD_BINARY) { if ((activityvalidity & VTF3_OLDACT_VALID_TOKEN) == 0) { (void) fprintf (stderr, "VTF3: Invalid activity token to " "VTF3_ComposeDefstate_obsol(), " "needs higher level tokenization/" "retokenization support\n"); (void) fflush (stderr); (void) exit (127); } if (activitytoken == VTF3_NOACT) { (void) fprintf (stderr, "VTF3: Bad value %d as activity token to " "VTF3_ComposeDefstate_obsol()\n", VTF3_NOACT); (void) fflush (stderr); (void) exit (127); } fcb->recbufferpos = fcb->recbuffer + 6; VTF3_STDBINARYCOMPOSE_WRITEI4 (activitytoken); VTF3_STDBINARYCOMPOSE_WRITEI4 (statetoken); (void) StdBinaryWriteSv (fcb, statename); return (StdBinaryWriteEp (fcb, VTF3_RECTYPE_DEFSTATE_OBSOL)); } if ((activityvalidity & VTF3_OLDACT_VALID_NAME) == 0) { (void) fprintf (stderr, "VTF3: Invalid activity name to " "VTF3_ComposeDefstate_obsol(), " "needs higher level tokenization/" "retokenization support\n"); (void) fflush (stderr); (void) exit (127); } if (activityname == 0) { (void) fprintf (stderr, "VTF3: NULL as activity name to " "VTF3_ComposeDefstate_obsol()\n"); (void) fflush (stderr); (void) exit (127); } isnoact = 1; for (i = 0; i < 6; i++) if (*(activityname + i) != *(noact + i)) { isnoact = 0; break; } if (isnoact != 0) { (void) fprintf (stderr, "VTF3: NOACT as activity name to " "VTF3_ComposeDefstate_obsol()\n"); (void) fflush (stderr); (void) exit (127); } fcb->recbufferpos = fcb->recbuffer + 0; (void) StdAsciiWriteSu (fcb, "SYMBOL \""); (void) StdAsciiWriteSp (fcb, activityname); (void) StdAsciiWriteSu (fcb, "\" "); (void) StdAsciiWriteI4 (fcb, statetoken); (void) StdAsciiWriteSu (fcb, " \""); (void) StdAsciiWriteSp (fcb, statename); (void) StdAsciiWriteSu (fcb, "\""); return (StdAsciiWriteEp (fcb, VTF3_RECTYPE_DEFSTATE_OBSOL)); } VTF3_rec_t * VTF3_ComposeDefsyscpunames (void *fcbcaller, int systemcpunamearraydim, char * const *systemcpunamearray) { fcb_t *fcb; int i; fcb = (fcb_t *) fcbcaller; (void) CheckFcbOut (fcb); if (systemcpunamearraydim < 0) { (void) fprintf (stderr, "VTF3: Bad dimension value %d to " "VTF3_ComposeDefsyscpunames()\n", systemcpunamearraydim); (void) fflush (stderr); (void) exit (127); } if (fcb->fileformat == VTF3_FILEFORMAT_STD_BINARY) { fcb->recbufferpos = fcb->recbuffer + 6; VTF3_STDBINARYCOMPOSE_WRITEI4 (systemcpunamearraydim); for (i = 0; i < systemcpunamearraydim; i++) (void) StdBinaryWriteSv (fcb, *(systemcpunamearray + i)); return (StdBinaryWriteEp (fcb, VTF3_RECTYPE_DEFSYSCPUNAMES)); } fcb->recbufferpos = fcb->recbuffer + 0; (void) StdAsciiWriteSu (fcb, "CPUNAMES"); for (i = 0; i < systemcpunamearraydim; i++) { (void) StdAsciiWriteSu (fcb, " \""); (void) StdAsciiWriteSp (fcb, *(systemcpunamearray + i)); (void) StdAsciiWriteSu (fcb, "\""); } return (StdAsciiWriteEp (fcb, VTF3_RECTYPE_DEFSYSCPUNAMES)); } VTF3_rec_t * VTF3_ComposeDefsyscpunums (void *fcbcaller, int systemcpunumberarraydim, const int *systemcpunumberarray) { fcb_t *fcb; int i; fcb = (fcb_t *) fcbcaller; (void) CheckFcbOut (fcb); if (systemcpunumberarraydim < 0) { (void) fprintf (stderr, "VTF3: Bad dimension value %d to " "VTF3_ComposeDefsyscpunums()\n", systemcpunumberarraydim); (void) fflush (stderr); (void) exit (127); } if (fcb->fileformat == VTF3_FILEFORMAT_STD_BINARY) { fcb->recbufferpos = fcb->recbuffer + 6; VTF3_STDBINARYCOMPOSE_WRITEI4 (systemcpunumberarraydim); for (i = 0; i < systemcpunumberarraydim; i++) { VTF3_STDBINARYCOMPOSE_WRITEI4 (*(systemcpunumberarray + i)); } return (StdBinaryWriteEp (fcb, VTF3_RECTYPE_DEFSYSCPUNUMS)); } fcb->recbufferpos = fcb->recbuffer + 0; (void) StdAsciiWriteSu (fcb, "NCPUS"); for (i = 0; i < systemcpunumberarraydim; i++) { (void) StdAsciiWriteSu (fcb, " "); (void) StdAsciiWriteI4 (fcb, *(systemcpunumberarray + i)); } return (StdAsciiWriteEp (fcb, VTF3_RECTYPE_DEFSYSCPUNUMS)); } VTF3_rec_t * VTF3_ComposeDefthreadnums (void *fcbcaller, int threadnumarraydim, const int *threadnumarray) { fcb_t *fcb; int i; fcb = (fcb_t *) fcbcaller; (void) CheckFcbOut (fcb); if (threadnumarraydim < 0) { (void) fprintf (stderr, "VTF3: Bad dimension value %d to " "VTF3_ComposeDefthreadnums()\n", threadnumarraydim); (void) fflush (stderr); (void) exit (127); } if (fcb->fileformat == VTF3_FILEFORMAT_STD_BINARY) { fcb->recbufferpos = fcb->recbuffer + 6; VTF3_STDBINARYCOMPOSE_WRITEI4 (threadnumarraydim); for (i = 0; i < threadnumarraydim; i++) { VTF3_STDBINARYCOMPOSE_WRITEI4 (*(threadnumarray + i)); } return (StdBinaryWriteEp (fcb, VTF3_RECTYPE_DEFTHREADNUMS)); } fcb->recbufferpos = fcb->recbuffer + 0; (void) StdAsciiWriteSu (fcb, "DEFTHREADNUMS"); for (i = 0; i < threadnumarraydim; i++) { (void) StdAsciiWriteSu (fcb, " "); (void) StdAsciiWriteI4 (fcb, *(threadnumarray + i)); } return (StdAsciiWriteEp (fcb, VTF3_RECTYPE_DEFTHREADNUMS)); } VTF3_rec_t * VTF3_ComposeDeftimeoffset (void *fcbcaller, double timeoffset) { fcb_t *fcb; fcb = (fcb_t *) fcbcaller; (void) CheckFcbOut (fcb); if (SignOfDouble (timeoffset) < 0) { (void) fprintf (stderr, "VTF3: Negative time offset to " "VTF3_ComposeDeftimeoffset()\n"); (void) fflush (stderr); (void) exit (127); } if (fcb->fileformat == VTF3_FILEFORMAT_STD_BINARY) { fcb->recbufferpos = fcb->recbuffer + 6; VTF3_STDBINARYCOMPOSE_WRITEU4 (ConvertDoubleToU4 (timeoffset)); return (StdBinaryWriteEp (fcb, VTF3_RECTYPE_DEFTIMEOFFSET)); } fcb->recbufferpos = fcb->recbuffer + 0; (void) StdAsciiWriteSu (fcb, "TIMEOFFSET "); (void) StdAsciiWriteU4 (fcb, ConvertDoubleToU4 (timeoffset)); return (StdAsciiWriteEp (fcb, VTF3_RECTYPE_DEFTIMEOFFSET)); } VTF3_rec_t * VTF3_ComposeDefunmerged (void *fcbcaller) { fcb_t *fcb; fcb = (fcb_t *) fcbcaller; (void) CheckFcbOut (fcb); if (fcb->fileformat == VTF3_FILEFORMAT_STD_BINARY) { fcb->recbufferpos = fcb->recbuffer + 6; return (StdBinaryWriteEp (fcb, VTF3_RECTYPE_DEFUNMERGED)); } fcb->recbufferpos = fcb->recbuffer + 0; (void) StdAsciiWriteSu (fcb, "UNMERGED"); return (StdAsciiWriteEp (fcb, VTF3_RECTYPE_DEFUNMERGED)); } VTF3_rec_t * VTF3_ComposeDefversion (void *fcbcaller, int versionnumber) { fcb_t *fcb; fcb = (fcb_t *) fcbcaller; (void) CheckFcbOut (fcb); if (fcb->fileformat == VTF3_FILEFORMAT_STD_BINARY) { fcb->recbufferpos = fcb->recbuffer + 6; VTF3_STDBINARYCOMPOSE_WRITEI4 (versionnumber); return (StdBinaryWriteEp (fcb, VTF3_RECTYPE_DEFVERSION)); } fcb->recbufferpos = fcb->recbuffer + 0; (void) StdAsciiWriteSu (fcb, "VERSION "); (void) StdAsciiWriteI4 (fcb, versionnumber); return (StdAsciiWriteEp (fcb, VTF3_RECTYPE_DEFVERSION)); } VTF3_rec_t * VTF3_ComposeDownto (void *fcbcaller, double time, int statetoken, unsigned int cpuid, int scltoken) { fcb_t *fcb; fcb = (fcb_t *) fcbcaller; (void) CheckFcbOut (fcb); fcb->lastvalidtime = time; if (statetoken == VTF3_NOSTATE) { (void) fprintf (stderr, "VTF3: Bad value %d as state token to " "VTF3_ComposeDownto()\n", VTF3_NOSTATE); (void) fflush (stderr); (void) exit (127); } if (fcb->fileformat == VTF3_FILEFORMAT_STD_BINARY) { fcb->recbufferpos = fcb->recbuffer + 6; (void) StdBinaryWriteTs (fcb, time); VTF3_STDBINARYCOMPOSE_WRITEI4 (statetoken); if (cpuid != 0) { VTF3_STDBINARYCOMPOSE_WRITEU4 (cpuid); } if (scltoken != VTF3_SCLNONE) { VTF3_STDBINARYCOMPOSE_WRITEI4 (scltoken); VTF3_STDBINARYCOMPOSE_WRITEI1 (0); } return (StdBinaryWriteEp (fcb, VTF3_RECTYPE_DOWNTO)); } if (fcb->fileformat == VTF3_FILEFORMAT_FST_ASCII) { fcb->recbufferpos = fcb->recbuffer + 0; (void) StdAsciiWriteTs (fcb, time); VTF3_FSTASCIICOMPOSE_WRITEC2 ('X', 'D'); VTF3_FSTASCIICOMPOSE_WRITEI4 (statetoken); if (cpuid != 0) { VTF3_FSTASCIICOMPOSE_WRITEC1 ('P'); VTF3_FSTASCIICOMPOSE_WRITEU4 (cpuid); } if (scltoken != VTF3_SCLNONE) { VTF3_FSTASCIICOMPOSE_WRITEC1 ('L'); VTF3_FSTASCIICOMPOSE_WRITEI4 (scltoken); } return (StdAsciiWriteEp (fcb, VTF3_RECTYPE_DOWNTO)); } fcb->recbufferpos = fcb->recbuffer + 0; (void) StdAsciiWriteTs (fcb, time); (void) StdAsciiWriteSu (fcb, " DOWNTO "); (void) StdAsciiWriteI4 (fcb, statetoken); #if (defined (VTF3_LEGACY_OUTPUT)) if (cpuid != 0) { (void) StdAsciiWriteSu (fcb, " CPU "); (void) StdAsciiWriteU4 (fcb, cpuid + 1); } #else if (cpuid != 0) { (void) StdAsciiWriteSu (fcb, " CPU "); (void) StdAsciiWriteU4 (fcb, cpuid); } #endif if (scltoken == VTF3_SCLRESET) (void) StdAsciiWriteSu (fcb, " SCL RESET"); else if (scltoken != VTF3_SCLNONE) { (void) StdAsciiWriteSu (fcb, " SCL "); (void) StdAsciiWriteI4 (fcb, scltoken); } return (StdAsciiWriteEp (fcb, VTF3_RECTYPE_DOWNTO)); } VTF3_rec_t * VTF3_ComposeExchange (void *fcbcaller, double time, unsigned int cpuid, int exchangetype, int statetoken, int job, int scltoken) { static const char *exchangetypename [] = VTF3_EXCHANGETYPENAME_INIT; fcb_t *fcb; fcb = (fcb_t *) fcbcaller; (void) CheckFcbOut (fcb); fcb->lastvalidtime = time; if (exchangetype >= (int) (sizeof (exchangetypename) / sizeof (exchangetypename[0])) || exchangetype < 0 || exchangetype == VTF3_EXCHANGETYPE_NOEXCH) { (void) fprintf (stderr, "VTF3: Bad value %d as exchange type to " "VTF3_ComposeExchange()\n", exchangetype); (void) fflush (stderr); (void) exit (127); } if (statetoken == VTF3_NOSTATE) { if (exchangetype == VTF3_EXCHANGETYPE_DOWNTO) { (void) fprintf (stderr, "VTF3: VTF3_ComposeExchange() does " "not accept ... DOWNTO NOACT ...\n"); (void) fflush (stderr); (void) exit (127); } if (exchangetype == VTF3_EXCHANGETYPE_UPFROM) { (void) fprintf (stderr, "VTF3: VTF3_ComposeExchange() does " "not accept ... UPFROM NOACT ...\n"); (void) fflush (stderr); (void) exit (127); } } if (fcb->fileformat == VTF3_FILEFORMAT_STD_BINARY) { fcb->recbufferpos = fcb->recbuffer + 6; (void) StdBinaryWriteTs (fcb, time); #if (!defined (VTF3_LEGACY_OUTPUT)) #if (0) if (job == VTF3_NOJOB && scltoken == VTF3_SCLNONE) { /* Up to now, VPTMERGE is not well done. */ #else if (job == VTF3_NOJOB) { #endif if (exchangetype == VTF3_EXCHANGETYPE_DOWNTO || exchangetype == VTF3_EXCHANGETYPE_UPTO || exchangetype == VTF3_EXCHANGETYPE_UPFROM) { VTF3_STDBINARYCOMPOSE_WRITEI4 (statetoken); if (cpuid != 0) { VTF3_STDBINARYCOMPOSE_WRITEU4 (cpuid); } if (scltoken != VTF3_SCLNONE) { VTF3_STDBINARYCOMPOSE_WRITEI4 (scltoken); VTF3_STDBINARYCOMPOSE_WRITEI1 (0); } if (exchangetype == VTF3_EXCHANGETYPE_DOWNTO) return (StdBinaryWriteEp (fcb, VTF3_RECTYPE_DOWNTO)); if (exchangetype == VTF3_EXCHANGETYPE_UPTO) return (StdBinaryWriteEp (fcb, VTF3_RECTYPE_UPTO)); return (StdBinaryWriteEp (fcb, VTF3_RECTYPE_UPFROM)); } } #endif VTF3_STDBINARYCOMPOSE_WRITEU4 (cpuid); VTF3_STDBINARYCOMPOSE_WRITEI1 (exchangetype); VTF3_STDBINARYCOMPOSE_WRITEI4 (statetoken); if (job != VTF3_NOJOB) { VTF3_STDBINARYCOMPOSE_WRITEI4 (job); } if (scltoken != VTF3_SCLNONE) { VTF3_STDBINARYCOMPOSE_WRITEI4 (scltoken); } if (job != VTF3_NOJOB) { VTF3_STDBINARYCOMPOSE_WRITEI1 ((int) (unsigned int) 0xff); } return (StdBinaryWriteEp (fcb, VTF3_RECTYPE_EXCHANGE)); } if (fcb->fileformat == VTF3_FILEFORMAT_FST_ASCII) { fcb->recbufferpos = fcb->recbuffer + 0; (void) StdAsciiWriteTs (fcb, time); #if (0) if (job == VTF3_NOJOB && scltoken == VTF3_SCLNONE) { /* Up to now, VPTMERGE is not well done. */ #else if (job == VTF3_NOJOB) { #endif if (exchangetype == VTF3_EXCHANGETYPE_DOWNTO || exchangetype == VTF3_EXCHANGETYPE_UPTO || exchangetype == VTF3_EXCHANGETYPE_UPFROM) { if (exchangetype == VTF3_EXCHANGETYPE_DOWNTO) { VTF3_FSTASCIICOMPOSE_WRITEC2 ('X', 'D'); } else if (exchangetype == VTF3_EXCHANGETYPE_UPTO) { VTF3_FSTASCIICOMPOSE_WRITEC2 ('X', 'U'); } else { VTF3_FSTASCIICOMPOSE_WRITEC2 ('X', 'F'); } VTF3_FSTASCIICOMPOSE_WRITEI4 (statetoken); if (cpuid != 0) { VTF3_FSTASCIICOMPOSE_WRITEC1 ('P'); VTF3_FSTASCIICOMPOSE_WRITEU4 (cpuid); } if (scltoken != VTF3_SCLNONE) { VTF3_FSTASCIICOMPOSE_WRITEC1 ('L'); VTF3_FSTASCIICOMPOSE_WRITEI4 (scltoken); } if (exchangetype == VTF3_EXCHANGETYPE_DOWNTO) return (StdAsciiWriteEp (fcb, VTF3_RECTYPE_DOWNTO)); if (exchangetype == VTF3_EXCHANGETYPE_UPTO) return (StdAsciiWriteEp (fcb, VTF3_RECTYPE_UPTO)); return (StdAsciiWriteEp (fcb, VTF3_RECTYPE_UPFROM)); } } VTF3_FSTASCIICOMPOSE_WRITEC2 ('X', 'X'); VTF3_FSTASCIICOMPOSE_WRITEI4 (exchangetype); if (statetoken != VTF3_NOSTATE) { VTF3_FSTASCIICOMPOSE_WRITEC1 ('S'); VTF3_FSTASCIICOMPOSE_WRITEI4 (statetoken); } if (cpuid != 0) { VTF3_FSTASCIICOMPOSE_WRITEC1 ('P'); VTF3_FSTASCIICOMPOSE_WRITEU4 (cpuid); } if (job != VTF3_NOJOB) { VTF3_FSTASCIICOMPOSE_WRITEC1 ('J'); VTF3_FSTASCIICOMPOSE_WRITEI4 (job); } if (scltoken != VTF3_SCLNONE) { VTF3_FSTASCIICOMPOSE_WRITEC1 ('L'); VTF3_FSTASCIICOMPOSE_WRITEI4 (scltoken); } return (StdAsciiWriteEp (fcb, VTF3_RECTYPE_EXCHANGE)); } fcb->recbufferpos = fcb->recbuffer + 0; (void) StdAsciiWriteTs (fcb, time); #if (!defined (VTF3_LEGACY_OUTPUT)) #if (0) if (job == VTF3_NOJOB && scltoken == VTF3_SCLNONE) { /* Up to now, VPTMERGE is not well done. */ #else if (job == VTF3_NOJOB) { #endif if (exchangetype == VTF3_EXCHANGETYPE_DOWNTO || exchangetype == VTF3_EXCHANGETYPE_UPTO || exchangetype == VTF3_EXCHANGETYPE_UPFROM) { if (exchangetype == VTF3_EXCHANGETYPE_DOWNTO) (void) StdAsciiWriteSu (fcb, " DOWNTO "); else if (exchangetype == VTF3_EXCHANGETYPE_UPTO) (void) StdAsciiWriteSu (fcb, " UPTO "); else (void) StdAsciiWriteSu (fcb, " UPFROM "); if (statetoken == VTF3_NOSTATE) (void) StdAsciiWriteSu (fcb, "NOACT"); else (void) StdAsciiWriteI4 (fcb, statetoken); if (cpuid != 0) { (void) StdAsciiWriteSu (fcb, " CPU "); (void) StdAsciiWriteU4 (fcb, cpuid); } if (scltoken == VTF3_SCLRESET) (void) StdAsciiWriteSu (fcb, " SCL RESET"); else if (scltoken != VTF3_SCLNONE) { (void) StdAsciiWriteSu (fcb, " SCL "); (void) StdAsciiWriteI4 (fcb, scltoken); } if (exchangetype == VTF3_EXCHANGETYPE_DOWNTO) return (StdAsciiWriteEp (fcb, VTF3_RECTYPE_DOWNTO)); if (exchangetype == VTF3_EXCHANGETYPE_UPTO) return (StdAsciiWriteEp (fcb, VTF3_RECTYPE_UPTO)); return (StdAsciiWriteEp (fcb, VTF3_RECTYPE_UPFROM)); } } if (cpuid != 0) { (void) StdAsciiWriteSu (fcb, " EXCHEXT CPU "); (void) StdAsciiWriteU4 (fcb, cpuid); } else (void) StdAsciiWriteSu (fcb, " EXCHEXT"); #else (void) StdAsciiWriteSu (fcb, " EXCHEXT CPU "); (void) StdAsciiWriteU4 (fcb, cpuid + 1); #endif (void) StdAsciiWriteSu (fcb, " "); (void) StdAsciiWriteSu (fcb, exchangetypename[exchangetype]); (void) StdAsciiWriteSu (fcb, " "); if (statetoken == VTF3_NOSTATE) (void) StdAsciiWriteSu (fcb, "NOACT"); else (void) StdAsciiWriteI4 (fcb, statetoken); if (job != VTF3_NOJOB) { (void) StdAsciiWriteSu (fcb, " JOB "); (void) StdAsciiWriteI4 (fcb, job); } if (scltoken == VTF3_SCLRESET) (void) StdAsciiWriteSu (fcb, " SCL RESET"); else if (scltoken != VTF3_SCLNONE) { (void) StdAsciiWriteSu (fcb, " SCL "); (void) StdAsciiWriteI4 (fcb, scltoken); } return (StdAsciiWriteEp (fcb, VTF3_RECTYPE_EXCHANGE)); } VTF3_rec_t * VTF3_ComposeExchange_obsol (void *fcbcaller, double time, unsigned int cpuid, int exchangetype, int statetoken, int activitytoken, const char *activityname, unsigned int activityvalidity, int job) { static const char *noact = "NOACT"; static const char *exchangetypename [] = VTF3_EXCHANGETYPENAME_INIT; fcb_t *fcb; int i, isnoact; fcb = (fcb_t *) fcbcaller; (void) CheckFcbOut (fcb); fcb->lastvalidtime = time; if (exchangetype != VTF3_EXCHANGETYPE_TO && exchangetype != VTF3_EXCHANGETYPE_DOWNTO && exchangetype != VTF3_EXCHANGETYPE_UPTO) { (void) fprintf (stderr, "VTF3: Bad value %d as exchange type to " "VTF3_ComposeExchange_obsol()\n", exchangetype); (void) fflush (stderr); (void) exit (127); } if (statetoken == VTF3_NOSTATE && exchangetype == VTF3_EXCHANGETYPE_DOWNTO) { (void) fprintf (stderr, "VTF3: VTF3_ComposeExchange_obsol() does " "not accept ... DOWNTO NOACT ...\n"); (void) fflush (stderr); (void) exit (127); } if (fcb->fileformat == VTF3_FILEFORMAT_STD_BINARY) { if ((activityvalidity & VTF3_OLDACT_VALID_TOKEN) == 0) { (void) fprintf (stderr, "VTF3: Invalid activity token to " "VTF3_ComposeExchange_obsol(), " "needs higher level tokenization/" "retokenization support\n"); (void) fflush (stderr); (void) exit (127); } if (statetoken == VTF3_NOSTATE || activitytoken == VTF3_NOACT) if (statetoken != VTF3_NOSTATE || activitytoken != VTF3_NOACT) { (void) fprintf (stderr, "VTF3: Conflicting values for " "state token and activity token to " "VTF3_ComposeExchange_obsol()\n"); (void) fflush (stderr); (void) exit (127); } fcb->recbufferpos = fcb->recbuffer + 6; (void) StdBinaryWriteTs (fcb, time); VTF3_STDBINARYCOMPOSE_WRITEU4 (cpuid); VTF3_STDBINARYCOMPOSE_WRITEI4 (VTF3_NOACT); VTF3_STDBINARYCOMPOSE_WRITEI4 (VTF3_NOSTATE); VTF3_STDBINARYCOMPOSE_WRITEI4 (activitytoken); VTF3_STDBINARYCOMPOSE_WRITEI4 (statetoken); VTF3_STDBINARYCOMPOSE_WRITEI4 (job); VTF3_STDBINARYCOMPOSE_WRITEI1 (exchangetype); return (StdBinaryWriteEp (fcb, VTF3_RECTYPE_EXCHANGE_OBSOL)); } if ((activityvalidity & VTF3_OLDACT_VALID_NAME) == 0) { (void) fprintf (stderr, "VTF3: Invalid activity name to " "VTF3_ComposeExchange_obsol(), " "needs higher level tokenization/" "retokenization support\n"); (void) fflush (stderr); (void) exit (127); } if (statetoken == VTF3_NOSTATE) { if (activityname != 0) for (i = 0; i < 6; i++) if (*(activityname + i) != *(noact + i)) { (void) fprintf (stderr, "VTF3: Conflicting values for " "state token and activity name to " "VTF3_ComposeExchange_obsol()\n"); (void) fflush (stderr); (void) exit (127); } } else { if (activityname == 0) { (void) fprintf (stderr, "VTF3: NULL as activity name to " "VTF3_ComposeExchange_obsol()\n"); (void) fflush (stderr); (void) exit (127); } isnoact = 1; for (i = 0; i < 6; i++) if (*(activityname + i) != *(noact + i)) { isnoact = 0; break; } if (isnoact != 0) { (void) fprintf (stderr, "VTF3: Conflicting values for " "state token and activity name to " "VTF3_ComposeExchange_obsol()\n"); (void) fflush (stderr); (void) exit (127); } } fcb->recbufferpos = fcb->recbuffer + 0; (void) StdAsciiWriteTs (fcb, time); #if (defined (VTF3_LEGACY_OUTPUT)) (void) StdAsciiWriteSu (fcb, " EXCHANGE ON CPUID "); (void) StdAsciiWriteU4 (fcb, cpuid + 1); #else if (cpuid != 0) { (void) StdAsciiWriteSu (fcb, " EXCHANGE CPU "); (void) StdAsciiWriteU4 (fcb, cpuid); } else (void) StdAsciiWriteSu (fcb, " EXCHANGE"); #endif (void) StdAsciiWriteSu (fcb, " "); (void) StdAsciiWriteSu (fcb, exchangetypename[exchangetype]); if (statetoken == VTF3_NOSTATE) (void) StdAsciiWriteSu (fcb, " NOACT"); else { (void) StdAsciiWriteSu (fcb, " \""); (void) StdAsciiWriteSp (fcb, activityname); (void) StdAsciiWriteSu (fcb, "\" "); (void) StdAsciiWriteI4 (fcb, statetoken); } #if (defined (VTF3_LEGACY_OUTPUT)) (void) StdAsciiWriteSu (fcb, " CLUSTER 1"); #endif if (job != VTF3_NOJOB) { (void) StdAsciiWriteSu (fcb, " JOB "); (void) StdAsciiWriteI4 (fcb, job); } return (StdAsciiWriteEp (fcb, VTF3_RECTYPE_EXCHANGE_OBSOL)); } VTF3_rec_t * VTF3_ComposeFileiobegin (void *fcbcaller, double time, unsigned int cpuid, int fileiotype, int iofiletoken, int bytescopied, int scltoken) { static const char *fileiotypename [] = VTF3_FILEIOTYPENAME_INIT; fcb_t *fcb; fcb = (fcb_t *) fcbcaller; (void) CheckFcbOut (fcb); fcb->lastvalidtime = time; if (fileiotype >= (int) (sizeof (fileiotypename) / sizeof (fileiotypename[0])) || fileiotype < 0 || fileiotype == VTF3_FILEIOTYPE_NOTYPE) { (void) fprintf (stderr, "VTF3: Bad value %d as I/O type to " "VTF3_ComposeFileiobegin()\n", fileiotype); (void) fflush (stderr); (void) exit (127); } if (fcb->fileformat == VTF3_FILEFORMAT_STD_BINARY) { fcb->recbufferpos = fcb->recbuffer + 6; (void) StdBinaryWriteTs (fcb, time); (void) StdBinaryWriteI2 (fcb, fileiotype); VTF3_STDBINARYCOMPOSE_WRITEU4 (cpuid); VTF3_STDBINARYCOMPOSE_WRITEI4 (iofiletoken); VTF3_STDBINARYCOMPOSE_WRITEI4 (bytescopied); if (scltoken != VTF3_SCLNONE) { VTF3_STDBINARYCOMPOSE_WRITEI4 (scltoken); } return (StdBinaryWriteEp (fcb, VTF3_RECTYPE_FILEIOBEGIN)); } if (fcb->fileformat == VTF3_FILEFORMAT_FST_ASCII) { fcb->recbufferpos = fcb->recbuffer + 0; (void) StdAsciiWriteTs (fcb, time); VTF3_FSTASCIICOMPOSE_WRITEC2 ('F', 'B'); VTF3_FSTASCIICOMPOSE_WRITEI4 (iofiletoken); if (cpuid != 0) { VTF3_FSTASCIICOMPOSE_WRITEC1 ('P'); VTF3_FSTASCIICOMPOSE_WRITEU4 (cpuid); } VTF3_FSTASCIICOMPOSE_WRITEC1 (*(fileiotypename[fileiotype] + 0)); VTF3_FSTASCIICOMPOSE_WRITEI4 (bytescopied); if (scltoken != VTF3_SCLNONE) { VTF3_FSTASCIICOMPOSE_WRITEC1 ('L'); VTF3_FSTASCIICOMPOSE_WRITEI4 (scltoken); } return (StdAsciiWriteEp (fcb, VTF3_RECTYPE_FILEIOBEGIN)); } fcb->recbufferpos = fcb->recbuffer + 0; (void) StdAsciiWriteTs (fcb, time); (void) StdAsciiWriteSu (fcb, " FILEIOBEGIN "); #if (defined (VTF3_LEGACY_OUTPUT)) (void) StdAsciiWriteSp (fcb, fileiotypename[fileiotype]); (void) StdAsciiWriteSu (fcb, " ON CPUID "); (void) StdAsciiWriteU4 (fcb, cpuid + 1); (void) StdAsciiWriteSu (fcb, " "); (void) StdAsciiWriteI4 (fcb, iofiletoken); (void) StdAsciiWriteSu (fcb, " "); (void) StdAsciiWriteI4 (fcb, bytescopied); #else (void) StdAsciiWriteI4 (fcb, iofiletoken); if (cpuid != 0) { (void) StdAsciiWriteSu (fcb, " CPU "); (void) StdAsciiWriteU4 (fcb, cpuid); } (void) StdAsciiWriteSu (fcb, " "); (void) StdAsciiWriteSp (fcb, fileiotypename[fileiotype]); (void) StdAsciiWriteSu (fcb, " "); (void) StdAsciiWriteI4 (fcb, bytescopied); #endif if (scltoken == VTF3_SCLRESET) (void) StdAsciiWriteSu (fcb, " SCL RESET"); else if (scltoken != VTF3_SCLNONE) { (void) StdAsciiWriteSu (fcb, " SCL "); (void) StdAsciiWriteI4 (fcb, scltoken); } return (StdAsciiWriteEp (fcb, VTF3_RECTYPE_FILEIOBEGIN)); } VTF3_rec_t * VTF3_ComposeFileioend (void *fcbcaller, double time, unsigned int cpuid, int fileiotype, int iofiletoken, int bytescopied, int scltoken) { static const char *fileiotypename [] = VTF3_FILEIOTYPENAME_INIT; fcb_t *fcb; fcb = (fcb_t *) fcbcaller; (void) CheckFcbOut (fcb); fcb->lastvalidtime = time; if (fileiotype >= (int) (sizeof (fileiotypename) / sizeof (fileiotypename[0])) || fileiotype < 0 || fileiotype == VTF3_FILEIOTYPE_NOTYPE) { (void) fprintf (stderr, "VTF3: Bad value %d as I/O type to " "VTF3_ComposeFileioend()\n", fileiotype); (void) fflush (stderr); (void) exit (127); } if (fcb->fileformat == VTF3_FILEFORMAT_STD_BINARY) { fcb->recbufferpos = fcb->recbuffer + 6; (void) StdBinaryWriteTs (fcb, time); (void) StdBinaryWriteI2 (fcb, fileiotype); VTF3_STDBINARYCOMPOSE_WRITEU4 (cpuid); VTF3_STDBINARYCOMPOSE_WRITEI4 (iofiletoken); VTF3_STDBINARYCOMPOSE_WRITEI4 (bytescopied); if (scltoken != VTF3_SCLNONE) { VTF3_STDBINARYCOMPOSE_WRITEI4 (scltoken); } return (StdBinaryWriteEp (fcb, VTF3_RECTYPE_FILEIOEND)); } if (fcb->fileformat == VTF3_FILEFORMAT_FST_ASCII) { fcb->recbufferpos = fcb->recbuffer + 0; (void) StdAsciiWriteTs (fcb, time); VTF3_FSTASCIICOMPOSE_WRITEC2 ('F', 'E'); VTF3_FSTASCIICOMPOSE_WRITEI4 (iofiletoken); if (cpuid != 0) { VTF3_FSTASCIICOMPOSE_WRITEC1 ('P'); VTF3_FSTASCIICOMPOSE_WRITEU4 (cpuid); } VTF3_FSTASCIICOMPOSE_WRITEC1 (*(fileiotypename[fileiotype] + 0)); VTF3_FSTASCIICOMPOSE_WRITEI4 (bytescopied); if (scltoken != VTF3_SCLNONE) { VTF3_FSTASCIICOMPOSE_WRITEC1 ('L'); VTF3_FSTASCIICOMPOSE_WRITEI4 (scltoken); } return (StdAsciiWriteEp (fcb, VTF3_RECTYPE_FILEIOEND)); } fcb->recbufferpos = fcb->recbuffer + 0; (void) StdAsciiWriteTs (fcb, time); (void) StdAsciiWriteSu (fcb, " FILEIOEND "); #if (defined (VTF3_LEGACY_OUTPUT)) (void) StdAsciiWriteSp (fcb, fileiotypename[fileiotype]); (void) StdAsciiWriteSu (fcb, " ON CPUID "); (void) StdAsciiWriteU4 (fcb, cpuid + 1); (void) StdAsciiWriteSu (fcb, " "); (void) StdAsciiWriteI4 (fcb, iofiletoken); (void) StdAsciiWriteSu (fcb, " "); (void) StdAsciiWriteI4 (fcb, bytescopied); #else (void) StdAsciiWriteI4 (fcb, iofiletoken); if (cpuid != 0) { (void) StdAsciiWriteSu (fcb, " CPU "); (void) StdAsciiWriteU4 (fcb, cpuid); } (void) StdAsciiWriteSu (fcb, " "); (void) StdAsciiWriteSp (fcb, fileiotypename[fileiotype]); (void) StdAsciiWriteSu (fcb, " "); (void) StdAsciiWriteI4 (fcb, bytescopied); #endif if (scltoken == VTF3_SCLRESET) (void) StdAsciiWriteSu (fcb, " SCL RESET"); else if (scltoken != VTF3_SCLNONE) { (void) StdAsciiWriteSu (fcb, " SCL "); (void) StdAsciiWriteI4 (fcb, scltoken); } return (StdAsciiWriteEp (fcb, VTF3_RECTYPE_FILEIOEND)); } VTF3_rec_t * VTF3_ComposeGlobalop (void *fcbcaller, double time, int globaloptoken, unsigned int cpuid, int communicator, unsigned int rootcpuid, int bytessent, int bytesreceived, double durationtimesteps, int scltoken) { fcb_t *fcb; fcb = (fcb_t *) fcbcaller; (void) CheckFcbOut (fcb); fcb->lastvalidtime = time; if (fcb->fileformat == VTF3_FILEFORMAT_STD_BINARY) { fcb->recbufferpos = fcb->recbuffer + 6; (void) StdBinaryWriteTs (fcb, time); VTF3_STDBINARYCOMPOSE_WRITEI4 (globaloptoken); VTF3_STDBINARYCOMPOSE_WRITEU4 (cpuid); VTF3_STDBINARYCOMPOSE_WRITEI4 (communicator); VTF3_STDBINARYCOMPOSE_WRITEU4 (rootcpuid); VTF3_STDBINARYCOMPOSE_WRITEI4 (bytessent); VTF3_STDBINARYCOMPOSE_WRITEI4 (bytesreceived); if (SignOfDouble (durationtimesteps) >= 0) (void) StdBinaryWriteTs (fcb, durationtimesteps); else (void) StdBinaryWriteF8 (fcb, -1.0e+0); if (scltoken != VTF3_SCLNONE) { VTF3_STDBINARYCOMPOSE_WRITEI4 (scltoken); } return (StdBinaryWriteEp (fcb, VTF3_RECTYPE_GLOBALOP)); } if (fcb->fileformat == VTF3_FILEFORMAT_FST_ASCII) { fcb->recbufferpos = fcb->recbuffer + 0; (void) StdAsciiWriteTs (fcb, time); VTF3_FSTASCIICOMPOSE_WRITEC2 ('G', 'O'); VTF3_FSTASCIICOMPOSE_WRITEI4 (globaloptoken); if (communicator != VTF3_NOCOMMUNICATOR) { VTF3_FSTASCIICOMPOSE_WRITEC1 ('C'); VTF3_FSTASCIICOMPOSE_WRITEI4 (communicator); } if (cpuid != 0) { VTF3_FSTASCIICOMPOSE_WRITEC1 ('P'); VTF3_FSTASCIICOMPOSE_WRITEU4 (cpuid); } if (rootcpuid != 0) { VTF3_FSTASCIICOMPOSE_WRITEC1 ('R'); VTF3_FSTASCIICOMPOSE_WRITEU4 (rootcpuid); } if (bytesreceived != 0) { VTF3_FSTASCIICOMPOSE_WRITEC1 ('I'); VTF3_FSTASCIICOMPOSE_WRITEI4 (bytesreceived); } if (bytessent != 0) { VTF3_FSTASCIICOMPOSE_WRITEC1 ('O'); VTF3_FSTASCIICOMPOSE_WRITEI4 (bytessent); } if (SignOfDouble (durationtimesteps) >= 0) { VTF3_FSTASCIICOMPOSE_WRITEC1 ('D'); (void) StdAsciiWriteTs (fcb, durationtimesteps); } if (scltoken != VTF3_SCLNONE) { VTF3_FSTASCIICOMPOSE_WRITEC1 ('L'); VTF3_FSTASCIICOMPOSE_WRITEI4 (scltoken); } return (StdAsciiWriteEp (fcb, VTF3_RECTYPE_GLOBALOP)); } fcb->recbufferpos = fcb->recbuffer + 0; (void) StdAsciiWriteTs (fcb, time); (void) StdAsciiWriteSu (fcb, " GLOBALOP "); (void) StdAsciiWriteI4 (fcb, globaloptoken); #if (defined (VTF3_LEGACY_OUTPUT)) (void) StdAsciiWriteSu (fcb, " ON "); (void) StdAsciiWriteU4 (fcb, cpuid + 1); (void) StdAsciiWriteSu (fcb, " "); (void) StdAsciiWriteI4 (fcb, communicator); (void) StdAsciiWriteSu (fcb, " "); (void) StdAsciiWriteU4 (fcb, rootcpuid + 1); (void) StdAsciiWriteSu (fcb, " "); (void) StdAsciiWriteI4 (fcb, bytessent); (void) StdAsciiWriteSu (fcb, " "); (void) StdAsciiWriteI4 (fcb, bytesreceived); (void) StdAsciiWriteSu (fcb, " "); if (SignOfDouble (durationtimesteps) >= 0) (void) StdAsciiWriteTs (fcb, durationtimesteps); else (void) StdAsciiWriteSu (fcb, "-1"); #else (void) StdAsciiWriteSu (fcb, " COM "); (void) StdAsciiWriteI4 (fcb, communicator); (void) StdAsciiWriteSu (fcb, " CPU "); (void) StdAsciiWriteU4 (fcb, cpuid); (void) StdAsciiWriteSu (fcb, " ROOT "); (void) StdAsciiWriteU4 (fcb, rootcpuid); (void) StdAsciiWriteSu (fcb, " IN "); (void) StdAsciiWriteI4 (fcb, bytesreceived); (void) StdAsciiWriteSu (fcb, " OUT "); (void) StdAsciiWriteI4 (fcb, bytessent); if (SignOfDouble (durationtimesteps) >= 0) { (void) StdAsciiWriteSu (fcb, " DTSTEPS "); (void) StdAsciiWriteTs (fcb, durationtimesteps); } #endif if (scltoken == VTF3_SCLRESET) (void) StdAsciiWriteSu (fcb, " SCL RESET"); else if (scltoken != VTF3_SCLNONE) { (void) StdAsciiWriteSu (fcb, " SCL "); (void) StdAsciiWriteI4 (fcb, scltoken); } return (StdAsciiWriteEp (fcb, VTF3_RECTYPE_GLOBALOP)); } /** * compose the record of a histogram * comment: the values are 64 bit integer written as two seperate 32 bit unsigned integers * therefore "values" holds two consecutive unsigned 32bit ints */ VTF3_rec_t * VTF3_ComposeHist (void *fcbcaller, double time, int histtoken, double starttime, unsigned int cpuid, int valuearraydim, int* numdatastrucperbin, const int* datastrucarray, const void *values ) { fcb_t *fcb; unsigned int ul, uh; int i,j,nrstructures; fcb = (fcb_t *) fcbcaller; (void) CheckFcbOut (fcb); fcb->lastvalidtime = time; /*initial checks */ if (valuearraydim < 0) { (void) fprintf (stderr, "VTF3: Bad dimension value %d to " "VTF3_ComposeHist()\n", valuearraydim); (void) fflush (stderr); (void) exit (127); } /*binary format */ if (fcb->fileformat == VTF3_FILEFORMAT_STD_BINARY) { fcb->recbufferpos = fcb->recbuffer + 6; (void) StdBinaryWriteTs (fcb, time); VTF3_STDBINARYCOMPOSE_WRITEI4 (histtoken); (void) StdBinaryWriteTs (fcb, starttime); VTF3_STDBINARYCOMPOSE_WRITEU4 (cpuid); VTF3_STDBINARYCOMPOSE_WRITEI4 (valuearraydim); /*loop over all bins and write out all data structures per bin */ for (i = 0; i < valuearraydim; i++) { VTF3_STDBINARYCOMPOSE_WRITEI4 (*(numdatastrucperbin + i)); /*get number of data structures per bin */ nrstructures=*(numdatastrucperbin + i); if ( nrstructures < 0) { (void) fprintf (stderr, "VTF3: Bad number of data strucures per histogram bin %d in " "VTF3_ComposeDefhist()\n", nrstructures); (void) fflush (stderr); (void) exit (127); } /*write out the data structure tokens in this bin */ for (j=0; j < nrstructures; j++ ) { VTF3_STDBINARYCOMPOSE_WRITEI4 (*(datastrucarray)); datastrucarray++; } } for (i = 0; i < valuearraydim; i++) { ul = LoadUintFromU4Array (values, 2 * i + 0); uh = LoadUintFromU4Array (values, 2 * i + 1); VTF3_STDBINARYCOMPOSE_WRITEU4 (ul); VTF3_STDBINARYCOMPOSE_WRITEU4 (uh); } return (StdBinaryWriteEp (fcb, VTF3_RECTYPE_HIST)); } /*ASCII format */ fcb->recbufferpos = fcb->recbuffer + 0; (void) StdAsciiWriteTs (fcb, time); (void) StdAsciiWriteSu (fcb, " HIST "); (void) StdAsciiWriteI4 (fcb, histtoken); (void) StdAsciiWriteSu (fcb, " START "); (void) StdAsciiWriteTs (fcb, starttime); (void) StdAsciiWriteSu (fcb, " CPU "); (void) StdAsciiWriteU4 (fcb, cpuid); (void) StdAsciiWriteSu (fcb, " NBINS "); (void) StdAsciiWriteI4 (fcb, valuearraydim); (void) StdAsciiWriteSu (fcb, " BINS "); /*loop over all bins and write out all data structures per bin */ for (i = 0; i < valuearraydim; i++) { (void) StdAsciiWriteSu (fcb, " "); (void) StdAsciiWriteI4 (fcb, *(numdatastrucperbin + i)); /*get number of data structures per bin */ nrstructures=*(numdatastrucperbin+i); if ( nrstructures < 0) { (void) fprintf (stderr, "VTF3: Bad number of data strucures per histogram bin %d in " "VTF3_ComposeHist()\n", nrstructures); (void) fflush (stderr); (void) exit (127); } /*write out the data structure tokens in this bin */ for (j=0; j < nrstructures; j++ ) { (void) StdAsciiWriteSu (fcb, " "); (void) StdAsciiWriteI4 (fcb, *(datastrucarray)); datastrucarray++; } } (void) StdAsciiWriteSu (fcb, " VAL"); for (i = 0; i < valuearraydim; i++) { /*get upper and lower 32bit part of int64 */ ul = LoadUintFromU4Array (values, 2 * i + 0); uh = LoadUintFromU4Array (values, 2 * i + 1); (void) StdAsciiWriteSu (fcb, " "); (void) StdAsciiWriteU4 (fcb, ul); (void) StdAsciiWriteSu (fcb, " "); (void) StdAsciiWriteU4 (fcb, uh); } return (StdAsciiWriteEp (fcb, VTF3_RECTYPE_HIST)); } VTF3_rec_t * VTF3_ComposeKparregbarsum (void *fcbcaller, double time, unsigned int cpuid, int kparregtoken, int seqn, int opasize, const void *opastream, int scltoken) { fcb_t *fcb; int numcharshex; fcb = (fcb_t *) fcbcaller; (void) CheckFcbOut (fcb); fcb->lastvalidtime = time; if (opasize < 0) { (void) fprintf (stderr, "VTF3: Bad size value %d to " "VTF3_ComposeKparregbarsum()\n", opasize); (void) fflush (stderr); (void) exit (127); } if (fcb->fileformat == VTF3_FILEFORMAT_STD_BINARY) { fcb->recbufferpos = fcb->recbuffer + 6; (void) StdBinaryWriteTs (fcb, time); VTF3_STDBINARYCOMPOSE_WRITEU4 (cpuid); VTF3_STDBINARYCOMPOSE_WRITEI4 (kparregtoken); VTF3_STDBINARYCOMPOSE_WRITEI4 (seqn); VTF3_STDBINARYCOMPOSE_WRITEI4 (opasize / (int) sizeof (char)); (void) StdBinaryWriteCa (fcb, (const char *) opastream, opasize / (int) sizeof (char)); if (scltoken != VTF3_SCLNONE) { VTF3_STDBINARYCOMPOSE_WRITEI4 (scltoken); } return (StdBinaryWriteEp (fcb, VTF3_RECTYPE_KPARREGBARSUM)); } fcb->recbufferpos = fcb->recbuffer + 0; (void) StdAsciiWriteTs (fcb, time); (void) StdAsciiWriteSu (fcb, " KPARREGBARSUM "); (void) StdAsciiWriteI4 (fcb, kparregtoken); (void) StdAsciiWriteSu (fcb, " CPU "); #if (defined (VTF3_LEGACY_OUTPUT)) (void) StdAsciiWriteU4 (fcb, cpuid + 1); #else (void) StdAsciiWriteU4 (fcb, cpuid); #endif (void) StdAsciiWriteSu (fcb, " SEQN "); (void) StdAsciiWriteI4 (fcb, seqn); (void) StdAsciiWriteSu (fcb, " OSIZE "); (void) StdAsciiWriteI4 (fcb, opasize / (int) sizeof (char)); if (opasize > 0) { (void) StdAsciiWriteSu (fcb, " OSTREAM "); numcharshex = TransMemToHexUpper (fcb, opastream, (size_t) opasize); (void) StdBinaryWriteCa (fcb, fcb->charvector, numcharshex); } if (scltoken == VTF3_SCLRESET) (void) StdAsciiWriteSu (fcb, " SCL RESET"); else if (scltoken != VTF3_SCLNONE) { (void) StdAsciiWriteSu (fcb, " SCL "); (void) StdAsciiWriteI4 (fcb, scltoken); } return (StdAsciiWriteEp (fcb, VTF3_RECTYPE_KPARREGBARSUM)); } VTF3_rec_t * VTF3_ComposeKparregbegin (void *fcbcaller, double time, unsigned int cpuid, int kparregtoken, int seqn, int numthreads, int scltoken) { fcb_t *fcb; fcb = (fcb_t *) fcbcaller; (void) CheckFcbOut (fcb); fcb->lastvalidtime = time; if (fcb->fileformat == VTF3_FILEFORMAT_STD_BINARY) { fcb->recbufferpos = fcb->recbuffer + 6; (void) StdBinaryWriteTs (fcb, time); VTF3_STDBINARYCOMPOSE_WRITEU4 (cpuid); VTF3_STDBINARYCOMPOSE_WRITEI4 (kparregtoken); VTF3_STDBINARYCOMPOSE_WRITEI4 (seqn); VTF3_STDBINARYCOMPOSE_WRITEI4 (numthreads); if (scltoken != VTF3_SCLNONE) { VTF3_STDBINARYCOMPOSE_WRITEI4 (scltoken); } return (StdBinaryWriteEp (fcb, VTF3_RECTYPE_KPARREGBEGIN)); } fcb->recbufferpos = fcb->recbuffer + 0; (void) StdAsciiWriteTs (fcb, time); (void) StdAsciiWriteSu (fcb, " KPARREGBEGIN "); (void) StdAsciiWriteI4 (fcb, kparregtoken); (void) StdAsciiWriteSu (fcb, " CPU "); #if (defined (VTF3_LEGACY_OUTPUT)) (void) StdAsciiWriteU4 (fcb, cpuid + 1); #else (void) StdAsciiWriteU4 (fcb, cpuid); #endif (void) StdAsciiWriteSu (fcb, " SEQN "); (void) StdAsciiWriteI4 (fcb, seqn); (void) StdAsciiWriteSu (fcb, " NTHREADS "); (void) StdAsciiWriteI4 (fcb, numthreads); if (scltoken == VTF3_SCLRESET) (void) StdAsciiWriteSu (fcb, " SCL RESET"); else if (scltoken != VTF3_SCLNONE) { (void) StdAsciiWriteSu (fcb, " SCL "); (void) StdAsciiWriteI4 (fcb, scltoken); } return (StdAsciiWriteEp (fcb, VTF3_RECTYPE_KPARREGBEGIN)); } VTF3_rec_t * VTF3_ComposeKparregend (void *fcbcaller, double time, unsigned int cpuid, int kparregtoken, int seqn, int opasize, const void *opastream, int scltoken) { fcb_t *fcb; int numcharshex; fcb = (fcb_t *) fcbcaller; (void) CheckFcbOut (fcb); fcb->lastvalidtime = time; if (opasize < 0) { (void) fprintf (stderr, "VTF3: Bad size value %d to " "VTF3_ComposeKparregend()\n", opasize); (void) fflush (stderr); (void) exit (127); } if (fcb->fileformat == VTF3_FILEFORMAT_STD_BINARY) { fcb->recbufferpos = fcb->recbuffer + 6; (void) StdBinaryWriteTs (fcb, time); VTF3_STDBINARYCOMPOSE_WRITEU4 (cpuid); VTF3_STDBINARYCOMPOSE_WRITEI4 (kparregtoken); VTF3_STDBINARYCOMPOSE_WRITEI4 (seqn); VTF3_STDBINARYCOMPOSE_WRITEI4 (opasize / (int) sizeof (char)); (void) StdBinaryWriteCa (fcb, (const char *) opastream, opasize / (int) sizeof (char)); if (scltoken != VTF3_SCLNONE) { VTF3_STDBINARYCOMPOSE_WRITEI4 (scltoken); } return (StdBinaryWriteEp (fcb, VTF3_RECTYPE_KPARREGEND)); } fcb->recbufferpos = fcb->recbuffer + 0; (void) StdAsciiWriteTs (fcb, time); (void) StdAsciiWriteSu (fcb, " KPARREGEND "); (void) StdAsciiWriteI4 (fcb, kparregtoken); (void) StdAsciiWriteSu (fcb, " CPU "); #if (defined (VTF3_LEGACY_OUTPUT)) (void) StdAsciiWriteU4 (fcb, cpuid + 1); #else (void) StdAsciiWriteU4 (fcb, cpuid); #endif (void) StdAsciiWriteSu (fcb, " SEQN "); (void) StdAsciiWriteI4 (fcb, seqn); (void) StdAsciiWriteSu (fcb, " OSIZE "); (void) StdAsciiWriteI4 (fcb, opasize / (int) sizeof (char)); if (opasize > 0) { (void) StdAsciiWriteSu (fcb, " OSTREAM "); numcharshex = TransMemToHexUpper (fcb, opastream, (size_t) opasize); (void) StdBinaryWriteCa (fcb, fcb->charvector, numcharshex); } if (scltoken == VTF3_SCLRESET) (void) StdAsciiWriteSu (fcb, " SCL RESET"); else if (scltoken != VTF3_SCLNONE) { (void) StdAsciiWriteSu (fcb, " SCL "); (void) StdAsciiWriteI4 (fcb, scltoken); } return (StdAsciiWriteEp (fcb, VTF3_RECTYPE_KPARREGEND)); } VTF3_rec_t * VTF3_ComposeMutexacquire (void *fcbcaller, double time, unsigned int cpuid, int enterstatetoken, int leavestatetoken, int leavestatetokenisupfrom, double durationtimesteps, int mutexsize, const void *mutex, int scltoken) { fcb_t *fcb; int numcharshex; fcb = (fcb_t *) fcbcaller; (void) CheckFcbOut (fcb); fcb->lastvalidtime = time; if (enterstatetoken == VTF3_NOSTATE) { (void) fprintf (stderr, "VTF3: Bad value %d as enter state token to " "VTF3_ComposeMutexacquire()\n", VTF3_NOSTATE); (void) fflush (stderr); (void) exit (127); } if (leavestatetokenisupfrom != 0 && leavestatetoken != enterstatetoken) { (void) fprintf (stderr, "VTF3: Bad value %d as leave state token to " "VTF3_ComposeMutexacquire()\n", leavestatetoken); (void) fflush (stderr); (void) exit (127); } if (SignOfDouble (durationtimesteps) < 0) { (void) fprintf (stderr, "VTF3: Negative duration time step number to " "VTF3_ComposeMutexacquire()\n"); (void) fflush (stderr); (void) exit (127); } if (mutexsize < 0) { (void) fprintf (stderr, "VTF3: Bad size value %d to " "VTF3_ComposeMutexacquire()\n", mutexsize); (void) fflush (stderr); (void) exit (127); } if (fcb->fileformat == VTF3_FILEFORMAT_STD_BINARY) { fcb->recbufferpos = fcb->recbuffer + 6; (void) StdBinaryWriteTs (fcb, time); VTF3_STDBINARYCOMPOSE_WRITEU4 (cpuid); VTF3_STDBINARYCOMPOSE_WRITEI4 (enterstatetoken); VTF3_STDBINARYCOMPOSE_WRITEI4 (leavestatetoken); VTF3_STDBINARYCOMPOSE_WRITEI1 ((leavestatetokenisupfrom != 0 ? 1 : 0)); (void) StdBinaryWriteTs (fcb, durationtimesteps); VTF3_STDBINARYCOMPOSE_WRITEI4 (mutexsize / (int) sizeof (char)); (void) StdBinaryWriteCa (fcb, (const char *) mutex, mutexsize / (int) sizeof (char)); if (scltoken != VTF3_SCLNONE) { VTF3_STDBINARYCOMPOSE_WRITEI4 (scltoken); } return (StdBinaryWriteEp (fcb, VTF3_RECTYPE_MUTEXACQUIRE)); } fcb->recbufferpos = fcb->recbuffer + 0; (void) StdAsciiWriteTs (fcb, time); (void) StdAsciiWriteSu (fcb, " MUTEXACQUIRE CPU "); #if (defined (VTF3_LEGACY_OUTPUT)) (void) StdAsciiWriteU4 (fcb, cpuid + 1); #else (void) StdAsciiWriteU4 (fcb, cpuid); #endif (void) StdAsciiWriteSu (fcb, " DOWNTO "); (void) StdAsciiWriteI4 (fcb, enterstatetoken); if (leavestatetokenisupfrom != 0) (void) StdAsciiWriteSu (fcb, " UPFROM "); else (void) StdAsciiWriteSu (fcb, " UPTO "); if (leavestatetoken == VTF3_NOSTATE) (void) StdAsciiWriteSu (fcb, "NOACT"); else (void) StdAsciiWriteI4 (fcb, leavestatetoken); (void) StdAsciiWriteSu (fcb, " DTSTEPS "); (void) StdAsciiWriteTs (fcb, durationtimesteps); (void) StdAsciiWriteSu (fcb, " MSIZE "); (void) StdAsciiWriteI4 (fcb, mutexsize / (int) sizeof (char)); if (mutexsize > 0) { (void) StdAsciiWriteSu (fcb, " MUTEX "); numcharshex = TransMemToHexUpper (fcb, mutex, (size_t) mutexsize); (void) StdBinaryWriteCa (fcb, fcb->charvector, numcharshex); } if (scltoken == VTF3_SCLRESET) (void) StdAsciiWriteSu (fcb, " SCL RESET"); else if (scltoken != VTF3_SCLNONE) { (void) StdAsciiWriteSu (fcb, " SCL "); (void) StdAsciiWriteI4 (fcb, scltoken); } return (StdAsciiWriteEp (fcb, VTF3_RECTYPE_MUTEXACQUIRE)); } VTF3_rec_t * VTF3_ComposeMutexrelease (void *fcbcaller, double time, unsigned int cpuid, int enterstatetoken, int leavestatetoken, int leavestatetokenisupfrom, double durationtimesteps, int mutexsize, const void *mutex, int scltoken) { fcb_t *fcb; int numcharshex; fcb = (fcb_t *) fcbcaller; (void) CheckFcbOut (fcb); fcb->lastvalidtime = time; if (enterstatetoken == VTF3_NOSTATE) { (void) fprintf (stderr, "VTF3: Bad value %d as enter state token to " "VTF3_ComposeMutexrelease()\n", VTF3_NOSTATE); (void) fflush (stderr); (void) exit (127); } if (leavestatetokenisupfrom != 0 && leavestatetoken != enterstatetoken) { (void) fprintf (stderr, "VTF3: Bad value %d as leave state token to " "VTF3_ComposeMutexrelease()\n", leavestatetoken); (void) fflush (stderr); (void) exit (127); } if (SignOfDouble (durationtimesteps) < 0) { (void) fprintf (stderr, "VTF3: Negative duration time step number to " "VTF3_ComposeMutexrelease()\n"); (void) fflush (stderr); (void) exit (127); } if (mutexsize < 0) { (void) fprintf (stderr, "VTF3: Bad size value %d to " "VTF3_ComposeMutexrelease()\n", mutexsize); (void) fflush (stderr); (void) exit (127); } if (fcb->fileformat == VTF3_FILEFORMAT_STD_BINARY) { fcb->recbufferpos = fcb->recbuffer + 6; (void) StdBinaryWriteTs (fcb, time); VTF3_STDBINARYCOMPOSE_WRITEU4 (cpuid); VTF3_STDBINARYCOMPOSE_WRITEI4 (enterstatetoken); VTF3_STDBINARYCOMPOSE_WRITEI4 (leavestatetoken); VTF3_STDBINARYCOMPOSE_WRITEI1 ((leavestatetokenisupfrom != 0 ? 1 : 0)); (void) StdBinaryWriteTs (fcb, durationtimesteps); VTF3_STDBINARYCOMPOSE_WRITEI4 (mutexsize / (int) sizeof (char)); (void) StdBinaryWriteCa (fcb, (const char *) mutex, mutexsize / (int) sizeof (char)); if (scltoken != VTF3_SCLNONE) { VTF3_STDBINARYCOMPOSE_WRITEI4 (scltoken); } return (StdBinaryWriteEp (fcb, VTF3_RECTYPE_MUTEXRELEASE)); } fcb->recbufferpos = fcb->recbuffer + 0; (void) StdAsciiWriteTs (fcb, time); (void) StdAsciiWriteSu (fcb, " MUTEXRELEASE CPU "); #if (defined (VTF3_LEGACY_OUTPUT)) (void) StdAsciiWriteU4 (fcb, cpuid + 1); #else (void) StdAsciiWriteU4 (fcb, cpuid); #endif (void) StdAsciiWriteSu (fcb, " DOWNTO "); (void) StdAsciiWriteI4 (fcb, enterstatetoken); if (leavestatetokenisupfrom != 0) (void) StdAsciiWriteSu (fcb, " UPFROM "); else (void) StdAsciiWriteSu (fcb, " UPTO "); if (leavestatetoken == VTF3_NOSTATE) (void) StdAsciiWriteSu (fcb, "NOACT"); else (void) StdAsciiWriteI4 (fcb, leavestatetoken); (void) StdAsciiWriteSu (fcb, " DTSTEPS "); (void) StdAsciiWriteTs (fcb, durationtimesteps); (void) StdAsciiWriteSu (fcb, " MSIZE "); (void) StdAsciiWriteI4 (fcb, mutexsize / (int) sizeof (char)); if (mutexsize > 0) { (void) StdAsciiWriteSu (fcb, " MUTEX "); numcharshex = TransMemToHexUpper (fcb, mutex, (size_t) mutexsize); (void) StdBinaryWriteCa (fcb, fcb->charvector, numcharshex); } if (scltoken == VTF3_SCLRESET) (void) StdAsciiWriteSu (fcb, " SCL RESET"); else if (scltoken != VTF3_SCLNONE) { (void) StdAsciiWriteSu (fcb, " SCL "); (void) StdAsciiWriteI4 (fcb, scltoken); } return (StdAsciiWriteEp (fcb, VTF3_RECTYPE_MUTEXRELEASE)); } VTF3_rec_t * VTF3_ComposeOpenmpenter (void *fcbcaller, double time, unsigned int cpuid, unsigned int constructtypetoken, unsigned int nametoken, int scltoken) { fcb_t *fcb; fcb = (fcb_t *) fcbcaller; (void) CheckFcbOut (fcb); fcb->lastvalidtime = time; if (fcb->fileformat == VTF3_FILEFORMAT_STD_BINARY) { fcb->recbufferpos = fcb->recbuffer + 6; (void) StdBinaryWriteTs (fcb, time); if (cpuid != 0) { VTF3_STDBINARYCOMPOSE_WRITEU4 (cpuid); } VTF3_STDBINARYCOMPOSE_WRITEU4 (constructtypetoken); VTF3_STDBINARYCOMPOSE_WRITEU4 (nametoken); if (scltoken != VTF3_SCLNONE) { VTF3_STDBINARYCOMPOSE_WRITEI4 (scltoken); VTF3_STDBINARYCOMPOSE_WRITEI1 (0); } return (StdBinaryWriteEp (fcb, VTF3_RECTYPE_OPENMPENTER)); } fcb->recbufferpos = fcb->recbuffer + 0; (void) StdAsciiWriteTs (fcb, time); (void) StdAsciiWriteSu (fcb, " OPENMPENTER"); #if (defined (VTF3_LEGACY_OUTPUT)) if (cpuid != 0) { (void) StdAsciiWriteSu (fcb, " CPU "); (void) StdAsciiWriteU4 (fcb, cpuid + 1); } #else if (cpuid != 0) { (void) StdAsciiWriteSu (fcb, " CPU "); (void) StdAsciiWriteU4 (fcb, cpuid); } #endif (void) StdAsciiWriteSu (fcb, " OP "); (void) StdAsciiWriteU4 (fcb, constructtypetoken); (void) StdAsciiWriteSu (fcb, " TAG "); (void) StdAsciiWriteU4 (fcb, nametoken); if (scltoken == VTF3_SCLRESET) (void) StdAsciiWriteSu (fcb, " SCL RESET"); else if (scltoken != VTF3_SCLNONE) { (void) StdAsciiWriteSu (fcb, " SCL "); (void) StdAsciiWriteI4 (fcb, scltoken); } return (StdAsciiWriteEp (fcb, VTF3_RECTYPE_OPENMPENTER)); } VTF3_rec_t * VTF3_ComposeOpenmpleave (void *fcbcaller, double time, unsigned int cpuid, int scltoken) { fcb_t *fcb; fcb = (fcb_t *) fcbcaller; (void) CheckFcbOut (fcb); fcb->lastvalidtime = time; if (fcb->fileformat == VTF3_FILEFORMAT_STD_BINARY) { fcb->recbufferpos = fcb->recbuffer + 6; (void) StdBinaryWriteTs (fcb, time); if (cpuid != 0) { VTF3_STDBINARYCOMPOSE_WRITEU4 (cpuid); } if (scltoken != VTF3_SCLNONE) { VTF3_STDBINARYCOMPOSE_WRITEI4 (scltoken); VTF3_STDBINARYCOMPOSE_WRITEI1 (0); } return (StdBinaryWriteEp (fcb, VTF3_RECTYPE_OPENMPLEAVE)); } fcb->recbufferpos = fcb->recbuffer + 0; (void) StdAsciiWriteTs (fcb, time); (void) StdAsciiWriteSu (fcb, " OPENMPLEAVE"); #if (defined (VTF3_LEGACY_OUTPUT)) if (cpuid != 0) { (void) StdAsciiWriteSu (fcb, " CPU "); (void) StdAsciiWriteU4 (fcb, cpuid + 1); } #else if (cpuid != 0) { (void) StdAsciiWriteSu (fcb, " CPU "); (void) StdAsciiWriteU4 (fcb, cpuid); } #endif if (scltoken == VTF3_SCLRESET) (void) StdAsciiWriteSu (fcb, " SCL RESET"); else if (scltoken != VTF3_SCLNONE) { (void) StdAsciiWriteSu (fcb, " SCL "); (void) StdAsciiWriteI4 (fcb, scltoken); } return (StdAsciiWriteEp (fcb, VTF3_RECTYPE_OPENMPLEAVE)); } VTF3_rec_t * VTF3_ComposeParreg (void *fcbcaller, double time, unsigned int cpugrpid, unsigned int nametoken, int sclstarttoken, int sclendtoken, int timearraydim, const double *timeoffsetanddurationarray) { fcb_t *fcb; int i; fcb = (fcb_t *) fcbcaller; (void) CheckFcbOut (fcb); fcb->lastvalidtime = time; if (sclstarttoken == VTF3_SCLNONE || sclstarttoken == VTF3_SCLRESET) { (void) fprintf (stderr, "VTF3: Bad value %d as SCL start token to " "VTF3_ComposeParreg()\n", sclstarttoken); (void) fflush (stderr); (void) exit (127); } if (sclendtoken == VTF3_SCLNONE || sclendtoken == VTF3_SCLRESET) { (void) fprintf (stderr, "VTF3: Bad value %d as SCL end token to " "VTF3_ComposeParreg()\n", sclendtoken); (void) fflush (stderr); (void) exit (127); } if (timearraydim < 1) { (void) fprintf (stderr, "VTF3: Bad dimension value %d to " "VTF3_ComposeParreg()\n", timearraydim); (void) fflush (stderr); (void) exit (127); } if (fcb->fileformat == VTF3_FILEFORMAT_STD_BINARY) { fcb->recbufferpos = fcb->recbuffer + 6; (void) StdBinaryWriteTs (fcb, time); VTF3_STDBINARYCOMPOSE_WRITEU4 (cpugrpid | VTF3_CPUGRP_MASK); VTF3_STDBINARYCOMPOSE_WRITEU4 (nametoken); VTF3_STDBINARYCOMPOSE_WRITEI4 (sclstarttoken); VTF3_STDBINARYCOMPOSE_WRITEI4 (sclendtoken); VTF3_STDBINARYCOMPOSE_WRITEI4 (timearraydim); for (i = 0; i < timearraydim; i++) { if (SignOfDouble (*(timeoffsetanddurationarray + 2 * i + 0)) < 0) { (void) fprintf (stderr, "VTF3: Negative time offset [%d] to " "VTF3_ComposeParreg()\n", i); (void) fflush (stderr); (void) exit (127); } (void) StdBinaryWriteTs (fcb, *(timeoffsetanddurationarray + 2 * i + 0)); if (SignOfDouble (*(timeoffsetanddurationarray + 2 * i + 1)) < 0) { (void) fprintf (stderr, "VTF3: Negative time duration [%d] to " "VTF3_ComposeParreg()\n", i); (void) fflush (stderr); (void) exit (127); } (void) StdBinaryWriteTs (fcb, *(timeoffsetanddurationarray + 2 * i + 1)); } return (StdBinaryWriteEp (fcb, VTF3_RECTYPE_PARREG)); } fcb->recbufferpos = fcb->recbuffer + 0; (void) StdAsciiWriteTs (fcb, time); #if (defined (VTF3_LEGACY_OUTPUT)) (void) StdAsciiWriteSu (fcb, " PARREG OF TEAM "); (void) StdAsciiWriteU4 (fcb, (cpugrpid | VTF3_CPUGRP_MASK) + 1); #else (void) StdAsciiWriteSu (fcb, " PARREG CPUGRP "); (void) StdAsciiWriteU4 (fcb, (cpugrpid | VTF3_CPUGRP_MASK)); #endif (void) StdAsciiWriteSu (fcb, " TAG "); (void) StdAsciiWriteU4 (fcb, nametoken); (void) StdAsciiWriteSu (fcb, " START SCL "); (void) StdAsciiWriteI4 (fcb, sclstarttoken); (void) StdAsciiWriteSu (fcb, " END SCL "); (void) StdAsciiWriteI4 (fcb, sclendtoken); #if (defined (VTF3_LEGACY_OUTPUT)) (void) StdAsciiWriteSu (fcb, " NUMWILLIES "); #else (void) StdAsciiWriteSu (fcb, " NUMTHREADS "); #endif (void) StdAsciiWriteI4 (fcb, timearraydim); for (i = 0; i < timearraydim; i++) { (void) StdAsciiWriteSu (fcb, " "); if (SignOfDouble (*(timeoffsetanddurationarray + 2 * i + 0)) < 0) { (void) fprintf (stderr, "VTF3: Negative time offset [%d] to " "VTF3_ComposeParreg()\n", i); (void) fflush (stderr); (void) exit (127); } (void) StdAsciiWriteTs (fcb, *(timeoffsetanddurationarray + 2 * i + 0)); (void) StdAsciiWriteSu (fcb, " "); if (SignOfDouble (*(timeoffsetanddurationarray + 2 * i + 1)) < 0) { (void) fprintf (stderr, "VTF3: Negative time duration [%d] to " "VTF3_ComposeParreg()\n", i); (void) fflush (stderr); (void) exit (127); } (void) StdAsciiWriteTs (fcb, *(timeoffsetanddurationarray + 2 * i + 1)); } return (StdAsciiWriteEp (fcb, VTF3_RECTYPE_PARREG)); } VTF3_rec_t * VTF3_ComposePattern (void *fcbcaller, double time, unsigned int cpuid, int patorpatshptoken, double durationtimesteps, int timesteparraydim, const double *timesteparray, const int *patchindexarray) { fcb_t *fcb; int i; fcb = (fcb_t *) fcbcaller; (void) CheckFcbOut (fcb); fcb->lastvalidtime = time; if (patorpatshptoken == VTF3_NOSTATE) { (void) fprintf (stderr, "VTF3: Bad value %d as pattern token to " "VTF3_ComposePattern()\n", VTF3_NOSTATE); (void) fflush (stderr); (void) exit (127); } if (SignOfDouble (durationtimesteps) < 0) { (void) fprintf (stderr, "VTF3: Negative duration time step number to " "VTF3_ComposePattern()\n"); (void) fflush (stderr); (void) exit (127); } if (timesteparraydim < 0) { (void) fprintf (stderr, "VTF3: Bad dimension value %d to " "VTF3_ComposePattern()\n", timesteparraydim); (void) fflush (stderr); (void) exit (127); } if (fcb->fileformat == VTF3_FILEFORMAT_STD_BINARY) { fcb->recbufferpos = fcb->recbuffer + 6; (void) StdBinaryWriteTs (fcb, time); VTF3_STDBINARYCOMPOSE_WRITEU4 (cpuid); VTF3_STDBINARYCOMPOSE_WRITEI4 (patorpatshptoken); (void) StdBinaryWriteTs (fcb, durationtimesteps); for (i = 0; i < timesteparraydim; i++) { if (SignOfDouble (*(timesteparray + i)) < 0) { (void) fprintf (stderr, "VTF3: Negative time step [%d] to " "VTF3_ComposePattern()\n", i); (void) fflush (stderr); (void) exit (127); } (void) StdBinaryWriteTs (fcb, *(timesteparray + i)); } if (patchindexarray != 0) { for (i = 0; i < timesteparraydim; i++) { VTF3_STDBINARYCOMPOSE_WRITEI4 (*(patchindexarray + i)); } VTF3_STDBINARYCOMPOSE_WRITEI1 (0); } return (StdBinaryWriteEp (fcb, VTF3_RECTYPE_PATTERN)); } fcb->recbufferpos = fcb->recbuffer + 0; (void) StdAsciiWriteTs (fcb, time); (void) StdAsciiWriteSu (fcb, " PATTERN "); (void) StdAsciiWriteI4 (fcb, patorpatshptoken); #if (defined (VTF3_LEGACY_OUTPUT)) if (cpuid != 0) { (void) StdAsciiWriteSu (fcb, " CPU "); (void) StdAsciiWriteU4 (fcb, cpuid + 1); } #else if (cpuid != 0) { (void) StdAsciiWriteSu (fcb, " CPU "); (void) StdAsciiWriteU4 (fcb, cpuid); } #endif (void) StdAsciiWriteSu (fcb, " DTSTEPS "); (void) StdAsciiWriteTs (fcb, durationtimesteps); (void) StdAsciiWriteSu (fcb, " NTSTEPS "); (void) StdAsciiWriteI4 (fcb, timesteparraydim); if (timesteparraydim > 0) (void) StdAsciiWriteSu (fcb, " TSTEPS"); for (i = 0; i < timesteparraydim; i++) { (void) StdAsciiWriteSu (fcb, " "); if (SignOfDouble (*(timesteparray + i)) < 0) { (void) fprintf (stderr, "VTF3: Negative time step [%d] to " "VTF3_ComposePattern()\n", i); (void) fflush (stderr); (void) exit (127); } (void) StdAsciiWriteTs (fcb, *(timesteparray + i)); } if (patchindexarray != 0) { if (timesteparraydim > 0) (void) StdAsciiWriteSu (fcb, " PATCHES"); for (i = 0; i < timesteparraydim; i++) { (void) StdAsciiWriteSu (fcb, " "); (void) StdAsciiWriteI4 (fcb, *(patchindexarray + i)); } } return (StdAsciiWriteEp (fcb, VTF3_RECTYPE_PATTERN)); } VTF3_rec_t * VTF3_ComposeRecvmsg (void *fcbcaller, double time, unsigned int receiver, unsigned int sender, int communicator, int msgtype, int msglength, int scltoken) { fcb_t *fcb; fcb = (fcb_t *) fcbcaller; (void) CheckFcbOut (fcb); fcb->lastvalidtime = time; if (fcb->fileformat == VTF3_FILEFORMAT_STD_BINARY) { fcb->recbufferpos = fcb->recbuffer + 6; (void) StdBinaryWriteTs (fcb, time); VTF3_STDBINARYCOMPOSE_WRITEU4 (receiver); VTF3_STDBINARYCOMPOSE_WRITEU4 (sender); VTF3_STDBINARYCOMPOSE_WRITEI4 (communicator); VTF3_STDBINARYCOMPOSE_WRITEI4 (msgtype); VTF3_STDBINARYCOMPOSE_WRITEI4 (msglength); if (scltoken != VTF3_SCLNONE) { VTF3_STDBINARYCOMPOSE_WRITEI4 (scltoken); } return (StdBinaryWriteEp (fcb, VTF3_RECTYPE_RECVMSG)); } if (fcb->fileformat == VTF3_FILEFORMAT_FST_ASCII) { fcb->recbufferpos = fcb->recbuffer + 0; (void) StdAsciiWriteTs (fcb, time); VTF3_FSTASCIICOMPOSE_WRITEC2 ('M', 'R'); VTF3_FSTASCIICOMPOSE_WRITEI4 (msglength); if (communicator != VTF3_NOCOMMUNICATOR) { VTF3_FSTASCIICOMPOSE_WRITEC1 ('C'); VTF3_FSTASCIICOMPOSE_WRITEI4 (communicator); } if (msgtype != 0) { VTF3_FSTASCIICOMPOSE_WRITEC1 ('T'); VTF3_FSTASCIICOMPOSE_WRITEI4 (msgtype); } if (receiver != 0) { VTF3_FSTASCIICOMPOSE_WRITEC1 ('R'); VTF3_FSTASCIICOMPOSE_WRITEU4 (receiver); } if (sender != 0) { VTF3_FSTASCIICOMPOSE_WRITEC1 ('S'); VTF3_FSTASCIICOMPOSE_WRITEU4 (sender); } if (scltoken != VTF3_SCLNONE) { VTF3_FSTASCIICOMPOSE_WRITEC1 ('L'); VTF3_FSTASCIICOMPOSE_WRITEI4 (scltoken); } return (StdAsciiWriteEp (fcb, VTF3_RECTYPE_RECVMSG)); } fcb->recbufferpos = fcb->recbuffer + 0; (void) StdAsciiWriteTs (fcb, time); (void) StdAsciiWriteSu (fcb, " RECVMSG "); #if (defined (VTF3_LEGACY_OUTPUT)) if (communicator != VTF3_NOCOMMUNICATOR) { (void) StdAsciiWriteI4 (fcb, communicator); (void) StdAsciiWriteSu (fcb, " "); } (void) StdAsciiWriteI4 (fcb, msgtype); #else (void) StdAsciiWriteI4 (fcb, msgtype); if (communicator != VTF3_NOCOMMUNICATOR) { (void) StdAsciiWriteSu (fcb, " COM "); (void) StdAsciiWriteI4 (fcb, communicator); } #endif (void) StdAsciiWriteSu (fcb, " BY "); #if (defined (VTF3_LEGACY_OUTPUT)) (void) StdAsciiWriteU4 (fcb, receiver + 1); (void) StdAsciiWriteSu (fcb, " FROM "); (void) StdAsciiWriteU4 (fcb, sender + 1); #else (void) StdAsciiWriteU4 (fcb, receiver); (void) StdAsciiWriteSu (fcb, " FROM "); (void) StdAsciiWriteU4 (fcb, sender); #endif (void) StdAsciiWriteSu (fcb, " LEN "); (void) StdAsciiWriteI4 (fcb, msglength); if (scltoken == VTF3_SCLRESET) (void) StdAsciiWriteSu (fcb, " SCL RESET"); else if (scltoken != VTF3_SCLNONE) { (void) StdAsciiWriteSu (fcb, " SCL "); (void) StdAsciiWriteI4 (fcb, scltoken); } return (StdAsciiWriteEp (fcb, VTF3_RECTYPE_RECVMSG)); } VTF3_rec_t * VTF3_ComposeSamp (void *fcbcaller, double time, unsigned int cpuorcpugrpid, int samplearraydim, const int *sampletokenarray, const int *samplevaluetypearray, const void *samplevaluearray) { fcb_t *fcb; int i, vt; unsigned int ul, uh; double f; fcb = (fcb_t *) fcbcaller; (void) CheckFcbOut (fcb); fcb->lastvalidtime = time; if (samplearraydim < 0) { (void) fprintf (stderr, "VTF3: Bad dimension value %d to " "VTF3_ComposeSamp()\n", samplearraydim); (void) fflush (stderr); (void) exit (127); } if (fcb->fileformat == VTF3_FILEFORMAT_STD_BINARY) { fcb->recbufferpos = fcb->recbuffer + 6; (void) StdBinaryWriteTs (fcb, time); VTF3_STDBINARYCOMPOSE_WRITEU4 (cpuorcpugrpid); for (i = 0; i < samplearraydim; i++) { VTF3_STDBINARYCOMPOSE_WRITEI4 (*(sampletokenarray + i)); if (samplevaluetypearray == 0) vt = VTF3_VALUETYPE_UINT; else if (*(samplevaluetypearray + i) == VTF3_VALUETYPE_FLOAT) vt = VTF3_VALUETYPE_FLOAT; else vt = VTF3_VALUETYPE_UINT; VTF3_STDBINARYCOMPOSE_WRITEI1 (vt); if (vt == VTF3_VALUETYPE_UINT) { if (vtffprtype == VTF3_CONST_FPNRT_IEEE754_DOUBLE_LITEND) { ul = LoadUintFromU4Array (samplevaluearray, 2 * i + 0); uh = LoadUintFromU4Array (samplevaluearray, 2 * i + 1); } else { uh = LoadUintFromU4Array (samplevaluearray, 2 * i + 0); ul = LoadUintFromU4Array (samplevaluearray, 2 * i + 1); } VTF3_STDBINARYCOMPOSE_WRITEU4 (uh); VTF3_STDBINARYCOMPOSE_WRITEU4 (ul); } else { f = LoadDoubleFromU4Array (samplevaluearray, 2 * i + 0); (void) StdBinaryWriteF8 (fcb, f); } } return (StdBinaryWriteEp (fcb, VTF3_RECTYPE_SAMP)); } if (fcb->fileformat == VTF3_FILEFORMAT_FST_ASCII) { fcb->recbufferpos = fcb->recbuffer + 0; (void) StdAsciiWriteTs (fcb, time); VTF3_FSTASCIICOMPOSE_WRITEC2 ('V', 'S'); VTF3_FSTASCIICOMPOSE_WRITEU4 (cpuorcpugrpid); for (i = 0; i < samplearraydim; i++) { if (samplevaluetypearray == 0) vt = VTF3_VALUETYPE_UINT; else if (*(samplevaluetypearray + i) == VTF3_VALUETYPE_FLOAT) vt = VTF3_VALUETYPE_FLOAT; else vt = VTF3_VALUETYPE_UINT; if (vt == VTF3_VALUETYPE_UINT) { VTF3_FSTASCIICOMPOSE_WRITEC1 ('U'); VTF3_FSTASCIICOMPOSE_WRITEI4 (*(sampletokenarray + i)); if (vtffprtype == VTF3_CONST_FPNRT_IEEE754_DOUBLE_LITEND) { ul = LoadUintFromU4Array (samplevaluearray, 2 * i + 0); uh = LoadUintFromU4Array (samplevaluearray, 2 * i + 1); } else { uh = LoadUintFromU4Array (samplevaluearray, 2 * i + 0); ul = LoadUintFromU4Array (samplevaluearray, 2 * i + 1); } if (uh != 0) { VTF3_FSTASCIICOMPOSE_WRITEC1 ('H'); VTF3_FSTASCIICOMPOSE_WRITEU4 (uh); } if (ul != 0) { VTF3_FSTASCIICOMPOSE_WRITEC1 ('L'); VTF3_FSTASCIICOMPOSE_WRITEU4 (ul); } } else { VTF3_FSTASCIICOMPOSE_WRITEC1 ('F'); VTF3_FSTASCIICOMPOSE_WRITEI4 (*(sampletokenarray + i)); f = LoadDoubleFromU4Array (samplevaluearray, 2 * i + 0); (void) FstAsciiWriteXy (fcb, f); } } return (StdAsciiWriteEp (fcb, VTF3_RECTYPE_SAMP)); } fcb->recbufferpos = fcb->recbuffer + 0; (void) StdAsciiWriteTs (fcb, time); #if (defined (VTF3_LEGACY_OUTPUT)) if (VTF3_IS_CPUGRP (cpuorcpugrpid) != 0) (void) StdAsciiWriteSu (fcb, " SAMP GROUP "); else (void) StdAsciiWriteSu (fcb, " SAMP CPU "); (void) StdAsciiWriteU4 (fcb, cpuorcpugrpid + 1); #else if (VTF3_IS_CPUGRP (cpuorcpugrpid) != 0) { (void) StdAsciiWriteSu (fcb, " SAMP GROUP "); (void) StdAsciiWriteU4 (fcb, cpuorcpugrpid); } else if (cpuorcpugrpid != 0) { (void) StdAsciiWriteSu (fcb, " SAMP CPU "); (void) StdAsciiWriteU4 (fcb, cpuorcpugrpid); } else (void) StdAsciiWriteSu (fcb, " SAMP"); #endif for (i = 0; i < samplearraydim; i++) { (void) StdAsciiWriteSu (fcb, " DEF "); (void) StdAsciiWriteI4 (fcb, *(sampletokenarray + i)); if (samplevaluetypearray == 0) vt = VTF3_VALUETYPE_UINT; else if (*(samplevaluetypearray + i) == VTF3_VALUETYPE_FLOAT) vt = VTF3_VALUETYPE_FLOAT; else vt = VTF3_VALUETYPE_UINT; if (vt == VTF3_VALUETYPE_UINT) { (void) StdAsciiWriteSu (fcb, " UINT "); if (vtffprtype == VTF3_CONST_FPNRT_IEEE754_DOUBLE_LITEND) { ul = LoadUintFromU4Array (samplevaluearray, 2 * i + 0); uh = LoadUintFromU4Array (samplevaluearray, 2 * i + 1); } else { uh = LoadUintFromU4Array (samplevaluearray, 2 * i + 0); ul = LoadUintFromU4Array (samplevaluearray, 2 * i + 1); } (void) StdAsciiWriteU4 (fcb, uh); (void) StdAsciiWriteSu (fcb, " "); (void) StdAsciiWriteU4 (fcb, ul); } else { (void) StdAsciiWriteSu (fcb, " FLOAT "); f = LoadDoubleFromU4Array (samplevaluearray, 2 * i + 0); (void) StdAsciiWriteF8 (fcb, f); } } return (StdAsciiWriteEp (fcb, VTF3_RECTYPE_SAMP)); } VTF3_rec_t * VTF3_ComposeSendmsg (void *fcbcaller, double time, unsigned int sender, unsigned int receiver, int communicator, int msgtype, int msglength, int scltoken) { fcb_t *fcb; fcb = (fcb_t *) fcbcaller; (void) CheckFcbOut (fcb); fcb->lastvalidtime = time; if (fcb->fileformat == VTF3_FILEFORMAT_STD_BINARY) { fcb->recbufferpos = fcb->recbuffer + 6; (void) StdBinaryWriteTs (fcb, time); VTF3_STDBINARYCOMPOSE_WRITEU4 (sender); VTF3_STDBINARYCOMPOSE_WRITEU4 (receiver); VTF3_STDBINARYCOMPOSE_WRITEI4 (communicator); VTF3_STDBINARYCOMPOSE_WRITEI4 (msgtype); VTF3_STDBINARYCOMPOSE_WRITEI4 (msglength); if (scltoken != VTF3_SCLNONE) { VTF3_STDBINARYCOMPOSE_WRITEI4 (scltoken); } return (StdBinaryWriteEp (fcb, VTF3_RECTYPE_SENDMSG)); } if (fcb->fileformat == VTF3_FILEFORMAT_FST_ASCII) { fcb->recbufferpos = fcb->recbuffer + 0; (void) StdAsciiWriteTs (fcb, time); VTF3_FSTASCIICOMPOSE_WRITEC2 ('M', 'S'); VTF3_FSTASCIICOMPOSE_WRITEI4 (msglength); if (communicator != VTF3_NOCOMMUNICATOR) { VTF3_FSTASCIICOMPOSE_WRITEC1 ('C'); VTF3_FSTASCIICOMPOSE_WRITEI4 (communicator); } if (msgtype != 0) { VTF3_FSTASCIICOMPOSE_WRITEC1 ('T'); VTF3_FSTASCIICOMPOSE_WRITEI4 (msgtype); } if (sender != 0) { VTF3_FSTASCIICOMPOSE_WRITEC1 ('S'); VTF3_FSTASCIICOMPOSE_WRITEU4 (sender); } if (receiver != 0) { VTF3_FSTASCIICOMPOSE_WRITEC1 ('R'); VTF3_FSTASCIICOMPOSE_WRITEU4 (receiver); } if (scltoken != VTF3_SCLNONE) { VTF3_FSTASCIICOMPOSE_WRITEC1 ('L'); VTF3_FSTASCIICOMPOSE_WRITEI4 (scltoken); } return (StdAsciiWriteEp (fcb, VTF3_RECTYPE_SENDMSG)); } fcb->recbufferpos = fcb->recbuffer + 0; (void) StdAsciiWriteTs (fcb, time); (void) StdAsciiWriteSu (fcb, " SENDMSG "); #if (defined (VTF3_LEGACY_OUTPUT)) if (communicator != VTF3_NOCOMMUNICATOR) { (void) StdAsciiWriteI4 (fcb, communicator); (void) StdAsciiWriteSu (fcb, " "); } (void) StdAsciiWriteI4 (fcb, msgtype); #else (void) StdAsciiWriteI4 (fcb, msgtype); if (communicator != VTF3_NOCOMMUNICATOR) { (void) StdAsciiWriteSu (fcb, " COM "); (void) StdAsciiWriteI4 (fcb, communicator); } #endif (void) StdAsciiWriteSu (fcb, " FROM "); #if (defined (VTF3_LEGACY_OUTPUT)) (void) StdAsciiWriteU4 (fcb, sender + 1); (void) StdAsciiWriteSu (fcb, " TO "); (void) StdAsciiWriteU4 (fcb, receiver + 1); #else (void) StdAsciiWriteU4 (fcb, sender); (void) StdAsciiWriteSu (fcb, " TO "); (void) StdAsciiWriteU4 (fcb, receiver); #endif (void) StdAsciiWriteSu (fcb, " LEN "); (void) StdAsciiWriteI4 (fcb, msglength); if (scltoken == VTF3_SCLRESET) (void) StdAsciiWriteSu (fcb, " SCL RESET"); else if (scltoken != VTF3_SCLNONE) { (void) StdAsciiWriteSu (fcb, " SCL "); (void) StdAsciiWriteI4 (fcb, scltoken); } return (StdAsciiWriteEp (fcb, VTF3_RECTYPE_SENDMSG)); } VTF3_rec_t * VTF3_ComposeSrcinfo_obsol (void *fcbcaller, double time, int activitytoken, int statetoken, int scllineposition) { fcb_t *fcb; fcb = (fcb_t *) fcbcaller; (void) CheckFcbOut (fcb); fcb->lastvalidtime = time; if (activitytoken == VTF3_NOACT) { (void) fprintf (stderr, "VTF3: Bad value %d as activity token to " "VTF3_ComposeSrcinfo_obsol()\n", VTF3_NOACT); (void) fflush (stderr); (void) exit (127); } if (statetoken == VTF3_NOSTATE) { (void) fprintf (stderr, "VTF3: Bad value %d as state token to " "VTF3_ComposeSrcinfo_obsol()\n", VTF3_NOSTATE); (void) fflush (stderr); (void) exit (127); } if (fcb->fileformat == VTF3_FILEFORMAT_STD_BINARY) { fcb->recbufferpos = fcb->recbuffer + 6; (void) StdBinaryWriteTs (fcb, time); VTF3_STDBINARYCOMPOSE_WRITEI4 (activitytoken); VTF3_STDBINARYCOMPOSE_WRITEI4 (statetoken); VTF3_STDBINARYCOMPOSE_WRITEI4 (scllineposition); return (StdBinaryWriteEp (fcb, VTF3_RECTYPE_SRCINFO_OBSOL)); } fcb->recbufferpos = fcb->recbuffer + 0; (void) StdAsciiWriteTs (fcb, time); #if (defined (VTF3_LEGACY_OUTPUT)) (void) StdAsciiWriteSu (fcb, " SRC "); (void) StdAsciiWriteI4 (fcb, activitytoken); (void) StdAsciiWriteSu (fcb, " "); (void) StdAsciiWriteI4 (fcb, statetoken); (void) StdAsciiWriteSu (fcb, " "); (void) StdAsciiWriteI4 (fcb, scllineposition); #else (void) StdAsciiWriteSu (fcb, " SRC ACT "); (void) StdAsciiWriteI4 (fcb, activitytoken); (void) StdAsciiWriteSu (fcb, " STATE "); (void) StdAsciiWriteI4 (fcb, statetoken); (void) StdAsciiWriteSu (fcb, " POS "); (void) StdAsciiWriteI4 (fcb, scllineposition); #endif return (StdAsciiWriteEp (fcb, VTF3_RECTYPE_SRCINFO_OBSOL)); } VTF3_rec_t * VTF3_ComposeUnrecognizable (void *fcbcaller, double lastvalidtime, int numberofunrecognizablechars, int typeofunrecognizablerecord, const char *unrecognizablerecord) { static int numcharssamplemax = 100; fcb_t *fcb; int strlenoffset, numcharssample, numcharshex, finaloffset, len; const char *keyword; size_t size; fcb = (fcb_t *) fcbcaller; (void) CheckFcbOut (fcb); fcb->lastvalidtime = lastvalidtime; if (fcb->fileformat == VTF3_FILEFORMAT_STD_BINARY) { fcb->recbufferpos = fcb->recbuffer + 6; (void) StdBinaryWriteTs (fcb, lastvalidtime); strlenoffset = (int) (fcb->recbufferpos - fcb->recbuffer); (void) StdBinaryWriteI2 (fcb, 0); if (typeofunrecognizablerecord == VTF3_RECTYPE_UNRECOGNIZABLE) (void) StdAsciiWriteSu (fcb, "Unrecognizable"); else { (void) StdAsciiWriteSu (fcb, "Corrupt "); keyword = KeyWordByRecType (typeofunrecognizablerecord); (void) StdAsciiWriteSu (fcb, keyword); } (void) StdAsciiWriteSu (fcb, " record, length = "); (void) StdAsciiWriteI4 (fcb, numberofunrecognizablechars); (void) StdAsciiWriteSu (fcb, ", contents = "); numcharssample = numberofunrecognizablechars; if (numcharssample < 0) numcharssample = 0; if (numcharssample > numcharssamplemax) numcharssample = numcharssamplemax; if (numcharssample == 0) (void) StdAsciiWriteSu (fcb, "?"); else { (void) StdAsciiWriteSu (fcb, "0x"); size = (size_t) numcharssample * sizeof (char); numcharshex = TransMemToHexLower (fcb, unrecognizablerecord, size); (void) StdBinaryWriteCa (fcb, fcb->charvector, numcharshex); if (numcharssample < numberofunrecognizablechars) (void) StdAsciiWriteSu (fcb, "..."); } finaloffset = (int) (fcb->recbufferpos - fcb->recbuffer); len = finaloffset - (strlenoffset + 2); if (len > (int) (unsigned int) 0x7fff) len = (int) (unsigned int) 0x7fff; finaloffset = strlenoffset + 2 + len; fcb->recbufferpos = fcb->recbuffer + strlenoffset; (void) StdBinaryWriteI2 (fcb, len); fcb->recbufferpos = fcb->recbuffer + finaloffset; return (StdBinaryWriteEp (fcb, VTF3_RECTYPE_COMMENT)); } if (fcb->fileformat == VTF3_FILEFORMAT_FST_ASCII) { fcb->recbufferpos = fcb->recbuffer + 0; (void) StdAsciiWriteTs (fcb, lastvalidtime); if (typeofunrecognizablerecord == VTF3_RECTYPE_UNRECOGNIZABLE) { if (fcb->recbufferpos + 17 > fcb->recbufferbeyond) (void) ReallocRecord (fcb, 17); *(fcb->recbufferpos + 0) = 'C'; *(fcb->recbufferpos + 1) = 'C'; *(fcb->recbufferpos + 2) = ' '; *(fcb->recbufferpos + 3) = 'U'; *(fcb->recbufferpos + 4) = 'n'; *(fcb->recbufferpos + 5) = 'r'; *(fcb->recbufferpos + 6) = 'e'; *(fcb->recbufferpos + 7) = 'c'; *(fcb->recbufferpos + 8) = 'o'; *(fcb->recbufferpos + 9) = 'g'; *(fcb->recbufferpos + 10) = 'n'; *(fcb->recbufferpos + 11) = 'i'; *(fcb->recbufferpos + 12) = 'z'; *(fcb->recbufferpos + 13) = 'a'; *(fcb->recbufferpos + 14) = 'b'; *(fcb->recbufferpos + 15) = 'l'; *(fcb->recbufferpos + 16) = 'e'; fcb->recbufferpos += 17; } else { if (fcb->recbufferpos + 11 > fcb->recbufferbeyond) (void) ReallocRecord (fcb, 11); *(fcb->recbufferpos + 0) = 'C'; *(fcb->recbufferpos + 1) = 'C'; *(fcb->recbufferpos + 2) = ' '; *(fcb->recbufferpos + 3) = 'C'; *(fcb->recbufferpos + 4) = 'o'; *(fcb->recbufferpos + 5) = 'r'; *(fcb->recbufferpos + 6) = 'r'; *(fcb->recbufferpos + 7) = 'u'; *(fcb->recbufferpos + 8) = 'p'; *(fcb->recbufferpos + 9) = 't'; *(fcb->recbufferpos + 10) = ' '; fcb->recbufferpos += 11; keyword = KeyWordByRecType (typeofunrecognizablerecord); (void) StdAsciiWriteSu (fcb, keyword); } if (fcb->recbufferpos + 18 > fcb->recbufferbeyond) (void) ReallocRecord (fcb, 18); *(fcb->recbufferpos + 0) = ' '; *(fcb->recbufferpos + 1) = 'r'; *(fcb->recbufferpos + 2) = 'e'; *(fcb->recbufferpos + 3) = 'c'; *(fcb->recbufferpos + 4) = 'o'; *(fcb->recbufferpos + 5) = 'r'; *(fcb->recbufferpos + 6) = 'd'; *(fcb->recbufferpos + 7) = ','; *(fcb->recbufferpos + 8) = ' '; *(fcb->recbufferpos + 9) = 'l'; *(fcb->recbufferpos + 10) = 'e'; *(fcb->recbufferpos + 11) = 'n'; *(fcb->recbufferpos + 12) = 'g'; *(fcb->recbufferpos + 13) = 't'; *(fcb->recbufferpos + 14) = 'h'; *(fcb->recbufferpos + 15) = ' '; *(fcb->recbufferpos + 16) = '='; *(fcb->recbufferpos + 17) = ' '; fcb->recbufferpos += 18; VTF3_FSTASCIICOMPOSE_WRITEI4 (numberofunrecognizablechars); if (fcb->recbufferpos + 13 > fcb->recbufferbeyond) (void) ReallocRecord (fcb, 13); *(fcb->recbufferpos + 0) = ','; *(fcb->recbufferpos + 1) = ' '; *(fcb->recbufferpos + 2) = 'c'; *(fcb->recbufferpos + 3) = 'o'; *(fcb->recbufferpos + 4) = 'n'; *(fcb->recbufferpos + 5) = 't'; *(fcb->recbufferpos + 6) = 'e'; *(fcb->recbufferpos + 7) = 'n'; *(fcb->recbufferpos + 8) = 't'; *(fcb->recbufferpos + 9) = 's'; *(fcb->recbufferpos + 10) = ' '; *(fcb->recbufferpos + 11) = '='; *(fcb->recbufferpos + 12) = ' '; fcb->recbufferpos += 13; numcharssample = numberofunrecognizablechars; if (numcharssample < 0) numcharssample = 0; if (numcharssample > numcharssamplemax) numcharssample = numcharssamplemax; if (numcharssample == 0) { VTF3_FSTASCIICOMPOSE_WRITEC1 ('?'); } else { VTF3_FSTASCIICOMPOSE_WRITEC2 ('0', 'x'); size = (size_t) numcharssample * sizeof (char); numcharshex = TransMemToHexLower (fcb, unrecognizablerecord, size); (void) StdBinaryWriteCa (fcb, fcb->charvector, numcharshex); if (numcharssample < numberofunrecognizablechars) { VTF3_FSTASCIICOMPOSE_WRITEC3 ('.', '.', '.'); } } return (StdAsciiWriteEp (fcb, VTF3_RECTYPE_COMMENT)); } fcb->recbufferpos = fcb->recbuffer + 0; (void) StdAsciiWriteTs (fcb, lastvalidtime); if (typeofunrecognizablerecord == VTF3_RECTYPE_UNRECOGNIZABLE) (void) StdAsciiWriteSu (fcb, " C Unrecognizable"); else { (void) StdAsciiWriteSu (fcb, " C Corrupt "); keyword = KeyWordByRecType (typeofunrecognizablerecord); (void) StdAsciiWriteSu (fcb, keyword); } (void) StdAsciiWriteSu (fcb, " record, length = "); (void) StdAsciiWriteI4 (fcb, numberofunrecognizablechars); (void) StdAsciiWriteSu (fcb, ", contents = "); numcharssample = numberofunrecognizablechars; if (numcharssample < 0) numcharssample = 0; if (numcharssample > numcharssamplemax) numcharssample = numcharssamplemax; if (numcharssample == 0) (void) StdAsciiWriteSu (fcb, "?"); else { (void) StdAsciiWriteSu (fcb, "0x"); size = (size_t) numcharssample * sizeof (char); numcharshex = TransMemToHexLower (fcb, unrecognizablerecord, size); (void) StdBinaryWriteCa (fcb, fcb->charvector, numcharshex); if (numcharssample < numberofunrecognizablechars) (void) StdAsciiWriteSu (fcb, "..."); } return (StdAsciiWriteEp (fcb, VTF3_RECTYPE_COMMENT)); } VTF3_rec_t * VTF3_ComposeUpfrom (void *fcbcaller, double time, int statetoken, unsigned int cpuid, int scltoken) { fcb_t *fcb; fcb = (fcb_t *) fcbcaller; (void) CheckFcbOut (fcb); fcb->lastvalidtime = time; if (statetoken == VTF3_NOSTATE) { (void) fprintf (stderr, "VTF3: Bad value %d as state token to " "VTF3_ComposeUpfrom()\n", VTF3_NOSTATE); (void) fflush (stderr); (void) exit (127); } if (fcb->fileformat == VTF3_FILEFORMAT_STD_BINARY) { fcb->recbufferpos = fcb->recbuffer + 6; (void) StdBinaryWriteTs (fcb, time); VTF3_STDBINARYCOMPOSE_WRITEI4 (statetoken); if (cpuid != 0) { VTF3_STDBINARYCOMPOSE_WRITEU4 (cpuid); } if (scltoken != VTF3_SCLNONE) { VTF3_STDBINARYCOMPOSE_WRITEI4 (scltoken); VTF3_STDBINARYCOMPOSE_WRITEI1 (0); } return (StdBinaryWriteEp (fcb, VTF3_RECTYPE_UPFROM)); } if (fcb->fileformat == VTF3_FILEFORMAT_FST_ASCII) { fcb->recbufferpos = fcb->recbuffer + 0; (void) StdAsciiWriteTs (fcb, time); VTF3_FSTASCIICOMPOSE_WRITEC2 ('X', 'F'); VTF3_FSTASCIICOMPOSE_WRITEI4 (statetoken); if (cpuid != 0) { VTF3_FSTASCIICOMPOSE_WRITEC1 ('P'); VTF3_FSTASCIICOMPOSE_WRITEU4 (cpuid); } if (scltoken != VTF3_SCLNONE) { VTF3_FSTASCIICOMPOSE_WRITEC1 ('L'); VTF3_FSTASCIICOMPOSE_WRITEI4 (scltoken); } return (StdAsciiWriteEp (fcb, VTF3_RECTYPE_UPFROM)); } fcb->recbufferpos = fcb->recbuffer + 0; (void) StdAsciiWriteTs (fcb, time); (void) StdAsciiWriteSu (fcb, " UPFROM "); (void) StdAsciiWriteI4 (fcb, statetoken); #if (defined (VTF3_LEGACY_OUTPUT)) if (cpuid != 0) { (void) StdAsciiWriteSu (fcb, " CPU "); (void) StdAsciiWriteU4 (fcb, cpuid + 1); } #else if (cpuid != 0) { (void) StdAsciiWriteSu (fcb, " CPU "); (void) StdAsciiWriteU4 (fcb, cpuid); } #endif if (scltoken == VTF3_SCLRESET) (void) StdAsciiWriteSu (fcb, " SCL RESET"); else if (scltoken != VTF3_SCLNONE) { (void) StdAsciiWriteSu (fcb, " SCL "); (void) StdAsciiWriteI4 (fcb, scltoken); } return (StdAsciiWriteEp (fcb, VTF3_RECTYPE_UPFROM)); } VTF3_rec_t * VTF3_ComposeUpto (void *fcbcaller, double time, int statetoken, unsigned int cpuid, int scltoken) { fcb_t *fcb; fcb = (fcb_t *) fcbcaller; (void) CheckFcbOut (fcb); fcb->lastvalidtime = time; if (fcb->fileformat == VTF3_FILEFORMAT_STD_BINARY) { fcb->recbufferpos = fcb->recbuffer + 6; (void) StdBinaryWriteTs (fcb, time); VTF3_STDBINARYCOMPOSE_WRITEI4 (statetoken); if (cpuid != 0) { VTF3_STDBINARYCOMPOSE_WRITEU4 (cpuid); } if (scltoken != VTF3_SCLNONE) { VTF3_STDBINARYCOMPOSE_WRITEI4 (scltoken); VTF3_STDBINARYCOMPOSE_WRITEI1 (0); } return (StdBinaryWriteEp (fcb, VTF3_RECTYPE_UPTO)); } if (fcb->fileformat == VTF3_FILEFORMAT_FST_ASCII) { fcb->recbufferpos = fcb->recbuffer + 0; (void) StdAsciiWriteTs (fcb, time); VTF3_FSTASCIICOMPOSE_WRITEC2 ('X', 'U'); VTF3_FSTASCIICOMPOSE_WRITEI4 (statetoken); if (cpuid != 0) { VTF3_FSTASCIICOMPOSE_WRITEC1 ('P'); VTF3_FSTASCIICOMPOSE_WRITEU4 (cpuid); } if (scltoken != VTF3_SCLNONE) { VTF3_FSTASCIICOMPOSE_WRITEC1 ('L'); VTF3_FSTASCIICOMPOSE_WRITEI4 (scltoken); } return (StdAsciiWriteEp (fcb, VTF3_RECTYPE_UPTO)); } fcb->recbufferpos = fcb->recbuffer + 0; (void) StdAsciiWriteTs (fcb, time); (void) StdAsciiWriteSu (fcb, " UPTO "); if (statetoken == VTF3_NOSTATE) (void) StdAsciiWriteSu (fcb, "NOACT"); else (void) StdAsciiWriteI4 (fcb, statetoken); #if (defined (VTF3_LEGACY_OUTPUT)) if (cpuid != 0) { (void) StdAsciiWriteSu (fcb, " CPU "); (void) StdAsciiWriteU4 (fcb, cpuid + 1); } #else if (cpuid != 0) { (void) StdAsciiWriteSu (fcb, " CPU "); (void) StdAsciiWriteU4 (fcb, cpuid); } #endif if (scltoken == VTF3_SCLRESET) (void) StdAsciiWriteSu (fcb, " SCL RESET"); else if (scltoken != VTF3_SCLNONE) { (void) StdAsciiWriteSu (fcb, " SCL "); (void) StdAsciiWriteI4 (fcb, scltoken); } return (StdAsciiWriteEp (fcb, VTF3_RECTYPE_UPTO)); } /*****************************************************************************/ static void StdAsciiParserClstrregval (fcb_t *fcb, int numcharsdata, int handlerindex, int havetime, double time) { int clstrtoken, clstrregarraydim, clstrregtoken, rc; unsigned int uh, ul; double f; VTF3_DCL_CLSTRREGVAL (typedef, (*handler_t)); handler_t handler; if (havetime == 0) goto Error; VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('C'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('L'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('S'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('T'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('R'); VTF3_ASCIIPARSER_CHECK_AND_PASS_BLANK; VTF3_STDASCIIPARSER_READI4 (clstrtoken); clstrregarraydim = 0; while (VTF3_ASCIIPARSER_TEST_CHAR ('R') != 0) { fcb->recbufferpos++; VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('E'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('G'); VTF3_ASCIIPARSER_CHECK_AND_PASS_BLANK; VTF3_STDASCIIPARSER_READI4 (clstrregtoken); VTF3_STORE_ONTO_INT_VECTOR (clstrregarraydim, clstrregtoken); if (VTF3_ASCIIPARSER_TEST_CHAR ('U') != 0) { fcb->recbufferpos++; VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('I'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('N'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('T'); VTF3_ASCIIPARSER_CHECK_AND_PASS_BLANK; VTF3_STDASCIIPARSER_READU4 (uh); VTF3_STDASCIIPARSER_READU4 (ul); VTF3_STORE_ONTO_INT_VECTOR2 (clstrregarraydim, VTF3_VALUETYPE_UINT); if (vtffprtype == VTF3_CONST_FPNRT_IEEE754_DOUBLE_LITEND) { VTF3_STORE_UINT_ONTO_U4VECTOR (2 * clstrregarraydim + 0, ul); VTF3_STORE_UINT_ONTO_U4VECTOR (2 * clstrregarraydim + 1, uh); } else { VTF3_STORE_UINT_ONTO_U4VECTOR (2 * clstrregarraydim + 0, uh); VTF3_STORE_UINT_ONTO_U4VECTOR (2 * clstrregarraydim + 1, ul); } clstrregarraydim++; continue; } VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('F'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('L'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('O'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('A'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('T'); VTF3_ASCIIPARSER_CHECK_AND_PASS_BLANK; if (StdAsciiReadF8 (fcb, &f) == 0) goto Error; VTF3_STORE_ONTO_INT_VECTOR2 (clstrregarraydim, VTF3_VALUETYPE_FLOAT); (void) StoreDoubleOntoU4Vector (fcb, 2 * clstrregarraydim + 0, f); clstrregarraydim++; } VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('\n'); VTF3_PARSER_LAST_VALID_TIME_MANAGEMENT; VTF3_PARSER_HANDLER_CALL_PROLOGUE (handler_t, handler); rc = (handler) (*(fcb->firsthandlerargs + handlerindex), time, clstrtoken, clstrregarraydim, fcb->intvector, fcb->intvector2, fcb->u4vector); VTF3_PARSER_HANDLER_CALL_EPILOGUE; return; /* LABEL */ Error: (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } static void StdAsciiParserComment (fcb_t *fcb, int numcharsdata, int handlerindex, int havetime, double time) { static unsigned int first = 1; static unsigned char uchar80h = (unsigned char) 0x80; char *p; const char *comment; int rc; VTF3_DCL_COMMENT (typedef, (*handler_t)); handler_t handler; if (first != 0) { first = 0; (void) PassI (numcharsdata); } if (havetime == 0) return; p = fcb->recbufferpos - 1; while (vtfspace[VTF3_CHAR2INDEX (*p)] != 0) p--; p++; if (vtfspace[VTF3_CHAR2INDEX (*p)] != 0) p++; comment = p; while (*p != '\n' && p < comment + (unsigned int) 0x7fff) { if (*p == '\0') *p = (char) * (char *) (unsigned char *) &uchar80h; p++; } if (p != comment && *(p - 0) == '\n' && *(p - 1) == '\r') p--; *p = '\0'; VTF3_PARSER_LAST_VALID_TIME_MANAGEMENT; VTF3_PARSER_HANDLER_CALL_PROLOGUE (handler_t, handler); rc = (handler) (*(fcb->firsthandlerargs + handlerindex), time, comment); VTF3_PARSER_HANDLER_CALL_EPILOGUE; return; } static void StdAsciiParserCpuregval (fcb_t *fcb, int numcharsdata, int handlerindex, int havetime, double time) { unsigned int cpuid, uh, ul; int cpuregarraydim, cpuregtoken, rc; double f; VTF3_DCL_CPUREGVAL (typedef, (*handler_t)); handler_t handler; if (havetime == 0) goto Error; if (VTF3_ASCIIPARSER_TEST_CHAR ('C') != 0) { fcb->recbufferpos++; VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('P'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('U'); VTF3_ASCIIPARSER_CHECK_AND_PASS_BLANK; VTF3_STDASCIIPARSER_READU4 (cpuid); if (fcb->legacyascii != 0) { if (cpuid == 0) goto Error; cpuid--; } } else cpuid = 0; cpuregarraydim = 0; while (VTF3_ASCIIPARSER_TEST_CHAR ('R') != 0) { fcb->recbufferpos++; VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('E'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('G'); VTF3_ASCIIPARSER_CHECK_AND_PASS_BLANK; VTF3_STDASCIIPARSER_READI4 (cpuregtoken); VTF3_STORE_ONTO_INT_VECTOR (cpuregarraydim, cpuregtoken); if (VTF3_ASCIIPARSER_TEST_CHAR ('U') != 0) { fcb->recbufferpos++; VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('I'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('N'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('T'); VTF3_ASCIIPARSER_CHECK_AND_PASS_BLANK; VTF3_STDASCIIPARSER_READU4 (uh); VTF3_STDASCIIPARSER_READU4 (ul); VTF3_STORE_ONTO_INT_VECTOR2 (cpuregarraydim, VTF3_VALUETYPE_UINT); if (vtffprtype == VTF3_CONST_FPNRT_IEEE754_DOUBLE_LITEND) { VTF3_STORE_UINT_ONTO_U4VECTOR (2 * cpuregarraydim + 0, ul); VTF3_STORE_UINT_ONTO_U4VECTOR (2 * cpuregarraydim + 1, uh); } else { VTF3_STORE_UINT_ONTO_U4VECTOR (2 * cpuregarraydim + 0, uh); VTF3_STORE_UINT_ONTO_U4VECTOR (2 * cpuregarraydim + 1, ul); } cpuregarraydim++; continue; } VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('F'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('L'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('O'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('A'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('T'); VTF3_ASCIIPARSER_CHECK_AND_PASS_BLANK; if (StdAsciiReadF8 (fcb, &f) == 0) goto Error; VTF3_STORE_ONTO_INT_VECTOR2 (cpuregarraydim, VTF3_VALUETYPE_FLOAT); (void) StoreDoubleOntoU4Vector (fcb, 2 * cpuregarraydim + 0, f); cpuregarraydim++; } VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('\n'); VTF3_PARSER_LAST_VALID_TIME_MANAGEMENT; VTF3_PARSER_HANDLER_CALL_PROLOGUE (handler_t, handler); rc = (handler) (*(fcb->firsthandlerargs + handlerindex), time, cpuid, cpuregarraydim, fcb->intvector, fcb->intvector2, fcb->u4vector); VTF3_PARSER_HANDLER_CALL_EPILOGUE; return; /* LABEL */ Error: (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } static void StdAsciiParserDefact (fcb_t *fcb, int numcharsdata, int handlerindex, int havetime, double time) { static unsigned int first = 1; static const char *noact = "NOACT"; int activitytoken, len, i, isequal, rc; const char *activityname; VTF3_DCL_DEFACT (typedef, (*handler_t)); handler_t handler; if (first != 0) { first = 0; (void) PassF (time); } if (havetime != 0) goto Error; VTF3_STDASCIIPARSER_READI4 (activitytoken); if (StdAsciiStoreStringOffsets (fcb, 0) == 0) goto Error; len = GetStringLength (fcb, 0); activityname = fcb->recbuffer + *(fcb->stroffsetvectorstart + 0); if (activitytoken == VTF3_NOACT) { if (len != 5) goto Error; for (i = 0; i < 5; i++) if (*(activityname + i) != *(noact + i)) goto Error; /* Trivial information, ignore this record. */ return; } if (len == 5) { isequal = 1; for (i = 0; i < 5; i++) if (*(activityname + i) != *(noact + i)) { isequal = 0; break; } if (isequal != 0) goto Error; } VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('\n'); activityname = StdAsciiGetSeparatedString (fcb, 0); VTF3_PARSER_HANDLER_CALL_PROLOGUE (handler_t, handler); rc = (handler) (*(fcb->firsthandlerargs + handlerindex), activitytoken, activityname); VTF3_PARSER_HANDLER_CALL_EPILOGUE; return; /* LABEL */ Error: (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } static void StdAsciiParserDefact_obsol (fcb_t *fcb, int numcharsdata, int handlerindex, int havetime, double time) { static unsigned int first = 1; static const char *noact = "NOACT"; int activitytoken, len, i, isequal, rc; const char *activityname; VTF3_DCL_DEFACT_OBSOL (typedef, (*handler_t)); handler_t handler; if (first != 0) { first = 0; (void) PassF (time); } if (havetime != 0) goto Error; if (VTF3_ASCIIPARSER_TEST_CHAR ('N') != 0) { fcb->recbufferpos++; VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('O'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('A'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('C'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('T'); VTF3_ASCIIPARSER_CHECK_AND_PASS_BLANK; activitytoken = VTF3_NOACT; } else VTF3_STDASCIIPARSER_READI4 (activitytoken); if (StdAsciiStoreStringOffsets (fcb, 0) == 0) goto Error; len = GetStringLength (fcb, 0); activityname = fcb->recbuffer + *(fcb->stroffsetvectorstart + 0); if (activitytoken == VTF3_NOACT) { if (len != 5) goto Error; for (i = 0; i < 5; i++) if (*(activityname + i) != *(noact + i)) goto Error; /* Trivial information, ignore this record. */ return; } if (len == 5) { isequal = 1; for (i = 0; i < 5; i++) if (*(activityname + i) != *(noact + i)) { isequal = 0; break; } if (isequal != 0) goto Error; } VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('\n'); activityname = StdAsciiGetSeparatedString (fcb, 0); VTF3_PARSER_HANDLER_CALL_PROLOGUE (handler_t, handler); rc = (handler) (*(fcb->firsthandlerargs + handlerindex), activitytoken, activityname); VTF3_PARSER_HANDLER_CALL_EPILOGUE; return; /* LABEL */ Error: (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } static void StdAsciiParserDefclkperiod (fcb_t *fcb, int numcharsdata, int handlerindex, int havetime, double time) { static unsigned int first = 1; double clkperiod; int rc; VTF3_DCL_DEFCLKPERIOD (typedef, (*handler_t)); handler_t handler; if (first != 0) { first = 0; (void) PassF (time); } if (havetime != 0) goto Error; if (StdAsciiReadF8 (fcb, &clkperiod) == 0) goto Error; VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('\n'); VTF3_PARSER_HANDLER_CALL_PROLOGUE (handler_t, handler); rc = (handler) (*(fcb->firsthandlerargs + handlerindex), clkperiod); VTF3_PARSER_HANDLER_CALL_EPILOGUE; return; /* LABEL */ Error: (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } static void StdAsciiParserDefclstr (fcb_t *fcb, int numcharsdata, int handlerindex, int havetime, double time) { static unsigned int first = 1; int clstrtoken, cpuidarraydim, i, rc; unsigned int cpuid; const char *clstrname; VTF3_DCL_DEFCLSTR (typedef, (*handler_t)); handler_t handler; if (first != 0) { first = 0; (void) PassF (time); } if (havetime != 0) goto Error; VTF3_STDASCIIPARSER_READI4 (clstrtoken); if (StdAsciiStoreStringOffsets (fcb, 0) == 0) goto Error; VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('N'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('C'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('P'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('U'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('S'); VTF3_ASCIIPARSER_CHECK_AND_PASS_BLANK; VTF3_STDASCIIPARSER_READI4 (cpuidarraydim); if (cpuidarraydim < 0) goto Error; if (cpuidarraydim > 0) { VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('C'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('P'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('U'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('S'); VTF3_ASCIIPARSER_CHECK_AND_PASS_BLANK; } for (i = 0; i < cpuidarraydim; i++) { VTF3_STDASCIIPARSER_READU4 (cpuid); if (fcb->legacyascii != 0) { if (cpuid == 0) goto Error; cpuid--; } VTF3_STORE_ONTO_UINT_VECTOR (i, cpuid); } VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('\n'); clstrname = StdAsciiGetSeparatedString (fcb, 0); VTF3_PARSER_HANDLER_CALL_PROLOGUE (handler_t, handler); rc = (handler) (*(fcb->firsthandlerargs + handlerindex), clstrtoken, clstrname, cpuidarraydim, fcb->uintvector); VTF3_PARSER_HANDLER_CALL_EPILOGUE; return; /* LABEL */ Error: (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } static void StdAsciiParserDefclstrreg (fcb_t *fcb, int numcharsdata, int handlerindex, int havetime, double time) { static unsigned int first = 1; int clstrregtoken, clstrregclasstoken, valuetype, rc; unsigned int uminh, uminl, umaxh, umaxl; double fmin, fmax; const char *clstrregname, *clstrregunit; VTF3_DCL_DEFCLSTRREG (typedef, (*handler_t)); handler_t handler; if (first != 0) { first = 0; (void) PassF (time); } if (havetime != 0) goto Error; VTF3_STDASCIIPARSER_READI4 (clstrregtoken); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('C'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('L'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('A'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('S'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('S'); VTF3_ASCIIPARSER_CHECK_AND_PASS_BLANK; VTF3_STDASCIIPARSER_READI4 (clstrregclasstoken); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('T'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('Y'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('P'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('E'); VTF3_ASCIIPARSER_CHECK_AND_PASS_BLANK; VTF3_ASCIIPARSER_PASS_BLANKS (fcb->recbufferpos); valuetype = VTF3_VALUETYPE_UINT; if (VTF3_ASCIIPARSER_TEST_CHAR ('U') != 0) { fcb->recbufferpos++; VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('I'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('N'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('T'); VTF3_ASCIIPARSER_CHECK_AND_PASS_BLANK; VTF3_ASCIIPARSER_PASS_BLANKS (fcb->recbufferpos); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('M'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('I'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('N'); VTF3_ASCIIPARSER_CHECK_AND_PASS_BLANK; VTF3_STDASCIIPARSER_READU4 (uminh); VTF3_STDASCIIPARSER_READU4 (uminl); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('M'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('A'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('X'); VTF3_ASCIIPARSER_CHECK_AND_PASS_BLANK; VTF3_STDASCIIPARSER_READU4 (umaxh); VTF3_STDASCIIPARSER_READU4 (umaxl); if (vtffprtype == VTF3_CONST_FPNRT_IEEE754_DOUBLE_LITEND) { VTF3_STORE_UINT_ONTO_U4VECTOR (0, uminl); VTF3_STORE_UINT_ONTO_U4VECTOR (1, uminh); VTF3_STORE_UINT_ONTO_U4VECTOR (2, umaxl); VTF3_STORE_UINT_ONTO_U4VECTOR (3, umaxh); } else { VTF3_STORE_UINT_ONTO_U4VECTOR (0, uminh); VTF3_STORE_UINT_ONTO_U4VECTOR (1, uminl); VTF3_STORE_UINT_ONTO_U4VECTOR (2, umaxh); VTF3_STORE_UINT_ONTO_U4VECTOR (3, umaxl); } } else if (VTF3_ASCIIPARSER_TEST_CHAR ('F') != 0) { fcb->recbufferpos++; VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('L'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('O'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('A'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('T'); VTF3_ASCIIPARSER_CHECK_AND_PASS_BLANK; VTF3_ASCIIPARSER_PASS_BLANKS (fcb->recbufferpos); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('M'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('I'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('N'); VTF3_ASCIIPARSER_CHECK_AND_PASS_BLANK; if (StdAsciiReadF8 (fcb, &fmin) == 0) goto Error; VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('M'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('A'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('X'); VTF3_ASCIIPARSER_CHECK_AND_PASS_BLANK; if (StdAsciiReadF8 (fcb, &fmax) == 0) goto Error; (void) StoreDoubleOntoU4Vector (fcb, 0, fmin); (void) StoreDoubleOntoU4Vector (fcb, 2, fmax); valuetype = VTF3_VALUETYPE_FLOAT; } else goto Error; VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('N'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('A'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('M'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('E'); VTF3_ASCIIPARSER_CHECK_AND_PASS_BLANK; if (StdAsciiStoreStringOffsets (fcb, 0) == 0) goto Error; VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('U'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('N'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('I'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('T'); VTF3_ASCIIPARSER_CHECK_AND_PASS_BLANK; if (StdAsciiStoreStringOffsets (fcb, 1) == 0) goto Error; VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('\n'); clstrregname = StdAsciiGetSeparatedString (fcb, 0); clstrregunit = StdAsciiGetSeparatedString (fcb, 1); VTF3_PARSER_HANDLER_CALL_PROLOGUE (handler_t, handler); rc = (handler) (*(fcb->firsthandlerargs + handlerindex), clstrregtoken, clstrregclasstoken, valuetype, fcb->u4vector, clstrregname, clstrregunit); VTF3_PARSER_HANDLER_CALL_EPILOGUE; return; /* LABEL */ Error: (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } static void StdAsciiParserDefclstrregclass (fcb_t *fcb, int numcharsdata, int handlerindex, int havetime, double time) { static unsigned int first = 1; int clstrregclasstoken, rc; const char *clstrregclassname; VTF3_DCL_DEFCLSTRREGCLASS (typedef, (*handler_t)); handler_t handler; if (first != 0) { first = 0; (void) PassF (time); } if (havetime != 0) goto Error; VTF3_STDASCIIPARSER_READI4 (clstrregclasstoken); if (StdAsciiStoreStringOffsets (fcb, 0) == 0) goto Error; VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('\n'); clstrregclassname = StdAsciiGetSeparatedString (fcb, 0); VTF3_PARSER_HANDLER_CALL_PROLOGUE (handler_t, handler); rc = (handler) (*(fcb->firsthandlerargs + handlerindex), clstrregclasstoken, clstrregclassname); VTF3_PARSER_HANDLER_CALL_EPILOGUE; return; /* LABEL */ Error: (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } static void StdAsciiParserDefcommunicator (fcb_t *fcb, int numcharsdata, int handlerindex, int havetime, double time) { static unsigned int first = 1; int communicator, communicatorsize, tripletarraydim, rc; unsigned int tripletitem1, tripletitem2, tripletitem3; VTF3_DCL_DEFCOMMUNICATOR (typedef, (*handler_t)); handler_t handler; if (first != 0) { first = 0; (void) PassF (time); } if (havetime != 0) goto Error; VTF3_STDASCIIPARSER_READI4 (communicator); if (VTF3_ASCIIPARSER_TEST_CHAR ('S') != 0) { fcb->recbufferpos++; VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('I'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('Z'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('E'); VTF3_ASCIIPARSER_CHECK_AND_PASS_BLANK; } VTF3_STDASCIIPARSER_READI4 (communicatorsize); tripletarraydim = 0; while (VTF3_ASCIIPARSER_TEST_CHAR ('\n') == 0) { if (tripletarraydim == 0) { if (VTF3_ASCIIPARSER_TEST_CHAR ('S') != 0) { fcb->recbufferpos++; VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('P'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('E'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('C'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('S'); VTF3_ASCIIPARSER_CHECK_AND_PASS_BLANK; } } if (StdAsciiReadU4ColonTrailing (fcb, &tripletitem1) == 0) goto Error; if (StdAsciiReadU4ColonTrailing (fcb, &tripletitem2) == 0) goto Error; VTF3_STDASCIIPARSER_READU4 (tripletitem3); VTF3_STORE_ONTO_UINT_VECTOR (3 * tripletarraydim + 0, tripletitem1); VTF3_STORE_ONTO_UINT_VECTOR (3 * tripletarraydim + 1, tripletitem2); VTF3_STORE_ONTO_UINT_VECTOR (3 * tripletarraydim + 2, tripletitem3); tripletarraydim++; } VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('\n'); VTF3_PARSER_HANDLER_CALL_PROLOGUE (handler_t, handler); rc = (handler) (*(fcb->firsthandlerargs + handlerindex), communicator, communicatorsize, tripletarraydim, fcb->uintvector); VTF3_PARSER_HANDLER_CALL_EPILOGUE; return; /* LABEL */ Error: (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } static void StdAsciiParserDefcpugrp (fcb_t *fcb, int numcharsdata, int handlerindex, int havetime, double time) { static unsigned int first = 1; unsigned int cpugrpid, cpuorcpugrpid; int cpuorcpugrpidarraydim, i, rc; const char *cpugrpname; VTF3_DCL_DEFCPUGRP (typedef, (*handler_t)); handler_t handler; if (first != 0) { first = 0; (void) PassF (time); } if (havetime != 0) goto Error; VTF3_STDASCIIPARSER_READU4 (cpugrpid); if (fcb->legacyascii != 0) { if (cpugrpid == 0) goto Error; cpugrpid--; } cpugrpid |= VTF3_CPUGRP_MASK; if (StdAsciiStoreStringOffsets (fcb, 0) == 0) goto Error; VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('N'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('M'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('E'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('M'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('B'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('S'); VTF3_ASCIIPARSER_CHECK_AND_PASS_BLANK; VTF3_STDASCIIPARSER_READI4 (cpuorcpugrpidarraydim); if (cpuorcpugrpidarraydim < 0) goto Error; if (cpuorcpugrpidarraydim > 0 && VTF3_ASCIIPARSER_TEST_CHAR ('M') != 0) { fcb->recbufferpos++; VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('E'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('M'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('B'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('S'); VTF3_ASCIIPARSER_CHECK_AND_PASS_BLANK; VTF3_ASCIIPARSER_PASS_BLANKS (fcb->recbufferpos); } for (i = 0; i < cpuorcpugrpidarraydim; i++) { VTF3_STDASCIIPARSER_READU4 (cpuorcpugrpid); if (fcb->legacyascii != 0) { if (cpuorcpugrpid == 0) goto Error; cpuorcpugrpid--; } VTF3_STORE_ONTO_UINT_VECTOR (i, cpuorcpugrpid); } VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('\n'); cpugrpname = StdAsciiGetSeparatedString (fcb, 0); VTF3_PARSER_HANDLER_CALL_PROLOGUE (handler_t, handler); rc = (handler) (*(fcb->firsthandlerargs + handlerindex), cpugrpid, cpuorcpugrpidarraydim, fcb->uintvector, cpugrpname); VTF3_PARSER_HANDLER_CALL_EPILOGUE; return; /* LABEL */ Error: (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } static void StdAsciiParserDefcpuname (fcb_t *fcb, int numcharsdata, int handlerindex, int havetime, double time) { static unsigned int first = 1; unsigned int cpuid; const char *cpuname; int rc; VTF3_DCL_DEFCPUNAME (typedef, (*handler_t)); handler_t handler; if (first != 0) { first = 0; (void) PassF (time); } if (havetime != 0) goto Error; VTF3_STDASCIIPARSER_READU4 (cpuid); if (fcb->legacyascii != 0) { if (cpuid == 0) goto Error; cpuid--; } if (StdAsciiStoreStringOffsets (fcb, 0) == 0) goto Error; VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('\n'); cpuname = StdAsciiGetSeparatedString (fcb, 0); VTF3_PARSER_HANDLER_CALL_PROLOGUE (handler_t, handler); rc = (handler) (*(fcb->firsthandlerargs + handlerindex), cpuid, cpuname); VTF3_PARSER_HANDLER_CALL_EPILOGUE; return; /* LABEL */ Error: (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } static void StdAsciiParserDefcpureg (fcb_t *fcb, int numcharsdata, int handlerindex, int havetime, double time) { static unsigned int first = 1; int cpuregtoken, cpuregclasstoken, valuetype, rc; unsigned int uminh, uminl, umaxh, umaxl; double fmin, fmax; const char *cpuregname, *cpuregunit; VTF3_DCL_DEFCPUREG (typedef, (*handler_t)); handler_t handler; if (first != 0) { first = 0; (void) PassF (time); } if (havetime != 0) goto Error; VTF3_STDASCIIPARSER_READI4 (cpuregtoken); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('C'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('L'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('A'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('S'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('S'); VTF3_ASCIIPARSER_CHECK_AND_PASS_BLANK; VTF3_STDASCIIPARSER_READI4 (cpuregclasstoken); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('T'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('Y'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('P'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('E'); VTF3_ASCIIPARSER_CHECK_AND_PASS_BLANK; VTF3_ASCIIPARSER_PASS_BLANKS (fcb->recbufferpos); valuetype = VTF3_VALUETYPE_UINT; if (VTF3_ASCIIPARSER_TEST_CHAR ('U') != 0) { fcb->recbufferpos++; VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('I'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('N'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('T'); VTF3_ASCIIPARSER_CHECK_AND_PASS_BLANK; VTF3_ASCIIPARSER_PASS_BLANKS (fcb->recbufferpos); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('M'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('I'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('N'); VTF3_ASCIIPARSER_CHECK_AND_PASS_BLANK; VTF3_STDASCIIPARSER_READU4 (uminh); VTF3_STDASCIIPARSER_READU4 (uminl); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('M'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('A'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('X'); VTF3_ASCIIPARSER_CHECK_AND_PASS_BLANK; VTF3_STDASCIIPARSER_READU4 (umaxh); VTF3_STDASCIIPARSER_READU4 (umaxl); if (vtffprtype == VTF3_CONST_FPNRT_IEEE754_DOUBLE_LITEND) { VTF3_STORE_UINT_ONTO_U4VECTOR (0, uminl); VTF3_STORE_UINT_ONTO_U4VECTOR (1, uminh); VTF3_STORE_UINT_ONTO_U4VECTOR (2, umaxl); VTF3_STORE_UINT_ONTO_U4VECTOR (3, umaxh); } else { VTF3_STORE_UINT_ONTO_U4VECTOR (0, uminh); VTF3_STORE_UINT_ONTO_U4VECTOR (1, uminl); VTF3_STORE_UINT_ONTO_U4VECTOR (2, umaxh); VTF3_STORE_UINT_ONTO_U4VECTOR (3, umaxl); } } else if (VTF3_ASCIIPARSER_TEST_CHAR ('F') != 0) { fcb->recbufferpos++; VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('L'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('O'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('A'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('T'); VTF3_ASCIIPARSER_CHECK_AND_PASS_BLANK; VTF3_ASCIIPARSER_PASS_BLANKS (fcb->recbufferpos); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('M'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('I'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('N'); VTF3_ASCIIPARSER_CHECK_AND_PASS_BLANK; if (StdAsciiReadF8 (fcb, &fmin) == 0) goto Error; VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('M'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('A'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('X'); VTF3_ASCIIPARSER_CHECK_AND_PASS_BLANK; if (StdAsciiReadF8 (fcb, &fmax) == 0) goto Error; (void) StoreDoubleOntoU4Vector (fcb, 0, fmin); (void) StoreDoubleOntoU4Vector (fcb, 2, fmax); valuetype = VTF3_VALUETYPE_FLOAT; } else goto Error; VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('N'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('A'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('M'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('E'); VTF3_ASCIIPARSER_CHECK_AND_PASS_BLANK; if (StdAsciiStoreStringOffsets (fcb, 0) == 0) goto Error; VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('U'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('N'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('I'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('T'); VTF3_ASCIIPARSER_CHECK_AND_PASS_BLANK; if (StdAsciiStoreStringOffsets (fcb, 1) == 0) goto Error; VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('\n'); cpuregname = StdAsciiGetSeparatedString (fcb, 0); cpuregunit = StdAsciiGetSeparatedString (fcb, 1); VTF3_PARSER_HANDLER_CALL_PROLOGUE (handler_t, handler); rc = (handler) (*(fcb->firsthandlerargs + handlerindex), cpuregtoken, cpuregclasstoken, valuetype, fcb->u4vector, cpuregname, cpuregunit); VTF3_PARSER_HANDLER_CALL_EPILOGUE; return; /* LABEL */ Error: (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } static void StdAsciiParserDefcpuregclass (fcb_t *fcb, int numcharsdata, int handlerindex, int havetime, double time) { static unsigned int first = 1; int cpuregclasstoken, rc; const char *cpuregclassname; VTF3_DCL_DEFCPUREGCLASS (typedef, (*handler_t)); handler_t handler; if (first != 0) { first = 0; (void) PassF (time); } if (havetime != 0) goto Error; VTF3_STDASCIIPARSER_READI4 (cpuregclasstoken); if (StdAsciiStoreStringOffsets (fcb, 0) == 0) goto Error; VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('\n'); cpuregclassname = StdAsciiGetSeparatedString (fcb, 0); VTF3_PARSER_HANDLER_CALL_PROLOGUE (handler_t, handler); rc = (handler) (*(fcb->firsthandlerargs + handlerindex), cpuregclasstoken, cpuregclassname); VTF3_PARSER_HANDLER_CALL_EPILOGUE; return; /* LABEL */ Error: (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } static void StdAsciiParserDefcreator (fcb_t *fcb, int numcharsdata, int handlerindex, int havetime, double time) { static unsigned int first = 1; const char *creator; int rc; VTF3_DCL_DEFCREATOR (typedef, (*handler_t)); handler_t handler; if (first != 0) { first = 0; (void) PassF (time); } if (havetime != 0) goto Error; if (StdAsciiStoreStringOffsets (fcb, 0) == 0) if (StdAsciiStoreBuggyStringOffsets (fcb, 0) == 0) goto Error; VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('\n'); creator = StdAsciiGetSeparatedString (fcb, 0); VTF3_PARSER_HANDLER_CALL_PROLOGUE (handler_t, handler); rc = (handler) (*(fcb->firsthandlerargs + handlerindex), creator); VTF3_PARSER_HANDLER_CALL_EPILOGUE; return; /* LABEL */ Error: (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } static void StdAsciiParserDefdatastruc (fcb_t *fcb, int numcharsdata, int handlerindex, int havetime, double time) { static unsigned int first = 1; int datastructoken, scltoken, rc; const char *datastrucname; VTF3_DCL_DEFDATASTRUC (typedef, (*handler_t)); handler_t handler; /*prevent compiler warning about unused variables (time, havetime) */ if (first != 0) { first = 0; (void) PassF (time); } if (havetime != 0) goto Error; /*read token */ VTF3_STDASCIIPARSER_READI4 (datastructoken); /*read source code location token */ VTF3_STDASCIIPARSER_READSCL; /*read data structure name */ if (StdAsciiStoreStringOffsets (fcb, 0) == 0) goto Error; datastrucname = StdAsciiGetSeparatedString (fcb, 0); VTF3_PARSER_HANDLER_CALL_PROLOGUE (handler_t, handler); rc = (handler) (*(fcb->firsthandlerargs + handlerindex), datastructoken, datastrucname, scltoken); VTF3_PARSER_HANDLER_CALL_EPILOGUE; return; /* LABEL */ Error: (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } static void StdAsciiParserDefglobalop (fcb_t *fcb, int numcharsdata, int handlerindex, int havetime, double time) { static unsigned int first = 1; int globaloptoken, rc; const char *globalopname; VTF3_DCL_DEFGLOBALOP (typedef, (*handler_t)); handler_t handler; if (first != 0) { first = 0; (void) PassF (time); } if (havetime != 0) goto Error; VTF3_STDASCIIPARSER_READI4 (globaloptoken); if (StdAsciiStoreStringOffsets (fcb, 0) == 0) goto Error; VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('\n'); globalopname = StdAsciiGetSeparatedString (fcb, 0); VTF3_PARSER_HANDLER_CALL_PROLOGUE (handler_t, handler); rc = (handler) (*(fcb->firsthandlerargs + handlerindex), globaloptoken, globalopname); VTF3_PARSER_HANDLER_CALL_EPILOGUE; return; /* LABEL */ Error: (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } static void StdAsciiParserDefhist (fcb_t *fcb, int numcharsdata, int handlerindex, int havetime, double time) { static unsigned int first = 1; int histtoken, nrelements, histgrp, rc; const char *histname; VTF3_DCL_DEFHIST (typedef, (*handler_t)); handler_t handler; /*prevent compiler warning about unused variables (time, havetime) */ if (first != 0) { first = 0; (void) PassF (time); } if (havetime != 0) goto Error; /*---- now read histogram stuff ---- */ /*token */ VTF3_STDASCIIPARSER_READI4 (histtoken); /*histogram group the histogram belongs to */ VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('H'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('G'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('R'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('P'); VTF3_ASCIIPARSER_CHECK_AND_PASS_BLANK; VTF3_STDASCIIPARSER_READI4 (histgrp); /*read word NBINS */ VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('N'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('B'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('I'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('N'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('S'); VTF3_ASCIIPARSER_CHECK_AND_PASS_BLANK; /*dimension */ VTF3_STDASCIIPARSER_READI4 (nrelements); if (nrelements < 0) goto Error; /*histogram name */ if (StdAsciiStoreStringOffsets (fcb, 0) == 0) goto Error; histname = StdAsciiGetSeparatedString (fcb, 0); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('\n'); /*finalize */ VTF3_PARSER_HANDLER_CALL_PROLOGUE (handler_t, handler); rc = (handler) (*(fcb->firsthandlerargs + handlerindex), histtoken, nrelements, histgrp, histname); VTF3_PARSER_HANDLER_CALL_EPILOGUE; return; /* LABEL */ Error: (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } static void StdAsciiParserDefhistgrp (fcb_t *fcb, int numcharsdata, int handlerindex, int havetime, double time) { static unsigned int first = 1; int histgrptoken, rc; const char *histgrpname; VTF3_DCL_DEFHISTGRP (typedef, (*handler_t)); handler_t handler; /*prevent compiler warning about unused variables (time, havetime) */ if (first != 0) { first = 0; (void) PassF (time); } if (havetime != 0) goto Error; VTF3_STDASCIIPARSER_READI4 (histgrptoken); if (StdAsciiStoreStringOffsets (fcb, 0) == 0) goto Error; VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('\n'); histgrpname = StdAsciiGetSeparatedString (fcb, 0); VTF3_PARSER_HANDLER_CALL_PROLOGUE (handler_t, handler); rc = (handler) (*(fcb->firsthandlerargs + handlerindex), histgrptoken, histgrpname); VTF3_PARSER_HANDLER_CALL_EPILOGUE; return; /* LABEL */ Error: (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } static void StdAsciiParserDefiofile (fcb_t *fcb, int numcharsdata, int handlerindex, int havetime, double time) { static unsigned int first = 1; int iofiletoken, communicator, rc; const char *iofilename; VTF3_DCL_DEFIOFILE (typedef, (*handler_t)); handler_t handler; if (first != 0) { first = 0; (void) PassF (time); } if (havetime != 0) goto Error; VTF3_STDASCIIPARSER_READI4 (iofiletoken); if (VTF3_ASCIIPARSER_TEST_CHAR ('C') != 0) { fcb->recbufferpos++; VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('O'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('M'); VTF3_ASCIIPARSER_CHECK_AND_PASS_BLANK; if (StdAsciiReadI4 (fcb, &communicator) == 0) goto Error; } else if (StdAsciiReadI4 (fcb, &communicator) == 0) communicator = VTF3_NOCOMMUNICATOR; if (StdAsciiStoreStringOffsets (fcb, 0) == 0) goto Error; VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('\n'); iofilename = StdBinaryGetSeparatedString (fcb, 0); VTF3_PARSER_HANDLER_CALL_PROLOGUE (handler_t, handler); rc = (handler) (*(fcb->firsthandlerargs + handlerindex), iofiletoken, communicator, iofilename); VTF3_PARSER_HANDLER_CALL_EPILOGUE; return; /* LABEL */ Error: (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } static void StdAsciiParserDefkparreg (fcb_t *fcb, int numcharsdata, int handlerindex, int havetime, double time) { static unsigned int first = 1; int kparregtoken, rc; const char *kparregname; VTF3_DCL_DEFKPARREG (typedef, (*handler_t)); handler_t handler; if (first != 0) { first = 0; (void) PassF (time); } if (havetime != 0) goto Error; VTF3_STDASCIIPARSER_READI4 (kparregtoken); if (StdAsciiStoreStringOffsets (fcb, 0) == 0) goto Error; VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('\n'); kparregname = StdAsciiGetSeparatedString (fcb, 0); VTF3_PARSER_HANDLER_CALL_PROLOGUE (handler_t, handler); rc = (handler) (*(fcb->firsthandlerargs + handlerindex), kparregtoken, kparregname); VTF3_PARSER_HANDLER_CALL_EPILOGUE; return; /* LABEL */ Error: (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } static void StdAsciiParserDefmsgname (fcb_t *fcb, int numcharsdata, int handlerindex, int havetime, double time) { static unsigned int first = 1; int communicator, msgtype, rc; const char *msgname; VTF3_DCL_DEFMSGNAME (typedef, (*handler_t)); handler_t handler; if (first != 0) { first = 0; (void) PassF (time); } if (havetime != 0) goto Error; VTF3_STDASCIIPARSER_READI4 (communicator); if (VTF3_ASCIIPARSER_TEST_CHAR ('C') != 0) { fcb->recbufferpos++; VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('O'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('M'); VTF3_ASCIIPARSER_CHECK_AND_PASS_BLANK; msgtype = communicator; if (StdAsciiReadI4 (fcb, &communicator) == 0) goto Error; } else if (StdAsciiReadI4 (fcb, &msgtype) == 0) { msgtype = communicator; communicator = VTF3_NOCOMMUNICATOR; } if (StdAsciiStoreStringOffsets (fcb, 0) == 0) goto Error; VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('\n'); msgname = StdAsciiGetSeparatedString (fcb, 0); VTF3_PARSER_HANDLER_CALL_PROLOGUE (handler_t, handler); rc = (handler) (*(fcb->firsthandlerargs + handlerindex), msgtype, communicator, msgname); VTF3_PARSER_HANDLER_CALL_EPILOGUE; return; /* LABEL */ Error: (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } static void StdAsciiParserDefopenmpname (fcb_t *fcb, int numcharsdata, int handlerindex, int havetime, double time) { static unsigned int first = 1; unsigned int nametoken; const char *openmpname; int rc; VTF3_DCL_DEFOPENMPNAME (typedef, (*handler_t)); handler_t handler; if (first != 0) { first = 0; (void) PassF (time); } if (havetime != 0) goto Error; VTF3_STDASCIIPARSER_READU4 (nametoken); if (StdAsciiStoreStringOffsets (fcb, 0) == 0) goto Error; VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('\n'); openmpname = StdAsciiGetSeparatedString (fcb, 0); VTF3_PARSER_HANDLER_CALL_PROLOGUE (handler_t, handler); rc = (handler) (*(fcb->firsthandlerargs + handlerindex), nametoken, openmpname); VTF3_PARSER_HANDLER_CALL_EPILOGUE; return; /* LABEL */ Error: (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } static void StdAsciiParserDefopenmptype (fcb_t *fcb, int numcharsdata, int handlerindex, int havetime, double time) { static unsigned int first = 1; unsigned int constructtypetoken; const char *constructtypename; int rc; VTF3_DCL_DEFOPENMPNAME (typedef, (*handler_t)); handler_t handler; if (first != 0) { first = 0; (void) PassF (time); } if (havetime != 0) goto Error; if (VTF3_ASCIIPARSER_TEST_CHAR ('I') != 0) { fcb->recbufferpos++; VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('D'); VTF3_ASCIIPARSER_CHECK_AND_PASS_BLANK; } VTF3_STDASCIIPARSER_READU4 (constructtypetoken); if (VTF3_ASCIIPARSER_TEST_CHAR ('N') != 0) { fcb->recbufferpos++; VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('A'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('M'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('E'); VTF3_ASCIIPARSER_CHECK_AND_PASS_BLANK; } if (StdAsciiStoreStringOffsets (fcb, 0) == 0) goto Error; VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('\n'); constructtypename = StdAsciiGetSeparatedString (fcb, 0); VTF3_PARSER_HANDLER_CALL_PROLOGUE (handler_t, handler); rc = (handler) (*(fcb->firsthandlerargs + handlerindex), constructtypetoken, constructtypename); VTF3_PARSER_HANDLER_CALL_EPILOGUE; return; /* LABEL */ Error: (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } static void StdAsciiParserDefpattern (fcb_t *fcb, int numcharsdata, int handlerindex, int havetime, double time) { static unsigned int first = 1; int pattoken, activitytoken, patshptoken, ratio, timesteparraydim, i, rc; double radius, timestep; VTF3_DCL_DEFPATTERN (typedef, (*handler_t)); handler_t handler; if (first != 0) { first = 0; (void) PassF (time); } if (havetime != 0) goto Error; VTF3_STDASCIIPARSER_READI4 (pattoken); if (pattoken == VTF3_NOSTATE) goto Error; VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('A'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('C'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('T'); VTF3_ASCIIPARSER_CHECK_AND_PASS_BLANK; VTF3_STDASCIIPARSER_READI4 (activitytoken); if (activitytoken == VTF3_NOACT) goto Error; VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('S'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('H'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('A'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('P'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('E'); VTF3_ASCIIPARSER_CHECK_AND_PASS_BLANK; VTF3_STDASCIIPARSER_READI4 (patshptoken); if (patshptoken == VTF3_NOSTATE) goto Error; VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('R'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('A'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('D'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('I'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('U'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('S'); VTF3_ASCIIPARSER_CHECK_AND_PASS_BLANK; if (StdAsciiReadTs (fcb, &radius) == 0) goto Error; if (SignOfDouble (radius) < 0) goto Error; VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('R'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('A'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('T'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('I'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('O'); VTF3_ASCIIPARSER_CHECK_AND_PASS_BLANK; VTF3_STDASCIIPARSER_READI4 (ratio); if (ratio < 0) goto Error; VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('N'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('T'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('S'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('T'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('E'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('P'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('S'); VTF3_ASCIIPARSER_CHECK_AND_PASS_BLANK; VTF3_STDASCIIPARSER_READI4 (timesteparraydim); if (timesteparraydim < 0) goto Error; if (timesteparraydim > 0) { VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('T'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('S'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('T'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('E'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('P'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('S'); VTF3_ASCIIPARSER_CHECK_AND_PASS_BLANK; } for (i = 0; i < timesteparraydim; i++) { if (StdAsciiReadTs (fcb, ×tep) == 0) goto Error; if (SignOfDouble (timestep) < 0) goto Error; (void) StoreDoubleOntoU4Vector (fcb, 2 * i + 0, timestep); } VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('\n'); VTF3_PARSER_HANDLER_CALL_PROLOGUE (handler_t, handler); rc = (handler) (*(fcb->firsthandlerargs + handlerindex), activitytoken, pattoken, patshptoken, radius, ratio, timesteparraydim, (double *) fcb->u4vector); VTF3_PARSER_HANDLER_CALL_EPILOGUE; return; /* LABEL */ Error: (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } static void StdAsciiParserDefpatternshape (fcb_t *fcb, int numcharsdata, int handlerindex, int havetime, double time) { static unsigned int first = 1; int patshptoken, activitytoken, patterntype, patshptokenbref1, patshptokenbref2, rc; VTF3_DCL_DEFPATTERNSHAPE (typedef, (*handler_t)); handler_t handler; if (first != 0) { first = 0; (void) PassF (time); } if (havetime != 0) goto Error; VTF3_STDASCIIPARSER_READI4 (patshptoken); if (patshptoken == VTF3_NOSTATE) goto Error; VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('A'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('C'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('T'); VTF3_ASCIIPARSER_CHECK_AND_PASS_BLANK; VTF3_STDASCIIPARSER_READI4 (activitytoken); if (activitytoken == VTF3_NOACT) goto Error; patterntype = VTF3_PATTERNTYPE_NOTYPE; if (VTF3_ASCIIPARSER_TEST_CHAR ('N') != 0) { fcb->recbufferpos++; VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('E'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('S'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('T'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('E'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('D'); VTF3_ASCIIPARSER_CHECK_AND_PASS_BLANK; patterntype = VTF3_PATTERNTYPE_NESTED; } else if (VTF3_ASCIIPARSER_TEST_CHAR ('R') != 0) { fcb->recbufferpos++; VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('E'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('P'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('E'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('A'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('T'); VTF3_ASCIIPARSER_CHECK_AND_PASS_BLANK; patterntype = VTF3_PATTERNTYPE_REPEAT; } else if (VTF3_ASCIIPARSER_TEST_CHAR ('S') != 0) { fcb->recbufferpos++; if (VTF3_ASCIIPARSER_TEST_CHAR ('E') != 0) { fcb->recbufferpos++; VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('R'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('I'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('A'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('L'); VTF3_ASCIIPARSER_CHECK_AND_PASS_BLANK; patterntype = VTF3_PATTERNTYPE_SERIAL; } else if (VTF3_ASCIIPARSER_TEST_CHAR ('I') != 0) { fcb->recbufferpos++; VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('N'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('G'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('L'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('E'); VTF3_ASCIIPARSER_CHECK_AND_PASS_BLANK; patterntype = VTF3_PATTERNTYPE_SINGLE; } else goto Error; } else goto Error; VTF3_STDASCIIPARSER_READI4 (patshptokenbref1); if (patshptokenbref1 == VTF3_NOSTATE) goto Error; VTF3_STDASCIIPARSER_READI4 (patshptokenbref2); if (patshptokenbref2 == VTF3_NOSTATE) goto Error; VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('\n'); VTF3_PARSER_HANDLER_CALL_PROLOGUE (handler_t, handler); rc = (handler) (*(fcb->firsthandlerargs + handlerindex), activitytoken, patshptoken, patterntype, patshptokenbref1, patshptokenbref2); VTF3_PARSER_HANDLER_CALL_EPILOGUE; return; /* LABEL */ Error: (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } static void StdAsciiParserDefredfunc_obsol (fcb_t *fcb, int numcharsdata, int handlerindex, int havetime, double time) { static unsigned int first = 1; int redfunctoken, rc; const char *redfuncname; VTF3_DCL_DEFREDFUNC_OBSOL (typedef, (*handler_t)); handler_t handler; if (first != 0) { first = 0; (void) PassF (time); } if (havetime != 0) goto Error; VTF3_STDASCIIPARSER_READI4 (redfunctoken); if (StdAsciiStoreStringOffsets (fcb, 0) == 0) goto Error; VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('\n'); redfuncname = StdAsciiGetSeparatedString (fcb, 0); VTF3_PARSER_HANDLER_CALL_PROLOGUE (handler_t, handler); rc = (handler) (*(fcb->firsthandlerargs + handlerindex), redfunctoken, redfuncname); VTF3_PARSER_HANDLER_CALL_EPILOGUE; return; /* LABEL */ Error: (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } static void StdAsciiParserDefsamp (fcb_t *fcb, int numcharsdata, int handlerindex, int havetime, double time) { static unsigned int first = 1; int sampletoken, sampleclasstoken, iscpugrpsamp, valuetype, dodifferentiation, datarephint, rc; unsigned int cpuorcpugrpid, uminh, uminl, umaxh, umaxl; double fmin, fmax; const char *samplename, *sampleunit; VTF3_DCL_DEFSAMP (typedef, (*handler_t)); handler_t handler; if (first != 0) { first = 0; (void) PassF (time); } if (havetime != 0) goto Error; VTF3_STDASCIIPARSER_READI4 (sampletoken); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('C'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('L'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('A'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('S'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('S'); VTF3_ASCIIPARSER_CHECK_AND_PASS_BLANK; VTF3_STDASCIIPARSER_READI4 (sampleclasstoken); iscpugrpsamp = 0; cpuorcpugrpid = 0; if (VTF3_ASCIIPARSER_TEST_CHAR ('G') != 0) { fcb->recbufferpos++; VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('R'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('O'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('U'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('P'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('S'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('A'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('M'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('P'); VTF3_ASCIIPARSER_CHECK_AND_PASS_BLANK; VTF3_ASCIIPARSER_PASS_BLANKS (fcb->recbufferpos); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('F'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('O'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('R'); VTF3_ASCIIPARSER_CHECK_AND_PASS_BLANK; iscpugrpsamp = 1; VTF3_STDASCIIPARSER_READU4 (cpuorcpugrpid); if (fcb->legacyascii != 0) { if (cpuorcpugrpid == 0) goto Error; cpuorcpugrpid--; } cpuorcpugrpid |= VTF3_CPUGRP_MASK; } else if (VTF3_ASCIIPARSER_TEST_CHAR ('C') != 0) { fcb->recbufferpos++; VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('P'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('U'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('S'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('A'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('M'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('P'); VTF3_ASCIIPARSER_CHECK_AND_PASS_BLANK; VTF3_ASCIIPARSER_PASS_BLANKS (fcb->recbufferpos); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('F'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('O'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('R'); VTF3_ASCIIPARSER_CHECK_AND_PASS_BLANK; VTF3_STDASCIIPARSER_READU4 (cpuorcpugrpid); if (fcb->legacyascii != 0) { if (cpuorcpugrpid == 0) goto Error; cpuorcpugrpid--; } } else goto Error; VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('T'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('Y'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('P'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('E'); VTF3_ASCIIPARSER_CHECK_AND_PASS_BLANK; VTF3_ASCIIPARSER_PASS_BLANKS (fcb->recbufferpos); valuetype = VTF3_VALUETYPE_UINT; if (VTF3_ASCIIPARSER_TEST_CHAR ('U') != 0) { fcb->recbufferpos++; VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('I'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('N'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('T'); VTF3_ASCIIPARSER_CHECK_AND_PASS_BLANK; VTF3_ASCIIPARSER_PASS_BLANKS (fcb->recbufferpos); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('M'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('I'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('N'); VTF3_ASCIIPARSER_CHECK_AND_PASS_BLANK; VTF3_STDASCIIPARSER_READU4 (uminh); VTF3_STDASCIIPARSER_READU4 (uminl); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('M'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('A'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('X'); VTF3_ASCIIPARSER_CHECK_AND_PASS_BLANK; VTF3_STDASCIIPARSER_READU4 (umaxh); VTF3_STDASCIIPARSER_READU4 (umaxl); if (vtffprtype == VTF3_CONST_FPNRT_IEEE754_DOUBLE_LITEND) { VTF3_STORE_UINT_ONTO_U4VECTOR (0, uminl); VTF3_STORE_UINT_ONTO_U4VECTOR (1, uminh); VTF3_STORE_UINT_ONTO_U4VECTOR (2, umaxl); VTF3_STORE_UINT_ONTO_U4VECTOR (3, umaxh); } else { VTF3_STORE_UINT_ONTO_U4VECTOR (0, uminh); VTF3_STORE_UINT_ONTO_U4VECTOR (1, uminl); VTF3_STORE_UINT_ONTO_U4VECTOR (2, umaxh); VTF3_STORE_UINT_ONTO_U4VECTOR (3, umaxl); } } else if (VTF3_ASCIIPARSER_TEST_CHAR ('F') != 0) { fcb->recbufferpos++; VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('L'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('O'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('A'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('T'); VTF3_ASCIIPARSER_CHECK_AND_PASS_BLANK; VTF3_ASCIIPARSER_PASS_BLANKS (fcb->recbufferpos); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('M'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('I'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('N'); VTF3_ASCIIPARSER_CHECK_AND_PASS_BLANK; if (StdAsciiReadF8 (fcb, &fmin) == 0) goto Error; VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('M'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('A'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('X'); VTF3_ASCIIPARSER_CHECK_AND_PASS_BLANK; if (StdAsciiReadF8 (fcb, &fmax) == 0) goto Error; (void) StoreDoubleOntoU4Vector (fcb, 0, fmin); (void) StoreDoubleOntoU4Vector (fcb, 2, fmax); valuetype = VTF3_VALUETYPE_FLOAT; } else goto Error; VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('D'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('I'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('F'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('F'); VTF3_ASCIIPARSER_CHECK_AND_PASS_BLANK; VTF3_STDASCIIPARSER_READI4 (dodifferentiation); if (dodifferentiation != 0) dodifferentiation = 1; VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('R'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('H'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('I'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('N'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('T'); VTF3_ASCIIPARSER_CHECK_AND_PASS_BLANK; VTF3_STDASCIIPARSER_READI4 (datarephint); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('N'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('A'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('M'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('E'); VTF3_ASCIIPARSER_CHECK_AND_PASS_BLANK; if (StdAsciiStoreStringOffsets (fcb, 0) == 0) goto Error; VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('U'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('N'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('I'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('T'); VTF3_ASCIIPARSER_CHECK_AND_PASS_BLANK; if (StdAsciiStoreStringOffsets (fcb, 1) == 0) goto Error; VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('\n'); samplename = StdAsciiGetSeparatedString (fcb, 0); sampleunit = StdAsciiGetSeparatedString (fcb, 1); VTF3_PARSER_HANDLER_CALL_PROLOGUE (handler_t, handler); rc = (handler) (*(fcb->firsthandlerargs + handlerindex), sampletoken, sampleclasstoken, iscpugrpsamp, cpuorcpugrpid, valuetype, fcb->u4vector, dodifferentiation, datarephint, samplename, sampleunit); VTF3_PARSER_HANDLER_CALL_EPILOGUE; return; /* LABEL */ Error: (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } static void StdAsciiParserDefsampclass (fcb_t *fcb, int numcharsdata, int handlerindex, int havetime, double time) { static unsigned int first = 1; int sampleclasstoken, rc; const char *sampleclassname; VTF3_DCL_DEFSAMPCLASS (typedef, (*handler_t)); handler_t handler; if (first != 0) { first = 0; (void) PassF (time); } if (havetime != 0) goto Error; VTF3_STDASCIIPARSER_READI4 (sampleclasstoken); if (StdAsciiStoreStringOffsets (fcb, 0) == 0) goto Error; VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('\n'); sampleclassname = StdAsciiGetSeparatedString (fcb, 0); VTF3_PARSER_HANDLER_CALL_PROLOGUE (handler_t, handler); rc = (handler) (*(fcb->firsthandlerargs + handlerindex), sampleclasstoken, sampleclassname); VTF3_PARSER_HANDLER_CALL_EPILOGUE; return; /* LABEL */ Error: (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } static void StdAsciiParserDefscl (fcb_t *fcb, int numcharsdata, int handlerindex, int havetime, double time) { static unsigned int first = 1; int scltoken, sclarraydim, i, sclfiletoken, scllineposition, rc; VTF3_DCL_DEFSCL (typedef, (*handler_t)); handler_t handler; if (first != 0) { first = 0; (void) PassF (time); } if (havetime != 0) goto Error; VTF3_STDASCIIPARSER_READI4 (scltoken); if (scltoken == VTF3_SCLNONE || scltoken == VTF3_SCLRESET) goto Error; VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('N'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('L'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('O'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('C'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('S'); VTF3_ASCIIPARSER_CHECK_AND_PASS_BLANK; VTF3_STDASCIIPARSER_READI4 (sclarraydim); if (sclarraydim < 0) goto Error; if (sclarraydim > 0) { VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('L'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('O'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('C'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('S'); VTF3_ASCIIPARSER_CHECK_AND_PASS_BLANK; } for (i = 0; i < sclarraydim; i++) { if (StdAsciiReadI4ColonTrailing (fcb, &sclfiletoken) == 0) goto Error; VTF3_STORE_ONTO_INT_VECTOR (i, sclfiletoken); VTF3_STDASCIIPARSER_READI4 (scllineposition); VTF3_STORE_ONTO_INT_VECTOR2 (i, scllineposition); } VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('\n'); VTF3_PARSER_HANDLER_CALL_PROLOGUE (handler_t, handler); rc = (handler) (*(fcb->firsthandlerargs + handlerindex), scltoken, sclarraydim, fcb->intvector, fcb->intvector2); VTF3_PARSER_HANDLER_CALL_EPILOGUE; return; /* LABEL */ Error: (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } static void StdAsciiParserDefsclfile (fcb_t *fcb, int numcharsdata, int handlerindex, int havetime, double time) { static unsigned int first = 1; int sclfiletoken, rc; const char *sclfilename; VTF3_DCL_DEFSCLFILE (typedef, (*handler_t)); handler_t handler; if (first != 0) { first = 0; (void) PassF (time); } if (havetime != 0) goto Error; VTF3_STDASCIIPARSER_READI4 (sclfiletoken); if (StdAsciiStoreStringOffsets (fcb, 0) == 0) goto Error; VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('\n'); sclfilename = StdAsciiGetSeparatedString (fcb, 0); VTF3_PARSER_HANDLER_CALL_PROLOGUE (handler_t, handler); rc = (handler) (*(fcb->firsthandlerargs + handlerindex), sclfiletoken, sclfilename); VTF3_PARSER_HANDLER_CALL_EPILOGUE; return; /* LABEL */ Error: (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } static void StdAsciiParserDefstate (fcb_t *fcb, int numcharsdata, int handlerindex, int havetime, double time) { static unsigned int first = 1; static const char *noact = "NOACT"; int statetoken, activitytoken, scltoken, len, i, isequal, rc; const char *statename; VTF3_DCL_DEFSTATE (typedef, (*handler_t)); handler_t handler; if (first != 0) { first = 0; (void) PassF (time); } if (havetime != 0) goto Error; VTF3_STDASCIIPARSER_READI4 (statetoken); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('A'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('C'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('T'); VTF3_ASCIIPARSER_CHECK_AND_PASS_BLANK; VTF3_STDASCIIPARSER_READI4 (activitytoken); if (StdAsciiStoreStringOffsets (fcb, 0) == 0) goto Error; VTF3_STDASCIIPARSER_READSCL; VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('\n'); len = GetStringLength (fcb, 0); statename = fcb->recbuffer + *(fcb->stroffsetvectorstart + 0); if (statetoken == VTF3_NOSTATE || activitytoken == VTF3_NOACT) { if (statetoken != VTF3_NOSTATE || activitytoken != VTF3_NOACT) goto Error; if (len != 5) goto Error; for (i = 0; i < 5; i++) if (*(statename + i) != *(noact + i)) goto Error; /* Trivial information, ignore this record. */ return; } if (len == 5) { isequal = 1; for (i = 0; i < 5; i++) if (*(statename + i) != *(noact + i)) { isequal = 0; break; } if (isequal != 0) goto Error; } statename = StdAsciiGetSeparatedString (fcb, 0); VTF3_PARSER_HANDLER_CALL_PROLOGUE (handler_t, handler); rc = (handler) (*(fcb->firsthandlerargs + handlerindex), activitytoken, statetoken, statename, scltoken); VTF3_PARSER_HANDLER_CALL_EPILOGUE; return; /* LABEL */ Error: (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } static void StdAsciiParserDefstate_obsol (fcb_t *fcb, int numcharsdata, int handlerindex, int havetime, double time) { static unsigned int first = 1; static const char *noact = "NOACT"; int statetoken, activitytoken, len, isequal, i, rc; const char *activityname, *statename; VTF3_DCL_DEFSTATE_OBSOL (typedef, (*handler_t)); handler_t handler; if (first != 0) { first = 0; (void) PassF (time); } if (havetime != 0) goto Error; if (StdAsciiStoreStringOffsets (fcb, 0) == 0) if (StdAsciiStoreOldStyleStringOffsets (fcb, 0) == 0) goto Error; VTF3_STDASCIIPARSER_READI4 (statetoken); if (StdAsciiStoreStringOffsets (fcb, 1) == 0) if (StdAsciiStoreOldStyleStringOffsets (fcb, 1) == 0) goto Error; VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('\n'); activitytoken = VTF3_NOACT; activitytoken++; len = GetStringLength (fcb, 0); if (len == 5) { activityname = fcb->recbuffer + *(fcb->stroffsetvectorstart + 0); isequal = 1; for (i = 0; i < 5; i++) if (*(activityname + i) != *(noact + i)) { isequal = 0; break; } if (isequal != 0) activitytoken = VTF3_NOACT; } len = GetStringLength (fcb, 1); statename = fcb->recbuffer + *(fcb->stroffsetvectorstart + 1); if (statetoken == VTF3_NOSTATE || activitytoken == VTF3_NOACT) { if (statetoken != VTF3_NOSTATE || activitytoken != VTF3_NOACT) goto Error; if (len != 5) goto Error; for (i = 0; i < 5; i++) if (*(statename + i) != *(noact + i)) goto Error; /* Trivial information, ignore this record. */ return; } if (len == 5) { isequal = 1; for (i = 0; i < 5; i++) if (*(statename + i) != *(noact + i)) { isequal = 0; break; } if (isequal != 0) goto Error; } activityname = StdAsciiGetSeparatedString (fcb, 0); statename = StdAsciiGetSeparatedString (fcb, 1); VTF3_PARSER_HANDLER_CALL_PROLOGUE (handler_t, handler); rc = (handler) (*(fcb->firsthandlerargs + handlerindex), VTF3_NOACT, activityname, VTF3_OLDACT_VALID_NAME, statetoken, statename); VTF3_PARSER_HANDLER_CALL_EPILOGUE; return; /* LABEL */ Error: (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } static void StdAsciiParserDefsyscpunames (fcb_t *fcb, int numcharsdata, int handlerindex, int havetime, double time) { static unsigned int first = 1; int systemcpunamearraydim, i, rc; const char *p; VTF3_DCL_DEFSYSCPUNAMES (typedef, (*handler_t)); handler_t handler; if (first != 0) { first = 0; (void) PassF (time); } if (havetime != 0) goto Error; systemcpunamearraydim = 0; while (VTF3_ASCIIPARSER_TEST_CHAR ('\n') == 0) { if (StdAsciiStoreStringOffsets (fcb, systemcpunamearraydim) == 0) goto Error; systemcpunamearraydim++; } VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('\n'); for (i = 0; i < systemcpunamearraydim; i++) { p = StdAsciiGetSeparatedString (fcb, i); (void) StoreOntoCharPtrVector (fcb, i, p); } (void) StoreOntoCharPtrVector (fcb, systemcpunamearraydim, 0); VTF3_PARSER_HANDLER_CALL_PROLOGUE (handler_t, handler); rc = (handler) (*(fcb->firsthandlerargs + handlerindex), systemcpunamearraydim, fcb->charptrvector); VTF3_PARSER_HANDLER_CALL_EPILOGUE; return; /* LABEL */ Error: (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } static void StdAsciiParserDefsyscpunums (fcb_t *fcb, int numcharsdata, int handlerindex, int havetime, double time) { static unsigned int first = 1; int systemcpunumberarraydim, systemcpunumber, rc; VTF3_DCL_DEFSYSCPUNUMS (typedef, (*handler_t)); handler_t handler; if (first != 0) { first = 0; (void) PassF (time); } if (havetime != 0) goto Error; systemcpunumberarraydim = 0; while (VTF3_ASCIIPARSER_TEST_CHAR ('\n') == 0) { VTF3_STDASCIIPARSER_READI4 (systemcpunumber); VTF3_STORE_ONTO_INT_VECTOR (systemcpunumberarraydim, systemcpunumber); systemcpunumberarraydim++; } VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('\n'); VTF3_PARSER_HANDLER_CALL_PROLOGUE (handler_t, handler); rc = (handler) (*(fcb->firsthandlerargs + handlerindex), systemcpunumberarraydim, fcb->intvector); VTF3_PARSER_HANDLER_CALL_EPILOGUE; return; /* LABEL */ Error: (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } static void StdAsciiParserDefthreadnums (fcb_t *fcb, int numcharsdata, int handlerindex, int havetime, double time) { static unsigned int first = 1; int threadnumarraydim, threadnum, rc; VTF3_DCL_DEFTHREADNUMS (typedef, (*handler_t)); handler_t handler; if (first != 0) { first = 0; (void) PassF (time); } if (havetime != 0) goto Error; threadnumarraydim = 0; while (VTF3_ASCIIPARSER_TEST_CHAR ('\n') == 0) { VTF3_STDASCIIPARSER_READI4 (threadnum); VTF3_STORE_ONTO_INT_VECTOR (threadnumarraydim, threadnum); threadnumarraydim++; } VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('\n'); VTF3_PARSER_HANDLER_CALL_PROLOGUE (handler_t, handler); rc = (handler) (*(fcb->firsthandlerargs + handlerindex), threadnumarraydim, fcb->intvector); VTF3_PARSER_HANDLER_CALL_EPILOGUE; return; /* LABEL */ Error: (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } static void StdAsciiParserDeftimeoffset (fcb_t *fcb, int numcharsdata, int handlerindex, int havetime, double time) { static unsigned int first = 1; unsigned int uinttimeoffset; double timeoffset; int rc; VTF3_DCL_DEFTIMEOFFSET (typedef, (*handler_t)); handler_t handler; if (first != 0) { first = 0; (void) PassF (time); } if (havetime != 0) goto Error; VTF3_STDASCIIPARSER_READU4 (uinttimeoffset); timeoffset = (double) uinttimeoffset; VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('\n'); VTF3_PARSER_HANDLER_CALL_PROLOGUE (handler_t, handler); rc = (handler) (*(fcb->firsthandlerargs + handlerindex), timeoffset); VTF3_PARSER_HANDLER_CALL_EPILOGUE; return; /* LABEL */ Error: (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } static void StdAsciiParserDefunmerged (fcb_t *fcb, int numcharsdata, int handlerindex, int havetime, double time) { static unsigned int first = 1; int rc; VTF3_DCL_DEFUNMERGED (typedef, (*handler_t)); handler_t handler; if (first != 0) { first = 0; (void) PassF (time); } if (havetime != 0) goto Error; VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('\n'); VTF3_PARSER_HANDLER_CALL_PROLOGUE (handler_t, handler); rc = (handler) (*(fcb->firsthandlerargs + handlerindex)); VTF3_PARSER_HANDLER_CALL_EPILOGUE; return; /* LABEL */ Error: (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } static void StdAsciiParserDefversion (fcb_t *fcb, int numcharsdata, int handlerindex, int havetime, double time) { static unsigned int first = 1; int versionnumber, rc; VTF3_DCL_DEFVERSION (typedef, (*handler_t)); handler_t handler; if (first != 0) { first = 0; (void) PassF (time); } if (havetime != 0) goto Error; VTF3_STDASCIIPARSER_READI4 (versionnumber); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('\n'); VTF3_PARSER_HANDLER_CALL_PROLOGUE (handler_t, handler); rc = (handler) (*(fcb->firsthandlerargs + handlerindex), versionnumber); VTF3_PARSER_HANDLER_CALL_EPILOGUE; return; /* LABEL */ Error: (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } static void StdAsciiParserDownto (fcb_t *fcb, int numcharsdata, int handlerindex, int havetime, double time) { int statetoken, scltoken, exchangetype, rc; unsigned int cpuid; VTF3_DCL_DOWNTO (typedef, (*handler_t)); handler_t handler; if (havetime == 0) goto Error; VTF3_STDASCIIPARSER_READI4 (statetoken); if (statetoken == VTF3_NOSTATE) goto Error; cpuid = 0; if (VTF3_ASCIIPARSER_TEST_CHAR ('C') != 0) { fcb->recbufferpos++; VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('P'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('U'); VTF3_ASCIIPARSER_CHECK_AND_PASS_BLANK; VTF3_STDASCIIPARSER_READU4 (cpuid); if (fcb->legacyascii != 0) { if (cpuid == 0) goto Error; cpuid--; } } VTF3_STDASCIIPARSER_READSCL; VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('\n'); VTF3_PARSER_LAST_VALID_TIME_MANAGEMENT; if (fcb->substitudeupfrom != 0) { exchangetype = VTF3_EXCHANGETYPE_DOWNTO; (void) SubstitudeUpFrom (fcb, cpuid, &exchangetype, &statetoken); } VTF3_PARSER_HANDLER_CALL_PROLOGUE (handler_t, handler); rc = (handler) (*(fcb->firsthandlerargs + handlerindex), time, statetoken, cpuid, scltoken); VTF3_PARSER_HANDLER_CALL_EPILOGUE; return; /* LABEL */ Error: (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } static void StdAsciiParserExchange (fcb_t *fcb, int numcharsdata, int handlerindex, int havetime, double time) { unsigned int cpuid; int exchangetype, statetoken, job, scltoken, rc; VTF3_DCL_EXCHANGE (typedef, (*handler_t)); handler_t handler; if (havetime == 0) goto Error; if (VTF3_ASCIIPARSER_TEST_CHAR ('C') != 0) { fcb->recbufferpos++; VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('P'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('U'); VTF3_ASCIIPARSER_CHECK_AND_PASS_BLANK; VTF3_STDASCIIPARSER_READU4 (cpuid); if (fcb->legacyascii != 0) { if (cpuid == 0) goto Error; cpuid--; } } else cpuid = 0; exchangetype = VTF3_EXCHANGETYPE_NOEXCH; if (VTF3_ASCIIPARSER_TEST_CHAR ('T') != 0) { fcb->recbufferpos++; VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('O'); exchangetype = VTF3_EXCHANGETYPE_TO; } else if (VTF3_ASCIIPARSER_TEST_CHAR ('D') != 0) { fcb->recbufferpos++; VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('O'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('W'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('N'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('T'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('O'); exchangetype = VTF3_EXCHANGETYPE_DOWNTO; } else { VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('U'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('P'); if (VTF3_ASCIIPARSER_TEST_CHAR ('T') != 0) { fcb->recbufferpos++; VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('O'); exchangetype = VTF3_EXCHANGETYPE_UPTO; } else if (VTF3_ASCIIPARSER_TEST_CHAR ('F') != 0) { fcb->recbufferpos++; VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('R'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('O'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('M'); exchangetype = VTF3_EXCHANGETYPE_UPFROM; } else goto Error; } VTF3_ASCIIPARSER_CHECK_AND_PASS_BLANK; VTF3_ASCIIPARSER_PASS_BLANKS (fcb->recbufferpos); if (VTF3_ASCIIPARSER_TEST_CHAR ('N') != 0) { fcb->recbufferpos++; VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('O'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('A'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('C'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('T'); statetoken = VTF3_NOSTATE; if (VTF3_ASCIIPARSER_TEST_CHAR ('\n') == 0) { VTF3_ASCIIPARSER_CHECK_AND_PASS_BLANK; VTF3_ASCIIPARSER_PASS_BLANKS (fcb->recbufferpos); } } else VTF3_STDASCIIPARSER_READI4 (statetoken); if (statetoken == VTF3_NOSTATE) { if (exchangetype == VTF3_EXCHANGETYPE_DOWNTO) goto Error; if (exchangetype == VTF3_EXCHANGETYPE_UPFROM) goto Error; } job = VTF3_NOJOB; if (VTF3_ASCIIPARSER_TEST_CHAR ('J') != 0) { fcb->recbufferpos++; VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('O'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('B'); VTF3_ASCIIPARSER_CHECK_AND_PASS_BLANK; VTF3_STDASCIIPARSER_READI4 (job); } VTF3_STDASCIIPARSER_READSCL; VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('\n'); VTF3_PARSER_LAST_VALID_TIME_MANAGEMENT; if (fcb->substitudeupfrom != 0) (void) SubstitudeUpFrom (fcb, cpuid, &exchangetype, &statetoken); VTF3_PARSER_HANDLER_CALL_PROLOGUE (handler_t, handler); rc = (handler) (*(fcb->firsthandlerargs + handlerindex), time, cpuid, exchangetype, statetoken, job, scltoken); VTF3_PARSER_HANDLER_CALL_EPILOGUE; return; /* LABEL */ Error: (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } static void StdAsciiParserExchange_obsol (fcb_t *fcb, int numcharsdata, int handlerindex, int havetime, double time) { static const char *noact = "NOACT"; unsigned int cpuid; int statetoken, activitytoken, len, isequal, i, exchangetype, cluster, job, rc; const char *activityname; VTF3_DCL_EXCHANGE_OBSOL (typedef, (*handler_t)); handler_t handler; if (havetime == 0) goto Error; if (VTF3_ASCIIPARSER_TEST_CHAR ('C') != 0) { fcb->recbufferpos++; VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('P'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('U'); VTF3_ASCIIPARSER_CHECK_AND_PASS_BLANK; VTF3_STDASCIIPARSER_READU4 (cpuid); if (fcb->legacyascii != 0) { if (cpuid == 0) goto Error; cpuid--; } } else if (VTF3_ASCIIPARSER_TEST_CHAR ('O') != 0) { fcb->recbufferpos++; VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('N'); VTF3_ASCIIPARSER_CHECK_AND_PASS_BLANK; VTF3_ASCIIPARSER_PASS_BLANKS (fcb->recbufferpos); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('C'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('P'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('U'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('I'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('D'); VTF3_ASCIIPARSER_CHECK_AND_PASS_BLANK; VTF3_STDASCIIPARSER_READU4 (cpuid); if (fcb->legacyascii != 0) { if (cpuid == 0) goto Error; cpuid--; } } else cpuid = 0; statetoken = VTF3_NOSTATE; activitytoken = VTF3_NOACT; statetoken++; activitytoken++; if (VTF3_ASCIIPARSER_TEST_CHAR ('F') != 0) { fcb->recbufferpos++; VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('R'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('O'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('M'); VTF3_ASCIIPARSER_CHECK_AND_PASS_BLANK; VTF3_ASCIIPARSER_PASS_BLANKS (fcb->recbufferpos); if (VTF3_ASCIIPARSER_TEST_CHAR ('N') != 0) { fcb->recbufferpos++; VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('O'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('A'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('C'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('T'); VTF3_ASCIIPARSER_CHECK_AND_PASS_BLANK; VTF3_ASCIIPARSER_PASS_BLANKS (fcb->recbufferpos); statetoken = VTF3_NOSTATE; activitytoken = VTF3_NOACT; } else { if (StdAsciiStoreStringOffsets (fcb, 0) == 0) if (StdAsciiStoreOldStyleStringOffsets (fcb, 0) == 0) goto Error; len = GetStringLength (fcb, 0); if (len == 5) { activityname = fcb->recbuffer + *(fcb->stroffsetvectorstart + 0); isequal = 1; for (i = 0; i < 5; i++) if (*(activityname + i) != *(noact + i)) { isequal = 0; break; } if (isequal != 0) activitytoken = VTF3_NOACT; } VTF3_STDASCIIPARSER_READI4 (statetoken); if (statetoken == VTF3_NOSTATE || activitytoken == VTF3_NOACT) if (statetoken != VTF3_NOSTATE || activitytoken != VTF3_NOACT) goto Error; } } exchangetype = VTF3_EXCHANGETYPE_NOEXCH; if (VTF3_ASCIIPARSER_TEST_CHAR ('T') != 0) { fcb->recbufferpos++; VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('O'); exchangetype = VTF3_EXCHANGETYPE_TO; } else if (VTF3_ASCIIPARSER_TEST_CHAR ('D') != 0) { fcb->recbufferpos++; VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('O'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('W'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('N'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('T'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('O'); exchangetype = VTF3_EXCHANGETYPE_DOWNTO; } else if (VTF3_ASCIIPARSER_TEST_CHAR ('U') != 0) { fcb->recbufferpos++; VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('P'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('T'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('O'); exchangetype = VTF3_EXCHANGETYPE_UPTO; } else goto Error; VTF3_ASCIIPARSER_CHECK_AND_PASS_BLANK; VTF3_ASCIIPARSER_PASS_BLANKS (fcb->recbufferpos); if (statetoken == VTF3_NOSTATE && exchangetype == VTF3_EXCHANGETYPE_UPTO) goto Error; statetoken = VTF3_NOSTATE; activitytoken = VTF3_NOACT; statetoken++; activitytoken++; if (VTF3_ASCIIPARSER_TEST_CHAR ('N') != 0) { fcb->recbufferpos++; VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('O'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('A'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('C'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('T'); if (VTF3_ASCIIPARSER_TEST_CHAR ('\n') == 0) { VTF3_ASCIIPARSER_CHECK_AND_PASS_BLANK; VTF3_ASCIIPARSER_PASS_BLANKS (fcb->recbufferpos); } statetoken = VTF3_NOSTATE; activitytoken = VTF3_NOACT; } else { if (StdAsciiStoreStringOffsets (fcb, 0) == 0) if (StdAsciiStoreOldStyleStringOffsets (fcb, 0) == 0) goto Error; len = GetStringLength (fcb, 0); if (len == 5) { activityname = fcb->recbuffer + *(fcb->stroffsetvectorstart + 0); isequal = 1; for (i = 0; i < 5; i++) if (*(activityname + i) != *(noact + i)) { isequal = 0; break; } if (isequal != 0) activitytoken = VTF3_NOACT; } if (activitytoken == VTF3_NOACT && VTF3_ASCIIPARSER_TEST_CHAR ('C') != 0) /* Work around a bug in the old VTF. */ statetoken = VTF3_NOSTATE; else { VTF3_STDASCIIPARSER_READI4 (statetoken); } if (statetoken == VTF3_NOSTATE || activitytoken == VTF3_NOACT) if (statetoken != VTF3_NOSTATE || activitytoken != VTF3_NOACT) goto Error; } if (statetoken == VTF3_NOSTATE && exchangetype == VTF3_EXCHANGETYPE_DOWNTO) goto Error; if (VTF3_ASCIIPARSER_TEST_CHAR ('C') != 0) { fcb->recbufferpos++; VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('L'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('U'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('S'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('T'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('E'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('R'); VTF3_ASCIIPARSER_CHECK_AND_PASS_BLANK; if (StdAsciiReadI4 (fcb, &cluster) == 0) goto Error; } job = VTF3_NOJOB; if (VTF3_ASCIIPARSER_TEST_CHAR ('J') != 0) { fcb->recbufferpos++; VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('O'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('B'); VTF3_ASCIIPARSER_CHECK_AND_PASS_BLANK; VTF3_STDASCIIPARSER_READI4 (job); } VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('\n'); if (statetoken == VTF3_NOSTATE) activityname = noact; else activityname = StdAsciiGetSeparatedString (fcb, 0); VTF3_PARSER_LAST_VALID_TIME_MANAGEMENT; if (fcb->substitudeupfrom != 0) (void) SubstitudeUpFrom (fcb, cpuid, &exchangetype, &statetoken); VTF3_PARSER_HANDLER_CALL_PROLOGUE (handler_t, handler); rc = (handler) (*(fcb->firsthandlerargs + handlerindex), time, cpuid, exchangetype, statetoken, VTF3_NOACT, activityname, VTF3_OLDACT_VALID_NAME, job); VTF3_PARSER_HANDLER_CALL_EPILOGUE; return; /* LABEL */ Error: (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } static void StdAsciiParserFileiobegin (fcb_t *fcb, int numcharsdata, int handlerindex, int havetime, double time) { int iofiletoken, fileiotype, bytescopied, scltoken, rc; unsigned int cpuid; VTF3_DCL_FILEIOBEGIN (typedef, (*handler_t)); handler_t handler; if (havetime == 0) goto Error; if (VTF3_ASCIIPARSER_TEST_CHAR ('R') == 0 && VTF3_ASCIIPARSER_TEST_CHAR ('W') == 0) { VTF3_STDASCIIPARSER_READI4 (iofiletoken); if (VTF3_ASCIIPARSER_TEST_CHAR ('C') != 0) { fcb->recbufferpos++; VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('P'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('U'); VTF3_ASCIIPARSER_CHECK_AND_PASS_BLANK; VTF3_STDASCIIPARSER_READU4 (cpuid); if (fcb->legacyascii != 0) { if (cpuid == 0) goto Error; cpuid--; } } else cpuid = 0; if (VTF3_ASCIIPARSER_TEST_CHAR ('R') != 0) { fcb->recbufferpos++; VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('E'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('A'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('D'); fileiotype = VTF3_FILEIOTYPE_READ; } else { VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('W'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('R'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('I'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('T'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('E'); fileiotype = VTF3_FILEIOTYPE_WRITE; } VTF3_ASCIIPARSER_CHECK_AND_PASS_BLANK; VTF3_ASCIIPARSER_PASS_BLANKS (fcb->recbufferpos); VTF3_STDASCIIPARSER_READI4 (bytescopied); } else { if (VTF3_ASCIIPARSER_TEST_CHAR ('R') != 0) { fcb->recbufferpos++; VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('E'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('A'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('D'); fileiotype = VTF3_FILEIOTYPE_READ; } else { VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('W'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('R'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('I'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('T'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('E'); fileiotype = VTF3_FILEIOTYPE_WRITE; } VTF3_ASCIIPARSER_CHECK_AND_PASS_BLANK; VTF3_ASCIIPARSER_PASS_BLANKS (fcb->recbufferpos); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('O'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('N'); VTF3_ASCIIPARSER_CHECK_AND_PASS_BLANK; VTF3_ASCIIPARSER_PASS_BLANKS (fcb->recbufferpos); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('C'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('P'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('U'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('I'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('D'); VTF3_ASCIIPARSER_CHECK_AND_PASS_BLANK; VTF3_STDASCIIPARSER_READU4 (cpuid); if (fcb->legacyascii != 0) { if (cpuid == 0) goto Error; cpuid--; } VTF3_STDASCIIPARSER_READI4 (iofiletoken); VTF3_STDASCIIPARSER_READI4 (bytescopied); } VTF3_STDASCIIPARSER_READSCL; VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('\n'); VTF3_PARSER_LAST_VALID_TIME_MANAGEMENT; VTF3_PARSER_HANDLER_CALL_PROLOGUE (handler_t, handler); rc = (handler) (*(fcb->firsthandlerargs + handlerindex), time, cpuid, fileiotype, iofiletoken, bytescopied, scltoken); VTF3_PARSER_HANDLER_CALL_EPILOGUE; return; /* LABEL */ Error: (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } static void StdAsciiParserFileioend (fcb_t *fcb, int numcharsdata, int handlerindex, int havetime, double time) { int iofiletoken, fileiotype, bytescopied, scltoken, rc; unsigned int cpuid; VTF3_DCL_FILEIOEND (typedef, (*handler_t)); handler_t handler; if (havetime == 0) goto Error; if (VTF3_ASCIIPARSER_TEST_CHAR ('R') == 0 && VTF3_ASCIIPARSER_TEST_CHAR ('W') == 0) { VTF3_STDASCIIPARSER_READI4 (iofiletoken); if (VTF3_ASCIIPARSER_TEST_CHAR ('C') != 0) { fcb->recbufferpos++; VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('P'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('U'); VTF3_ASCIIPARSER_CHECK_AND_PASS_BLANK; VTF3_STDASCIIPARSER_READU4 (cpuid); if (fcb->legacyascii != 0) { if (cpuid == 0) goto Error; cpuid--; } } else cpuid = 0; if (VTF3_ASCIIPARSER_TEST_CHAR ('R') != 0) { fcb->recbufferpos++; VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('E'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('A'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('D'); fileiotype = VTF3_FILEIOTYPE_READ; } else { VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('W'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('R'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('I'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('T'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('E'); fileiotype = VTF3_FILEIOTYPE_WRITE; } VTF3_ASCIIPARSER_CHECK_AND_PASS_BLANK; VTF3_ASCIIPARSER_PASS_BLANKS (fcb->recbufferpos); VTF3_STDASCIIPARSER_READI4 (bytescopied); } else { if (VTF3_ASCIIPARSER_TEST_CHAR ('R') != 0) { fcb->recbufferpos++; VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('E'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('A'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('D'); fileiotype = VTF3_FILEIOTYPE_READ; } else { VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('W'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('R'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('I'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('T'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('E'); fileiotype = VTF3_FILEIOTYPE_WRITE; } VTF3_ASCIIPARSER_CHECK_AND_PASS_BLANK; VTF3_ASCIIPARSER_PASS_BLANKS (fcb->recbufferpos); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('O'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('N'); VTF3_ASCIIPARSER_CHECK_AND_PASS_BLANK; VTF3_ASCIIPARSER_PASS_BLANKS (fcb->recbufferpos); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('C'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('P'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('U'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('I'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('D'); VTF3_ASCIIPARSER_CHECK_AND_PASS_BLANK; VTF3_STDASCIIPARSER_READU4 (cpuid); if (fcb->legacyascii != 0) { if (cpuid == 0) goto Error; cpuid--; } VTF3_STDASCIIPARSER_READI4 (iofiletoken); VTF3_STDASCIIPARSER_READI4 (bytescopied); } VTF3_STDASCIIPARSER_READSCL; VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('\n'); VTF3_PARSER_LAST_VALID_TIME_MANAGEMENT; VTF3_PARSER_HANDLER_CALL_PROLOGUE (handler_t, handler); rc = (handler) (*(fcb->firsthandlerargs + handlerindex), time, cpuid, fileiotype, iofiletoken, bytescopied, scltoken); VTF3_PARSER_HANDLER_CALL_EPILOGUE; return; /* LABEL */ Error: (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } static void StdAsciiParserGlobalop (fcb_t *fcb, int numcharsdata, int handlerindex, int havetime, double time) { int globaloptoken, communicator, bytesreceived, bytessent, scltoken, rc; unsigned int cpuid, rootcpuid; double durationtimesteps; VTF3_DCL_GLOBALOP (typedef, (*handler_t)); handler_t handler; if (havetime == 0) goto Error; VTF3_STDASCIIPARSER_READI4 (globaloptoken); if (VTF3_ASCIIPARSER_TEST_CHAR ('O') == 0) { if (VTF3_ASCIIPARSER_TEST_CHAR ('C') != 0) { fcb->recbufferpos++; VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('O'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('M'); VTF3_ASCIIPARSER_CHECK_AND_PASS_BLANK; } VTF3_STDASCIIPARSER_READI4 (communicator); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('C'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('P'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('U'); VTF3_ASCIIPARSER_CHECK_AND_PASS_BLANK; VTF3_STDASCIIPARSER_READU4 (cpuid); if (fcb->legacyascii != 0) { if (cpuid == 0) goto Error; cpuid--; } VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('R'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('O'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('O'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('T'); VTF3_ASCIIPARSER_CHECK_AND_PASS_BLANK; VTF3_STDASCIIPARSER_READU4 (rootcpuid); if (fcb->legacyascii != 0) { if (rootcpuid == 0) goto Error; rootcpuid--; } VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('I'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('N'); VTF3_ASCIIPARSER_CHECK_AND_PASS_BLANK; VTF3_STDASCIIPARSER_READI4 (bytesreceived); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('O'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('U'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('T'); VTF3_ASCIIPARSER_CHECK_AND_PASS_BLANK; VTF3_STDASCIIPARSER_READI4 (bytessent); if (VTF3_ASCIIPARSER_TEST_CHAR ('D') != 0) { fcb->recbufferpos++; if (VTF3_ASCIIPARSER_TEST_CHAR ('U') != 0) { fcb->recbufferpos++; VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('R'); } else { VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('T'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('S'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('T'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('E'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('P'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('S'); } VTF3_ASCIIPARSER_CHECK_AND_PASS_BLANK; /* Try the fast variant, `StdAsciiReadTs()' is able to return negative values. */ if (StdAsciiReadTs (fcb, &durationtimesteps) == 0) /* Failed, try the slow variant. */ if (StdAsciiReadF8 (fcb, &durationtimesteps) == 0) goto Error; if (SignOfDouble (durationtimesteps) < 0) durationtimesteps = -1.0e+0; } else durationtimesteps = -1.0e+0; } else { VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('O'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('N'); VTF3_ASCIIPARSER_CHECK_AND_PASS_BLANK; VTF3_STDASCIIPARSER_READU4 (cpuid); if (fcb->legacyascii != 0) { if (cpuid == 0) goto Error; cpuid--; } VTF3_STDASCIIPARSER_READI4 (communicator); VTF3_STDASCIIPARSER_READU4 (rootcpuid); if (fcb->legacyascii != 0) { if (rootcpuid == 0) goto Error; rootcpuid--; } VTF3_STDASCIIPARSER_READI4 (bytessent); VTF3_STDASCIIPARSER_READI4 (bytesreceived); /* Try the fast variant, `StdAsciiReadTs()' is able to return negative values. */ if (StdAsciiReadTs (fcb, &durationtimesteps) == 0) /* Failed, try the slow variant. */ if (StdAsciiReadF8 (fcb, &durationtimesteps) == 0) goto Error; if (SignOfDouble (durationtimesteps) < 0) durationtimesteps = -1.0e+0; } VTF3_STDASCIIPARSER_READSCL; VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('\n'); VTF3_PARSER_LAST_VALID_TIME_MANAGEMENT; VTF3_PARSER_HANDLER_CALL_PROLOGUE (handler_t, handler); rc = (handler) (*(fcb->firsthandlerargs + handlerindex), time, globaloptoken, cpuid, communicator, rootcpuid, bytessent, bytesreceived, durationtimesteps, scltoken); VTF3_PARSER_HANDLER_CALL_EPILOGUE; return; /* LABEL */ Error: (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } static void StdAsciiParserHist (fcb_t *fcb, int numcharsdata, int handlerindex, int havetime, double time) { int i, j, k, histtoken, dim, rc, nrdatastruc, datastructoken; unsigned int cpuid, uh, ul; double starttime; VTF3_DCL_HIST (typedef, (*handler_t)); handler_t handler; if (havetime == 0) goto Error; VTF3_STDASCIIPARSER_READI4 (histtoken); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('S'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('T'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('A'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('R'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('T'); if (StdAsciiReadTs (fcb, &starttime) == 0) goto Error; if (SignOfDouble (starttime) < 0) goto Error; VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('C'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('P'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('U'); VTF3_ASCIIPARSER_CHECK_AND_PASS_BLANK; VTF3_STDASCIIPARSER_READU4 (cpuid); /*number of bins of histogram */ VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('N'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('B'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('I'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('N'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('S'); VTF3_ASCIIPARSER_CHECK_AND_PASS_BLANK; VTF3_STDASCIIPARSER_READU4 (dim); if ( dim < 0 ) { goto Error; } /*single bins */ if (dim > 0) { VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('B'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('I'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('N'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('S'); VTF3_ASCIIPARSER_CHECK_AND_PASS_BLANK; /*loop over number of bins */ k=0; for (i = 0; i < dim; i++) { /*number of tokens for this bin in datastrucarray */ VTF3_STDASCIIPARSER_READI4 (nrdatastruc); VTF3_STORE_ONTO_INT_VECTOR (i, nrdatastruc); if (nrdatastruc < 0) goto Error; if ( nrdatastruc == 0 ) { VTF3_STORE_ONTO_INT_VECTOR2 (k, VTF3_NODATASTRUC); k++; } else { for (j = 0; j < nrdatastruc; j++) { VTF3_STDASCIIPARSER_READI4 (datastructoken); VTF3_STORE_ONTO_INT_VECTOR2 (k, datastructoken); k++; } } } } VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('V'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('A'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('L'); VTF3_ASCIIPARSER_CHECK_AND_PASS_BLANK; for ( i=0; ifirsthandlerargs + handlerindex), time, histtoken, starttime, cpuid, dim, fcb->intvector, fcb->intvector2, fcb->u4vector ); VTF3_PARSER_HANDLER_CALL_EPILOGUE; return; /* LABEL */ Error: (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } static void StdAsciiParserKparregbarsum (fcb_t *fcb, int numcharsdata, int handlerindex, int havetime, double time) { int kparregtoken, seqn, opasize, passedchars, remainder, scltoken, rc; unsigned int cpuid; VTF3_DCL_KPARREGBARSUM (typedef, (*handler_t)); handler_t handler; if (havetime == 0) goto Error; VTF3_STDASCIIPARSER_READI4 (kparregtoken); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('C'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('P'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('U'); VTF3_ASCIIPARSER_CHECK_AND_PASS_BLANK; VTF3_STDASCIIPARSER_READU4 (cpuid); if (fcb->legacyascii != 0) { if (cpuid == 0) goto Error; cpuid--; } VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('S'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('E'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('Q'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('N'); VTF3_ASCIIPARSER_CHECK_AND_PASS_BLANK; VTF3_STDASCIIPARSER_READI4 (seqn); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('O'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('S'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('I'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('Z'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('E'); VTF3_ASCIIPARSER_CHECK_AND_PASS_BLANK; VTF3_STDASCIIPARSER_READI4 (opasize); if (opasize < 0) goto Error; if (opasize == 0) { /* Work around some lazy code in the old VTF. */ if (VTF3_ASCIIPARSER_TEST_CHAR ('O') != 0) { fcb->recbufferpos++; VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('S'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('T'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('R'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('E'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('A'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('M'); if (VTF3_ASCIIPARSER_TEST_CHAR ('\n') == 0) { VTF3_ASCIIPARSER_CHECK_AND_PASS_BLANK; VTF3_ASCIIPARSER_PASS_BLANKS (fcb->recbufferpos); } } } else { VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('O'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('S'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('T'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('R'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('E'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('A'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('M'); VTF3_ASCIIPARSER_CHECK_AND_PASS_BLANK; VTF3_ASCIIPARSER_PASS_BLANKS (fcb->recbufferpos); passedchars = (int) (fcb->recbufferpos - fcb->recbuffer); remainder = numcharsdata - passedchars; if (opasize > (int) (((unsigned int) remainder >> 1) + 1)) goto Error; if (passedchars + 2 * opasize > numcharsdata) goto Error; if (TransHexToMem (fcb, fcb->recbufferpos, (unsigned int) opasize) == 0) goto Error; fcb->recbufferpos += 2 * opasize; opasize *= (int) sizeof (char); if (VTF3_ASCIIPARSER_TEST_CHAR ('\n') == 0) { VTF3_ASCIIPARSER_CHECK_AND_PASS_BLANK; VTF3_ASCIIPARSER_PASS_BLANKS (fcb->recbufferpos); } } VTF3_STDASCIIPARSER_READSCL; VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('\n'); VTF3_PARSER_LAST_VALID_TIME_MANAGEMENT; VTF3_PARSER_HANDLER_CALL_PROLOGUE (handler_t, handler); rc = (handler) (*(fcb->firsthandlerargs + handlerindex), time, cpuid, kparregtoken, seqn, opasize, fcb->charvector, scltoken); VTF3_PARSER_HANDLER_CALL_EPILOGUE; return; /* LABEL */ Error: (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } static void StdAsciiParserKparregbegin (fcb_t *fcb, int numcharsdata, int handlerindex, int havetime, double time) { int kparregtoken, seqn, numthreads, scltoken, rc; unsigned int cpuid; VTF3_DCL_KPARREGBEGIN (typedef, (*handler_t)); handler_t handler; if (havetime == 0) goto Error; VTF3_STDASCIIPARSER_READI4 (kparregtoken); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('C'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('P'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('U'); VTF3_ASCIIPARSER_CHECK_AND_PASS_BLANK; VTF3_STDASCIIPARSER_READU4 (cpuid); if (fcb->legacyascii != 0) { if (cpuid == 0) goto Error; cpuid--; } VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('S'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('E'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('Q'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('N'); VTF3_ASCIIPARSER_CHECK_AND_PASS_BLANK; VTF3_STDASCIIPARSER_READI4 (seqn); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('N'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('T'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('H'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('R'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('E'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('A'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('D'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('S'); VTF3_ASCIIPARSER_CHECK_AND_PASS_BLANK; VTF3_STDASCIIPARSER_READI4 (numthreads); VTF3_STDASCIIPARSER_READSCL; VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('\n'); VTF3_PARSER_LAST_VALID_TIME_MANAGEMENT; VTF3_PARSER_HANDLER_CALL_PROLOGUE (handler_t, handler); rc = (handler) (*(fcb->firsthandlerargs + handlerindex), time, cpuid, kparregtoken, seqn, numthreads, scltoken); VTF3_PARSER_HANDLER_CALL_EPILOGUE; return; /* LABEL */ Error: (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } static void StdAsciiParserKparregend (fcb_t *fcb, int numcharsdata, int handlerindex, int havetime, double time) { int kparregtoken, seqn, opasize, passedchars, remainder, scltoken, rc; unsigned int cpuid; VTF3_DCL_KPARREGEND (typedef, (*handler_t)); handler_t handler; if (havetime == 0) goto Error; VTF3_STDASCIIPARSER_READI4 (kparregtoken); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('C'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('P'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('U'); VTF3_ASCIIPARSER_CHECK_AND_PASS_BLANK; VTF3_STDASCIIPARSER_READU4 (cpuid); if (fcb->legacyascii != 0) { if (cpuid == 0) goto Error; cpuid--; } VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('S'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('E'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('Q'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('N'); VTF3_ASCIIPARSER_CHECK_AND_PASS_BLANK; VTF3_STDASCIIPARSER_READI4 (seqn); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('O'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('S'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('I'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('Z'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('E'); VTF3_ASCIIPARSER_CHECK_AND_PASS_BLANK; VTF3_STDASCIIPARSER_READI4 (opasize); if (opasize < 0) goto Error; if (opasize == 0) { /* Work around some lazy code in the old VTF. */ if (VTF3_ASCIIPARSER_TEST_CHAR ('O') != 0) { fcb->recbufferpos++; VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('S'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('T'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('R'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('E'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('A'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('M'); if (VTF3_ASCIIPARSER_TEST_CHAR ('\n') == 0) { VTF3_ASCIIPARSER_CHECK_AND_PASS_BLANK; VTF3_ASCIIPARSER_PASS_BLANKS (fcb->recbufferpos); } } } else { VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('O'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('S'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('T'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('R'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('E'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('A'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('M'); VTF3_ASCIIPARSER_CHECK_AND_PASS_BLANK; VTF3_ASCIIPARSER_PASS_BLANKS (fcb->recbufferpos); passedchars = (int) (fcb->recbufferpos - fcb->recbuffer); remainder = numcharsdata - passedchars; if (opasize > (int) (((unsigned int) remainder >> 1) + 1)) goto Error; if (passedchars + 2 * opasize > numcharsdata) goto Error; if (TransHexToMem (fcb, fcb->recbufferpos, (unsigned int) opasize) == 0) goto Error; fcb->recbufferpos += 2 * opasize; opasize *= (int) sizeof (char); if (VTF3_ASCIIPARSER_TEST_CHAR ('\n') == 0) { VTF3_ASCIIPARSER_CHECK_AND_PASS_BLANK; VTF3_ASCIIPARSER_PASS_BLANKS (fcb->recbufferpos); } } VTF3_STDASCIIPARSER_READSCL; VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('\n'); VTF3_PARSER_LAST_VALID_TIME_MANAGEMENT; VTF3_PARSER_HANDLER_CALL_PROLOGUE (handler_t, handler); rc = (handler) (*(fcb->firsthandlerargs + handlerindex), time, cpuid, kparregtoken, seqn, opasize, fcb->charvector, scltoken); VTF3_PARSER_HANDLER_CALL_EPILOGUE; return; /* LABEL */ Error: (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } static void StdAsciiParserMutexacquire (fcb_t *fcb, int numcharsdata, int handlerindex, int havetime, double time) { unsigned int cpuid; int enterstatetoken, leavestatetokenisupfrom, leavestatetoken, mutexsize, passedchars, remainder, scltoken, exchangetype, rc; double durationtimesteps; VTF3_DCL_MUTEXACQUIRE (typedef, (*handler_t)); handler_t handler; if (havetime == 0) goto Error; VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('C'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('P'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('U'); VTF3_ASCIIPARSER_CHECK_AND_PASS_BLANK; VTF3_STDASCIIPARSER_READU4 (cpuid); if (fcb->legacyascii != 0) { if (cpuid == 0) goto Error; cpuid--; } VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('D'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('O'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('W'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('N'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('T'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('O'); VTF3_ASCIIPARSER_CHECK_AND_PASS_BLANK; VTF3_STDASCIIPARSER_READI4 (enterstatetoken); if (enterstatetoken == VTF3_NOSTATE) goto Error; VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('U'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('P'); leavestatetokenisupfrom = 0; if (VTF3_ASCIIPARSER_TEST_CHAR ('F') != 0) { fcb->recbufferpos++; VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('R'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('O'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('M'); leavestatetokenisupfrom = 1; } else if (VTF3_ASCIIPARSER_TEST_CHAR ('T') != 0) { fcb->recbufferpos++; VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('O'); } else goto Error; VTF3_ASCIIPARSER_CHECK_AND_PASS_BLANK; VTF3_ASCIIPARSER_PASS_BLANKS (fcb->recbufferpos); if (VTF3_ASCIIPARSER_TEST_CHAR ('N') != 0) { fcb->recbufferpos++; VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('O'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('A'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('C'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('T'); VTF3_ASCIIPARSER_CHECK_AND_PASS_BLANK; VTF3_ASCIIPARSER_PASS_BLANKS (fcb->recbufferpos); leavestatetoken = VTF3_NOSTATE; } else { VTF3_STDASCIIPARSER_READI4 (leavestatetoken); } if (leavestatetokenisupfrom != 0 && leavestatetoken != enterstatetoken) goto Error; VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('D'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('T'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('S'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('T'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('E'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('P'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('S'); VTF3_ASCIIPARSER_CHECK_AND_PASS_BLANK; if (StdAsciiReadTs (fcb, &durationtimesteps) == 0) goto Error; if (SignOfDouble (durationtimesteps) < 0) goto Error; VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('M'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('S'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('I'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('Z'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('E'); VTF3_ASCIIPARSER_CHECK_AND_PASS_BLANK; VTF3_STDASCIIPARSER_READI4 (mutexsize); if (mutexsize < 0) goto Error; if (mutexsize > 0) { VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('M'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('U'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('T'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('E'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('X'); VTF3_ASCIIPARSER_CHECK_AND_PASS_BLANK; VTF3_ASCIIPARSER_PASS_BLANKS (fcb->recbufferpos); passedchars = (int) (fcb->recbufferpos - fcb->recbuffer); remainder = numcharsdata - passedchars; if (mutexsize > (int) (((unsigned int) remainder >> 1) + 1)) goto Error; if (passedchars + 2 * mutexsize > numcharsdata) goto Error; if (TransHexToMem (fcb, fcb->recbufferpos, (unsigned int) mutexsize) == 0) goto Error; fcb->recbufferpos += 2 * mutexsize; mutexsize *= (int) sizeof (char); if (VTF3_ASCIIPARSER_TEST_CHAR ('\n') == 0) { VTF3_ASCIIPARSER_CHECK_AND_PASS_BLANK; VTF3_ASCIIPARSER_PASS_BLANKS (fcb->recbufferpos); } } VTF3_STDASCIIPARSER_READSCL; VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('\n'); VTF3_PARSER_LAST_VALID_TIME_MANAGEMENT; if (fcb->substitudeupfrom != 0 && leavestatetokenisupfrom != 0) { exchangetype = VTF3_EXCHANGETYPE_DOWNTO; (void) SubstitudeUpFrom (fcb, cpuid, &exchangetype, &enterstatetoken); exchangetype = VTF3_EXCHANGETYPE_UPFROM; (void) SubstitudeUpFrom (fcb, cpuid, &exchangetype, &leavestatetoken); if (exchangetype != VTF3_EXCHANGETYPE_UPFROM) leavestatetokenisupfrom = 0; } VTF3_PARSER_HANDLER_CALL_PROLOGUE (handler_t, handler); rc = (handler) (*(fcb->firsthandlerargs + handlerindex), time, cpuid, enterstatetoken, leavestatetoken, leavestatetokenisupfrom, durationtimesteps, mutexsize, fcb->charvector, scltoken); VTF3_PARSER_HANDLER_CALL_EPILOGUE; return; /* LABEL */ Error: (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } static void StdAsciiParserMutexrelease (fcb_t *fcb, int numcharsdata, int handlerindex, int havetime, double time) { unsigned int cpuid; int enterstatetoken, leavestatetokenisupfrom, leavestatetoken, mutexsize, passedchars, remainder, scltoken, exchangetype, rc; double durationtimesteps; VTF3_DCL_MUTEXRELEASE (typedef, (*handler_t)); handler_t handler; if (havetime == 0) goto Error; VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('C'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('P'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('U'); VTF3_ASCIIPARSER_CHECK_AND_PASS_BLANK; VTF3_STDASCIIPARSER_READU4 (cpuid); if (fcb->legacyascii != 0) { if (cpuid == 0) goto Error; cpuid--; } VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('D'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('O'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('W'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('N'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('T'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('O'); VTF3_ASCIIPARSER_CHECK_AND_PASS_BLANK; VTF3_STDASCIIPARSER_READI4 (enterstatetoken); if (enterstatetoken == VTF3_NOSTATE) goto Error; VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('U'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('P'); leavestatetokenisupfrom = 0; if (VTF3_ASCIIPARSER_TEST_CHAR ('F') != 0) { fcb->recbufferpos++; VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('R'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('O'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('M'); leavestatetokenisupfrom = 1; } else if (VTF3_ASCIIPARSER_TEST_CHAR ('T') != 0) { fcb->recbufferpos++; VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('O'); } else goto Error; VTF3_ASCIIPARSER_CHECK_AND_PASS_BLANK; VTF3_ASCIIPARSER_PASS_BLANKS (fcb->recbufferpos); if (VTF3_ASCIIPARSER_TEST_CHAR ('N') != 0) { fcb->recbufferpos++; VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('O'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('A'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('C'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('T'); VTF3_ASCIIPARSER_CHECK_AND_PASS_BLANK; VTF3_ASCIIPARSER_PASS_BLANKS (fcb->recbufferpos); leavestatetoken = VTF3_NOSTATE; } else { VTF3_STDASCIIPARSER_READI4 (leavestatetoken); } if (leavestatetokenisupfrom != 0 && leavestatetoken != enterstatetoken) goto Error; VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('D'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('T'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('S'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('T'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('E'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('P'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('S'); VTF3_ASCIIPARSER_CHECK_AND_PASS_BLANK; if (StdAsciiReadTs (fcb, &durationtimesteps) == 0) goto Error; if (SignOfDouble (durationtimesteps) < 0) goto Error; VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('M'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('S'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('I'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('Z'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('E'); VTF3_ASCIIPARSER_CHECK_AND_PASS_BLANK; VTF3_STDASCIIPARSER_READI4 (mutexsize); if (mutexsize < 0) goto Error; if (mutexsize > 0) { VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('M'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('U'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('T'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('E'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('X'); VTF3_ASCIIPARSER_CHECK_AND_PASS_BLANK; VTF3_ASCIIPARSER_PASS_BLANKS (fcb->recbufferpos); passedchars = (int) (fcb->recbufferpos - fcb->recbuffer); remainder = numcharsdata - passedchars; if (mutexsize > (int) (((unsigned int) remainder >> 1) + 1)) goto Error; if (passedchars + 2 * mutexsize > numcharsdata) goto Error; if (TransHexToMem (fcb, fcb->recbufferpos, (unsigned int) mutexsize) == 0) goto Error; fcb->recbufferpos += 2 * mutexsize; mutexsize *= (int) sizeof (char); if (VTF3_ASCIIPARSER_TEST_CHAR ('\n') == 0) { VTF3_ASCIIPARSER_CHECK_AND_PASS_BLANK; VTF3_ASCIIPARSER_PASS_BLANKS (fcb->recbufferpos); } } VTF3_STDASCIIPARSER_READSCL; VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('\n'); VTF3_PARSER_LAST_VALID_TIME_MANAGEMENT; if (fcb->substitudeupfrom != 0 && leavestatetokenisupfrom != 0) { exchangetype = VTF3_EXCHANGETYPE_DOWNTO; (void) SubstitudeUpFrom (fcb, cpuid, &exchangetype, &enterstatetoken); exchangetype = VTF3_EXCHANGETYPE_UPFROM; (void) SubstitudeUpFrom (fcb, cpuid, &exchangetype, &leavestatetoken); if (exchangetype != VTF3_EXCHANGETYPE_UPFROM) leavestatetokenisupfrom = 0; } VTF3_PARSER_HANDLER_CALL_PROLOGUE (handler_t, handler); rc = (handler) (*(fcb->firsthandlerargs + handlerindex), time, cpuid, enterstatetoken, leavestatetoken, leavestatetokenisupfrom, durationtimesteps, mutexsize, fcb->charvector, scltoken); VTF3_PARSER_HANDLER_CALL_EPILOGUE; return; /* LABEL */ Error: (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } static void StdAsciiParserOpenmpenter (fcb_t *fcb, int numcharsdata, int handlerindex, int havetime, double time) { unsigned int cpuid, constructtypetoken, nametoken; int scltoken, rc; VTF3_DCL_OPENMPENTER (typedef, (*handler_t)); handler_t handler; if (havetime == 0) goto Error; cpuid = 0; if (VTF3_ASCIIPARSER_TEST_CHAR ('C') != 0) { fcb->recbufferpos++; VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('P'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('U'); VTF3_ASCIIPARSER_CHECK_AND_PASS_BLANK; VTF3_STDASCIIPARSER_READU4 (cpuid); if (fcb->legacyascii != 0) { if (cpuid == 0) goto Error; cpuid--; } } VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('O'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('P'); VTF3_ASCIIPARSER_CHECK_AND_PASS_BLANK; VTF3_STDASCIIPARSER_READU4 (constructtypetoken); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('T'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('A'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('G'); VTF3_ASCIIPARSER_CHECK_AND_PASS_BLANK; VTF3_STDASCIIPARSER_READU4 (nametoken); VTF3_STDASCIIPARSER_READSCL; VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('\n'); VTF3_PARSER_LAST_VALID_TIME_MANAGEMENT; VTF3_PARSER_HANDLER_CALL_PROLOGUE (handler_t, handler); rc = (handler) (*(fcb->firsthandlerargs + handlerindex), time, cpuid, constructtypetoken, nametoken, scltoken); VTF3_PARSER_HANDLER_CALL_EPILOGUE; return; /* LABEL */ Error: (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } static void StdAsciiParserOpenmpleave (fcb_t *fcb, int numcharsdata, int handlerindex, int havetime, double time) { unsigned int cpuid; int scltoken, rc; VTF3_DCL_OPENMPLEAVE (typedef, (*handler_t)); handler_t handler; if (havetime == 0) goto Error; cpuid = 0; if (VTF3_ASCIIPARSER_TEST_CHAR ('C') != 0) { fcb->recbufferpos++; VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('P'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('U'); VTF3_ASCIIPARSER_CHECK_AND_PASS_BLANK; VTF3_STDASCIIPARSER_READU4 (cpuid); if (fcb->legacyascii != 0) { if (cpuid == 0) goto Error; cpuid--; } } VTF3_STDASCIIPARSER_READSCL; VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('\n'); VTF3_PARSER_LAST_VALID_TIME_MANAGEMENT; VTF3_PARSER_HANDLER_CALL_PROLOGUE (handler_t, handler); rc = (handler) (*(fcb->firsthandlerargs + handlerindex), time, cpuid, scltoken); VTF3_PARSER_HANDLER_CALL_EPILOGUE; return; /* LABEL */ Error: (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } static void StdAsciiParserParreg (fcb_t *fcb, int numcharsdata, int handlerindex, int havetime, double time) { unsigned int cpugrpid, nametoken; int scltoken, sclstarttoken, sclendtoken, timearraydim, i, rc; double timeval; VTF3_DCL_PARREG (typedef, (*handler_t)); handler_t handler; if (havetime == 0) goto Error; cpugrpid = 0; if (VTF3_ASCIIPARSER_TEST_CHAR ('C') != 0) { fcb->recbufferpos++; VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('P'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('U'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('G'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('R'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('P'); VTF3_ASCIIPARSER_CHECK_AND_PASS_BLANK; VTF3_STDASCIIPARSER_READU4 (cpugrpid); if (fcb->legacyascii != 0) { if (cpugrpid == 0) goto Error; cpugrpid--; } } else if (VTF3_ASCIIPARSER_TEST_CHAR ('O') != 0) { fcb->recbufferpos++; VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('F'); VTF3_ASCIIPARSER_CHECK_AND_PASS_BLANK; VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('T'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('E'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('A'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('M'); VTF3_ASCIIPARSER_CHECK_AND_PASS_BLANK; VTF3_STDASCIIPARSER_READU4 (cpugrpid); if (fcb->legacyascii != 0) { if (cpugrpid == 0) goto Error; cpugrpid--; } } else goto Error; VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('T'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('A'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('G'); VTF3_ASCIIPARSER_CHECK_AND_PASS_BLANK; VTF3_STDASCIIPARSER_READU4 (nametoken); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('S'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('T'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('A'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('R'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('T'); VTF3_ASCIIPARSER_CHECK_AND_PASS_BLANK; VTF3_STDASCIIPARSER_READSCL; if ((scltoken != VTF3_SCLNONE) && (scltoken != VTF3_SCLRESET)) sclstarttoken = scltoken; else goto Error; VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('E'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('N'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('D'); VTF3_ASCIIPARSER_CHECK_AND_PASS_BLANK; VTF3_STDASCIIPARSER_READSCL; if ((scltoken != VTF3_SCLNONE) && (scltoken != VTF3_SCLRESET)) sclendtoken = scltoken; else goto Error; VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('N'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('U'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('M'); if (VTF3_ASCIIPARSER_TEST_CHAR ('W') != 0) { fcb->recbufferpos++; VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('I'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('L'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('L'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('I'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('E'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('S'); } else if (VTF3_ASCIIPARSER_TEST_CHAR ('T') != 0) { fcb->recbufferpos++; VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('H'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('R'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('E'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('A'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('D'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('S'); } else goto Error; VTF3_ASCIIPARSER_CHECK_AND_PASS_BLANK; VTF3_STDASCIIPARSER_READI4 (timearraydim); if (timearraydim < 1) goto Error; for (i = 0; i < 2 * timearraydim; i++) { if (StdAsciiReadTs (fcb, &timeval) == 0) goto Error; if (SignOfDouble (timeval) < 0) goto Error; (void) StoreDoubleOntoU4Vector (fcb, 2 * i + 0, timeval); } VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('\n'); VTF3_PARSER_LAST_VALID_TIME_MANAGEMENT; VTF3_PARSER_HANDLER_CALL_PROLOGUE (handler_t, handler); rc = (handler) (*(fcb->firsthandlerargs + handlerindex), time, cpugrpid, nametoken, sclstarttoken, sclendtoken, timearraydim, (double *) fcb->u4vector); VTF3_PARSER_HANDLER_CALL_EPILOGUE; return; /* LABEL */ Error: (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } static void StdAsciiParserPattern (fcb_t *fcb, int numcharsdata, int handlerindex, int havetime, double time) { int patorpatshptoken, timesteparraydim, i, *patchindexarray, patchindex, rc; unsigned int cpuid; double durationtimesteps, timestep; VTF3_DCL_PATTERN (typedef, (*handler_t)); handler_t handler; if (havetime == 0) goto Error; VTF3_STDASCIIPARSER_READI4 (patorpatshptoken); if (patorpatshptoken == VTF3_NOSTATE) goto Error; cpuid = 0; if (VTF3_ASCIIPARSER_TEST_CHAR ('C') != 0) { fcb->recbufferpos++; VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('P'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('U'); VTF3_ASCIIPARSER_CHECK_AND_PASS_BLANK; VTF3_STDASCIIPARSER_READU4 (cpuid); if (fcb->legacyascii != 0) { if (cpuid == 0) goto Error; cpuid--; } } VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('D'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('T'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('S'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('T'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('E'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('P'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('S'); VTF3_ASCIIPARSER_CHECK_AND_PASS_BLANK; if (StdAsciiReadTs (fcb, &durationtimesteps) == 0) goto Error; if (SignOfDouble (durationtimesteps) < 0) goto Error; VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('N'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('T'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('S'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('T'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('E'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('P'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('S'); VTF3_ASCIIPARSER_CHECK_AND_PASS_BLANK; VTF3_STDASCIIPARSER_READI4 (timesteparraydim); if (timesteparraydim < 0) goto Error; if (timesteparraydim > 0) { VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('T'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('S'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('T'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('E'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('P'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('S'); VTF3_ASCIIPARSER_CHECK_AND_PASS_BLANK; } for (i = 0; i < timesteparraydim; i++) { if (StdAsciiReadTs (fcb, ×tep) == 0) goto Error; if (SignOfDouble (timestep) < 0) goto Error; (void) StoreDoubleOntoU4Vector (fcb, 2 * i + 0, timestep); } patchindexarray = 0; if (timesteparraydim > 0) { if (VTF3_ASCIIPARSER_TEST_CHAR ('P') != 0) { fcb->recbufferpos++; VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('A'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('T'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('C'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('H'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('E'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('S'); VTF3_ASCIIPARSER_CHECK_AND_PASS_BLANK; for (i = 0; i < timesteparraydim; i++) { VTF3_STDASCIIPARSER_READI4 (patchindex); VTF3_STORE_ONTO_INT_VECTOR (i, patchindex); } patchindexarray = fcb->intvector; } } VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('\n'); VTF3_PARSER_LAST_VALID_TIME_MANAGEMENT; VTF3_PARSER_HANDLER_CALL_PROLOGUE (handler_t, handler); rc = (handler) (*(fcb->firsthandlerargs + handlerindex), time, cpuid, patorpatshptoken, durationtimesteps, timesteparraydim, (double *) fcb->u4vector, patchindexarray); VTF3_PARSER_HANDLER_CALL_EPILOGUE; return; /* LABEL */ Error: (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } static void StdAsciiParserRecvmsg (fcb_t *fcb, int numcharsdata, int handlerindex, int havetime, double time) { int communicator, msgtype, msglength, scltoken, rc; unsigned int receiver, sender; VTF3_DCL_RECVMSG (typedef, (*handler_t)); handler_t handler; if (havetime == 0) goto Error; VTF3_STDASCIIPARSER_READI4 (communicator); if (VTF3_ASCIIPARSER_TEST_CHAR ('C') != 0) { fcb->recbufferpos++; VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('O'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('M'); VTF3_ASCIIPARSER_CHECK_AND_PASS_BLANK; msgtype = communicator; if (StdAsciiReadI4 (fcb, &communicator) == 0) goto Error; } else if (VTF3_ASCIIPARSER_TEST_CHAR ('B') == 0) { VTF3_STDASCIIPARSER_READI4 (msgtype); } else { msgtype = communicator; communicator = VTF3_NOCOMMUNICATOR; } VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('B'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('Y'); VTF3_ASCIIPARSER_CHECK_AND_PASS_BLANK; VTF3_STDASCIIPARSER_READU4 (receiver); if (fcb->legacyascii != 0) { if (receiver == 0) goto Error; receiver--; } VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('F'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('R'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('O'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('M'); VTF3_ASCIIPARSER_CHECK_AND_PASS_BLANK; VTF3_STDASCIIPARSER_READU4 (sender); if (fcb->legacyascii != 0) { if (sender == 0) goto Error; sender--; } VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('L'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('E'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('N'); VTF3_ASCIIPARSER_CHECK_AND_PASS_BLANK; VTF3_STDASCIIPARSER_READI4 (msglength); VTF3_STDASCIIPARSER_READSCL; VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('\n'); VTF3_PARSER_LAST_VALID_TIME_MANAGEMENT; VTF3_PARSER_HANDLER_CALL_PROLOGUE (handler_t, handler); rc = (handler) (*(fcb->firsthandlerargs + handlerindex), time, receiver, sender, communicator, msgtype, msglength, scltoken); VTF3_PARSER_HANDLER_CALL_EPILOGUE; return; /* LABEL */ Error: (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } static void StdAsciiParserSamp (fcb_t *fcb, int numcharsdata, int handlerindex, int havetime, double time) { unsigned int cpuorcpugrpid, uh, ul; int samplearraydim, sampletoken, rc; double f; VTF3_DCL_SAMP (typedef, (*handler_t)); handler_t handler; if (havetime == 0) goto Error; if (VTF3_ASCIIPARSER_TEST_CHAR ('C') != 0) { fcb->recbufferpos++; VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('P'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('U'); VTF3_ASCIIPARSER_CHECK_AND_PASS_BLANK; VTF3_STDASCIIPARSER_READU4 (cpuorcpugrpid); if (fcb->legacyascii != 0) { if (cpuorcpugrpid == 0) goto Error; cpuorcpugrpid--; } } else if (VTF3_ASCIIPARSER_TEST_CHAR ('G') != 0) { fcb->recbufferpos++; VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('R'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('O'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('U'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('P'); VTF3_ASCIIPARSER_CHECK_AND_PASS_BLANK; VTF3_STDASCIIPARSER_READU4 (cpuorcpugrpid); if (fcb->legacyascii != 0) { if (cpuorcpugrpid == 0) goto Error; cpuorcpugrpid--; } cpuorcpugrpid |= VTF3_CPUGRP_MASK; } else cpuorcpugrpid = 0; samplearraydim = 0; while (VTF3_ASCIIPARSER_TEST_CHAR ('D') != 0) { fcb->recbufferpos++; VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('E'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('F'); VTF3_ASCIIPARSER_CHECK_AND_PASS_BLANK; VTF3_STDASCIIPARSER_READI4 (sampletoken); VTF3_STORE_ONTO_INT_VECTOR (samplearraydim, sampletoken); if (VTF3_ASCIIPARSER_TEST_CHAR ('U') != 0) { fcb->recbufferpos++; VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('I'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('N'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('T'); VTF3_ASCIIPARSER_CHECK_AND_PASS_BLANK; VTF3_STDASCIIPARSER_READU4 (uh); VTF3_STDASCIIPARSER_READU4 (ul); VTF3_STORE_ONTO_INT_VECTOR2 (samplearraydim, VTF3_VALUETYPE_UINT); if (vtffprtype == VTF3_CONST_FPNRT_IEEE754_DOUBLE_LITEND) { VTF3_STORE_UINT_ONTO_U4VECTOR (2 * samplearraydim + 0, ul); VTF3_STORE_UINT_ONTO_U4VECTOR (2 * samplearraydim + 1, uh); } else { VTF3_STORE_UINT_ONTO_U4VECTOR (2 * samplearraydim + 0, uh); VTF3_STORE_UINT_ONTO_U4VECTOR (2 * samplearraydim + 1, ul); } samplearraydim++; continue; } VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('F'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('L'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('O'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('A'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('T'); VTF3_ASCIIPARSER_CHECK_AND_PASS_BLANK; if (StdAsciiReadF8 (fcb, &f) == 0) goto Error; VTF3_STORE_ONTO_INT_VECTOR2 (samplearraydim, VTF3_VALUETYPE_FLOAT); (void) StoreDoubleOntoU4Vector (fcb, 2 * samplearraydim + 0, f); samplearraydim++; } VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('\n'); VTF3_PARSER_LAST_VALID_TIME_MANAGEMENT; VTF3_PARSER_HANDLER_CALL_PROLOGUE (handler_t, handler); rc = (handler) (*(fcb->firsthandlerargs + handlerindex), time, cpuorcpugrpid, samplearraydim, fcb->intvector, fcb->intvector2, fcb->u4vector); VTF3_PARSER_HANDLER_CALL_EPILOGUE; return; /* LABEL */ Error: (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } static void StdAsciiParserSendmsg (fcb_t *fcb, int numcharsdata, int handlerindex, int havetime, double time) { int communicator, msgtype, msglength, scltoken, rc; unsigned int sender, receiver; VTF3_DCL_SENDMSG (typedef, (*handler_t)); handler_t handler; if (havetime == 0) goto Error; VTF3_STDASCIIPARSER_READI4 (communicator); if (VTF3_ASCIIPARSER_TEST_CHAR ('C') != 0) { fcb->recbufferpos++; VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('O'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('M'); VTF3_ASCIIPARSER_CHECK_AND_PASS_BLANK; msgtype = communicator; if (StdAsciiReadI4 (fcb, &communicator) == 0) goto Error; } else if (VTF3_ASCIIPARSER_TEST_CHAR ('F') == 0) { VTF3_STDASCIIPARSER_READI4 (msgtype); } else { msgtype = communicator; communicator = VTF3_NOCOMMUNICATOR; } VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('F'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('R'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('O'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('M'); VTF3_ASCIIPARSER_CHECK_AND_PASS_BLANK; VTF3_STDASCIIPARSER_READU4 (sender); if (fcb->legacyascii != 0) { if (sender == 0) goto Error; sender--; } VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('T'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('O'); VTF3_ASCIIPARSER_CHECK_AND_PASS_BLANK; VTF3_STDASCIIPARSER_READU4 (receiver); if (fcb->legacyascii != 0) { if (receiver == 0) goto Error; receiver--; } VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('L'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('E'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('N'); VTF3_ASCIIPARSER_CHECK_AND_PASS_BLANK; VTF3_STDASCIIPARSER_READI4 (msglength); VTF3_STDASCIIPARSER_READSCL; VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('\n'); VTF3_PARSER_LAST_VALID_TIME_MANAGEMENT; VTF3_PARSER_HANDLER_CALL_PROLOGUE (handler_t, handler); rc = (handler) (*(fcb->firsthandlerargs + handlerindex), time, sender, receiver, communicator, msgtype, msglength, scltoken); VTF3_PARSER_HANDLER_CALL_EPILOGUE; return; /* LABEL */ Error: (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } static void StdAsciiParserSrcinfo_obsol (fcb_t *fcb, int numcharsdata, int handlerindex, int havetime, double time) { int activitytoken, statetoken, scllineposition, rc; VTF3_DCL_SRCINFO_OBSOL (typedef, (*handler_t)); handler_t handler; if (havetime == 0) goto Error; if (VTF3_ASCIIPARSER_TEST_CHAR ('A') != 0) { fcb->recbufferpos++; VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('C'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('T'); VTF3_ASCIIPARSER_CHECK_AND_PASS_BLANK; } VTF3_STDASCIIPARSER_READI4 (activitytoken); if (activitytoken == VTF3_NOACT) goto Error; if (VTF3_ASCIIPARSER_TEST_CHAR ('S') != 0) { fcb->recbufferpos++; VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('T'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('A'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('T'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('E'); VTF3_ASCIIPARSER_CHECK_AND_PASS_BLANK; } VTF3_STDASCIIPARSER_READI4 (statetoken); if (statetoken == VTF3_NOSTATE) goto Error; if (VTF3_ASCIIPARSER_TEST_CHAR ('P') != 0) { fcb->recbufferpos++; VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('O'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('S'); VTF3_ASCIIPARSER_CHECK_AND_PASS_BLANK; } VTF3_STDASCIIPARSER_READI4 (scllineposition); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('\n'); VTF3_PARSER_LAST_VALID_TIME_MANAGEMENT; VTF3_PARSER_HANDLER_CALL_PROLOGUE (handler_t, handler); rc = (handler) (*(fcb->firsthandlerargs + handlerindex), time, activitytoken, statetoken, scllineposition); VTF3_PARSER_HANDLER_CALL_EPILOGUE; return; /* LABEL */ Error: (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } static void StdAsciiParserUnrecognizable (fcb_t *fcb, int numcharsdata, int handlerindex, int havetime, double time) { static unsigned int first = 1; if (first != 0) { first = 0; (void) PassI (havetime); (void) PassF (time); } (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } static void StdAsciiParserUpfrom (fcb_t *fcb, int numcharsdata, int handlerindex, int havetime, double time) { int statetoken, scltoken, exchangetype, rc; unsigned int cpuid; VTF3_DCL_UPFROM (typedef, (*upfromhandler_t)); upfromhandler_t upfromhandler; VTF3_DCL_UPTO (typedef, (*uptohandler_t)); uptohandler_t uptohandler; if (havetime == 0) goto Error; VTF3_STDASCIIPARSER_READI4 (statetoken); if (statetoken == VTF3_NOSTATE) goto Error; cpuid = 0; if (VTF3_ASCIIPARSER_TEST_CHAR ('C') != 0) { fcb->recbufferpos++; VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('P'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('U'); VTF3_ASCIIPARSER_CHECK_AND_PASS_BLANK; VTF3_STDASCIIPARSER_READU4 (cpuid); if (fcb->legacyascii != 0) { if (cpuid == 0) goto Error; cpuid--; } } VTF3_STDASCIIPARSER_READSCL; VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('\n'); VTF3_PARSER_LAST_VALID_TIME_MANAGEMENT; exchangetype = VTF3_EXCHANGETYPE_UPFROM; if (fcb->substitudeupfrom != 0) (void) SubstitudeUpFrom (fcb, cpuid, &exchangetype, &statetoken); if (exchangetype == VTF3_EXCHANGETYPE_UPFROM) { VTF3_PARSER_HANDLER_CALL_PROLOGUE (upfromhandler_t, upfromhandler); rc = (upfromhandler) (*(fcb->firsthandlerargs + handlerindex), time, statetoken, cpuid, scltoken); VTF3_PARSER_HANDLER_CALL_EPILOGUE; return; } if (exchangetype == VTF3_EXCHANGETYPE_UPTO) { handlerindex = vtfuptohandlerindex; VTF3_PARSER_HANDLER_CALL_PROLOGUE (uptohandler_t, uptohandler); rc = (uptohandler) (*(fcb->firsthandlerargs + handlerindex), time, statetoken, cpuid, scltoken); VTF3_PARSER_HANDLER_CALL_EPILOGUE; return; } (void) fprintf (stderr, "VTF3: StdAsciiParserUpfrom(): " "Unrecoverable error\n"); (void) fflush (stderr); (void) exit (127); return; /* LABEL */ Error: (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } static void StdAsciiParserUpto (fcb_t *fcb, int numcharsdata, int handlerindex, int havetime, double time) { int statetoken, scltoken, exchangetype, rc; unsigned int cpuid; VTF3_DCL_UPTO (typedef, (*handler_t)); handler_t handler; if (havetime == 0) goto Error; if (VTF3_ASCIIPARSER_TEST_CHAR ('N') != 0) { fcb->recbufferpos++; VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('O'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('A'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('C'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('T'); if (VTF3_ASCIIPARSER_TEST_CHAR ('\n') == 0) { VTF3_ASCIIPARSER_CHECK_AND_PASS_BLANK; VTF3_ASCIIPARSER_PASS_BLANKS (fcb->recbufferpos); } statetoken = VTF3_NOSTATE; } else { VTF3_STDASCIIPARSER_READI4 (statetoken); } cpuid = 0; if (VTF3_ASCIIPARSER_TEST_CHAR ('C') != 0) { fcb->recbufferpos++; VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('P'); VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('U'); VTF3_ASCIIPARSER_CHECK_AND_PASS_BLANK; VTF3_STDASCIIPARSER_READU4 (cpuid); if (fcb->legacyascii != 0) { if (cpuid == 0) goto Error; cpuid--; } } VTF3_STDASCIIPARSER_READSCL; VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('\n'); VTF3_PARSER_LAST_VALID_TIME_MANAGEMENT; if (fcb->substitudeupfrom != 0) { exchangetype = VTF3_EXCHANGETYPE_UPTO; (void) SubstitudeUpFrom (fcb, cpuid, &exchangetype, &statetoken); } VTF3_PARSER_HANDLER_CALL_PROLOGUE (handler_t, handler); rc = (handler) (*(fcb->firsthandlerargs + handlerindex), time, statetoken, cpuid, scltoken); VTF3_PARSER_HANDLER_CALL_EPILOGUE; return; /* LABEL */ Error: (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } /*****************************************************************************/ static void StdBinaryParserClstrregval (fcb_t *fcb, int numcharsdata, int handlerindex) { int i, clstrregarraydim, clstrtoken, clstrregtoken, clstrregvaluetype, rc; double time, f; unsigned int uh, ul; VTF3_DCL_CLSTRREGVAL (typedef, (*handler_t)); handler_t handler; i = numcharsdata - 12; if (i < 0) { (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } if (i % 13 != 0) { (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } clstrregarraydim = i / 13; fcb->recbufferpos = fcb->recbuffer + 6; time = StdBinaryReadTs (fcb); VTF3_STDBINARYPARSER_READI4 (clstrtoken); for (i = 0; i < clstrregarraydim; i++) { VTF3_STDBINARYPARSER_READI4 (clstrregtoken); VTF3_STORE_ONTO_INT_VECTOR (i, clstrregtoken); VTF3_STDBINARYPARSER_READI1 (clstrregvaluetype); if (clstrregvaluetype != VTF3_VALUETYPE_FLOAT) clstrregvaluetype = VTF3_VALUETYPE_UINT; VTF3_STORE_ONTO_INT_VECTOR2 (i, clstrregvaluetype); if (clstrregvaluetype == VTF3_VALUETYPE_UINT) { VTF3_STDBINARYPARSER_READU4 (uh); VTF3_STDBINARYPARSER_READU4 (ul); if (vtffprtype == VTF3_CONST_FPNRT_IEEE754_DOUBLE_LITEND) { VTF3_STORE_UINT_ONTO_U4VECTOR (2 * i + 0, ul); VTF3_STORE_UINT_ONTO_U4VECTOR (2 * i + 1, uh); } else { VTF3_STORE_UINT_ONTO_U4VECTOR (2 * i + 0, uh); VTF3_STORE_UINT_ONTO_U4VECTOR (2 * i + 1, ul); } } else { f = StdBinaryReadF8 (fcb); (void) StoreDoubleOntoU4Vector (fcb, 2 * i + 0, f); } } VTF3_PARSER_LAST_VALID_TIME_MANAGEMENT; VTF3_PARSER_HANDLER_CALL_PROLOGUE (handler_t, handler); /* Note for VAMPIR, VPTMERGE and other applications. In handler argument lists, all register and sample values are 64 bit unsigned integers or C language doubles. In the integer case, if there is not an integral 64 bit data type available, one has to do a good job to avoid problems which go together with endianess. */ rc = (handler) (*(fcb->firsthandlerargs + handlerindex), time, clstrtoken, clstrregarraydim, fcb->intvector, fcb->intvector2, fcb->u4vector); VTF3_PARSER_HANDLER_CALL_EPILOGUE; return; } static void StdBinaryParserComment (fcb_t *fcb, int numcharsdata, int handlerindex) { int i, rc; double time; const char *comment; VTF3_DCL_COMMENT (typedef, (*handler_t)); handler_t handler; i = numcharsdata - 10; if (i < 0) { (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } fcb->recbufferpos = fcb->recbuffer + 6; time = StdBinaryReadTs (fcb); (void) StdBinaryStoreStringOffsets (fcb, 0); if (i != GetStringLength (fcb, 0)) { (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } comment = StdBinaryGetSeparatedString (fcb, 0); VTF3_PARSER_LAST_VALID_TIME_MANAGEMENT; VTF3_PARSER_HANDLER_CALL_PROLOGUE (handler_t, handler); rc = (handler) (*(fcb->firsthandlerargs + handlerindex), time, comment); VTF3_PARSER_HANDLER_CALL_EPILOGUE; return; } static void StdBinaryParserCpuregval (fcb_t *fcb, int numcharsdata, int handlerindex) { int i, cpuregarraydim, cpuregtoken, cpuregvaluetype, rc; double time, f; unsigned int cpuid, uh, ul; VTF3_DCL_CPUREGVAL (typedef, (*handler_t)); handler_t handler; i = numcharsdata - 12; if (i < 0) { (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } if (i % 13 != 0) { (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } cpuregarraydim = i / 13; fcb->recbufferpos = fcb->recbuffer + 6; time = StdBinaryReadTs (fcb); VTF3_STDBINARYPARSER_READU4 (cpuid); for (i = 0; i < cpuregarraydim; i++) { VTF3_STDBINARYPARSER_READI4 (cpuregtoken); VTF3_STORE_ONTO_INT_VECTOR (i, cpuregtoken); VTF3_STDBINARYPARSER_READI1 (cpuregvaluetype); if (cpuregvaluetype != VTF3_VALUETYPE_FLOAT) cpuregvaluetype = VTF3_VALUETYPE_UINT; VTF3_STORE_ONTO_INT_VECTOR2 (i, cpuregvaluetype); if (cpuregvaluetype == VTF3_VALUETYPE_UINT) { VTF3_STDBINARYPARSER_READU4 (uh); VTF3_STDBINARYPARSER_READU4 (ul); if (vtffprtype == VTF3_CONST_FPNRT_IEEE754_DOUBLE_LITEND) { VTF3_STORE_UINT_ONTO_U4VECTOR (2 * i + 0, ul); VTF3_STORE_UINT_ONTO_U4VECTOR (2 * i + 1, uh); } else { VTF3_STORE_UINT_ONTO_U4VECTOR (2 * i + 0, uh); VTF3_STORE_UINT_ONTO_U4VECTOR (2 * i + 1, ul); } } else { f = StdBinaryReadF8 (fcb); (void) StoreDoubleOntoU4Vector (fcb, 2 * i + 0, f); } } VTF3_PARSER_LAST_VALID_TIME_MANAGEMENT; VTF3_PARSER_HANDLER_CALL_PROLOGUE (handler_t, handler); rc = (handler) (*(fcb->firsthandlerargs + handlerindex), time, cpuid, cpuregarraydim, fcb->intvector, fcb->intvector2, fcb->u4vector); VTF3_PARSER_HANDLER_CALL_EPILOGUE; return; } static void StdBinaryParserDefact (fcb_t *fcb, int numcharsdata, int handlerindex) { static const char *noact = "NOACT"; int i, activitytoken, len, isequal, rc; const char *activityname; VTF3_DCL_DEFACT (typedef, (*handler_t)); handler_t handler; i = numcharsdata - 6; if (i < 0) { (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } fcb->recbufferpos = fcb->recbuffer + 6; VTF3_STDBINARYPARSER_READI4 (activitytoken); (void) StdBinaryStoreStringOffsets (fcb, 0); len = GetStringLength (fcb, 0); if (i != len) { (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } activityname = fcb->recbuffer + *(fcb->stroffsetvectorstart + 0); if (activitytoken == VTF3_NOACT) { if (len != 5) { (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } for (i = 0; i < 5; i++) if (*(activityname + i) != *(noact + i)) { (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } /* Trivial information, ignore this record. */ return; } if (len == 5) { isequal = 1; for (i = 0; i < 5; i++) if (*(activityname + i) != *(noact + i)) { isequal = 0; break; } if (isequal != 0) { (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } } activityname = StdBinaryGetSeparatedString (fcb, 0); VTF3_PARSER_HANDLER_CALL_PROLOGUE (handler_t, handler); rc = (handler) (*(fcb->firsthandlerargs + handlerindex), activitytoken, activityname); VTF3_PARSER_HANDLER_CALL_EPILOGUE; return; } static void StdBinaryParserDefact_obsol (fcb_t *fcb, int numcharsdata, int handlerindex) { static const char *noact = "NOACT"; int i, activitytoken, len, isequal, rc; const char *activityname; VTF3_DCL_DEFACT_OBSOL (typedef, (*handler_t)); handler_t handler; i = numcharsdata - 6; if (i < 0) { (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } fcb->recbufferpos = fcb->recbuffer + 6; VTF3_STDBINARYPARSER_READI4 (activitytoken); (void) StdBinaryStoreStringOffsets (fcb, 0); len = GetStringLength (fcb, 0); if (i != len) { (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } activityname = fcb->recbuffer + *(fcb->stroffsetvectorstart + 0); if (activitytoken == VTF3_NOACT) { if (len != 5) { (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } for (i = 0; i < 5; i++) if (*(activityname + i) != *(noact + i)) { (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } /* Trivial information, ignore this record. */ return; } if (len == 5) { isequal = 1; for (i = 0; i < 5; i++) if (*(activityname + i) != *(noact + i)) { isequal = 0; break; } if (isequal != 0) { (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } } activityname = StdBinaryGetSeparatedString (fcb, 0); VTF3_PARSER_HANDLER_CALL_PROLOGUE (handler_t, handler); rc = (handler) (*(fcb->firsthandlerargs + handlerindex), activitytoken, activityname); VTF3_PARSER_HANDLER_CALL_EPILOGUE; return; } static void StdBinaryParserDefclkperiod (fcb_t *fcb, int numcharsdata, int handlerindex) { int i, rc; double clkperiod; VTF3_DCL_DEFCLKPERIOD (typedef, (*handler_t)); handler_t handler; i = numcharsdata - 8; if (i != 0) { (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } fcb->recbufferpos = fcb->recbuffer + 6; clkperiod = StdBinaryReadF8 (fcb); VTF3_PARSER_HANDLER_CALL_PROLOGUE (handler_t, handler); rc = (handler) (*(fcb->firsthandlerargs + handlerindex), clkperiod); VTF3_PARSER_HANDLER_CALL_EPILOGUE; return; } static void StdBinaryParserDefclstr (fcb_t *fcb, int numcharsdata, int handlerindex) { int i, clstrtoken, len, cpuidarraydim, rc; unsigned int cpuid; const char *clstrname; VTF3_DCL_DEFCLSTR (typedef, (*handler_t)); handler_t handler; i = numcharsdata - 10; if (i < 0) { (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } fcb->recbufferpos = fcb->recbuffer + 6; VTF3_STDBINARYPARSER_READI4 (clstrtoken); (void) StdBinaryStoreStringOffsets (fcb, 0); len = GetStringLength (fcb, 0); if (len < 0) { (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } i -= len; if (i < 0) { (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } VTF3_STDBINARYPARSER_READI4 (cpuidarraydim); if (i != cpuidarraydim * 4) { (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } for (i = 0; i < cpuidarraydim; i++) { VTF3_STDBINARYPARSER_READU4 (cpuid); VTF3_STORE_ONTO_UINT_VECTOR (i, cpuid); } clstrname = StdBinaryGetSeparatedString (fcb, 0); VTF3_PARSER_HANDLER_CALL_PROLOGUE (handler_t, handler); rc = (handler) (*(fcb->firsthandlerargs + handlerindex), clstrtoken, clstrname, cpuidarraydim, fcb->uintvector); VTF3_PARSER_HANDLER_CALL_EPILOGUE; return; } static void StdBinaryParserDefclstrreg (fcb_t *fcb, int numcharsdata, int handlerindex) { int i, clstrregtoken, clstrregclasstoken, valuetype, len, rc; unsigned int uminh, uminl, umaxh, umaxl; double fmin, fmax; const char *clstrregname, *clstrregunit; VTF3_DCL_DEFCLSTRREG (typedef, (*handler_t)); handler_t handler; i = numcharsdata - 29; if (i < 0) { (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } fcb->recbufferpos = fcb->recbuffer + 6; VTF3_STDBINARYPARSER_READI4 (clstrregtoken); VTF3_STDBINARYPARSER_READI4 (clstrregclasstoken); VTF3_STDBINARYPARSER_READI1 (valuetype); if (valuetype == VTF3_VALUETYPE_UINT) { VTF3_STDBINARYPARSER_READU4 (uminh); VTF3_STDBINARYPARSER_READU4 (uminl); VTF3_STDBINARYPARSER_READU4 (umaxh); VTF3_STDBINARYPARSER_READU4 (umaxl); if (vtffprtype == VTF3_CONST_FPNRT_IEEE754_DOUBLE_LITEND) { VTF3_STORE_UINT_ONTO_U4VECTOR (0, uminl); VTF3_STORE_UINT_ONTO_U4VECTOR (1, uminh); VTF3_STORE_UINT_ONTO_U4VECTOR (2, umaxl); VTF3_STORE_UINT_ONTO_U4VECTOR (3, umaxh); } else { VTF3_STORE_UINT_ONTO_U4VECTOR (0, uminh); VTF3_STORE_UINT_ONTO_U4VECTOR (1, uminl); VTF3_STORE_UINT_ONTO_U4VECTOR (2, umaxh); VTF3_STORE_UINT_ONTO_U4VECTOR (3, umaxl); } } else if (valuetype == VTF3_VALUETYPE_FLOAT) { fmin = StdBinaryReadF8 (fcb); fmax = StdBinaryReadF8 (fcb); (void) StoreDoubleOntoU4Vector (fcb, 0, fmin); (void) StoreDoubleOntoU4Vector (fcb, 2, fmax); } else { (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } (void) StdBinaryStoreStringOffsets (fcb, 0); len = GetStringLength (fcb, 0); if (len < 0) { (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } i -= len; if (i < 0) { (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } (void) StdBinaryStoreStringOffsets (fcb, 1); if (i != GetStringLength (fcb, 1)) { (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } clstrregname = StdBinaryGetSeparatedString (fcb, 0); clstrregunit = StdBinaryGetSeparatedString (fcb, 1); VTF3_PARSER_HANDLER_CALL_PROLOGUE (handler_t, handler); rc = (handler) (*(fcb->firsthandlerargs + handlerindex), clstrregtoken, clstrregclasstoken, valuetype, fcb->u4vector, clstrregname, clstrregunit); VTF3_PARSER_HANDLER_CALL_EPILOGUE; return; } static void StdBinaryParserDefclstrregclass (fcb_t *fcb, int numcharsdata, int handlerindex) { int i, clstrregclasstoken, rc; const char *clstrregclassname; VTF3_DCL_DEFCLSTRREGCLASS (typedef, (*handler_t)); handler_t handler; i = numcharsdata - 6; if (i < 0) { (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } fcb->recbufferpos = fcb->recbuffer + 6; VTF3_STDBINARYPARSER_READI4 (clstrregclasstoken); (void) StdBinaryStoreStringOffsets (fcb, 0); if (i != GetStringLength (fcb, 0)) { (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } clstrregclassname = StdBinaryGetSeparatedString (fcb, 0); VTF3_PARSER_HANDLER_CALL_PROLOGUE (handler_t, handler); rc = (handler) (*(fcb->firsthandlerargs + handlerindex), clstrregclasstoken, clstrregclassname); VTF3_PARSER_HANDLER_CALL_EPILOGUE; return; } static void StdBinaryParserDefcommunicator (fcb_t *fcb, int numcharsdata, int handlerindex) { int i, communicator, communicatorsize, tripletarraydim, rc; unsigned int tripletitem1, tripletitem2, tripletitem3; VTF3_DCL_DEFCOMMUNICATOR (typedef, (*handler_t)); handler_t handler; i = numcharsdata - 12; if (i < 0) { (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } fcb->recbufferpos = fcb->recbuffer + 6; VTF3_STDBINARYPARSER_READI4 (communicator); VTF3_STDBINARYPARSER_READI4 (communicatorsize); VTF3_STDBINARYPARSER_READI4 (tripletarraydim); if (i != tripletarraydim * 12) { (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } for (i = 0; i < tripletarraydim; i++) { VTF3_STDBINARYPARSER_READU4 (tripletitem1); VTF3_STDBINARYPARSER_READU4 (tripletitem2); VTF3_STDBINARYPARSER_READU4 (tripletitem3); VTF3_STORE_ONTO_UINT_VECTOR (3 * i + 0, tripletitem1); VTF3_STORE_ONTO_UINT_VECTOR (3 * i + 1, tripletitem2); VTF3_STORE_ONTO_UINT_VECTOR (3 * i + 2, tripletitem3); } VTF3_PARSER_HANDLER_CALL_PROLOGUE (handler_t, handler); rc = (handler) (*(fcb->firsthandlerargs + handlerindex), communicator, communicatorsize, tripletarraydim, fcb->uintvector); VTF3_PARSER_HANDLER_CALL_EPILOGUE; return; } static void StdBinaryParserDefcpugrp (fcb_t *fcb, int numcharsdata, int handlerindex) { int i, len, cpuorcpugrpidarraydim, rc; unsigned int cpugrpid, cpuorcpugrpid; const char *cpugrpname; VTF3_DCL_DEFCPUGRP (typedef, (*handler_t)); handler_t handler; i = numcharsdata - 6; if (i < 0) { (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } fcb->recbufferpos = fcb->recbuffer + 6; VTF3_STDBINARYPARSER_READU4 (cpugrpid); cpugrpid |= VTF3_CPUGRP_MASK; (void) StdBinaryStoreStringOffsets (fcb, 0); len = GetStringLength (fcb, 0); if (len < 0) { (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } i -= len; if (i < 0) { (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } if (i % 4 != 0) { (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } cpuorcpugrpidarraydim = i / 4; for (i = 0; i < cpuorcpugrpidarraydim; i++) { VTF3_STDBINARYPARSER_READU4 (cpuorcpugrpid); VTF3_STORE_ONTO_UINT_VECTOR (i, cpuorcpugrpid); } cpugrpname = StdBinaryGetSeparatedString (fcb, 0); VTF3_PARSER_HANDLER_CALL_PROLOGUE (handler_t, handler); rc = (handler) (*(fcb->firsthandlerargs + handlerindex), cpugrpid, cpuorcpugrpidarraydim, fcb->uintvector, cpugrpname); VTF3_PARSER_HANDLER_CALL_EPILOGUE; return; } static void StdBinaryParserDefcpuname (fcb_t *fcb, int numcharsdata, int handlerindex) { int i, rc; unsigned int cpuid; const char *cpuname; VTF3_DCL_DEFCPUNAME (typedef, (*handler_t)); handler_t handler; i = numcharsdata - 6; if (i < 0) { (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } fcb->recbufferpos = fcb->recbuffer + 6; VTF3_STDBINARYPARSER_READU4 (cpuid); (void) StdBinaryStoreStringOffsets (fcb, 0); if (i != GetStringLength (fcb, 0)) { (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } cpuname = StdBinaryGetSeparatedString (fcb, 0); VTF3_PARSER_HANDLER_CALL_PROLOGUE (handler_t, handler); rc = (handler) (*(fcb->firsthandlerargs + handlerindex), cpuid, cpuname); VTF3_PARSER_HANDLER_CALL_EPILOGUE; return; } static void StdBinaryParserDefcpureg (fcb_t *fcb, int numcharsdata, int handlerindex) { int i, cpuregtoken, cpuregclasstoken, valuetype, len, rc; unsigned int uminh, uminl, umaxh, umaxl; double fmin, fmax; const char *cpuregname, *cpuregunit; VTF3_DCL_DEFCPUREG (typedef, (*handler_t)); handler_t handler; i = numcharsdata - 29; if (i < 0) { (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } fcb->recbufferpos = fcb->recbuffer + 6; VTF3_STDBINARYPARSER_READI4 (cpuregtoken); VTF3_STDBINARYPARSER_READI4 (cpuregclasstoken); VTF3_STDBINARYPARSER_READI1 (valuetype); if (valuetype == VTF3_VALUETYPE_UINT) { VTF3_STDBINARYPARSER_READU4 (uminh); VTF3_STDBINARYPARSER_READU4 (uminl); VTF3_STDBINARYPARSER_READU4 (umaxh); VTF3_STDBINARYPARSER_READU4 (umaxl); if (vtffprtype == VTF3_CONST_FPNRT_IEEE754_DOUBLE_LITEND) { VTF3_STORE_UINT_ONTO_U4VECTOR (0, uminl); VTF3_STORE_UINT_ONTO_U4VECTOR (1, uminh); VTF3_STORE_UINT_ONTO_U4VECTOR (2, umaxl); VTF3_STORE_UINT_ONTO_U4VECTOR (3, umaxh); } else { VTF3_STORE_UINT_ONTO_U4VECTOR (0, uminh); VTF3_STORE_UINT_ONTO_U4VECTOR (1, uminl); VTF3_STORE_UINT_ONTO_U4VECTOR (2, umaxh); VTF3_STORE_UINT_ONTO_U4VECTOR (3, umaxl); } } else if (valuetype == VTF3_VALUETYPE_FLOAT) { fmin = StdBinaryReadF8 (fcb); fmax = StdBinaryReadF8 (fcb); (void) StoreDoubleOntoU4Vector (fcb, 0, fmin); (void) StoreDoubleOntoU4Vector (fcb, 2, fmax); } else { (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } (void) StdBinaryStoreStringOffsets (fcb, 0); len = GetStringLength (fcb, 0); if (len < 0) { (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } i -= len; if (i < 0) { (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } (void) StdBinaryStoreStringOffsets (fcb, 1); if (i != GetStringLength (fcb, 1)) { (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } cpuregname = StdBinaryGetSeparatedString (fcb, 0); cpuregunit = StdBinaryGetSeparatedString (fcb, 1); VTF3_PARSER_HANDLER_CALL_PROLOGUE (handler_t, handler); rc = (handler) (*(fcb->firsthandlerargs + handlerindex), cpuregtoken, cpuregclasstoken, valuetype, fcb->u4vector, cpuregname, cpuregunit); VTF3_PARSER_HANDLER_CALL_EPILOGUE; return; } static void StdBinaryParserDefcpuregclass (fcb_t *fcb, int numcharsdata, int handlerindex) { int i, cpuregclasstoken, rc; const char *cpuregclassname; VTF3_DCL_DEFCPUREGCLASS (typedef, (*handler_t)); handler_t handler; i = numcharsdata - 6; if (i < 0) { (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } fcb->recbufferpos = fcb->recbuffer + 6; VTF3_STDBINARYPARSER_READI4 (cpuregclasstoken); (void) StdBinaryStoreStringOffsets (fcb, 0); if (i != GetStringLength (fcb, 0)) { (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } cpuregclassname = StdBinaryGetSeparatedString (fcb, 0); VTF3_PARSER_HANDLER_CALL_PROLOGUE (handler_t, handler); rc = (handler) (*(fcb->firsthandlerargs + handlerindex), cpuregclasstoken, cpuregclassname); VTF3_PARSER_HANDLER_CALL_EPILOGUE; return; } static void StdBinaryParserDefcreator (fcb_t *fcb, int numcharsdata, int handlerindex) { int i, len, rc; const char *creator; VTF3_DCL_DEFCREATOR (typedef, (*handler_t)); handler_t handler; i = numcharsdata - 2; if (i < 0) { (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } fcb->recbufferpos = fcb->recbuffer + 6; (void) StdBinaryStoreStringOffsets (fcb, 0); len = GetStringLength (fcb, 0); if (i != len) { (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } creator = StdBinaryGetSeparatedString (fcb, 0); /* Check for a bug of the old VTF. */ if (*creator == '"') { /* Continue to check for a bug of the old VTF. */ if (*(creator + len - 1) == '"') { /* Repair the bug of the old VTF. */ *((char *) creator + len - 1) = '\0'; creator++; } } VTF3_PARSER_HANDLER_CALL_PROLOGUE (handler_t, handler); rc = (handler) (*(fcb->firsthandlerargs + handlerindex), creator); VTF3_PARSER_HANDLER_CALL_EPILOGUE; return; } static void StdBinaryParserDefdatastruc (fcb_t *fcb, int numcharsdata, int handlerindex) { int i, datastructoken, scltoken, rc; const char *datastrucname; VTF3_DCL_DEFDATASTRUC (typedef, (*handler_t)); handler_t handler; /*minimum length of record */ i = numcharsdata - 6; if (i < 0) { (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } /*first 6 bytes are record type and record length */ fcb->recbufferpos = fcb->recbuffer + 6; /*read token */ VTF3_STDBINARYPARSER_READI4 (datastructoken); /*read scl token */ VTF3_STDBINARYPARSER_READI4 (scltoken); /*read data structure name */ (void) StdBinaryStoreStringOffsets (fcb, 0); i = GetStringLength (fcb, 0); if (i < 0) { (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } datastrucname = StdBinaryGetSeparatedString (fcb, 0); VTF3_PARSER_HANDLER_CALL_PROLOGUE (handler_t, handler); rc = (handler) (*(fcb->firsthandlerargs + handlerindex), datastructoken, datastrucname, scltoken); VTF3_PARSER_HANDLER_CALL_EPILOGUE; return; } static void StdBinaryParserDefglobalop (fcb_t *fcb, int numcharsdata, int handlerindex) { int i, globaloptoken, rc; const char *globalopname; VTF3_DCL_DEFGLOBALOP (typedef, (*handler_t)); handler_t handler; i = numcharsdata - 6; if (i < 0) { (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } fcb->recbufferpos = fcb->recbuffer + 6; VTF3_STDBINARYPARSER_READI4 (globaloptoken); (void) StdBinaryStoreStringOffsets (fcb, 0); if (i != GetStringLength (fcb, 0)) { (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } globalopname = StdBinaryGetSeparatedString (fcb, 0); VTF3_PARSER_HANDLER_CALL_PROLOGUE (handler_t, handler); rc = (handler) (*(fcb->firsthandlerargs + handlerindex), globaloptoken, globalopname); VTF3_PARSER_HANDLER_CALL_EPILOGUE; return; } static void StdBinaryParserDefhist (fcb_t *fcb, int numcharsdata, int handlerindex) { int l; int histtoken, nrelements, histgrp, rc; const char *histname; VTF3_DCL_DEFHIST (typedef, (*handler_t)); handler_t handler; /*minimum length of record */ l = numcharsdata - 6; if (l < 0) { (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } /*first 6 bytes are record type and record length */ fcb->recbufferpos = fcb->recbuffer + 6; /*token */ VTF3_STDBINARYPARSER_READI4 (histtoken); /*group */ VTF3_STDBINARYPARSER_READI4 (histgrp); /*number of elements */ VTF3_STDBINARYPARSER_READI4 (nrelements); if ( nrelements<0) { (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } /*histogram name */ (void) StdBinaryStoreStringOffsets (fcb, 0); l = GetStringLength (fcb, 0); if (l < 0) { (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } histname = StdBinaryGetSeparatedString (fcb, 0); VTF3_PARSER_HANDLER_CALL_PROLOGUE (handler_t, handler); rc = (handler) (*(fcb->firsthandlerargs + handlerindex), histtoken, nrelements, histgrp, histname); VTF3_PARSER_HANDLER_CALL_EPILOGUE; return; } static void StdBinaryParserDefhistgrp (fcb_t *fcb, int numcharsdata, int handlerindex) { int i, histgrptoken, rc; const char *histgrpname; VTF3_DCL_DEFHISTGRP (typedef, (*handler_t)); handler_t handler; /*minimum length of record */ i = numcharsdata - 6; if (i < 0) { (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } /*first 6 bytes are record type and record length */ fcb->recbufferpos = fcb->recbuffer + 6; /*read token */ VTF3_STDBINARYPARSER_READI4 (histgrptoken); /*read group name */ (void) StdBinaryStoreStringOffsets (fcb, 0); if (i != GetStringLength (fcb, 0)) { (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } histgrpname = StdBinaryGetSeparatedString (fcb, 0); VTF3_PARSER_HANDLER_CALL_PROLOGUE (handler_t, handler); rc = (handler) (*(fcb->firsthandlerargs + handlerindex), histgrptoken, histgrpname); VTF3_PARSER_HANDLER_CALL_EPILOGUE; return; } static void StdBinaryParserDefiofile (fcb_t *fcb, int numcharsdata, int handlerindex) { int i, iofiletoken, communicator, rc; const char *iofilename; VTF3_DCL_DEFIOFILE (typedef, (*handler_t)); handler_t handler; i = numcharsdata - 10; if (i < 0) { (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } fcb->recbufferpos = fcb->recbuffer + 6; VTF3_STDBINARYPARSER_READI4 (iofiletoken); VTF3_STDBINARYPARSER_READI4 (communicator); (void) StdBinaryStoreStringOffsets (fcb, 0); if (i != GetStringLength (fcb, 0)) { (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } iofilename = StdBinaryGetSeparatedString (fcb, 0); VTF3_PARSER_HANDLER_CALL_PROLOGUE (handler_t, handler); rc = (handler) (*(fcb->firsthandlerargs + handlerindex), iofiletoken, communicator, iofilename); VTF3_PARSER_HANDLER_CALL_EPILOGUE; return; } static void StdBinaryParserDefkparreg (fcb_t *fcb, int numcharsdata, int handlerindex) { int i, kparregtoken, rc; const char *kparregname; VTF3_DCL_DEFKPARREG (typedef, (*handler_t)); handler_t handler; i = numcharsdata - 6; if (i < 0) { (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } fcb->recbufferpos = fcb->recbuffer + 6; VTF3_STDBINARYPARSER_READI4 (kparregtoken); (void) StdBinaryStoreStringOffsets (fcb, 0); if (i != GetStringLength (fcb, 0)) { (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } kparregname = StdBinaryGetSeparatedString (fcb, 0); VTF3_PARSER_HANDLER_CALL_PROLOGUE (handler_t, handler); rc = (handler) (*(fcb->firsthandlerargs + handlerindex), kparregtoken, kparregname); VTF3_PARSER_HANDLER_CALL_EPILOGUE; return; } static void StdBinaryParserDefmsgname (fcb_t *fcb, int numcharsdata, int handlerindex) { int i, msgtype, len, communicator, rc; const char *msgname; VTF3_DCL_DEFMSGNAME (typedef, (*handler_t)); handler_t handler; i = numcharsdata - 6; if (i < 0) { (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } fcb->recbufferpos = fcb->recbuffer + 6; VTF3_STDBINARYPARSER_READI4 (msgtype); (void) StdBinaryStoreStringOffsets (fcb, 0); len = GetStringLength (fcb, 0); if (len < 0) { (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } i -= len; if (i == 4) { VTF3_STDBINARYPARSER_READI4 (communicator); } else if (i == 0) communicator = VTF3_NOCOMMUNICATOR; else { (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } msgname = StdBinaryGetSeparatedString (fcb, 0); VTF3_PARSER_HANDLER_CALL_PROLOGUE (handler_t, handler); rc = (handler) (*(fcb->firsthandlerargs + handlerindex), msgtype, communicator, msgname); VTF3_PARSER_HANDLER_CALL_EPILOGUE; return; } static void StdBinaryParserDefopenmpname (fcb_t *fcb, int numcharsdata, int handlerindex) { int i, rc; unsigned int nametoken; const char *openmpname; VTF3_DCL_DEFOPENMPNAME (typedef, (*handler_t)); handler_t handler; i = numcharsdata - 6; if (i < 0) { (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } fcb->recbufferpos = fcb->recbuffer + 6; VTF3_STDBINARYPARSER_READU4 (nametoken); (void) StdBinaryStoreStringOffsets (fcb, 0); if (i != GetStringLength (fcb, 0)) { (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } openmpname = StdBinaryGetSeparatedString (fcb, 0); VTF3_PARSER_HANDLER_CALL_PROLOGUE (handler_t, handler); rc = (handler) (*(fcb->firsthandlerargs + handlerindex), nametoken, openmpname); VTF3_PARSER_HANDLER_CALL_EPILOGUE; return; } static void StdBinaryParserDefopenmptype (fcb_t *fcb, int numcharsdata, int handlerindex) { int i, rc; unsigned int constructtypetoken; const char *constructtypename; VTF3_DCL_DEFOPENMPTYPE (typedef, (*handler_t)); handler_t handler; i = numcharsdata - 6; if (i < 0) { (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } fcb->recbufferpos = fcb->recbuffer + 6; VTF3_STDBINARYPARSER_READU4 (constructtypetoken); (void) StdBinaryStoreStringOffsets (fcb, 0); if (i != GetStringLength (fcb, 0)) { (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } constructtypename = StdBinaryGetSeparatedString (fcb, 0); VTF3_PARSER_HANDLER_CALL_PROLOGUE (handler_t, handler); rc = (handler) (*(fcb->firsthandlerargs + handlerindex), constructtypetoken, constructtypename); VTF3_PARSER_HANDLER_CALL_EPILOGUE; return; } static void StdBinaryParserDefpattern (fcb_t *fcb, int numcharsdata, int handlerindex) { int i, timesteparraydim, activitytoken, pattoken, patshptoken, ratio, rc; double radius, timestep; VTF3_DCL_DEFPATTERN (typedef, (*handler_t)); handler_t handler; i = numcharsdata - 24; if (i < 0) { (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } if (i % 8 != 0) { (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } timesteparraydim = i / 8; fcb->recbufferpos = fcb->recbuffer + 6; VTF3_STDBINARYPARSER_READI4 (activitytoken); if (activitytoken == VTF3_NOACT) { (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } VTF3_STDBINARYPARSER_READI4 (pattoken); if (pattoken == VTF3_NOSTATE) { (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } VTF3_STDBINARYPARSER_READI4 (patshptoken); if (patshptoken == VTF3_NOSTATE) { (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } radius = StdBinaryReadTs (fcb); if (SignOfDouble (radius) < 0) { (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } VTF3_STDBINARYPARSER_READI4 (ratio); if (ratio < 0) { (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } for (i = 0; i < timesteparraydim; i++) { timestep = StdBinaryReadTs (fcb); if (SignOfDouble (timestep) < 0) { (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } (void) StoreDoubleOntoU4Vector (fcb, 2 * i + 0, timestep); } VTF3_PARSER_HANDLER_CALL_PROLOGUE (handler_t, handler); rc = (handler) (*(fcb->firsthandlerargs + handlerindex), activitytoken, pattoken, patshptoken, radius, ratio, timesteparraydim, (double *) fcb->u4vector); VTF3_PARSER_HANDLER_CALL_EPILOGUE; return; } static void StdBinaryParserDefpatternshape (fcb_t *fcb, int numcharsdata, int handlerindex) { static unsigned int first = 1; static const char *patterntypename [] = VTF3_PATTERNTYPENAME_INIT; int i, activitytoken, patshptoken, patterntype, patshptokenbref1, patshptokenbref2, rc; VTF3_DCL_DEFPATTERNSHAPE (typedef, (*handler_t)); handler_t handler; if (first != 0) { first = 0; (void) PassP (patterntypename); } i = numcharsdata - 17; if (i != 0) { (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } fcb->recbufferpos = fcb->recbuffer + 6; VTF3_STDBINARYPARSER_READI4 (activitytoken); if (activitytoken == VTF3_NOACT) { (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } VTF3_STDBINARYPARSER_READI4 (patshptoken); if (patshptoken == VTF3_NOSTATE) { (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } VTF3_STDBINARYPARSER_READI1 (patterntype); if (patterntype >= (int) (sizeof (patterntypename) / sizeof (patterntypename[0])) || patterntype < 0 || patterntype == VTF3_PATTERNTYPE_NOTYPE) { (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } VTF3_STDBINARYPARSER_READI4 (patshptokenbref1); if (patshptokenbref1 == VTF3_NOSTATE) { (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } VTF3_STDBINARYPARSER_READI4 (patshptokenbref2); if (patshptokenbref2 == VTF3_NOSTATE) { (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } VTF3_PARSER_HANDLER_CALL_PROLOGUE (handler_t, handler); rc = (handler) (*(fcb->firsthandlerargs + handlerindex), activitytoken, patshptoken, patterntype, patshptokenbref1, patshptokenbref2); VTF3_PARSER_HANDLER_CALL_EPILOGUE; return; } static void StdBinaryParserDefredfunc_obsol (fcb_t *fcb, int numcharsdata, int handlerindex) { int i, redfunctoken, rc; const char *redfuncname; VTF3_DCL_DEFREDFUNC_OBSOL (typedef, (*handler_t)); handler_t handler; i = numcharsdata - 6; if (i < 0) { (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } fcb->recbufferpos = fcb->recbuffer + 6; VTF3_STDBINARYPARSER_READI4 (redfunctoken); (void) StdBinaryStoreStringOffsets (fcb, 0); if (i != GetStringLength (fcb, 0)) { (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } redfuncname = StdBinaryGetSeparatedString (fcb, 0); VTF3_PARSER_HANDLER_CALL_PROLOGUE (handler_t, handler); rc = (handler) (*(fcb->firsthandlerargs + handlerindex), redfunctoken, redfuncname); VTF3_PARSER_HANDLER_CALL_EPILOGUE; return; } static void StdBinaryParserDefsamp (fcb_t *fcb, int numcharsdata, int handlerindex) { int i, sampletoken, sampleclasstoken, iscpugrpsamp, valuetype, dodifferentiation, datarephint, len, rc; unsigned int cpuorcpugrpid, uminh, uminl, umaxh, umaxl; double fmin, fmax; const char *samplename, *sampleunit; VTF3_DCL_DEFSAMP (typedef, (*handler_t)); handler_t handler; i = numcharsdata - 39; if (i < 0) { (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } fcb->recbufferpos = fcb->recbuffer + 6; VTF3_STDBINARYPARSER_READI4 (sampletoken); VTF3_STDBINARYPARSER_READI4 (sampleclasstoken); VTF3_STDBINARYPARSER_READI1 (iscpugrpsamp); VTF3_STDBINARYPARSER_READU4 (cpuorcpugrpid); if (iscpugrpsamp != 0) cpuorcpugrpid |= VTF3_CPUGRP_MASK; VTF3_STDBINARYPARSER_READI1 (valuetype); if (valuetype == VTF3_VALUETYPE_UINT) { VTF3_STDBINARYPARSER_READU4 (uminh); VTF3_STDBINARYPARSER_READU4 (uminl); VTF3_STDBINARYPARSER_READU4 (umaxh); VTF3_STDBINARYPARSER_READU4 (umaxl); if (vtffprtype == VTF3_CONST_FPNRT_IEEE754_DOUBLE_LITEND) { VTF3_STORE_UINT_ONTO_U4VECTOR (0, uminl); VTF3_STORE_UINT_ONTO_U4VECTOR (1, uminh); VTF3_STORE_UINT_ONTO_U4VECTOR (2, umaxl); VTF3_STORE_UINT_ONTO_U4VECTOR (3, umaxh); } else { VTF3_STORE_UINT_ONTO_U4VECTOR (0, uminh); VTF3_STORE_UINT_ONTO_U4VECTOR (1, uminl); VTF3_STORE_UINT_ONTO_U4VECTOR (2, umaxh); VTF3_STORE_UINT_ONTO_U4VECTOR (3, umaxl); } } else if (valuetype == VTF3_VALUETYPE_FLOAT) { fmin = StdBinaryReadF8 (fcb); fmax = StdBinaryReadF8 (fcb); (void) StoreDoubleOntoU4Vector (fcb, 0, fmin); (void) StoreDoubleOntoU4Vector (fcb, 2, fmax); } else { (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } VTF3_STDBINARYPARSER_READI1 (dodifferentiation); VTF3_STDBINARYPARSER_READI4 (datarephint); (void) StdBinaryStoreStringOffsets (fcb, 0); len = GetStringLength (fcb, 0); if (len < 0) { (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } i -= len; if (i < 0) { (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } (void) StdBinaryStoreStringOffsets (fcb, 1); if (i != GetStringLength (fcb, 1)) { (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } samplename = StdBinaryGetSeparatedString (fcb, 0); sampleunit = StdBinaryGetSeparatedString (fcb, 1); VTF3_PARSER_HANDLER_CALL_PROLOGUE (handler_t, handler); rc = (handler) (*(fcb->firsthandlerargs + handlerindex), sampletoken, sampleclasstoken, iscpugrpsamp, cpuorcpugrpid, valuetype, fcb->u4vector, dodifferentiation, datarephint, samplename, sampleunit); VTF3_PARSER_HANDLER_CALL_EPILOGUE; return; } static void StdBinaryParserDefsampclass (fcb_t *fcb, int numcharsdata, int handlerindex) { int i, sampleclasstoken, rc; const char *sampleclassname; VTF3_DCL_DEFSAMPCLASS (typedef, (*handler_t)); handler_t handler; i = numcharsdata - 6; if (i < 0) { (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } fcb->recbufferpos = fcb->recbuffer + 6; VTF3_STDBINARYPARSER_READI4 (sampleclasstoken); (void) StdBinaryStoreStringOffsets (fcb, 0); if (i != GetStringLength (fcb, 0)) { (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } sampleclassname = StdBinaryGetSeparatedString (fcb, 0); VTF3_PARSER_HANDLER_CALL_PROLOGUE (handler_t, handler); rc = (handler) (*(fcb->firsthandlerargs + handlerindex), sampleclasstoken, sampleclassname); VTF3_PARSER_HANDLER_CALL_EPILOGUE; return; } static void StdBinaryParserDefscl (fcb_t *fcb, int numcharsdata, int handlerindex) { int i, sclarraydim, scltoken, sclfiletoken, scllineposition, rc; VTF3_DCL_DEFSCL (typedef, (*handler_t)); handler_t handler; i = numcharsdata - 4; if (i < 0) { (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } if (i % 8 != 0) { (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } sclarraydim = i / 8; fcb->recbufferpos = fcb->recbuffer + 6; VTF3_STDBINARYPARSER_READI4 (scltoken); if (scltoken == VTF3_SCLNONE || scltoken == VTF3_SCLRESET) { (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } for (i = 0; i < sclarraydim; i++) { VTF3_STDBINARYPARSER_READI4 (sclfiletoken); VTF3_STORE_ONTO_INT_VECTOR (i, sclfiletoken); VTF3_STDBINARYPARSER_READI4 (scllineposition); VTF3_STORE_ONTO_INT_VECTOR2 (i, scllineposition); } VTF3_PARSER_HANDLER_CALL_PROLOGUE (handler_t, handler); rc = (handler) (*(fcb->firsthandlerargs + handlerindex), scltoken, sclarraydim, fcb->intvector, fcb->intvector2); VTF3_PARSER_HANDLER_CALL_EPILOGUE; return; } static void StdBinaryParserDefsclfile (fcb_t *fcb, int numcharsdata, int handlerindex) { int i, sclfiletoken, rc; const char *sclfilename; VTF3_DCL_DEFSCLFILE (typedef, (*handler_t)); handler_t handler; i = numcharsdata - 6; if (i < 0) { (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } fcb->recbufferpos = fcb->recbuffer + 6; VTF3_STDBINARYPARSER_READI4 (sclfiletoken); (void) StdBinaryStoreStringOffsets (fcb, 0); if (i != GetStringLength (fcb, 0)) { (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } sclfilename = StdBinaryGetSeparatedString (fcb, 0); VTF3_PARSER_HANDLER_CALL_PROLOGUE (handler_t, handler); rc = (handler) (*(fcb->firsthandlerargs + handlerindex), sclfiletoken, sclfilename); VTF3_PARSER_HANDLER_CALL_EPILOGUE; return; } static void StdBinaryParserDefstate (fcb_t *fcb, int numcharsdata, int handlerindex) { static const char *noact = "NOACT"; int i, activitytoken, statetoken, len, scltoken, isequal, rc; const char *statename; VTF3_DCL_DEFSTATE (typedef, (*handler_t)); handler_t handler; i = numcharsdata - 10; if (i < 0) { (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } fcb->recbufferpos = fcb->recbuffer + 6; VTF3_STDBINARYPARSER_READI4 (activitytoken); VTF3_STDBINARYPARSER_READI4 (statetoken); (void) StdBinaryStoreStringOffsets (fcb, 0); len = GetStringLength (fcb, 0); if (len < 0) { (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } i -= len; if (i == 4) { VTF3_STDBINARYPARSER_READI4 (scltoken); } else if (i == 0) scltoken = VTF3_SCLNONE; else { (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } statename = fcb->recbuffer + *(fcb->stroffsetvectorstart + 0); if (statetoken == VTF3_NOSTATE || activitytoken == VTF3_NOACT) { if (statetoken != VTF3_NOSTATE || activitytoken != VTF3_NOACT) { (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } if (len != 5) { (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } for (i = 0; i < 5; i++) if (*(statename + i) != *(noact + i)) { (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } /* Trivial information, ignore this record. */ return; } if (len == 5) { isequal = 1; for (i = 0; i < 5; i++) if (*(statename + i) != *(noact + i)) { isequal = 0; break; } if (isequal != 0) { (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } } statename = StdBinaryGetSeparatedString (fcb, 0); VTF3_PARSER_HANDLER_CALL_PROLOGUE (handler_t, handler); rc = (handler) (*(fcb->firsthandlerargs + handlerindex), activitytoken, statetoken, statename, scltoken); VTF3_PARSER_HANDLER_CALL_EPILOGUE; return; } static void StdBinaryParserDefstate_obsol (fcb_t *fcb, int numcharsdata, int handlerindex) { static const char *noact = "NOACT"; int i, activitytoken, statetoken, len, isequal, rc; const char *statename; VTF3_DCL_DEFSTATE_OBSOL (typedef, (*handler_t)); handler_t handler; i = numcharsdata - 10; if (i < 0) { (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } fcb->recbufferpos = fcb->recbuffer + 6; VTF3_STDBINARYPARSER_READI4 (activitytoken); VTF3_STDBINARYPARSER_READI4 (statetoken); (void) StdBinaryStoreStringOffsets (fcb, 0); len = GetStringLength (fcb, 0); if (len < 0) { (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } i -= len; if (i == 8) /* Old style `SCL #:#', ignore it. */ i -= 8; if (i != 0) { (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } statename = fcb->recbuffer + *(fcb->stroffsetvectorstart + 0); if (statetoken == VTF3_NOSTATE || activitytoken == VTF3_NOACT) { if (statetoken != VTF3_NOSTATE || activitytoken != VTF3_NOACT) { (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } if (len != 5) { (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } for (i = 0; i < 5; i++) if (*(statename + i) != *(noact + i)) { (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } /* Trivial information, ignore this record. */ return; } if (len == 5) { isequal = 1; for (i = 0; i < 5; i++) if (*(statename + i) != *(noact + i)) { isequal = 0; break; } if (isequal != 0) { (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } } statename = StdBinaryGetSeparatedString (fcb, 0); VTF3_PARSER_HANDLER_CALL_PROLOGUE (handler_t, handler); /* Note for VAMPIR, VPTMERGE and other applications. This interface has different modes. Firstly, `(activityvalidity & VTF3_OLDACT_VALID_TOKEN) != 0 && (activityvalidity & VTF3_OLDACT_VALID_NAME ) == 0'. In this mode, which is used here, one has to process the activity token. Secondly, `(activityvalidity & VTF3_OLDACT_VALID_TOKEN) == 0 && (activityvalidity & VTF3_OLDACT_VALID_NAME ) != 0'. When in second mode, which is used by the ASCII parsers, the activity name is valid. Thirdly, `(activityvalidity & VTF3_OLDACT_VALID_TOKEN) != 0 && (activityvalidity & VTF3_OLDACT_VALID_NAME ) != 0'. Both, the activity token and the activity name, have to be valid. The latter mode is not supported by VTF3, but, of course, it is necessary at higher application levels. Since one needs to assume here that the input is unsorted, it is not appropriate to perform any activity string tokenization/retokenization. As the result, one has to take into account that it is impossible to have different formats for input and output without higher level support for the obsolete activity and state definition records. In this way, VAMPIR and VPTMERGE should not have any trouble, but, for instance, VTF3_CopyFile() will fail in some cases. */ rc = (handler) (*(fcb->firsthandlerargs + handlerindex), activitytoken, noact, VTF3_OLDACT_VALID_TOKEN, statetoken, statename); VTF3_PARSER_HANDLER_CALL_EPILOGUE; return; } static void StdBinaryParserDefsyscpunames (fcb_t *fcb, int numcharsdata, int handlerindex) { int k, systemcpunamearraydim, i, len, rc; const char *p; VTF3_DCL_DEFSYSCPUNAMES (typedef, (*handler_t)); handler_t handler; k = numcharsdata - 4; if (k < 0) { (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } fcb->recbufferpos = fcb->recbuffer + 6; VTF3_STDBINARYPARSER_READI4 (systemcpunamearraydim); if (systemcpunamearraydim < 0) { (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } for (i = 0; i < systemcpunamearraydim; i++) { k -= 2; if (k < 0) { (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } (void) StdBinaryStoreStringOffsets (fcb, i); len = GetStringLength (fcb, i); if (len < 0) { (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } k -= len; if (k < 0) { (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } } if (k != 0) { (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } for (i = 0; i < systemcpunamearraydim; i++) { p = StdBinaryGetSeparatedString (fcb, i); (void) StoreOntoCharPtrVector (fcb, i, p); } (void) StoreOntoCharPtrVector (fcb, systemcpunamearraydim, 0); VTF3_PARSER_HANDLER_CALL_PROLOGUE (handler_t, handler); rc = (handler) (*(fcb->firsthandlerargs + handlerindex), systemcpunamearraydim, fcb->charptrvector); VTF3_PARSER_HANDLER_CALL_EPILOGUE; return; } static void StdBinaryParserDefsyscpunums (fcb_t *fcb, int numcharsdata, int handlerindex) { int i, systemcpunumberarraydim, systemcpunumber, rc; VTF3_DCL_DEFSYSCPUNUMS (typedef, (*handler_t)); handler_t handler; i = numcharsdata - 4; if (i < 0) { (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } fcb->recbufferpos = fcb->recbuffer + 6; VTF3_STDBINARYPARSER_READI4 (systemcpunumberarraydim); if (i != systemcpunumberarraydim * 4) { (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } for (i = 0; i < systemcpunumberarraydim; i++) { VTF3_STDBINARYPARSER_READI4 (systemcpunumber); VTF3_STORE_ONTO_INT_VECTOR (i, systemcpunumber); } VTF3_PARSER_HANDLER_CALL_PROLOGUE (handler_t, handler); rc = (handler) (*(fcb->firsthandlerargs + handlerindex), systemcpunumberarraydim, fcb->intvector); VTF3_PARSER_HANDLER_CALL_EPILOGUE; return; } static void StdBinaryParserDefthreadnums (fcb_t *fcb, int numcharsdata, int handlerindex) { int i, threadnumarraydim, threadnum, rc; VTF3_DCL_DEFTHREADNUMS (typedef, (*handler_t)); handler_t handler; i = numcharsdata - 4; if (i < 0) { (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } fcb->recbufferpos = fcb->recbuffer + 6; VTF3_STDBINARYPARSER_READI4 (threadnumarraydim); if (i != threadnumarraydim * 4) { (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } for (i = 0; i < threadnumarraydim; i++) { VTF3_STDBINARYPARSER_READI4 (threadnum); VTF3_STORE_ONTO_INT_VECTOR (i, threadnum); } VTF3_PARSER_HANDLER_CALL_PROLOGUE (handler_t, handler); rc = (handler) (*(fcb->firsthandlerargs + handlerindex), threadnumarraydim, fcb->intvector); VTF3_PARSER_HANDLER_CALL_EPILOGUE; return; } static void StdBinaryParserDeftimeoffset (fcb_t *fcb, int numcharsdata, int handlerindex) { int i, rc; unsigned int uinttimeoffset; double timeoffset; VTF3_DCL_DEFTIMEOFFSET (typedef, (*handler_t)); handler_t handler; i = numcharsdata - 4; if (i != 0) { (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } fcb->recbufferpos = fcb->recbuffer + 6; VTF3_STDBINARYPARSER_READU4 (uinttimeoffset); timeoffset = (double) uinttimeoffset; VTF3_PARSER_HANDLER_CALL_PROLOGUE (handler_t, handler); rc = (handler) (*(fcb->firsthandlerargs + handlerindex), timeoffset); VTF3_PARSER_HANDLER_CALL_EPILOGUE; return; } static void StdBinaryParserDefunmerged (fcb_t *fcb, int numcharsdata, int handlerindex) { int i, rc; VTF3_DCL_DEFUNMERGED (typedef, (*handler_t)); handler_t handler; i = numcharsdata - 0; if (i != 0) { (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } fcb->recbufferpos = fcb->recbuffer + 6; VTF3_PARSER_HANDLER_CALL_PROLOGUE (handler_t, handler); rc = (handler) (*(fcb->firsthandlerargs + handlerindex)); VTF3_PARSER_HANDLER_CALL_EPILOGUE; return; } static void StdBinaryParserDefversion (fcb_t *fcb, int numcharsdata, int handlerindex) { int i, rc; int versionnumber; VTF3_DCL_DEFVERSION (typedef, (*handler_t)); handler_t handler; i = numcharsdata - 4; if (i != 0) { (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } fcb->recbufferpos = fcb->recbuffer + 6; VTF3_STDBINARYPARSER_READI4 (versionnumber); VTF3_PARSER_HANDLER_CALL_PROLOGUE (handler_t, handler); rc = (handler) (*(fcb->firsthandlerargs + handlerindex), versionnumber); VTF3_PARSER_HANDLER_CALL_EPILOGUE; return; } static void StdBinaryParserDownto (fcb_t *fcb, int numcharsdata, int handlerindex) { int i, statetoken, scltoken, exchangetype, rc; double time; unsigned int cpuid; VTF3_DCL_DOWNTO (typedef, (*handler_t)); handler_t handler; i = numcharsdata - 12; if (i < 0) { (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } fcb->recbufferpos = fcb->recbuffer + 6; time = StdBinaryReadTs (fcb); VTF3_STDBINARYPARSER_READI4 (statetoken); if (statetoken == VTF3_NOSTATE) { (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } if (i == 4 || i == 9) { i -= 4; VTF3_STDBINARYPARSER_READU4 (cpuid); } else cpuid = 0; if (i == 5) { VTF3_STDBINARYPARSER_READI4 (scltoken); } else if (i == 0) scltoken = VTF3_SCLNONE; else { (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } VTF3_PARSER_LAST_VALID_TIME_MANAGEMENT; if (fcb->substitudeupfrom != 0) { exchangetype = VTF3_EXCHANGETYPE_DOWNTO; (void) SubstitudeUpFrom (fcb, cpuid, &exchangetype, &statetoken); } VTF3_PARSER_HANDLER_CALL_PROLOGUE (handler_t, handler); rc = (handler) (*(fcb->firsthandlerargs + handlerindex), time, statetoken, cpuid, scltoken); VTF3_PARSER_HANDLER_CALL_EPILOGUE; return; } static void StdBinaryParserExchange (fcb_t *fcb, int numcharsdata, int handlerindex) { static unsigned int first = 1; static const char *exchangetypename [] = VTF3_EXCHANGETYPENAME_INIT; int i, exchangetype, statetoken, job, scltoken, rc; double time; unsigned int cpuid; VTF3_DCL_EXCHANGE (typedef, (*handler_t)); handler_t handler; if (first != 0) { first = 0; (void) PassP (exchangetypename); } i = numcharsdata - 17; if (i < 0) { (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } fcb->recbufferpos = fcb->recbuffer + 6; time = StdBinaryReadTs (fcb); VTF3_STDBINARYPARSER_READU4 (cpuid); VTF3_STDBINARYPARSER_READI1 (exchangetype); VTF3_STDBINARYPARSER_READI4 (statetoken); if (i % 4 == 1) { i -= 4 + 1; if (i < 0) { (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } VTF3_STDBINARYPARSER_READI4 (job); } else job = VTF3_NOJOB; if (i == 4) { VTF3_STDBINARYPARSER_READI4 (scltoken); } else if (i == 0) scltoken = VTF3_SCLNONE; else { (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } if (statetoken == VTF3_NOSTATE) { if (exchangetype == VTF3_EXCHANGETYPE_DOWNTO) { (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } if (exchangetype == VTF3_EXCHANGETYPE_UPFROM) { (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } } if (exchangetype >= (int) (sizeof (exchangetypename) / sizeof (exchangetypename[0])) || exchangetype < 0 || exchangetype == VTF3_EXCHANGETYPE_NOEXCH) { (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } VTF3_PARSER_LAST_VALID_TIME_MANAGEMENT; if (fcb->substitudeupfrom != 0) (void) SubstitudeUpFrom (fcb, cpuid, &exchangetype, &statetoken); VTF3_PARSER_HANDLER_CALL_PROLOGUE (handler_t, handler); rc = (handler) (*(fcb->firsthandlerargs + handlerindex), time, cpuid, exchangetype, statetoken, job, scltoken); VTF3_PARSER_HANDLER_CALL_EPILOGUE; return; } static void StdBinaryParserExchange_obsol (fcb_t *fcb, int numcharsdata, int handlerindex) { static const char *noact = "NOACT"; int i, activitytoken, statetoken, job, exchangetype, rc; double time; unsigned int cpuid; VTF3_DCL_EXCHANGE_OBSOL (typedef, (*handler_t)); handler_t handler; i = numcharsdata - 32; if (i < 0) { (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } fcb->recbufferpos = fcb->recbuffer + 6; time = StdBinaryReadTs (fcb); VTF3_STDBINARYPARSER_READU4 (cpuid); VTF3_STDBINARYPARSER_READI4 (activitytoken); VTF3_STDBINARYPARSER_READI4 (statetoken); VTF3_STDBINARYPARSER_READI4 (activitytoken); VTF3_STDBINARYPARSER_READI4 (statetoken); VTF3_STDBINARYPARSER_READI4 (job); if (i % 8 == 1) { i--; VTF3_STDBINARYPARSER_READI1 (exchangetype); } else exchangetype = VTF3_EXCHANGETYPE_TO; if (i == 8) /* Old style `SCL #:#', ignore it. */ i -= 8; if (i != 0) { (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } if (statetoken == VTF3_NOSTATE || activitytoken == VTF3_NOACT) { if (exchangetype == 2 && statetoken == (-1) && activitytoken == 0) { /* Old-style record, repair it. */ exchangetype = VTF3_EXCHANGETYPE_UPTO; statetoken = VTF3_NOSTATE; activitytoken = VTF3_NOACT; } if (statetoken != VTF3_NOSTATE || activitytoken != VTF3_NOACT) { (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } if (exchangetype == VTF3_EXCHANGETYPE_DOWNTO) { (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } } if (exchangetype != VTF3_EXCHANGETYPE_TO && exchangetype != VTF3_EXCHANGETYPE_DOWNTO && exchangetype != VTF3_EXCHANGETYPE_UPTO) { (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } VTF3_PARSER_LAST_VALID_TIME_MANAGEMENT; if (fcb->substitudeupfrom != 0) (void) SubstitudeUpFrom (fcb, cpuid, &exchangetype, &statetoken); VTF3_PARSER_HANDLER_CALL_PROLOGUE (handler_t, handler); /* Note for VAMPIR, VPTMERGE and other applications. This interface has different modes. Firstly, `(activityvalidity & VTF3_OLDACT_VALID_TOKEN) != 0 && (activityvalidity & VTF3_OLDACT_VALID_NAME ) == 0'. In this mode, which is used here, one has to process the activity token. Secondly, `(activityvalidity & VTF3_OLDACT_VALID_TOKEN) == 0 && (activityvalidity & VTF3_OLDACT_VALID_NAME ) != 0'. When in second mode, which is used by the ASCII parsers, the activity name is valid. Thirdly, `(activityvalidity & VTF3_OLDACT_VALID_TOKEN) != 0 && (activityvalidity & VTF3_OLDACT_VALID_NAME ) != 0'. Both, the activity token and the activity name, have to be valid. The latter mode is not supported by VTF3, but, of course, it is necessary at higher application levels. Since one needs to assume here that the input is unsorted, it is not appropriate to perform any activity string tokenization/retokenization. As the result, one has to take into account that it is impossible to have different formats for input and output without higher level support for the obsolete activity and state definition records. In this way, VAMPIR and VPTMERGE should not have any trouble, but, for instance, VTF3_CopyFile() will fail in some cases. */ rc = (handler) (*(fcb->firsthandlerargs + handlerindex), time, cpuid, exchangetype, statetoken, activitytoken, noact, VTF3_OLDACT_VALID_TOKEN, job); VTF3_PARSER_HANDLER_CALL_EPILOGUE; return; } static void StdBinaryParserFileiobegin (fcb_t *fcb, int numcharsdata, int handlerindex) { static unsigned int first = 1; static const char *fileiotypename [] = VTF3_FILEIOTYPENAME_INIT; int i, fileiotype, iofiletoken, bytescopied, scltoken, rc; double time; unsigned int cpuid; VTF3_DCL_FILEIOBEGIN (typedef, (*handler_t)); handler_t handler; if (first != 0) { first = 0; (void) PassP (fileiotypename); } i = numcharsdata - 22; if (i < 0) { (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } fcb->recbufferpos = fcb->recbuffer + 6; time = StdBinaryReadTs (fcb); fileiotype = StdBinaryReadI2 (fcb); if (fileiotype >= (int) (sizeof (fileiotypename) / sizeof (fileiotypename[0])) || fileiotype < 0 || fileiotype == VTF3_FILEIOTYPE_NOTYPE) { (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } VTF3_STDBINARYPARSER_READU4 (cpuid); VTF3_STDBINARYPARSER_READI4 (iofiletoken); VTF3_STDBINARYPARSER_READI4 (bytescopied); if (i == 4) { VTF3_STDBINARYPARSER_READI4 (scltoken); } else if (i == 0) scltoken = VTF3_SCLNONE; else { (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } VTF3_PARSER_LAST_VALID_TIME_MANAGEMENT; VTF3_PARSER_HANDLER_CALL_PROLOGUE (handler_t, handler); rc = (handler) (*(fcb->firsthandlerargs + handlerindex), time, cpuid, fileiotype, iofiletoken, bytescopied, scltoken); VTF3_PARSER_HANDLER_CALL_EPILOGUE; return; } static void StdBinaryParserFileioend (fcb_t *fcb, int numcharsdata, int handlerindex) { static unsigned int first = 1; static const char *fileiotypename [] = VTF3_FILEIOTYPENAME_INIT; int i, fileiotype, iofiletoken, bytescopied, scltoken, rc; double time; unsigned int cpuid; VTF3_DCL_FILEIOEND (typedef, (*handler_t)); handler_t handler; if (first != 0) { first = 0; (void) PassP (fileiotypename); } i = numcharsdata - 22; if (i < 0) { (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } fcb->recbufferpos = fcb->recbuffer + 6; time = StdBinaryReadTs (fcb); fileiotype = StdBinaryReadI2 (fcb); if (fileiotype >= (int) (sizeof (fileiotypename) / sizeof (fileiotypename[0])) || fileiotype < 0 || fileiotype == VTF3_FILEIOTYPE_NOTYPE) { (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } VTF3_STDBINARYPARSER_READU4 (cpuid); VTF3_STDBINARYPARSER_READI4 (iofiletoken); VTF3_STDBINARYPARSER_READI4 (bytescopied); if (i == 4) { VTF3_STDBINARYPARSER_READI4 (scltoken); } else if (i == 0) scltoken = VTF3_SCLNONE; else { (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } VTF3_PARSER_LAST_VALID_TIME_MANAGEMENT; VTF3_PARSER_HANDLER_CALL_PROLOGUE (handler_t, handler); rc = (handler) (*(fcb->firsthandlerargs + handlerindex), time, cpuid, fileiotype, iofiletoken, bytescopied, scltoken); VTF3_PARSER_HANDLER_CALL_EPILOGUE; return; } static void StdBinaryParserGlobalop (fcb_t *fcb, int numcharsdata, int handlerindex) { int i, globaloptoken, communicator, bytessent, bytesreceived, scltoken, rc; double time, durationtimesteps; unsigned int cpuid, rootcpuid; VTF3_DCL_GLOBALOP (typedef, (*handler_t)); handler_t handler; i = numcharsdata - 40; if (i < 0) goto ParserLegacyGlobalop; fcb->recbufferpos = fcb->recbuffer + 6; time = StdBinaryReadTs (fcb); VTF3_STDBINARYPARSER_READI4 (globaloptoken); VTF3_STDBINARYPARSER_READU4 (cpuid); VTF3_STDBINARYPARSER_READI4 (communicator); VTF3_STDBINARYPARSER_READU4 (rootcpuid); VTF3_STDBINARYPARSER_READI4 (bytessent); VTF3_STDBINARYPARSER_READI4 (bytesreceived); durationtimesteps = StdBinaryReadTs (fcb); if (SignOfDouble (durationtimesteps) < 0) durationtimesteps = -1.0e+0; if (i == 4) { VTF3_STDBINARYPARSER_READI4 (scltoken); } else if (i == 0) scltoken = VTF3_SCLNONE; else goto ParserLegacyGlobalop; /* LABEL */ InvokeGlobalopHandler: VTF3_PARSER_LAST_VALID_TIME_MANAGEMENT; VTF3_PARSER_HANDLER_CALL_PROLOGUE (handler_t, handler); /* Note for VAMPIR, VPTMERGE and other applications. A value `durationtimesteps<0' means that the duration time value is not valid, i.e., this information is not available. */ rc = (handler) (*(fcb->firsthandlerargs + handlerindex), time, globaloptoken, cpuid, communicator, rootcpuid, bytessent, bytesreceived, durationtimesteps, scltoken); VTF3_PARSER_HANDLER_CALL_EPILOGUE; return; /* LABEL */ ParserLegacyGlobalop: i = numcharsdata - 32; if (i < 0) { (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } fcb->recbufferpos = fcb->recbuffer + 6; time = StdBinaryReadTs (fcb); VTF3_STDBINARYPARSER_READI4 (globaloptoken); VTF3_STDBINARYPARSER_READU4 (cpuid); VTF3_STDBINARYPARSER_READI4 (communicator); VTF3_STDBINARYPARSER_READU4 (rootcpuid); VTF3_STDBINARYPARSER_READI4 (bytessent); VTF3_STDBINARYPARSER_READI4 (bytesreceived); if (i % 4 == 2) { i -= 8 + 2; if (i < 0) { (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } /* StdBinaryReadTs() is able to return negative values. */ durationtimesteps = StdBinaryReadTs (fcb); if (SignOfDouble (durationtimesteps) < 0) durationtimesteps = -1.0e+0; } else durationtimesteps = -1.0e+0; if (i == 8) /* Old style `SCL #:#', ignore it. */ scltoken = VTF3_SCLNONE; else if (i == 4) { VTF3_STDBINARYPARSER_READI4 (scltoken); } else if (i == 0) scltoken = VTF3_SCLNONE; else { (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } goto InvokeGlobalopHandler; } static void StdBinaryParserHist (fcb_t *fcb, int numcharsdata, int handlerindex) { int i, j, k, histtoken, dim, rc, nrdatastruc, datastructoken; double time, starttime; unsigned int cpuid, ul, uh; VTF3_DCL_HIST (typedef, (*handler_t)); handler_t handler; /*min number of bytes expected (4length,2type,8time,4token,4cpu,4dim) */ i = numcharsdata - 26; if (i < 0) { (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } fcb->recbufferpos = fcb->recbuffer + 6; time = StdBinaryReadTs (fcb); VTF3_STDBINARYPARSER_READI4 (histtoken); starttime = StdBinaryReadTs (fcb); VTF3_STDBINARYPARSER_READU4 (cpuid); VTF3_STDBINARYPARSER_READI4 (dim); if ( dim < 0 ) { (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } /*read bins */ k=0; for (i = 0; i < dim; i++) { VTF3_STDBINARYPARSER_READI4 (nrdatastruc); VTF3_STORE_ONTO_INT_VECTOR (i, nrdatastruc); if ( nrdatastruc < 0) { (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } if ( nrdatastruc == 0 ) { VTF3_STORE_ONTO_INT_VECTOR2 (k, VTF3_NODATASTRUC); k++; } else { for (j = 0; j < nrdatastruc; j++) { VTF3_STDBINARYPARSER_READI4 (datastructoken); VTF3_STORE_ONTO_INT_VECTOR2 (k, datastructoken); k++; } } } /*histogram values */ for ( i=0; ifirsthandlerargs + handlerindex), time, histtoken, starttime, cpuid, dim, fcb->intvector, fcb->intvector2, fcb->u4vector ); VTF3_PARSER_HANDLER_CALL_EPILOGUE; return; } static void StdBinaryParserKparregbarsum (fcb_t *fcb, int numcharsdata, int handlerindex) { int i, kparregtoken, seqn, opasize, scltoken, rc; double time; unsigned int cpuid; const void *opastream; VTF3_DCL_KPARREGBARSUM (typedef, (*handler_t)); handler_t handler; i = numcharsdata - 24; if (i < 0) { (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } fcb->recbufferpos = fcb->recbuffer + 6; time = StdBinaryReadTs (fcb); VTF3_STDBINARYPARSER_READU4 (cpuid); VTF3_STDBINARYPARSER_READI4 (kparregtoken); VTF3_STDBINARYPARSER_READI4 (seqn); VTF3_STDBINARYPARSER_READI4 (opasize); if (opasize < 0) { (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } i -= opasize; if (i < 0) { (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } opastream = fcb->recbufferpos; fcb->recbufferpos += opasize; opasize *= (int) sizeof (char); if (i == 4) { VTF3_STDBINARYPARSER_READI4 (scltoken); } else if (i == 0) scltoken = VTF3_SCLNONE; else { (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } VTF3_PARSER_LAST_VALID_TIME_MANAGEMENT; VTF3_PARSER_HANDLER_CALL_PROLOGUE (handler_t, handler); rc = (handler) (*(fcb->firsthandlerargs + handlerindex), time, cpuid, kparregtoken, seqn, opasize, opastream, scltoken); VTF3_PARSER_HANDLER_CALL_EPILOGUE; return; } static void StdBinaryParserKparregbegin (fcb_t *fcb, int numcharsdata, int handlerindex) { int i, kparregtoken, seqn, numthreads, scltoken, rc; double time; unsigned int cpuid; VTF3_DCL_KPARREGBEGIN (typedef, (*handler_t)); handler_t handler; i = numcharsdata - 24; if (i < 0) { (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } fcb->recbufferpos = fcb->recbuffer + 6; time = StdBinaryReadTs (fcb); VTF3_STDBINARYPARSER_READU4 (cpuid); VTF3_STDBINARYPARSER_READI4 (kparregtoken); VTF3_STDBINARYPARSER_READI4 (seqn); VTF3_STDBINARYPARSER_READI4 (numthreads); if (i == 4) { VTF3_STDBINARYPARSER_READI4 (scltoken); } else if (i == 0) scltoken = VTF3_SCLNONE; else { (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } VTF3_PARSER_LAST_VALID_TIME_MANAGEMENT; VTF3_PARSER_HANDLER_CALL_PROLOGUE (handler_t, handler); rc = (handler) (*(fcb->firsthandlerargs + handlerindex), time, cpuid, kparregtoken, seqn, numthreads, scltoken); VTF3_PARSER_HANDLER_CALL_EPILOGUE; return; } static void StdBinaryParserKparregend (fcb_t *fcb, int numcharsdata, int handlerindex) { int i, kparregtoken, seqn, opasize, scltoken, rc; double time; unsigned int cpuid; const void *opastream; VTF3_DCL_KPARREGEND (typedef, (*handler_t)); handler_t handler; i = numcharsdata - 24; if (i < 0) { (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } fcb->recbufferpos = fcb->recbuffer + 6; time = StdBinaryReadTs (fcb); VTF3_STDBINARYPARSER_READU4 (cpuid); VTF3_STDBINARYPARSER_READI4 (kparregtoken); VTF3_STDBINARYPARSER_READI4 (seqn); VTF3_STDBINARYPARSER_READI4 (opasize); if (opasize < 0) { (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } i -= opasize; if (i < 0) { (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } opastream = fcb->recbufferpos; fcb->recbufferpos += opasize; opasize *= (int) sizeof (char); if (i == 4) { VTF3_STDBINARYPARSER_READI4 (scltoken); } else if (i == 0) scltoken = VTF3_SCLNONE; else { (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } VTF3_PARSER_LAST_VALID_TIME_MANAGEMENT; VTF3_PARSER_HANDLER_CALL_PROLOGUE (handler_t, handler); rc = (handler) (*(fcb->firsthandlerargs + handlerindex), time, cpuid, kparregtoken, seqn, opasize, opastream, scltoken); VTF3_PARSER_HANDLER_CALL_EPILOGUE; return; } static void StdBinaryParserMutexacquire (fcb_t *fcb, int numcharsdata, int handlerindex) { int i, enterstatetoken, leavestatetoken, leavestatetokenisupfrom, mutexsize, scltoken, exchangetype, rc; double time, durationtimesteps; unsigned int cpuid; const void *mutex; VTF3_DCL_MUTEXACQUIRE (typedef, (*handler_t)); handler_t handler; i = numcharsdata - 33; if (i < 0) { (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } fcb->recbufferpos = fcb->recbuffer + 6; time = StdBinaryReadTs (fcb); VTF3_STDBINARYPARSER_READU4 (cpuid); VTF3_STDBINARYPARSER_READI4 (enterstatetoken); if (enterstatetoken == VTF3_NOSTATE) { (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } VTF3_STDBINARYPARSER_READI4 (leavestatetoken); VTF3_STDBINARYPARSER_READI1 (leavestatetokenisupfrom); if (leavestatetokenisupfrom != 0) leavestatetokenisupfrom = 1; if (leavestatetokenisupfrom != 0 && leavestatetoken != enterstatetoken) { (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } durationtimesteps = StdBinaryReadTs (fcb); if (SignOfDouble (durationtimesteps) < 0) { (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } VTF3_STDBINARYPARSER_READI4 (mutexsize); if (mutexsize < 0) { (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } i -= mutexsize; if (i < 0) { (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } mutex = fcb->recbufferpos; fcb->recbufferpos += mutexsize; mutexsize *= (int) sizeof (char); if (i == 4) { VTF3_STDBINARYPARSER_READI4 (scltoken); } else if (i == 0) scltoken = VTF3_SCLNONE; else { (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } VTF3_PARSER_LAST_VALID_TIME_MANAGEMENT; if (fcb->substitudeupfrom != 0 && leavestatetokenisupfrom != 0) { exchangetype = VTF3_EXCHANGETYPE_DOWNTO; (void) SubstitudeUpFrom (fcb, cpuid, &exchangetype, &enterstatetoken); exchangetype = VTF3_EXCHANGETYPE_UPFROM; (void) SubstitudeUpFrom (fcb, cpuid, &exchangetype, &leavestatetoken); if (exchangetype != VTF3_EXCHANGETYPE_UPFROM) leavestatetokenisupfrom = 0; } VTF3_PARSER_HANDLER_CALL_PROLOGUE (handler_t, handler); rc = (handler) (*(fcb->firsthandlerargs + handlerindex), time, cpuid, enterstatetoken, leavestatetoken, leavestatetokenisupfrom, durationtimesteps, mutexsize, mutex, scltoken); VTF3_PARSER_HANDLER_CALL_EPILOGUE; return; } static void StdBinaryParserMutexrelease (fcb_t *fcb, int numcharsdata, int handlerindex) { int i, enterstatetoken, leavestatetoken, leavestatetokenisupfrom, mutexsize, scltoken, exchangetype, rc; double time, durationtimesteps; unsigned int cpuid; const void *mutex; VTF3_DCL_MUTEXRELEASE (typedef, (*handler_t)); handler_t handler; i = numcharsdata - 33; if (i < 0) { (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } fcb->recbufferpos = fcb->recbuffer + 6; time = StdBinaryReadTs (fcb); VTF3_STDBINARYPARSER_READU4 (cpuid); VTF3_STDBINARYPARSER_READI4 (enterstatetoken); if (enterstatetoken == VTF3_NOSTATE) { (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } VTF3_STDBINARYPARSER_READI4 (leavestatetoken); VTF3_STDBINARYPARSER_READI1 (leavestatetokenisupfrom); if (leavestatetokenisupfrom != 0) leavestatetokenisupfrom = 1; if (leavestatetokenisupfrom != 0 && leavestatetoken != enterstatetoken) { (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } durationtimesteps = StdBinaryReadTs (fcb); if (SignOfDouble (durationtimesteps) < 0) { (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } VTF3_STDBINARYPARSER_READI4 (mutexsize); if (mutexsize < 0) { (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } i -= mutexsize; if (i < 0) { (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } mutex = fcb->recbufferpos; fcb->recbufferpos += mutexsize; mutexsize *= (int) sizeof (char); if (i == 4) { VTF3_STDBINARYPARSER_READI4 (scltoken); } else if (i == 0) scltoken = VTF3_SCLNONE; else { (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } VTF3_PARSER_LAST_VALID_TIME_MANAGEMENT; if (fcb->substitudeupfrom != 0 && leavestatetokenisupfrom != 0) { exchangetype = VTF3_EXCHANGETYPE_DOWNTO; (void) SubstitudeUpFrom (fcb, cpuid, &exchangetype, &enterstatetoken); exchangetype = VTF3_EXCHANGETYPE_UPFROM; (void) SubstitudeUpFrom (fcb, cpuid, &exchangetype, &leavestatetoken); if (exchangetype != VTF3_EXCHANGETYPE_UPFROM) leavestatetokenisupfrom = 0; } VTF3_PARSER_HANDLER_CALL_PROLOGUE (handler_t, handler); rc = (handler) (*(fcb->firsthandlerargs + handlerindex), time, cpuid, enterstatetoken, leavestatetoken, leavestatetokenisupfrom, durationtimesteps, mutexsize, mutex, scltoken); VTF3_PARSER_HANDLER_CALL_EPILOGUE; return; } static void StdBinaryParserOpenmpenter (fcb_t *fcb, int numcharsdata, int handlerindex) { int i, scltoken, rc; double time; unsigned int cpuid, constructtypetoken, nametoken; VTF3_DCL_OPENMPENTER (typedef, (*handler_t)); handler_t handler; i = numcharsdata - 16; if (i < 0) { (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } fcb->recbufferpos = fcb->recbuffer + 6; time = StdBinaryReadTs (fcb); if (i == 4 || i == 9) { i -= 4; VTF3_STDBINARYPARSER_READU4 (cpuid); } else cpuid = 0; VTF3_STDBINARYPARSER_READU4 (constructtypetoken); VTF3_STDBINARYPARSER_READU4 (nametoken); if (i == 5) { VTF3_STDBINARYPARSER_READI4 (scltoken); } else if (i == 0) scltoken = VTF3_SCLNONE; else { (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } VTF3_PARSER_LAST_VALID_TIME_MANAGEMENT; VTF3_PARSER_HANDLER_CALL_PROLOGUE (handler_t, handler); rc = (handler) (*(fcb->firsthandlerargs + handlerindex), time, cpuid, constructtypetoken, nametoken, scltoken); VTF3_PARSER_HANDLER_CALL_EPILOGUE; return; } static void StdBinaryParserOpenmpleave (fcb_t *fcb, int numcharsdata, int handlerindex) { int i, scltoken, rc; double time; unsigned int cpuid; VTF3_DCL_OPENMPLEAVE (typedef, (*handler_t)); handler_t handler; i = numcharsdata - 8; if (i < 0) { (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } fcb->recbufferpos = fcb->recbuffer + 6; time = StdBinaryReadTs (fcb); if (i == 4 || i == 9) { i -= 4; VTF3_STDBINARYPARSER_READU4 (cpuid); } else cpuid = 0; if (i == 5) { VTF3_STDBINARYPARSER_READI4 (scltoken); } else if (i == 0) scltoken = VTF3_SCLNONE; else { (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } VTF3_PARSER_LAST_VALID_TIME_MANAGEMENT; VTF3_PARSER_HANDLER_CALL_PROLOGUE (handler_t, handler); rc = (handler) (*(fcb->firsthandlerargs + handlerindex), time, cpuid, scltoken); VTF3_PARSER_HANDLER_CALL_EPILOGUE; return; } static void StdBinaryParserParreg (fcb_t *fcb, int numcharsdata, int handlerindex) { int i, sclstarttoken, sclendtoken, timearraydim, rc; double time, timeval; unsigned int cpugrpid, nametoken; VTF3_DCL_PARREG (typedef, (*handler_t)); handler_t handler; i = numcharsdata - 28; if (i < 0) { (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } fcb->recbufferpos = fcb->recbuffer + 6; time = StdBinaryReadTs (fcb); VTF3_STDBINARYPARSER_READU4 (cpugrpid); VTF3_STDBINARYPARSER_READU4 (nametoken); VTF3_STDBINARYPARSER_READI4 (sclstarttoken); VTF3_STDBINARYPARSER_READI4 (sclendtoken); VTF3_STDBINARYPARSER_READI4 (timearraydim); if (sclstarttoken == VTF3_SCLNONE || sclstarttoken == VTF3_SCLRESET || sclendtoken == VTF3_SCLNONE || sclendtoken == VTF3_SCLRESET || timearraydim < 1) { (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } if (i != timearraydim * 16) { (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } for (i = 0; i < 2 * timearraydim; i++) { timeval = StdBinaryReadTs (fcb); if (SignOfDouble (timeval) < 0) { (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } (void) StoreDoubleOntoU4Vector (fcb, 2 * i + 0, timeval); } VTF3_PARSER_LAST_VALID_TIME_MANAGEMENT; VTF3_PARSER_HANDLER_CALL_PROLOGUE (handler_t, handler); rc = (handler) (*(fcb->firsthandlerargs + handlerindex), time, cpugrpid, nametoken, sclstarttoken, sclendtoken, timearraydim, (double *) fcb->u4vector); VTF3_PARSER_HANDLER_CALL_EPILOGUE; return; } static void StdBinaryParserPattern (fcb_t *fcb, int numcharsdata, int handlerindex) { int i, havepatchindexarray, timesteparraydim, patorpatshptoken, *patchindexarray, patchindex, rc; double time, durationtimesteps, timestep; unsigned int cpuid; VTF3_DCL_PATTERN (typedef, (*handler_t)); handler_t handler; i = numcharsdata - 24; if (i < 0) { (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } if (i % 4 == 1) { i--; if (i % 12 != 0) { (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } havepatchindexarray = 1; timesteparraydim = i / 12; } else { if (i % 8 != 0) { (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } havepatchindexarray = 0; timesteparraydim = i / 8; } fcb->recbufferpos = fcb->recbuffer + 6; time = StdBinaryReadTs (fcb); VTF3_STDBINARYPARSER_READU4 (cpuid); VTF3_STDBINARYPARSER_READI4 (patorpatshptoken); durationtimesteps = StdBinaryReadTs (fcb); if (SignOfDouble (durationtimesteps) < 0) { (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } for (i = 0; i < timesteparraydim; i++) { timestep = StdBinaryReadTs (fcb); if (SignOfDouble (timestep) < 0) { (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } (void) StoreDoubleOntoU4Vector (fcb, 2 * i + 0, timestep); } patchindexarray = 0; if (havepatchindexarray != 0) { for (i = 0; i < timesteparraydim; i++) { VTF3_STDBINARYPARSER_READI4 (patchindex); VTF3_STORE_ONTO_INT_VECTOR (i, patchindex); } patchindexarray = fcb->intvector; } VTF3_PARSER_LAST_VALID_TIME_MANAGEMENT; VTF3_PARSER_HANDLER_CALL_PROLOGUE (handler_t, handler); rc = (handler) (*(fcb->firsthandlerargs + handlerindex), time, cpuid, patorpatshptoken, durationtimesteps, timesteparraydim, (double *) fcb->u4vector, patchindexarray); VTF3_PARSER_HANDLER_CALL_EPILOGUE; return; } static void StdBinaryParserRecvmsg (fcb_t *fcb, int numcharsdata, int handlerindex) { int i, communicator, msgtype, msglength, scltoken, rc; double time; unsigned int receiver, sender; VTF3_DCL_RECVMSG (typedef, (*handler_t)); handler_t handler; i = numcharsdata - 28; if (i < 0) { (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } fcb->recbufferpos = fcb->recbuffer + 6; time = StdBinaryReadTs (fcb); VTF3_STDBINARYPARSER_READU4 (receiver); VTF3_STDBINARYPARSER_READU4 (sender); VTF3_STDBINARYPARSER_READI4 (communicator); VTF3_STDBINARYPARSER_READI4 (msgtype); VTF3_STDBINARYPARSER_READI4 (msglength); if (i == 8) /* Old style `SCL #:#', ignore it. */ scltoken = VTF3_SCLNONE; else if (i == 4) { VTF3_STDBINARYPARSER_READI4 (scltoken); } else if (i == 0) scltoken = VTF3_SCLNONE; else { (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } VTF3_PARSER_LAST_VALID_TIME_MANAGEMENT; VTF3_PARSER_HANDLER_CALL_PROLOGUE (handler_t, handler); rc = (handler) (*(fcb->firsthandlerargs + handlerindex), time, receiver, sender, communicator, msgtype, msglength, scltoken); VTF3_PARSER_HANDLER_CALL_EPILOGUE; return; } static void StdBinaryParserSamp (fcb_t *fcb, int numcharsdata, int handlerindex) { int i, samplearraydim, sampletoken, samplevaluetype, rc; double time, f; unsigned int cpuorcpugrpid, uh, ul; VTF3_DCL_SAMP (typedef, (*handler_t)); handler_t handler; i = numcharsdata - 12; if (i < 0) { (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } if (i % 13 != 0) { (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } samplearraydim = i / 13; fcb->recbufferpos = fcb->recbuffer + 6; time = StdBinaryReadTs (fcb); VTF3_STDBINARYPARSER_READU4 (cpuorcpugrpid); for (i = 0; i < samplearraydim; i++) { VTF3_STDBINARYPARSER_READI4 (sampletoken); VTF3_STORE_ONTO_INT_VECTOR (i, sampletoken); VTF3_STDBINARYPARSER_READI1 (samplevaluetype); if (samplevaluetype != VTF3_VALUETYPE_FLOAT) samplevaluetype = VTF3_VALUETYPE_UINT; VTF3_STORE_ONTO_INT_VECTOR2 (i, samplevaluetype); if (samplevaluetype == VTF3_VALUETYPE_UINT) { VTF3_STDBINARYPARSER_READU4 (uh); VTF3_STDBINARYPARSER_READU4 (ul); if (vtffprtype == VTF3_CONST_FPNRT_IEEE754_DOUBLE_LITEND) { VTF3_STORE_UINT_ONTO_U4VECTOR (2 * i + 0, ul); VTF3_STORE_UINT_ONTO_U4VECTOR (2 * i + 1, uh); } else { VTF3_STORE_UINT_ONTO_U4VECTOR (2 * i + 0, uh); VTF3_STORE_UINT_ONTO_U4VECTOR (2 * i + 1, ul); } } else { f = StdBinaryReadF8 (fcb); (void) StoreDoubleOntoU4Vector (fcb, 2 * i + 0, f); } } VTF3_PARSER_LAST_VALID_TIME_MANAGEMENT; VTF3_PARSER_HANDLER_CALL_PROLOGUE (handler_t, handler); rc = (handler) (*(fcb->firsthandlerargs + handlerindex), time, cpuorcpugrpid, samplearraydim, fcb->intvector, fcb->intvector2, fcb->u4vector); VTF3_PARSER_HANDLER_CALL_EPILOGUE; return; } static void StdBinaryParserSendmsg (fcb_t *fcb, int numcharsdata, int handlerindex) { int i, communicator, msgtype, msglength, scltoken, rc; double time; unsigned int sender, receiver; VTF3_DCL_SENDMSG (typedef, (*handler_t)); handler_t handler; i = numcharsdata - 28; if (i < 0) { (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } fcb->recbufferpos = fcb->recbuffer + 6; time = StdBinaryReadTs (fcb); VTF3_STDBINARYPARSER_READU4 (sender); VTF3_STDBINARYPARSER_READU4 (receiver); VTF3_STDBINARYPARSER_READI4 (communicator); VTF3_STDBINARYPARSER_READI4 (msgtype); VTF3_STDBINARYPARSER_READI4 (msglength); if (i == 8) /* Old style `SCL #:#', ignore it. */ scltoken = VTF3_SCLNONE; else if (i == 4) { VTF3_STDBINARYPARSER_READI4 (scltoken); } else if (i == 0) scltoken = VTF3_SCLNONE; else { (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } VTF3_PARSER_LAST_VALID_TIME_MANAGEMENT; VTF3_PARSER_HANDLER_CALL_PROLOGUE (handler_t, handler); rc = (handler) (*(fcb->firsthandlerargs + handlerindex), time, sender, receiver, communicator, msgtype, msglength, scltoken); VTF3_PARSER_HANDLER_CALL_EPILOGUE; return; } static void StdBinaryParserSrcinfo_obsol (fcb_t *fcb, int numcharsdata, int handlerindex) { int i, activitytoken, statetoken, scllineposition, rc; double time; VTF3_DCL_SRCINFO_OBSOL (typedef, (*handler_t)); handler_t handler; i = numcharsdata - 20; if (i != 0) { (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } fcb->recbufferpos = fcb->recbuffer + 6; time = StdBinaryReadTs (fcb); VTF3_STDBINARYPARSER_READI4 (activitytoken); VTF3_STDBINARYPARSER_READI4 (statetoken); if (activitytoken == VTF3_NOACT || statetoken == VTF3_NOSTATE) { (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } VTF3_STDBINARYPARSER_READI4 (scllineposition); VTF3_PARSER_LAST_VALID_TIME_MANAGEMENT; VTF3_PARSER_HANDLER_CALL_PROLOGUE (handler_t, handler); rc = (handler) (*(fcb->firsthandlerargs + handlerindex), time, activitytoken, statetoken, scllineposition); VTF3_PARSER_HANDLER_CALL_EPILOGUE; return; } static void StdBinaryParserUnrecognizable (fcb_t *fcb, int numcharsdata, int handlerindex) { (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } static void StdBinaryParserUpfrom (fcb_t *fcb, int numcharsdata, int handlerindex) { int i, statetoken, scltoken, exchangetype, rc; double time; unsigned int cpuid; VTF3_DCL_UPFROM (typedef, (*upfromhandler_t)); upfromhandler_t upfromhandler; VTF3_DCL_UPTO (typedef, (*uptohandler_t)); uptohandler_t uptohandler; i = numcharsdata - 12; if (i < 0) { (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } fcb->recbufferpos = fcb->recbuffer + 6; time = StdBinaryReadTs (fcb); VTF3_STDBINARYPARSER_READI4 (statetoken); if (statetoken == VTF3_NOSTATE) { (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } if (i == 4 || i == 9) { i -= 4; VTF3_STDBINARYPARSER_READU4 (cpuid); } else cpuid = 0; if (i == 5) { VTF3_STDBINARYPARSER_READI4 (scltoken); } else if (i == 0) scltoken = VTF3_SCLNONE; else { (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } VTF3_PARSER_LAST_VALID_TIME_MANAGEMENT; exchangetype = VTF3_EXCHANGETYPE_UPFROM; if (fcb->substitudeupfrom != 0) (void) SubstitudeUpFrom (fcb, cpuid, &exchangetype, &statetoken); if (exchangetype == VTF3_EXCHANGETYPE_UPFROM) { VTF3_PARSER_HANDLER_CALL_PROLOGUE (upfromhandler_t, upfromhandler); rc = (upfromhandler) (*(fcb->firsthandlerargs + handlerindex), time, statetoken, cpuid, scltoken); VTF3_PARSER_HANDLER_CALL_EPILOGUE; return; } if (exchangetype == VTF3_EXCHANGETYPE_UPTO) { handlerindex = vtfuptohandlerindex; VTF3_PARSER_HANDLER_CALL_PROLOGUE (uptohandler_t, uptohandler); rc = (uptohandler) (*(fcb->firsthandlerargs + handlerindex), time, statetoken, cpuid, scltoken); VTF3_PARSER_HANDLER_CALL_EPILOGUE; return; } (void) fprintf (stderr, "VTF3: StdBinaryParserUpfrom(): " "Unrecoverable error\n"); (void) fflush (stderr); (void) exit (127); return; } static void StdBinaryParserUpto (fcb_t *fcb, int numcharsdata, int handlerindex) { int i, statetoken, scltoken, exchangetype, rc; double time; unsigned int cpuid; VTF3_DCL_UPTO (typedef, (*handler_t)); handler_t handler; i = numcharsdata - 12; if (i < 0) { (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } fcb->recbufferpos = fcb->recbuffer + 6; time = StdBinaryReadTs (fcb); VTF3_STDBINARYPARSER_READI4 (statetoken); if (i == 4 || i == 9) { i -= 4; VTF3_STDBINARYPARSER_READU4 (cpuid); } else cpuid = 0; if (i == 5) { VTF3_STDBINARYPARSER_READI4 (scltoken); } else if (i == 0) scltoken = VTF3_SCLNONE; else { (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } VTF3_PARSER_LAST_VALID_TIME_MANAGEMENT; if (fcb->substitudeupfrom != 0) { exchangetype = VTF3_EXCHANGETYPE_UPTO; (void) SubstitudeUpFrom (fcb, cpuid, &exchangetype, &statetoken); } VTF3_PARSER_HANDLER_CALL_PROLOGUE (handler_t, handler); rc = (handler) (*(fcb->firsthandlerargs + handlerindex), time, statetoken, cpuid, scltoken); VTF3_PARSER_HANDLER_CALL_EPILOGUE; return; } /*****************************************************************************/ static void FstAsciiParserClstrregval (fcb_t *fcb, int numcharsdata, int handlerindex, int havetime, double time) { int clstrtoken, clstrregarraydim, clstrregtoken, rc; unsigned int uh, ul, ux, uy; double f; VTF3_DCL_CLSTRREGVAL (typedef, (*handler_t)); handler_t handler; if (havetime == 0) goto Error; VTF3_FSTASCIIPARSER_READI4 (clstrtoken); clstrregarraydim = 0; while (VTF3_ASCIIPARSER_TEST_CHAR ('\r') == 0 && VTF3_ASCIIPARSER_TEST_CHAR ('\n') == 0) { if (VTF3_ASCIIPARSER_TEST_CHAR ('U') != 0) { fcb->recbufferpos++; VTF3_FSTASCIIPARSER_READI4 (clstrregtoken); VTF3_STORE_ONTO_INT_VECTOR (clstrregarraydim, clstrregtoken); VTF3_STORE_ONTO_INT_VECTOR2 (clstrregarraydim, VTF3_VALUETYPE_UINT); uh = 0; if (VTF3_ASCIIPARSER_TEST_CHAR ('H') != 0) { fcb->recbufferpos++; VTF3_FSTASCIIPARSER_READU4 (uh); } ul = 0; if (VTF3_ASCIIPARSER_TEST_CHAR ('L') != 0) { fcb->recbufferpos++; VTF3_FSTASCIIPARSER_READU4 (ul); } if (vtffprtype == VTF3_CONST_FPNRT_IEEE754_DOUBLE_LITEND) { VTF3_STORE_UINT_ONTO_U4VECTOR (2 * clstrregarraydim + 0, ul); VTF3_STORE_UINT_ONTO_U4VECTOR (2 * clstrregarraydim + 1, uh); } else { VTF3_STORE_UINT_ONTO_U4VECTOR (2 * clstrregarraydim + 0, uh); VTF3_STORE_UINT_ONTO_U4VECTOR (2 * clstrregarraydim + 1, ul); } clstrregarraydim++; continue; } if (VTF3_ASCIIPARSER_TEST_CHAR ('F') != 0) { fcb->recbufferpos++; VTF3_FSTASCIIPARSER_READI4 (clstrregtoken); VTF3_STORE_ONTO_INT_VECTOR (clstrregarraydim, clstrregtoken); VTF3_STORE_ONTO_INT_VECTOR2 (clstrregarraydim, VTF3_VALUETYPE_FLOAT); ux = 0; if (VTF3_ASCIIPARSER_TEST_CHAR ('X') != 0) { fcb->recbufferpos++; VTF3_FSTASCIIPARSER_READU4 (ux); } uy = 0; if (VTF3_ASCIIPARSER_TEST_CHAR ('Y') != 0) { fcb->recbufferpos++; VTF3_FSTASCIIPARSER_READU4 (uy); } f = GetDoubleFromXy (ux, uy); (void) StoreDoubleOntoU4Vector (fcb, 2 * clstrregarraydim + 0, f); clstrregarraydim++; continue; } goto Error; } if (VTF3_ASCIIPARSER_TEST_CHAR ('\r') != 0) fcb->recbufferpos++; VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('\n'); VTF3_PARSER_LAST_VALID_TIME_MANAGEMENT; VTF3_PARSER_HANDLER_CALL_PROLOGUE (handler_t, handler); rc = (handler) (*(fcb->firsthandlerargs + handlerindex), time, clstrtoken, clstrregarraydim, fcb->intvector, fcb->intvector2, fcb->u4vector); VTF3_PARSER_HANDLER_CALL_EPILOGUE; return; /* LABEL */ Error: (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } static void FstAsciiParserComment (fcb_t *fcb, int numcharsdata, int handlerindex, int havetime, double time) { static unsigned int first = 1; static unsigned char uchar80h = (unsigned char) 0x80; char *p; const char *comment; int rc; VTF3_DCL_COMMENT (typedef, (*handler_t)); handler_t handler; if (first != 0) { first = 0; (void) PassI (numcharsdata); } if (havetime == 0) return; p = fcb->recbufferpos; if (vtfspace[VTF3_CHAR2INDEX (*p)] != 0) p++; comment = p; while (*p != '\n' && p < comment + (unsigned int) 0x7fff) { if (*p == '\0') *p = (char) * (char *) (unsigned char *) &uchar80h; p++; } if (p != comment && *(p - 0) == '\n' && *(p - 1) == '\r') p--; *p = '\0'; VTF3_PARSER_LAST_VALID_TIME_MANAGEMENT; VTF3_PARSER_HANDLER_CALL_PROLOGUE (handler_t, handler); rc = (handler) (*(fcb->firsthandlerargs + handlerindex), time, comment); VTF3_PARSER_HANDLER_CALL_EPILOGUE; return; } static void FstAsciiParserCpuregval (fcb_t *fcb, int numcharsdata, int handlerindex, int havetime, double time) { unsigned int cpuid, uh, ul, ux, uy; int cpuregarraydim, cpuregtoken, rc; double f; VTF3_DCL_CPUREGVAL (typedef, (*handler_t)); handler_t handler; if (havetime == 0) goto Error; VTF3_FSTASCIIPARSER_READU4 (cpuid); cpuregarraydim = 0; while (VTF3_ASCIIPARSER_TEST_CHAR ('\r') == 0 && VTF3_ASCIIPARSER_TEST_CHAR ('\n') == 0) { if (VTF3_ASCIIPARSER_TEST_CHAR ('U') != 0) { fcb->recbufferpos++; VTF3_FSTASCIIPARSER_READI4 (cpuregtoken); VTF3_STORE_ONTO_INT_VECTOR (cpuregarraydim, cpuregtoken); VTF3_STORE_ONTO_INT_VECTOR2 (cpuregarraydim, VTF3_VALUETYPE_UINT); uh = 0; if (VTF3_ASCIIPARSER_TEST_CHAR ('H') != 0) { fcb->recbufferpos++; VTF3_FSTASCIIPARSER_READU4 (uh); } ul = 0; if (VTF3_ASCIIPARSER_TEST_CHAR ('L') != 0) { fcb->recbufferpos++; VTF3_FSTASCIIPARSER_READU4 (ul); } if (vtffprtype == VTF3_CONST_FPNRT_IEEE754_DOUBLE_LITEND) { VTF3_STORE_UINT_ONTO_U4VECTOR (2 * cpuregarraydim + 0, ul); VTF3_STORE_UINT_ONTO_U4VECTOR (2 * cpuregarraydim + 1, uh); } else { VTF3_STORE_UINT_ONTO_U4VECTOR (2 * cpuregarraydim + 0, uh); VTF3_STORE_UINT_ONTO_U4VECTOR (2 * cpuregarraydim + 1, ul); } cpuregarraydim++; continue; } if (VTF3_ASCIIPARSER_TEST_CHAR ('F') != 0) { fcb->recbufferpos++; VTF3_FSTASCIIPARSER_READI4 (cpuregtoken); VTF3_STORE_ONTO_INT_VECTOR (cpuregarraydim, cpuregtoken); VTF3_STORE_ONTO_INT_VECTOR2 (cpuregarraydim, VTF3_VALUETYPE_FLOAT); ux = 0; if (VTF3_ASCIIPARSER_TEST_CHAR ('X') != 0) { fcb->recbufferpos++; VTF3_FSTASCIIPARSER_READU4 (ux); } uy = 0; if (VTF3_ASCIIPARSER_TEST_CHAR ('Y') != 0) { fcb->recbufferpos++; VTF3_FSTASCIIPARSER_READU4 (uy); } f = GetDoubleFromXy (ux, uy); (void) StoreDoubleOntoU4Vector (fcb, 2 * cpuregarraydim + 0, f); cpuregarraydim++; continue; } goto Error; } if (VTF3_ASCIIPARSER_TEST_CHAR ('\r') != 0) fcb->recbufferpos++; VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('\n'); VTF3_PARSER_LAST_VALID_TIME_MANAGEMENT; VTF3_PARSER_HANDLER_CALL_PROLOGUE (handler_t, handler); rc = (handler) (*(fcb->firsthandlerargs + handlerindex), time, cpuid, cpuregarraydim, fcb->intvector, fcb->intvector2, fcb->u4vector); VTF3_PARSER_HANDLER_CALL_EPILOGUE; return; /* LABEL */ Error: (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } static void FstAsciiParserDefact (fcb_t *fcb, int numcharsdata, int handlerindex, int havetime, double time) { (void) StdAsciiParserDefact (fcb, numcharsdata, handlerindex, havetime, time); return; } static void FstAsciiParserDefact_obsol (fcb_t *fcb, int numcharsdata, int handlerindex, int havetime, double time) { (void) StdAsciiParserDefact_obsol (fcb, numcharsdata, handlerindex, havetime, time); return; } static void FstAsciiParserDefclkperiod (fcb_t *fcb, int numcharsdata, int handlerindex, int havetime, double time) { (void) StdAsciiParserDefclkperiod (fcb, numcharsdata, handlerindex, havetime, time); return; } static void FstAsciiParserDefclstr (fcb_t *fcb, int numcharsdata, int handlerindex, int havetime, double time) { (void) StdAsciiParserDefclstr (fcb, numcharsdata, handlerindex, havetime, time); return; } static void FstAsciiParserDefclstrreg (fcb_t *fcb, int numcharsdata, int handlerindex, int havetime, double time) { (void) StdAsciiParserDefclstrreg (fcb, numcharsdata, handlerindex, havetime, time); return; } static void FstAsciiParserDefclstrregclass (fcb_t *fcb, int numcharsdata, int handlerindex, int havetime, double time) { (void) StdAsciiParserDefclstrregclass (fcb, numcharsdata, handlerindex, havetime, time); return; } static void FstAsciiParserDefcommunicator (fcb_t *fcb, int numcharsdata, int handlerindex, int havetime, double time) { (void) StdAsciiParserDefcommunicator (fcb, numcharsdata, handlerindex, havetime, time); return; } static void FstAsciiParserDefcpugrp (fcb_t *fcb, int numcharsdata, int handlerindex, int havetime, double time) { (void) StdAsciiParserDefcpugrp (fcb, numcharsdata, handlerindex, havetime, time); return; } static void FstAsciiParserDefcpuname (fcb_t *fcb, int numcharsdata, int handlerindex, int havetime, double time) { (void) StdAsciiParserDefcpuname (fcb, numcharsdata, handlerindex, havetime, time); return; } static void FstAsciiParserDefcpureg (fcb_t *fcb, int numcharsdata, int handlerindex, int havetime, double time) { (void) StdAsciiParserDefcpureg (fcb, numcharsdata, handlerindex, havetime, time); return; } static void FstAsciiParserDefcpuregclass (fcb_t *fcb, int numcharsdata, int handlerindex, int havetime, double time) { (void) StdAsciiParserDefcpuregclass (fcb, numcharsdata, handlerindex, havetime, time); return; } static void FstAsciiParserDefcreator (fcb_t *fcb, int numcharsdata, int handlerindex, int havetime, double time) { (void) StdAsciiParserDefcreator (fcb, numcharsdata, handlerindex, havetime, time); return; } static void FstAsciiParserDefdatastruc (fcb_t *fcb, int numcharsdata, int handlerindex, int havetime, double time) { (void) StdAsciiParserDefdatastruc (fcb, numcharsdata, handlerindex, havetime, time); return; } static void FstAsciiParserDefglobalop (fcb_t *fcb, int numcharsdata, int handlerindex, int havetime, double time) { (void) StdAsciiParserDefglobalop (fcb, numcharsdata, handlerindex, havetime, time); return; } static void FstAsciiParserDefhist (fcb_t *fcb, int numcharsdata, int handlerindex, int havetime, double time) { (void) StdAsciiParserDefhist (fcb, numcharsdata, handlerindex, havetime, time); return; } static void FstAsciiParserDefhistgrp (fcb_t *fcb, int numcharsdata, int handlerindex, int havetime, double time) { (void) StdAsciiParserDefhistgrp (fcb, numcharsdata, handlerindex, havetime, time); return; } static void FstAsciiParserDefiofile (fcb_t *fcb, int numcharsdata, int handlerindex, int havetime, double time) { (void) StdAsciiParserDefiofile (fcb, numcharsdata, handlerindex, havetime, time); return; } static void FstAsciiParserDefkparreg (fcb_t *fcb, int numcharsdata, int handlerindex, int havetime, double time) { (void) StdAsciiParserDefkparreg (fcb, numcharsdata, handlerindex, havetime, time); return; } static void FstAsciiParserDefmsgname (fcb_t *fcb, int numcharsdata, int handlerindex, int havetime, double time) { (void) StdAsciiParserDefmsgname (fcb, numcharsdata, handlerindex, havetime, time); return; } static void FstAsciiParserDefopenmpname (fcb_t *fcb, int numcharsdata, int handlerindex, int havetime, double time) { (void) StdAsciiParserDefopenmpname (fcb, numcharsdata, handlerindex, havetime, time); return; } static void FstAsciiParserDefopenmptype (fcb_t *fcb, int numcharsdata, int handlerindex, int havetime, double time) { (void) StdAsciiParserDefopenmptype (fcb, numcharsdata, handlerindex, havetime, time); return; } static void FstAsciiParserDefpattern (fcb_t *fcb, int numcharsdata, int handlerindex, int havetime, double time) { (void) StdAsciiParserDefpattern (fcb, numcharsdata, handlerindex, havetime, time); return; } static void FstAsciiParserDefpatternshape (fcb_t *fcb, int numcharsdata, int handlerindex, int havetime, double time) { (void) StdAsciiParserDefpatternshape (fcb, numcharsdata, handlerindex, havetime, time); return; } static void FstAsciiParserDefredfunc_obsol (fcb_t *fcb, int numcharsdata, int handlerindex, int havetime, double time) { (void) StdAsciiParserDefredfunc_obsol (fcb, numcharsdata, handlerindex, havetime, time); return; } static void FstAsciiParserDefsamp (fcb_t *fcb, int numcharsdata, int handlerindex, int havetime, double time) { (void) StdAsciiParserDefsamp (fcb, numcharsdata, handlerindex, havetime, time); return; } static void FstAsciiParserDefsampclass (fcb_t *fcb, int numcharsdata, int handlerindex, int havetime, double time) { (void) StdAsciiParserDefsampclass (fcb, numcharsdata, handlerindex, havetime, time); return; } static void FstAsciiParserDefscl (fcb_t *fcb, int numcharsdata, int handlerindex, int havetime, double time) { (void) StdAsciiParserDefscl (fcb, numcharsdata, handlerindex, havetime, time); return; } static void FstAsciiParserDefsclfile (fcb_t *fcb, int numcharsdata, int handlerindex, int havetime, double time) { (void) StdAsciiParserDefsclfile (fcb, numcharsdata, handlerindex, havetime, time); return; } static void FstAsciiParserDefstate (fcb_t *fcb, int numcharsdata, int handlerindex, int havetime, double time) { (void) StdAsciiParserDefstate (fcb, numcharsdata, handlerindex, havetime, time); return; } static void FstAsciiParserDefstate_obsol (fcb_t *fcb, int numcharsdata, int handlerindex, int havetime, double time) { (void) StdAsciiParserDefstate_obsol (fcb, numcharsdata, handlerindex, havetime, time); return; } static void FstAsciiParserDefsyscpunames (fcb_t *fcb, int numcharsdata, int handlerindex, int havetime, double time) { (void) StdAsciiParserDefsyscpunames (fcb, numcharsdata, handlerindex, havetime, time); return; } static void FstAsciiParserDefsyscpunums (fcb_t *fcb, int numcharsdata, int handlerindex, int havetime, double time) { (void) StdAsciiParserDefsyscpunums (fcb, numcharsdata, handlerindex, havetime, time); return; } static void FstAsciiParserDefthreadnums (fcb_t *fcb, int numcharsdata, int handlerindex, int havetime, double time) { (void) StdAsciiParserDefthreadnums (fcb, numcharsdata, handlerindex, havetime, time); return; } static void FstAsciiParserDeftimeoffset (fcb_t *fcb, int numcharsdata, int handlerindex, int havetime, double time) { (void) StdAsciiParserDeftimeoffset (fcb, numcharsdata, handlerindex, havetime, time); return; } static void FstAsciiParserDefunmerged (fcb_t *fcb, int numcharsdata, int handlerindex, int havetime, double time) { (void) StdAsciiParserDefunmerged (fcb, numcharsdata, handlerindex, havetime, time); return; } static void FstAsciiParserDefversion (fcb_t *fcb, int numcharsdata, int handlerindex, int havetime, double time) { (void) StdAsciiParserDefversion (fcb, numcharsdata, handlerindex, havetime, time); return; } static void FstAsciiParserDownto (fcb_t *fcb, int numcharsdata, int handlerindex, int havetime, double time) { int statetoken, scltoken, exchangetype, rc; unsigned int cpuid; VTF3_DCL_DOWNTO (typedef, (*handler_t)); handler_t handler; if (havetime == 0) goto Error; VTF3_FSTASCIIPARSER_READI4 (statetoken); if (statetoken == VTF3_NOSTATE) goto Error; cpuid = 0; if (VTF3_ASCIIPARSER_TEST_CHAR ('P') != 0) { fcb->recbufferpos++; VTF3_FSTASCIIPARSER_READU4 (cpuid); } scltoken = VTF3_SCLNONE; if (VTF3_ASCIIPARSER_TEST_CHAR ('L') != 0) { fcb->recbufferpos++; VTF3_FSTASCIIPARSER_READI4 (scltoken); } if (VTF3_ASCIIPARSER_TEST_CHAR ('\r') != 0) fcb->recbufferpos++; VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('\n'); VTF3_PARSER_LAST_VALID_TIME_MANAGEMENT; if (fcb->substitudeupfrom != 0) { exchangetype = VTF3_EXCHANGETYPE_DOWNTO; (void) SubstitudeUpFrom (fcb, cpuid, &exchangetype, &statetoken); } VTF3_PARSER_HANDLER_CALL_PROLOGUE (handler_t, handler); rc = (handler) (*(fcb->firsthandlerargs + handlerindex), time, statetoken, cpuid, scltoken); VTF3_PARSER_HANDLER_CALL_EPILOGUE; return; /* LABEL */ Error: (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } static void FstAsciiParserExchange (fcb_t *fcb, int numcharsdata, int handlerindex, int havetime, double time) { static unsigned int first = 1; static const char *exchangetypename [] = VTF3_EXCHANGETYPENAME_INIT; int exchangetype, statetoken, job, scltoken, rc; unsigned int cpuid; VTF3_DCL_EXCHANGE (typedef, (*handler_t)); handler_t handler; if (first != 0) { first = 0; (void) PassP (exchangetypename); } if (havetime == 0) goto Error; VTF3_FSTASCIIPARSER_READI4 (exchangetype); if (exchangetype >= (int) (sizeof (exchangetypename) / sizeof (exchangetypename[0])) || exchangetype < 0 || exchangetype == VTF3_EXCHANGETYPE_NOEXCH) goto Error; statetoken = VTF3_NOSTATE; if (VTF3_ASCIIPARSER_TEST_CHAR ('S') != 0) { fcb->recbufferpos++; VTF3_FSTASCIIPARSER_READI4 (statetoken); } if (statetoken == VTF3_NOSTATE) { if (exchangetype == VTF3_EXCHANGETYPE_DOWNTO) goto Error; if (exchangetype == VTF3_EXCHANGETYPE_UPFROM) goto Error; } cpuid = 0; if (VTF3_ASCIIPARSER_TEST_CHAR ('P') != 0) { fcb->recbufferpos++; VTF3_FSTASCIIPARSER_READU4 (cpuid); } job = VTF3_NOJOB; if (VTF3_ASCIIPARSER_TEST_CHAR ('J') != 0) { fcb->recbufferpos++; VTF3_FSTASCIIPARSER_READI4 (job); } scltoken = VTF3_SCLNONE; if (VTF3_ASCIIPARSER_TEST_CHAR ('L') != 0) { fcb->recbufferpos++; VTF3_FSTASCIIPARSER_READI4 (scltoken); } if (VTF3_ASCIIPARSER_TEST_CHAR ('\r') != 0) fcb->recbufferpos++; VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('\n'); VTF3_PARSER_LAST_VALID_TIME_MANAGEMENT; if (fcb->substitudeupfrom != 0) (void) SubstitudeUpFrom (fcb, cpuid, &exchangetype, &statetoken); VTF3_PARSER_HANDLER_CALL_PROLOGUE (handler_t, handler); rc = (handler) (*(fcb->firsthandlerargs + handlerindex), time, cpuid, exchangetype, statetoken, job, scltoken); VTF3_PARSER_HANDLER_CALL_EPILOGUE; return; /* LABEL */ Error: (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } static void FstAsciiParserExchange_obsol (fcb_t *fcb, int numcharsdata, int handlerindex, int havetime, double time) { (void) StdAsciiParserExchange_obsol (fcb, numcharsdata, handlerindex, havetime, time); return; } static void FstAsciiParserFileiobegin (fcb_t *fcb, int numcharsdata, int handlerindex, int havetime, double time) { int iofiletoken, fileiotype, bytescopied, scltoken, rc; unsigned int cpuid; VTF3_DCL_FILEIOBEGIN (typedef, (*handler_t)); handler_t handler; if (havetime == 0) goto Error; VTF3_FSTASCIIPARSER_READI4 (iofiletoken); cpuid = 0; if (VTF3_ASCIIPARSER_TEST_CHAR ('P') != 0) { fcb->recbufferpos++; VTF3_FSTASCIIPARSER_READU4 (cpuid); } if (VTF3_ASCIIPARSER_TEST_CHAR ('R') != 0) { fcb->recbufferpos++; fileiotype = VTF3_FILEIOTYPE_READ; } else if (VTF3_ASCIIPARSER_TEST_CHAR ('W') != 0) { fcb->recbufferpos++; fileiotype = VTF3_FILEIOTYPE_WRITE; } else goto Error; VTF3_FSTASCIIPARSER_READI4 (bytescopied); scltoken = VTF3_SCLNONE; if (VTF3_ASCIIPARSER_TEST_CHAR ('L') != 0) { fcb->recbufferpos++; VTF3_FSTASCIIPARSER_READI4 (scltoken); } if (VTF3_ASCIIPARSER_TEST_CHAR ('\r') != 0) fcb->recbufferpos++; VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('\n'); VTF3_PARSER_LAST_VALID_TIME_MANAGEMENT; VTF3_PARSER_HANDLER_CALL_PROLOGUE (handler_t, handler); rc = (handler) (*(fcb->firsthandlerargs + handlerindex), time, cpuid, fileiotype, iofiletoken, bytescopied, scltoken); VTF3_PARSER_HANDLER_CALL_EPILOGUE; return; /* LABEL */ Error: (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } static void FstAsciiParserFileioend (fcb_t *fcb, int numcharsdata, int handlerindex, int havetime, double time) { int iofiletoken, fileiotype, bytescopied, scltoken, rc; unsigned int cpuid; VTF3_DCL_FILEIOEND (typedef, (*handler_t)); handler_t handler; if (havetime == 0) goto Error; VTF3_FSTASCIIPARSER_READI4 (iofiletoken); cpuid = 0; if (VTF3_ASCIIPARSER_TEST_CHAR ('P') != 0) { fcb->recbufferpos++; VTF3_FSTASCIIPARSER_READU4 (cpuid); } if (VTF3_ASCIIPARSER_TEST_CHAR ('R') != 0) { fcb->recbufferpos++; fileiotype = VTF3_FILEIOTYPE_READ; } else if (VTF3_ASCIIPARSER_TEST_CHAR ('W') != 0) { fcb->recbufferpos++; fileiotype = VTF3_FILEIOTYPE_WRITE; } else goto Error; VTF3_FSTASCIIPARSER_READI4 (bytescopied); scltoken = VTF3_SCLNONE; if (VTF3_ASCIIPARSER_TEST_CHAR ('L') != 0) { fcb->recbufferpos++; VTF3_FSTASCIIPARSER_READI4 (scltoken); } if (VTF3_ASCIIPARSER_TEST_CHAR ('\r') != 0) fcb->recbufferpos++; VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('\n'); VTF3_PARSER_LAST_VALID_TIME_MANAGEMENT; VTF3_PARSER_HANDLER_CALL_PROLOGUE (handler_t, handler); rc = (handler) (*(fcb->firsthandlerargs + handlerindex), time, cpuid, fileiotype, iofiletoken, bytescopied, scltoken); VTF3_PARSER_HANDLER_CALL_EPILOGUE; return; /* LABEL */ Error: (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } static void FstAsciiParserGlobalop (fcb_t *fcb, int numcharsdata, int handlerindex, int havetime, double time) { int globaloptoken, communicator, bytesreceived, bytessent, scltoken, rc; unsigned int cpuid, rootcpuid, ux, uy; double durationtimesteps; VTF3_DCL_GLOBALOP (typedef, (*handler_t)); handler_t handler; if (havetime == 0) goto Error; VTF3_FSTASCIIPARSER_READI4 (globaloptoken); communicator = VTF3_NOCOMMUNICATOR; if (VTF3_ASCIIPARSER_TEST_CHAR ('C') != 0) { fcb->recbufferpos++; VTF3_FSTASCIIPARSER_READI4 (communicator); } cpuid = 0; if (VTF3_ASCIIPARSER_TEST_CHAR ('P') != 0) { fcb->recbufferpos++; VTF3_FSTASCIIPARSER_READU4 (cpuid); } rootcpuid = 0; if (VTF3_ASCIIPARSER_TEST_CHAR ('R') != 0) { fcb->recbufferpos++; VTF3_FSTASCIIPARSER_READU4 (rootcpuid); } bytesreceived = 0; if (VTF3_ASCIIPARSER_TEST_CHAR ('I') != 0) { fcb->recbufferpos++; VTF3_FSTASCIIPARSER_READI4 (bytesreceived); } bytessent = 0; if (VTF3_ASCIIPARSER_TEST_CHAR ('O') != 0) { fcb->recbufferpos++; VTF3_FSTASCIIPARSER_READI4 (bytessent); } durationtimesteps = -1.0e+0; if (VTF3_ASCIIPARSER_TEST_CHAR ('D') != 0) { fcb->recbufferpos++; /* VTF3_FSTASCIIPARSER_READTS() is able to pick up negative values. */ VTF3_FSTASCIIPARSER_READTS (durationtimesteps); if (SignOfDouble (durationtimesteps) < 0) durationtimesteps = -1.0e+0; } else if (VTF3_ASCIIPARSER_TEST_CHAR ('X') != 0 || VTF3_ASCIIPARSER_TEST_CHAR ('Y') != 0) { /* Older version of this record. */ ux = 0; if (VTF3_ASCIIPARSER_TEST_CHAR ('X') != 0) { fcb->recbufferpos++; VTF3_FSTASCIIPARSER_READU4 (ux); } uy = 0; if (VTF3_ASCIIPARSER_TEST_CHAR ('Y') != 0) { fcb->recbufferpos++; VTF3_FSTASCIIPARSER_READU4 (uy); } durationtimesteps = GetDoubleFromXy (ux, uy); if (SignOfDouble (durationtimesteps) < 0) durationtimesteps = -1.0e+0; } scltoken = VTF3_SCLNONE; if (VTF3_ASCIIPARSER_TEST_CHAR ('L') != 0) { fcb->recbufferpos++; VTF3_FSTASCIIPARSER_READI4 (scltoken); } if (VTF3_ASCIIPARSER_TEST_CHAR ('\r') != 0) fcb->recbufferpos++; VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('\n'); VTF3_PARSER_LAST_VALID_TIME_MANAGEMENT; VTF3_PARSER_HANDLER_CALL_PROLOGUE (handler_t, handler); rc = (handler) (*(fcb->firsthandlerargs + handlerindex), time, globaloptoken, cpuid, communicator, rootcpuid, bytessent, bytesreceived, durationtimesteps, scltoken); VTF3_PARSER_HANDLER_CALL_EPILOGUE; return; /* LABEL */ Error: (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } static void FstAsciiParserHist (fcb_t *fcb, int numcharsdata, int handlerindex, int havetime, double time) { (void) StdAsciiParserHist (fcb, numcharsdata, handlerindex, havetime, time); return; } static void FstAsciiParserKparregbarsum (fcb_t *fcb, int numcharsdata, int handlerindex, int havetime, double time) { (void) StdAsciiParserKparregbarsum (fcb, numcharsdata, handlerindex, havetime, time); return; } static void FstAsciiParserKparregbegin (fcb_t *fcb, int numcharsdata, int handlerindex, int havetime, double time) { (void) StdAsciiParserKparregbegin (fcb, numcharsdata, handlerindex, havetime, time); return; } static void FstAsciiParserKparregend (fcb_t *fcb, int numcharsdata, int handlerindex, int havetime, double time) { (void) StdAsciiParserKparregend (fcb, numcharsdata, handlerindex, havetime, time); return; } static void FstAsciiParserMutexacquire (fcb_t *fcb, int numcharsdata, int handlerindex, int havetime, double time) { (void) StdAsciiParserMutexacquire (fcb, numcharsdata, handlerindex, havetime, time); return; } static void FstAsciiParserMutexrelease (fcb_t *fcb, int numcharsdata, int handlerindex, int havetime, double time) { (void) StdAsciiParserMutexrelease (fcb, numcharsdata, handlerindex, havetime, time); return; } static void FstAsciiParserOpenmpenter (fcb_t *fcb, int numcharsdata, int handlerindex, int havetime, double time) { (void) StdAsciiParserOpenmpenter (fcb, numcharsdata, handlerindex, havetime, time); return; } static void FstAsciiParserOpenmpleave (fcb_t *fcb, int numcharsdata, int handlerindex, int havetime, double time) { (void) StdAsciiParserOpenmpleave (fcb, numcharsdata, handlerindex, havetime, time); return; } static void FstAsciiParserParreg (fcb_t *fcb, int numcharsdata, int handlerindex, int havetime, double time) { (void) StdAsciiParserParreg (fcb, numcharsdata, handlerindex, havetime, time); return; } static void FstAsciiParserPattern (fcb_t *fcb, int numcharsdata, int handlerindex, int havetime, double time) { (void) StdAsciiParserPattern (fcb, numcharsdata, handlerindex, havetime, time); return; } static void FstAsciiParserRecvmsg (fcb_t *fcb, int numcharsdata, int handlerindex, int havetime, double time) { int msglength, communicator, msgtype, scltoken, rc; unsigned int receiver, sender; VTF3_DCL_RECVMSG (typedef, (*handler_t)); handler_t handler; if (havetime == 0) goto Error; VTF3_FSTASCIIPARSER_READI4 (msglength); communicator = VTF3_NOCOMMUNICATOR; if (VTF3_ASCIIPARSER_TEST_CHAR ('C') != 0) { fcb->recbufferpos++; VTF3_FSTASCIIPARSER_READI4 (communicator); } msgtype = 0; if (VTF3_ASCIIPARSER_TEST_CHAR ('T') != 0) { fcb->recbufferpos++; VTF3_FSTASCIIPARSER_READI4 (msgtype); } receiver = 0; if (VTF3_ASCIIPARSER_TEST_CHAR ('R') != 0) { fcb->recbufferpos++; VTF3_FSTASCIIPARSER_READU4 (receiver); } sender = 0; if (VTF3_ASCIIPARSER_TEST_CHAR ('S') != 0) { fcb->recbufferpos++; VTF3_FSTASCIIPARSER_READU4 (sender); } scltoken = VTF3_SCLNONE; if (VTF3_ASCIIPARSER_TEST_CHAR ('L') != 0) { fcb->recbufferpos++; VTF3_FSTASCIIPARSER_READI4 (scltoken); } if (VTF3_ASCIIPARSER_TEST_CHAR ('\r') != 0) fcb->recbufferpos++; VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('\n'); VTF3_PARSER_LAST_VALID_TIME_MANAGEMENT; VTF3_PARSER_HANDLER_CALL_PROLOGUE (handler_t, handler); rc = (handler) (*(fcb->firsthandlerargs + handlerindex), time, receiver, sender, communicator, msgtype, msglength, scltoken); VTF3_PARSER_HANDLER_CALL_EPILOGUE; return; /* LABEL */ Error: (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } static void FstAsciiParserSamp (fcb_t *fcb, int numcharsdata, int handlerindex, int havetime, double time) { unsigned int cpuorcpugrpid, uh, ul, ux, uy; int samplearraydim, sampletoken, rc; double f; VTF3_DCL_SAMP (typedef, (*handler_t)); handler_t handler; if (havetime == 0) goto Error; VTF3_FSTASCIIPARSER_READU4 (cpuorcpugrpid); samplearraydim = 0; while (VTF3_ASCIIPARSER_TEST_CHAR ('\r') == 0 && VTF3_ASCIIPARSER_TEST_CHAR ('\n') == 0) { if (VTF3_ASCIIPARSER_TEST_CHAR ('U') != 0) { fcb->recbufferpos++; VTF3_FSTASCIIPARSER_READI4 (sampletoken); VTF3_STORE_ONTO_INT_VECTOR (samplearraydim, sampletoken); VTF3_STORE_ONTO_INT_VECTOR2 (samplearraydim, VTF3_VALUETYPE_UINT); uh = 0; if (VTF3_ASCIIPARSER_TEST_CHAR ('H') != 0) { fcb->recbufferpos++; VTF3_FSTASCIIPARSER_READU4 (uh); } ul = 0; if (VTF3_ASCIIPARSER_TEST_CHAR ('L') != 0) { fcb->recbufferpos++; VTF3_FSTASCIIPARSER_READU4 (ul); } if (vtffprtype == VTF3_CONST_FPNRT_IEEE754_DOUBLE_LITEND) { VTF3_STORE_UINT_ONTO_U4VECTOR (2 * samplearraydim + 0, ul); VTF3_STORE_UINT_ONTO_U4VECTOR (2 * samplearraydim + 1, uh); } else { VTF3_STORE_UINT_ONTO_U4VECTOR (2 * samplearraydim + 0, uh); VTF3_STORE_UINT_ONTO_U4VECTOR (2 * samplearraydim + 1, ul); } samplearraydim++; continue; } if (VTF3_ASCIIPARSER_TEST_CHAR ('F') != 0) { fcb->recbufferpos++; VTF3_FSTASCIIPARSER_READI4 (sampletoken); VTF3_STORE_ONTO_INT_VECTOR (samplearraydim, sampletoken); VTF3_STORE_ONTO_INT_VECTOR2 (samplearraydim, VTF3_VALUETYPE_FLOAT); ux = 0; if (VTF3_ASCIIPARSER_TEST_CHAR ('X') != 0) { fcb->recbufferpos++; VTF3_FSTASCIIPARSER_READU4 (ux); } uy = 0; if (VTF3_ASCIIPARSER_TEST_CHAR ('Y') != 0) { fcb->recbufferpos++; VTF3_FSTASCIIPARSER_READU4 (uy); } f = GetDoubleFromXy (ux, uy); (void) StoreDoubleOntoU4Vector (fcb, 2 * samplearraydim + 0, f); samplearraydim++; continue; } goto Error; } if (VTF3_ASCIIPARSER_TEST_CHAR ('\r') != 0) fcb->recbufferpos++; VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('\n'); VTF3_PARSER_LAST_VALID_TIME_MANAGEMENT; VTF3_PARSER_HANDLER_CALL_PROLOGUE (handler_t, handler); rc = (handler) (*(fcb->firsthandlerargs + handlerindex), time, cpuorcpugrpid, samplearraydim, fcb->intvector, fcb->intvector2, fcb->u4vector); VTF3_PARSER_HANDLER_CALL_EPILOGUE; return; /* LABEL */ Error: (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } static void FstAsciiParserSendmsg (fcb_t *fcb, int numcharsdata, int handlerindex, int havetime, double time) { int msglength, communicator, msgtype, scltoken, rc; unsigned int sender, receiver; VTF3_DCL_SENDMSG (typedef, (*handler_t)); handler_t handler; if (havetime == 0) goto Error; VTF3_FSTASCIIPARSER_READI4 (msglength); communicator = VTF3_NOCOMMUNICATOR; if (VTF3_ASCIIPARSER_TEST_CHAR ('C') != 0) { fcb->recbufferpos++; VTF3_FSTASCIIPARSER_READI4 (communicator); } msgtype = 0; if (VTF3_ASCIIPARSER_TEST_CHAR ('T') != 0) { fcb->recbufferpos++; VTF3_FSTASCIIPARSER_READI4 (msgtype); } sender = 0; if (VTF3_ASCIIPARSER_TEST_CHAR ('S') != 0) { fcb->recbufferpos++; VTF3_FSTASCIIPARSER_READU4 (sender); } receiver = 0; if (VTF3_ASCIIPARSER_TEST_CHAR ('R') != 0) { fcb->recbufferpos++; VTF3_FSTASCIIPARSER_READU4 (receiver); } scltoken = VTF3_SCLNONE; if (VTF3_ASCIIPARSER_TEST_CHAR ('L') != 0) { fcb->recbufferpos++; VTF3_FSTASCIIPARSER_READI4 (scltoken); } if (VTF3_ASCIIPARSER_TEST_CHAR ('\r') != 0) fcb->recbufferpos++; VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('\n'); VTF3_PARSER_LAST_VALID_TIME_MANAGEMENT; VTF3_PARSER_HANDLER_CALL_PROLOGUE (handler_t, handler); rc = (handler) (*(fcb->firsthandlerargs + handlerindex), time, sender, receiver, communicator, msgtype, msglength, scltoken); VTF3_PARSER_HANDLER_CALL_EPILOGUE; return; /* LABEL */ Error: (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } static void FstAsciiParserSrcinfo_obsol (fcb_t *fcb, int numcharsdata, int handlerindex, int havetime, double time) { (void) StdAsciiParserSrcinfo_obsol (fcb, numcharsdata, handlerindex, havetime, time); return; } static void FstAsciiParserUnrecognizable (fcb_t *fcb, int numcharsdata, int handlerindex, int havetime, double time) { static unsigned int first = 1; if (first != 0) { first = 0; (void) PassI (havetime); (void) PassF (time); } (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } static void FstAsciiParserUpfrom (fcb_t *fcb, int numcharsdata, int handlerindex, int havetime, double time) { int statetoken, scltoken, exchangetype, rc; unsigned int cpuid; VTF3_DCL_UPFROM (typedef, (*upfromhandler_t)); upfromhandler_t upfromhandler; VTF3_DCL_UPTO (typedef, (*uptohandler_t)); uptohandler_t uptohandler; if (havetime == 0) goto Error; VTF3_FSTASCIIPARSER_READI4 (statetoken); if (statetoken == VTF3_NOSTATE) goto Error; cpuid = 0; if (VTF3_ASCIIPARSER_TEST_CHAR ('P') != 0) { fcb->recbufferpos++; VTF3_FSTASCIIPARSER_READU4 (cpuid); } scltoken = VTF3_SCLNONE; if (VTF3_ASCIIPARSER_TEST_CHAR ('L') != 0) { fcb->recbufferpos++; VTF3_FSTASCIIPARSER_READI4 (scltoken); } if (VTF3_ASCIIPARSER_TEST_CHAR ('\r') != 0) fcb->recbufferpos++; VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('\n'); VTF3_PARSER_LAST_VALID_TIME_MANAGEMENT; exchangetype = VTF3_EXCHANGETYPE_UPFROM; if (fcb->substitudeupfrom != 0) (void) SubstitudeUpFrom (fcb, cpuid, &exchangetype, &statetoken); if (exchangetype == VTF3_EXCHANGETYPE_UPFROM) { VTF3_PARSER_HANDLER_CALL_PROLOGUE (upfromhandler_t, upfromhandler); rc = (upfromhandler) (*(fcb->firsthandlerargs + handlerindex), time, statetoken, cpuid, scltoken); VTF3_PARSER_HANDLER_CALL_EPILOGUE; return; } if (exchangetype == VTF3_EXCHANGETYPE_UPTO) { handlerindex = vtfuptohandlerindex; VTF3_PARSER_HANDLER_CALL_PROLOGUE (uptohandler_t, uptohandler); rc = (uptohandler) (*(fcb->firsthandlerargs + handlerindex), time, statetoken, cpuid, scltoken); VTF3_PARSER_HANDLER_CALL_EPILOGUE; return; } (void) fprintf (stderr, "VTF3: FstAsciiParserUpfrom(): " "Unrecoverable error\n"); (void) fflush (stderr); (void) exit (127); return; /* LABEL */ Error: (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } static void FstAsciiParserUpto (fcb_t *fcb, int numcharsdata, int handlerindex, int havetime, double time) { int statetoken, scltoken, exchangetype, rc; unsigned int cpuid; VTF3_DCL_UPTO (typedef, (*handler_t)); handler_t handler; if (havetime == 0) goto Error; VTF3_FSTASCIIPARSER_READI4 (statetoken); cpuid = 0; if (VTF3_ASCIIPARSER_TEST_CHAR ('P') != 0) { fcb->recbufferpos++; VTF3_FSTASCIIPARSER_READU4 (cpuid); } scltoken = VTF3_SCLNONE; if (VTF3_ASCIIPARSER_TEST_CHAR ('L') != 0) { fcb->recbufferpos++; VTF3_FSTASCIIPARSER_READI4 (scltoken); } if (VTF3_ASCIIPARSER_TEST_CHAR ('\r') != 0) fcb->recbufferpos++; VTF3_ASCIIPARSER_CHECK_AND_PASS_CHAR ('\n'); VTF3_PARSER_LAST_VALID_TIME_MANAGEMENT; if (fcb->substitudeupfrom != 0) { exchangetype = VTF3_EXCHANGETYPE_UPTO; (void) SubstitudeUpFrom (fcb, cpuid, &exchangetype, &statetoken); } VTF3_PARSER_HANDLER_CALL_PROLOGUE (handler_t, handler); rc = (handler) (*(fcb->firsthandlerargs + handlerindex), time, statetoken, cpuid, scltoken); VTF3_PARSER_HANDLER_CALL_EPILOGUE; return; /* LABEL */ Error: (void) HandleBadRecord (fcb, numcharsdata, handlerindex); return; } /*****************************************************************************/ void VTF3_Close (void *fcbcaller) { fcb_t *fcb; int numbytes; fcb = (fcb_t *) fcbcaller; (void) CheckFcb (fcb); if (fcb->pfile == 0) ; else if (fcb->isoutput != 0) { /* This is for the data and/or for the file. */ (void) FlushIoBuffer (fcb); /* This is for the file. */ (void) FlushIoBuffer (fcb); /* Just for fun. */ fcb->pfile = 0; fcb->filehasbeenclosed = 1; } else if (fcb->filecompressiontype == VTF3_FILECOMPRESSION_NONE) { if (fclose (fcb->pfile) != 0) { (void) fprintf (stderr, "VTF3: Error while closing input\n"); (void) fflush (stderr); } fcb->pfile = 0; fcb->filehasbeenclosed = 1; } else if (fcb->filecompressiontype == VTF3_FILECOMPRESSION_ZLIB) { numbytes = VTF3_GzRead (&fcb->pfile, &fcb->zfile, fcb->iobuffer, 0, &fcb->zfileposition); if (numbytes == (-2)) { VTF3_NOMEM_GOOD_BYE_INFO; (void) exit (127); } else if (numbytes != 0) { (void) fprintf (stderr, "VTF3: Error while closing " "Z-stream input\n"); (void) fflush (stderr); } fcb->pfile = 0; fcb->filehasbeenclosed = 1; } else { (void) fprintf (stderr, "VTF3: VTF3_Close(): Unrecoverable error\n"); (void) fflush (stderr); (void) exit (127); } (void) FreeFcb (fcb); return; } size_t VTF3_CopyFile (const char *inputfilename, const char *outputfilename, int outputfileformat, int substitudeupfrom) { void *fcbout, **firsthandlerargs, *fcbin; int nrectypes, i; VTF3_handler_t *copyhandlers; size_t bytesread; (void) CheckVtfInitialization (); if (inputfilename == 0) { (void) fprintf (stderr, "VTF3: VTF3_CopyFile(): " "NULL as input file name\n"); (void) fflush (stderr); (void) exit (127); } if (outputfilename == 0) { (void) fprintf (stderr, "VTF3: VTF3_CopyFile(): " "NULL as output file name\n"); (void) fflush (stderr); (void) exit (127); } fcbout = VTF3_OpenFileOutput (outputfilename, outputfileformat, 0); if (fcbout == 0) { (void) fprintf (stderr, "VTF3: VTF3_CopyFile(): " "Can't open `%s' for output\n", outputfilename); (void) fflush (stderr); (void) exit (127); } nrectypes = VTF3_GetRecTypeArrayDim (); copyhandlers = (VTF3_handler_t *) malloc ((size_t) nrectypes * sizeof (VTF3_handler_t)); if (copyhandlers == 0) { VTF3_NOMEM_GOOD_BYE_INFO; (void) exit (127); } (void) VTF3_GetCopyHandlerArray (copyhandlers); firsthandlerargs = (void **) malloc ((size_t) nrectypes * sizeof (void *)); if (firsthandlerargs == 0) { VTF3_NOMEM_GOOD_BYE_INFO; (void) exit (127); } for (i = 0; i < nrectypes; i++) *(firsthandlerargs + i) = fcbout; fcbin = VTF3_OpenFileInput (inputfilename, copyhandlers, firsthandlerargs, substitudeupfrom); if (fcbin == 0) { (void) fprintf (stderr, "VTF3: VTF3_CopyFile(): " "Can't open `%s' for input\n", inputfilename); (void) fflush (stderr); (void) exit (127); } (void) free (firsthandlerargs); (void) free (copyhandlers); bytesread = VTF3_ReadFileInput (fcbin); (void) VTF3_Close (fcbin); (void) VTF3_Close (fcbout); return (bytesread); } int VTF3_DebugHandler (void *firsthandlerarg, ...) { (void) PassP (firsthandlerarg); (void) fprintf (stderr, "VTF3: VTF3_DebugHandler() invoked\n"); (void) fflush (stderr); (void) exit (127); return (0); } void VTF3_GetCopyHandlerArray (VTF3_handler_t *callercopyhandlers) { int i; (void) CheckVtfInitialization (); for (i = 0; i < (int) (sizeof (recordtypes) / sizeof (recordtypes[0])); i++) *(callercopyhandlers + i) = copyhandlers[i]; return; } void VTF3_GetDefRecTypeArray (int *callerdefrecordtypes) { int i; (void) CheckVtfInitialization (); for (i = 0; i < (int) (sizeof (defrecordtypes) / sizeof (defrecordtypes[0])); i++) *(callerdefrecordtypes + i) = defrecordtypes[i]; return; } int VTF3_GetDefRecTypeArrayDim (void) { (void) CheckVtfInitialization (); return ((int) (sizeof (defrecordtypes) / sizeof (defrecordtypes[0]))); } void VTF3_GetRecTypeArray (int *callerrecordtypes) { int i; (void) CheckVtfInitialization (); for (i = 0; i < (int) (sizeof (recordtypes) / sizeof (recordtypes[0])); i++) *(callerrecordtypes + i) = recordtypes[i]; return; } int VTF3_GetRecTypeArrayDim (void) { (void) CheckVtfInitialization (); return ((int) (sizeof (recordtypes) / sizeof (recordtypes[0]))); } const char * VTF3_GetVersion (void) { (void) CheckVtfInitialization (); return ((const char *) &vtfversionbuf[0]); } int VTF3_GetVersionNumber (void) { (void) CheckVtfInitialization (); return (vtfversionnumber); } void VTF3_InitTables (void) { static const unsigned char stdbinaryheader [] = VTF3_HEADER_STD_BINARY; static char dig [10] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9'}; static char hexlower [16] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'}; static char hexupper [16] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'}; static const char *lower = "_abcdefghijklmnopqrstuvwxyz"; static const char *upper = "_ABCDEFGHIJKLMNOPQRSTUVWXYZ"; static const char *space = " \f\r\t\v"; /* Without '\n' ! */ int i, dim; unsigned int u, zebra; const char *p; if (vtfisinitialized != 0) return; if (PassI ((int) sizeof (double)) != 8 * PassI ((int) sizeof (char))) { (void) fprintf (stderr, "VTF3: sizeof(double) != 8 * sizeof(char)\n"); (void) fflush (stderr); (void) exit (127); } if (PassI ((int) sizeof (unsigned int)) < 4 * PassI ((int) sizeof (char))) { (void) fprintf (stderr, "VTF3: sizeof(unsigned int) < 4 * sizeof(char)\n"); (void) fflush (stderr); (void) exit (127); } if (PassI ((int) sizeof (int)) < 4 * PassI ((int) sizeof (char))) { (void) fprintf (stderr, "VTF3: sizeof(int) < 4 * sizeof(char)\n"); (void) fflush (stderr); (void) exit (127); } if (PassI ((int) sizeof (unsigned int)) != PassI ((int) sizeof (int))) { (void) fprintf (stderr, "VTF3: sizeof(unsigned int) != sizeof(int)\n"); (void) fflush (stderr); (void) exit (127); } if (PassI ((int) sizeof (unsigned char)) != PassI ((int) sizeof (char))) { (void) fprintf (stderr, "VTF3: sizeof(unsigned char) != sizeof(char)\n"); (void) fflush (stderr); (void) exit (127); } vtfbinaryheaderasrecordlength = ((unsigned int) stdbinaryheader[0] << 0) + ((unsigned int) stdbinaryheader[1] << 8) + ((unsigned int) stdbinaryheader[2] << 16) + ((unsigned int) stdbinaryheader[3] << 24); if (VTF3_CONST_MAX_RECBUF_DIM >= vtfbinaryheaderasrecordlength) { (void) fprintf (stderr, "VTF3: VTF3_CONST_MAX_RECBUF_DIM = %d >= %u\n", VTF3_CONST_MAX_RECBUF_DIM, vtfbinaryheaderasrecordlength); (void) fflush (stderr); (void) exit (127); } (void) SetFprType (); (void) PrepVersion (); for (i = 0; i < 256; i++) vtfdigit[i] = 10; for (i = 0; i < 10; i++) vtfdigit[VTF3_CHAR2INDEX (dig[i])] = i; (void) PrepVersionNumber (); for (i = 0; i < 256; i++) vtfhexdig[i] = 255; for (u = 0; u < 16; u++) vtfhexdig[VTF3_CHAR2INDEX (hexlower[u])] = u; for (u = 0; u < 16; u++) vtfhexdig[VTF3_CHAR2INDEX (hexupper[u])] = u; for (i = 0; i < 256; i++) vtfletter[i] = 0; p = lower; while (*p != '\0') { u = VTF3_CHAR2INDEX (*p++); vtfletter[u] = (int) (p - lower); } p = upper; while (*p != '\0') { u = VTF3_CHAR2INDEX (*p++); vtfletter[u] = (int) (p - upper); } for (i = 0; i < 256; i++) vtfspace[i] = 0; p = space; while (*p != '\0') vtfspace[VTF3_CHAR2INDEX (*p++)] = 1; for (u = 0; u < 256; u++) vtfupper[u] = (char) (unsigned char) u; p = lower; while (*p != '\0') { u = VTF3_CHAR2INDEX (*p); vtfupper[u] = vtfupper[VTF3_CHAR2INDEX (*(upper + (int) (p -lower)))]; p++; } dim = (int) (sizeof (recordtypes) / sizeof (recordtypes[0])); (void) QuickSortRecTypes (&recordtypes[0], &stdasciikeywords[0], &fstasciikeywords[0], ©handlers[0], &stdasciiparsers[0], &stdbinaryparsers[0], &fstasciiparsers[0], 0, (unsigned int) dim - 1); vtfunrecognizablehandlerindex = 0; vtfuptohandlerindex = 0; for (i = 0; i < dim; i++) { if (recordtypes[i] == VTF3_RECTYPE_UNRECOGNIZABLE) vtfunrecognizablehandlerindex = i; if (recordtypes[i] == VTF3_RECTYPE_UPTO) vtfuptohandlerindex = i; } for (i = 0; i < dim; i++) { stdasciikwparser[i] = stdasciikeywords[i]; fstasciikwparser[i] = fstasciikeywords[i]; stdasciikwparser2hi[i] = i; fstasciikwparser2hi[i] = i; } (void) QuickSortKeyWords (&stdasciikwparser[0], &stdasciikwparser2hi[0], 0, (unsigned int) dim - 1); (void) QuickSortKeyWords (&fstasciikwparser[0], &fstasciikwparser2hi[0], 0, (unsigned int) dim - 1); for (i = 1; i < dim; i++) if (KeyWordComp (stdasciikwparser[i - 1], stdasciikwparser[i]) == 0 || KeyWordComp (fstasciikwparser[i - 1], fstasciikwparser[i]) == 0) { (void) fprintf (stderr, "VTF3: VTF3_InitTables(): " "Unrecoverable error\n"); (void) fflush (stderr); (void) exit (127); } vtfzebra = 0x0; while (vtfzebra != (zebra = PassU (vtfzebra << 2 | (unsigned int) 0x1))) vtfzebra = zebra; vtfisinitialized = 1; return; } void * VTF3_OpenFileInput (const char *inputfilename, const VTF3_handler_t *handlers, void * const *firsthandlerargs, int substitudeupfrom) { static unsigned int first = 1; static const unsigned char stdasciiheader [] = VTF3_HEADER_STD_ASCII; static const unsigned char formatheaders [] [sizeof (stdasciiheader) / sizeof (stdasciiheader[0])] = VTF3_HEADER_ALL_INIT; FILE *pfile; fcb_t *fcb; int nrectypes, i, numcharsheader, iobufferposoffset, isequal, j; size_t numcharsbuffer; if (first != 0) { first = 0; (void) PassP (stdasciiheader); } (void) CheckVtfInitialization (); if (inputfilename == 0) { (void) fprintf (stderr, "VTF3: VTF3_OpenFileInput(): " "NULL as input file name\n"); (void) fflush (stderr); (void) exit (127); } if (handlers == 0) { (void) fprintf (stderr, "VTF3: VTF3_OpenFileInput(): " "NULL as record handler vector\n"); (void) fflush (stderr); (void) exit (127); } if (firsthandlerargs == 0) { (void) fprintf (stderr, "VTF3: VTF3_OpenFileInput(): " "NULL as record handler argument-1 vector\n"); (void) fflush (stderr); (void) exit (127); } if ((pfile = fopen (inputfilename, "rb")) == 0) return (0); fcb = AllocFcb (); fcb->pfile = pfile; fcb->filecompressiontype = GetFileCompressionType (inputfilename); nrectypes = (int) (sizeof (recordtypes) / sizeof (recordtypes[0])); fcb->handlers = (VTF3_handler_t *) malloc ((size_t) nrectypes * sizeof (VTF3_handler_t)); if (fcb->handlers == 0) { VTF3_NOMEM_GOOD_BYE_INFO; (void) exit (127); } fcb->firsthandlerargs = (void **) malloc ((size_t) nrectypes * sizeof (void *)); if (fcb->firsthandlerargs == 0) { VTF3_NOMEM_GOOD_BYE_INFO; (void) exit (127); } for (i = 0; i < nrectypes; i++) { *(fcb->handlers + i) = *(handlers + i); if (*(fcb->handlers + i) == 0) *(fcb->firsthandlerargs + i) = 0; else if (*(fcb->handlers + i) == (VTF3_handler_t) VTF3_DebugHandler) *(fcb->firsthandlerargs + i) = 0; else *(fcb->firsthandlerargs + i) = *(firsthandlerargs + i); } #if (defined (VTF3_LEGACY_OUTPUT)) substitudeupfrom *= PassI (0); #endif fcb->substitudeupfrom = substitudeupfrom != 0 ? 1 : 0; (void) FillIoBuffer (fcb); numcharsbuffer = (size_t) (fcb->iobuffereof - fcb->iobuffer); numcharsheader = (int) (sizeof (stdasciiheader) / sizeof (unsigned char)); iobufferposoffset = 0; fcb->fileformat = VTF3_FILEFORMAT_STD_ASCII; if (numcharsbuffer >= sizeof (stdasciiheader) / sizeof (unsigned char)) { for (i = 0; i < (int) (sizeof (formatheaders) / sizeof (stdasciiheader)); i++) { isequal = 1; for (j = 0; j < numcharsheader; j++) { if ((unsigned char) *(fcb->iobuffer + j) != formatheaders[i][j]) { isequal = 0; break; } } if (isequal != 0) { iobufferposoffset = numcharsheader; fcb->fileformat = i; break; } if (numcharsbuffer == sizeof (stdasciiheader) / sizeof (unsigned char)) continue; if (formatheaders[i][numcharsheader - 1] != '\n') continue; if (*(fcb->iobuffer + numcharsheader - 1) != '\r') continue; isequal = 1; for (j = 0; j < numcharsheader - 1; j++) { if ((unsigned char) *(fcb->iobuffer + j) != formatheaders[i][j]) { isequal = 0; break; } } if (isequal == 0) continue; if (*(fcb->iobuffer + numcharsheader) == '\n') { /* Violated ASCII header, accept it. */ iobufferposoffset = numcharsheader + 1; fcb->fileformat = i; break; } } } fcb->iobufferpos = fcb->iobuffer + iobufferposoffset; fcb->headerbytesnotcounted = (size_t) iobufferposoffset * sizeof (char); fcb->legacyascii = iobufferposoffset == 0 ? 1 : 0; return (fcb); } void * VTF3_OpenFileOutput (const char *outputfilename, int outputfileformat, int writeunmergedrecord) { static unsigned int first = 1; static const unsigned char stdasciiheader [] = VTF3_HEADER_STD_ASCII; static const unsigned char formatheaders [] [sizeof (stdasciiheader) / sizeof (stdasciiheader[0])] = VTF3_HEADER_ALL_INIT; FILE *pfile; fcb_t *fcb; int iobufferposoffset; if (first != 0) { first = 0; (void) PassP (stdasciiheader); } (void) CheckVtfInitialization (); if (outputfilename == 0) { (void) fprintf (stderr, "VTF3: VTF3_OpenFileOutput(): " "NULL as output file name\n"); (void) fflush (stderr); (void) exit (127); } if (outputfileformat >= (int) (sizeof (formatheaders) / sizeof (stdasciiheader)) || outputfileformat < 0) { (void) fprintf (stderr, "VTF3: Bad value %d as file format to " "VTF3_OpenFileOutput()\n", outputfileformat); (void) fflush (stderr); (void) exit (127); } if ((pfile = fopen (outputfilename, "wb")) == 0) return (0); fcb = AllocFcb (); fcb->pfile = pfile; fcb->filecompressiontype = GetFileCompressionType (outputfilename); fcb->iobuffer = (char *) malloc (VTF3_CONST_IOBUF_DIM * sizeof (char)); if (fcb->iobuffer == 0) { VTF3_NOMEM_GOOD_BYE_INFO; (void) exit (127); } fcb->iobufferbeyond = fcb->iobuffer + VTF3_CONST_IOBUF_DIM; fcb->iobuffereof = fcb->iobuffer + VTF3_CONST_IOBUF_DIM; if (PassI (VTF3_CONST_IOBUF_DIM) < (int) (sizeof (stdasciiheader) / sizeof (unsigned char))) { (void) fprintf (stderr, "VTF3: VTF3_OpenFileOutput(): " "Too small I/O buffer dimension\n"); (void) fflush (stderr); (void) exit (127); } #if (defined (VTF3_LEGACY_OUTPUT)) if (outputfileformat == VTF3_FILEFORMAT_FST_ASCII) outputfileformat = VTF3_FILEFORMAT_STD_ASCII; if (outputfileformat != VTF3_FILEFORMAT_STD_ASCII) { (void) memcpy (fcb->iobuffer, &formatheaders[outputfileformat][0], sizeof (stdasciiheader)); iobufferposoffset = (int) (sizeof (stdasciiheader) / sizeof (unsigned char)); } else iobufferposoffset = 0; #else (void) memcpy (fcb->iobuffer, &formatheaders[outputfileformat][0], sizeof (stdasciiheader)); iobufferposoffset = (int) (sizeof (stdasciiheader) / sizeof (unsigned char)); #endif fcb->iobufferpos = fcb->iobuffer + iobufferposoffset; fcb->fileformat = outputfileformat; fcb->isoutput = 1; if (writeunmergedrecord != 0) (void) VTF3_WriteDefunmerged (fcb); return (fcb); } void * VTF3_OpenMemoryInput (int inputfileformat, const VTF3_handler_t *handlers, void * const *firsthandlerargs, int substitudeupfrom) { static unsigned int first = 1; static const unsigned char stdasciiheader [] = VTF3_HEADER_STD_ASCII; static const unsigned char formatheaders [] [sizeof (stdasciiheader) / sizeof (stdasciiheader[0])] = VTF3_HEADER_ALL_INIT; fcb_t *fcb; int nrectypes, i; if (first != 0) { first = 0; (void) PassP (stdasciiheader); (void) PassP (formatheaders); } (void) CheckVtfInitialization (); if (inputfileformat >= (int) (sizeof (formatheaders) / sizeof (stdasciiheader)) || inputfileformat < 0) { (void) fprintf (stderr, "VTF3: Bad value %d as file format to " "VTF3_OpenMemoryInput()\n", inputfileformat); (void) fflush (stderr); (void) exit (127); } if (handlers == 0) { (void) fprintf (stderr, "VTF3: VTF3_OpenMemoryInput(): " "NULL as record handler vector\n"); (void) fflush (stderr); (void) exit (127); } if (firsthandlerargs == 0) { (void) fprintf (stderr, "VTF3: VTF3_OpenMemoryInput(): " "NULL as record handler argument-1 vector\n"); (void) fflush (stderr); (void) exit (127); } fcb = AllocFcb (); fcb->fileformat = inputfileformat; nrectypes = (int) (sizeof (recordtypes) / sizeof (recordtypes[0])); fcb->handlers = (VTF3_handler_t *) malloc ((size_t) nrectypes * sizeof (VTF3_handler_t)); if (fcb->handlers == 0) { VTF3_NOMEM_GOOD_BYE_INFO; (void) exit (127); } fcb->firsthandlerargs = (void **) malloc ((size_t) nrectypes * sizeof (void *)); if (fcb->firsthandlerargs == 0) { VTF3_NOMEM_GOOD_BYE_INFO; (void) exit (127); } for (i = 0; i < nrectypes; i++) { *(fcb->handlers + i) = *(handlers + i); if (*(fcb->handlers + i) == 0) *(fcb->firsthandlerargs + i) = 0; else if (*(fcb->handlers + i) == (VTF3_handler_t) VTF3_DebugHandler) *(fcb->firsthandlerargs + i) = 0; else *(fcb->firsthandlerargs + i) = *(firsthandlerargs + i); } #if (defined (VTF3_LEGACY_OUTPUT)) substitudeupfrom *= PassI (0); #endif fcb->substitudeupfrom = substitudeupfrom != 0 ? 1 : 0; return (fcb); } void * VTF3_OpenMemoryOutput (int outputfileformat) { static unsigned int first = 1; static const unsigned char stdasciiheader [] = VTF3_HEADER_STD_ASCII; static const unsigned char formatheaders [] [sizeof (stdasciiheader) / sizeof (stdasciiheader[0])] = VTF3_HEADER_ALL_INIT; fcb_t *fcb; if (first != 0) { first = 0; (void) PassP (stdasciiheader); (void) PassP (formatheaders); } (void) CheckVtfInitialization (); if (outputfileformat >= (int) (sizeof (formatheaders) / sizeof (stdasciiheader)) || outputfileformat < 0) { (void) fprintf (stderr, "VTF3: Bad value %d as file format to " "VTF3_OpenMemoryOutput()\n", outputfileformat); (void) fflush (stderr); (void) exit (127); } #if (defined (VTF3_LEGACY_OUTPUT)) if (outputfileformat == VTF3_FILEFORMAT_FST_ASCII) outputfileformat = VTF3_FILEFORMAT_STD_ASCII; #endif fcb = AllocFcb (); fcb->fileformat = outputfileformat; fcb->isoutput = 1; return (fcb); } int VTF3_QueryFormat (const void *fcb) { (void) CheckFcb ((const fcb_t *) fcb); return (((const fcb_t *) fcb)->fileformat); } size_t VTF3_ReadFileInput (void *fcbcaller) { fcb_t *fcb; size_t bytestoberead; unsigned int u; int recordstoberead; fcb = (fcb_t *) fcbcaller; (void) CheckFcbIn (fcb); if (fcb->pfile == 0 && fcb->filehasbeenclosed == 0) { (void) fprintf (stderr, "VTF3: VTF3_ReadFileInput(): " "FCB isn't for file processing\n"); (void) fflush (stderr); (void) exit (127); } bytestoberead = ((size_t) ~ (size_t) 0 >> 1) - 1; u = ((unsigned int) ~ (unsigned int) 0 >> 1) - 1; recordstoberead = * (int *) &u; (void) ReadInputLtd (fcb, &bytestoberead, &recordstoberead); return (bytestoberead); } size_t VTF3_ReadFileInputLtdBytes (void *fcbcaller, size_t bytestoberead) { fcb_t *fcb; unsigned int u; int recordstoberead; fcb = (fcb_t *) fcbcaller; (void) CheckFcbIn (fcb); if (fcb->pfile == 0 && fcb->filehasbeenclosed == 0) { (void) fprintf (stderr, "VTF3: VTF3_ReadFileInputLtdBytes(): " "FCB isn't for file processing\n"); (void) fflush (stderr); (void) exit (127); } u = ((unsigned int) ~ (unsigned int) 0 >> 1) - 1; recordstoberead = * (int *) &u; (void) ReadInputLtd (fcb, &bytestoberead, &recordstoberead); return (bytestoberead); } int VTF3_ReadFileInputLtdRecs (void *fcbcaller, int recordstoberead) { fcb_t *fcb; size_t bytestoberead; fcb = (fcb_t *) fcbcaller; (void) CheckFcbIn (fcb); if (fcb->pfile == 0 && fcb->filehasbeenclosed == 0) { (void) fprintf (stderr, "VTF3: VTF3_ReadFileInputLtdRecs(): " "FCB isn't for file processing\n"); (void) fflush (stderr); (void) exit (127); } bytestoberead = ((size_t) ~ (size_t) 0 >> 1) - 1; (void) ReadInputLtd (fcb, &bytestoberead, &recordstoberead); return (recordstoberead); } size_t VTF3_ReadMemoryInput (void *fcbcaller, const void *src, size_t size) { fcb_t *fcb; char *iobuffer; size_t bytestoberead; unsigned int u; int recordstoberead; fcb = (fcb_t *) fcbcaller; (void) CheckFcbIn (fcb); if (fcb->pfile != 0 || fcb->filehasbeenclosed != 0) { (void) fprintf (stderr, "VTF3: VTF3_ReadMemoryInput(): " "FCB isn't for memory processing\n"); (void) fflush (stderr); (void) exit (127); } if (src == 0) { (void) fprintf (stderr, "VTF3: VTF3_ReadMemoryInput(): " "NULL as record source\n"); (void) fflush (stderr); (void) exit (127); } iobuffer = (char *) (void *) (const void *) src; fcb->iobuffer = iobuffer; fcb->iobufferbeyond = iobuffer + size / sizeof (char) + 1; fcb->iobuffereof = iobuffer + size / sizeof (char); fcb->iobufferpos = iobuffer + 0; bytestoberead = ((size_t) ~ (size_t) 0 >> 1) - 1; u = ((unsigned int) ~ (unsigned int) 0 >> 1) - 1; recordstoberead = * (int *) &u; (void) ReadInputLtd (fcb, &bytestoberead, &recordstoberead); fcb->iobuffer = 0; fcb->iobufferbeyond = 0; fcb->iobuffereof = 0; fcb->iobufferpos = 0; return (bytestoberead); } /*****************************************************************************/ #if (defined (VTF3_MAIN_COPYFILE)) int main (int argc, char **argv) { const char *inputfile = "input.vpt"; const char *outputfile = "output.vpt"; int fileformat, nrectypes, i; VTF3_handler_t *handlers; void **firsthandlerargs, *fcb; size_t bytesread; (void) VTF3_InitTables (); (void) fprintf (stdout, "%s\n", VTF3_GetVersion ()); (void) fprintf (stdout, "%d\n", VTF3_GetVersionNumber ()); fileformat = VTF3_FILEFORMAT_UNDEFINED; if (argc == 2) { if (*(*(argv + 1) + 0) == 'a' || *(*(argv + 1) + 0) == 'A') { fileformat = VTF3_FILEFORMAT_STD_ASCII; if (*(*(argv + 1) + 1) == '0') outputfile = "/dev/null"; } else if (*(*(argv + 1) + 0) == 'b' || *(*(argv + 1) + 0) == 'B') { fileformat = VTF3_FILEFORMAT_STD_BINARY; if (*(*(argv + 1) + 1) == '0') outputfile = "/dev/null"; } else if (*(*(argv + 1) + 0) == 'f' || *(*(argv + 1) + 0) == 'F') { fileformat = VTF3_FILEFORMAT_FST_ASCII; if (*(*(argv + 1) + 1) == '0') outputfile = "/dev/null"; } else if (*(*(argv + 1) + 0) == 'm' || *(*(argv + 1) + 0) == 'M') { nrectypes = VTF3_GetRecTypeArrayDim (); handlers = (VTF3_handler_t *) malloc ((size_t) nrectypes * sizeof (VTF3_handler_t)); if (handlers == 0) { VTF3_NOMEM_GOOD_BYE_INFO; (void) exit (127); } for (i = 0; i < nrectypes; i++) *(handlers + i) = 0; firsthandlerargs = (void **) malloc ((size_t) nrectypes * sizeof (void *)); if (firsthandlerargs == 0) { VTF3_NOMEM_GOOD_BYE_INFO; (void) exit (127); } for (i = 0; i < nrectypes; i++) *(firsthandlerargs + i) = 0; fcb = VTF3_OpenFileInput (inputfile, handlers, firsthandlerargs, 0); if (fcb == 0) { (void) fprintf (stderr, "VTF3: VTF3_OpenFileInput() " "returned NULL as FCB\n"); (void) fflush (stderr); (void) exit (127); } (void) free (firsthandlerargs); (void) free (handlers); bytesread = VTF3_ReadFileInput (fcb); (void) VTF3_Close (fcb); (void) fprintf (stdout, "%lu bytes read and parsed\n", (unsigned long) bytesread); return (0); } } if (fileformat == VTF3_FILEFORMAT_UNDEFINED) { nrectypes = VTF3_GetRecTypeArrayDim (); handlers = (VTF3_handler_t *) malloc ((size_t) nrectypes * sizeof (VTF3_handler_t)); if (handlers == 0) { VTF3_NOMEM_GOOD_BYE_INFO; (void) exit (127); } for (i = 0; i < nrectypes; i++) *(handlers + i) = 0; firsthandlerargs = (void **) malloc ((size_t) nrectypes * sizeof (void *)); if (firsthandlerargs == 0) { VTF3_NOMEM_GOOD_BYE_INFO; (void) exit (127); } for (i = 0; i < nrectypes; i++) *(firsthandlerargs + i) = 0; fcb = VTF3_OpenFileInput (inputfile, handlers, firsthandlerargs, 0); if (fcb != 0) { fileformat = VTF3_QueryFormat (fcb); (void) VTF3_Close (fcb); } (void) free (firsthandlerargs); (void) free (handlers); } if (fileformat == VTF3_FILEFORMAT_UNDEFINED) fileformat = VTF3_FILEFORMAT_STD_ASCII; bytesread = VTF3_CopyFile (inputfile, outputfile, fileformat, 0); (void) fprintf (stdout, "%lu bytes read and translated\n", (unsigned long) bytesread); return (0); } #endif