/* 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 1.5a 14 Jan 2000" /* 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] 8 Sep 99 v 1.4a WJS Add max level to alt tag of "next level" button Reverse /pre and /head commands in error_ per empirical evidence w/lynx & a Sun browser Don't prefix &x to messages that already start with it. Bug fix: attempted to print null string while diagnosing projection parse error [Never officially released. Used in test OO server defgb] 20 Apr 99 v 1.4 WJS Have error_ exit with 250 instead of 0 (!) [In general use on Bob's box; not on Chris'] [Needs outer.h 1.1] [Needs error_exit_defn.h] 13 Mar 99 v 1.4 WJS Flush output buffer at &r in case reading program doesn't want data Try to get outer.h version string into image [Needs outer_utils.c 1.0] [Needs path_info_routines 1.2 or later (.c & .h)] [Begin 1.4] 16 Dec 98 v 1.3a WJS Bug fix: logical vars need to be signed. Try to learn from v 1.2a!! Bug fix: compile-time OTHEROPTS was not being used as default for runtime PLOTLINK and vice versa. [General production release early 1999] [Released for beta test on synthesis 16 Dec 98] [Needs outer.h 1.0a] [Needs outer_utils.c 1.0] [Needs path_info_routines 1.2 or later (.c & .h)] [Begin 1.3a] 10 Dec 98 v 1.3 WJS Next-level links use string equality to determine what data at next level is displayed (unless GENERATE_ALPHA_SELECTIONS is turned off). Mods to "top" links 1) Add per-link display control 2) If at level 0, display "nolevel0" gif instead of "Level 0" link. 3) If at last level, display "nolevelN" gif instead of "Level N" link. 4) Use "Level N" for alternate text for next level button. 5) If TEST_GIFS defined, test for button gif existence before generating link to gif. If gif does not exist, display its "alt" text instead Mods to selection/projection code 1) String operations eq,ne,lt,le,gt,ge,contains,is_contained_in, begins_with,ends_with. (These ops typically delimited w/blanks - see trigram mod, below, for way to get blanks into query strings) 2) Parametrize stack size and increase. Still do not test for overflow 3) Do some restructuring & commenting. Remove need for a couple of compile-time constants Accept %hh trigram in selection strings and convert it to the (hopefully) ASCII character corresponding to the hex value of hh. To get a real percent sign in the query string, use %25. A leading 0 must be present, if appropriate; eg, use %09 for tab, not %9. Use iovaldouble_ function instead of iovalreal_ if USE_DOUBLE is defined as TRUE Dynamically allocate more buffers. Can remove PATHSIZE from .h file Calculate some buffer sizes. Can remove OUTVARBUFSIZE & OUTBUFSIZE from .h file More flexibility in BUTTONIMAGESDIR spec. Accept it with or without trailing /. If no protocol (ie, :// string), prepend file://localhost (with another / if necessary) Bug fix: was adding port even when MYADDR had port in it. Bug fix: remove blank btwn "Documentation" & "Plotting and Other Op" Bug fix: v 1.1 handling of query string w/blanks NG since htmlescape doesn't "do" blanks. Improper use of htmlescape anyway - it's designed to allow printing of text w/html special chars such that html formatting doesn't happen. Put htmlescape & some new routines in outer_utils.c Put lots of #defines, etc, in outer.h [Released for beta test on synthesis] [Needs outer.h 1.0] [Needs outer_utils.c 1.0] [Needs path_info_routines 1.2 or later (.c & .h)] [Begin 1.3] [Comments pre-v1.3 removed to outer_brev_revision.doc. WJS 11 Nov 99 */ /* =========================================== 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 */ /* All #includes in outer.h */ #include "outer.h" char outerh_version[]=OUTERH_VERSION; /* Get version into image */ typedef signed char Logical; /* NB: occasionally gets -1, */ /* hence need signed */ /* 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... */ char *htmlescape(); char *trigram(); char *un_trigram(); #if USE_DOUBLE #define ioval iovaldouble_ typedef double Comp_precision; #else #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; Logical test_gifs; char *buttonimagesdir; 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? */ /************************************************************************/ 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 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