/* outer_brev.c version 1.0 came from outer.c version 2.5, JGOFS 1.5 release (as of 10 Jan 98). Incompatibilities 1) outer_brev variable names may not include spaces or percent signs. 2) Non-numeric data values (including "nd") cannot be selected with numeric operators 3) When clicking on a datum to use it as a selection for the next level, comparisons are done as strings instead of numbers 4) Rely on program exit to free dynamically allocated memory */ #define OUTER_VERSION "outer_brev version 2.1 12 Jul 2006" /* 12 Jul 06 v 2.1 WJS BACKGROUND_COLOR; DISPLAY_DATA_URL. Per Bob by request from NEC project Results in adding
& tags even if new stuff isn't spec'd 20 Oct 05 v 2.1 WJS Bug fix: didn't properly handle escaped chars 6 Oct 05 v 2.1 WJS Add "like" string comparison function Add upper-cased version of string comparison functions to do case-blind comparisons parse used to add a $ to selection strings as a non-null to indicate string end. Seems to me that this would conflict if we actually searched for a $, so switch it to something binary (and check input string just in case) [Needs outer.h 1.4] [Begin 2.1] 23 Apr 04 v 2.0b WJS Mods to "version-returning function". a) change from local to global to ensure it can't be "optimized out" b) don't want "version" in any function name since such names appear when grep'ping for "version" 31 Mar 04 v 2.0b WJS Remove typedef Logical - now in core.h Comment mod to reflect that outer_utils now in jgofs.a 11 Feb 04 v 2.0b WJS Put int type on main to attempt to avoid compiler diagnostic [Needs outer.h 1.4] [Begin 2.0b] 29 Aug 03 v 2.0a WJS Bug fix: HAS_OUTER_INTEREST_ENTRY was considered true if specified as false (code just looked to see if it was defined) 10 Jul 03 v 2.0a WJS Improve formatting of text ID'ing compilation options in error msgs 26 Jun 03 v 2.0a WJS Bug fix: printed "truncating" after every line between brevend and EOF 9 Jan 03 v 2.0a WJS Need to be able to control ioexpress_outer_interest_ at least on a per- object basis. Add an env var, compilation default, etc Mod get_logical_val to return a parametrization for illegal instead of a constant. [Needs outer.h 1.3] [Begin 2.0a] 24 Dec 02 v 2.0 WJS Bug fix: when in .brev mode, inner is left hanging when outer stops reading. Problems range from number of unclosed files eventually hitting open file limit to inner's input not being properly positioned when outer asks for next record at level "above" the .brev level (consider situation where all levels are coming from same inner source - could be flat file or jgofs input object or...). outer must continue to read until EOF even if it doesn't want to display Support ioexpress_outer_interest_ entry. If inner has an entry of that name (controlled by HAS_OUTER_INTEREST_ENTRY compilation switch), set and reset flag to let inner know that outer does or doesn't want the next record. Idea is to have inner go to EOF when it knows outer doesn't want the rest of the info at that level. Insert info about some compilation options into image. Print it on occasion [Put on Bob's box as a testdefgb-otherwise unreleased] [Begin 2.0] 10 Jan 02 v 1.5b WJS Bug fix: parse adds a char to string it parses. Make sure there's room for it. [Begin 1.5b] 14 Jan 00 v 1.5a WJS Bug fix: error_ not prefixing messages w/ &x if in flat mode (has been this way since at least jgofs 1.5 outer - call it a design bug) If an error message already begins w/ &x, do not precede it w/ another. Formerly rule was, if an error message begins w/ "&x "... [Begin 1.5a] 12 Nov 99 v 1.5 WJS Bug fix: left trailing comma on level 0 button string 11 Nov 99 v 1.5 WJS Do level 0 button link properly. Problem is query string. We don't want selections/projections in level 0 button link, but we need inner's portion of the query string (eg; if math is the method, the first arg of the query string is the object math is working on. If we don't include that, link is wrong) Remove OO_OUTER switch since it is no longer useful. 13 Sep 99 v 1.5 WJS Add query string when setting up link to info server [Needs outer.h 1.2] [Needs error_exit_defn.h] [Needs outer_utils.c 1.0] [Needs path_info_routines 1.2 or later (.c & .h)] [Begin 1.5] [Comments pre-v1.5 removed to outer_brev_revision.doc. WJS 9 Jan 03] */ /* =========================================== Subroutines required: =========================================== */ int ioopen_(); /* int ioopen_(s,nparams,ntotal) char s[][]; int *nparams,*ntotal; s[0..nparams-1]: parameter strings. Inner sets s[j][0]=0 for any strings which it processes; others will be processed by outer. Thus selection/projections would normally be ignored by inner. nparams: number of parameter strings ntotal (returned): total number of variable names */ int ioreadrec_(); /* int ioreadrec_(level) int *level; Read record at appropriate level. Return 0 if end at that level. Return 1 if ok. */ void ioclose_(); /* ioclose_() Close files Note: this routine should NOT call error_ */ void iovalreal_(); /* iovalreal_(vn,f) int *vn; float *f; Return real value (f) for variable indexed by vn. -9999 for strings */ void iovalstr_(); /* iovalstr_(vn,tmp) int *vn; char *tmp; Return string value (tmp) for variable indexed by vn. */ int iovarlevel_(); /* int iovarlevel_(vn) int *vn; Return level corresponding to variable indexed by vn. */ int ioattrout_(); /* ioattrout_(vn, str) int *vn; char *str; Output next attribute for variable indexed by vn. 0=none left. */ void ioname_(); /* ioname_(vn,s) int *vn; char *s; Return name (s) corresponding to variable number vn. */ int iowidth_(); /* int iowidth_(vn); int *vn; Return length of variable field indexed by vn. */ int iocommout_(); /* int iocommout_(s) char *s; Return next comment string. 0=none left. -1=next comment contains a URL */ #ifndef HAS_OUTER_INTEREST_ENTRY #define HAS_OUTER_INTEREST_ENTRY FALSE #endif #if HAS_OUTER_INTEREST_ENTRY #define OUTER_COMPILATION_OPTION_INTEREST "compiled to use ioexpress_outer_interest_ entry" int ioexpress_outer_interest_(); /* int ioexpress_outer_interest_(flag) int flag; Use flag (TRUE/FALSE as of v 2.0) to tell inner if we want next record from ioreadrec_ or if we have no more interest in this level Get back indicator (unused; TRUE/FALSE as of v 2.0) if inner can respond to a flag of FALSE by somehow ending its own input */ #else #define OUTER_COMPILATION_OPTION_INTEREST "compiled to ignore any ioexpress_outer_interest_ entry" #endif /* All #includes in outer.h */ #include "outer.h" /* jgofs.a functions... */ /* HTDoConnect in turn requires some functions, presently found */ /* jgofs.a. Some are HT*.c modules; a couple are in jdb.c */ /* These functions needed only for testing for gifs, which is turned */ /* off by default. However, can't eliminate these defns based on */ /* compile-time TEST_GIFS, since user can spec tests at run time */ /* (only useful time, if functionality useful at all). */ /* If requiring these functions causes trouble (eg, no jgofs.a), */ /* should unconditionally set test_gifs to false. Suggest testing */ /* it first, and aborting if true (on grounds that somebody appears */ /* to want gifs tested, and we're not about to do it) */ int HTDoConnect(); int HTDoRead(); /* outer_utils.c functions (in jgofs.a as of ~Apr 04) */ char *htmlescape(); char *trigram(); char *un_trigram(); #if USE_DOUBLE #define OUTER_COMPILATION_OPTION_USE_DOUBLE "compiled to use iovaldouble_ entry" #define ioval iovaldouble_ typedef double Comp_precision; #else #define OUTER_COMPILATION_OPTION_USE_DOUBLE "compiled to use iovalreal_ entry" #define ioval iovalreal_ typedef float Comp_precision; #endif void ioval(); int ntotal; int minlevel; int maxlevel; int reqlevel; int maxobjectlevel; int cl; int brevflag=0; int htmlflag=0; int flatflag=0; int *level=NULL; int brevstart; int brevcount; int brevend; /* PATH_INFO stuff. Functions are in path_info_routines */ char *flat_PATH_INFO,*nextlevel_PATH_INFO,*level0_PATH_INFO; char *no_extURL_PATH_INFO,*full_list_PATH_INFO; char *propagate_brev_no_extURL_PATH_INFO; char *make_PATH_INFO_putenv_string(),*get_jgofs_env_datum(); int get_level(); static char *outnames=NULL; char *parsav; char *QUERY_STRING_no_selections; char *objsav; Logical dirlink,doclink,plotlink,lev0link,levnlink,flatlink; Logical quotenolink,toplinks,otheropts,oo_outer,brev_optimize_inner_calls; Logical test_gifs; Logical display_data_url; char *buttonimagesdir; char *background_color; Logical trailing_buttonimagesdir_slash; /* Format of "server" is node (optionally w/port), followed by cgi */ /* program name. Program name by itself can be used if we know */ /* that node is local. A node spec does not include a leading // */ /* (but we'll strip them off found) */ char *dirserver_w_dir; char *optionserver; char *infoserver_w_obj,*infoserver_extURL; char *dataserver,*localnodeport; char *equality_test; /* Links generate string or numeric test? */ /************************************************************************/ char *outer_return_vers() /* Dummy routine. Exists only to force .h file version string into */ /* this module. Note string must not be global or we'll have con- */ /* flicts if another routine similarly includes the version string */ { static char version[] = OUTER_VERSION"/"FULL_OUTERH_VERSION; return version; } void error_(s1,s2) char *s1,*s2; { char *prefix; if(htmlflag){ printf("%s: %s
");
print_vert_bar (NULL,TRUE);
}
}
if (lev0link) {
if (maxlevel == 0) {
ptr = " - At level 0 - ";
ptr1 = gifs[NOLEVEL0_GIF];
print_vert_bar (ptr1,FALSE);
printf("");
} else {
ptr = "Level 0";
ptr1 = gifs[LEVEL0_GIF];
print_vert_bar (ptr1,FALSE);
/* Level 0 button gets query string w/o selections/projections */
/* I still don't know why it doesn't keep any "original" se- */
/* lections/projections, but we certainly don't want any */
/* "clicked-on" selections. See comments up top for dis- */
/* cussion of preservation of inner's args */
/* QUERY_STRING_no_selections may be \0; has its own ? */
/* if needed */
printf ("",
JGOFS_DATA_CGI_SPEC, level0_PATH_INFO, QUERY_STRING_no_selections);
free(QUERY_STRING_no_selections);
}
tag_toplink(ptr, ptr1);
}
if (levnlink) {
if (maxlevel < maxobjectlevel) {
ptr = next_level;
ptr1 = gifs[LEVELN_GIF];
print_vert_bar (ptr1,FALSE);
printf ("",
JGOFS_DATA_CGI_SPEC, nextlevel_PATH_INFO, parsav);
sprintf(next_level,"Level %d (of %d)",maxlevel+1,maxobjectlevel);
} else {
ptr = " - At last level - ";
ptr1 = gifs[NOLEVELN_GIF];
print_vert_bar (ptr1,FALSE);
printf("");
}
tag_toplink(ptr, ptr1);
}
if (flatlink) {
print_vert_bar (gifs[FLAT_GIF],FALSE);
printf ("",
JGOFS_DATA_CGI_SPEC, flat_PATH_INFO, parsav);
tag_toplink("Flat list", gifs[FLAT_GIF]);
}
/* If we are displaying buttons, " comment, above) */
if (any_buttons_on_line_1 || any_buttons_on_line_2) printf("
" (whatever that is) */
/* I wonder if this should also happen in a NOTOPLINKS environment */
/* (See
");
printf("\n");
printf("\n");
print_comments_html();
/* look at attributes to create array of widths - see ioattrout_ */
for(j=0; j%*s",
JGOFS_DATA_CGI_SPEC, nextlevel_PATH_INFO,
parsav, comma, outnames+j*VARNAMEBUFSIZE, equality_test, ptr,
tmp,
field_width-len_datum+2, " "
);
free (ptr);
}
else printf("%-*s ",field_width,tmp);
}
printf("\n");
return;
}
void print_full_list_link (s)
char *s;
{
#define BREVLINKINDENT 16
printf ("%*s%s\n",BREVLINKINDENT," ",s);
printf ("%*sFull data listing\n",
BREVLINKINDENT, " ", JGOFS_DATA_CGI_SPEC, full_list_PATH_INFO, parsav);
return;
}
Logical outputhtml(firsttime)
Logical firsttime;
{
/* linecount (only for abbreviated listing feature) */
static int linecount;
int i,j;
/* minlevel != maxlevel for first record of each maxlevel file */
/* in a multilevel display */
if (minlevel