#!/usr/local/bin/perl -w { # timecnv_driver.pl WJS Sep 97 # Basic job is to copy .shtml form to stdout. While doing so, it # inserts some environment stuff as hidden variables, so that timecnv.pl, # the form's submit routine, can have them. It also creates a unique # id for temp files used in this connection, and passes that along. # It also "handles" the .shtml file's #include statements, while ignoring # #execs $version = "timecnv_driver.pl version 1.0 24 Sep 1997"; ### require ("cgi-lib.pl"); $debug = 0; $unique = $$; #### # Nonstandard configuration in effect as of 24 Sep 97 # util_dir # listvar #### # Directories $jgofs_root = "/data/globec"; $tmpdir="/tmp"; $util_dir = "/export/home/wsass"; # Where parse_info stuff is; = bin_dir? $bin_dir = "$jgofs_root/bin"; # Where listvar is $html_dir = "."; # Where timecnv.shtml lives # Programs ### $listvar = "$bin_dir/listvar"; $listvar = "/export/home/wsass/listvar"; $parse_path_info = "$util_dir/parse_path_info"; # Data files $listvar_file = "$tmpdir/timecnv_$unique.listvar"; $html_file = "$html_dir/timecnv.shtml"; # #include values in timecnv.shtml that we will deal with. Anything # not on this list makes us issue an error $listvar_key = "timecnv.varlist"; $object_key = "timecnv.objectname"; $hidden_key = "timecnv.hidden"; ### if (-e $tmpdir) { if (! -d $tmpdir) { &CgiDie ($version,"$tmpdir is not a directory\n") } if (! -w $tmpdir) { &CgiDie ($version, "Cannot create files in directory $tmpdir\n") } } else { mkdir ($tmpdir,0777) || &CgiDie($version,"Cannot create directory $tmpdir : $!\n"); } # Get object out of PATH_INFO %path_info = ( split(/[,=]/,`$parse_path_info`) ); ($? == 0) || &CgiDie ($version,"$parse_path_info exited w/code $?\n"); ($obj = $path_info{"object"}) || &CgiDie($version,"No object information reached this program\n"); # Get list of variables into temp file. This list will also be used # by timecnv.pl, so don't alter format w/o changing that program # -a switch requires listvar 1.2. Putting it last allows the # command to work w/old versions of listvar (except of course that # you don't get attributes...) $listvar_commands = "/bin/csh -c " . "\"(" . "unsetenv PATH_INFO" . ";" . $listvar . " " . $obj . " -a" . ")\""; $debug && print "$listvar_commands\n"; open (FILE,"$listvar_commands | ") || &CgiDie ($version,"Bad pipe open/read $listvar_commands : $!\n"); open (OUTFILE,"+> $listvar_file") || &CgiDie ($version,"Cannot write $listvar_file : $!\n"); while () { $debug && print "$_"; # If record leads off with &x, we have a listvar error, so die if (/^&x/) { close FILE; close OUTFILE; &CgiDie ($version,"listvar died: $_"); } print OUTFILE $_; } # If tempted to do error checking on close (since that gives status # of pipe command), note that listvar seems to exit w/29 (Illegal seek) # after what seemed to be a good listvar... close FILE; ### print &PrintHeader(); # Copy .shtml file to stdout, detecting and acting on #include # directives open (FILE,$html_file) || &CgiDie($version,"Cannot read $html_file : $!\n"); while () { # Look for