|
*** Makefile.old Wed Jun 15 16:10:52 1994
--- Makefile Thu Dec 15 10:53:56 1994
***************
*** 28,43 ****
# system.
- PATH=$(INFORMIXDIR)/bin:$PATH
-
# INFORMIX SQL stuff; ensures we find sql*.h files
! INFORMIXDIR = /usr/prop
! # CC = gcc -static -fwritable-strings -fpcc-struct-return
! CC = cc -non_shared
! ESQL = esql -non_shared
MAKEDEP = makedepend
! INSTALL = installbsd
DEST = /usr/local/sbin
# variable specifying the location of dsql.profile
--- 28,47 ----
# system.
# INFORMIX SQL stuff; ensures we find sql*.h files
! # INFORMIXDIR = /opt/informix # Sun installation?
! INFORMIXDIR = /usr/prop/informix
! # Choose your compiler
! #CC = gcc -fwritable-strings -fpcc-struct-return
! CC = cc
!
! # Esql.
! #ESQL = $(INFORMIXDIR)/bin/esql
! ESQL = esql
!
MAKEDEP = makedepend
! INSTALL = installbsd -c
DEST = /usr/local/sbin
# variable specifying the location of dsql.profile
***************
*** 82,87 ****
--- 86,93 ----
#CFLAGS = -g -DDEBUG -I$(INFORMIXDIR)/incl/esql -DBASEDIR=\"$(BASEPATH)\"
LIBS =
+ # Sun (again! sigh.)
+ # LIBS = -lsocket -lnsl
LINKER = cc
***************
*** 115,142 ****
all: $(PROGRAM)
$(PROGRAM): $(OBJS) $(LIBS)
@echo -n "Loading $(PROGRAM) ... "
$(ESQL) -o $(PROGRAM) $(LDFLAGS) $(OBJS) $(LIBS)
@echo "done"
! informix.o : informix.c
! $(ESQL) $(CFLAGS) -c $<
! clean:; @rm -f $(OBJS)
depend:; $(MAKEDEP) -I$(INFORMIXDIR)/incl/esql $(SRCS)
index:; @ctags -wx $(HDRS) $(SRCS)
! install: $(PROGRAM)
@echo Installing $(PROGRAM) in $(DEST)
! @$(INSTALL) -c $(PROGRAM) $(DEST)
! @$(INSTALL) -c -m 0400 dsql.profile $(BASEPATH)
testinstall: $(PROGRAM)
@echo Installing $(PROGRAM) as $(DEST)/$(TEST)
! @$(INSTALL) -c $(PROGRAM) $(DEST)/$(TEST)
@-cp dsql.profile $(BASEPATH)
@chmod 400 $(BASEPATH)/dsql.profile
--- 121,149 ----
all: $(PROGRAM)
+ $(PROGRAM): $(OBJS)
$(PROGRAM): $(OBJS) $(LIBS)
@echo -n "Loading $(PROGRAM) ... "
$(ESQL) -o $(PROGRAM) $(LDFLAGS) $(OBJS) $(LIBS)
@echo "done"
! #informix.o : informix.c
! # $(ESQL) $(CFLAGS) -c $<
! clean:; @$(RM) -f $(OBJS)
depend:; $(MAKEDEP) -I$(INFORMIXDIR)/incl/esql $(SRCS)
index:; @ctags -wx $(HDRS) $(SRCS)
! install: $(PROGRAM) dsql.profile
@echo Installing $(PROGRAM) in $(DEST)
! @$(INSTALL) $(PROGRAM) $(DEST)
! @$(INSTALL) -m 0400 dsql.profile $(BASEPATH)
testinstall: $(PROGRAM)
@echo Installing $(PROGRAM) as $(DEST)/$(TEST)
! @$(INSTALL) $(PROGRAM) $(DEST)/$(TEST)
@-cp dsql.profile $(BASEPATH)
@chmod 400 $(BASEPATH)/dsql.profile
***************
*** 153,226 ****
@make -f $(MAKEFILE) DEST=$(DEST) $(INSTALL)
- # DO NOT DELETE THIS LINE -- make depend depends on it.
-
- blobcmds.o: /usr/include/sys/file.h /usr/include/sys/types.h
- blobcmds.o: /usr/include/standards.h /usr/include/sys/param.h
- blobcmds.o: /usr/include/sys/limits.h /usr/include/machine/machparam.h
- blobcmds.o: /usr/include/machine/endian.h /usr/include/machine/machlimits.h
- blobcmds.o: /usr/include/sys/access.h /usr/include/sys/fcntl.h dsqlsrvr.h
- blobcmds.o: /usr/include/stdio.h /usr/include/signal.h
- blobcmds.o: /usr/include/sys/stat.h /usr/include/sys/mode.h
- blobcmds.o: /usr/include/errno.h state.h dreply.h
- bufutil.o: /usr/include/sys/time.h /usr/include/sys/types.h
- bufutil.o: /usr/include/standards.h /usr/include/sys/time.h dsqlsrvr.h
- bufutil.o: /usr/include/stdio.h /usr/include/signal.h /usr/include/sys/file.h
- bufutil.o: /usr/include/sys/param.h /usr/include/sys/limits.h
- bufutil.o: /usr/include/machine/machparam.h /usr/include/machine/endian.h
- bufutil.o: /usr/include/machine/machlimits.h /usr/include/sys/access.h
- bufutil.o: /usr/include/sys/fcntl.h /usr/include/sys/stat.h
- bufutil.o: /usr/include/sys/mode.h /usr/include/errno.h state.h dreply.h
- bufutil.o: bufutil.h
- dbms.o: /usr/include/stdio.h /usr/include/standards.h dbms.h dreply.h
- dsql.o: dsqlsrvr.h /usr/include/stdio.h /usr/include/standards.h
- dsql.o: /usr/include/signal.h /usr/include/sys/types.h
- dsql.o: /usr/include/sys/file.h /usr/include/sys/param.h
- dsql.o: /usr/include/sys/limits.h /usr/include/machine/machparam.h
- dsql.o: /usr/include/machine/endian.h /usr/include/machine/machlimits.h
- dsql.o: /usr/include/sys/access.h /usr/include/sys/fcntl.h
- dsql.o: /usr/include/sys/stat.h /usr/include/sys/mode.h /usr/include/errno.h
- dsql.o: state.h dreply.h dbms.h statetab.h
- dsqlcmds.o: /usr/include/ctype.h /usr/include/standards.h dsqlsrvr.h
- dsqlcmds.o: /usr/include/stdio.h /usr/include/signal.h
- dsqlcmds.o: /usr/include/sys/types.h /usr/include/sys/file.h
- dsqlcmds.o: /usr/include/sys/param.h /usr/include/sys/limits.h
- dsqlcmds.o: /usr/include/machine/machparam.h /usr/include/machine/endian.h
- dsqlcmds.o: /usr/include/machine/machlimits.h /usr/include/sys/access.h
- dsqlcmds.o: /usr/include/sys/fcntl.h /usr/include/sys/stat.h
- dsqlcmds.o: /usr/include/sys/mode.h /usr/include/errno.h state.h dreply.h
- dsqlcmds.o: dbms.h
- execcmds.o: dsqlsrvr.h /usr/include/stdio.h /usr/include/standards.h
- execcmds.o: /usr/include/signal.h /usr/include/sys/types.h
- execcmds.o: /usr/include/sys/file.h /usr/include/sys/param.h
- execcmds.o: /usr/include/sys/limits.h /usr/include/machine/machparam.h
- execcmds.o: /usr/include/machine/endian.h /usr/include/machine/machlimits.h
- execcmds.o: /usr/include/sys/access.h /usr/include/sys/fcntl.h
- execcmds.o: /usr/include/sys/stat.h /usr/include/sys/mode.h
- execcmds.o: /usr/include/errno.h state.h dreply.h
- informix.o: /usr/include/pwd.h /usr/include/standards.h
- informix.o: /usr/include/sys/types.h /usr/include/ctype.h /usr/include/ndbm.h
- informix.o: /usr/include/setjmp.h /usr/include/signal.h
- informix.o: /usr/prop/incl/esql/sqlca.h /usr/prop/incl/esql/sqltypes.h
- informix.o: /usr/prop/incl/esql/sqlda.h /usr/prop/incl/esql/sqlstype.h
- informix.o: /usr/prop/incl/esql/sqlhdr.h dsqlsrvr.h /usr/include/stdio.h
- informix.o: /usr/include/sys/file.h /usr/include/sys/param.h
- informix.o: /usr/include/sys/limits.h /usr/include/machine/machparam.h
- informix.o: /usr/include/machine/endian.h /usr/include/machine/machlimits.h
- informix.o: /usr/include/sys/access.h /usr/include/sys/fcntl.h
- informix.o: /usr/include/sys/stat.h /usr/include/sys/mode.h
- informix.o: /usr/include/errno.h state.h dreply.h
- state.o: state.h /usr/include/stdio.h /usr/include/standards.h
- unix.o: /usr/include/sys/types.h /usr/include/standards.h
- unix.o: /usr/include/sys/socket.h /usr/include/sys/wait.h
- unix.o: /usr/include/netinet/in.h /usr/include/netdb.h
- unix.o: /usr/include/rpc/netdb.h /usr/include/pwd.h /usr/include/sys/time.h
- unix.o: /usr/include/sys/time.h /usr/include/sys/ioctl.h
- unix.o: /usr/include/sys/secdefines.h /usr/include/stdlib.h dsqlsrvr.h
- unix.o: /usr/include/stdio.h /usr/include/signal.h /usr/include/sys/file.h
- unix.o: /usr/include/sys/param.h /usr/include/sys/limits.h
- unix.o: /usr/include/machine/machparam.h /usr/include/machine/endian.h
- unix.o: /usr/include/machine/machlimits.h /usr/include/sys/access.h
- unix.o: /usr/include/sys/fcntl.h /usr/include/sys/stat.h
- unix.o: /usr/include/sys/mode.h /usr/include/errno.h state.h dreply.h dbms.h
- unix.o: bufutil.h
--- 160,162 ----
*** blobcmds.c.old Thu Mar 17 10:01:36 1994
--- blobcmds.c Thu Dec 15 10:53:56 1994
***************
*** 23,37 ****
*/
# ifndef lint
! static char *rcsid = "$Header: /usr/src/local/sbin/dsql/srvr/src/RCS/blobcmds.c,v 3.4 93/06/01 15:01:58 dm Exp $";
# endif
/*
* functions for BLOB state commands.
! * $Log: blobcmds.c,v $
! * Revision 3.4 93/06/01 15:01:58 dm
* add dummies for vms to quiet compiler
! *
* Revision 3.3 92/11/13 14:06:20 dm
* change index() to strchr(), etc.
*
--- 23,50 ----
*/
# ifndef lint
! static char *rcsid = "$Header: /usr/src/local/sbin/dsql/srvr/src/RCS/blobcmds.c,v 3.8 1994/11/18 02:05:01 dm Exp $";
# endif
/*
* functions for BLOB state commands.
! * $Log: blobcmds.c,v $
! * Revision 3.8 1994/11/18 02:05:01 dm
! * finally fix the reinit of tempfile variable
! *
! * Revision 3.7 1994/11/17 16:53:32 dm
! * TRUNC was not the problem. the problem was that tempfile was not
! * reinitialized after a close.
! *
! * Revision 3.6 1994/11/05 01:38:54 dm
! * add O_TRUNC to blobwrite open.
! *
! * Revision 3.5 1994/09/21 00:18:49 dm
! * better function declarations
! *
! * Revision 3.4 1993/06/01 15:01:58 dm
* add dummies for vms to quiet compiler
! *
* Revision 3.3 92/11/13 14:06:20 dm
* change index() to strchr(), etc.
*
***************
*** 134,144 ****
extern char *nextword();
extern void reply();
! static char *tempfile = "/tmp/dsqlblobXXXXXX";
long blobstart;
blob_get(cmd, nst, est)
{
char *fname, *cp, *s, *sz;
struct stat f_info;
--- 147,159 ----
extern char *nextword();
extern void reply();
! static char tempfile[32];
long blobstart;
blob_get(cmd, nst, est)
+ char *cmd;
+ int nst, est;
{
char *fname, *cp, *s, *sz;
struct stat f_info;
***************
*** 190,195 ****
--- 205,212 ----
}
blob_put(cmd, nst, est)
+ char *cmd;
+ int nst, est;
{
char rbuf[128];
char *fname, *s, *sz, *offs, *ovr;
***************
*** 205,210 ****
--- 222,228 ----
if (!dir_ok(fname)) return est;
+ strcpy(tempfile, "/tmp/dsqlblobXXXXXX");
if (mktemp(tempfile) == -1) {
sprintf(rbuf, "mktemp failed: %s", strerror(errno));
reply(R_FAIL, R_BLOB, B_SYSERR, rbuf);
***************
*** 246,251 ****
--- 264,270 ----
char dirname[PATHSIZE], *cp;
char rbuf[128];
struct stat f_info;
+ extern char *strcpy(char *d, const char *s);
strcpy(dirname, file);
if ((cp = strrchr(dirname, '/')) == NULL) strcpy(dirname, ".");
***************
*** 412,422 ****
--- 431,445 ----
# else
blob_get(cmd, nst, est)
+ char *cmd;
+ int nst, est;
{
return est;
}
blob_put(cmd, nst, est)
+ char *cmd;
+ int nst, est;
{
return est;
}
*** bufutil.c.old Thu Mar 17 10:01:36 1994
--- bufutil.c Thu Dec 15 10:53:56 1994
***************
*** 23,29 ****
*/
# ifndef lint
! static char *rcsid = "$Header: /usr/src/local/sbin/dsql/srvr/src/RCS/bufutil.c,v 3.6 93/06/21 13:27:15 dm Exp $";
# endif lint
/* utility routines to do internally buffered read and write.
--- 23,29 ----
*/
# ifndef lint
! static char *rcsid = "$Header: /usr/src/local/sbin/dsql/srvr/src/RCS/bufutil.c,v 3.7 1994/11/05 01:39:41 dm Exp $";
# endif lint
/* utility routines to do internally buffered read and write.
***************
*** 31,41 ****
*/
/*
! * $Log: bufutil.c,v $
! * Revision 3.6 93/06/21 13:27:15 dm
! * freadchar and fblob_close implementations added. this fixes a
* problem in ultrix where ioctl does not work across nfs for files.
! *
* Revision 3.5 93/06/01 15:04:41 dm
* switch for vms around syslog call
*
--- 31,44 ----
*/
/*
! * $Log: bufutil.c,v $
! * Revision 3.7 1994/11/05 01:39:41 dm
! * fix unreadchar(). this was a true bug.
! *
! * Revision 3.6 1993/06/21 13:27:15 dm
! * freadchar and fblob_close implementations added. this fixes a
* problem in ultrix where ioctl does not work across nfs for files.
! *
* Revision 3.5 93/06/01 15:04:41 dm
* switch for vms around syslog call
*
***************
*** 293,299 ****
if ((fdp = get_fdent(fd)) != NULL) {
fdp->bp--;
- fdp->count++;
}
}
--- 296,301 ----
No differences encountered
*** dbms.c.old Thu Mar 17 10:01:37 1994
--- dbms.c Thu Dec 15 10:53:56 1994
***************
*** 23,29 ****
*/
# ifndef lint
! static char *rcsid = "$Header: /usr/src/local/sbin/dsql/srvr/src/RCS/dbms.c,v 3.4 93/01/08 11:39:02 dm Exp $";
# endif
#include
--- 23,29 ----
*/
# ifndef lint
! static char *rcsid = "$Header: /usr/src/local/sbin/dsql/srvr/src/RCS/dbms.c,v 3.4 1993/01/08 11:39:02 dm Exp $";
# endif
#include
No differences encountered
*** dreply.h.old Thu Mar 17 10:01:37 1994
--- dreply.h Thu Dec 15 10:53:56 1994
***************
*** 27,37 ****
/*
*
* dsql reply codes for servers and clients
! * $Log: dreply.h,v $
! * Revision 3.3 93/06/23 11:55:48 dm
* add oracle codes.
! *
! *
* Revision 3.2 92/08/11 13:55:51 dm
* commend #endif trailer (make lint shutup)
*
--- 27,36 ----
/*
*
* dsql reply codes for servers and clients
! * $Log: dreply.h,v $
! * Revision 3.3 1993/06/23 11:55:48 dm
* add oracle codes.
! *
* Revision 3.2 92/08/11 13:55:51 dm
* commend #endif trailer (make lint shutup)
*
*** dsql.c.old Thu Mar 17 10:01:37 1994
--- dsql.c Thu Dec 15 10:53:56 1994
***************
*** 23,34 ****
*/
# ifndef lint
! static char *rcsid = "$Header: /usr/src/local/sbin/dsql/srvr/src/RCS/dsql.c,v 3.3 92/09/03 12:43:56 dm Exp $";
# endif
/*
* DSQL TCP Server -- portable version
! * $Log: dsql.c,v $
* Revision 3.3 92/09/03 12:43:56 dm
* *** empty log message ***
*
--- 23,37 ----
*/
# ifndef lint
! static char *rcsid = "$Header: /usr/src/local/sbin/dsql/srvr/src/RCS/dsql.c,v 3.4 1994/03/03 11:14:26 dm Exp $";
# endif
/*
* DSQL TCP Server -- portable version
! * $Log: dsql.c,v $
! * Revision 3.4 1994/03/03 11:14:26 dm
! * changes made in solaris port; uninstalled and untested at this time.
! *
* Revision 3.3 92/09/03 12:43:56 dm
* *** empty log message ***
*
***************
*** 130,139 ****
break;
#endif
default:
! exit();
}
}
! else exit();
}
--- 133,142 ----
break;
#endif
default:
! exit(1);
}
}
! else exit(1);
}
*** dsqlcmds.c.old Thu Mar 17 10:01:38 1994
--- dsqlcmds.c Thu Dec 15 10:53:56 1994
***************
*** 23,34 ****
*/
# ifndef lint
! static char *rcsid = "$Header: /usr/src/local/sbin/dsql/srvr/src/RCS/dsqlcmds.c,v 3.9 93/06/21 13:26:05 dm Exp $";
# endif
/* commands to handle server requests. the STATE table is at the
* the end of the file.
! * $Log: dsqlcmds.c,v $
* Revision 3.9 93/06/21 13:26:05 dm
* use freadchar and fblob_close for readchar and dsql_close. these
* are defined back to readchar and dsql_close in all cases except
--- 23,45 ----
*/
# ifndef lint
! static char *rcsid = "$Header: /usr/src/local/sbin/dsql/srvr/src/RCS/dsqlcmds.c,v 3.12 1994/09/26 17:11:10 dm Exp $";
# endif
/* commands to handle server requests. the STATE table is at the
* the end of the file.
! * $Log: dsqlcmds.c,v $
! * Revision 3.12 1994/09/26 17:11:10 dm
! * change env() to sysenv() due to name conflict with informix libs.
! *
! * Revision 3.11 1994/09/21 00:18:03 dm
! * better function declarations, ptr testing.
! *
! * Revision 3.10 1994/02/11 11:59:13 dm
! * extension to nextword() to allow double quotes to enclose a 'word'.
! * this enables spaces as legal characters in pathnames which are quoted.
! * affects chdir, getfile, putfile.
! *
* Revision 3.9 93/06/21 13:26:05 dm
* use freadchar and fblob_close for readchar and dsql_close. these
* are defined back to readchar and dsql_close in all cases except
***************
*** 203,209 ****
*p++ = '\0';
/* server is protocol version 3, compatable with 2 */
if (atoi(cp) >= 2 && atoi(p) <= 3) {
! reply(R_GOOD, R_INIT, C_ISOK, "DSQL PROTOCOL VERSION 3");
return nst;
}
/* we can't handle this version client */
--- 214,220 ----
*p++ = '\0';
/* server is protocol version 3, compatable with 2 */
if (atoi(cp) >= 2 && atoi(p) <= 3) {
! reply(R_GOOD, R_INIT, C_ISOK, "DSQL PROTOCOL VERSION 3.01");
return nst;
}
/* we can't handle this version client */
***************
*** 312,317 ****
--- 323,330 ----
int
info(cmd, nst, est)
+ char *cmd;
+ int nst, est;
{
char *type;
***************
*** 328,333 ****
--- 341,348 ----
/* initialize flag and prepare for blob operation */
int
blob(cmd, nst, est)
+ char *cmd;
+ int nst, est;
{
#ifndef unix
reply(R_FAIL, R_DSQL, D_NOTIMPL, "blob not implemented");
***************
*** 343,348 ****
--- 358,365 ----
/* prepare for exec operation */
int
dexec(cmd, nst, est)
+ char *cmd;
+ int nst, est;
{
#ifdef unix
return Uexec(cmd, nst, est);
***************
*** 368,373 ****
--- 385,392 ----
int
blob_retrieve(cmd, nst, est)
+ char *cmd;
+ int nst, est;
{
int c = 0, cnt;
char *cp;
***************
*** 436,441 ****
--- 455,462 ----
int
exec_retrieve(cmd, nst, est)
+ char *cmd;
+ int nst, est;
{
#ifdef unix
return Uexec_retrieve(cmd, nst, est);
***************
*** 503,509 ****
#endif
}
! int env(cmd, nst, est)
char *cmd;
int nst, est;
{
--- 524,530 ----
#endif
}
! int sysenv(cmd, nst, est)
char *cmd;
int nst, est;
{
***************
*** 573,578 ****
--- 594,600 ----
{
char *cp = c;
+ if (!c || !*c) return cp;
while (*cp++ != ' ' && *cp)
;
return cp;
***************
*** 581,586 ****
--- 603,612 ----
/* parse next word in a multiword string. words are separated by
* one space. return pointer to the word and change p to point
* to the next word in the string.
+ *
+ * pre-V4: a "word" may be surrounded by double quotes. if the first
+ * char is a '"' search for the trailing '"' to define the end of the
+ * word. allow '\' to escape a '"' inside a "word."
*/
char *
nextword(s)
***************
*** 589,596 ****
char *cp;
cp = s;
! while (*cp && *cp != ' ') cp++;
if (*cp) *cp++ = '\0';
return cp;
}
-
--- 615,639 ----
char *cp;
cp = s;
! if (*cp == '"') {
! strcpy(cp, cp +1);
! cp = s;
! while (*cp) {
! if (*cp == '"' && *(cp -1) == '\\') {
! strcpy(cp -1, cp);
! cp++;
! continue;
! }
! if (*cp == '"') {
! *cp++ = '\0';
! break;
! }
! cp++;
! }
! }
! else {
! while (*cp && *cp != ' ') cp++;
! }
if (*cp) *cp++ = '\0';
return cp;
}
*** dsqlsrvr.h.old Wed Jun 15 16:10:53 1994
--- dsqlsrvr.h Thu Dec 15 10:53:56 1994
***************
*** 29,34 ****
--- 29,35 ----
# include
# include
+ # include /* helps to align implicit declarations */
#ifdef unix
# include
***************
*** 38,43 ****
--- 39,51 ----
# define freadchar readchar /* see freadchar() in bufutils.c */
# define fblob_close dsql_close
# endif
+ # ifdef sun /* big sigh... */
+ # include
+ # include
+ # include
+ # include
+ # include /* ! */
+ # endif
#else /* i.e., vms */
# include
# include
***************
*** 57,64 ****
extern int maxdata;
extern char *databuf;
extern int c_rd, c_wrt; /* client input/output channels */
extern char *crypt();
! extern char *strchr(), *strrchr();
# define Match(s1,s2) (!strcmp(s1, s2))
--- 65,75 ----
extern int maxdata;
extern char *databuf;
extern int c_rd, c_wrt; /* client input/output channels */
+ extern char *stripcmd(char *);
+
extern char *crypt();
! extern void *malloc(size_t);
! extern void *realloc(void *, size_t);
# define Match(s1,s2) (!strcmp(s1, s2))
***************
*** 66,72 ****
# define NOSTR ((char *) 0) /* Null string pointer */
# define NAMSIZ 64
# define SUCCESS 0
! # ifdef ULTRIX
# define TRUE (-1)
# endif
# define FALSE 0
--- 77,83 ----
# define NOSTR ((char *) 0) /* Null string pointer */
# define NAMSIZ 64
# define SUCCESS 0
! # if defined(ULTRIX) || defined(sun)
# define TRUE (-1)
# endif
# define FALSE 0
*** execcmds.c.old Thu Mar 17 10:01:39 1994
--- execcmds.c Thu Dec 15 10:53:56 1994
***************
*** 23,35 ****
*/
#ifndef lint
! static char *rcsid = "$Header: /usr/src/local/sbin/dsql/srvr/src/RCS/execcmds.c,v 3.4 93/02/26 16:38:10 dm Exp $";
#endif lint
/*
* system specific commands for the EXEC functions.
*
! * $Log: execcmds.c,v $
* Revision 3.4 93/02/26 16:38:10 dm
* cleanup
*
--- 23,41 ----
*/
#ifndef lint
! static char *rcsid = "$Header: /usr/src/local/sbin/dsql/srvr/src/RCS/execcmds.c,v 3.6 1994/09/21 00:18:33 dm Exp $";
#endif lint
/*
* system specific commands for the EXEC functions.
*
! * $Log: execcmds.c,v $
! * Revision 3.6 1994/09/21 00:18:33 dm
! * better function declarations.
! *
! * Revision 3.5 1994/03/03 11:14:43 dm
! * changes made in solaris port; uninstalled and untested at this time.
! *
* Revision 3.4 93/02/26 16:38:10 dm
* cleanup
*
***************
*** 109,114 ****
--- 115,121 ----
Uexec(cmd, nst,est)
char *cmd;
+ int nst, est;
{
extern char inbuf[];
char rbuf[128];
***************
*** 115,121 ****
int nowait = FALSE; /* return immediately when true */
char *bufend; /* end of entire input */
char *cp;
! sigset_t mask =0;
cp = (char *) stripcmd(cmd);
if (*cp) {
--- 122,128 ----
int nowait = FALSE; /* return immediately when true */
char *bufend; /* end of entire input */
char *cp;
! sigset_t mask;
cp = (char *) stripcmd(cmd);
if (*cp) {
***************
*** 168,174 ****
* dsql_pclose() will unblock the signal.
*/
! mask = sigmask(SIGCHLD);
sigprocmask(SIG_BLOCK, &mask, NULL);
/* open a pipe on the command and prepare to read the result, if any */
if ((execpipe = dsql_popen(cmdbuf, "r")) == -1) {
--- 175,182 ----
* dsql_pclose() will unblock the signal.
*/
! sigemptyset(&mask);
! sigaddset(&mask, SIGCHLD);
sigprocmask(SIG_BLOCK, &mask, NULL);
/* open a pipe on the command and prepare to read the result, if any */
if ((execpipe = dsql_popen(cmdbuf, "r")) == -1) {
***************
*** 203,208 ****
--- 211,218 ----
int
Uexec_retrieve(cmd, nst, est)
+ char *cmd;
+ int nst, est;
{
char rbuf[64];
*** informix.c.old Thu Mar 17 10:01:36 1994
--- informix.c Thu Dec 15 10:53:56 1994
***************
*** 23,29 ****
*/
# ifndef lint
! static char *rcsid = "$Header: /usr/src/local/sbin/dsql/srvr/src/RCS/informix.c,v 3.14 93/03/26 11:30:54 dm Exp $";
# endif
/* commands to handle INFORMIX DBMS operations. this module is
--- 23,29 ----
*/
# ifndef lint
! static char *rcsid = "$Header: /usr/src/local/sbin/dsql/srvr/src/RCS/informix.c,v 3.20 1994/12/15 18:34:01 dm Exp $";
# endif
/* commands to handle INFORMIX DBMS operations. this module is
***************
*** 43,54 ****
* are comments before each informix esql lib call (all _iq... functions).
* THIS MUST BE CHECKED AGAINST VERSION UPDATES OF THE INFORMIX ESQL LIBS.
*
! * $Log: informix.c,v $
! * Revision 3.14 93/03/26 11:30:54 dm
* malloc(0) returns NULL on some systems. a procedure
* returning no data will have a record size of 0 but we don't
* want to induce a malloc() failure on that account.
! *
* Revision 3.13 93/03/05 11:20:52 dm
* add number of rows processed (if non-zero) to OK reply.
*
--- 43,73 ----
* are comments before each informix esql lib call (all _iq... functions).
* THIS MUST BE CHECKED AGAINST VERSION UPDATES OF THE INFORMIX ESQL LIBS.
*
! * $Log: informix.c,v $
! * Revision 3.20 1994/12/15 18:34:01 dm
! * merge informix 4 and informix 5+ code in pre-nobody version.
! *
! * Revision 3.19 1994/12/15 17:40:40 dm
! * back step to 3.17 in prep for patch02 release.
! *
! * Revision 3.17 1994/11/05 01:40:34 dm
! * make sure the cursors are closed in all cases after a statement.
! * make sure memory is only freed which has been allocated.
! *
! * Revision 3.16 1994/09/28 20:40:55 dm
! * fix forward declarations and some arg typing.
! *
! * Revision 3.15 1994/09/22 23:27:42 dm
! * change the esql lib interface to keep up with informix 5.0.
! * change DCURSOR structure to set cursor and statement name. then
! * use those strings to index into the backend list rather than store
! * cursors in the dsql server.
! *
! * Revision 3.14 1993/03/26 11:30:54 dm
* malloc(0) returns NULL on some systems. a procedure
* returning no data will have a record size of 0 but we don't
* want to induce a malloc() failure on that account.
! *
* Revision 3.13 93/03/05 11:20:52 dm
* add number of rows processed (if non-zero) to OK reply.
*
***************
*** 97,103 ****
* *** empty log message ***
*
*/
!
/* system includes */
# include
# include
--- 116,124 ----
* *** empty log message ***
*
*/
!
! #define InformixRelease 6 /* cover esql lib change after 4 */
!
/* system includes */
# include
# include
***************
*** 111,116 ****
--- 132,138 ----
# include "sqlda.h"
# include "sqlstype.h"
# include "sqlhdr.h"
+ # include "decimal.h"
/* server includes */
# include "dsqlsrvr.h"
***************
*** 132,139 ****
typedef struct {
int flag;
! char name[16]; /* name of this cursor */
_SQCURSOR cursor;
struct sqlda *descrip; /* descriptor */
char *recbuf; /* ptr to buf for one record */
int recbufsize; /* size of buffered select data */
--- 154,166 ----
typedef struct {
int flag;
! #if (InformixRelease < 5)
! char name[16]; /* name of this cursor */
_SQCURSOR cursor;
+ #else
+ char st_name[16]; /* name of this statement */
+ char cr_name[16]; /* name of this cursor */
+ #endif /* Informix Release */
struct sqlda *descrip; /* descriptor */
char *recbuf; /* ptr to buf for one record */
int recbufsize; /* size of buffered select data */
***************
*** 143,158 ****
static char Idelim = '|'; /* default field delimiter */
static long lastSerialNum; /* hold last serial number */
static DCURSOR *current_cursor = NULL;
static DCURSOR dcursorlist[DCLISTSIZE];
static unsigned long sqlchksum; /* running check sum */
static DCURSOR *newdcursor();
static DCURSOR *getdcursor(int);
- static char cmdbuf[4096];
-
/* SQL DATABASE ACCESS COMMANDS */
int Iinit();
int Idsql();
--- 170,189 ----
static char Idelim = '|'; /* default field delimiter */
static long lastSerialNum; /* hold last serial number */
+ #if (InformixRelease > 4)
+ static _FetchSpec fSpec;
+ #endif /* InformixRelease */
+
static DCURSOR *current_cursor = NULL;
static DCURSOR dcursorlist[DCLISTSIZE];
static unsigned long sqlchksum; /* running check sum */
+ static char cmdbuf[4096];
static DCURSOR *newdcursor();
static DCURSOR *getdcursor(int);
+ static int setDelim(char *delim, int nst, int est);
/* SQL DATABASE ACCESS COMMANDS */
int Iinit();
int Idsql();
***************
*** 173,179 ****
static void Iflushsql();
static int Isqlerror();
- extern char *stripcmd();
extern char *nextword();
int
--- 204,209 ----
***************
*** 188,196 ****
/* set the cursor names */
for (dc = dcursorlist, i = 0; i < DCLISTSIZE; dc++, i++) {
- sprintf(dc->name, "dc%d", i);
dc->flag = DC_FREE;
}
/* parse the (optional) words within quote marks */
db = cmd +1;
cp = db;
--- 218,236 ----
/* set the cursor names */
for (dc = dcursorlist, i = 0; i < DCLISTSIZE; dc++, i++) {
dc->flag = DC_FREE;
+ #if (InformixRelease < 5)
+ sprintf(dc->name, "dc%d", i);
}
+ #else
+ sprintf(dc->cr_name, "cr%d", i);
+ sprintf(dc->st_name, "st%d", i);
+ }
+ fSpec.fval = 0;
+ fSpec.fdir = 0;
+ fSpec.findchk = 0;
+ #endif /* InformixRelease */
+
/* parse the (optional) words within quote marks */
db = cmd +1;
cp = db;
***************
*** 207,216 ****
return 0;
default:
if (!Idosql(1)) {
- Iflushsql();
return 0;
}
- Iflushsql();
sprintf(dbcmd, "%s opened", db);
break;
}
--- 247,254 ----
***************
*** 240,246 ****
reply(R_CONT, R_DSQL, C_ISOK, "continue...");
/* expecting multiline SQL statement(s) */
! *cmdbuf = '\0';
bufend = cmdbuf;
havedata = FALSE;
datapending = FALSE;
--- 278,284 ----
reply(R_CONT, R_DSQL, C_ISOK, "continue...");
/* expecting multiline SQL statement(s) */
! cmdbuf[0] = '\0';
bufend = cmdbuf;
havedata = FALSE;
datapending = FALSE;
***************
*** 262,268 ****
strcat(cmdbuf, " ");
bufend++;
}
-
/* execute statement(s) in order received */
/* may want more logic here later to handle macos internally */
--- 300,305 ----
***************
*** 330,341 ****
break;
default:
if (!Idosql(s_no)) {
- Iflushsql();
return est;
}
if (sqlca.sqlerrd[2])
sprintf(rbuf, "%ld row(s) processed; ", sqlca.sqlerrd[2]);
- Iflushsql();
break;
}
} while (se < bufend);
--- 367,376 ----
***************
*** 346,351 ****
--- 381,388 ----
int
Iinfo(cmd, nst, est)
+ char *cmd;
+ int nst, est;
{
char *type;
***************
*** 359,367 ****
}
static int
! setDelim(delim, nst, est)
! char *delim;
! int nst, est;
{
if (*delim && *delim < '\177') {
Idelim = *delim;
--- 396,402 ----
}
static int
! setDelim(char *delim, int nst, int est)
{
if (*delim && *delim < '\177') {
Idelim = *delim;
***************
*** 471,481 ****
--- 506,521 ----
static int
Isqlprepare(sqlstr, stmt)
char *sqlstr;
+ int stmt;
{
if ((current_cursor = newdcursor()) == NULL) return SQL_ERR;
/* $ prepare stmt_id from $sqlstr; */
+ #if (InformixRelease < 5)
_iqprepare(¤t_cursor->cursor, sqlstr);
+ #else
+ _iqnprep(current_cursor->st_name, sqlstr, 0);
+ #endif /* InformixRelease */
if (Isqlerror(stmt)) {
Iflushsql();
***************
*** 483,489 ****
}
/* $ describe stmt_id into sel_desc; */
! _iqdscribe(¤t_cursor->cursor, ¤t_cursor->descrip);
if (Isqlerror(stmt)) {
Iflushsql();
--- 523,533 ----
}
/* $ describe stmt_id into sel_desc; */
! #if (InformixRelease < 5)
! _iqprepare(¤t_cursor->cursor, sqlstr);
! #else
! _iqdescribe(_iqlocate_cursor(current_cursor->st_name, 1, 0), ¤t_cursor->descrip, (char *) 0);
! #endif /* InformixRelease */
if (Isqlerror(stmt)) {
Iflushsql();
***************
*** 511,529 ****
--- 555,590 ----
}
/* $ declare sel_cursor scroll cursor for stmt_id; */
+ #if (InformixRelease < 5)
_iqddclcur(¤t_cursor->cursor, current_cursor->name, 32);
+ #else
+ _iqcddcl(_iqlocate_cursor(current_cursor->cr_name, 0, 0),
+ current_cursor->cr_name,
+ _iqlocate_cursor(current_cursor->st_name, 1, 0), 32);
+ #endif /* InformixRelease */
if (Isqlerror(stmt)) return 0;
/* $ open sel_cursor; */
+ #if (InformixRelease < 5)
_iqcopen(¤t_cursor->cursor, 0, (char *) 0, (char *) 0, (char *) 0, 0);
+ #else
+ _iqdcopen(_iqlocate_cursor(current_cursor->cr_name, 0, 0), (struct sqlda *) 0, (char *) 0, (struct value *) 0, 0, 0);
+ #endif /* InformixRelease */
if (Isqlerror(stmt)) return 0;
/* $ fetch first sel_cursor using descriptor sel_desc; */
+ #if (InformixRelease < 5)
_iqnftch(¤t_cursor->cursor, 0, (char *) 0, current_cursor->descrip,
3, (long) 0, 0, (char *) 0, (char *) 0, 0);
+ #else
+ fSpec.fval = 0;
+ fSpec.fdir = 3;
+ _iqcftch(_iqlocate_cursor(current_cursor->cr_name, 0, 0),
+ (struct sqlda *) 0, current_cursor->descrip, (char *) 0, &fSpec);
+ #endif /* InformixRelease */
if (Isqlerror(stmt)) {
return 0;
***************
*** 539,545 ****
{
char *cp1, *type;
long offset;
! int cursor_idx, fetch_type, dcount;
DCURSOR *dc;
char tbuf[16];
--- 600,609 ----
{
char *cp1, *type;
long offset;
! int cursor_idx, dcount;
! #if (InformixRelease < 5)
! int fetch_type;
! #endif /* InformixRelease */
DCURSOR *dc;
char tbuf[16];
***************
*** 555,579 ****
--- 619,678 ----
}
if (Match(type, "NEXT") || Match(type, "next")) {
+ #if (InformixRelease < 5)
fetch_type = 1;
+ #else
+ fSpec.fval = 0;
+ fSpec.fdir = 1;
+ #endif /* InformixRelease */
}
else if (Match(type, "PREV") || Match(type, "prev")) {
+ #if (InformixRelease < 5)
fetch_type = 2;
+ #else
+ fSpec.fval = 0;
+ fSpec.fdir = 2;
+ #endif /* InformixRelease */
}
else if (Match(type, "FIRST") || Match(type, "first")) {
+ #if (InformixRelease < 5)
fetch_type = 3;
+ #else
+ fSpec.fval = 0;
+ fSpec.fdir = 3;
+ #endif /* InformixRelease */
}
else if (Match(type, "LAST") || Match(type, "last")) {
+ #if (InformixRelease < 5)
fetch_type = 4;
+ #else
+ fSpec.fval = 0;
+ fSpec.fdir = 4;
+ #endif /* InformixRelease */
}
else if (Match(type, "CURRENT") || Match(type, "current")) {
+ #if (InformixRelease < 5)
fetch_type = 5;
+ #else
+ fSpec.fval = 0;
+ fSpec.fdir = 5;
+ #endif /* InformixRelease */
}
else if (isdigit(*type)) { /* ABSOLUTE */
+ #if (InformixRelease < 5)
fetch_type = 6;
+ #else
+ fSpec.fval = offset;
+ fSpec.fdir = 6;
+ #endif /* InformixRelease */
}
else if (*type == '+' || *type == '-') { /* RELATIVE */
+ #if (InformixRelease < 5)
fetch_type = 7;
+ #else
+ fSpec.fval = (int) offset;
+ fSpec.fdir = 7;
+ #endif /* InformixRelease */
}
else {
reply(R_FAIL, R_DSQL, D_CMDPROBLEM, "bad fetch keyword");
***************
*** 580,587 ****
--- 679,691 ----
return est;
}
+ #if (InformixRelease < 5)
_iqnftch(&dc->cursor, 0, (char *) 0, dc->descrip, fetch_type, offset,
0, (char *) 0, (char *) 0, 0);
+ #else
+ _iqcftch(_iqlocate_cursor(dc->cr_name, 0, 0),
+ (struct sqlda *) 0, dc->descrip, (char *) 0, &fSpec);
+ #endif /* InformixRelease */
if (Isqlerror(cursor_idx)) return est;
if (sqlca.sqlcode == SQLNOTFOUND) {
***************
*** 611,628 ****
return nst;
}
! /* return -1 if no problems, 0 for err. */
static int
Idosql(stmt)
int stmt;
{
/* $ execute stmt_id; */
_iqxecute(¤t_cursor->cursor, 0, (char *) 0, (char *) 0, (char *) 0);
lastSerialNum = sqlca.sqlerrd[1];
! if (Isqlerror(stmt)) return 0;
! return -1;
}
/* read in whole data records until there's no more room in
--- 715,742 ----
return nst;
}
! /* return -1 if no problems, 0 for err.
! * this function always flushed the buffers and closes the cursor.
! */
static int
Idosql(stmt)
int stmt;
{
+ int retval = -1;
/* $ execute stmt_id; */
+ #if (InformixRelease < 5)
_iqxecute(¤t_cursor->cursor, 0, (char *) 0, (char *) 0, (char *) 0);
+ #else
+ _iqexecute(_iqlocate_cursor(current_cursor->st_name, 1, 0),
+ (struct sqlda *) 0, (char *) 0, (struct value *) 0,
+ (struct sqlda *) 0, (char *) 0, (struct value *) 0);
+ #endif /* InformixRelease */
lastSerialNum = sqlca.sqlerrd[1];
! if (Isqlerror(stmt)) retval = 0;
! Iflushsql();
! return retval;
}
/* read in whole data records until there's no more room in
***************
*** 645,652 ****
--- 759,773 ----
bufload += strlen(endo);
/* $ fetch next sel_cursor using descriptor sel_desc; */
+ #if (InformixRelease < 5)
_iqnftch(¤t_cursor->cursor, 0, (char *) 0,
current_cursor->descrip, 1, (long) 0, 0, (char *) 0, (char *) 0, 0);
+ #else
+ fSpec.fval = 0;
+ fSpec.fdir = 1;
+ _iqcftch(_iqlocate_cursor(current_cursor->cr_name, 0, 0),
+ (struct sqlda *) 0, current_cursor->descrip, (char *) 0, &fSpec);
+ #endif /* InformixRelease */
if (sqlca.sqlcode == SQLNOTFOUND) { /* no more data */
havedata = FALSE;
***************
*** 681,687 ****
case CFLOATTYPE:
if (*col->sqlind < 0) break;
! bycopy(col->sqldata, &f, sizeof(float));
sprintf(numstr, "%f", f);
strcat(dbuf, numstr);
bytes += strlen(numstr);
--- 802,808 ----
case CFLOATTYPE:
if (*col->sqlind < 0) break;
! bycopy(col->sqldata, (char *) &f, sizeof(float));
sprintf(numstr, "%f", f);
strcat(dbuf, numstr);
bytes += strlen(numstr);
***************
*** 688,694 ****
break;
case CDOUBLETYPE:
if (*col->sqlind < 0) break;
! bycopy(col->sqldata, &d, sizeof(double));
sprintf(numstr, "%lf", d);
strcat(dbuf, numstr);
bytes += strlen(numstr);
--- 809,815 ----
break;
case CDOUBLETYPE:
if (*col->sqlind < 0) break;
! bycopy(col->sqldata, (char *) &d, sizeof(double));
sprintf(numstr, "%lf", d);
strcat(dbuf, numstr);
bytes += strlen(numstr);
***************
*** 695,701 ****
break;
case CDECIMALTYPE:
if (*col->sqlind < 0) break;
! dectoasc(col->sqldata,numstr,DSTRSZ,-1);
ldchar(numstr,DSTRSZ,numstr);
strcat(dbuf, numstr);
bytes += strlen(numstr);
--- 816,822 ----
break;
case CDECIMALTYPE:
if (*col->sqlind < 0) break;
! dectoasc((dec_t *)col->sqldata, numstr, DSTRSZ, -1);
ldchar(numstr,DSTRSZ,numstr);
strcat(dbuf, numstr);
bytes += strlen(numstr);
***************
*** 737,743 ****
--- 858,868 ----
case SQLSMFLOAT:
pos = rtypalign(pos,CFLOATTYPE);
col->sqltype = CFLOATTYPE;
+ #if (InformixRelease < 5)
col->sqllen = rtypmsize(CFLOATTYPE);
+ #else
+ col->sqllen = rtypmsize(CFLOATTYPE, SIZSMFLOAT);
+ #endif /* InformixRelease */
pos += col->sqllen;
break;
***************
*** 744,750 ****
--- 869,879 ----
case SQLFLOAT:
pos = rtypalign(pos,CDOUBLETYPE);
col->sqltype = CDOUBLETYPE;
+ #if (InformixRelease < 5)
col->sqllen = rtypmsize(CDOUBLETYPE);
+ #else
+ col->sqllen = rtypmsize(CDOUBLETYPE, SIZFLOAT);
+ #endif /* InformixRelease */
pos += col->sqllen;
break;
***************
*** 752,758 ****
--- 881,891 ----
case SQLDECIMAL:
pos = rtypalign(pos,CDECIMALTYPE);
col->sqltype = CDECIMALTYPE;
+ #if (InformixRelease < 5)
col->sqllen = rtypmsize(CDECIMALTYPE);
+ #else
+ col->sqllen = rtypmsize(CDECIMALTYPE, SIZDECIMAL);
+ #endif /* InformixRelease */
pos += col->sqllen;
break;
***************
*** 905,916 ****
int closedcursor(dc)
DCURSOR *dc;
{
! if (dc->flag == DC_FREE) return 0; /* not open */
! free(dc->recbuf);
! free(dc->ind);
dc->flag = DC_FREE;
/* $ close sel_cursor; */
_iqclose(&dc->cursor);
return -1;
}
--- 1038,1061 ----
int closedcursor(dc)
DCURSOR *dc;
{
! if (!dc || dc->flag == DC_FREE) return 0; /* not open */
! if (dc->recbuf) {
! free(dc->recbuf);
! dc->recbuf = NULL;
! }
!
! if (dc->ind) {
! free(dc->ind);
! dc->ind = NULL;
! }
!
dc->flag = DC_FREE;
/* $ close sel_cursor; */
+ #if (InformixRelease < 5)
_iqclose(&dc->cursor);
+ #else
+ _iqclose(_iqlocate_cursor(dc->cr_name, 0, 0));
+ #endif /* InformixRelease */
return -1;
}
*** statetab.h.old Thu Mar 17 10:01:43 1994
--- statetab.h Thu Dec 15 10:53:57 1994
***************
*** 38,44 ****
extern int fetch();
extern int close_cursor();
extern int dchdir();
! extern int env();
extern int abrt();
extern int quit();
--- 38,44 ----
extern int fetch();
extern int close_cursor();
extern int dchdir();
! extern int sysenv();
extern int abrt();
extern int quit();
***************
*** 106,113 ****
{"DBMS [^ ][^ ]* \".*\" \".*\"$", CMD, CMD, dbms},
{"DBUG$", CMD, CMD, debuglog},
! {"CHDIR [^ ][^ ]*$", CMD, CMD, dchdir},
! {"ENV [^ ]*ET ..*$", CMD, CMD, env},
{"QUIT$", NOSTATE, NOSTATE, quit},
{NULL}}
--- 106,113 ----
{"DBMS [^ ][^ ]* \".*\" \".*\"$", CMD, CMD, dbms},
{"DBUG$", CMD, CMD, debuglog},
! {"CHDIR [^ ].*$", CMD, CMD, dchdir},
! {"ENV [^ ]*ET ..*$", CMD, CMD, sysenv},
{"QUIT$", NOSTATE, NOSTATE, quit},
{NULL}}
*** unix.c.old Wed Jun 15 16:10:53 1994
--- unix.c Thu Dec 15 10:53:57 1994
***************
*** 23,37 ****
*/
# ifndef lint
! static char *rcsid = "$Header: /usr/src/local/sbin/dsql/dsql.3/srvr/RCS/unix.c,v 1.1 1994/06/15 23:00:59 dm Exp $";
# endif
/* these functions are unix io. no database specific routines.
*
* $Log: unix.c,v $
! * Revision 1.1 1994/06/15 23:00:59 dm
! * Initial revision
*
* Revision 3.10 93/02/26 16:39:31 dm
* ensure entire buffer is written at low level.
* drop wait() call in killChild(). dsql_wait() will reap
--- 23,60 ----
*/
# ifndef lint
! static char *rcsid = "$Header: /usr/src/local/sbin/dsql/srvr/src/RCS/unix.c,v 3.18 1994/11/05 01:39:14 dm Exp $";
# endif
/* these functions are unix io. no database specific routines.
*
* $Log: unix.c,v $
! * Revision 3.18 1994/11/05 01:39:14 dm
! * debug byte count from actual read() return.
*
+ * Revision 3.17 1994/09/29 01:54:40 dm
+ * undo the previous change. never thought that was thhe problem.
+ *
+ * Revision 3.16 1994/09/28 20:40:33 dm
+ * for some reason, initgroups() seg faults if we don't use a local
+ * buffer. still under investigation.
+ *
+ * Revision 3.15 1994/06/15 23:16:24 dm
+ * port to alpha. change type for time().
+ *
+ * Revision 3.14 1994/03/03 11:14:43 dm
+ * changes made in solaris port; uninstalled and untested at this time.
+ *
+ * Revision 3.13 94/03/03 10:22:41 dm
+ * fix Uchdir to allow spaces in path names.
+ *
+ * Revision 3.12 94/01/31 14:39:19 dm
+ * use inet_ntoa() to get ip string.
+ *
+ * Revision 3.11 93/12/16 18:47:49 dm
+ * not really part of v3 but we needed it for clinical: put client
+ * IP in the environment.
+ *
* Revision 3.10 93/02/26 16:39:31 dm
* ensure entire buffer is written at low level.
* drop wait() call in killChild(). dsql_wait() will reap
***************
*** 152,158 ****
/* functions */
void goodbye();
! void dsql_wait();
extern void reply();
char inbuf[4*BUFSIZ]; /* buffer for input from client */
--- 175,181 ----
/* functions */
void goodbye();
! void dsql_wait(int);
extern void reply();
char inbuf[4*BUFSIZ]; /* buffer for input from client */
***************
*** 175,184 ****
# ifndef DEBUG
openlog("v3 dsql server", LOG_PID, LOG_LOCAL3);
i = sizeof(sin);
! if (getpeername(c_rd, &sin, &i) < 0) {
syslog(LOG_ERR|LOG_DEBUG, "getpeername failed: %m");
return FALSE;
}
peer = gethostbyaddr((char *) &sin.sin_addr, sizeof(sin.sin_addr),
sin.sin_family);
--- 198,210 ----
# ifndef DEBUG
openlog("v3 dsql server", LOG_PID, LOG_LOCAL3);
i = sizeof(sin);
! if (getpeername(c_rd, (struct sockaddr *)&sin, &i) < 0) {
syslog(LOG_ERR|LOG_DEBUG, "getpeername failed: %m");
return FALSE;
}
+ /* this is really part of v4 but we need it now */
+ setenv("DSQLCLIENTIP", inet_ntoa(sin.sin_addr, 1));
+
peer = gethostbyaddr((char *) &sin.sin_addr, sizeof(sin.sin_addr),
sin.sin_family);
***************
*** 280,285 ****
--- 306,312 ----
char *newdir;
newdir = stripcmd(cmd);
+ nextword(newdir);
if (chdir(newdir) == -1) {
reply(R_FAIL, R_DSQL, D_SYSERR, strerror(errno));
return est;
***************
*** 315,323 ****
--- 342,355 ----
return nst;
}
else if (Match(type, "UNSET")) { /* no error if not set */
+ #ifndef sun
unsetenv(var);
reply(R_GOOD, R_DSQL, D_ISOK, "unsetenv ok");
return nst;
+ #else /* sun don't have unsetenv() */
+ reply(R_FAIL, R_DSQL, D_NOTIMPL, "can not unsetenv on SUN systems!");
+ return est;
+ #endif
}
reply(R_FAIL, R_DSQL, D_CMDPROBLEM, "unknown ENV type");
return est;
***************
*** 333,339 ****
exit(0);
}
! void dsql_wait()
{
int w_status;
int pid;
--- 365,371 ----
exit(0);
}
! void dsql_wait(i)
{
int w_status;
int pid;
***************
*** 350,356 ****
showTime(nst, est)
{
struct tm *now, *localtime();
! long clock, time();
char tmbuf[30];
clock = time(0);
--- 382,388 ----
showTime(nst, est)
{
struct tm *now, *localtime();
! time_t clock, time();
char tmbuf[30];
clock = time(0);
***************
*** 409,415 ****
--- 441,450 ----
if ((pipe_pid = vfork()) == 0) {
signal(SIGCHLD, SIG_IGN);
+ #ifndef sun /* sun does not support this usage */
setpgrp(getpid(), getpid());
+ #endif
+
/* myside and hisside reverse roles in child */
close(myside);
if (hisside != tst(0, 1)) {
***************
*** 445,453 ****
dsql_pclose(child)
int child;
{
! sigset_t mask = 0;
! mask = sigmask(SIGCHLD);
sigprocmask(SIG_UNBLOCK, &mask, NULL);
popen_pid[child] = -1;
dsql_close(child);
--- 480,489 ----
dsql_pclose(child)
int child;
{
! sigset_t mask;
! sigemptyset(&mask);
! sigaddset(&mask, SIGCHLD);
sigprocmask(SIG_UNBLOCK, &mask, NULL);
popen_pid[child] = -1;
dsql_close(child);
***************
*** 568,574 ****
cp = tmpbuf;
while ((cp = strchr(cp, '\n')) != NULL) *cp = 'J';
truncbuf(tmpbuf, n);
! syslog(LOG_ERR|LOG_DEBUG, "read %d:>%s", n, tmpbuf);
}
}
--- 604,610 ----
cp = tmpbuf;
while ((cp = strchr(cp, '\n')) != NULL) *cp = 'J';
truncbuf(tmpbuf, n);
! syslog(LOG_ERR|LOG_DEBUG, "read %d:>%s", f->count, tmpbuf);
}
}
***************
*** 624,630 ****
/* vms does not have unlink() so this is more portable */
int
removefile(f)
! int f;
{
return unlink(f);
}
--- 660,678 ----
/* vms does not have unlink() so this is more portable */
int
removefile(f)
! char * f;
{
return unlink(f);
}
+
+ #ifdef sun /* ugh! */
+ setenv(var, val, n)
+ char *var, *val;
+ int n;
+ {
+ char tbuf[BUFSIZ];
+
+ sprintf(tbuf, "%s=%s", var, val);
+ putenv(tbuf);
+ }
+ #endif /* sun */
|