/* PROGRAM Handle a VMS Help request from a WWW client VMSHelpGate.c ** =========================================== ** PROGRAM FOR CGI/1.0 SCRIPTS TO GENERATE HTML ** RENDITIONS OF VMS HELP LIBRARY CONTENTS. ** Note that in the present absence of table ** support, PRE formatting is used to create ** multicolumn displays. The tab expansion ** functions cannot take into account any ** numbering of anchors performed by the client, ** so the displays will not be as intented when ** this gateway is used by the WWW LineMode ** browser, or by Lynx when set to "Numbered ** Links" mode. The PRE formatting assumes ** the client has an 80 column (or greater) ** display window in effect. ** FOR USE ON VMS. ** ** USAGE (called from a script, e.g., HelpGate.com): ** ** $ VMSHelpGate :== $device:[directory]VMSHelpGate.exe ** $ VMSHelpGate ! cern server ** $ VMSHelpGate method url protocol ! decthreads server. ** ** The symbol WWW_PATH_INFO is set by the httpd and holds ** the argument for the help library and module to be ** returned to the client as HTML. It should be of the ** form: /HELP[/@library][/topic[/subtopic...]] ** with the following in the httpd configuration file to ** set it up: ** ** map /help /htbin/helpgate/HELP ** map /help/* /htbin/helpgate/HELP/* ** exec /htbin/* /HTTPD_Dir/* ** ** If no "/@library" is specified, "/@SYS$HELP:HELPLIB" ** is assumed. ** ** The symbols WWW_HOST_ACRONYM for indicating the ** host (e.g., WFEB) in the TITLE, and WWW_COPYRIGHT_STRING ** for showing a copyright notice at the tops of displays, ** should be set by the script. ** ** The script should also set the following two symbols ** to "TRUE" or "FALSE" as desired. They default to "FALSE" ** if undefined. ** WWW_CREATE_REAL_LINKS determines if we create real links ** from links simply listed in HELP text. ** WWW_CREATE_HELP_LINKS determines if we create links to other ** HELP topics that are referenced. ** ** A couple of notes if you use the WWW_CREATE_HELP_LINKS code: ** * Just one space is allowed between HELP words. ** * Qualifiers are not supported (yet). ** * Hyphenated HELP topics (like HELP E-MAIL) where the ** hyphen is the last character on a line are unsupported. ** And if you use the WWW_CREATE_REAL_LINKS code, note that the ** URL is assumed to be contained all on one line. ** ** AUTHORS: ** JFG Jean-Francois Groff, CERN, Geneva jfg@info.cern.ch ** FM Foteos Macrides macrides@sci.wfeb.edu ** DLJ David L. Jones, Ohio State Univ. vman+@osu.edu ** JW Jim Winkle, Univ of Wisconsin-Madison jwinkle@doit.wisc.edu ** ** HISTORY: ** Originally written by JFG as a standalone gateway. ** Extensively modified by FM for use with HTTP/1.0 and ** CGI scripts. ** ** JFG's HISTORY: ** -------------- ** 1.1 26 Feb 92 (JFG) Enabled strange topics ** 1.0 7 Oct 91 (JFG) First release ** 0.4 2 Oct 91 (JFG) Handle help summary. Definitive address format : ** //node[:port]/HELP[/@library][/topic[/subtopic...]] ** 0.3 27 Sep 91 (JFG) Created from h2h.c ** ** (c) CERN WorldWideWeb project 1990-1992. See Copyright.html for details ** ** Current HISTORY: ** ---------------- ** 2.0 1 May 94 (FM) Polishing up my modifications, for general release. ** ** DLJ mods: ** -------------------- ** 5 May 95 Convert to support DECthreads scripting system ** (cgilib). Replace printfs with cgi_printf. ** 7 May 94 Replace WWW_HELP_DIR 'caching' with direct library ** access via VMS Librarian utility routines. ** ** 2.1 8 May 94 (FM) Adopted DLJ's mods for CERN server too, with minor ** fixes for spacing in PRE formatted sections, and bug ** fix in lbr_close() of lbrio.c which caused ACCIO due ** to bad argument in free() call. ** 11 May 94 (FM) Added fixes from DLJ for Alphas. ** 27 Jun 94 (FM) Fixes in anchor_strcpy() for current HELP library ** rules and escaping of any lead colon. Unescape ** it in main() if still present. ** DLJ mods: ** -------------------- ** 2 Jul 94 Make qualifers within a level anchors and include ** in them with hrefs in generated menus. This more ** more closely mimics DCL HELP. Use cleaner algorithm ** to determine line-breaks in menus. ** ** 3 Jul 94 Add hack to deal with bugs in mac-mosaicB6 and **
operations. ** ** 31 Oct 94 Escape '<', '>', and '&' in help text as per HTML spec. ** (No checks being done within anchors) ** ** 2 Aug 99 Make finickier check for module boundary. ** ** JW mods: ** -------------------- ** 2.2 13 Nov 96 Create real links to links simply listed in HELP text, ** and create links to other HELP topics referenced. */ #include#include #include #include #include #include "lbrio.h" /* direct library access *DLJ* */ #define TAB_SIZE 16 /* 11 is what DCL HELP uses. */ #define LINE_WIDTH 80 /* * For DECthreads, include the cgilib.h */ #ifdef NOCGILIB #define cgi_init(a,b) 1 #define cgi_info(a) getenv(strcpy(&cgi_info_buf[4], a)-4) static char cgi_info_buf[64] = { 'W', 'W', 'W', '_' }; #define cgi_printf printf #else #include "cgilib.h" #endif /** Headers taken from h2h.c **/ /* Maximum line size for buffers */ #define LSIZE 256 /* Maximum command line size for VMS */ #define CSIZE 256 /* Maximum VMS file name size (note that it's actually 49.49) */ #define FSIZE 80 /* Maximum anchor size */ #define ASIZE 80 /** Function declarations **/ int strcasecomp(char *, char *); int strncasecomp(char *, char *, int); char *anchor_strcpy(char *, char *); void show_copyright(void); int hlp_to_html(lbr_index, char *); int lis_to_html(lbr_index, char *); lbr_index open_hlp(char *, char *); static char *pre_start; /* either "/n " or "/n" (macmosaic) */ /***************************************************************************** main : Retrieve information from VMS help libraries or cached modules and convert to HTML "on the fly". Input : symbol WWW_PATH_INFO set by httpd : HT address ------------------------------------------------------------------------------*/ int main(int argc, char *argv[]) { char *arg; lbr_index hlp; /* lbr control structure *DLJ* */ char *help_file; char *query; char *s; char *cp; char *browser; /* User-agent field, DLJ */ int status; /* Initialize CGI library. */ status = cgi_init ( argc, argv ); if ( (status&1) == 0 ) exit ( status ); s = cgi_info ( "HTTP_USER_AGENT" ); /* * Hack to accomodate MacMosaic bug. Mosaic 1.0.3 ignores the first * LF it sees after going intomode while other browsers need the * line break before going into. Check for the faulty browser and * do the right thing. */ pre_start = "\n"; if ( s ) { browser = malloc ( strlen(s) + 1 ); strcpy ( browser, s ); for ( cp = browser; *cp; cp++ ) if (isspace(*cp) ) { *cp = '\0'; break; } /* fprintf(stderr,"browser: '%s'\n", browser ); */ if ( strcmp ( browser, "MacMosaicB6" ) == 0 ) pre_start = "\n"; } /* output the content type */ cgi_printf("Content-Type: text/html\n\n\n"); /* address must be of the form /HELP[/@library][/topic[/subtopic...]] */ if ((arg=cgi_info("PATH_INFO")) == NULL || (s = strtok (arg + 1, "/")) == NULL) { cgi_printf("Address should begin with /HELP arg=%d\n\n", arg); exit(0); } if (strcasecomp (s, "HELP")) { cgi_printf("Address should begin with /HELP : /%s\n