Many improvements and bug fixes.
authorAdam Dickmeiss <adam@indexdata.dk>
Wed, 8 Nov 1995 16:14:32 +0000 (16:14 +0000)
committerAdam Dickmeiss <adam@indexdata.dk>
Wed, 8 Nov 1995 16:14:32 +0000 (16:14 +0000)
First version that ran on dtbsun.

12 files changed:
www/Makefile
www/mquery.egw
www/msearch.egw
www/mtargets.egw
www/query.egw
www/search.egw
www/showfull.egw
www/targets.egw
www/wcgi.c
www/wtcl.c
www/z39util.tcl
www/ztargets.conf

index beb9aeb..b522a08 100644 (file)
@@ -2,7 +2,11 @@
 # Europagate, 1995
 #
 # $Log: Makefile,v $
-# Revision 1.11  1995/11/07 14:56:58  adam
+# Revision 1.12  1995/11/08 16:14:32  adam
+# Many improvements and bug fixes.
+# First version that ran on dtbsun.
+#
+# Revision 1.11  1995/11/07  14:56:58  adam
 # Work on search in multiple targets.
 # New wtcl command: wlog.
 # Optional timeout parameter to zwait.
@@ -46,7 +50,7 @@ SHELL=/bin/sh
 ZDEFS=
 ZINC=-I../../yaz/include
 ZLIB=../../yaz/lib/libyaz.a
-MOSILIB=../../xtimosi/src/libmosi.a ../../yaz/lib/librfc.a
+#MOSILIB=../../xtimosi/src/libmosi.a ../../yaz/lib/librfc.a
 LIBIRTCL=/usr/local/lib/libirtcl.a $(ZLIB) $(MOSILIB)
 #
 OLIB=../lib/util.a ../lib/libres+log.a 
@@ -80,7 +84,8 @@ $(TPROG1): $(P1)
        $(CC) $(CFLAGS) -o $(TPROG1) $(P1) $(OLIB)
 
 $(TPROG2): $(P2)
-       $(CC) $(CFLAGS) -o $(TPROG2) $(P2) $(OLIB) $(LIBIRTCL) $(TCLLIB) -lm
+       $(CC) $(CFLAGS) -o $(TPROG2) $(P2) $(OLIB) $(LIBIRTCL) \
+               $(NETLIB) $(TCLLIB) -lm
 
 $(TPROG3): $(P3)
        $(CC) $(CFLAGS) -o $(TPROG3) $(P3) $(OLIB)
@@ -93,9 +98,10 @@ install.prog: $(TPROG1) $(TPROG2)
                cp $$x $(CGIBIN); \
                chmod +x $(CGIBIN)/$$x; \
        done; \
-       ln -f $(CGIBIN)/$(TPROG2) $(CGIBIN)/egwtcl; \
-       ln -f $(CGIBIN)/$(TPROG2) $(CGIBIN)/egwirtcl; \
-       ln -f $(CGIBIN)/$(TPROG2) $(CGIBIN)/egwhtml
+       for p in egwtcl egwirtcl egwhtml; do \
+               rm -f $(CGIBIN)/$$p; \
+               ln $(CGIBIN)/$(TPROG2) $(CGIBIN)/$$p; \
+       done
 
 install.script:
        @for x in $(WSCRIPTS); do \
