/* list.h */ #define LISTH_VERSION "list.h version 1.6 21 Mar 2009" /* 21 Mar 09. WJS 1.6 */ /* Reset EOF to ^D for Solaris */ /* 14 Mar 09. WJS 1.6 */ /* Define terminal setup/reset for linux */ /* 3 Aug 08. WJS 1.5 */ /* DEFAULT_ERR_PREFIX */ /* 20 Jul 06. WJS 1.4 */ /* INCLUDE_ATTRIBUTES_SWITCH */ /* 4 Feb 04. WJS 1.3a */ /* Define FULL_LISTH_VERSION to include core.h version */ /* Make #include'rs of this file "get" FULL_LISTH_VERSION into the */ /* binary (by referencing it in a char buf[]=FULL_LISTH_VERSION */ /* or some such) */ /* 17 Dec 03. WJS 1.3 */ /* MAXVARNAMESIZE */ /* Get rid of NVALS in favor of getting NVAR from inner.h */ /* 12 Dec 03. WJS 1.3 */ /* #include "core.h" - shortens this considerably */ /* 10 Oct 03. WJS 1.2 */ /* STDOUT_NAME */ /* 3 Oct 03. WJS 1.1 */ /* #include */ /* Let's not give "Bad Object:" style error messages */ #include "core.h" #define FULL_LISTH_VERSION LISTH_VERSION"/"COREH_VERSION #include INNEROPTIONS #if PC #define getchar getch #endif #if ! PC #include #endif /* Status for exiting program */ /* Must be something like this in some .h file, but don't know where */ /* Found a reference to EXIT_SUCCESS & EXIT_FAILURE. Hmmm */ /* Note that we are using "high" values (near 255) to represent */ /* jdb errors, so don't use these here... */ #ifdef EXIT_SUCCESS #define OK_EXIT EXIT_SUCCESS #else #define OK_EXIT 0 #endif #ifdef EXIT_FAILURE #define ERROR_EXIT EXIT_FAILURE #else #define ERROR_EXIT 1 #endif /* Idea is to save errno, have something act when */ /* this happens, and then note that action has been taken. INIT & */ /* POST must therefore not conflict w/any errno (or stop commenting */ /* and use a flag variable separate from a saved errno variable) */ /* All un#defined values for status are interpreted as errnos */ #define OFILE_STATUS_INIT -1 #define OFILE_STATUS_POST_ERR -2 /* The fooling w/DATUMSIZE is probably dumb, but it IS historically */ /* consistent */ #define MIN_DATUMSIZE 120 #ifdef DATUMSIZE #if DATUMSIZE < MIN_DATUMSIZE #undef DATUMSIZE #endif #endif #ifndef DATUMSIZE #define DATUMSIZE MIN_DATUMSIZE #endif #if PC #define CR '\r' #else #define CR '\n' #endif #define SPACE ' ' #define DEFAULT_OSEP ',' #define DEFAULT_SUBSTITUTE_MISSING_VALUE "-9999.0" #define DEFAULT_ERR_PREFIX "***LISTERR*** " #define DEFAULT_FIELD_WIDTH 7 #define SCREEN_COLS 80 #define SCREEN_ROWS 24 /* Original list did an unconditional /bin/stty opost at exit */ /* despite not setting -opost at the beginning. As of Feb 02, do */ /* not understand opost matter. WJS */ /* Inference from "Porting UNIX" book: terminal data structure */ /* uses same location for icanon/EOF and -icanon/MIN values ... */ /* sometimes. Empirically verified on globec's Solaris - IRIX et al */ /* commands below left Solaris EOF at ^A. Altering min to 5 left */ /* Solaris EOF to ^E. Did not happen on fleetlink's linux. */ /* Proper soln is to change code to save everything before going */ /* -icanon and restoring that set of values instead of just icanon */ /* Proper soln would be some work, and runs up against cross-OS */ /* issues where we don't have test platforms. Let's hear it for */ /* cheap ameliorations! WJS Mar 09 */ #if SUN || ULTRIX char *setup_term_command = "/bin/stty cbreak"; char *reset_term_command = "/bin/stty -cbreak opost"; #elif IRIX || IBM || OSF || HP || LINUX char *setup_term_command = "/bin/stty -icanon min 1 time 0"; char *reset_term_command = "/bin/stty icanon opost"; #elif SOL char *setup_term_command = "/bin/stty -icanon min 1 time 0"; char *reset_term_command = "/bin/stty icanon eof \\^D opost"; #elif VMS char *setup_term_command = "SET TERM/PASTHRU"; char *reset_term_command = "SET TERM/NOPASTHRU"; #else char *setup_term_command = ""; char *reset_term_command = ""; #endif /* Buffer sizing considerations. */ /* 1) Although the name and value buffers are logically different */ /* sizes, we use them to hold right-justified fields, and we */ /* right justify both to the same size. Accordingly the */ /* buffers need to be the same size (or the application needs */ /* to be recoded from "right justify all, output all" logic */ /* to "right justify 1, output 1" logic which would permit 1 */ /* buffer, reused for every right-justified field) */ /* 2) We append the attribute string to the name in the name */ /* buffer before right justifying, so the buffer needs to be */ /* big enough for that */ /* 3) There is no logical connection between the output field */ /* width to which we are right justifying, and the data field */ /* width. For example, somebody could request that data */ /* fields that never exceed 10 bytes in size should always be */ /* displayed in 20 character fields. We don't know the widths */ /* until we call jdbopen, but we must supply jdbopen with a */ /* buffer. We should provide a temporary buffer big enough */ /* to hold the jdbopen data, find the widths, then dynamically */ /* allocate buffers of the correct size and copy the temp */ /* buffer into that. We don't do this. Aside from eating my */ /* hat if the max requested width exceeds this buffer size, we */ /* fail safe by leaving that column left justified */ /* 4) Each buffer needs to be at least DEFAULT_FIELD_WIDTH in */ /* size. They are. */ /* 5) The value buffer needs to be big enough to hold */ /* MISSING_VAL_NUMERIC. It is */ /* 6) DEFAULT_MAXOLEN is size of output line if dynamic sizing */ /* disabled and size of increment by which to increase buffer */ /* if dynamic sizing IS enabled. It must also be big enough */ /* to hold the object spec. */ #define DEFAULT_MAXOLEN 4096 #define OLEN_SANITY_LIMIT 10000000 #define MAXVALBUFSIZE DATUMSIZE + 1 #define MAXVARNAMESIZE VARNAMESIZE + 1 /* + 2 in next line is for the []s we add to bracket the attrib list */ #define MAXNAMEBUFSIZE MAXVARNAMESIZE + TOTATTRSIZE + 2 #if MAXVALBUFSIZE > MAXNAMEBUFSIZE #define BUFSIZE MAXVALBUFSIZE #else #define BUFSIZE MAXNAMEBUFSIZE #endif /* NOT_VALID (= neither TRUE nor FALSE) comes from core.h */ #define FLAG_UNDEFINED NOT_VALID #define DEFAULT_FFLAG 0 #define DEFAULT_RFLAG 0 #if DEFAULT_FFLAG != 0 && DEFAULT_RFLAG != 0 #error "Incompatible flag defaults" #endif /* INCLUDE_ATTRIBUTES_SWITCH controls whether or not the -a switch */ /* is honored. list 1.6 did not have this switch. The attribute */ /* list was always listed after/its variable. v 1.7 by default does */ /* NOT list the attributes, but implements the -a switch to revert to */ /* v 1.6 style. Code below defaults to v 1.6. A user who wants v 1.7 */ /* can change this code or specify */ /* -DINCLUDE_ATTRIBUTES_SWITCH=TRUE */ /* on the compilation for list */ /* A specification of -DINCLUDE_ATTRIBUTES_SWITCH is a synonym for */ /* the above; a spec of =FALSE forces 1.6 behavior */ #ifdef INCLUDE_ATTRIBUTES_SWITCH #if INCLUDE_ATTRIBUTES_SWITCH != TRUE && INCLUDE_ATTRIBUTES_SWITCH != FALSE #error "Invalid INCLUDE_ATTRIBUTES_SWITCH" #endif #else #define INCLUDE_ATTRIBUTES_SWITCH FALSE #endif