/* defgb.h */ /* Supplies constants to defgb package. */ /* Generally, constants are created from user-supplied compiler */ /* -D values and defaults defined somewhere in this file */ /* Some constants are checked for permissible values */ /* Note that "compile-time initialization" can also be done in */ /* the code modules. Further, run-time initialization can take place */ /* before the system "starts running". Besides the obvious data */ /* declaration statements, check the init* modules in ioopen_routines */ #define DEFGBH_VERSION "defgb.h version 3.5 28 Jul 97" /* 28 Jul 97. Include PATH_INFO_routines.h */ /* 5 Jun 97. Move _nonconfig back in here per new make scheme */ /* 4 Jun 97. Remove EOD_STRING-never used */ /* 16 May 97. *SINK -> *FILE; NULL_SINK -> NULL_DEVICE */ /* 8 Apr 97. Time/date wjstbl size change for new opts */ /* [Begin 3.5] */ /* 18 Mar 97. DEFAULT_OTHER_COMMENT_SINK (bit bucket) */ /* Put "version" in ID string so grep for it works! */ /* [Begin 3.4a] */ /* 11 Feb 97. EOD_STRING */ /* 10 Feb 97. PROCESS_VARLIST replaces PROCESS_NONLEVEL0_VARLIST */ /* 5 Feb 97. VARLIST_OPT. */ /* [Begin 3.4] */ /* 17 Dec 96. Convert externally specifiable *SEPARATOR strings */ /* to *SEPARATORS strings. External is compatible w/def; */ /* internally, 1 char things are SEPARATOR; string things */ /* are SEPARATORS */ /* 7 Dec 96. MAXLEVELS -> defgb_nonconfigurable.h */ /* METHOD_PROTOTYPE compilation switch */ /* WIDTH_OPT -> INPWIDTH_OPT; DISPWIDTH_OPT */ /* READ_COMMANDS switch replaces EXEC switch */ /* READ_OBJECTS switch */ /* 25 Nov 96. WJSTBL strings */ /* DISP_DATA_WIDTHS */ /* 19 Nov 96. ALT_SEPARATORS; DEFAULT separator strings */ /* [Begin 3.3] */ /* 9 Nov 96. Add module name to version string. */ /* Remove defmet. */ /* [Begin 3.2] */ /* 1 Aug 96. Use #error instead of #undef. */ /* [Begin 3.1] */ /* 1 Aug 96. TOKEN to 120 for all methods. WJS */ /* 20 Jul 96. Remove TRUE/FALSE defns. They are now supplied by */ /* some system include file spec'd in _nonconfig.h */ /* 19 Jul 96. Split into conditional and unconditional parts. */ /* Sources that compile with this file must use different */ /* object file names per different conditional input */ /* params. To be safe, always use different names */ /* [Begin v 3.0] WJS */ /* 18 Jul 96. More time/date work. Byte type. */ /* 24 Jun 96. Input and output time structures. */ /* Change GMT references to TIMEDATE. */ /* DATA_FIELD_TRIM not user-specifiable */ /* [Begin 2.3] WJS */ /* 6 Jun 96. DATA_FIELD_TRIM, SIGNIFICANT_EMBEDDED_SEPARATORS */ /* DATAFIELDOPTS opt file WJS */ /* 3 Jun 96. Remove NEGATE_LON. WJS */ /* 1 Jun 96. ERR_PREFIX optional. latlonparams stuff. */ /* [Begin 2.2] WJS */ /* 30 May 96. SIGNIFICANT_CONSECUTIVE_SEPARATORS, ERR_PREFIX WJS */ /*************** defgb_nonconfigurable.h ****************************/ /**** ****/ /* Contents of this file contain constants that may NOT be modified at */ /* compile time. Thus, sources compiled with only this file can use */ /* the same object file name */ /* Last NONCONFIGH_VERSION "defgb_nonconfig.h version 1.6 20 May 97" */ /* 20 May 97. Change ULTIMATE_ERROR_STREAM to stderr */ /* Remove HTML_TAG_START - outer does this work now */ /* ADD_TO_BUFFER_SINK -> ADD_TO_BUFFER_FILE */ /* NULL_SINK -> NULL_DEVICE */ /* Make non-user-specifiable structs for PRIMARY*FILE */ /* Remove .dup_maxscriptdiags */ /* 26 Apr 97. JGOFS_ERROR_FILE. Remove PRIMARY*STREAM */ /* Change DEFAULT_ERR_PREFIX to match JGOFS protocol */ /* [Begin 1.6] */ /* 7 Apr 97. outtime.conv */ /* 1 Apr 97. .level */ /* OBJECT_PARAM_STRING_DELIM, OBJECT_PARAM_STRING_SEP */ /* [Begin 1.5] */ /* 18 Mar 97. Explicitly used signed for Logical type. Default */ /* is machine dependent, and they vary... */ /* Put "version" in ID string so grep for it works! */ /* 8 Mar 97. .reread, .scanheader */ /* [Begin 1.4a] */ /* 28 Feb 97. Replace .processed_data with .eod; add .eof */ /* Replace .nvar with .lastvar */ /* outtime.val, .max, .fmt */ /* .buf, .maxlenrec */ /* 10 Feb 97. OPTFILE_WHITESPACE idea bad-back it out */ /* 7 Feb 97. Replace .missing with .nvar */ /* [Begin 1.4] */ /* 5 Feb 97. VARLIST opt file. */ /* 28 Jan 97. objlevel. ndatarecs. CREATE_NULL_DATA. NULL_INPUT */ /* 1 Jan 97. source_type parametrization */ /* Switch to binary WJSTBL_SEPARATOR */ /* [Begin 1.3] */ /* 17 Dec 96. item_alt_separators */ /* *ENTRY_SEPARATOR -> string (*ENTRY_SEPARATORS) */ /* *.entry_separator -> string (*.entry_separators) */ /* OPTFILE_WHITESPACE */ /* 10 Dec 96. MAXLEVELS */ /* New datafieldopts options (bigger table) */ /* 26 Nov 96. source_is_* logicals to source_type. */ /* DISPWIDTHS opt file. */ /* 20 Nov 96. DEFAULT separator; errprefix strings. OBJECT_DELIM. */ /* [Begin 1.2] */ /* 1 Aug 96. If don't test for existence of T/F, get compile */ /* warning on systems that have them if our T/F value */ /* doesn't match theirs. Sigh. Since putting T/F in */ /* defgb.h would mean that everybody would need that, we */ /* break the non-config rule. Sigh. WJS */ #include "path_info_routines.h" #include #include #include #include #include #include #ifndef FALSE /* Not sure where the system defns of these are on Bob's box, if */ /* anywhere and we gotta have them. C defines FALSE but doesn't care */ /* about TRUE, so define latter in terms of former in case there */ /* are system differences (eg, VMS generally likes -1 for TRUE...) */ #define FALSE 0 #define TRUE !FALSE #endif #if FALSE || !TRUE #error "Bad TRUE/FALSE values got into program at compile time" #endif double strtod(); typedef signed char Logical; /* NB: occasionally gets -1, */ /* hence need signed */ /* Define a "summary" switch for each known variant of defgb */ /* (and a catchall) */ #define UNKNOWN_VARIANT 0 #define DEFGB 1 #define DEFMET 2 #define DEFGB_NOHEADER 3 #define DEFGB_URL 4 /* Characters */ /* COMMENT_CHAR Character in first position of data */ /* record which indicates that what follows is */ /* a comment */ /* INDIRECT_FILE_CHAR Prefix character that indicates that */ /* file name which follows contains name of */ /* desired file (instead of being that file) */ /* LEVEL_CONTINUATION_CHAR Character in variable list that indi- */ /* cates that a new level begins at this point */ /* DIRSEP Character in a file spec that indicates */ /* a directory name has just concluded */ /* SOURCE_IS_DATA Character in indirect file entry which */ /* indicates that what follows is a data */ /* record (rather than a file containing that */ /* data) */ /* SCRIPT_PARAM_SEP Character which separates shell script */ /* file name from its parameters */ /* W_EXTEND Trailing character in variable name */ /* which pads name length to output datum */ /* length. Alternate to specifying [width] */ /* attribute */ /* PIPECHAR Character which indicates I/O piping to */ /* shell */ /* INP_REDIRECT_CHAR Character which indicates input */ /* redirection to shell */ /* OUTP_REDIRECT_CHAR Character which indicates output */ /* redirection to shell */ /* OMIT_FROM_TAG_CHAR Character in METHOD_NAME which, if */ /* present, indicates that it, what follows, */ /* and any immediately preceding blanks are to */ /* be omitted from the tag on inserted */ /* tags (see diagnostics optional file) */ /* ATTRIB_SEP Character which separates entries in */ /* a variable attribute list. Note this is a */ /* a character, not a string. Embedded */ /* whitespace (for example) is significant */ /* within an attribute string */ /* OBJECT_PARAM_STRING_SEP Within a data source string that in- */ /* dicates a JGOFS object, the character that */ /* separates parameters within the parameter */ /* string (if any) of that object */ #define COMMENT_CHAR '#' #define INDIRECT_FILE_CHAR '@' #define LEVEL_CONTINUATION_CHAR '>' #define DIRSEP '/' #define SOURCE_IS_DATA '\\' #define SCRIPT_PARAM_SEP ' ' #define W_EXTEND '_' #define PIPECHAR '|' #define INP_REDIRECT_CHAR '<' #define OUTP_REDIRECT_CHAR '>' #define OMIT_FROM_TAG_CHAR '(' #define ATTRIB_SEP ';' #define OBJECT_PARAM_STRING_SEP ',' /* Params for building a "wjstbl" (see doc in create_wjstbl) */ /* These characters must not conflict with characters that can */ /* appear in table entries, and routines that build tables should */ /* check. Easiest way to do this is to make them binary, but */ /* not sure if this can be done w/white space character, which is */ /* sometimes used to terminate a scanf */ /* Routines that decode tables do not need to know these */ /* characters since the separator is the first character of */ /* a table and the white space character is the last. If used */ /* when decoding, be sure table being decoded was built with them */ #define DEFAULT_WJSTBL_WHITE_SPACE '\v' #define DEFAULT_WJSTBL_SEPARATOR 1 /* Strings */ /* *_ENTRY_SEPARATORS Characters which separate consecutive */ /* entries in an optional file. Data struc- */ /* ture has room for a per-option string, */ /* but in general, the default is used. If a */ /* per-option is desired, define it here and */ /* use it in init code (probably get_files) */ /* If null, whole record is 1 entry */ /* If non-null, should share same whitespace */ /* chars as *ITEM_SEPARATORS, w/ at least 1 */ /* unique non-whitespace char */ /* *_SEPARATORS Characters which separate items within */ /* entries in an input file. See *_ENTRY_SEP- */ /* ARATORS comment above */ /* DEFAULT_ENTRY_SEPARATORS Separators between "pairs" for "common */ /* format" opt files. See DEFAULT_ITEM_ */ /* SEPARATORS */ /* DEFAULT_ITEM_SEPARATORS Separators within "pairs" for "common */ /* format" opt files. Must be disjoint from */ /* DEFAULT_ENTRY_SEPARATORS. Whitespace */ /* characters go w/innermost parsing unit, */ /* which is ITEM */ /* REMOVAL_SEPARATORS Separators for removal opt file */ /* REQUIRED_SEPARATORS Characters which must appear in */ /* SEPARATORS string (& hence not in data) */ /* Reason is that rest of system assumes this, */ /* so we don't want to accept data that will */ /* be unusable... */ /* DEFAULT_SEPARATORS Default separators for data files */ /* DEFAULT_ALT_SEPARATORS Default alternate separators */ /* DEFAULT_URL_SEPARATORS Default data separators defgb_url files */ /* COMM_TRUNC_IND String which indicates truncated comment*/ /* EXEC_DELIM Characters that surround a new level */ /* data source indicating that the source */ /* is output of a shell script (not a file) */ /* OBJECT_DELIM Characters that surround a new level */ /* data source indicating that the source */ /* is a JGOFS data object (not a file) */ /* OBJECT_PARAM_STRING_DELIM Within a data source string that in- */ /* dicates a JGOFS object, the delimiters that */ /* surround the parameter string of that object*/ /* ATTR_DELIM Characters that surround variable */ /* attribute */ /* TAG_DELIM Characters that surround comment tag */ /* MISSING_VALUE_STRING String that represents various data */ /* anomalies when data is presented in string */ /* form */ /* DEFAULT_ERR_PREFIX Default for ERR_PREFIX string */ /* NULL_INPUT String that represents non-existent */ /* input. Will provide a "missing value" */ /* line for such devices, if necessary */ #define DEFAULT_ENTRY_SEPARATORS ";" #define DEFAULT_ITEM_SEPARATORS "=\n \t" #define REMOVAL_SEPARATORS "\n,; \t" #define REQUIRED_SEPARATORS "\n\t" #define DEFAULT_SEPARATORS "\n ,\r\t" #define DEFAULT_ALT_SEPARATORS "\'\'" #define DEFAULT_URL_SEPARATORS "\n\t" #define COMM_TRUNC_IND " ..." #define EXEC_DELIM "()" #define OBJECT_DELIM "{}" #define OBJECT_PARAM_STRING_DELIM "()" #define ATTR_DELIM "[]" #define TAG_DELIM "{}" #define MISSING_VALUE_STRING "nd" #define DEFAULT_ERR_PREFIX "&x" #define NULL_INPUT "/dev/null" /* Configurable strings-see defgb.h. Default values come from */ /* this file */ /* ERR_PREFIX */ /* ALT_SEPARATORS */ /* SEPARATORS */ /* MISSING_VALUE_REAL Floating point number that represents */ /* various data anomalies when data is */ /* represented in floating point form */ #define MISSING_VALUE_REAL -9999. /* MAXLEVELS Cannot be bigger than 10 (Email from Glenn ~20 Feb 96) */ /* Somewhere, system assumes max level is 1 character long */ /* (0-9; hence size of 10). Don't see point in allowing */ /* it to be smaller, hence not configurable */ #define MAXLEVELS 10 /************************************************************************/ /* Fundamental structure saving information about the various */ /* sources of info that we tap into. Not all fields are relevant to */ /* all sources of info. */ /* Values for .source_type character */ /* COMMAND_FILE data is coming from a child process via a */ /* via a shell command or user-written script. See EXEC_DELIM */ /* above (as well as doc) */ /* DATA_FILE data is coming from a disk file */ /* JGOFS_OBJECT data is coming from a JGOFS object. See */ /* OBJECT_DELIM (as well as doc) */ /* INDIRECT_FILE_LINE data consists of one record. The record */ /* record is either part of a line in the indirect file */ /* (possibly redirected to an argument passed to the method */ /* by the shell which, in turn, is a parameter in the */ /* .objects file if the method is run by serv). See */ /* SOURCE_IS_DATA (as well as doc) */ /* CREATE_NULL_DATA data not provided by user. Supply line of */ /* "missing data" tokens */ /* ILLEGAL_SOURCE not initialized, or not one of the above */ #define COMMAND_FILE 'c' #define DATA_FILE 'f' #define JGOFS_OBJECT 'o' #define INDIRECT_FILE_LINE 'i' #define CREATE_NULL_DATA 'z' #define ILLEGAL_SOURCE 'x' struct fileinfo { FILE *stream; char *source; /* Where does information of this type */ /* come from? Can be file name, this buffer, */ /* object or script. Additionally, may be */ /* asked to supply appropriate # of nds. */ /* source_type field tells which */ char *descrip; /* Keyword for an optional file type in the */ /* indirect file. Also may be used in error */ /* messages to id optional file type. This */ /* field filled in from constants in init_ */ /* file_structs */ char *item_separators;/* Chars, any string of which (or any one of */ /* which for datafiles; see significant_con- */ /* secutive_separators doc) separates items */ /* in an entry */ char *entry_separators; /* Chars that separate mult entries on a line */ /* Should be the whitespace of item_separators */ /* plus one significant character. */ /* Set to '\0' if mult entries not allowed */ char *comment_postfix; /* String inserted after comments from this */ /* file to distinguish them from other comments */ /* Presently = " {" + file.descrip + "}, so */ /* this field candidate for removal */ char *buf; /* Data buffer pointer for this structure. */ /* Logically an array, but wanted a pointer. */ /* Allocated in init_filestructs. */ /* Not sure separate buffer per structure is */ /* necessary, but at one point it was. */ int nrecs; /* Count of records read from this file */ int ndatarecs; /* Count of data records read from this file */ /* Excludes comments, var lists, etc */ int print_lines; /* Dump every 'print_lines'th input line */ int dup_print_lines; /* Dump every 'dup_print_lines'th input line */ /* to dup diag sink */ int lastvar; /* Upper bound for variables at a level */ /* (actually, first variable of next level) */ /* For datafiles */ int level; /* Level within this object of this structure */ /* For datafiles */ int objlevel; /* JGOFS object level to which this file */ /* corresponds. For datafiles. */ int force_flag; /* If non-zero, file is not optional. +1=file */ /* required; -1=must NOT be present */ int maxlenrec; /* Maximum length of fixed field record. Sum of */ /* lens of fixed field variables present at */ /* this level. Also serves as fixed/free */ /* flag */ char item_alt_separators[2+1]; /* Delims which allow item_separators */ /* in an item; see alt_sep doc */ char source_type; /* See *source, above. Vals: f, d, o, z, or s. */ /* Next bit filled in in get_files */ unsigned int pre_trans : 1; /* Vars in this file need translation */ unsigned int accepts_trans_prefix : 1; unsigned int reread : 1; /* Signal to reprocess contents of buf */ unsigned int scanheader : 1; /* This file may have variable list */ /* (data files only) */ /* Next 3 bits separate data hunks from actual "files" */ /* A fileinfo structure is processed until its eod bit */ /* is set. The open bit says that the data stream */ /* associated with this file structure is open (and */ /* implies that there is a real stream as opposed to */ /* a simulated stream of some kind). The eof bit says */ /* that an end-of-file has been encountered on the */ /* data stream associated with the file structure. */ /* Normally, open=FALSE causes an open, which sets */ /* open and resets eod and eof. Processing continues */ /* until eod. If end-of-file is encountered, eof is */ /* set. USUALLY eod is set, too. getrec_and_proc- */ /* comment manages the eof and eod bits. open_datafile */ /* and open_and_log_optfile do opens. Closing things */ /* (and resetting open) is done "elsewhere" */ /* We generally assume that eof is only set for a */ /* data stream. */ unsigned int eod : 1; unsigned int open : 1; unsigned int eof : 1; }; /* Next statement defines default order of optional file types in */ /* indirect input file */ /* Descriptors are put into place at runtime in init_file_structs, */ /* among other places. */ /* Do not change the values of these, since it could break indirect */ /* files that do not keyword their entries */ /* Don't know how to parametrize so max value of defines gets to be */ /* size of array. */ #define DATAFILE 0 #define TRANSVAR 1 #define INPWIDTHS 2 #define REMOVALS 3 #define TIMEDATEPARAMS 4 #define DIAGNOSTICS 5 #define LATLONPARAMS 6 #define DATAFIELDOPTS 7 #define DISPWIDTHS 8 #define VARLIST 9 #define NFILETYPES 10 /************************************************************************/ /* Datafield options */ /* Table contains the 5 keywords (max size 46), 3 TRUE/FALSEs, */ /* 2 separator strings (for convenience, use same size as FALSE; */ /* namely, 5) and, for each keyword/variable pair, 2 separators */ /* and a blank */ #define NUM_DATAFIELDOPTS 5 #define DATAFIELDOPTS_WJSTBL NUM_DATAFIELDOPTS*(46 + 5 +2 +1) /************************************************************************/ /* Time/date options */ /* wjstbl-format strings for recognized time zone abbreviations with */ /* their displacements. Displacement is from UTC (which, when added */ /* to UTC, gives the local time). Takes HH or HHMM format; leading + */ /* optional, as are leading zeros. */ /* Need separate table for DST since DST zone name conflicts with */ /* other possible DST input */ #define TZTBL "/PST/-8 /MST/-7 /CST/-6 /EST/-5 /AST/-4 /NST/-0330 /GMT/0 " #define TZDSTTBL "/PDT/-7 /MDT/-6 /CDT/-5 /EDT/-4 /ADT/-3 /NDT/-0230 " #define TIMEDATE_INPUT_KEYWORD_PREFIX "invar" /* Types of time/date data fragments */ #define YEAR_FRAG 0 #define MONTH_FRAG 1 #define DAY_FRAG 2 #define HOUR_FRAG 3 #define TIME_OFFSET_FRAG 4 #define NUM_OUTTIME_VARIABLES 5 /* Count. keep = last frag + 1 */ /* There is one output variable corresponding to each of the */ /* input fragments above. The variables are: 24 hour time w/opt */ /* fract min, 4 digit year, month, day, and signed 4 digit */ /* offset from prime meridian. Output variable can include */ /* information from the rest of the input fragments, whose list */ /* continues below */ #define MINUTE_FRAG 5 #define SECOND_FRAG 6 #define FRACTION_FRAG 7 #define DST_FRAG 8 #define AMPM_FRAG 9 #define NUM_TIMEDATE_FRAGS 10 /* Count. keep = last frag + 1 */ /* A single valid format could theoretically specify every output */ /* time variable as well as skip an arbitrary number of fields, as */ /* well has have an arbitrary number of punctuation characters. */ /* We also stick a %1s (length 3) on the end of each input format */ /* to check for extra characters in an input field */ /* A single format conversion specifier can be as big as 21 */ /* (%*99[A-Z,a-z,0-9,+,-] see code). */ /* Allow for as many skipped fields as valid ones, and */ /* 15 punctuation characters. We do NOT check overflow for this */ /* buffer in the code (since we build it char by char), so it's */ /* grossly oversized... */ #define MAXLEN_TIMEDATE_INPFORMAT 3 + (2 * NUM_OUTTIME_VARIABLES * 21) + 15 /* Allow for hhmm.mmmmm, which should be enough precision */ #define MAX_OUTTIME_PRECISION 5 #define MAXLEN_OUTTIME_VARIABLE 5 + MAX_OUTTIME_PRECISION struct intime { int var; /* Input variable w/time info */ int fragbuf_index; /* Index into vector of length numfrags. */ /* Each vector element is a pointer to a buffer */ /* that will hold a fragment. Buffers are in */ /* order that the fragments appear in this */ /* input variable */ int nfrags; /* Number of fragments this input variable */ char format[MAXLEN_TIMEDATE_INPFORMAT+1]; /* sscanf format string */ /* that gets frags from variable. */ }; struct outtime { int var; /* Output time/date variable that will include */ /* this fragment */ int lev; /* Level var occurs on */ int intime_index; /* Index of intime structure describing */ /* input variable from which fragment comes */ int val; /* Temp buffer for values of this fragment as */ /* we do processing */ int max; /* Maximum value for this fragment. Fixed for */ /* some fragments, variable for others... */ /* Largest permissible value for some frags, */ /* smallest impermissible value for others... */ char *var_type; /* Name of output variable (not fragment) */ /* corresponding to this structure */ char *fmt; /* Output format for this fragment */ /* Set in init_time_structs */ char fragbuf[MAXLEN_OUTTIME_VARIABLE +1]; /* Fragment buffer */ char source_field_type[1+1]; /* Kind of field fragment */ /* was derived from. Used as flag telling if */ /* fragment found & in error msg if found twice */ /* String for err msg convenience */ signed char conv; /* Output conversion info. Meaning depends on */ /* structure. */ /* For HOUR (representing hr/min/sec), indicates */ /* UTC/local conversion. +1 = local->UTC, -1 = UTC->local, 0 = none */ }; /* Lat/lon structure */ #define MAXLATLONFORMATSIZE 10 struct latlonformat { char convention; char format[MAXLATLONFORMATSIZE+1]; int var; }; /* Output options */ /* Parametrize various output levels */ /* Error output levels */ #define NOERROR_OUTPUT 0 #define ERROR_MESSAGE 10 #define ID_INNER 20 #define ID_SESSION 25 #define ID_PROBLEM_FILE 50 #define GET_MORE_FROM_SCRIPT 60 #define ID_ALL_OPEN_FILES 80 /* Trace output levels */ #define NOTRACE 0 #define TRACE_IOOPEN 10 #define TRACE_OPTFILE_ROUTINES 20 #define TRACE_PERFILE_ROUTINES 40 #define TRACE_COMMENTS 50 #define TRACE_IOREADREC 70 #define STDERR_DEVICE "/dev/stderr" #define STDOUT_DEVICE "/dev/stdout" #define NULL_DEVICE "/dev/null" /* Comments sent to ADD_TO_BUFFER_FILE won't go there directly-they */ /* will be buffered until outer wants them. */ #define ADD_TO_BUFFER_FILE STDOUT_DEVICE /* By default, errors are sent to outer, which takes care of things */ /* like setting up html environment or issuing JGOFS protocol prefix */ /* if necessary. We need to buffer messages sent to outer's sink */ /* rather than writing them ourselves */ #define JGOFS_ERROR_FILE STDOUT_DEVICE /* Errors in dealing w/sinks go to error sink. Define where we will */ /* send messages about errors w/error sink itself. */ /* If sink changes, stream may have to be opened in the code */ #define ULTIMATE_ERROR_STREAM stderr /* Define where to send primary sinks if user spec's duplicate sink */ #define PRIMARY_DEBUG_FILE STDERR_DEVICE #define PRIMARY_ERROR_FILE JGOFS_ERROR_FILE /* Characteristics of outinfo structure */ #define DATA_COMMENT_SINK 0 #define NON_DATA_COMMENT_SINK 1 #define ERROR_SINK 2 #define DIAG_SINK 3 #define PRIMARY_ERROR_SINK 4 #define PRIMARY_DIAG_SINK 5 #define NUM_SINKS 6 /* Count. keep = last sink + 1 */ #define NUM_DIAG_FLAGS 3 /* inserted_comments, *comment_id */ #define NUM_DIAG_LEVELS 2 /* trace_ & error_ */ #define NUM_EXTRA_DIAG_SOURCES 1 /* maxscriptdiags */ /* Each level has a counter and a addl- counter which user can spec */ /* So does each extra diag source */ /* There is one counter per opt file, iovalstr, iovalreal, and they */ /* all have an addl- version */ #define NUM_DIAG_COUNTERS 2*(NUM_DIAG_LEVELS + NUM_EXTRA_DIAG_SOURCES + \ NFILETYPES + 2) /* Number of things user can specify. */ #define NUM_DIAG_KEYWORDS NUM_SINKS + NUM_DIAG_FLAGS + NUM_DIAG_COUNTERS /* Size the table. Max keyword size of 18 comes from doc (must be */ /* maxed w/ biggest descriptor string); +12 is for biggest prefix/ */ /* suffix we add ("print__lines" at the moment), +5 is for */ /* addl-; max file size of 40 a punt; max flag value is false-hence */ /* size 5; allow 4 digit counters/levels */ #define DIAGS_WJSTBL 40*NUM_SINKS + 5*NUM_DIAG_FLAGS + 4*NUM_DIAG_COUNTERS + \ (18+12+5)*NUM_DIAG_KEYWORDS /* Control of how much non-def data is generated, and where it goes */ /* Structure is filled in in configure_output. Some defaults are */ /* hardcoded; some default to values in this file (some of which, in */ /* turn, can be specified at compile time by the user) */ /* All _sink strings may be file specifications (including /dev/null */ /* /dev/stdout or /dev/stderr (latter 2 may be used even if they are */ /* not defined on a system)). If more than one refer to the same */ /* file, they must be spelled the same; eg, don't use absolute */ /* directory spec for one and relative for another. This, so we can */ /* determine whether or not they are the same file */ /* Use Logical instead of unsigned int since we want to have */ /* pointers to some of the flags */ struct outfile { Logical *open_ptr; /* Will point to one of outsink_open_flags */ FILE **stream_ptr; /* Will point to one of outsink_streams[i] */ char **mode_ptr; /* Will point to one of outsink_modes */ char *sink; /* Will end up non-null. Expect ptr to */ /* /dev/null if people want to chuck stuff; */ /* will write to /dev/null. Will skip writ- */ /* ing if (somehow) 0 len string gets in */ char *descrip; Logical processed; /* For help during input to protect agnst user */ /* spec'ing sink > once */ Logical dup; }; struct outinfo { /* defgb can generate information at the beginning of the main */ /* comment stream. The next items allow specification of where */ /* this data should go, and what it should consist of */ struct outfile file[NUM_SINKS]; Logical outsink_open_flags[NUM_SINKS]; FILE *outsink_streams[NUM_SINKS]; char *outsink_modes[NUM_SINKS]; /* Append or new file */ Logical inserted_comments; /* Insert lines identfying opt */ /* file & indirect file sources */ Logical inserted_comment_id; /* Tag inserted lines with name */ /* of opt file routine */ /* generating line */ Logical opt_file_comment_id; /* Tag comment lines from opt */ /* files with name of opt file */ /* routine reading line */ /* Debugging stuff. Includes original DEBUG & DEBUG0 output */ /* Input data dump numbers in fileinfo structure */ int trace_level; /* Level of output to primary sink */ int dup_trace_level; /* Level of output to duplicate sink */ int iovalstr; /* Dump every 'iovalstr'th call to iovalstr */ int iovalreal; /* 'iovalreal'th call to iovalreal */ int dup_iovalstr; /* Dump every 'dup_iovalstr'th call to iovalstr */ /* to dup diag sink */ int dup_iovalreal; /* Dump every 'dup_iovalreal'th call to */ /* iovalreal to dup diag sink */ int n_iovalstrs; /* Count of calls to iovalstr */ int n_iovalreals; /* iovalreal */ /* How much error stuff */ int error_level; /* Level of output to primary sink */ int dup_error_level; /* Level of output to duplicate sink */ int maxscriptdiags; /* # of "extra" script msgs to primary */ /* sink */ }; /**** ****/ /*************** end defgb_nonconfigurable.h ************************/ /* ERR_PREFIX String which, if found at the beginning */ /* of any data record, indicates that record */ /* is actually an error message */ #ifndef ERR_PREFIX #define ERR_PREFIX DEFAULT_ERR_PREFIX #endif /********* /* Use METHOD_PROTOTYPE as compilation switch to avoid confusion caused */ /* by having make file variable METHOD not being the same as compila- */ /* tion switch METHOD. _PROTOTYPE better name anyway, but too lazy */ /* to go through code changing METHOD... */ #ifdef METHOD #error "No more METHOD compilation switch. Please use METHOD_PROTOTYPE. Tnx" #undef METHOD /* ... or else get another diagnostic. #error (above) */ /* does not "stop dead", but will not allow object file */ /* to be created */ #endif #ifdef METHOD_PROTOTYPE #define METHOD METHOD_PROTOTYPE #if METHOD==DEFGB #define DEFAULT_METHOD_NAME "defgb" #elif METHOD==DEFMET #error "No more defmet. met data was edited so that defgb can be used" #elif METHOD==DEFGB_NOHEADER #define DEFAULT_METHOD_NAME "defgb_noheader" #elif METHOD==DEFGB_URL #define DEFAULT_METHOD_NAME "defgb_url" #else #error "Unrecognized METHOD_PROTOTYPE switch-please check compilation line" #endif #else #define METHOD UNKNOWN_VARIANT #define DEFAULT_METHOD_NAME "defgb (by default)" #endif #ifndef METHOD_NAME #define METHOD_NAME DEFAULT_METHOD_NAME #endif /********* /* White space & separator character for optional files. See doc in */ /* defgb_nonconfig.h & create_wjstbl. Only spec these if the default */ /* characters are somewhere in opt file data */ #ifndef WJSTBL_WHITE_SPACE /* Must be a c "white space" character */ #define WJSTBL_WHITE_SPACE DEFAULT_WJSTBL_WHITE_SPACE #endif #ifndef WJSTBL_SEPARATOR #define WJSTBL_SEPARATOR DEFAULT_WJSTBL_SEPARATOR #endif /* _OPT switches allow control of optional capabilities spec'd via */ /* the indirect parameter file. The default value of 0 allows */ /* or disallows capability based on whether or not the relevant file */ /* is provided in the parameter file. If _OPT is positive, relevant */ /* file MUST be provided in the parameter file. If _OPT is negative, */ /* file must NOT be provided in parameter file. */ #ifndef TRANS_OPT #define TRANS_OPT 0 #endif #ifndef INPWIDTH_OPT #define INPWIDTH_OPT 0 #endif #ifndef REMOVAL_OPT #define REMOVAL_OPT 0 #endif #ifndef TIMEDATE_OPT #define TIMEDATE_OPT 0 #endif #ifndef LATLON_OPT #define LATLON_OPT 0 #endif #ifndef DATAFIELDOPTS_OPT #define DATAFIELDOPTS_OPT 0 #endif #ifndef DISPWIDTH_OPT #define DISPWIDTH_OPT 0 #endif #ifndef VARLIST_OPT #define VARLIST_OPT 0 #endif /* No DIAGS_OPT -can't see purpose of it */ #ifdef READ_COMMANDS /* Compile w/EXEC capability. Saying NO allows */ /* defgb use where startchild not written */ #if ((METHOD==DEFGB_URL) && !READ_COMMANDS) #error "This method MUST have READ_COMMANDS capability" #endif #else #define READ_COMMANDS TRUE #endif #ifndef READ_OBJECTS /* Allow use of JGOFS objects as input. Saying */ /* NO allows defgb use where jdb routines (or */ /* the httpd API they use) not available */ #define READ_OBJECTS TRUE #endif #ifndef TOKEN #define TOKEN 120 #endif #if TOKEN < MAXLEN_OUTTIME_VARIABLE #define TOKEN MAXLEN_OUTTIME_VARIABLE #endif #ifndef NVAR #define NVAR 250 #endif #ifndef MAXCOMMENTLINE /* outer limitation. Size does not */ #define MAXCOMMENTLINE 80 /* include # or \n */ #endif #ifndef DISPLAY_WIDTH /* To right-justify inserted comments, */ #define DISPLAY_WIDTH 80 /* need to know rightmost column. In */ #endif /* html mode, outer inserts a hash & */ #define LENGTH_OUTER_DISPLAY_PREFIX 2 /* a blank before each comment */ #define EFFECTIVE_DISPLAY_WIDTH DISPLAY_WIDTH-LENGTH_OUTER_DISPLAY_PREFIX #ifndef COMMENTSIZE #define COMMENTSIZE 2430 #endif #ifndef MAXVARNAMESIZE #define MAXVARNAMESIZE 40 #endif #ifndef MAXREC #define MAXREC 1257 /* No particular reason for this value */ /* according to Glenn 3 Dec 96 */ #endif /* Lists that contain input from various opt files */ #ifndef TRANS_LIST #define TRANS_LIST 10000 #endif #ifndef VAR_DATA_WIDTHS #define VAR_DATA_WIDTHS 1000 #endif #ifndef DISP_DATA_WIDTHS #define DISP_DATA_WIDTHS 1000 #endif /* Params below define differences from defw. Allow these to be */ /* set on compile line */ /* To enable fixed-format input, specify a inpwidths file in an */ /* indirect input file (see doc) */ #ifdef SEPARATOR /* See also doc for fileinfo struct */ #define SEPARATORS SEPARATOR #else #if METHOD==DEFGB_URL /* This string is, logically, datafile[*]. */ #define SEPARATORS DEFAULT_URL_SEPARATORS /* item_separators */ #else #define SEPARATORS DEFAULT_SEPARATORS #endif #endif /* Allow separators within fields by delimiting them with */ /* separator characters */ #ifdef ALT_SEPARATOR #define ALT_SEPARATORS ALT_SEPARATOR #else #define ALT_SEPARATORS DEFAULT_ALT_SEPARATORS #endif /* If set, consecutive SEPARATORS characters mean empty fields */ /* This applies only to free field data; not variable lists, and not */ /* to any subfile field following the data */ #ifndef SIGNIFICANT_CONSECUTIVE_SEPARATORS #define SIGNIFICANT_CONSECUTIVE_SEPARATORS FALSE #endif /* In fixed fields, does an embedded separator mean 2 fields and, */ /* therefore, an error? */ #ifndef SIGNIFICANT_EMBEDDED_SEPARATORS #define SIGNIFICANT_EMBEDDED_SEPARATORS TRUE #endif /* In fixed fields, should we trim off leading and trailing separators? */ /* #ifndef DATA_FIELD_TRIM */ #define DATA_FIELD_TRIM TRUE /* #endif */ /* What character represents a field to skip in a time/date template */ #ifndef TIMEDATE_SKIPFIELD_CHAR #define TIMEDATE_SKIPFIELD_CHAR '*' #endif /* Character interpreted by SSCANF to mean "skip this field" */ #define SSCANF_SKIPFIELD_CHAR '*' /* Are there variable lists in with the data files or not? */ #ifndef PROCESS_VARLIST #define PROCESS_VARLIST METHOD!=DEFGB_NOHEADER #endif /************************************************************************/ /* Compile-time configurable portions of indirect input files */ /* (should be possible to specify all of these at runtime, too -see */ /* runtime doc) */ /* Also see init* modules in ioopen_routines to see how these values */ /* get applied to the actual data structures. */ /* Output options */ /* Set up default. Can be overridden at runtime via diagnostics */ /* opt file. Final value set in configure_output */ #ifndef DEFAULT_ERROR_LEVEL #define DEFAULT_ERROR_LEVEL GET_MORE_FROM_SCRIPT #endif #ifndef DEFAULT_MAXSCRIPTDIAGS #define DEFAULT_MAXSCRIPTDIAGS 5 #endif /* Set up default trace level. Can be overridden at runtime via /* diagnostics opt file. Final value set in configure_output */ #ifndef DEFAULT_TRACE_LEVEL #ifdef DEBUG /* Compatibility w/older inners */ #define DEFAULT_TRACE_LEVEL TRACE_PERFILE_ROUTINES #else #define DEFAULT_TRACE_LEVEL NOTRACE #endif #endif /* Data trace default (compatibility w/older inners) */ #ifdef DEBUG0 #define DEFAULT_DATA_TRACE 1 #else #define DEFAULT_DATA_TRACE 0 #endif /* User-changeable default sinks-since there are some messages */ /* generated before diags get set up. Note that comments generated */ /* before the comment sinks are set up are buffered, so we just */ /* reprocess them from the buffer after we know where they should go */ #ifndef DEFAULT_DEBUG_FILE #define DEFAULT_DEBUG_FILE PRIMARY_DEBUG_FILE #endif #ifndef DEFAULT_ERROR_FILE #define DEFAULT_ERROR_FILE PRIMARY_ERROR_FILE #endif #ifndef DEFAULT_OTHER_COMMENT_FILE #define DEFAULT_OTHER_COMMENT_FILE NULL_DEVICE #endif /* Inserted comment switch defaults */ #ifndef DEFAULT_INSERTED_MSGS #define DEFAULT_INSERTED_MSGS TRUE #endif #ifndef DEFAULT_INSERTED_MSG_TAG #define DEFAULT_INSERTED_MSG_TAG TRUE #endif #ifndef DEFAULT_COMMENT_SOURCE_TAG #define DEFAULT_COMMENT_SOURCE_TAG TRUE #endif /* Time/date table contains up to 5 pairs of keyword (max size 19) */ /* & variable, up to 10 pairs of keyword (max size 11) & variable */ /* up to 2 pairs of keyword (max size 17) & convention (max size */ /* 5, and up to 10 pairs of keyword (max size 15) & template. */ /* Each pair also requires 2 separators and a blank */ #define TIMEDATE_WJSTBL NUM_OUTTIME_VARIABLES*(19 + MAXVARNAMESIZE + 2 + 1) \ + NUM_TIMEDATE_FRAGS*(11 + MAXVARNAMESIZE + 2 + 1) \ + 2*(17 + 5 + 2 + 1) \ + NUM_TIMEDATE_FRAGS*(15 + TOKEN + 2 + 1) /* Latlon table allows 12 keywords (max size 16), 12 values, and, */ /* for each keyword/variable pair, 2 separators and a blank. */ /* The values can be single characters, formats, or variable names */ #define NUM_LATLONPARAMS 12 #if MAXVARNAMESIZE > MAXLATLONFORMATSIZE #define MAXLATLONVALUESIZE MAXVARNAMESIZE #else #define MAXLATLONVALUESIZE MAXLATLONFORMATSIZE #endif #define LATLON_WJSTBL NUM_LATLONPARAMS*(16 + MAXLATLONVALUESIZE +2 +1)