index 27e6e32..051dc91 100644 (file)
@@ -4,7 +4,7 @@
 </head>
 <body>
 {
-# $Id: mquery.egw,v 1.1 1995/11/07 14:56:58 adam Exp $
+# $Id: mquery.egw,v 1.2 1995/11/08 16:14:32 adam Exp $
 
     if {[info commands saveState] == ""} {
         source z39util.tcl
@@ -14,7 +14,7 @@
     global nextSetNo
     global hist
 
-    html {<form action="http://} $env(SERVER_NAME) $env(SCRIPT_NAME)
+    html {<form action="http:} $env(SCRIPT_NAME)
     html / $sessionId {/msearch.egw/} $setNo {" method=post>} \n
 
     if {[catch {set setNo $nextSetNo}]} {
@@ -74,7 +74,7 @@ and will continue to be so until the end of December 1995.</em>
 <hr>
 
 {
-    html {<a href="http://} $env(SERVER_NAME) $env(SCRIPT_NAME)
+    html {<a href="http:} $env(SCRIPT_NAME)
     html / $sessionId {/mtargets.egw"> New target </a>}
 }
 {
index 1d1238e..7f41697 100644 (file)
@@ -1,6 +1,6 @@
 <html>
 {
-# $Id: msearch.egw,v 1.1 1995/11/07 14:56:58 adam Exp $
+# $Id: msearch.egw,v 1.2 1995/11/08 16:14:33 adam Exp $
 
     if {[info commands saveState] == ""} {
         source z39util.tcl
@@ -63,9 +63,9 @@
 
 <hr>
 {
-    html {<a href="http://} $env(SERVER_NAME) $env(SCRIPT_NAME)
+    html {<a href="http:} $env(SCRIPT_NAME)
     html / $sessionId {/mtargets.egw"> New target </a>} " | \n"
-    html {<a href="http://} $env(SERVER_NAME) $env(SCRIPT_NAME)
+    html {<a href="http:} $env(SCRIPT_NAME)
     html / $sessionId {/mquery.egw/} $host + $setNo {"> New query </a>}
 }
 
index 6c91b03..095aa8a 100644 (file)
@@ -1,6 +1,6 @@
 <html>
 {
-# $Id: mtargets.egw,v 1.2 1995/11/07 14:56:58 adam Exp $
+# $Id: mtargets.egw,v 1.3 1995/11/08 16:14:33 adam Exp $
     set setNo 1
     source /usr/local/etc/httpd/conf/ztargets.conf
     if {[info commands saveState] == ""} {
@@ -15,7 +15,7 @@
 <hr>
 <h3>Choose one or more Z39.50 targets:</h3>
 {
-    html {<form action="http://} $env(SERVER_NAME) $env(SCRIPT_NAME)
+    html {<form action="http:} $env(SCRIPT_NAME)
     html / $sessionId {/mquery.egw/} $setNo {" method=post><br>} \n
     foreach t [array names targets] {
         html {<input type="checkbox" name="target" value="} $t
index 8f816be..e2f9468 100644 (file)
@@ -4,7 +4,7 @@
 </head>
 <body>
 {
-# $Id: query.egw,v 1.10 1995/11/08 12:42:17 adam Exp $
+# $Id: query.egw,v 1.11 1995/11/08 16:14:33 adam Exp $
 
     if {[info commands saveState] == ""} {
         source z39util.tcl
@@ -55,10 +55,16 @@ proc ok-response {} {
             html "</body></html>\n"
             wabort
         } elseif {$sessionWait == 0} {
-            zwait sessionWait
+            if {[catch {zwait sessionWait 30}]} {
+                html "Cannot connect to target ${host} <br>\n"
+                html "</body></html>\n"
+               z39 disconnect
+                wabort
+            }
             if {$sessionWait != 1} {
                 html "Cannot connect to target ${host} <br>\n"
                 html "</body></html>\n"
+               z39 disconnect
                 wabort
             }
         }
@@ -69,7 +75,11 @@ proc ok-response {} {
             htmlr "</body></html>"
             wabort
         }
-        zwait sessionWait
+        if {[catch {zwait sessionWait 60}]} {
+            htmlr "Cannot initialize with target ${host} <br>"
+            htmlr "</body></html>"
+            wabort
+       }       
         if {$sessionWait != "1"} {
             htmlr "Cannot initialize with target ${host} <br>"
             htmlr "</body></html>"
@@ -78,7 +88,7 @@ proc ok-response {} {
     }
     set databases [lindex $targets($host) 1]
 
-    html {<form action="http://} $env(SERVER_NAME) $env(SCRIPT_NAME)
+    html {<form action="http:} $env(SCRIPT_NAME)
     html / $sessionId {/search.egw/} $setNo {" method=post>} \n
     set nodb [llength $databases]
     if {$nodb > 1} {
@@ -126,7 +136,7 @@ proc ok-response {} {
 }
 <hr><p>
 Alternatively you can enter your query in
-<a href="ccl.html"> CCL </a> here: <br>
+<a href="http://www.dtv.dk/ccl.html"> CCL </a> here: <br>
 <input type=text name="cclentry" size=52> <br>
 <hr>
 <h3> Various technical parameters: </h3> <br>
@@ -150,7 +160,7 @@ and will continue to be so until the end of December 1995.</em>
 <hr>
 
 {
-    html {<a href="http://} $env(SERVER_NAME) $env(SCRIPT_NAME)
+    html {<a href="http:} $env(SCRIPT_NAME)
     html / $sessionId {/targets.egw"> New target </a>}
 }
 {
index ebd2e66..21af854 100644 (file)
@@ -1,6 +1,6 @@
 <html>
 {
-# $Id: search.egw,v 1.10 1995/11/08 12:42:17 adam Exp $
+# $Id: search.egw,v 1.11 1995/11/08 16:14:33 adam Exp $
 
 proc buttons {setNo setMax startPos} {
     global sessionId
@@ -9,12 +9,12 @@ proc buttons {setNo setMax startPos} {
 
     html "<p>\n"
     if {$setMax < [z39.$setNo resultCount]} {
-        html {<a href="http://} $env(SERVER_NAME) $env(SCRIPT_NAME)
+        html {<a href="http:} $env(SCRIPT_NAME)
         html / $sessionId {/search.egw/} $setNo + [expr $setMax + 1]
         html + [expr $setMax + $hist($setNo,maxPresent)] {"> Next </a>} "| \n"
     }
     if {$startPos != "" && $startPos != "1"} {
-        html {<a href="http://} $env(SERVER_NAME) $env(SCRIPT_NAME)
+        html {<a href="http:} $env(SCRIPT_NAME)
         html / $sessionId {/search.egw/} $setNo 
         if {[expr $startPos - $hist($setNo,maxPresent)] > 1} {
             html + [expr $startPos - $hist($setNo,maxPresent)]
@@ -22,9 +22,9 @@ proc buttons {setNo setMax startPos} {
         }
         html {"> Prev </a>} "| \n"
     }
-    html {<a href="http://} $env(SERVER_NAME) $env(SCRIPT_NAME)
+    html {<a href="http:} $env(SCRIPT_NAME)
     html / $sessionId {/targets.egw"> New target </a>} " | \n"
-    html {<a href="http://} $env(SERVER_NAME) $env(SCRIPT_NAME)
+    html {<a href="http:} $env(SCRIPT_NAME)
     html / $sessionId {/query.egw/} $hist($setNo,host) + $setNo 
     html {"> New query </a>} "<p>\n"
 }
@@ -37,13 +37,12 @@ proc buttons {setNo setMax startPos} {
     global setNo
     global hist
 
-    set oldHost $hist($setNo,host)
-
     if {[wform menu1] == ""} {
         set setNo [lindex $sessionParms 0]
     } else {
         if {![info exists hist($nextSetNo,host)]} {
-           set hist($nextSetNo,host) $oldHost
+            set hist($nextSetNo,idAuthentication) $hist($setNo,idAuthentication)
+            set hist($nextSetNo,host) $hist($setNo,host)
         }
         set setNo $nextSetNo
         html "using host " $hist($setNo,host) " <br\n"
index 0e0c228..c2d11ce 100644 (file)
@@ -1,6 +1,6 @@
 <html>
 {
-# $Id: showfull.egw,v 1.5 1995/11/08 12:42:17 adam Exp $
+# $Id: showfull.egw,v 1.6 1995/11/08 16:14:34 adam Exp $
 
 proc buttons {setNo no} {
     global sessionId
@@ -9,23 +9,23 @@ proc buttons {setNo no} {
 
     html "<p>\n"
     if {$no < [z39.$setNo resultCount]} {
-        html {<a href="http://} $env(SERVER_NAME) $env(SCRIPT_NAME)
+        html {<a href="http:} $env(SCRIPT_NAME)
         html / $sessionId {/showfull.egw/} $setNo + [expr $no + 1]
         html {"> Next </a>} "| \n"
     }
     if {$no > 1} {
-        html {<a href="http://} $env(SERVER_NAME) $env(SCRIPT_NAME)
+        html {<a href="http:} $env(SCRIPT_NAME)
         html / $sessionId {/showfull.egw/} $setNo + [expr $no - 1]
         html {"> Prev </a>} "| \n"
     }
-    html {<a href="http://} $env(SERVER_NAME) $env(SCRIPT_NAME)
+    html {<a href="http:} $env(SCRIPT_NAME)
     html / $sessionId {/search.egw/} $setNo + 1
     html + [expr $hist($setNo,maxPresent) - 1]
     html {"> Result </a>} "| \n"
        
-    html {<a href="http://} $env(SERVER_NAME) $env(SCRIPT_NAME)
+    html {<a href="http:} $env(SCRIPT_NAME)
     html / $sessionId {/targets.egw"> New target </a>} " | \n"
-    html {<a href="http://} $env(SERVER_NAME) $env(SCRIPT_NAME)
+    html {<a href="http:} $env(SCRIPT_NAME)
     html / $sessionId {/query.egw/} $hist($setNo,host) + $setNo 
     html {"> New query </a>} "<p>\n"
 }
index cf0232c..366e502 100644 (file)
@@ -1,6 +1,6 @@
 <html>
 {
-# $Id: targets.egw,v 1.6 1995/11/08 12:42:17 adam Exp $
+# $Id: targets.egw,v 1.7 1995/11/08 16:14:34 adam Exp $
     source /usr/local/etc/httpd/conf/ztargets.conf
     if {[info commands saveState] == ""} {
         source z39util.tcl
@@ -27,7 +27,7 @@ Consejo Superior de Investigaciones Cient&iacute;ficas <br>
 <dl>
 {
     foreach t [array names targets] {
-        html {<dt><a href="http://} $env(SERVER_NAME) $env(SCRIPT_NAME) /
+        html {<dt><a href="http:} $env(SCRIPT_NAME) /
         html "$sessionId/query.egw/$t" {"> } [lindex $targets($t) 0] " </a>\n"
         set desc [lindex $targets($t) 4]
         if {$desc != ""} {
index 3a4dec6..be3cb96 100644 (file)
  * USE OR PERFORMANCE OF THIS SOFTWARE.
  *
  * $Log: wcgi.c,v $
- * Revision 1.7  1995/11/08 12:42:18  adam
+ * Revision 1.8  1995/11/08 16:14:35  adam
+ * Many improvements and bug fixes.
+ * First version that ran on dtbsun.
+ *
+ * Revision 1.7  1995/11/08  12:42:18  adam
  * Added descriptive text field in target info.
  * Added authentication field in target info.
  *
@@ -119,6 +123,7 @@ static int spawn (char *sprog, int id)
        case 0: 
             close (0);
             close (1);
+           close (2);
             gw_log (GW_LOG_DEBUG, prog, "execl %s", path);
             execl (path, sprog, 0); 
             gw_log (GW_LOG_FATAL|GW_LOG_ERRNO, prog, "execl %s", path);
@@ -140,6 +145,7 @@ int main()
     char combuf[COMBUF];
     int linein = -1, lineout, data, gw_id;
 
+    chdir ("/usr/local/etc/httpd/cgi-bin");
     gw_log_init ("egw");
     gw_log_file (GW_LOG_ALL, "/usr/local/etc/httpd/logs/egwcgi_log");
     gw_log_level (GW_LOG_ALL);
@@ -260,10 +266,22 @@ int main()
     *(p++) = '\0';               /* no envvars tranferred at present */
     if ((t = getenv("CONTENT_LENGTH")) && (data = atoi(t)) > 0)
     {
-       if (read(0, p, data) < data)
-       {
-           gw_log (GW_LOG_FATAL, prog, "Failed to read input");
-           fatal("Internal error in server");
+        int j, i = 0;
+        while (i < data)
+        {
+           j = read(0, p + i, data - i);
+            if (j == -1)
+            {
+               gw_log (GW_LOG_ERRNO|GW_LOG_FATAL, prog,
+                        "Failed to read input");
+               fatal("Internal error in server");
+            }
+            else if (j == 0)
+            {
+               gw_log (GW_LOG_ERRNO, prog, "Failed to read input");
+               fatal("Internal error in server");
+            }
+            i += j;
        }
     }
     p += data;
@@ -283,7 +301,7 @@ int main()
     }
     gw_log (GW_LOG_DEBUG, prog, "Reading response");
 
-#if 0
+#if 1
     while ((data = read(linein, combuf, COMBUF)) > 0)
     {
         gw_log (GW_LOG_DEBUG, prog, "Got %d bytes", data);
index bb2c34d..fc641f9 100644 (file)
  * USE OR PERFORMANCE OF THIS SOFTWARE.
  *
  * $Log: wtcl.c,v $
- * Revision 1.9  1995/11/07 14:57:00  adam
+ * Revision 1.10  1995/11/08 16:14:35  adam
+ * Many improvements and bug fixes.
+ * First version that ran on dtbsun.
+ *
+ * Revision 1.9  1995/11/07  14:57:00  adam
  * Work on search in multiple targets.
  * New wtcl command: wlog.
  * Optional timeout parameter to zwait.
@@ -270,6 +274,8 @@ static void *do_create (WCLIENT wcl, void *args)
 static void report_error (struct tcl_info *p, int errorLine,
                           const char *pre, const char *msg)
 {
+    if (!msg)
+        msg = "";
     gw_log (GW_LOG_WARN, mod, "%s %d %s", pre, errorLine, msg);
     wo_printf (p->wcl, "\n<br><hr>\n<strong>"
                "%s %d</strong><br>\n", pre, errorLine);
index 20fcec2..5c81b13 100644 (file)
@@ -1,5 +1,5 @@
 #
-# $Id: z39util.tcl,v 1.3 1995/11/08 12:42:18 adam Exp $
+# $Id: z39util.tcl,v 1.4 1995/11/08 16:14:36 adam Exp $
 #
 proc saveState {} {
     uplevel #0 {
@@ -8,15 +8,14 @@ proc saveState {} {
         if {$var == "f"} continue
         if {$var == "sessionId"} continue
         if {$var == "errorInfo"} continue
-       set names [array names $var]
-        if {$names != ""} {
+       if {[catch {set names [array names $var]}]} {
+            eval "set v \$${var}"
+            puts $f "set ${var} \{$v\}"
+        } else {
            foreach n $names {
                 eval "set v \$${var}(\$n)"
                puts $f "set ${var}($n) \{$v\}"
            }
-        } else {
-            eval "set v \$${var}"
-            puts $f "set ${var} \{$v\}"
         }
     }
     close $f
@@ -78,7 +77,7 @@ proc display-brief {zset no} {
         set title [lindex [$zset getMarc $no field 245 * a] 0]
         set year [lindex [$zset getMarc $no field 260 * c] 0]
     } ] } {
-        html {<a href="http://} $env(SERVER_NAME) $env(SCRIPT_NAME) /
+        html {<a href="http:} $env(SCRIPT_NAME) /
         html $sessionId {/showfull.egw/} $setNo + $no {"> } $title {</a>}
         html " <i> ${year} </i>"
     }
@@ -211,9 +210,14 @@ proc z39search {setNo piggy} {
             html "Cannot initialize with target ${host} <br>\n"
             return 0
         }
-        zwait sessionWait
+        if {[catch {zwait sessionWait 60}]} {
+            html "Cannot initialize with target ${host} <br>\n"
+           z39 disconnect
+            return 0
+        }
         if {$sessionWait != "1"} {
             html "Cannot initialize with target ${host} <br>\n"
+           z39 disconnect
             return 0
         }
     }
@@ -238,9 +242,15 @@ proc z39search {setNo piggy} {
     set sessionWait 0
     z39.$setNo search $hist($setNo,query)
 
-    zwait sessionWait
+    if {[catch {zwait sessionWait 600}]} {
+        html "</body></html>\n"
+        z39 disconnect
+        return 0
+    }
+        
     if {$sessionWait != 1} {
         html "</body></html>\n"
+        z39 disconnect
         return 0
     }
     set status [z39.$setNo responseStatus]
@@ -392,7 +402,10 @@ proc z39present {setNo setOffset setMax dfunc} {
         if {$got < $toGet} {
             set sessionWait 0
             z39.$setNo present $setOffset $toGet
-            zwait sessionWait
+            if {[catch {zwait sessionWait 300}]} {
+               z39 disconnect
+                break
+           }
             if {$sessionWait != "1"} {
                 break
             }
@@ -417,7 +430,7 @@ proc z39history {} {
     }
     html "<hr><h3>History</h3><dl>\n"
     for {set setNo 1} {$setNo < $nextSetNo} {incr setNo} {
-        html {<dt> <a href="http://} $env(SERVER_NAME) $env(SCRIPT_NAME)
+        html {<dt> <a href="http:} $env(SCRIPT_NAME)
         html / $sessionId {/search.egw/} $setNo + 1
         html + [expr $hist($setNo,maxPresent) - 1]
         html {"> } [lindex $targets($hist($setNo,host)) 0]
@@ -437,4 +450,4 @@ proc z39history {} {
         html "\n"
     }
     html "</dl>\n"
-}
\ No newline at end of file
+}
index 41371f0..ef953d2 100644 (file)
@@ -1,4 +1,4 @@
-# $Id: ztargets.conf,v 1.6 1995/11/08 12:42:18 adam Exp $
+# $Id: ztargets.conf,v 1.7 1995/11/08 16:14:36 adam Exp $
 set commonFields {
  { Title {@attr 1=4} }
  { Author {@attr 1=1003} }
@@ -9,8 +9,8 @@ set commonFields {
 }
 
 set targets(myriad.middlebury.edu) {
-    Myriad 
-    Default
+    Midcat
+    MIDCAT
     { { Title {@attr 1=4} }
       { Author {@attr 1=1003} }
       { Abstract {@attr 1=62} }