# Makefile for www gateway utility
# Europagate, 1995
#
-# $Id: Makefile,v 1.41 1996/06/06 11:10:10 adam Exp $
+# $Id: Makefile,v 1.42 1997/01/24 13:13:10 adam Exp $
#
SHELL=/bin/sh
#ELIB=-lnsl -lsocket
OLIB=../lib/util.a ../lib/libres+log.a
-TCLLIB=/usr/local/lib/libtcl7.5.a
+TCLLIB=-L/usr/local/lib -ltcl8.0 -lm
TCLINC=
HSCRIPTS=egwindex.html
P4=wproto.o winterp.o waissh.o wtcl.o wirtcl.o wshmain.o wwaistcl.o
CPP=$(CC) -E
+EGWUSER=nobody
HTTPDDIR=/usr/local/etc/httpd
CGIDIR=$(HTTPDDIR)/cgi-bin
HTDOCS=$(HTTPDDIR)/htdocs
EGWDIR=$(HTTPDDIR)/egw
GIFDIR=$(HTDOCS)/egwgif
-#HTTPDDIR=/usr/local/www
-#CGIDIR=/usr/local/www/cgi-bin
-#HTDOCS=/data2/html/egw/html
-#EGWDIR=/data2/html/egw/scripts
-#GIFDIR=/data2/html/egw/gif
-
INCLUDE=-I../include $(ZINC) $(TCLINC) $(IRTCLINC)
DEFS=$(INCLUDE) $(ZDEFS) -DEGWDIR=\"$(EGWDIR)\"
echo "Making directory $(EGWDIR)"; \
mkdir $(EGWDIR); \
fi
+ @chown $(EGWUSER) $(EGWDIR)
@for x in $(TPROG1); do \
echo Installing $$x; \
cp $$x $(CGIDIR); \
- chmod a+x $(CGIDIR)/$$x; \
+ chown $(EGWUSER) $(CGIDIR)/$$x; \
+ chmod +x $(CGIDIR)/$$x; \
+ chmod u+s $(CGIDIR)/$$x; \
done; \
for x in $(TPROG2); do \
echo Installing $$x; \
- cp $$x $(EGWDIR); \
- chmod a+x $(EGWDIR)/$$x; \
+ cp $$x $(EGWDIR)/$$x; \
+ chown $(EGWUSER) $(EGWDIR)/$$x; \
+ chmod +x $(EGWDIR)/$$x; \
done; \
for p in egwtcl egwirtcl egwhtml; do \
rm -f $(EGWDIR)/$$p; \
ln $(EGWDIR)/$(TPROG2) $(EGWDIR)/$$p; \
+ chown $(EGWUSER) $(EGWDIR)/$$p; \
done
@if [ -x $(TPROG4) ]; then \
echo Installing $(TPROG4); \
cp $(TPROG4) $(EGWDIR)/$(TPROG4); \
- chmod a+x $(EGWDIR)/$(TPROG4); \
+ chmod +x $(EGWDIR)/$(TPROG4); \
+ chown $(EGWUSER) $(EGWDIR)/$(TPROG4); \
fi
install.script:
@for x in *.egw *.tcl; do \
echo Installing $$x; \
cp $$x $(EGWDIR)/$$x; \
+ chown $(EGWUSER) $(EGWDIR)/$$x; \
done
@for x in $(HSCRIPTS); do \
echo Installing $$x; \
cp $$x $(HTDOCS); \
+ chmod a+r $(HTDOCS)/$$x; \
done
@for x in $(CONFFILES); do \
echo Installing $$x; \
cp $$x $(EGWDIR); \
+ chown $(EGWUSER) $(EGWDIR)/$$x; \
done
install.gif:
@if [ ! -d $(GIFDIR) ]; then \
echo "Making directory $(GIFDIR)"; \
mkdir $(GIFDIR); \
+ chmod a+x $(GIFDIR); \
fi
- @for x in gif/*.gif; do \
+ @cd gif; for x in *.gif; do \
echo Installing $$x; \
cp $$x $(GIFDIR); \
+ chmod a+r $(GIFDIR)/$$x; \
done
.c.o:
* USE OR PERFORMANCE OF THIS SOFTWARE.
*
* $Log: wcgi.c,v $
+ * Revision 1.19 1997/01/24 13:13:10 adam
+ * Implemnted egw_source and added a "raw" option to the URL.
+ * Fixed a bug in the buffering system of wproto; the macro wo_putc could
+ * override memory if it was the first HTML generating function called.
+ *
* Revision 1.18 1996/03/14 11:48:37 adam
* New function egw_prog that returns name of shell.
*
int linein = -1, lineout, data, gw_id;
if (chdir (EGWDIR))
- fatal ("Couldn't change directory to " EGWDIR);
+ fatal ("egwcgi: Couldn't change directory to " EGWDIR);
gw_log_init ("egw");
gw_log_file (GW_LOG_ALL, "egwcgi_log");
#if 0
* USE OR PERFORMANCE OF THIS SOFTWARE.
*
* $Log: wproto.c,v $
+ * Revision 1.22 1997/01/24 13:13:11 adam
+ * Implemnted egw_source and added a "raw" option to the URL.
+ * Fixed a bug in the buffering system of wproto; the macro wo_putc could
+ * override memory if it was the first HTML generating function called.
+ *
* Revision 1.21 1996/05/23 15:53:11 adam
* Bug fix: egw_enc failed on 8-bit chars.
* New command: egw_parms.
#include <stdarg.h>
#include <ctype.h>
#include <errno.h>
+#include <assert.h>
#include "wproto.h"
{
if (wc->outbuffer_offset + len >= wc->outbuffer_size)
{
- if (!wc->outbuffer)
- wc->outbuffer = malloc (wc->outbuffer_size +=
- ((len >= OUTBUFFER_CHUNK) ? len*2 : OUTBUFFER_CHUNK));
- else
- wc->outbuffer = realloc(wc->outbuffer, wc->outbuffer_size +=
- ((len >= OUTBUFFER_CHUNK) ? len*2 : OUTBUFFER_CHUNK));
+ assert (wc->outbuffer);
+ wc->outbuffer = realloc(wc->outbuffer, wc->outbuffer_size +=
+ ((len >= OUTBUFFER_CHUNK) ? len*2 : OUTBUFFER_CHUNK));
}
memcpy(wc->outbuffer + wc->outbuffer_offset, s, len);
wc->outbuffer_offset += len;
void wo_clear (WCLIENT wc, const char *type)
{
+ if (!wc->outbuffer)
+ wc->outbuffer = malloc (wc->outbuffer_size = OUTBUFFER_CHUNK);
wc->outbuffer_offset = 0;
if (type)
wo_printf(wc, "Content-type: %s\n\n", type);
* USE OR PERFORMANCE OF THIS SOFTWARE.
*
* $Log: wproto.h,v $
+ * Revision 1.12 1997/01/24 13:13:12 adam
+ * Implemnted egw_source and added a "raw" option to the URL.
+ * Fixed a bug in the buffering system of wproto; the macro wo_putc could
+ * override memory if it was the first HTML generating function called.
+ *
* Revision 1.11 1996/05/23 15:53:11 adam
* Bug fix: egw_enc failed on 8-bit chars.
* New command: egw_parms.
(*((wc)->outbuffer + (wc)->outbuffer_offset++) = (char) (ch)), 0)
char *wgetval (WCLIENT wc, char *name);
+
+/* wproto_process: wait for one request from egwcgi. returns <=0 on
+ timeout; returns >0 otherwise. */
int wproto_process (WCLIENT wc, int timeout);
+
+/* wproto_init: initializes communication with egwcgi. */
WCLIENT wproto_init (const char *fifoDir, const char *prog);
+
+
void wo_printf (WCLIENT wc, const char *fmt, ...);
void wo_clear (WCLIENT wc, const char *type);
int wo_finish (WCLIENT wc);
* USE OR PERFORMANCE OF THIS SOFTWARE.
*
* $Log: wshmain.c,v $
+ * Revision 1.5 1997/01/24 13:13:12 adam
+ * Implemnted egw_source and added a "raw" option to the URL.
+ * Fixed a bug in the buffering system of wproto; the macro wo_putc could
+ * override memory if it was the first HTML generating function called.
+ *
* Revision 1.4 1996/05/23 15:53:12 adam
* Bug fix: egw_enc failed on 8-bit chars.
* New command: egw_parms.
{
char *p;
int r;
+ int raw_mode = 0;
r = wproto_process (wcl, timeout);
if (r <= 0)
if (*script)
{
+#if 0
p = script + strlen(script);
while (*--p && p != script)
switch (*p)
{
case '+':
wproto_cache (wcl, wcl->cache_level+1);
- *p = '\0';
break;
case '-':
if (p[1])
*p = '\0';
break;
}
+#else
+ p = script;
+ while (*p)
+ {
+ if (*p == ';') /* ";" or ";<date>" */
+ {
+ wo_printf (wcl, "Expires: %s\n", p[1] ? p+1 : "0");
+ gw_log (GW_LOG_DEBUG, mod, "Expires: %s", p[1] ?p+1:"0");
+ *p = '\0';
+ break;
+ }
+ else if (*p == '+') /* "+<name>=<value>" or "+<name>" */
+ {
+ const char *name1 = NULL;
+ const char *name2 = NULL;
+ const char *value1 = NULL;
+ const char *value2 = NULL;
+ int len;
+ *p = '\0';
+ name1 = ++p;
+ while (*p && *p != ';' && *p != '+')
+ {
+ if (*p == '=')
+ {
+ name2 = p++;
+ value1 = p;
+ while (*p && *p != ';' && *p != '+')
+ p++;
+ value2 = p;
+ break;
+ }
+ p++;
+ }
+ if (!name2)
+ name2 = p;
+ len = name2 - name1;
+ if (len == 3 && !memcmp (name1, "raw", len))
+ raw_mode = 1;
+ }
+ else
+ p++;
+ }
+ *p = '\0';
+#endif
}
- wo_printf (wcl, "Content-type: text/html\n\n");
+ if (!raw_mode)
+ wo_printf (wcl, "Content-type: text/html\n\n");
for (p = parms; *p; p++)
if (*p == '+')
*p = ' ';
gw_log (GW_LOG_STAT, mod, "parms: %s", parms);
if (w_interp_exec (w_interp, script, parms))
{
+ if (raw_mode)
+ wo_printf (wcl, "Content-type: text/html\n\n");
wo_printf (wcl, "<html><head><title>wsh error</title></head>\n");
wo_printf (wcl, "<body>Couldn't execute script %s</body></html>",
script);
* USE OR PERFORMANCE OF THIS SOFTWARE.
*
* $Log: wtcl.c,v $
+ * Revision 1.18 1997/01/24 13:13:13 adam
+ * Implemnted egw_source and added a "raw" option to the URL.
+ * Fixed a bug in the buffering system of wproto; the macro wo_putc could
+ * override memory if it was the first HTML generating function called.
+ *
* Revision 1.17 1996/05/31 08:02:56 adam
* Bug fix: egw_enc encoded '/' - it shouldn't.
*
WCLIENT wcl;
};
+static int exec_file (const char *fname, struct tcl_info *p);
+
Tcl_Interp *w_interp_tcl_get (W_Interp w_interp)
{
struct tcl_info *p;
return TCL_OK;
}
+static int proc_source (ClientData clientData, Tcl_Interp *interp,
+ int argc, char **argv)
+{
+ struct tcl_info *p = (struct tcl_info*) clientData;
+ int r;
+
+ if (argc != 2)
+ {
+ Tcl_AppendResult (p->interp,
+ "wrong # args: should be egw_source file", NULL);
+ return TCL_ERROR;
+ }
+ r = exec_file (argv[1], p);
+ if (r == -2)
+ {
+ Tcl_AppendResult (p->interp, "egw_source: couldn't source ",
+ argv[1], NULL);
+ return TCL_ERROR;
+ }
+ else if (r == -1)
+ {
+ Tcl_AppendResult (p->interp, "egw_source: Tcl error in script ",
+ argv[1], NULL);
+ return TCL_ERROR;
+ }
+ return TCL_OK;
+}
+
+
int Tcl_AppInit (Tcl_Interp *interp)
{
if (Tcl_Init (interp) == TCL_ERROR)
Tcl_CreateCommand (p->interp, "egw_enc", proc_enc, p, NULL);
Tcl_CreateCommand (p->interp, "egw_dec", proc_dec, p, NULL);
Tcl_CreateCommand (p->interp, "egw_prog", proc_prog, p, NULL);
+ Tcl_CreateCommand (p->interp, "egw_source", proc_source, p, NULL);
sprintf (tmp_str, "%d", wcl->id);
Tcl_SetVar (p->interp, "sessionId", tmp_str, TCL_GLOBAL_ONLY);
return p;
wo_printf (p->wcl, "<xmp>\n%s</xmp>\n<hr>\n", msg);
}
-static int tcl_exec (const char *fname, char *parms,
- struct tcl_info *p, FILE *inf, int *lineno)
+static int tcl_exec (const char *fname, struct tcl_info *p, FILE *inf,
+ int *lineno)
{
int c, escape = 0, level = 0;
int r, fbuf_ptr = 0;
return r;
}
-static int do_exec (const char *fname, char *parms, void *mydata)
+static int exec_file (const char *fname, struct tcl_info *p)
{
- struct tcl_info *p = mydata;
int c, escape = 0;
int lineno = 1;
FILE *inf = fopen (fname, "r");
gw_log (GW_LOG_WARN|GW_LOG_ERRNO, mod, "open %s", fname);
return -1;
}
- Tcl_SetVar (p->interp, "sessionParms", parms, TCL_GLOBAL_ONLY);
while ((c = getc(inf)) != EOF)
{
if (c == '\\')
wo_putc (p->wcl, c);
else
{
- int r = tcl_exec (fname, parms, p, inf, &lineno);
+ int r = tcl_exec (fname, p, inf, &lineno);
if (r == TCL_RETURN)
{
fclose (inf);
return 0;
}
+static int do_exec (const char *fname, char *parms, void *mydata)
+{
+ struct tcl_info *p = mydata;
+
+ Tcl_SetVar (p->interp, "sessionParms", parms, TCL_GLOBAL_ONLY);
+ return exec_file (fname, p);
+}
static int do_load (char *parms, void *mydata)
{