]> andersk Git - moira.git/commitdiff
Oracle and Solaris/POSIX changes
authordanw <danw>
Mon, 20 Jan 1997 18:26:06 +0000 (18:26 +0000)
committerdanw <danw>
Mon, 20 Jan 1997 18:26:06 +0000 (18:26 +0000)
Removed outdated TODO list and Ingres-specific files

26 files changed:
server/Imakefile
server/TODO [deleted file]
server/cache.dc
server/increment.dc
server/malloc.h [deleted file]
server/meinitlst.c [deleted file]
server/mr_glue.c
server/mr_main.c
server/mr_sauth.c
server/mr_sbrk.c [deleted file]
server/mr_scall.c
server/mr_server.h
server/mr_shutdown.c
server/mr_smalloc.c [deleted file]
server/mr_util.c
server/qaccess.dc
server/qfollow.dc
server/qrtn.dc
server/qrtn.h
server/qsetup.dc
server/qsubs.c
server/qsupport.dc
server/queries2.c
server/query.h
server/qvalidate.dc
server/startmoira.c

index 36c38cf8af9d20a3e8e502bebee3020c008fb152..6ab2adbbba6579b0daba45f4209caede54f9fc6e 100644 (file)
@@ -8,49 +8,39 @@
 # Imakefile for server directory.
 #
 
-#ifdef INGRES
-XSRC= mr_sbrk.c meinitlst.c
-XOBJ= mr_sbrk.o meinitlst.o
-#else
-XSRC=
-XOBJ=
-#endif
-
-DEFINES=-DGDSS -I/mit/gdss/include -I.
+DEFINES= -I. $(GDSSINC)
 
 SRCS = startmoira.c mr_main.c mr_sauth.c mr_scall.c \
-       mr_srvdata.c mr_shutdown.c mr_util.c qrtn.c \
-       qsupport.c qsubs.c queries2.c mr_smalloc.c \
-       increment.c cache.c mr_glue.c qvalidate.c \
-       mr_server.h query.h qrtn.h qaccess.c qsetup.c \
-       qfollow.c malloc.h $(XSRC)
+       mr_srvdata.c mr_shutdown.c mr_util.c \
+       mr_server.h query.h qrtn.h qrtn.c \
+       qsupport.c qsubs.c queries2.c increment.c \
+       cache.c mr_glue.c qvalidate.c qaccess.c qsetup.c \
+       qfollow.c
 CODE= startmoira.c mr_main.c mr_sauth.c mr_scall.c \
-       mr_srvdata.c mr_shutdown.c mr_util.c qrtn.dc \
-       qsupport.dc qsubs.c queries2.c mr_smalloc.c \
-       increment.dc cache.dc mr_glue.c qvalidate.dc \
-       Imakefile mr_server.h query.h qrtn.h qaccess.dc \
-       qsetup.dc qfollow.dc malloc.h $(XSRC)
+       mr_srvdata.c mr_shutdown.c mr_util.c \
+       mr_server.h query.h qrtn.h qrtn.dc \
+       qsupport.dc qsubs.c queries2.c increment.dc \
+       cache.dc mr_glue.c qvalidate.dc Imakefile \
+       qaccess.dc qsetup.dc qfollow.dc
 SRVOBJ=mr_main.o mr_sauth.o mr_scall.o mr_srvdata.o mr_shutdown.o \
        mr_util.o qrtn.o queries2.o qsupport.o qsubs.o \
-       mr_smalloc.o increment.o cache.o qvalidate.o \
-       qaccess.o qsetup.o qfollow.o $(XOBJ)
+       increment.o cache.o qvalidate.o \
+       qaccess.o qsetup.o qfollow.o
 GLUOBJS=mr_glue.o qrtn.o queries2.o qsupport.o qsubs.o \
-       ../lib/mr_et.o mr_srvdata.o mr_smalloc.o \
+       ../lib/mr_et.o mr_sauth.o mr_srvdata.o \
        ../lib/krb_et.o mr_util.o increment.o cache.o \
-       qvalidate.o qaccess.o qsetup.o qfollow.o $(XOBJ)
+       qvalidate.o qaccess.o qsetup.o qfollow.o
 SRCDIR = $(SRCTOP)/server
 sqlrule()
 
 program(moirad, ${SRVOBJ},${MR_LIBDEP} ${GDB_LIBDEP},\
        -L/usr/athena/lib .././lib/libmoira.a -lzephyr \
-       .././gdb/libmrgdb.a  -lcom_err \
-       /mit/gdss/`machtype`/libgdss.a -lkrb -ldes -lhesiod \
-       ${SQL_LIB}, ${PROGDIR})
+       .././gdb/libmrgdb.a  -lcom_err $(LIBGDSS)\
+       -lkrb -ldes -lhesiod ${SQL_LIB}, ${PROGDIR})
 program(startmoira, startmoira.o,${MR_LIBDEP} ${GDB_LIBDEP},\
-      -L/usr/athena/lib .././lib/libmoira.a -lzephyr \
-      .././gdb/libmrgdb.a -lcom_err \
-      /mit/gdss/`machtype`/libgdss.a -lkrb -ldes -lhesiod \
-      ${SQL_LIB}, ${PROGDIR})
+       -L/usr/athena/lib .././lib/libmoira.a -lzephyr \
+       .././gdb/libmrgdb.a -lcom_err -lkrb -ldes -lhesiod,\
+       ${PROGDIR})
 library_obj_rule()
 install_library_target(mrglue,$(GLUOBJS),$(SRCS),)
 
diff --git a/server/TODO b/server/TODO
deleted file mode 100644 (file)
index 1470b28..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
-Bugs
-----
-
-"Query complete." is printed twice after alis, dlis, and others.
-fflush() before the vfork(), strangely, does not fix this.
-
-The _exit() in next_incremental() may allow memory leakage from the 
-incremental updates, as well as leaving other things (?) not cleaned up.
-Maybe this should be investigated.
-
-Timeouts may sometimes be other errors.  Need to parse the error message
-string when the error number is 39100 to figure out if it is a timeout or not.
-
-gnfq/gqot do not handle wildcards in <login>/<name>.  (Could they?
-Do they need it?) They do handle wildcards for filesystem names.
-
-
-Try to improve performance:
----------------------------
-gqot/dqot
-
-
-Improvements
-------------
-
-Add case insensitivity: List names, others(?)
-
-Abstraction for string retrieval
-
-
-Other
------
-
-rsve, dsin, sshi have range variable problems
index 6ee13326251aab7a76a2e0a32c40c96b75394bd2..fa155d3d2e74f3fa5b01050cdb65edf27ae439c3 100644 (file)
@@ -11,33 +11,14 @@ static char *rcsid_cache_dc = "$Header$";
 #endif lint
 
 #include <mit-copyright.h>
-#include "query.h"
+#include <string.h>
 #include "mr_server.h"
+#include "query.h"
 EXEC SQL INCLUDE sqlca;
 
-EXEC SQL WHENEVER SQLERROR CALL ingerr;
-
-extern char *whoami, *strsave();
-extern int ingres_errno, mr_errcode;
-
+EXEC SQL WHENEVER SQLERROR DO dbmserr();
 
-/*** NOTE **************************************************************
- *
- *    This code depends on each type starting with a unique letter.  If
- *    any new types are added to the system that begin with the same
- *    letter as one of the existing types:
- *             User
- *             List
- *             String
- *             Machine
- *             Subnet
- *             Cluster
- *             Filesystem
- *    then we will have to rework the code that only looks at the first
- *    letter of the types.
- *
- ***********************************************************************
- */
+extern char *whoami;
 
 /* Cache parameters: */
 #define CACHESIZE 101          /* number of cache slots */
@@ -45,7 +26,7 @@ extern int ingres_errno, mr_errcode;
 
 struct item {
     char name[NAMESZ];
-    char type[9];
+    enum tables type;
     int nhash;
     int id;
     struct item *next;
@@ -63,13 +44,13 @@ int cachehits = 0, cachemisses = 0;
 /* Name hash function. */
 
 int hashname(name, type)
-register char *name;
-char *type;
+     char *name;
+     enum tables type;
 {
-    register int val = *type;
+    register int val = type;
 
     while (*name)
-      val = val<<5 - val + *name++ - '`';
+      val = (val<<5) - val + *name++ - '`';
     return(val);
 }
 
@@ -78,7 +59,7 @@ char *type;
  * if the cache was previously in use.
  */
 
-flush_cache()
+void flush_cache(void)
 {
     register struct item *i;
 
@@ -105,23 +86,21 @@ flush_cache()
  */
 
 int name_to_id(name, type, id)
-char *name;
-char *type;
-int *id;
+     char *name;
+     enum tables type;
+     int *id;
 {
     register struct item *i, *t;
     EXEC SQL BEGIN DECLARE SECTION;
     char *iname;
-    int j, rowcount;
+    int j, h;
     EXEC SQL END DECLARE SECTION;
-    char key;
-    int h, ctr;
 
     h = hashname(name, type);
     for (i = cachehead.next; i != &cachehead; i = i->next) {
        if (i->nhash != h ||
            strcmp(name, i->name) ||
-           strcasecmp(type, i->type))
+           type!=i->type)
          continue;
        *id = i->id;
        cachehits++;
@@ -136,55 +115,49 @@ int *id;
 
     cachemisses++;
     iname = name;
-    key = *type;
 
-    if (!strcasecmp(type, "subnet"))
-      key = 'N';
-
-    switch (key) {
-    case 'U':
-    case 'u':
-       if (index(iname, '@') || (strlen(iname) > 8)) {
-           sqlca.sqlcode = 100;
-           break;
+    switch (type)
+      {
+      case USERS_TABLE:
+       if (strchr(iname, '@') || (strlen(iname) > 8)) {
+         sqlca.sqlcode = SQL_NO_MATCH;
+         break;
        }
        EXEC SQL SELECT users_id INTO :j FROM users WHERE login=:iname;
        break;
-    case 'L':
-    case 'l':
+      case LIST_TABLE:
        EXEC SQL SELECT list_id INTO :j FROM list WHERE name=:iname;
        break;
-    case 'M':
-    case 'm':
-       EXEC SQL SELECT mach_id INTO :j FROM machine WHERE name=UPPERCASE(:iname);
+      case MACHINE_TABLE:
+       EXEC SQL SELECT mach_id INTO :j FROM machine WHERE name=UPPER(:iname);
        break;
-    case 'N':
-    case 'n':
-       EXEC SQL SELECT snet_id INTO :j FROM subnet WHERE name=UPPERCASE(:iname);
+      case SUBNET_TABLE:
+       EXEC SQL SELECT snet_id INTO :j FROM subnet WHERE name=UPPER(:iname);
        break;
-    case 'C':
-    case 'c':
-       EXEC SQL SELECT clu_id INTO :j FROM cluster WHERE name=:iname;
+      case CLUSTER_TABLE:
+       EXEC SQL SELECT clu_id INTO :j FROM clusters WHERE name=:iname;
        break;
-    case 'F':
-    case 'f':
+      case FILESYS_TABLE:
        EXEC SQL SELECT filsys_id INTO :j FROM filesys WHERE label=:iname;
        break;
-    case 'S':
-    case 's':
+      case STRINGS_TABLE:
+       if (!iname[0]) { /* special-case empty string */
+         *id=0;
+         return MR_SUCCESS;
+       }
        EXEC SQL SELECT string_id INTO :j FROM strings WHERE string=:iname;
        break;
-    default:
+      default:
        return(MR_INTERNAL);
     }
-    if (sqlca.sqlcode == 100)
+    if (sqlca.sqlcode == SQL_NO_MATCH)
       return(MR_NO_MATCH);
     if (sqlca.sqlerrd[2] > 1)
       return(MR_NOT_UNIQUE);
     if (sqlca.sqlcode != 0)
-      return(MR_INGRES_ERR);
+      return(MR_DBMS_ERR);
     *id = j;
-    if (name[0] == '#' && !strcasecmp(type, "USER"))
+    if (name[0] == '#' && type!=USERS_TABLE)
       return(MR_SUCCESS);
     if (cachesize < CACHESIZE) {
        i = (struct item *) malloc(sizeof(struct item));
@@ -195,19 +168,17 @@ int *id;
        i->prev->next = &cachehead;
     }
     strcpy(i->name, name);
-    strcpy(i->type, type);
+    i->type=type;
     i->nhash = h;
     i->id = j;
     i->next = cachehead.next;
     i->prev = &cachehead;
+    i->trans = NULL;
     cachehead.next->prev = i;
     cachehead.next = i;
     /* find the end of the transaction chain & add this item */
     for (t = &cachehead; t->trans && t != i; t = t->trans);
-    if (t != i) {
-       t->trans = i;
-       i->trans = (struct item *)NULL;
-    }
+    if (t != i) t->trans = i;
     return(MR_SUCCESS);
 }
 
@@ -218,20 +189,18 @@ int *id;
  */
 
 int id_to_name(id, type, name)
-int id;
-char *type;
-char **name;
+     int id;
+     enum tables type;
+     char **name;
 {
     register struct item *i, *t;
     EXEC SQL BEGIN DECLARE SECTION;
     char iname[NAMESZ];
-    int j, rowcount;
+    int j;
     EXEC SQL END DECLARE SECTION;
-    char key;
-    int ctr;
 
     for (i = cachehead.next; i != &cachehead; i = i->next) {
-       if (i->id != id || strcasecmp(type, i->type)) continue;
+       if (i->id != id || type!=i->type) continue;
        free(*name);
        *name = strsave(i->name);
        cachehits++;
@@ -246,43 +215,34 @@ char **name;
 
     cachemisses++;
     j = id;
-    key = *type;
-    if (!strcasecmp(type, "subnet"))
-      key = 'N';
-
-    switch (key) {
-    case 'U':
-    case 'u':
-       EXEC SQL SELECT CHAR(login) INTO :iname FROM users WHERE users_id=:j;
+
+    switch (type)
+      {
+      case USERS_TABLE:
+       EXEC SQL SELECT login INTO :iname FROM users WHERE users_id=:j;
        break;
-    case 'L':
-    case 'l':
-       EXEC SQL SELECT CHAR(name) INTO :iname FROM list WHERE list_id=:j;
+      case LIST_TABLE:
+       EXEC SQL SELECT name INTO :iname FROM list WHERE list_id=:j;
        break;
-    case 'M':
-    case 'm':
-       EXEC SQL SELECT CHAR(name) INTO :iname FROM machine WHERE mach_id=:j;
+      case MACHINE_TABLE:
+       EXEC SQL SELECT name INTO :iname FROM machine WHERE mach_id=:j;
        break;
-    case 'N':
-    case 'n':
-       EXEC SQL SELECT CHAR(name) INTO :iname FROM subnet WHERE snet_id=:j;
+      case SUBNET_TABLE:
+       EXEC SQL SELECT name INTO :iname FROM subnet WHERE snet_id=:j;
        break;
-    case 'C':
-    case 'c':
-       EXEC SQL SELECT CHAR(name) INTO :iname FROM cluster WHERE clu_id=:j;
+      case CLUSTER_TABLE:
+       EXEC SQL SELECT name INTO :iname FROM clusters WHERE clu_id=:j;
        break;
-    case 'F':
-    case 'f':
-       EXEC SQL SELECT CHAR(label) INTO :iname FROM filesys WHERE filsys_id=:j;
+      case FILESYS_TABLE:
+       EXEC SQL SELECT label INTO :iname FROM filesys WHERE filsys_id=:j;
        break;
-    case 'S':
-    case 's':
-       EXEC SQL SELECT CHAR(string) INTO :iname FROM strings WHERE string_id=:j;
+      case STRINGS_TABLE:
+       EXEC SQL SELECT string INTO :iname FROM strings WHERE string_id=:j;
        break;
     default:
        return(MR_INTERNAL);
     }
-    if (sqlca.sqlcode == 100) {
+    if (sqlca.sqlcode == SQL_NO_MATCH) {
        free(*name);
        sprintf(iname, "#%d", j);
        *name = strsave(iname);
@@ -291,10 +251,10 @@ char **name;
     if (sqlca.sqlerrd[2] > 1)
       return(MR_INTERNAL);
     if (sqlca.sqlcode != 0)
-      return(MR_INGRES_ERR);
+      return(MR_DBMS_ERR);
     free(*name);
     *name = strsave(strtrim(iname));
-    if (**name == '#' && !strcasecmp(type, "USER"))
+    if (**name == '#' && type!=USERS_TABLE)
       return(MR_SUCCESS);
     if (cachesize < CACHESIZE) {
        i = (struct item *) malloc(sizeof(struct item));
@@ -305,19 +265,17 @@ char **name;
        i->prev->next = &cachehead;
     }
     strcpy(i->name, *name);
-    strcpy(i->type, type);
+    i->type=type;
     i->nhash = hashname(*name, type);
     i->id = id;
     i->next = cachehead.next;
     i->prev = &cachehead;
+    i->trans = NULL;
     cachehead.next->prev = i;
     cachehead.next = i;
     /* find the end of the transaction chain & add this item */
     for (t = &cachehead; t->trans && t != i; t = t->trans);
-    if (t != i) {
-       t->trans = i;
-       i->trans = (struct item *)NULL;
-    }
+    if (t != i) t->trans = i;
     return(MR_SUCCESS);
 }
 
@@ -326,15 +284,15 @@ char **name;
  * database.
  */
 
-cache_entry(name, type, id)
-char *name;
-char *type;
-int id;
+int cache_entry(name, type, id)
+     char *name;
+     enum tables type;
+     int id;
 {
     register struct item *i, *t;
 
     for (i = cachehead.next; i != &cachehead; i = i->next)
-      if (i->id == id && !strcmp(i->type, type)) {
+      if (i->id == id && i->type==type) {
          if (strcmp(i->name, name)) {
              strcpy(i->name, name);
              i->nhash = hashname(name, type);
@@ -350,28 +308,26 @@ int id;
        i->prev->next = &cachehead;
     }
     strcpy(i->name, name);
-    strcpy(i->type, type);
+    i->type=type;
     i->nhash = hashname(name, type);
     i->id = id;
     i->next = cachehead.next;
     i->prev = &cachehead;
+    i->trans = NULL;
     cachehead.next->prev = i;
     cachehead.next = i;
     /* find the end of the transaction chain & add this item */
     for (t = &cachehead; t->trans && t != i; t = t->trans);
-    if (t != i) {
-       t->trans = i;
-       i->trans = (struct item *)NULL;
-    }
+    if (t != i) t->trans = i;
     return(MR_SUCCESS);
 }
 
 
 /* Flush something that may or may not already be in the cache. */
 
-flush_name(name, type)
-char *name;
-char *type;
+void flush_name(name, type)
+     char *name;
+     enum tables type;
 {
     int h;
     register struct item *i;
@@ -379,12 +335,11 @@ char *type;
     h = hashname(name, type);
 
     for (i = cachehead.next; i != &cachehead; i = i->next) {
-       if (!strcmp(name, i->name) && !strcasecmp(type, i->type)) {
+       if (!strcmp(name, i->name) && type==i->type) {
            cachesize--;
            i->next->prev = i->prev;
            i->prev->next = i->next;
            free(i);
-           return(MR_SUCCESS);
        }
     }
 }
@@ -394,7 +349,7 @@ char *type;
  * Just throws away the list of cache changes for this transaction.
  */
 
-cache_commit()
+void cache_commit(void)
 {
     cachehead.trans = (struct item *)NULL;
 }
@@ -404,7 +359,7 @@ cache_commit()
  * from that transaction.
  */
 
-cache_abort()
+void cache_abort(void)
 {
     register struct item *i, *t;
 
index c81361a616c2b4c0a5dd07ae824f85cf4d44aba0..a913f2af1b57732ab169c3f1e787a41edd98f4d5 100644 (file)
 static char *rcsid_increment_dc = "$Header$";
 #endif lint
 
-#include <fcntl.h>
 #include <mit-copyright.h>
 #include <moira.h>
-#include "query.h"
+#include <fcntl.h>
+#include <unistd.h>
+#include <signal.h>
 #include "mr_server.h"
+#include "query.h"
+#include "qrtn.h"
 EXEC SQL INCLUDE sqlca;
 
 extern char *whoami;
+extern char *table_name[];
+extern int num_tables;
 
 int inc_pid = 0;
 int inc_running = 0;
@@ -28,27 +33,15 @@ time_t inc_started;
 
 #define MAXARGC 15
 
-EXEC SQL WHENEVER SQLERROR CALL ingerr;
+EXEC SQL WHENEVER SQLERROR DO dbmserr();
 
 /* structures to save before args */
-static char beforeb[MAXARGC][ARGLEN];
 static char *before[MAXARGC];
-EXEC SQL BEGIN DECLARE SECTION;
-char *barg0, *barg1, *barg2, *barg3, *barg4;
-char *barg5, *barg6, *barg7, *barg8, *barg9;
-char *barg10, *barg11, *barg12, *barg13, *barg14;
-EXEC SQL END DECLARE SECTION;
 static int beforec;
-static char *beforetable;
+static enum tables beforetable;
 
 /* structures to save after args */
-static char afterb[MAXARGC][ARGLEN];
 static char *after[MAXARGC];
-EXEC SQL BEGIN DECLARE SECTION;
-char *aarg0, *aarg1, *aarg2, *aarg3, *aarg4;
-char *aarg5, *aarg6, *aarg7, *aarg8, *aarg9;
-char *aarg10, *aarg11, *aarg12, *aarg13, *aarg14;
-EXEC SQL END DECLARE SECTION;
 static int afterc;
 
 /* structures to save entire sets of incremental changes */
@@ -63,281 +56,272 @@ struct iupdate {
     char *service;
 };
 
+void next_incremental(void);
+char **copy_argv(char **argv, int argc);
+void free_argv(char **argv, int argc);
+int table_num(char *table);
 
-incremental_init()
+void incremental_init(void)
 {
     int i;
 
-    for (i = 0; i < MAXARGC; i++) {
-       before[i] = &beforeb[i][0];
-       after[i] = &afterb[i][0];
-    }
-    barg0 = before[0];
-    barg1 = before[1];
-    barg2 = before[2];
-    barg3 = before[3];
-    barg4 = before[4];
-    barg5 = before[5];
-    barg6 = before[6];
-    barg7 = before[7];
-    barg8 = before[8];
-    barg9 = before[9];
-    barg10 = before[10];
-    barg11 = before[11];
-    barg12 = before[12];
-    barg13 = before[13];
-    barg14 = before[14];
-    aarg0 = after[0];
-    aarg1 = after[1];
-    aarg2 = after[2];
-    aarg3 = after[3];
-    aarg4 = after[4];
-    aarg5 = after[5];
-    aarg6 = after[6];
-    aarg7 = after[7];
-    aarg8 = after[8];
-    aarg9 = after[9];
-    aarg10 = after[10];
-    aarg11 = after[11];
-    aarg12 = after[12];
-    aarg13 = after[13];
-    aarg14 = after[14];
     if (incremental_sq == NULL)
       incremental_sq = sq_create();
     if (incremental_exec == NULL)
       incremental_exec = sq_create();
+
+    for(i=0; i<MAXARGC; i++) {
+      before[i]=malloc(ARGLEN);
+      after[i]=malloc(ARGLEN);
+    }
 }
 
 
-incremental_before(table, qual, argv)
-char *table;
-EXEC SQL BEGIN DECLARE SECTION; 
-char *qual;
-EXEC SQL END DECLARE SECTION; 
-char **argv;
+/* record the state of a table row before it is changed */
+
+void incremental_before(table, qual, argv)
+     enum tables table;
+EXEC SQL BEGIN DECLARE SECTION;
+     char *qual, **argv;
+EXEC SQL END DECLARE SECTION;
 {
     EXEC SQL BEGIN DECLARE SECTION;
     int id;
     EXEC SQL END DECLARE SECTION;
 
-    char buffer[512], *name;
+    char *name;
 
     beforetable = table;
 
-    if (!strcmp(table, "users")) {
-       EXEC SQL SELECT u.login, CHAR(u.uid), u.shell, u.last, u.first, u.middle, 
-           CHAR(u.status), u.clearid, u.type
-         INTO :barg0, :barg1, :barg2, :barg3, :barg4, :barg5, :barg6,
-           :barg7, :barg8
-         FROM users u WHERE :qual;
+    switch(table)
+      {
+      case USERS_TABLE:
+       sprintf(stmt_buf, "SELECT u.login, u.unix_uid, u.shell, u.last, "
+               "u.first, u.middle, u.status, u.clearid, u.type "
+               "FROM users u WHERE %s", qual);
+       dosql(before);
        beforec = 9;
-    } else if (!strcmp(table, "machine")) {
-       EXEC SQL SELECT m.name, m.vendor INTO :barg0, :barg1 FROM machine m
-         WHERE :qual;
+       break;
+      case MACHINE_TABLE:
+       sprintf(stmt_buf, "SELECT m.name, m.vendor FROM machine m "
+               "WHERE %s", qual);
+       dosql(before);
        beforec = 2;
-    } else if (!strcmp(table, "cluster")) {
-       EXEC SQL SELECT c.name, c.description, c.location 
-         INTO :barg0, :barg1, :barg2
-         FROM cluster c WHERE :qual;
+       break;
+      case CLUSTER_TABLE:
+       sprintf(stmt_buf, "SELECT c.name, c.description, c.location "
+               "FROM clusters c WHERE %s", qual);
+       dosql(before);
        beforec = 3;
-    } else if (!strcmp(table, "mcmap")) {
-       strcpy(barg0, argv[0]);
-       strcpy(barg1, argv[1]);
+       break;
+      case MCMAP_TABLE:
+       strcpy(before[0], argv[0]);
+       strcpy(before[1], argv[1]);
        beforec = 2;
-    } else if (!strcmp(table, "svc")) {
-       strcpy(barg0, argv[0]);
-       strcpy(barg1, argv[1]);
-       strcpy(barg2, argv[2]);
+       break;
+      case SVC_TABLE:
+       strcpy(before[0], argv[0]);
+       strcpy(before[1], argv[1]);
+       strcpy(before[2], argv[2]);
        beforec = 3;
-    } else if (!strcmp(table, "filesys")) {
-       EXEC SQL SELECT fs.label, fs.type, CHAR(fs.mach_id), fs.name, 
-           fs.mount, fs.access, fs.comments, CHAR(fs.owner), CHAR(fs.owners),
-            CHAR(fs.createflg), fs.lockertype
-         INTO :barg0, :barg1, :barg2, :barg3, :barg4, :barg5, :barg6, 
-            :barg7, :barg8, :barg9, :barg10
-         FROM filesys fs WHERE :qual;
+       break;
+      case FILESYS_TABLE:
+       sprintf(stmt_buf, "SELECT fs.label, fs.type, fs.mach_id, fs.name, "
+               "fs.mount, fs.rwaccess, fs.comments, fs.owner, fs.owners, "
+               "fs.createflg, fs.lockertype FROM filesys fs WHERE %s", qual);
+       dosql(before);
         name = malloc(0);
-        id = atoi(barg2);
-        id_to_name(id, "MACHINE", &name);
-        strcpy(barg2, name);
-        id = atoi(barg7);
-        id_to_name(id, "USER", &name);
-        strcpy(barg7, name);
-        id = atoi(barg8);
-        id_to_name(id, "LIST", &name);
-        strcpy(barg8, name);
+        id = atoi(before[2]);
+        id_to_name(id, MACHINE_TABLE, &name);
+        strcpy(before[2], name);
+        id = atoi(before[7]);
+        id_to_name(id, USERS_TABLE, &name);
+        strcpy(before[7], name);
+        id = atoi(before[8]);
+        id_to_name(id, LIST_TABLE, &name);
+        strcpy(before[8], name);
         free(name);
        beforec = 11;
-    } else if (!strcmp(table, "quota")) {
-       strcpy(barg0, "?");
-       strcpy(barg1, argv[1]);
-       strcpy(barg2, "?");
-       sprintf(buffer, "%s AND fs.filsys_id = q.filsys_id", qual);
-       qual = buffer;
-       EXEC SQL SELECT CHAR(q.quota), fs.name INTO :barg3, :barg4
-         FROM quota q, filesys fs WHERE :qual;
+       break;
+      case QUOTA_TABLE:
+       strcpy(before[0], "?");
+       strcpy(before[1], argv[1]);
+       strcpy(before[2], "?");
+       sprintf(stmt_buf, "SELECT q.quota, fs.name FROM quota q, filesys fs "
+               "WHERE %s AND fs.filsys_id = q.filsys_id", qual);
+       dosql(&(before[3]));
+       strcpy(before[2], argv[1]);
        beforec = 5;
-    } else if (!strcmp(table, "list")) {
-       EXEC SQL SELECT l.name, CHAR(l.active), CHAR(l.publicflg), 
-           CHAR(l.hidden), CHAR(l.maillist), CHAR(l.grouplist), CHAR(l.gid), 
-           l.acl_type, CHAR(l.acl_id), l.description
-         INTO :barg0, :barg1, :barg2, :barg3, :barg4, :barg5, :barg6,
-           :barg7, :barg8, :barg9
-         FROM list l WHERE :qual;
+       break;
+      case LIST_TABLE:
+       sprintf(stmt_buf, "SELECT l.name, l.active, l.publicflg, l.hidden, "
+               "l.maillist, l.grouplist, l.gid, l.acl_type, l.acl_id, "
+               "l.description FROM list l WHERE %s", qual);
+       dosql(before);
        beforec = 10;
-    } else if (!strcmp(table, "members")) {
+       break;
+      case IMEMBERS_TABLE:
        id = (int) argv[0];
-       EXEC SQL SELECT CHAR(active), CHAR(publicflg), CHAR(hidden),
-               CHAR(maillist), CHAR(grouplist), CHAR(gid)
-               INTO :barg3, :barg4, :barg5, :barg6, :barg7, :barg8
-               FROM list WHERE list_id = :id;
+       sprintf(stmt_buf, "SELECT active, publicflg, hidden, maillist, "
+               "grouplist, gid FROM list WHERE list_id = %d", id);
+       dosql(&(before[3]));
        name = malloc(0);
-       id_to_name(id, "LIST", &name);
-       strcpy(barg0, name);
-       strcpy(barg1, argv[1]);
+       id_to_name(id, LIST_TABLE, &name);
+       strcpy(before[0], name);
+       strcpy(before[1], argv[1]);
        id = (int) argv[2];
        beforec = 9;
-       if (!strcmp(barg1, "USER")) {
-           id_to_name(id, barg1, &name);
-           EXEC SQL SELECT CHAR(status) INTO :barg9 FROM users 
+       if (!strcmp(before[1], "USER")) {
+           id_to_name(id, USERS_TABLE, &name);
+           EXEC SQL SELECT status INTO :before[9] FROM users 
                WHERE users_id=:id;
            beforec = 10;
-       } else if (!strcmp(barg1, "LIST")) {
-           id_to_name(id, barg1, &name);
-       } else if (!strcmp(barg1, "STRING")) {
-           id_to_name(id, barg1, &name);
-       } else if (!strcmp(barg1, "KERBEROS")) {
-           id_to_name(id, "STRING", &name);
+       } else if (!strcmp(before[1], "LIST")) {
+           id_to_name(id, LIST_TABLE, &name);
+       } else if (!strcmp(before[1], "STRING") || !strcmp(before[1], "KERBEROS")) {
+           id_to_name(id, STRINGS_TABLE, &name);
        }
-       strcpy(barg2, name);
+       strcpy(before[2], name);
        free(name);
-    } /* else
-      com_err(whoami, 0, "unknown table in incremental_before"); */
+       break;
+      default:
+       /*
+       com_err(whoami, 0, "requested incremental on unexpected table `%s'",
+               table_name[table]);
+       */
+       break;
+      }
 }
 
 
-incremental_clear_before()
+void incremental_clear_before(void)
 {
     beforec = 0;
 }
 
-incremental_clear_after()
-{
-    incremental_after("clear", 0);
-}
-
 
+/* add an element to the incremental queue for the changed row */
 
-incremental_after(table, qual, argv)
-char *table;
-EXEC SQL BEGIN DECLARE SECTION; 
-char *qual;
-EXEC SQL END DECLARE SECTION; 
-char **argv;
+void incremental_after(table, qual, argv)
+     enum tables table;
+EXEC SQL BEGIN DECLARE SECTION;
+     char *qual, **argv;
+EXEC SQL END DECLARE SECTION;
 {
-    char buffer[2048], *name;
+#ifdef DEBUG
+    char buffer[2048];
+#endif
+    char *name;
 EXEC SQL BEGIN DECLARE SECTION; 
-    int id, i;
+    int id;
 EXEC SQL END DECLARE SECTION; 
     struct iupdate *iu;
-    char **copy_argv();
-
-    if (!strcmp(table, "users")) {
-       EXEC SQL SELECT u.login, CHAR(u.uid), u.shell, u.last, u.first, 
-           u.middle, CHAR(u.status), u.clearid, u.type
-         INTO :aarg0, :aarg1, :aarg2, :aarg3, :aarg4, :aarg5,
-           :aarg6, :aarg7, :aarg8
-         FROM users u WHERE :qual;
+
+    switch(table)
+      {
+      case USERS_TABLE:
+       sprintf(stmt_buf, "SELECT u.login, u.unix_uid, u.shell, u.last, "
+               "u.first, u.middle, u.status, u.clearid, u.type "
+               "FROM users u WHERE %s", qual);
+       dosql(after);
        afterc = 9;
-    } else if (!strcmp(table, "machine")) {
-       EXEC SQL SELECT m.name, m.vendor INTO :aarg0, :aarg1
-         FROM machine m WHERE :qual;
+       break;
+      case MACHINE_TABLE:
+       sprintf(stmt_buf, "SELECT m.name, m.vendor FROM machine m "
+               "WHERE %s", qual);
+       dosql(after);
        afterc = 2;
-    } else if (!strcmp(table, "cluster")) {
-       EXEC SQL SELECT c.name, c.description, c.location 
-         INTO :aarg0, :aarg1, :aarg2
-         FROM cluster c WHERE :qual;
+       break;
+      case CLUSTER_TABLE:
+       sprintf(stmt_buf, "SELECT c.name, c.description, c.location "
+               "FROM clusters c WHERE %s", qual);
+       dosql(after);
        afterc = 3;
-    } else if (!strcmp(table, "mcmap")) {
-       strcpy(aarg0, argv[0]);
-       strcpy(aarg1, argv[1]);
+       break;
+      case MCMAP_TABLE:
+       strcpy(after[0], argv[0]);
+       strcpy(after[1], argv[1]);
        afterc = 2;
-    } else if (!strcmp(table, "svc")) {
-       strcpy(aarg0, argv[0]);
-       strcpy(aarg1, argv[1]);
-       strcpy(aarg2, argv[2]);
+       break;
+      case SVC_TABLE:
+       strcpy(after[0], argv[0]);
+       strcpy(after[1], argv[1]);
+       strcpy(after[2], argv[2]);
        afterc = 3;
-    } else if (!strcmp(table, "filesys")) {
-        EXEC SQL SELECT CHAR(fs.label), fs.type, CHAR(fs.mach_id), fs.name, 
-           fs.mount, fs.access, fs.comments, CHAR(fs.owner), CHAR(fs.owners),
-           CHAR(fs.createflg), fs.lockertype
-          INTO :aarg0, :aarg1, :aarg2, :aarg3, :aarg4, :aarg5, :aarg6,
-             :aarg7, :aarg8, :aarg9, :aarg10
-          FROM filesys fs WHERE :qual;
+       break;
+      case FILESYS_TABLE:
+       sprintf(stmt_buf, "SELECT fs.label, fs.type, fs.mach_id, fs.name, "
+               "fs.mount, fs.rwaccess, fs.comments, fs.owner, fs.owners, "
+               "fs.createflg, fs.lockertype FROM filesys fs WHERE %s", qual);
+       dosql(after);
         name = malloc(0);
-        id = atoi(aarg2);
-        id_to_name(id, "MACHINE", &name);
-        strcpy(aarg2, name);
-        id = atoi(aarg7);
-        id_to_name(id, "USER", &name);
-        strcpy(aarg7, name);
-        id = atoi(aarg8);
-        id_to_name(id, "LIST", &name);
-        strcpy(aarg8, name);
+        id = atoi(after[2]);
+        id_to_name(id, MACHINE_TABLE, &name);
+        strcpy(after[2], name);
+        id = atoi(after[7]);
+        id_to_name(id, USERS_TABLE, &name);
+        strcpy(after[7], name);
+        id = atoi(after[8]);
+        id_to_name(id, LIST_TABLE, &name);
+        strcpy(after[8], name);
         free(name);
        afterc = 11;
-    } else if (!strcmp(table, "quota")) {
-       strcpy(aarg0, "?");
-       strcpy(aarg1, argv[1]);
-       strcpy(aarg2, "?");
-       sprintf(buffer, "%s and fs.filsys_id = q.filsys_id and q.type = '%s'",
+       break;
+      case QUOTA_TABLE:
+       strcpy(after[0], "?");
+       strcpy(after[1], argv[1]);
+       strcpy(after[2], "?");
+       sprintf(stmt_buf, "SELECT q.quota, fs.name FROM quota q, filesys fs "
+               "WHERE %s and fs.filsys_id = q.filsys_id and q.type = '%s'",
                qual, argv[1]);
-       qual = buffer;
-       EXEC SQL SELECT CHAR(q.quota), fs.name INTO :aarg3, :aarg4
-         FROM quota q, filesys fs WHERE :qual;
+       dosql(&(after[3]));
        afterc = 5;
-    } else if (!strcmp(table, "list")) {
-       EXEC SQL SELECT l.name, CHAR(l.active), CHAR(l.publicflg), 
-           CHAR(l.hidden), CHAR(l.maillist), CHAR(l.grouplist), CHAR(l.gid), 
-            l.acl_type, CHAR(l.acl_id), l.description
-         INTO :aarg0, :aarg1, :aarg2, :aarg3, :aarg4, :aarg5, :aarg6,
-            :aarg7, :aarg8, :aarg9
-         FROM list l WHERE :qual;
+       break;
+      case LIST_TABLE:
+       sprintf(stmt_buf, "SELECT l.name, l.active, l.publicflg, l.hidden, "
+               "l.maillist, l.grouplist, l.gid, l.acl_type, l.acl_id, "
+               "l.description FROM list l WHERE %s", qual);
+       dosql(after);
        afterc = 10;
-    } else if (!strcmp(table, "members")) {
+       break;
+      case IMEMBERS_TABLE:
        id = (int) argv[0];
-       EXEC SQL SELECT CHAR(active), CHAR(publicflg), CHAR(hidden),
-               CHAR(maillist), CHAR(grouplist), CHAR(gid)
-               INTO :aarg3, :aarg4, :aarg5, :aarg6, :aarg7, :aarg8
-               FROM list WHERE list_id = :id;
+       sprintf(stmt_buf, "SELECT active, publicflg, hidden, maillist, "
+               "grouplist, gid FROM list WHERE list_id = %d", id);
+       dosql(&(after[3]));
        name = malloc(0);
-       id_to_name(id, "LIST", &name);
-       strcpy(aarg0, name);
-       strcpy(aarg1, argv[1]);
+       id_to_name(id, LIST_TABLE, &name);
+       strcpy(after[0], name);
+       strcpy(after[1], argv[1]);
        id = (int) argv[2];
        afterc = 9;
-       if (!strcmp(aarg1, "USER")) {
-           id_to_name(id, aarg1, &name);
-           EXEC SQL SELECT CHAR(status) INTO :aarg9 FROM users 
+       if (!strcmp(after[1], "USER")) {
+           id_to_name(id, USERS_TABLE, &name);
+           EXEC SQL SELECT status INTO :after[9] FROM users 
                WHERE users_id=:id;
            afterc = 10;
-       } else if (!strcmp(aarg1, "LIST")) {
-           id_to_name(id, aarg1, &name);
-       } else if (!strcmp(aarg1, "STRING")) {
-           id_to_name(id, aarg1, &name);
-       } else if (!strcmp(aarg1, "KERBEROS")) {
-           id_to_name(id, "STRING", &name);
+       } else if (!strcmp(after[1], "LIST")) {
+           id_to_name(id, LIST_TABLE, &name);
+       } else if (!strcmp(after[1], "STRING") || !strcmp(after[1], "KERBEROS")) {
+           id_to_name(id, STRINGS_TABLE, &name);
        }
-       strcpy(aarg2, name);
+       strcpy(after[2], name);
        free(name);
-    } else if (!strcmp(table, "clear")) {
+       break;
+      case NO_TABLE:
        afterc = 0;
        table = beforetable;
-    } /* else
-      com_err(whoami, 0, "unknown table in incremental_after"); */
+       break;
+      default:
+       /*
+       com_err(whoami, 0, "requested incremental on unexpected table `%s'",
+               table_name[table]);
+       */
+       break;
+      }
 
     iu = (struct iupdate *) malloc(sizeof(struct iupdate));
-    iu->table = strsave(table);
+    iu->table = table_name[table];
     iu->beforec = beforec;
     iu->before = copy_argv(before, beforec);
     iu->afterc = afterc;
@@ -345,7 +329,7 @@ EXEC SQL END DECLARE SECTION;
     sq_save_data(incremental_sq, iu);
 
 #ifdef DEBUG
-    sprintf(buffer, "INCREMENTAL(%s, [", table);
+    sprintf(buffer, "INCREMENTAL(%s, [", table_name[table]);
     for (i = 0; i < beforec; i++) {
        if (i == 0)
          strcat(buffer, strtrim(before[0]));
@@ -368,6 +352,11 @@ EXEC SQL END DECLARE SECTION;
 #endif DEBUG
 }
 
+void incremental_clear_after(void)
+{
+    incremental_after(NO_TABLE, NULL, NULL);
+}
+
 
 /* Called when the current transaction is committed to start any queued
  * incremental updates.  This caches the update table the first time it
@@ -376,12 +365,11 @@ EXEC SQL END DECLARE SECTION;
 
 struct inc_cache {
     struct inc_cache *next;
-    char *table;
-    char *service;
+    char *table, *service;
 };
 
 
-incremental_update()
+void incremental_update(void)
 {
     static int inited = 0;
     static struct inc_cache *cache;
@@ -394,7 +382,7 @@ incremental_update()
     if (!inited) {
        inited++;
 
-       EXEC SQL DECLARE inc CURSOR FOR SELECT tablename, service FROM incremental;
+       EXEC SQL DECLARE inc CURSOR FOR SELECT table_name, service FROM incremental;
        EXEC SQL OPEN inc;
        while (1) {
            EXEC SQL FETCH inc INTO :tab, :serv;
@@ -422,11 +410,12 @@ incremental_update()
 }
 
 
-next_incremental()
+void next_incremental(void)
 {
     struct iupdate *iu;
     char *argv[MAXARGC * 2 + 4], cafter[3], cbefore[3], prog[BUFSIZ];
     int i;
+    sigset_t sigs;
 
     if (incremental_exec == NULL)
       incremental_init();
@@ -455,6 +444,10 @@ next_incremental()
 #endif
     argv[0] = prog;
     argv[4 + iu->beforec + iu->afterc] = 0;
+
+    sigemptyset(&sigs);
+    sigaddset(&sigs, SIGCHLD);
+    sigprocmask(SIG_BLOCK, &sigs, NULL);
     inc_pid = vfork();
     switch (inc_pid) {
     case 0:
@@ -467,10 +460,10 @@ next_incremental()
        inc_running = 1;
        inc_started = now;
     }
+    sigprocmask(SIG_UNBLOCK, &sigs, NULL);
 
     free_argv(iu->before, iu->beforec);
     free_argv(iu->after, iu->afterc);
-    free(iu->table);
     free(iu);
 
 }
@@ -480,14 +473,13 @@ next_incremental()
  * incremental updates
  */
 
-incremental_flush()
+void incremental_flush(void)
 {
     struct iupdate *iu;
 
     while (sq_get_data(incremental_sq, &iu)) {
        free_argv(iu->before, iu->beforec);
        free_argv(iu->after, iu->afterc);
-       free(iu->table);
        free(iu);
     }
     sq_destroy(incremental_sq);
@@ -496,8 +488,8 @@ incremental_flush()
 
 
 char **copy_argv(argv, argc)
-char **argv;
-int argc;
+     char **argv;
+     int argc;
 {
     char **ret = (char **)malloc(sizeof(char *) * argc);
     while (--argc >= 0)
@@ -505,11 +497,21 @@ int argc;
     return(ret);
 }
 
-free_argv(argv, argc)
-char **argv;
-int argc;
+void free_argv(argv, argc)
+     char **argv;
+     int argc;
 {
     while (--argc >= 0)
       free(argv[argc]);
     free(argv);
 }
+
+int table_num(char *name)
+{
+  int i;
+
+  for(i = num_tables-1; i; i--)
+    if(!strcmp(table_name[i], name)) break;
+
+  return i; /* 0 = "none" if no match */
+}
diff --git a/server/malloc.h b/server/malloc.h
deleted file mode 100644 (file)
index b5d2b4b..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-/*
- *     $Source$
- *     $Author$
- *     $Header$
- *
- *     Copyright (C) 1993 by the Massachusetts Institute of Technology
- *
- * This is a stub routine that defines the malloc, realloc, free, etc.
- * It also #includes string.h and strings.h, so that the debugging
- * malloc can redefine them if necessary.
- */
-
-extern char *malloc();
-extern char *realloc();
-extern void free();
-
-#include <string.h>
-#include <strings.h>
diff --git a/server/meinitlst.c b/server/meinitlst.c
deleted file mode 100644 (file)
index 09abdc5..0000000
+++ /dev/null
@@ -1,172 +0,0 @@
-/*
- *     $Source$
- *     $Author$
- *     $Header$
- *
- *     Copyright (C) 1987 by the Massachusetts Institute of Technology
- *     For copying and distribution information, please see the file
- *     <mit-copyright.h>.
- *
- *     This code is a reverse-engineered version of
- *     ~rtingres/lib/compatlib(meinitlst.o) with a better malloc and
- *     free.  It only works with Ingres version 5 on the vax.
- */
-
-#ifndef lint
-static char *rcsid_meinitlst_c = "$Header$";
-#endif lint
-
-#include <mit-copyright.h>
-#include <sys/errno.h>
-#include <sys/types.h>
-#include <moira_site.h>
-
-#if INGRESVER == 5 && defined(vax)
-
-/*
- * entry points:
- *     MEinitLists()
- *     calloc()
- *     free()
- *     malloc()
- *     memalign()
- *     realloc()
- *     valloc()
- */
-
-struct cons {
-       char *car;
-       char *cdr;
-};
-extern int Status;
-extern char MEsetup;
-extern struct cons MElist, MEfreelist;
-extern short ME_pid;
-extern char *MElistHead, *MEfreeHead;
-
-MEinitLists()
-{
-       Status = 0;
-       MEsetup = 1;
-       MElist.car = 0;
-       MElist.cdr = MElistHead;
-       MEfreelist.car = 0;
-       MEfreelist.cdr = MEfreeHead;
-       ME_pid = getpid() & 0x7fff;
-       return 0;
-}
-#ifdef notdef
-free(addr)
-{
-       return MEfree(addr);
-}
-
-caddr_t malloc(size)
-       u_int size;
-{
-       char *temp;
-       if(MEalloc(1, size, &temp)) return 0;
-       else return temp;
-}
-
-caddr_t calloc(a1, a2)
-       int a1, a2;
-{
-       char *temp;
-       if (MEcalloc(a1, a2, &temp)) return 0;
-       else return temp;
-}
-
-caddr_t realloc(adr, nsize)
-       char *adr;
-       u_int nsize;
-{
-       char *new_addr;
-       u_int cur_size;
-       if (MEsize(adr, &cur_size)) return 0;
-       if (cur_size >= nsize) return adr;
-       if ( (new_addr = malloc(nsize)) == 0) return 0;
-       (void) MEcopy(adr, cur_size, new_addr);
-       (void) free(adr);
-       return new_addr;
-}
-
-valloc(size)
-       int size;
-{
-       static int pagesize;
-       if (pagesize == 0) pagesize = getpagesize();
-       return memalign(pagesize, size);
-}
-
-memalign(alignment, size)
-{
-       int temp1;
-       int temp2;
-       int temp3;
-       int temp4;
-       if (!size || alignment & 1) {
-               errno = EINVAL;
-               return 0;
-       }
-       if (alignment < 4) alignment = 4;
-
-/*
-_memalign:      fc0
-_memalign+2:    subl2   $10,sp
-_memalign+5:    tstl    8(ap)
-_memalign+8:    beql    _memalign+e
-_memalign+a:    blbc    4(ap),_memalign+18
->_memalign+e:    movl    $16,_errno
->_memalign+15:   clrf    r0
-_memalign+17:   ret
->_memalign+18:   cmpl    4(ap),$4
-_memalign+1c:   bgequ   _memalign+22
-_memalign+1e:   movl    $4,4(ap)
->_memalign+22:   pushl   $4
-_memalign+24:   addl3   $3,8(ap),-(sp)
-_memalign+29:   calls   $2,udiv
-_memalign+30:   ashl    $2,r0,8(ap)
-_memalign+35:   addl3   4(ap),8(ap),r0
-_memalign+3b:   addl3   $20,r0,-4(fp)
-_memalign+40:   pushl   -4(fp)
-_memalign+43:   calls   $1,_malloc
-_memalign+4a:   movl    r0,r11
-_memalign+4d:   beql    _memalign+15
-_memalign+4f:   subl3   $10,r11,r10
-_memalign+53:   ashl    $0,4(r10),r8
-_memalign+58:   pushl   4(ap)
-_memalign+5b:   subl3   $1,4(ap),r0
-_memalign+60:   addl3   r11,r0,-(sp)
-_memalign+64:   calls   $2,udiv
-_memalign+6b:   mull3   4(ap),r0,-c(fp)
-_memalign+71:   movl    -c(fp),r7
-_memalign+75:   subl3   $10,r7,r6
-_memalign+79:   subl3   r10,r6,-8(fp)
-_memalign+7e:   subl2   -8(fp),r8
-_memalign+82:   cmpl    -8(fp),$10
-_memalign+86:   bgequ   _memalign+a7
-_memalign+88:   pushl   8(ap)
-_memalign+8b:   pushl   4(ap)
-_memalign+8e:   calls   $2,_memalign
-_memalign+95:   movl    r0,-10(fp)
-_memalign+99:   pushl   r11
-_memalign+9b:   calls   $1,_free
-_memalign+a2:   movl    -10(fp),r0
-_memalign+a6:   ret
->_memalign+a7:   movl    -8(fp),r0
-_memalign+ab:   extzv   $0,$20,r0,4(r10)
-_memalign+b1:   extzv   $0,$20,r8,4(r6)
-_memalign+b7:   movl    (r10),(r6)
-_memalign+ba:   movw    8(r10),8(r6)
-_memalign+bf:   movl    r6,_MElist
-_memalign+c6:   cmpl    _MElist+4,r10
-_memalign+cd:   bneq    _memalign+d6
-_memalign+cf:   movl    r6,_MElist+4
->_memalign+d6:   pushl   r10
-_memalign+d8:   calls   $1,_MEf_add
-_memalign+df:   addl3   $10,r6,r0
-_memalign+e3:   ret
-*/
-#endif notdef
-#endif /* INGRESVER == 5 && defined(vax) */
index 8fd1505d99f7201f21ce9a3f235ea3e4c4154c43..dfe95f7495553ace2a3a846fdf5ed332a5df7edb 100644 (file)
@@ -21,8 +21,8 @@ static char *rcsid_mr_glue_c = "$Header$";
 #include <sys/wait.h>
 #include <krb_et.h>
 #include <pwd.h>
-#include "query.h"
 #include "mr_server.h"
+#include "query.h"
 
 static int already_connected = 0;
 
@@ -39,18 +39,26 @@ char *server;
 {
     register int status;
     extern int query_timeout;
+    struct sigaction action;
 
     if (already_connected) return MR_ALREADY_CONNECTED;
 
     initialize_sms_error_table();
     initialize_krb_error_table();
-    bzero((char *)&pseudo_client, sizeof(pseudo_client)); /* XXX */
+    memset((char *)&pseudo_client, 0, sizeof(pseudo_client)); /* XXX */
 
     query_timeout = 0;
     status =  mr_open_database();
     if (!status) already_connected = 1;
 
-    signal(SIGCHLD, reapchild);
+    action.sa_flags = 0;
+    sigemptyset(&action.sa_mask);
+    sigaddset(&action.sa_mask, SIGCHLD);
+    action.sa_handler = reapchild;
+    if (sigaction(SIGCHLD, &action, NULL) < 0) {
+      com_err(whoami, errno, "Unable to establish signal handlers.");
+      exit(1);
+    }
     return status;
 }
 
@@ -92,9 +100,9 @@ char *prog;
     strcat(buf, pseudo_client.kname.realm);
     strcpy(pseudo_client.clname, buf);
     pseudo_client.users_id = 0;
-    name_to_id(pseudo_client.kname.name, "USER", &pseudo_client.users_id);
+    name_to_id(pseudo_client.kname.name, USERS_TABLE, &pseudo_client.users_id);
     pseudo_client.client_id = pseudo_client.users_id;
-    strcpy(pseudo_client.entity, prog);
+    strncpy(pseudo_client.entity, prog, 8);
     pseudo_client.args = (mr_params *) malloc(sizeof(mr_params));
     pseudo_client.args->mr_version_no = MR_VERSION_2;
     return 0;
@@ -214,16 +222,15 @@ trigger_dcm(dummy0, dummy1, cl)
 
 void reapchild()
 {
-    union wait status;
-    int pid;
+    int status, pid;
 
-    while ((pid = wait3(&status, WNOHANG, (struct rusage *)0)) > 0) {
+    while ((pid = waitpid(-1, &status, WNOHANG)) > 0) {
        if (pid == inc_pid) {
            inc_running = 0;
            next_incremental();
        }
-       if  (status.w_termsig != 0 || status.w_retcode != 0)
+       if  (WTERMSIG(status) != 0 || WEXITSTATUS(status) != 0)
          com_err(whoami, 0, "%d: child exits with signal %d status %d",
-                 pid, status.w_termsig, status.w_retcode);
+                 pid, WTERMSIG(status), WEXITSTATUS(status));
     }
 }
index 704a57a7afb73da85acb5dba6d4d2258db26e83e..2b11724e03b4e092e2f96f66762f3bbb434d948e 100644 (file)
 static char *rcsid_mr_main_c = "$Header$";
 
 #include <mit-copyright.h>
-#include <strings.h>
+#include <string.h>
+#include <stdio.h>
 #include <sys/types.h>
 #include <sys/errno.h>
 #include <sys/signal.h>
 #include <sys/wait.h>
 #include <sys/stat.h>
+#include <unistd.h>
+#include <signal.h>
 #include "mr_server.h"
 #include <krb_et.h>
+#include <gdss_et.h>
+#include <arpa/inet.h>
 
 extern CONNECTION newconn, listencon;
 
@@ -46,21 +51,15 @@ extern char *takedown;
 extern int errno;
 extern FILE *journal;
 
-extern char *inet_ntoa();
-extern void mr_com_err();
-extern void do_client();
-
-extern int sigshut();
-void clist_append();
-void oplist_append();
-void reapchild(), godormant(), gowakeup();
-
 extern time_t now;
 
-#ifdef _DEBUG_MALLOC_INC
-static char *dbg_malloc();
-static int dbg_free();
-#endif
+int do_listen(char *port);
+void do_reset_listen(void);
+void clist_append(client *cp);
+void oplist_append(LIST_OF_OPERATIONS *oplp, OPERATION op);
+void oplist_delete(LIST_OF_OPERATIONS oplp, OPERATION op);
+void mr_setup_signals(void);
+int new_connection(void);
 
 /*
  * Main MOIRA server loop.
@@ -70,10 +69,9 @@ static int dbg_free();
  */
 
 /*ARGSUSED*/
-int
-main(argc, argv)
-       int argc;
-       char **argv;
+int main(argc, argv)
+     int argc;
+     char **argv;
 {
        int status, i;
        time_t tardy;
@@ -89,10 +87,9 @@ main(argc, argv)
        initialize_krb_error_table();
        initialize_gdss_error_table();
        set_com_err_hook(mr_com_err);
-       setlinebuf(stderr);
-       
-       database = "moira";
-       port = index(MOIRA_SERVER, ':') + 1;
+       setvbuf(stderr, NULL, _IOLBF, BUFSIZ);
+
+       port = strchr(MOIRA_SERVER, ':') + 1;
 
        for (i = 1; i < argc; i++) {
            if (!strcmp(argv[i], "-db") && i+1 < argc) {
@@ -107,17 +104,6 @@ main(argc, argv)
            }
        }
 
-       /* Profiling implies that getting rid of one level of call
-        * indirection here wins us maybe 1% on the VAX.
-        */
-#ifdef _DEBUG_MALLOC_INC
-       gdb_amv = dbg_malloc;
-       gdb_fmv = dbg_free;
-#else
-       gdb_amv = malloc;
-       gdb_fmv = (int (*)()) free;
-#endif
-       
        /*
         * GDB initialization.
         */
@@ -280,7 +266,7 @@ main(argc, argv)
                                do_client(cur_client);
                        } else if (clients[i]->last_time_used < tardy) {
                                com_err(whoami, 0, "Shutting down connection due to inactivity");
-                               shutdown(cur_client->con->in.fd, 0);
+                               shutdown(cur_client->con->in.fd, 2);
                        }
                        cur_client = NULL;
                        if (takedown) break;
@@ -296,9 +282,8 @@ main(argc, argv)
  * Set up the template connection and queue the first accept.
  */
 
-int
-do_listen(port)
-char *port;
+int do_listen(port)
+     char *port;
 {
        listencon = create_listening_connection(port);
 
@@ -315,7 +300,7 @@ char *port;
 }
 
 
-do_reset_listen()
+void do_reset_listen(void)
 {
        client_addrlen = sizeof(client_addr);
        start_accepting_client(listencon, listenop, &newconn,
@@ -328,8 +313,7 @@ do_reset_listen()
  *
  * It sets up a new client and adds it to the list of currently active clients.
  */
-int
-new_connection()
+int new_connection(void)
 {
        register client *cp;
        static counter = 0;
@@ -349,7 +333,7 @@ new_connection()
         * Set up the new connection and reply to the client
         */
        cp = (client *)malloc(sizeof *cp);
-       bzero(cp, sizeof(*cp));
+       memset(cp, 0, sizeof(*cp));
        cp->action = CL_ACCEPT;
        cp->con = newconn;
        cp->id = counter++;
@@ -404,16 +388,15 @@ new_connection()
 /*
  * Add a new client to the known clients.
  */
-void
-clist_append(cp)
-       client *cp;
+void clist_append(cp)
+     client *cp;
 {              
        client **clients_n;
        
        nclients++;
        clients_n = (client **)malloc
                ((unsigned)(nclients * sizeof(client *)));
-       bcopy((char *)clients, (char *)clients_n, (nclients-1)*sizeof(cp));
+       memcpy((char *)clients_n, (char *)clients, (nclients-1)*sizeof(cp));
        clients_n[nclients-1] = cp;
        free((char *)clients);
        clients = clients_n;
@@ -421,9 +404,8 @@ clist_append(cp)
 }
 
                
-void
-clist_delete(cp)
-       client *cp;
+void clist_delete(cp)
+     client *cp;
 {
        client **clients_n, **scpp, **dcpp; /* source and dest client */
                                            /* ptr ptr */
@@ -459,15 +441,14 @@ clist_delete(cp)
  * cases it won't have to copy the array.
  */
 
-void
-oplist_append(oplp, op)
-       LIST_OF_OPERATIONS *oplp;
-       OPERATION op;
+void oplist_append(oplp, op)
+     LIST_OF_OPERATIONS *oplp;
+     OPERATION op;
 {
        int count = (*oplp)->count+1;
        LIST_OF_OPERATIONS newlist = (LIST_OF_OPERATIONS)
                db_alloc(size_of_list_of_operations(count));
-       bcopy((char *)(*oplp), (char *)newlist,
+       memcpy((char *)newlist, (char *)(*oplp),
              size_of_list_of_operations((*oplp)->count));
        newlist->count++;
        newlist->op[count-1] = op;
@@ -476,9 +457,9 @@ oplist_append(oplp, op)
 }
 
 
-oplist_delete(oplp, op)
-       LIST_OF_OPERATIONS oplp;
-       register OPERATION op;
+void oplist_delete(oplp, op)
+     LIST_OF_OPERATIONS oplp;
+     OPERATION op;
 {
        register OPERATION *s;
        register int c;
@@ -498,22 +479,27 @@ oplist_delete(oplp, op)
 }
 
 
-void reapchild()
+void reapchild(x)
+     int x;
 {
-    union wait status;
-    int pid;
+    int status, pid;
 
-    while ((pid = wait3(&status, WNOHANG, (struct rusage *)0)) > 0) {
+    while ((pid = waitpid(-1, &status, WNOHANG)) > 0) {
+#ifdef INCR_DEBUG
+        com_err(whoami, 0, "Reaping %d (inc_pid=%d, inc_running=%d)",
+               pid, inc_pid, inc_running);
+#endif
        if (pid == inc_pid)
          inc_running = 0;
-       if  (!takedown && (status.w_termsig != 0 || status.w_retcode != 0))
-         com_err(whoami, 0, "%d: child exits with signal %d status %d",
-                 pid, status.w_termsig, status.w_retcode);
+        if  (!takedown && (WTERMSIG(status)!= 0 || WEXITSTATUS(status)!= 0))
+          com_err(whoami, 0, "%d: child exits with signal %d status %d",
+                  pid, WTERMSIG(status), WEXITSTATUS(status));
     }
 }
 
 
-void godormant()
+void godormant(x)
+     int x;
 {
     switch (dormant) {
     case AWAKE:
@@ -530,7 +516,8 @@ void godormant()
 }
 
 
-void gowakeup()
+void gowakeup(x)
+     int x;
 {
     switch (dormant) {
     case ASLEEP:
@@ -547,32 +534,39 @@ void gowakeup()
 }
 
        
-mr_setup_signals()
+void mr_setup_signals(void)
 {
+    struct sigaction action;
+
+    action.sa_flags = 0;
+    sigemptyset(&action.sa_mask);
+
     /* There should probably be a few more of these. */
        
-    if ((((int)signal (SIGTERM, sigshut)) < 0) ||
-       (((int)signal (SIGCHLD, reapchild)) < 0) ||
-       (((int)signal (SIGUSR1, godormant)) < 0) ||
-       (((int)signal (SIGUSR2, gowakeup)) < 0) ||
-       (((int)signal (SIGHUP, sigshut)) < 0)) {
-       com_err(whoami, errno, " Unable to establish signal handlers.");
-       exit(1);
+    action.sa_handler = sigshut;
+    if ((sigaction(SIGTERM, &action, NULL) < 0) ||
+       (sigaction(SIGINT, &action, NULL) < 0) ||
+       (sigaction(SIGHUP, &action, NULL) < 0)) {
+      com_err(whoami, errno, "Unable to establish signal handlers.");
+      exit(1);
     }
-}
 
-#ifdef _DEBUG_MALLOC_INC
-static char *dbg_malloc(size)
-       SIZETYPE        size;
-{
-       return( debug_malloc("somewhere in the gdb code",1,size) );
-}
+    action.sa_handler = godormant;
+    if (sigaction(SIGUSR1, &action, NULL) < 0) {
+      com_err(whoami, errno, "Unable to establish signal handlers.");
+      exit(1);
+    }
 
-static int dbg_free(cptr)
-       DATATYPE        *cptr;
-{
-       debug_free((char *)NULL, 0, cptr);
-       return 0;               /* GDB is being stupid */
-}
-#endif
+    action.sa_handler = gowakeup;
+    if (sigaction(SIGUSR2, &action, NULL) < 0) {
+      com_err(whoami, errno, "Unable to establish signal handlers.");
+      exit(1);
+    }
 
+    action.sa_handler = reapchild;
+    sigaddset(&action.sa_mask, SIGCHLD);
+    if (sigaction(SIGCHLD, &action, NULL) < 0) {
+      com_err(whoami, errno, "Unable to establish signal handlers.");
+      exit(1);
+    }
+}
index dcb45b23efa123a203c8010f8ab97eae9e5ffc34..0abc038a869254d361d9f33b1306f3b38f19812a 100644 (file)
@@ -14,15 +14,17 @@ static char *rcsid_sms_sauth_c = "$Header$";
 #endif lint
 
 #include <mit-copyright.h>
-#include <strings.h>
+#include <string.h>
 #include "mr_server.h"
 #include <ctype.h>
 #include <krb_et.h>
+#include <moira.h>
 
 extern char buf1[];
 extern char *whoami;
 
-char *kname_unparse();
+/* from libmoira */
+char *kname_unparse(char *, char *, char *);
 
 /*
  * Handle a MOIRA_AUTH RPC request.
@@ -39,11 +41,11 @@ do_auth(cl)
        KTEXT_ST auth;
        AUTH_DAT ad;
        int status, ok;
-       char buf[REALM_SZ+INST_SZ+ANAME_SZ], hostbuf[BUFSIZ], *host, *p;
+       char hostbuf[BUFSIZ], *host, *p;
        extern int errno;
 
        auth.length = cl->args->mr_argl[0];
-       bcopy(cl->args->mr_argv[0], (char *)auth.dat, auth.length);
+       memcpy((char *)auth.dat, cl->args->mr_argv[0], auth.length);
        auth.mbz = 0;
        if (gethostname(hostbuf, sizeof(hostbuf)) < 0)
          com_err(whoami, errno, "Unable to get local hostname");
@@ -53,11 +55,8 @@ do_auth(cl)
            *p = tolower(*p);
        *p = 0;
 
-       if ((status = krb_rd_req (&auth, MOIRA_SNAME, host, cl->haddr.sin_addr,
-                                &ad, "")) != 0 &&
-           /* for backwards compatability with old clients */
-           (status = krb_rd_req (&auth, "sms", "sms", cl->haddr.sin_addr,
-                                &ad, "")) != 0) {
+       if ((status = krb_rd_req (&auth, MOIRA_SNAME, host,
+                                 cl->haddr.sin_addr.s_addr, &ad, "")) != 0) {
                status += ERROR_TABLE_BASE_krb;
                cl->reply.mr_status = status;
                if (log_flags & LOG_RES)
@@ -66,9 +65,9 @@ do_auth(cl)
        }
        free(host);
 
-       bcopy(ad.pname, cl->kname.name, ANAME_SZ);
-       bcopy(ad.pinst, cl->kname.inst, INST_SZ);
-       bcopy(ad.prealm, cl->kname.realm, REALM_SZ);
+       memcpy(cl->kname.name, ad.pname, ANAME_SZ);
+       memcpy(cl->kname.inst, ad.pinst, INST_SZ);
+       memcpy(cl->kname.realm, ad.prealm, REALM_SZ);
        strcpy(cl->clname, kname_unparse(ad.pname, ad.pinst, ad.prealm));
 
        if (ad.pinst[0] == 0 && !strcmp(ad.prealm, krb_realm))
@@ -85,7 +84,7 @@ do_auth(cl)
        } else {
            strcpy(cl->entity, "???");
        }
-       bzero(&ad, sizeof(ad)); /* Clean up session key, etc. */
+       memset(&ad, 0, sizeof(ad));     /* Clean up session key, etc. */
 
        if (log_flags & LOG_RES)
            com_err(whoami, 0, "Auth to %s using %s, uid %d cid %d",
@@ -95,85 +94,3 @@ do_auth(cl)
        else if (cl->users_id == 0)
          cl->reply.mr_status = MR_USER_AUTH;
 }
-
-
-/* Turn a principal, instance, realm triple into a single non-ambiguous 
- * string.  This is the inverse of kname_parse().  It returns a pointer
- * to a static buffer, or NULL on error.
- */
-
-char *kname_unparse(p, i, r)
-char *p;
-char *i;
-char *r;
-{
-    static char name[MAX_K_NAME_SZ];
-    char *s;
-
-    s = name;
-    if (!p || strlen(p) > ANAME_SZ)
-      return(NULL);
-    while (*p) {
-       switch (*p) {
-       case '@':
-           *s++ = '\\';
-           *s++ = '@';
-           break;
-       case '.':
-           *s++ = '\\';
-           *s++ = '.';
-           break;
-       case '\\':
-           *s++ = '\\';
-           *s++ = '\\';
-           break;
-       default:
-           *s++ = *p;
-       }
-       p++;
-    }
-    if (i && *i) {
-       if (strlen(i) > INST_SZ)
-         return(NULL);
-       *s++ = '.';
-       while (*i) {
-           switch (*i) {
-           case '@':
-               *s++ = '\\';
-               *s++ = '@';
-               break;
-           case '.':
-               *s++ = '\\';
-               *s++ = '.';
-               break;
-           case '\\':
-               *s++ = '\\';
-               *s++ = '\\';
-               break;
-           default:
-               *s++ = *i;
-           }
-           i++;
-       }
-    }
-    *s++ = '@';
-    if (!r || strlen(r) > REALM_SZ)
-      return(NULL);
-    while (*r) {
-       switch (*r) {
-       case '@':
-           *s++ = '\\';
-           *s++ = '@';
-           break;
-       case '\\':
-           *s++ = '\\';
-           *s++ = '\\';
-           break;
-       default:
-           *s++ = *r;
-       }
-       r++;
-    }
-    *s = '\0';
-    return(&name[0]);
-}
diff --git a/server/mr_sbrk.c b/server/mr_sbrk.c
deleted file mode 100644 (file)
index 565a567..0000000
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- *     $Source$
- *     $Author$
- *     $Header$
- *
- *     Copyright (C) 1987 by the Massachusetts Institute of Technology
- *     For copying and distribution information, please see the file
- *     <mit-copyright.h>.
- */
-
-#ifndef lint
-static char *rcsid_sms_sbrk_c = "$Header$";
-#endif lint
-
-#include <mit-copyright.h>
-
-/*
- * The following routine is a kludge around a deficiency in the Ingres
- * memory allocator; it likes to call sbrk(0) a lot to check on the
- * amount of memory allocated.
- */
-#include <sys/types.h>
-
-#ifdef vax
-extern char end;
-asm("  .data");
-asm("          .globl  curbrk");
-asm("  .globl  minbrk");
-asm("_curbrk:");
-asm("curbrk:   .long   _end");
-asm("_minbrk:");
-asm("minbrk:   .long   _end");
-    
-extern caddr_t curbrk;
-extern caddr_t minbrk;
-
-caddr_t sbrk(incr)
-       register int incr;
-{
-       register caddr_t oldbrk = curbrk;
-       if (incr) {
-               if (brk(oldbrk + incr) < 0)
-                       return (caddr_t)-1;
-               curbrk += incr;
-       }       
-       return oldbrk;
-}
-#endif vax
-
-/*
- * Local Variables:
- * mode: c
- * c-indent-level: 4
- * c-continued-statement-offset: 4
- * c-brace-offset: -4
- * c-argdecl-indent: 4
- * c-label-offset: -4
- * End:
- */
index eecc2d0df7dbe205d5f305ec54d67a108ecd3358..56a545e4bb5f01dd0f9b4bcb1b16d2b0777e5ac0 100644 (file)
@@ -17,10 +17,12 @@ static char *rcsid_sms_scall_c = "$Header$";
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <sys/file.h>
+#include <fcntl.h>
+#include <string.h>
 #include <krb.h>
 #include <errno.h>
-#include "query.h"
 #include "mr_server.h"
+#include "query.h"
 extern char buf1[];
 extern int nclients;
 extern char *whoami;
@@ -28,7 +30,7 @@ extern int errno;
 
 extern void clist_delete(), do_auth(), do_shutdown();
 void do_call();
-extern int ingres_errno, mr_errcode;
+extern int dbms_errno, mr_errcode;
 static int row_count;
 
 /* Put this in a variable so that we can patch it if necessary */
@@ -99,7 +101,6 @@ do_call(cl)
        client *cl;
 {
        int pn;
-       extern int ingres_errno;
        cl->reply.mr_argc = 0;
        cl->reply.mr_status = 0;
        cl->reply.mr_version_no = cl->args->mr_version_no;
@@ -124,7 +125,7 @@ do_call(cl)
        }
 
        /* make sure this gets cleared before every operation */
-       ingres_errno = 0;
+       dbms_errno = 0;
 
        switch(pn) {
        case MR_NOOP:
@@ -186,7 +187,7 @@ retr_callback(argc, argv, p_cp)
        register int i;
 
        if (row_count++ >= max_row_count) {
-           ingres_errno = mr_errcode = MR_NO_MEM;
+           dbms_errno = mr_errcode = MR_NO_MEM;
            return;
        }
 
@@ -217,7 +218,7 @@ retr_callback(argc, argv, p_cp)
        for (i = 0; i < argc; i++) {
                register int len = strlen(argv[i]) + 1;
                nargv[i] = malloc(len);
-               bcopy(argv[i], nargv[i], len);
+               memcpy(nargv[i], argv[i], len);
        }
        arg_tmp->mr_flattened = (char *)NULL;
        arg_tmp->mr_argl = (int *)NULL;
@@ -258,7 +259,7 @@ list_users(callbk, callarg)
                argv[2] = buf;
                sprintf(buf, "port %d", ntohs(cl->haddr.sin_port));
                argv[3] = ctime(&cl->last_time_used);
-               cp = index(argv[3], '\n');
+               cp = strchr(argv[3], '\n');
                if (cp) *cp = '\0';
                argv[4] = buf1;
                sprintf(buf1, "[#%d]", cl->id);
@@ -353,8 +354,6 @@ trigger_dcm(dummy0, dummy1, cl)
        pid = vfork();
        switch (pid) {
        case 0:
-               for (dummy0 = getdtablesize() - 1; dummy0 > 2; dummy0--)
-                 close(dummy0);
                execl(prog, "startdcm", 0);
                exit(1);
                
index 2ceddd528dee4c23b9254a1fe47479924fc9b60b..cafb3a5ed7cf212d0f1ff7b0f06bf45cbdb666ae 100644 (file)
@@ -14,7 +14,8 @@
 #include "mr_proto.h"
 #include <moira_site.h>
 #include <krb.h>
-#include "malloc.h"
+#include <com_err.h>
+#include <stdlib.h>
 
 typedef struct returned_tuples {
        struct returned_tuples *next;
@@ -109,3 +110,86 @@ extern int dormant;
 extern int inc_running, inc_pid;
 extern time_t inc_started, now;
 #define INC_TIMEOUT (3 * 60)   /* 3 minutes */
+
+
+#define SQL_NO_MATCH 1403 /* oracle, not ingres (= 100) */
+
+/* prototypes from gdb */
+int gdb_init(void);
+int gdb_debug(int flag);
+void start_accepting_client(CONNECTION, OPERATION, CONNECTION *,
+                            char *, int*, TUPLE *);
+int initialize_operation(OPERATION, int (*init_function)(), char *,
+                        int (*cancel_function)());
+int reset_operation(OPERATION);
+int delete_operation(OPERATION);
+int start_replying_to_client(OPERATION, CONNECTION, int, char *, char *);
+int op_select(LIST_OF_OPERATIONS, int, fd_set *, fd_set *, fd_set *,
+             struct timeval *);
+
+/* prototypes from libmoira */
+struct save_queue *sq_create(void);
+void sq_save_data(struct save_queue *sq, void *data);
+void sq_save_unique_data(struct save_queue *sq, void *data);
+void sq_save_args(int argc, void *argv[], struct save_queue *sq);
+int sq_get_data(struct save_queue *sq, void *data);
+int sq_remove_data(struct save_queue *sq, void *data);
+int sq_empty(struct save_queue *sq);
+void sq_destroy(struct save_queue *sq);
+
+void send_zgram(char *instance, char *buf);
+void critical_alert(char *, char *, ...);
+void mr_destroy_reply(mr_params *reply);
+int gdss2et(int);
+
+/* prototypes from increment.dc */
+void incremental_init(void);
+void next_incremental(void);
+void incremental_update(void);
+void incremental_flush(void);
+
+/* prototypes from qrtn.dc */
+void dbmserr(void);
+void dosql(char *buffers[]);
+int mr_open_database(void);
+void mr_close_database(void);
+int mr_process_query(client *cl, char *name, int argc, char *argv_ro[],
+                    int (*action)(), char *actarg);
+int mr_check_access(client *cl, char *name, int argc, char *argv_ro[]);
+void sanity_check_queries(void);
+int set_krb_mapping(char *name, char *login, int ok, int *kid, int *uid);
+int get_client(client *cl, char **client_type, int *client_id);
+int find_member(char *list_type, int list_id, char *member_type,
+               int member_id);
+int do_for_all_rows(char *query, int count, int (*action)(), int actarg);
+int build_qual(char *fmt, int argc, char *argv[], char *qual);
+
+
+/* prototyoes from qsupport.dc */
+int set_pop_usage(int id, int cnt);
+
+/* prototypes from qvalidate.dc */
+void sanity_check_database(void);
+int add_string(char *name);
+int convert_wildcards(char *arg);
+
+/* prototypes from mr_main.c */
+void clist_delete(client *cp);
+
+/* prototypes from mr_sauth.c */
+void do_auth(client *cl);
+
+/* prototypes from mr_scall.c */
+void do_client(client *cp);
+int trigger_dcm(int dummy0, int dummy1, client *cl);
+
+/* prototypes from mr_shutdown.c */
+void sigshut(int);
+void do_shutdown(client *cl);
+
+/* prototypes from mr_util.c */
+char *requote(char *buf, char *cp, int len);
+void log_args(char *tag, int version, int argc, char **argv);
+void mr_com_err(char *whoami, int code, char *fmt, caddr_t pvar);
+int mr_trim_args(int argc, char **argv);
+char **mr_copy_args(char **argv, int argc);
index a3e99c75576eb3831ebac80b52fda99accb55b0d..a32f7d4dbafab78abdce99aad600f142a106e1b0 100644 (file)
@@ -14,14 +14,13 @@ static char *rcsid_sms_shutdown_c = "$Header$";
 #endif lint
 
 #include <mit-copyright.h>
-#include <strings.h>
 #include <sys/errno.h>
 #include "mr_server.h"
 
 extern char *takedown;
 extern char *whoami;
 
-sigshut()
+void sigshut(int sig)
 {
        takedown = "Shut down by signal.";
 }
@@ -30,7 +29,6 @@ void
 do_shutdown(cl)
        client *cl;
 {
-       static char buf[BUFSIZ];
        /*
         * This feature is no longer supported.  Sorry.
         */
diff --git a/server/mr_smalloc.c b/server/mr_smalloc.c
deleted file mode 100644 (file)
index 5f8b770..0000000
+++ /dev/null
@@ -1,792 +0,0 @@
-#include <stdio.h>
-botch(message)
-       char *message;
-{
-       fprintf(stderr, "Malloc botch: %s\n", message);
-       abort();
-}      
-
-#define rcheck
-/****************************************************************
- *                                                             *
- *             Storage Allocator for Foundation.               *
- *             Built from gnuemacs storage allocator           *
- *                                                             *
- ****************************************************************/
-
-/*   Copyright (C) 1985 Richard M. Stallman,
-    based mostly on the public domain work of others.
-
-This program is distributed in the hope that it will be useful,
-but without any warranty.  No author or distributor
-accepts responsibility to anyone for the consequences of using it
-or for whether it serves any particular purpose or works at all,
-unless he says so in writing.
-
-   Permission is granted to anyone to distribute verbatim copies
-   of this program's source code as received, in any medium, provided that
-   the copyright notice, the nonwarraty notice above
-   and this permission notice are preserved,
-   and that the distributor grants the recipient all rights
-   for further redistribution as permitted by this notice,
-   and informs him of these rights.
-
-   Permission is granted to distribute modified versions of this
-   program's source code, or of portions of it, under the above
-   conditions, plus the conditions that all changed files carry
-   prominent notices stating who last changed them and that the
-   derived material, including anything packaged together with it and
-   conceptually functioning as a modification of it rather than an
-   application of it, is in its entirety subject to a permission
-   notice identical to this one.
-
-   Permission is granted to distribute this program (verbatim or
-   as modified) in compiled or executable form, provided verbatim
-   redistribution is permitted as stated above for source code, and
-    A.  it is accompanied by the corresponding machine-readable
-      source code, under the above conditions, or
-    B.  it is accompanied by a written offer, with no time limit,
-      to distribute the corresponding machine-readable source code,
-      under the above conditions, to any one, in return for reimbursement
-      of the cost of distribution.   Verbatim redistribution of the
-      written offer must be permitted.  Or,
-    C.  it is distributed by someone who received only the
-      compiled or executable form, and is accompanied by a copy of the
-      written offer of source code which he received along with it.
-
-   Permission is granted to distribute this program (verbatim or as modified)
-   in executable form as part of a larger system provided that the source
-   code for this program, including any modifications used,
-   is also distributed or offered as stated in the preceding paragraph.
-
-In other words, you are welcome to use, share and improve this program.
-You are forbidden to forbid anyone else to use, share and improve
-what you give them.   Help stamp out software-hoarding!  */
-\f
-/****************************************************************
- *                                                             *
- *             Helpful historical comments                     *
- *                                                             *
- ****************************************************************/
-
-/*
- * @(#)nmalloc.c 1 (Caltech) 2/21/82
- *
- *     U of M Modified: 20 Jun 1983 ACT: strange hacks for Emacs
- *
- *     Nov 1983, Mike@BRL, Added support for 4.1C/4.2 BSD.
- *
- * This is a very fast storage allocator.  It allocates blocks of a small 
- * number of different sizes, and keeps free lists of each size.  Blocks
- * that don't exactly fit are passed up to the next larger size.  In this 
- * implementation, the available sizes are (2^n)-4 (or -16) bytes long.
- * This is designed for use in a program that uses vast quantities of
- * memory, but bombs when it runs out.  To make it a little better, it
- * warns the user when he starts to get near the end.
- *
- * June 84, ACT: modified rcheck code to check the range given to malloc,
- * rather than the range determined by the 2-power used.
- *
- * Jan 85, RMS: calls malloc_warning to issue warning on nearly full.
- * No longer Emacs-specific; can serve as all-purpose malloc for GNU.
- * You should call malloc_init to reinitialize after loading dumped Emacs.
- * Call malloc_stats to get info on memory stats if MSTATS turned on.
- * realloc knows how to return same block given, just changing its size,
- * if the power of 2 is correct.
- *
- * Jan 86, WDC: Removed Emacs specific stuff, and neatened a few comments.
- *
- * March 86 WDC: Added in code by Eichin for Scribble checking of blocks
- * Scribble check writes a known pattern into the free blocks, checks it
- * to see if it is still undamaged before allocating it.  It writes a
- * different pattern into the space beyond the end of an allocated block,
- * and tests it for damage when expanding the block's bounds in realloc.
- * Note, this check takes *TIME* and should not be compiled in by default.
- *
- * Berkeley UNIX 4.3 has a storage allocator that shares a common
- * ancestor with this one.  It handles realloc compatibly with the
- * archaic use of realloc on an already freed block to "compact"
- * storage.  It uses a pagesize system call rather than assuming the
- * page size is 1024 bytes.  Finally it guarantees that a freed block
- * is not munged by the allocator itself, incase someone wants to fiddle
- * with freed space after freeing it but before allocating more.
- *
- * This particular storage allocator would benefit from having a
- * non-hardwired pagesize.  But because of the scribble check it would
- * not be useful to keep the free pointer in the header.  SO: When you
- * free something allocated with this allocator, DONT TRY TO USE IT.
- * It is GUARANTEED to be damaged by the freeing process.
- *
- * For interfacing to systems that want to be able to ask the size of
- * the allocated block, rather than remembering it, the m_blocksize
- * function, rips open the block and tells you how big it is.  The size
- * returned is nbytes, the number of bytes asked for, NOT the actual
- * amount of space in the block.
- */
-\f
-/****************************************************************
- *                                                             *
- *      Includes, declarations, and definitions                *
- *                                                             *
- ****************************************************************/
-
-/* Determine which kind of system this is.  */
-#include <signal.h>
-#ifndef SIGTSTP
-#define USG
-#else /* SIGTSTP */
-#ifdef SIGIO
-#define BSD42
-#endif /* SIGIO */
-#endif /* SIGTSTP */
-
-#ifndef BSD42
-#ifndef USG
-#include <sys/vlimit.h>                /* warn the user when near the end */
-#endif
-#else /* if BSD42 */
-#include <sys/time.h>
-#include <sys/resource.h>
-#endif /* BSD42 */
-#include <moira_site.h>
-
-#ifdef scribblecheck
-#define rcheck
-#endif /* we need to have range data to use block boundary checking */
-
-#ifdef rcheck
-/*
- * To implement range checking, we write magic values in at the
- * beginning and end of each allocated block, and make sure they
- * are undisturbed whenever a free or a realloc occurs.
- */
-
-/* Written in each of the 4 bytes following the block's real space */
-#define MAGIC1 0x55
-#define MAGICFREE 0x69         /* 0110 1001 Magic value for Free blocks */
-
-/* Written in the 4 bytes before the block's real space */
-#define MAGIC4 0x55555555
-#define MAGICFREE4 0x69696969
-
-#define ASSERT(p) if (!(p)) botch("p"); else
-#define EXTRA  4               /* 4 bytes extra for MAGIC1s */
-#else
-#define ASSERT(p)
-#define EXTRA  0
-#endif /* rcheck */
-
-#define ISALLOC ((char) 0xf7)  /* magic byte that implies allocation */
-#define ISFREE ((char) 0x54)   /* magic byte that implies free block */
-                               /* this is for error checking only */
-
-/* If range checking is not turned on, all we have is a flag
- * indicating whether memory is allocated, an index in nextf[],
- * and a field that tells how many bytes.
- * To realloc() memory we copy nbytes.
- * 16 bits of header space is unused.
- */
-struct mhead {
-       char     mh_alloc;      /* ISALLOC or ISFREE */
-       char     mh_index;      /* index in nextf[] */
-       unsigned short mh_extra;/* Currently wasted 16 bits */
-/* Remainder are valid only when block is allocated */
-       unsigned mh_nbytes;     /* number of bytes allocated */
-#ifdef rcheck
-       int      mh_magic4;     /* should be == MAGIC4 */
-#endif /* rcheck */
-};
-
-/*
- * Access free-list pointer of a block.
- * It is stored at block + 4.
- * This is not a field in the mhead structure because we want
- * sizeof (struct mhead) to describe the overhead for when the
- * block is in use, and we do not want the free-list pointer
- * to count in that.
- */
-#define CHAIN(a) \
-  (*(struct mhead **) (sizeof (char *) + (char *) (a)))
-
-\f
-/****************************************************************
- *                                                             *
- *             Variable Creations                              *
- *                                                             *
- ****************************************************************/
-
-extern char etext;
-extern char *start_of_data ();  /* This seems necessary for USG */
-
-#ifdef notdef
-
-/* These two are for user programs to look at, when they are interested.  */
-
-int malloc_sbrk_used;       /* amount of data space used now */
-int malloc_sbrk_unused;     /* amount more we can have */
-#endif notdef
-/* start of data space; can be changed by calling init_malloc */
-static char *data_space_start;
-
-#ifdef MSTATS
-/*
- * nmalloc[i] is the difference between the number of mallocs and frees
- * for a given block size.
- */
-static int nmalloc[30];
-static int nmal, nfre;
-#endif /* MSTATS */
-
-/*
- * nextf[i] is the pointer to the next free block of size 2^(i+3).  The
- * smallest allocatable block is 8 bytes.  The overhead information will
- * go in the first int of the block, and the returned pointer will point
- * to the second.
- */
-static struct mhead *nextf[30];
-
-/* Number of bytes of writable memory we can expect to be able to get */
-static int lim_data;
-/* Level number of warnings already issued.
- * 0 -- no warnings issued.
- * 1 -- 75% warning already issued.
- * 2 -- 85% warning already issued.
- */
-static int warnlevel;
-
-#ifdef notdef
-/* nonzero once initial bunch of free blocks made */
-static int gotpool;
-#endif notdef
-\f
-/****************************************************************
- *                                                             *
- *             Start of procedures                             *
- *                                                             *
- *     malloc_init, m_blocksize                                *
- *                                                             *
- ****************************************************************/
-
-/*
- * Cause reinitialization based on job parameters;
- * also declare where the end of pure storage is.
- */
-malloc_init (start)
-     char *start;
-{
-  data_space_start = start;
-  lim_data = 0;
-  warnlevel = 0;
-}
-
-int m_blocksize(a_block)
-     char *a_block;
-{
-  return(((struct mhead *)a_block-1)->mh_nbytes);
-}
-
-#if INGRESVER == 5 && defined(vax)
-/* This is here to pull in our private version of meinitlst.o
- * so that we don't try to get the buggy Ingres 5.0 one.
- */
-extern int MEinitLists();
-
-static int (*foo)() = MEinitLists;
-#endif
-       
-\f
-/****************************************************************
- *                                                             *
- *    morecore - Ask the system for more memory                        *
- *                                                             *
- ****************************************************************/
-
-static
-morecore (nu)                  /* ask system for more memory */
-     register int nu;          /* size index to get more of  */
-{
-  char *sbrk ();
-  register char *cp;
-  register int nblks;
-  register int siz;
-
-#ifdef notdef
-  if (!data_space_start)
-    {
-#if defined(USG)
-      data_space_start = start_of_data ();
-#else /* not USG */
-      data_space_start = &etext;
-#endif /* not USG */
-    }
-
-  if (lim_data == 0)
-    get_lim_data ();
-
-  /* On initial startup, get two blocks of each size up to 1k bytes */
-  if (!gotpool)
-    getpool (), getpool (), gotpool = 1;
-
-  /* Find current end of memory and issue warning if getting near max */
-
-  cp = sbrk (0);
-  siz = cp - data_space_start;
-  malloc_sbrk_used = siz;
-  malloc_sbrk_unused = lim_data - siz;
-
-  switch (warnlevel)
-    {
-    case 0: 
-      if (siz > (lim_data / 4) * 3)
-       {
-         warnlevel++;
-         malloc_warning ("Warning: past 75% of memory limit");
-       }
-      break;
-    case 1: 
-      if (siz > (lim_data / 20) * 17)
-       {
-         warnlevel++;
-         malloc_warning ("Warning: past 85% of memory limit");
-       }
-      break;
-    case 2: 
-      if (siz > (lim_data / 20) * 19)
-       {
-         warnlevel++;
-         malloc_warning ("Warning: past 95% of memory limit");
-       }
-      break;
-    }
-
-  if ((int) cp & 0x3ff)        /* land on 1K boundaries */
-    sbrk (1024 - ((int) cp & 0x3ff));
-#endif notdef
-  
-  /* Take at least 2k, and figure out how many blocks of the desired size
-    we're about to get */
-  nblks = 1;
-  if ((siz = nu) < 8)
-    nblks = 1 << ((siz = 8) - nu);
-#if INGRESVER == 5 && defined(vax)
-  {
-      char *tcp;         
-      if (MEalloc(1, 1 << (siz+3), &tcp))
-       return;                 /* No more room! */
-      cp = tcp;
-  }
-#else /* INGRESVER == 5 && defined(vax) */
-  if ((cp = sbrk (1 << (siz + 3))) == (char *) -1)
-    return;                    /* no more room! */
-#endif /* INGRESVER == 5 && defined(vax) */
-  if ((int) cp & 7)
-    {          /* shouldn't happen, but just in case */
-      cp = (char *) (((int) cp + 8) & ~7);
-      nblks--;
-    }
-
-  /* save new header and link the nblks blocks together */
-  nextf[nu] = (struct mhead *) cp;
-  siz = 1 << (nu + 3);
-  while (1)
-    {
-      ((struct mhead *) cp) -> mh_alloc = ISFREE;
-      ((struct mhead *) cp) -> mh_index = nu;
-#ifdef rcheck
-      ((struct mhead *) cp) -> mh_magic4 = MAGICFREE4;
-#endif /* rcheck */
-#ifdef scribblecheck
-    {
-      /* Check that upper stuff was still MAGIC1 */
-      register char *m = (char *)((struct mhead *)cp+1);
-      register char *en = (8<<nu) + cp;
-      /* Fill whole block with MAGICFREE */
-      while (m<en) *m++ = MAGICFREE;
-    }
-#endif /* scribblecheck */
-
-      /* Clear newly allocated blocks, to match free ones */
-      if (--nblks <= 0) break;
-      CHAIN ((struct mhead *) cp) = (struct mhead *) (cp + siz);
-      cp += siz;
-    }
-  CHAIN ((struct mhead *) cp) = 0;
-}
-\f
-/****************************************************************
- *                                                             *
- *     getpool - Get initial pools of small blocks             *
- *                                                             *
- ****************************************************************/
-#ifdef notdef
-static
-getpool ()
-{
-  register int nu;
-  register char *cp = sbrk (0);
-
-  if ((int) cp & 0x3ff)        /* land on 1K boundaries */
-    sbrk (1024 - ((int) cp & 0x3ff));
-
-  /* Get 2k of storage */
-
-  cp = sbrk (04000);
-  if (cp == (char *) -1)
-    return;
-
-  /* Divide it into an initial 8-word block
-     plus one block of size 2**nu for nu = 3 ... 10.  */
-
-  CHAIN (cp) = nextf[0];
-  nextf[0] = (struct mhead *) cp;
-  ((struct mhead *) cp) -> mh_alloc = ISFREE;
-  ((struct mhead *) cp) -> mh_index = 0;
-#ifdef rcheck
-      ((struct mhead *) cp) -> mh_magic4 = MAGICFREE4;
-#endif /* rcheck */
-  cp += 8;
-
-  for (nu = 0; nu < 7; nu++)
-    {
-      CHAIN (cp) = nextf[nu];
-      nextf[nu] = (struct mhead *) cp;
-      ((struct mhead *) cp) -> mh_alloc = ISFREE;
-      ((struct mhead *) cp) -> mh_index = nu;
-#ifdef rcheck
-      ((struct mhead *) cp) -> mh_magic4 = MAGICFREE4;
-#endif /* rcheck */
-#ifdef scribblecheck
-    {
-      register char *m = (char *)((struct mhead *)cp+1);
-      register char *en = (8<<nu) + cp;
-      /* Fill whole block with MAGICFREE */
-      while (m<en) *m++ = MAGICFREE;
-    }
-#endif /* scribblecheck */
-      cp += 8 << nu;
-    }
-}
-#endif notdef
-\f
-/****************************************************************
- *                                                             *
- *     malloc - get a block of space from a pool               *
- *                                                             *
- ****************************************************************/
-
-char *
-malloc (n)             /* get a block */
-     unsigned n;
-{
-  register struct mhead *p;
-  register unsigned int nbytes;
-  register int nunits = 0;
-
-  /* Figure out how many bytes are required, rounding up to the nearest
-     multiple of 4, then figure out which nextf[] area to use */
-  nbytes = (n + sizeof *p + EXTRA + 3) & ~3;
-  {
-    register unsigned int   shiftr = (nbytes - 1) >> 2;
-
-    while (shiftr >>= 1)
-      nunits++;
-  }
-
-  /* If there are no blocks of the appropriate size, go get some */
-  /* COULD SPLIT UP A LARGER BLOCK HERE ... ACT */
-  if (nextf[nunits] == 0)
-    morecore (nunits);
-
-  /* Get one block off the list, and set the new list head */
-  if ((p = nextf[nunits]) == 0)
-    return 0;
-  nextf[nunits] = CHAIN (p);
-
-  /* Check for free block clobbered */
-  /* If not for this check, we would gobble a clobbered free chain ptr */
-  /* and bomb out on the NEXT allocate of this size block */
-  if (p -> mh_alloc != ISFREE || p -> mh_index != nunits)
-#ifdef rcheck
-    botch ("block on free list clobbered");
-#else /* not rcheck */
-    abort ();
-#endif /* not rcheck */
-#ifdef rcheck
-  if (p -> mh_magic4 != MAGICFREE4)
-    botch ("Magic in block on free list clobbered");
-#endif /* rcheck */
-#ifdef scribblecheck
-  /* Check for block filled with magic numbers, then change to zeros */
-  {
-    register char  *m = (char *) (p + 1);
-    register char *en = (8<<p->mh_index) + (char *) p;
-    register int  block_valid = 0;
-    while(m<en && (block_valid=(*m==MAGICFREE)))
-      *m++=(char)0;
-    /* so, status comes out as 1 if ok, 0 if terminated */
-    if (!block_valid) botch ("data on free list damaged");
-  }
-#endif /* scribblecheck */
-  /* Fill in the info, and if range checking, set up the magic numbers */
-  p -> mh_alloc = ISALLOC;
-  p -> mh_nbytes = n;
-#ifdef rcheck
-  p -> mh_magic4 = MAGIC4;
-  {
-    register char  *m = (char *) (p + 1) + n;
-#ifdef scribblecheck
-    register char *en = (8<<p->mh_index)+(char *)p;
-    /* point to end of block */
-    while (m<en) *m++ = MAGIC1;
-#else /* scribblecheck */
-    *m++ = MAGIC1, *m++ = MAGIC1, *m++ = MAGIC1, *m = MAGIC1; 
-#endif /* scribblecheck */
-  }
-#endif /* not rcheck */
-#ifdef MSTATS
-  nmalloc[nunits]++;
-  nmal++;
-#endif /* MSTATS */
-  return (char *) (p + 1);
-}
-\f
-/****************************************************************
- *                                                             *
- *     free - Free a block of space                            *
- *                                                             *
- ****************************************************************/
-
-free (mem)
-     char *mem;
-{
-  register struct mhead *p;
-  {
-    register char *ap = mem;
-
-    ASSERT (ap != 0);
-    p = (struct mhead *) ap - 1;
-    ASSERT (p -> mh_alloc == ISALLOC);
-#ifdef rcheck
-    ASSERT (p -> mh_magic4 == MAGIC4);
-    ap += p -> mh_nbytes;
-    p->mh_magic4 = MAGICFREE4;
-    ASSERT (*ap++ == MAGIC1); ASSERT (*ap++ == MAGIC1);
-    ASSERT (*ap++ == MAGIC1); ASSERT (*ap   == MAGIC1);
-#endif /* rcheck */
-  }
-  {
-    register int nunits = p -> mh_index;
-
-    ASSERT (nunits <= 29);
-#ifdef scribblecheck
-    {
-      /* Check that upper stuff was still MAGIC1 */
-      register char  *m = (char *) (p + 1) + p->mh_nbytes;
-      register char *en = (8<<p->mh_index) + (char *) p;
-      register int  block_valid = 0;
-      while(m<en && (block_valid=(*m++==MAGIC1)));
-      if (!block_valid) botch ("block freed with data out of bounds");
-      /* Fill whole block with MAGICFREE */
-      m = (char *) (p + 1);
-      while (m<en) *m++ = MAGICFREE;
-    }
-#endif /* scribblecheck */
-    p -> mh_alloc = ISFREE;
-    CHAIN (p) = nextf[nunits];
-    nextf[nunits] = p;
-#ifdef MSTATS
-    nmalloc[nunits]--;
-    nfre++;
-#endif /* MSTATS */
-  }
-}
-\f
-/****************************************************************
- *                                                             *
- *     realloc - resize a block, copy if necessary             *
- *                                                             *
- ****************************************************************/
-
-char *
-realloc (mem, n)
-     char *mem;
-     register unsigned n;
-{
-  register struct mhead *p;
-  register unsigned int tocopy;
-  register int nbytes;
-  register int nunits;
-
-  if ((p = (struct mhead *) mem) == 0)
-    return malloc (n);
-  p--;
-  nunits = p -> mh_index;
-  ASSERT (p -> mh_alloc == ISALLOC);
-  tocopy = p -> mh_nbytes;
-#ifdef rcheck
-  ASSERT (p -> mh_magic4 == MAGIC4);
-  {
-    register char *m = mem + tocopy;
-#ifdef scribblecheck
-    register char *en = (8<<p->mh_index) + (char *)p;
-    register int block_valid = 0;
-    while(m<en && (block_valid=(*m++==MAGIC1)));
-    if (!block_valid) botch ("out of bounds data on realloc");
-#else /* scribblecheck */
-    ASSERT (*m++ == MAGIC1); ASSERT (*m++ == MAGIC1);
-    ASSERT (*m++ == MAGIC1); ASSERT (*m   == MAGIC1);
-#endif /* scribblecheck */
-  }
-#endif /* not rcheck */
-
-  /* See if desired size rounds to same power of 2 as actual size. */
-  nbytes = (n + sizeof *p + EXTRA + 7) & ~7;
-
-  /* If ok, use the same block, just marking its size as changed.  */
-  if (nbytes > (4 << nunits) && nbytes <= (8 << nunits))
-    {
-      /* Here we check on realloc if we are grabbing unused space */
-#ifdef rcheck
-      register char *m = mem + tocopy;
-#ifdef scribblecheck
-      register char *en = (8<<p->mh_index) + (char *) p;
-      while (m<en) *m++=(char)0;
-#else /* scribblecheck */
-      *m++ = 0;  *m++ = 0;  *m++ = 0;  *m++ = 0;
-#endif /* scribblecheck */
-      m = mem + n;
-#ifdef scribblecheck
-      while(m<en) *m++ = MAGIC1;
-#else /* scribblecheck */
-      *m++ = MAGIC1;  *m++ = MAGIC1;  *m++ = MAGIC1;  *m++ = MAGIC1;
-#endif /* scribblecheck */
-#endif /* not rcheck */
-      p-> mh_nbytes = n;
-      return mem;
-    }
-
-  if (n < tocopy)
-    tocopy = n;
-  {
-    register char *new;
-
-    if ((new = malloc (n)) == 0)
-      return 0;
-    bcopy (mem, new, tocopy);
-    free (mem);
-    return new;
-  }
-}
-\f
-/****************************************************************
- *                                                             *
- *     Memory Statistics stuff                                 *
- *                                                             *
- ****************************************************************/
-
-#ifdef MSTATS
-/* Return statistics describing allocation of blocks of size 2**n. */
-
-struct mstats_value
-  {
-    int blocksize;
-    int nfree;
-    int nused;
-  };
-
-struct mstats_value
-malloc_stats (size)
-     int size;
-{
-  struct mstats_value v;
-  register int i;
-  register struct mhead *p;
-
-  v.nfree = 0;
-
-  if (size < 0 || size >= 30)
-    {
-      v.blocksize = 0;
-      v.nused = 0;
-      return v;
-    }
-
-  v.blocksize = 1 << (size + 3);
-  v.nused = nmalloc[size];
-
-  for (p = nextf[size]; p; p = CHAIN (p))
-    v.nfree++;
-
-  return v;
-}
-#endif /* MSTATS */
-\f
-#ifdef notdef
-/****************************************************************
- *                                                             *
- *     Stuff having to do with determining memory limits       *
- *                                                             *
- ****************************************************************/
-
-/*
- *     This function returns the total number of bytes that the process
- *     will be allowed to allocate via the sbrk(2) system call.  On
- *     BSD systems this is the total space allocatable to stack and
- *     data.  On USG systems this is the data space only.
- */
-
-#ifdef USG
-
-get_lim_data ()
-{
-  extern long ulimit ();
-    
-  lim_data = ulimit (3, 0);
-  lim_data -= (long) data_space_start;
-}
-
-#else /* not USG */
-#ifndef BSD42
-
-get_lim_data ()
-{
-  lim_data = vlimit (LIM_DATA, -1);
-}
-
-#else /* BSD42 */
-
-get_lim_data ()
-{
-  struct rlimit XXrlimit;
-
-  getrlimit (RLIMIT_DATA, &XXrlimit);
-  lim_data = XXrlimit.rlim_cur;                /* soft limit */
-}
-
-#endif /* BSD42 */
-#endif /* not USG */
-#endif notdef
-
-/*
- * Calloc - allocate and clear memory block
- */
-char *
-calloc(num, size)
-        register unsigned num, size;
-{
-        extern char *malloc();
-        register char *p;
-
-        size *= num;
-        if (p = malloc(size))
-                bzero(p, size);
-        return (p);
-}
-
-cfree(p, num, size)
-        char *p;
-        unsigned num;
-        unsigned size;
-{
-        free(p);
-}
index 8855b0c95fa2937b877530082493d5ae6541cb3a..3ff7b674b2cb632b868ec1de10840dfe1a085304 100644 (file)
@@ -17,6 +17,7 @@ static char *rcsid_mr_util_c = "$Header$";
 
 #include <ctype.h>
 #include <sys/types.h>
+#include <string.h>
 
 extern char *whoami;
 
@@ -35,7 +36,7 @@ requote(buf, cp, len)
                if (isprint(c)) *buf++ = c;
                else {
                        sprintf(buf, "\\%03o", c);
-                       buf = index(buf, '\0');
+                       buf = strchr(buf, '\0');
                }
        }
        if (len > 1) { *buf++ = '"'; count++; len--; }
@@ -43,7 +44,7 @@ requote(buf, cp, len)
        return buf;
 }
 
-log_args(tag, version, argc, argv)
+void log_args(tag, version, argc, argv)
        char *tag;
        int version;
        int argc;
index d710e5e08e76f06e59de954708353b4a21c334f7..8a7a0d97509175b5616c64b71078540f7769fb75 100644 (file)
@@ -14,21 +14,20 @@ static char *rcsid_qsupport_dc = "$Header$";
 #endif lint
 
 #include <mit-copyright.h>
-#include "query.h"
 #include "mr_server.h"
+#include "query.h"
 #include <ctype.h>
 EXEC SQL INCLUDE sqlca;
-EXEC SQL INCLUDE sqlda;
 #include "qrtn.h"
 
 extern char *whoami;
-extern int ingres_errno, mr_errcode;
+extern int dbms_errno, mr_errcode;
 
 EXEC SQL BEGIN DECLARE SECTION;
 extern char stmt_buf[];
 EXEC SQL END DECLARE SECTION;
 
-EXEC SQL WHENEVER SQLERROR CALL ingerr;
+EXEC SQL WHENEVER SQLERROR DO dbmserr();
 
 
 /* Specialized Access Routines */
@@ -39,10 +38,10 @@ EXEC SQL WHENEVER SQLERROR CALL ingerr;
  *    now in argv[0] instead of the login name.
  */
 
-access_user(q, argv, cl)
-    struct query *q;
-    char *argv[];
-    client *cl;
+int access_user(q, argv, cl)
+     struct query *q;
+     char *argv[];
+     client *cl;
 {
     if (cl->users_id != *(int *)argv[0])
        return(MR_PERM);
@@ -57,30 +56,31 @@ access_user(q, argv, cl)
  *   argv[0...n] contain search info.  q->
  */
 
-access_login(q, argv, cl)
-    struct query *q;
-    char *argv[];
-    client *cl;
+int access_login(q, argv, cl)
+     struct query *q;
+     char *argv[];
+     client *cl;
 {
     EXEC SQL BEGIN DECLARE SECTION;
     int id;
-    char qual[256];
     EXEC SQL END DECLARE SECTION;
 
-    /* BEGIN KLUDGE
-       Ingres will lose horribly if you try to look up a user with
-       a username > 8 chars (which some old versions of the moira client
-       still sometimes do). This routine is only called by gubl/gual and
-       gubu/guau, so we know argv[0] must be <=8 chars in a correct
-       query, so verify that first */
-    if(strlen(argv[0])>8) return MR_ARG_TOO_LONG;
-    /* END KLUDGE */
-
-    build_qual(q->qual, q->argc, argv, qual);
-    if (!strncmp(q->name,"get_user_account",strlen("get_user_account"))) {
-       EXEC SQL SELECT users_id INTO :id FROM users u, strings str WHERE :qual;
-    } else {
-       EXEC SQL SELECT users_id INTO :id FROM users u WHERE :qual;
+    if(q->argc != 1) return MR_ARGS;
+
+    if(!strcmp(q->shortname, "gual")) {
+      EXEC SQL SELECT users_id INTO :id FROM users u, strings str
+       WHERE u.login LIKE :argv[0] AND u.users_id != 0
+       AND u.comments = str.string_id;
+    } else if (!strcmp(q->shortname, "gubl")) {
+      EXEC SQL SELECT users_id INTO :id FROM users u
+       WHERE u.login LIKE :argv[0] AND u.users_id != 0;
+    } else if (!strcmp(q->shortname, "guau")) {
+      EXEC SQL SELECT users_id INTO :id FROM users u, strings str
+       WHERE u.unix_uid = :argv[0] AND u.users_id != 0
+       AND u.comments = str.string_id;
+    } else if(!strcmp(q->shortname, "gubu")) {
+      EXEC SQL SELECT users_id INTO :id FROM users u
+       WHERE u.unix_uid = :argv[0] AND u.users_id != 0;
     }
 
     if (sqlca.sqlerrd[2] != 1 || id != cl->users_id)
@@ -104,10 +104,10 @@ access_login(q, argv, cl)
  *     and the list is public, allow access if client = member
  */
 
-access_list(q, argv, cl)
-    struct query *q;
-    char *argv[];
-    client *cl;
+int access_list(q, argv, cl)
+     struct query *q;
+     char *argv[];
+     client *cl;
 {
     EXEC SQL BEGIN DECLARE SECTION;
     int list_id, acl_id, flags, gid;
@@ -136,13 +136,15 @@ access_list(q, argv, cl)
        if (*(int *)argv[2] == client_id) return(MR_SUCCESS);
     /* if update_list, don't allow them to change the GID */
     } else if (!strcmp("ulis", q->shortname)) {
-       if ((!strcmp(argv[7], UNIQUE_GID) && (gid != -1)) ||
-           (strcmp(argv[7], UNIQUE_GID) && (gid != atoi(argv[7]))))
-         return(MR_PERM);
+      if (!strcmp(argv[7], UNIQUE_GID)) {
+       if(gid != -1) return MR_PERM;
+      } else {
+       if(gid != atoi(argv[7])) return MR_PERM;
+      }
     }
 
     /* check for client in access control list */
-    status = find_member(acl_type, acl_id, client_type, client_id, 0);
+    status = find_member(acl_type, acl_id, client_type, client_id);
     if (!status) return(MR_PERM);
 
     return(MR_SUCCESS);
@@ -156,10 +158,10 @@ access_list(q, argv, cl)
  *         cl - client identifier
  */
 
-access_visible_list(q, argv, cl)
-    struct query *q;
-    char *argv[];
-    client *cl;
+int access_visible_list(q, argv, cl)
+     struct query *q;
+     char *argv[];
+     client *cl;
 {
     EXEC SQL BEGIN DECLARE SECTION;
     int list_id, acl_id, flags ;
@@ -183,7 +185,7 @@ access_visible_list(q, argv, cl)
        return(status);
 
     /* check for client in access control list */
-    status = find_member(acl_type, acl_id, client_type, client_id, 0);
+    status = find_member(acl_type, acl_id, client_type, client_id);
     if (!status)
        return(MR_PERM);
 
@@ -198,10 +200,10 @@ access_visible_list(q, argv, cl)
  *         cl - client identifier
  */
 
-access_vis_list_by_name(q, argv, cl)
-    struct query *q;
-    char *argv[];
-    client *cl;
+int access_vis_list_by_name(q, argv, cl)
+     struct query *q;
+     char *argv[];
+     client *cl;
 {
     EXEC SQL BEGIN DECLARE SECTION;
     int acl_id, flags, rowcount;
@@ -227,7 +229,7 @@ access_vis_list_by_name(q, argv, cl)
        return(status);
 
     /* check for client in access control list */
-    status = find_member(acl_type, acl_id, client_type, client_id, 0);
+    status = find_member(acl_type, acl_id, client_type, client_id);
     if (!status)
        return(MR_PERM);
 
@@ -240,10 +242,10 @@ access_vis_list_by_name(q, argv, cl)
  * on the acl of, or the list is visible.
  */
 
-access_member(q, argv, cl)
-    struct query *q;
-    char *argv[];
-    client *cl;
+int access_member(q, argv, cl)
+     struct query *q;
+     char *argv[];
+     client *cl;
 {
     if (!strcmp(argv[0], "LIST") || !strcmp(argv[0], "RLIST"))
       return(access_visible_list(q, &argv[1], cl));
@@ -266,10 +268,10 @@ access_member(q, argv, cl)
  * access iff argv[0] == "TRUE" and argv[2] == "FALSE".
  */
 
-access_qgli(q, argv, cl)
-    struct query *q;
-    char *argv[];
-    client *cl;
+int access_qgli(q, argv, cl)
+     struct query *q;
+     char *argv[];
+     client *cl;
 {
     if (!strcmp(argv[0], "TRUE") && !strcmp(argv[2], "FALSE"))
       return(MR_SUCCESS);
@@ -281,10 +283,10 @@ access_qgli(q, argv, cl)
  * allow access if a wildcard is used.
  */
 
-access_service(q, argv, cl)
-    struct query *q;
-    char *argv[];
-    client *cl;
+int access_service(q, argv, cl)
+     struct query *q;
+     char *argv[];
+     client *cl;
 {
     EXEC SQL BEGIN DECLARE SECTION;
     int acl_id;
@@ -305,7 +307,7 @@ access_service(q, argv, cl)
        return(status);
 
     /* check for client in access control list */
-    status = find_member(acl_type, acl_id, client_type, client_id, 0);
+    status = find_member(acl_type, acl_id, client_type, client_id);
     if (!status) return(MR_PERM);
 
     return(MR_SUCCESS);
@@ -316,10 +318,10 @@ access_service(q, argv, cl)
  *     named by argv[0]
  */
 
-access_filesys(q, argv, cl)
-    struct query *q;
-    char *argv[];
-    client *cl;
+int access_filesys(q, argv, cl)
+     struct query *q;
+     char *argv[];
+     client *cl;
 {
     EXEC SQL BEGIN DECLARE SECTION;
     int users_id, list_id;
@@ -338,7 +340,7 @@ access_filesys(q, argv, cl)
       return(MR_SUCCESS);
     if ((status = get_client(cl, &client_type, &client_id)) != MR_SUCCESS)
       return(status);
-    status = find_member("LIST", list_id, client_type, client_id, 0);
+    status = find_member("LIST", list_id, client_type, client_id);
     if (status)
       return(MR_SUCCESS);
     else
@@ -351,14 +353,14 @@ access_filesys(q, argv, cl)
 
 int host_access_level = 0;              /* 1 for network, 2 for host */
 
-access_host(q, argv, cl)
-    struct query *q;
-    char *argv[];
-    client *cl;
+int access_host(q, argv, cl)
+     struct query *q;
+     char *argv[];
+     client *cl;
 {
     EXEC SQL BEGIN DECLARE SECTION;
-    int mid, sid, users_id, id;
-    char mtype[9], stype[9], *name;
+    int mid, sid, id;
+    char mtype[9], stype[9];
     EXEC SQL END DECLARE SECTION;
     int status, client_id;
     char *client_type;
@@ -382,12 +384,12 @@ access_host(q, argv, cl)
 
     if ((status = get_client(cl, &client_type, &client_id)) != MR_SUCCESS)
       return(status);
-    status = find_member(stype, sid, client_type, client_id, 0);
+    status = find_member(stype, sid, client_type, client_id);
     if (status) {
        host_access_level = 1;
        return(MR_SUCCESS);
     }
-    status = find_member(mtype, mid, client_type, client_id, 0);
+    status = find_member(mtype, mid, client_type, client_id);
     if (status) {
        host_access_level = 2;
        return(MR_SUCCESS);
@@ -402,10 +404,10 @@ access_host(q, argv, cl)
  * If deleting an alias, any owner will do.
  */
 
-access_ahal(q, argv, cl)
-    struct query *q;
-    char *argv[];
-    client *cl;
+int access_ahal(q, argv, cl)
+     struct query *q;
+     char *argv[];
+     client *cl;
 {
     EXEC SQL BEGIN DECLARE SECTION;
     int cnt, id, mid, sid;
@@ -420,7 +422,7 @@ access_ahal(q, argv, cl)
     id = *(int *)argv[1];
 
     EXEC SQL SELECT count(name) INTO :cnt from hostalias WHERE mach_id = :id;
-    if (ingres_errno) return(mr_errcode);
+    if (dbms_errno) return(mr_errcode);
     /* if the type is APPEND, this is ahal and we need to make sure there
      * will be no more than 2 aliases.  If it's not, it must be dhal and
      * any owner will do.
@@ -432,10 +434,10 @@ access_ahal(q, argv, cl)
       WHERE m.mach_id=:id and s.snet_id=m.snet_id;
     if ((status = get_client(cl, &client_type, &client_id)) != MR_SUCCESS)
       return(status);
-    status = find_member(mtype, mid, client_type, client_id, 0);
+    status = find_member(mtype, mid, client_type, client_id);
     if (status)
       return(MR_SUCCESS);
-    status = find_member(stype, sid, client_type, client_id, 0);
+    status = find_member(stype, sid, client_type, client_id);
     if (status)
       return(MR_SUCCESS);
     else
@@ -447,10 +449,10 @@ access_ahal(q, argv, cl)
 /* access_snt - check for retrieving network structure
  */
 
-access_snt(q, argv, cl)
-    struct query *q;
-    char *argv[];
-    client *cl;
+int access_snt(q, argv, cl)
+     struct query *q;
+     char *argv[];
+     client *cl;
 {
     if(q->type == RETRIEVE)
        return(MR_SUCCESS);
index 06123f10bb682b8c6562f5e6b9a00cf760370337..89962303ba6817bb0a7045c4059ca7c58e029aef 100644 (file)
@@ -14,74 +14,76 @@ static char *rcsid_qsupport_dc = "$Header$";
 #endif lint
 
 #include <mit-copyright.h>
-#include "query.h"
 #include "mr_server.h"
+#include "query.h"
 #include <ctype.h>
+#include <string.h>
 #ifdef GDSS
 #include "gdss.h"
 #endif /* GDSS */
 EXEC SQL INCLUDE sqlca;
-EXEC SQL INCLUDE sqlda;
 #include "qrtn.h"
 
-extern char *whoami, *strsave();
-extern int ingres_errno, mr_errcode;
+extern char *whoami, *table_name[];
+extern int dbms_errno, mr_errcode;
 
 EXEC SQL BEGIN DECLARE SECTION;
 extern char stmt_buf[];
 EXEC SQL END DECLARE SECTION;
 
-EXEC SQL WHENEVER SQLERROR CALL ingerr;
+static void hex_dump(unsigned char *p);
+
+EXEC SQL WHENEVER SQLERROR DO dbmserr();
 
 
 /* FOLLOWUP ROUTINES */
 
-/* generic set_modtime routine.  This takes the table name from the query,
+/* generic set_modtime routine.  This takes the table id from the query,
  * and will update the modtime, modby, and modwho fields in the entry in
  * the table whose name field matches argv[0].
  */
 
-set_modtime(q, argv, cl)
-    struct query *q;
-    char *argv[];
-    client *cl;
+int set_modtime(q, argv, cl)
+     struct query *q;
+     char *argv[];
+     client *cl;
 {
     char *name, *entity, *table;
     int who;
 
     entity = cl->entity;
     who = cl->client_id;
-    table = q->rtable;
+    table = table_name[q->rtable];
     name = argv[0];
 
-    sprintf(stmt_buf,"UPDATE %s SET modtime = 'now', modby = %d, modwith = '%s' WHERE %s.name = LEFT('%s',SIZE(%s.name))",table,who,entity,table,name,table);
+    sprintf(stmt_buf,"UPDATE %s SET modtime = SYSDATE, modby = %d, modwith = '%s' WHERE name = '%s'",table,who,entity,name);
     EXEC SQL EXECUTE IMMEDIATE :stmt_buf;
 
     return(MR_SUCCESS);
 }
 
-/* generic set_modtime_by_id routine.  This takes the table name from
+/* generic set_modtime_by_id routine.  This takes the table id from
  * the query, and the id name from the validate record,
  * and will update the modtime, modby, and modwho fields in the entry in
  * the table whose id matches argv[0].
  */
 
-set_modtime_by_id(q, argv, cl)
-    struct query *q;
-    char **argv;
-    client *cl;
+int set_modtime_by_id(q, argv, cl)
+     struct query *q;
+     char *argv[];
+     client *cl;
 {
     char *entity, *table, *id_name;
     int who, id;
 
     entity = cl->entity;
     who = cl->client_id;
-    table = q->rtable;
+    table = table_name[q->rtable];
     id_name = q->validate->object_id;
 
     id = *(int *)argv[0];
-    sprintf(stmt_buf,"UPDATE %s SET modtime = 'now', modby = %d, \
-modwith = '%s' WHERE %s.%s = %d",table,who,entity,table,id_name,id);
+    sprintf(stmt_buf,"UPDATE %s SET modtime = SYSDATE, modby = %d, \
+modwith = '%s' WHERE %s = %d",table,who,entity,id_name,id);
     EXEC SQL EXECUTE IMMEDIATE :stmt_buf;
     return(MR_SUCCESS);
 }
@@ -90,10 +92,10 @@ modwith = '%s' WHERE %s.%s = %d",table,who,entity,table,id_name,id);
 /* Sets the finger modtime on a user record.  The users_id will be in argv[0].
  */
 
-set_finger_modtime(q, argv, cl)
-    struct query *q;
-    char *argv[];
-    client *cl;
+int set_finger_modtime(q, argv, cl)
+     struct query *q;
+     char *argv[];
+     client *cl;
 {
     EXEC SQL BEGIN DECLARE SECTION;
     int users_id, who;
@@ -104,8 +106,8 @@ set_finger_modtime(q, argv, cl)
     who = cl->client_id;
     users_id = *(int *)argv[0];
 
-    EXEC SQL UPDATE users SET fmodtime='now', fmodby = :who, fmodwith = :entity
-      WHERE users.users_id = :users_id;
+    EXEC SQL UPDATE users SET fmodtime=SYSDATE, fmodby = :who,
+      fmodwith = :entity WHERE users_id = :users_id;
 
    return(MR_SUCCESS);
 }
@@ -114,10 +116,10 @@ set_finger_modtime(q, argv, cl)
 /* Sets the pobox modtime on a user record.  The users_id will be in argv[0].
  */
 
-set_pobox_modtime(q, argv, cl)
-    struct query *q;
-    char **argv;
-    client *cl;
+int set_pobox_modtime(q, argv, cl)
+     struct query *q;
+     char *argv[];
+     client *cl;
 {
     EXEC SQL BEGIN DECLARE SECTION;
     int users_id, who;
@@ -128,8 +130,8 @@ set_pobox_modtime(q, argv, cl)
     who = cl->client_id;
     users_id = *(int *)argv[0];
 
-    EXEC SQL UPDATE users SET pmodtime='now', pmodby = :who, pmodwith = :entity
-      WHERE users.users_id = :users_id;
+    EXEC SQL UPDATE users SET pmodtime=SYSDATE, pmodby = :who,
+      pmodwith = :entity WHERE users_id = :users_id;
 
     return(MR_SUCCESS);
 }
@@ -138,20 +140,20 @@ set_pobox_modtime(q, argv, cl)
 /* Like set_modtime, but uppercases the name first.
  */
 
-set_uppercase_modtime(q, argv, cl)
-    struct query *q;
-    char **argv;
-    client *cl;
+int set_uppercase_modtime(q, argv, cl)
+     struct query *q;
+     char *argv[];
+     client *cl;
 {
     char *name, *entity, *table;
     int who;
 
     entity = cl->entity;
     who = cl->client_id;
-    table = q->rtable;
+    table = table_name[q->rtable];
     name = argv[0];
 
-    sprintf(stmt_buf,"UPDATE %s SET modtime = 'now', modby = %d, modwith = '%s' WHERE %s.name = UPPERCASE(LEFT('%s',SIZE(%s.name)))",table,who,entity,table,name,table);
+    sprintf(stmt_buf,"UPDATE %s SET modtime = SYSDATE, modby = %d, modwith = '%s' WHERE name = UPPER('%s')",table,who,entity,name);
     EXEC SQL EXECUTE IMMEDIATE :stmt_buf;
 
     return(MR_SUCCESS);
@@ -163,10 +165,10 @@ set_uppercase_modtime(q, argv, cl)
  * operates on is "mcm", not "machine".
  */
 
-set_mach_modtime_by_id(q, argv, cl)
-    struct query *q;
-    char **argv;
-    client *cl;
+int set_mach_modtime_by_id(q, argv, cl)
+     struct query *q;
+     char *argv[];
+     client *cl;
 {
     EXEC SQL BEGIN DECLARE SECTION;
     char *entity;
@@ -176,8 +178,8 @@ set_mach_modtime_by_id(q, argv, cl)
     entity = cl->entity;
     who = cl->client_id;
     id = *(int *)argv[0];
-    EXEC SQL UPDATE machine SET modtime='now', modby = :who, modwith = :entity
-      WHERE machine.mach_id = :id;
+    EXEC SQL UPDATE machine SET modtime=SYSDATE, modby = :who,
+      modwith = :entity WHERE mach_id = :id;
 
     return(MR_SUCCESS);
 }
@@ -188,10 +190,10 @@ set_mach_modtime_by_id(q, argv, cl)
  * table that query operates on is "svc", not "cluster".
  */
 
-set_cluster_modtime_by_id(q, argv, cl)
-    struct query *q;
-    char **argv;
-    client *cl;
+int set_cluster_modtime_by_id(q, argv, cl)
+     struct query *q;
+     char *argv[];
+     client *cl;
 {
     EXEC SQL BEGIN DECLARE SECTION;
     char *entity;
@@ -202,8 +204,8 @@ set_cluster_modtime_by_id(q, argv, cl)
     who = cl->client_id;
 
     id = *(int *)argv[0];
-    EXEC SQL UPDATE cluster SET modtime='now', modby = :who, modwith = :entity
-      WHERE cluster.clu_id = :id;
+    EXEC SQL UPDATE clusters SET modtime=SYSDATE, modby = :who,
+      modwith = :entity WHERE clu_id = :id;
     return(MR_SUCCESS);
 }
 
@@ -212,10 +214,10 @@ set_cluster_modtime_by_id(q, argv, cl)
  * and the mach_id is in argv[1].
  */
 
-set_serverhost_modtime(q, argv, cl)
-    struct query *q;
-    char **argv;
-    client *cl;
+int set_serverhost_modtime(q, argv, cl)
+     struct query *q;
+     char *argv[];
+     client *cl;
 {
     EXEC SQL BEGIN DECLARE SECTION;
     char *entity, *serv;
@@ -228,7 +230,7 @@ set_serverhost_modtime(q, argv, cl)
     serv = argv[0];
     id = *(int *)argv[1];
     EXEC SQL UPDATE serverhosts
-      SET modtime = 'now', modby = :who, modwith = :entity
+      SET modtime = SYSDATE, modby = :who, modwith = :entity
       WHERE service = :serv AND mach_id = :id;
     return(MR_SUCCESS);
 }
@@ -238,10 +240,10 @@ set_serverhost_modtime(q, argv, cl)
  * directory name is in argv[1].
  */
 
-set_nfsphys_modtime(q, argv, cl)
-    struct query *q;
-    char **argv;
-    client *cl;
+int set_nfsphys_modtime(q, argv, cl)
+     struct query *q;
+     char *argv[];
+     client *cl;
 {
     EXEC SQL BEGIN DECLARE SECTION;
     char *entity, *dir;
@@ -253,8 +255,8 @@ set_nfsphys_modtime(q, argv, cl)
 
     id = *(int *)argv[0];
     dir = argv[1];
-    EXEC SQL UPDATE nfsphys SET modtime = 'now', modby = :who, modwith = :entity
-      WHERE dir = :dir AND mach_id = :id;
+    EXEC SQL UPDATE nfsphys SET modtime = SYSDATE, modby = :who,
+      modwith = :entity WHERE dir = :dir AND mach_id = :id;
     return(MR_SUCCESS);
 }
 
@@ -263,10 +265,10 @@ set_nfsphys_modtime(q, argv, cl)
  * label.
  */
 
-set_filesys_modtime(q, argv, cl)
-    struct query *q;
-    char *argv[];
-    client *cl;
+int set_filesys_modtime(q, argv, cl)
+     struct query *q;
+     char *argv[];
+     client *cl;
 {
     EXEC SQL BEGIN DECLARE SECTION;
     char *label, *entity;
@@ -282,9 +284,9 @@ set_filesys_modtime(q, argv, cl)
     if (!strcmp(q->shortname, "ufil"))
       label = argv[1];
 
-    EXEC SQL UPDATE filesys SET modtime = 'now', modby = :who,
+    EXEC SQL UPDATE filesys SET modtime = SYSDATE, modby = :who,
         modwith = :entity, phys_id = :_var_phys_id
-      WHERE label = LEFT(:label,SIZE(label));
+      WHERE label = :label;
     return(MR_SUCCESS);
 }
 
@@ -293,10 +295,10 @@ set_filesys_modtime(q, argv, cl)
  * name.
  */
 
-set_zephyr_modtime(q, argv, cl)
-    struct query *q;
-    char *argv[];
-    client *cl;
+int set_zephyr_modtime(q, argv, cl)
+     struct query *q;
+     char *argv[];
+     client *cl;
 {
     EXEC SQL BEGIN DECLARE SECTION;
     char *class, *entity;
@@ -308,8 +310,8 @@ set_zephyr_modtime(q, argv, cl)
 
     class = argv[0];
 
-    EXEC SQL UPDATE zephyr SET modtime = 'now', modby = :who, modwith = :entity
-      WHERE class = LEFT(:class,SIZE(class));
+    EXEC SQL UPDATE zephyr SET modtime = SYSDATE, modby = :who,
+      modwith = :entity WHERE class = :class;
 
     return(MR_SUCCESS);
 }
@@ -320,13 +322,12 @@ set_zephyr_modtime(q, argv, cl)
  * passed as a pointer to an integer.  This will either turn it into a
  * username, or # + the users_id.
  */
-followup_fix_modby(q, sq, v, action, actarg, cl)
-    struct query *q;
-    register struct save_queue *sq;
-    struct validate *v;
-    register int (*action)();
-    register int actarg;
-    client *cl;
+int followup_fix_modby(q, sq, v, action, actarg, cl)
+     struct query *q;
+     struct save_queue *sq;
+     struct validate *v;
+     int (*action)(), actarg;
+     client *cl;
 {
     register int i, j;
     char **argv;
@@ -336,9 +337,9 @@ followup_fix_modby(q, sq, v, action, actarg, cl)
     while (sq_get_data(sq, &argv)) {
        id = atoi(argv[i]);
        if (id > 0)
-         status = id_to_name(id, "USER", &argv[i]);
+         status = id_to_name(id, USERS_TABLE, &argv[i]);
        else
-         status = id_to_name(-id, "STRING", &argv[i]);
+         status = id_to_name(-id, STRINGS_TABLE, &argv[i]);
        if (status && status != MR_NO_MATCH)
          return(status);
        (*action)(q->vcnt, argv, actarg);
@@ -359,13 +360,12 @@ followup_fix_modby(q, sq, v, action, actarg, cl)
  * these are ones with U_END return values.  "gub*" queries also use this
  * routine but don't have a signature.
  */
-followup_guax(q, sq, v, action, actarg, cl)
-    struct query *q;
-    register struct save_queue *sq;
-    struct validate *v;
-    register int (*action)();
-    register int actarg;
-    client *cl;
+int followup_guax(q, sq, v, action, actarg, cl)
+     struct query *q;
+     struct save_queue *sq;
+     struct validate *v;
+     int (*action)(), actarg;
+     client *cl;
 {
     register int i, j;
     char **argv;
@@ -374,40 +374,37 @@ followup_guax(q, sq, v, action, actarg, cl)
     char *kname;
     SigInfo  si;
     EXEC SQL BEGIN DECLARE SECTION; 
-    int timestamp, who;
+    int timestamp, who, siglen;
     char *login;
-    varchar struct { short data_size; char data_buf[257];} rsig;
+    char rsig[256];
+    EXEC SQL VAR rsig IS STRING(256);
     EXEC SQL END DECLARE SECTION; 
 #endif /* GDSS */
     int id, status;
 
     i = q->vcnt - 2;
     while (sq_get_data(sq, &argv)) {
-#ifdef DEBUG
-       com_err(whoami, 0, "argv[SIGNATURE] = \"%s\"", argv[U_SIGNATURE]);
-#endif /* DEBUG */
        id = atoi(argv[i]);
        if (id > 0)
-         status = id_to_name(id, "USER", &argv[i]);
+         status = id_to_name(id, USERS_TABLE, &argv[i]);
        else
-         status = id_to_name(-id, "STRING", &argv[i]);
+         status = id_to_name(-id, STRINGS_TABLE, &argv[i]);
        if (status && status != MR_NO_MATCH)
          return(status);
 #ifdef GDSS
        if (q->vcnt == U_END && strlen(argv[U_SIGNATURE])) {
-           login = argv[U_NAME];
-           EXEC SQL REPEATED SELECT signature, sigdate, sigwho 
+           login = strtrim(argv[U_NAME]);
+           EXEC SQL SELECT signature, sigdate, sigwho 
              INTO :rsig, :timestamp, :who FROM users
              WHERE login = :login;
-           /** What about (INGRES) error handling? **/
+           if(dbms_errno) return mr_errcode;
            kname = malloc(1);
-            status = id_to_name(who, "STRING", &kname);
+            status = id_to_name(who, STRINGS_TABLE, &kname);
             si.timestamp = timestamp;
            si.SigInfoVersion = 0; /* XXXXX this isn't used */
            kname_parse(si.pname, si.pinst, si.prealm, kname);
             free(kname);
-           rsig.data_buf[rsig.data_size] = 0;
-            si.rawsig = (unsigned char *)strsave(rsig.data_buf);
+            si.rawsig = (unsigned char *)strsave(rsig);
            if (log_flags & LOG_GDSS)
              com_err(whoami, 0, "rawsig length = %d, sig=\"%s\"", strlen(si.rawsig), si.rawsig);
            GDSS_Recompose(&si, sigbuf);
@@ -439,14 +436,14 @@ followup_guax(q, sq, v, action, actarg, cl)
  **
  **/
 
-followup_ausr(q, argv, cl)
-    struct query *q;
-    char *argv[];
-    client *cl;
+int followup_ausr(q, argv, cl)
+     struct query *q;
+     char *argv[];
+     client *cl;
 {
     EXEC SQL BEGIN DECLARE SECTION;
-    int who, status, id;
-    char *login, *entity, *src, *dst, *name;
+    int who, status;
+    char *login, *entity, *name;
     char fullname[129];
     EXEC SQL END DECLARE SECTION;
 #ifdef GDSS
@@ -468,13 +465,6 @@ followup_ausr(q, argv, cl)
 
 #ifdef GDSS
       if (q->vcnt == U_END && *argv[U_SIGNATURE]) {
-       /* unquote ' chars in signature */
-       for (dst = src = argv[U_SIGNATURE]; *src; ) {
-           if (*src == '\'')
-             src++;
-           *dst++ = *src++;
-       }
-       *dst = 0;
         sprintf(databuf, "%s:%s", argv[U_NAME], argv[U_MITID]);
         /* skip bytes for timestamp & kname */
         si.rawsig = (unsigned char *) rawsig;
@@ -485,7 +475,7 @@ followup_ausr(q, argv, cl)
        }
         if (status == 0) {
             name = kname_unparse(si.pname, si.pinst, si.prealm);
-            status = name_to_id(name, "STRING", &sigwho);
+            status = name_to_id(name, STRINGS_TABLE, &sigwho);
             if (status == MR_NO_MATCH) {
              sigwho=add_string(name);
             } else if (status)
@@ -509,19 +499,20 @@ followup_ausr(q, argv, cl)
 
     /* create finger entry, pobox & set modtime on user */
 #ifdef GDSS
-    EXEC SQL REPEATED UPDATE users
-      SET modtime='now', modby=:who, modwith = :entity,
-          fullname = :fullname, affiliation = type,
-          signature = :rawsig, sigdate = :timestamp, sigwho = :sigwho,
-          fmodtime='now', fmodby = :who, fmodwith = :entity,
-          potype='NONE', pmodtime='now', pmodby = :who, pmodwith = :entity
+    EXEC SQL UPDATE users
+      SET modtime=SYSDATE, modby=:who, modwith = :entity,
+          fullname = NVL(:fullname,CHR(0)), affiliation = type,
+          signature = NVL(:rawsig,CHR(0)), sigdate = :timestamp,
+          sigwho = :sigwho, fmodtime=SYSDATE, fmodby = :who, 
+          fmodwith = :entity, potype='NONE', pmodtime=SYSDATE, 
+          pmodby = :who, pmodwith = :entity
       WHERE login = :login;
 #else /* GDSS */
-    EXEC SQL REPEATED UPDATE users
-      SET modtime='now', modby=:who, modwith = :entity,
-          fullname = :fullname, affiliation = type,
-          fmodtime='now', fmodby = :who, fmodwith = :entity,
-          potype='NONE', pmodtime='now', pmodby = :who, pmodwith = :entity
+    EXEC SQL UPDATE users
+      SET modtime=SYSDATE, modby=:who, modwith = :entity,
+          fullname = NVL(:fullname,CHR(0)), affiliation = type,
+          fmodtime=SYSDATE, fmodby = :who, fmodwith = :entity,
+          potype='NONE', pmodtime=SYSDATE, pmodby = :who, pmodwith = :entity
       WHERE login = :login;
 #endif /* GDSS */
 
@@ -530,7 +521,7 @@ followup_ausr(q, argv, cl)
 
 
 /**
- ** followup_uusr - do signature, set_user_modtime
+ ** followup_uuac - do signature, set_user_modtime
  **
  ** Inputs:
  **   argv[0] - login (add_user)
@@ -538,14 +529,14 @@ followup_ausr(q, argv, cl)
  **
  **/
 
-followup_uuac(q, argv, cl)
-    struct query *q;
-    char *argv[];
-    client *cl;
+int followup_uuac(q, argv, cl)
+     struct query *q;
+     char *argv[];
+     client *cl;
 {
     EXEC SQL BEGIN DECLARE SECTION; 
     int who, status, id;
-    char *entity, *name, *src, *dst;
+    char *entity, *name;
     EXEC SQL END DECLARE SECTION; 
 #ifdef GDSS
     char databuf[32], *kname_unparse();
@@ -563,33 +554,20 @@ followup_uuac(q, argv, cl)
     
 #ifdef GDSS
     if (q->vcnt == U_MODTIME && *argv[U_SIGNATURE + 1]) {
-       /* unquote ' chars in signature */
-       for (dst = src = argv[U_SIGNATURE+1]; *src; ) {
-           if (*src == '\'')
-             src++;
-           *dst++ = *src++;
-       }
-       *dst = 0;
         login = malloc(1);
-        status = id_to_name(id, "USER", &login);
+        status = id_to_name(id, USERS_TABLE, &login);
         sprintf(databuf, "%s:%s", login, argv[U_MITID+1]);
         free(login);
         /* skip bytes for timestamp & kname */
         si.rawsig = (unsigned char *) rawsig;
-#ifdef DEBUG
-       com_err(whoami, 0, "verifying sig");
-#endif /* DEBUG */
         status = GDSS_Verify(databuf, strlen(databuf), argv[U_SIGNATURE+1], &si);
-#ifdef DEBUG
-       com_err(whoami, 0, "verified");
-#endif /* DEBUG */
        if (strlen(rawsig) > mr_sig_length) {
            com_err(whoami, 0, "GDSS signature would be truncated.");  /** untested **/
            return(MR_INTERNAL);
        }
         if (status == 0) {
             name = kname_unparse(si.pname, si.pinst, si.prealm);
-            status = name_to_id(name, "STRING", &sigwho);
+            status = name_to_id(name, STRINGS_TABLE, &sigwho);
             if (status == MR_NO_MATCH) {
              sigwho=add_string(name);
             } else if (status)
@@ -610,17 +588,16 @@ followup_uuac(q, argv, cl)
     /* create finger entry, pobox & set modtime on user */
 
 #ifdef GDSS
-    EXEC SQL REPEATED UPDATE users SET modtime='now', modby = :who, modwith = :entity,
-        signature = :rawsig, sigdate = :timestamp, sigwho = :sigwho
+    EXEC SQL UPDATE users SET modtime=SYSDATE, modby = :who, modwith = :entity,
+        signature = NVL(:rawsig,CHR(0)), sigdate = :timestamp, sigwho = :sigwho
       WHERE users_id = :id;
 #else /* GDSS */
-    EXEC SQL REPEATED UPDATE users SET modtime='now', modby = :who, modwith = :entity
+    EXEC SQL UPDATE users SET modtime=SYSDATE, modby = :who, modwith = :entity
       WHERE users_id = :id;
 #endif /* GDSS */
     return(MR_SUCCESS);
 }
  
 /* followup_gpob: fixes argv[2] based on the IDs currently there and the
  * type in argv[1].  Then completes the upcall to the user.
  *
@@ -630,13 +607,13 @@ followup_uuac(q, argv, cl)
  * are skipped.
  */
 
-followup_gpob(q, sq, v, action, actarg, cl)
-    register struct query *q;
-    register struct save_queue *sq;
-    register struct validate *v;
-    register int (*action)();
-    int actarg;
-    client *cl;
+int followup_gpob(q, sq, v, action, actarg, cl)
+     struct query *q;
+     struct save_queue *sq;
+     struct validate *v;
+     int (*action)();
+     int actarg;
+     client *cl;
 {
     char **argv;
     char *ptype, *p;
@@ -646,17 +623,17 @@ followup_gpob(q, sq, v, action, actarg, cl)
     while (sq_get_data(sq, &argv)) {
        mr_trim_args(2, argv);
        ptype = argv[1];
-       p = index(argv[2], ':');
+       p = strchr(argv[2], ':');
        *p++ = 0;
        mid = atoi(argv[2]);
        sid = atoi(p);
 
        if (!strcmp(ptype, "POP")) {
-           status = id_to_name(mid, "MACHINE", &argv[2]);
+           status = id_to_name(mid, MACHINE_TABLE, &argv[2]);
            if (status == MR_NO_MATCH)
              return(MR_MACHINE);
        } else if (!strcmp(ptype, "SMTP")) {
-           status = id_to_name(sid, "STRING", &argv[2]);
+           status = id_to_name(sid, STRINGS_TABLE, &argv[2]);
            if (status == MR_NO_MATCH)
              return(MR_STRING);
        } else /* ptype == "NONE" */ {
@@ -667,9 +644,9 @@ followup_gpob(q, sq, v, action, actarg, cl)
        if (!strcmp(q->shortname, "gpob")) {
            sid = atoi(argv[4]);
            if (sid > 0)
-             status = id_to_name(sid, "USER", &argv[4]);
+             status = id_to_name(sid, USERS_TABLE, &argv[4]);
            else
-             status = id_to_name(-sid, "STRING", &argv[4]);
+             status = id_to_name(-sid, STRINGS_TABLE, &argv[4]);
        }
        if (status && status != MR_NO_MATCH) return(status);
 
@@ -692,13 +669,12 @@ followup_gpob(q, sq, v, action, actarg, cl)
  * Also fixes the modby field by called followup_fix_modby.
  */
 
-followup_gsnt(q, sq, v, action, actarg, cl)
-    register struct query *q;
-    register struct save_queue *sq;
-    register struct validate *v;
-    register int (*action)();
-    int actarg;
-    client *cl;
+int followup_gsnt(q, sq, v, action, actarg, cl)
+     struct query *q;
+     struct save_queue *sq;
+     struct validate *v;
+     int (*action)(), actarg;
+     client *cl;
 {
     char **argv, *type;
     int id, i, idx, status;
@@ -710,9 +686,9 @@ followup_gsnt(q, sq, v, action, actarg, cl)
 
        id = atoi(argv[i = q->vcnt - 2]);
        if (id > 0)
-         status = id_to_name(id, "USER", &argv[i]);
+         status = id_to_name(id, USERS_TABLE, &argv[i]);
        else
-         status = id_to_name(-id, "STRING", &argv[i]);
+         status = id_to_name(-id, STRINGS_TABLE, &argv[i]);
        if (status && status != MR_NO_MATCH)
          return(status);
 
@@ -720,11 +696,11 @@ followup_gsnt(q, sq, v, action, actarg, cl)
        type = argv[idx - 1];
 
        if (!strcmp(type, "LIST")) {
-           status = id_to_name(id, "LIST", &argv[idx]);
+           status = id_to_name(id, LIST_TABLE, &argv[idx]);
        } else if (!strcmp(type, "USER")) {
-           status = id_to_name(id, "USER", &argv[idx]);
+           status = id_to_name(id, USERS_TABLE, &argv[idx]);
        } else if (!strcmp(type, "KERBEROS")) {
-           status = id_to_name(id, "STRING", &argv[idx]);
+           status = id_to_name(id, STRINGS_TABLE, &argv[idx]);
        } else if (!strcmp(type, "NONE")) {
            status = 0;
            free(argv[idx]);
@@ -757,13 +733,12 @@ followup_gsnt(q, sq, v, action, actarg, cl)
  * Also fixes the modby field by called followup_fix_modby.
  */
 
-followup_ghst(q, sq, v, action, actarg, cl)
-    register struct query *q;
-    register struct save_queue *sq;
-    register struct validate *v;
-    register int (*action)();
-    int actarg;
-    client *cl;
+int followup_ghst(q, sq, v, action, actarg, cl)
+     struct query *q;
+     struct save_queue *sq;
+     struct validate *v;
+     int (*action)(), actarg;
+     client *cl;
 {
     char **argv, *type;
     int id, i, idx, status;
@@ -773,23 +748,23 @@ followup_ghst(q, sq, v, action, actarg, cl)
 
        id = atoi(argv[i = q->vcnt - 2]);
        if (id > 0)
-         status = id_to_name(id, "USER", &argv[i]);
+         status = id_to_name(id, USERS_TABLE, &argv[i]);
        else
-         status = id_to_name(-id, "STRING", &argv[i]);
+         status = id_to_name(-id, STRINGS_TABLE, &argv[i]);
        if (status && status != MR_NO_MATCH)
          return(status);
 
        id = atoi(argv[13]);
-       status = id_to_name(id, "STRING", &argv[13]);
+       status = id_to_name(id, STRINGS_TABLE, &argv[13]);
        if (status) return(status);
        id = atoi(argv[14]);
-       status = id_to_name(id, "STRING", &argv[14]);
+       status = id_to_name(id, STRINGS_TABLE, &argv[14]);
        if (status) return(status);
        id = atoi(argv[16]);
        if (id < 0)
-         status = id_to_name(-id, "STRING", &argv[16]);
+         status = id_to_name(-id, STRINGS_TABLE, &argv[16]);
        else
-         status = id_to_name(id, "USER", &argv[16]);
+         status = id_to_name(id, USERS_TABLE, &argv[16]);
        if (status && status != MR_NO_MATCH)
          return(status);
 
@@ -798,11 +773,11 @@ followup_ghst(q, sq, v, action, actarg, cl)
        type = strtrim(argv[idx - 1]);
 
        if (!strcmp(type, "LIST")) {
-           status = id_to_name(id, "LIST", &argv[idx]);
+           status = id_to_name(id, LIST_TABLE, &argv[idx]);
        } else if (!strcmp(type, "USER")) {
-           status = id_to_name(id, "USER", &argv[idx]);
+           status = id_to_name(id, USERS_TABLE, &argv[idx]);
        } else if (!strcmp(type, "KERBEROS")) {
-           status = id_to_name(id, "STRING", &argv[idx]);
+           status = id_to_name(id, STRINGS_TABLE, &argv[idx]);
        } else if (!strcmp(type, "NONE")) {
            status = 0;
            free(argv[idx]);
@@ -835,13 +810,12 @@ followup_ghst(q, sq, v, action, actarg, cl)
  * Also fixes the modby field by called followup_fix_modby.
  */
 
-followup_glin(q, sq, v, action, actarg, cl)
-    register struct query *q;
-    register struct save_queue *sq;
-    register struct validate *v;
-    register int (*action)();
-    int actarg;
-    client *cl;
+int followup_glin(q, sq, v, action, actarg, cl)
+     struct query *q;
+     struct save_queue *sq;
+     struct validate *v;
+     int (*action)(), actarg;
+     client *cl;
 {
     char **argv, *type;
     int id, i, idx, status;
@@ -855,9 +829,9 @@ followup_glin(q, sq, v, action, actarg, cl)
 
        id = atoi(argv[i = q->vcnt - 2]);
        if (id > 0)
-         status = id_to_name(id, "USER", &argv[i]);
+         status = id_to_name(id, USERS_TABLE, &argv[i]);
        else
-         status = id_to_name(-id, "STRING", &argv[i]);
+         status = id_to_name(-id, STRINGS_TABLE, &argv[i]);
        if (status && status != MR_NO_MATCH)
          return(status);
 
@@ -865,11 +839,11 @@ followup_glin(q, sq, v, action, actarg, cl)
        type = argv[idx - 1];
 
        if (!strcmp(type, "LIST")) {
-           status = id_to_name(id, "LIST", &argv[idx]);
+           status = id_to_name(id, LIST_TABLE, &argv[idx]);
        } else if (!strcmp(type, "USER")) {
-           status = id_to_name(id, "USER", &argv[idx]);
+           status = id_to_name(id, USERS_TABLE, &argv[idx]);
        } else if (!strcmp(type, "KERBEROS")) {
-           status = id_to_name(id, "STRING", &argv[idx]);
+           status = id_to_name(id, STRINGS_TABLE, &argv[idx]);
        } else if (!strcmp(type, "NONE")) {
            status = 0;
            free(argv[idx]);
@@ -908,13 +882,12 @@ followup_glin(q, sq, v, action, actarg, cl)
  *   argv[3] = ascii(quota)
  */
 
-followup_gqot(q, sq, v, action, actarg, cl)
-    struct query *q;
-    register struct save_queue *sq;
-    struct validate *v;
-    register int (*action)();
-    register int actarg;
-    client *cl;
+int followup_gqot(q, sq, v, action, actarg, cl)
+     struct query *q;
+     struct save_queue *sq;
+     struct validate *v;
+     int (*action)(), actarg;
+     client *cl;
 {
     register int j;
     char **argv;
@@ -933,11 +906,11 @@ followup_gqot(q, sq, v, action, actarg, cl)
        if (idx == 4) {
            switch (argv[1][0]) {
            case 'U':
-               status = id_to_name(atoi(argv[2]), "USER", &argv[2]);
+               status = id_to_name(atoi(argv[2]), USERS_TABLE, &argv[2]);
                break;
            case 'G':
            case 'L':
-               status = id_to_name(atoi(argv[2]), "LIST", &argv[2]);
+               status = id_to_name(atoi(argv[2]), LIST_TABLE, &argv[2]);
                break;
            case 'A':
                free(argv[2]);
@@ -955,10 +928,10 @@ followup_gqot(q, sq, v, action, actarg, cl)
        name = argv[idx];
        if (id == 0) {
            label = argv[0];
-           EXEC SQL REPEATED SELECT name INTO :name FROM filesys
+           EXEC SQL SELECT name INTO :name FROM filesys
              WHERE label = :label;
        } else {
-           EXEC SQL REPEATED SELECT dir INTO :name FROM nfsphys
+           EXEC SQL SELECT dir INTO :name FROM nfsphys
              WHERE nfsphys_id = :id;
        }
        if (sqlca.sqlerrd[2] != 1) {
@@ -967,9 +940,9 @@ followup_gqot(q, sq, v, action, actarg, cl)
 
        id = atoi(argv[idx+3]);
        if (id > 0)
-         status = id_to_name(id, "USER", &argv[idx+3]);
+         status = id_to_name(id, USERS_TABLE, &argv[idx+3]);
        else
-         status = id_to_name(-id, "STRING", &argv[idx+3]);
+         status = id_to_name(-id, STRINGS_TABLE, &argv[idx+3]);
        if (status && status != MR_NO_MATCH)
          return(status);
        (*action)(q->vcnt, argv, actarg);
@@ -989,24 +962,25 @@ followup_gqot(q, sq, v, action, actarg, cl)
  *   argv[3 or 2] = ascii(quota)
  */
 
-followup_aqot(q, argv, cl)
-    struct query  *q;
-    char **argv;
-    client *cl;
+int followup_aqot(q, argv, cl)
+     struct query *q;
+     char *argv[];
+     client *cl;
 {
     EXEC SQL BEGIN DECLARE SECTION;
-    int quota, id, fs, who, physid;
-    char *entity, *qtype, *table_name;
+    int quota, id, fs, who, physid, table;
+    char *entity, *qtype, *tname;
     EXEC SQL END DECLARE SECTION;
     char incr_qual[60];
     char *incr_argv[2];
     int status;
 
-    table_name=q->rtable;
+    table=q->rtable;
+    tname=table_name[table];
     fs = *(int *)argv[0];
-    EXEC SQL REPEATED SELECT phys_id INTO :physid FROM filesys
+    EXEC SQL SELECT phys_id INTO :physid FROM filesys
       WHERE filsys_id = :fs;
-    if(ingres_errno)
+    if(dbms_errno)
        return(mr_errcode);
 
     if (!strcmp(q->shortname, "aqot") || !strcmp(q->shortname, "uqot")) {
@@ -1033,37 +1007,37 @@ followup_aqot(q, argv, cl)
        incremental_clear_before();
        EXEC SQL INSERT INTO quota 
            (filsys_id, type, entity_id, quota, phys_id) 
-         VALUES (:fs, :qtype, :id, :quota, :physid);
-       incremental_after(table_name, incr_qual, incr_argv);    
+         VALUES (:fs, NVL(:qtype,CHR(0)), :id, :quota, :physid);
+       incremental_after(table, incr_qual, incr_argv);    
     } else {
-       incremental_before(table_name, incr_qual, incr_argv);
+       incremental_before(table, incr_qual, incr_argv);
        EXEC SQL UPDATE quota SET quota = :quota
          WHERE filsys_id = :fs AND type = :qtype AND entity_id = :id;
        status = mr_errcode;
-       incremental_after(table_name, incr_qual, incr_argv);
+       incremental_after(table, incr_qual, incr_argv);
     }
 
-    if (ingres_errno)
+    if (dbms_errno)
        return(mr_errcode);
-    flush_name(argv[0], q->rtable);  
+    flush_name(argv[0], table);  
     if(q->type==APPEND) {
-        EXEC SQL UPDATE tblstats SET appends = appends + 1, modtime = 'now'
-         WHERE table_name = :table_name;
+        EXEC SQL UPDATE tblstats SET appends = appends + 1, modtime = SYSDATE
+         WHERE table_name = :tname;
     } else {
-        EXEC SQL UPDATE tblstats SET updates = updates + 1, modtime = 'now'
-         WHERE table_name = :table_name;
+        EXEC SQL UPDATE tblstats SET updates = updates + 1, modtime = SYSDATE
+         WHERE table_name = :tname;
     }
        
     /* Proceed with original followup */
     who = cl->client_id;
     entity = cl->entity;
 
-    EXEC SQL REPEATED UPDATE quota
-      SET modtime = 'now', modby = :who, modwith = :entity
+    EXEC SQL UPDATE quota
+      SET modtime = SYSDATE, modby = :who, modwith = :entity
       WHERE filsys_id = :fs and type = :qtype and entity_id = :id;
-    EXEC SQL REPEATED UPDATE nfsphys SET allocated = allocated + :quota
+    EXEC SQL UPDATE nfsphys SET allocated = allocated + :quota
       WHERE nfsphys_id = :physid;
-    if (ingres_errno) return(mr_errcode);
+    if (dbms_errno) return(mr_errcode);
     return(MR_SUCCESS);
 }
 
@@ -1071,19 +1045,20 @@ followup_aqot(q, argv, cl)
 /* Necessitated by the requirement of a correlation name by the incremental
  * routines, since query table deletes don't provide one. 
  */
-followup_dqot(q,argv,cl)
-    struct query *q;
-    char **argv;
-    struct client *cl;
+int followup_dqot(q, argv, cl)
+     struct query *q;
+     char **argv;
+     client *cl;
 {
     char *qtype;
-    int id, fs;
+    int id, fs, table;
     char *incr_argv[2];
     EXEC SQL BEGIN DECLARE SECTION; 
-    char incr_qual[80];
-    char *tblname;
+    char incr_qual[80], *tname;
     EXEC SQL END DECLARE SECTION; 
 
+    table=q->rtable;
+    tname=table_name[table];
     fs = *(int *)argv[0];
     if (!strcmp(q->shortname, "dqot")) {
        qtype = argv[1];
@@ -1098,28 +1073,27 @@ followup_dqot(q,argv,cl)
     /* quota case of incremental_{before|after} only looks at slot 1 */
     incr_argv[1]=qtype;
 
-    incremental_before(q->rtable, incr_qual, incr_argv);
-    EXEC SQL DELETE FROM quota q WHERE :incr_qual;
+    incremental_before(table, incr_qual, incr_argv);
+    EXEC SQL DELETE FROM quota q WHERE q.filsys_id=:fs AND q.type=:qtype
+      AND q.entity_id=:id;
     incremental_clear_after();
 
-    if (ingres_errno) 
+    if (dbms_errno) 
        return(mr_errcode);
-    flush_name(argv[0], q->rtable);
+    flush_name(argv[0], table);
 
-    tblname = q->rtable;
-    EXEC SQL UPDATE tblstats SET deletes = deletes + 1, modtime = 'now'
-      WHERE table_name = :tblname;
+    EXEC SQL UPDATE tblstats SET deletes = deletes + 1, modtime = SYSDATE
+      WHERE table_name = :tname;
     return(MR_SUCCESS);
 }
 
 
-followup_gpce(q, sq, v, action, actarg, cl)
-    struct query *q;
-    register struct save_queue *sq;
-    struct validate *v;
-    register int (*action)();
-    register int actarg;
-    client *cl;
+int followup_gpce(q, sq, v, action, actarg, cl)
+     struct query *q;
+     struct save_queue *sq;
+     struct validate *v;
+     int (*action)(), actarg;
+     client *cl;
 {
     register int i, j;
     char **argv;
@@ -1128,13 +1102,13 @@ followup_gpce(q, sq, v, action, actarg, cl)
     i = q->vcnt - 2;
     while (sq_get_data(sq, &argv)) {
        id = atoi(argv[PCAP_QSERVER]);
-       status = id_to_name(id, "MACHINE", &argv[PCAP_QSERVER]);
+       status = id_to_name(id, MACHINE_TABLE, &argv[PCAP_QSERVER]);
        if (status) return (status);
        id = atoi(argv[i]);
        if (id > 0)
-         status = id_to_name(id, "USER", &argv[i]);
+         status = id_to_name(id, USERS_TABLE, &argv[i]);
        else
-         status = id_to_name(-id, "STRING", &argv[i]);
+         status = id_to_name(-id, STRINGS_TABLE, &argv[i]);
        if (status && status != MR_NO_MATCH)
          return(status);
        (*action)(q->vcnt, argv, actarg);
@@ -1150,13 +1124,12 @@ followup_gpce(q, sq, v, action, actarg, cl)
 /* followup_gzcl:
  */
 
-followup_gzcl(q, sq, v, action, actarg, cl)
-    register struct query *q;
-    register struct save_queue *sq;
-    register struct validate *v;
-    register int (*action)();
-    int actarg;
-    client *cl;
+int followup_gzcl(q, sq, v, action, actarg, cl)
+     struct query *q;
+     struct save_queue *sq;
+     struct validate *v;
+     int (*action)(), actarg;
+     client *cl;
 {
     int id, i, status;
     char **argv;
@@ -1166,20 +1139,20 @@ followup_gzcl(q, sq, v, action, actarg, cl)
 
        id = atoi(argv[i = q->vcnt - 2]);
        if (id > 0)
-         status = id_to_name(id, "USER", &argv[i]);
+         status = id_to_name(id, USERS_TABLE, &argv[i]);
        else
-         status = id_to_name(-id, "STRING", &argv[i]);
+         status = id_to_name(-id, STRINGS_TABLE, &argv[i]);
        if (status && status != MR_NO_MATCH)
          return(status);
 
        for (i = 1; i < 8; i+=2) {
            id = atoi(argv[i+1]);
            if (!strcmp(argv[i], "LIST")) {
-               status = id_to_name(id, "LIST", &argv[i+1]);
+               status = id_to_name(id, LIST_TABLE, &argv[i+1]);
            } else if (!strcmp(argv[i], "USER")) {
-               status = id_to_name(id, "USER", &argv[i+1]);
+               status = id_to_name(id, USERS_TABLE, &argv[i+1]);
            } else if (!strcmp(argv[i], "KERBEROS")) {
-               status = id_to_name(id, "STRING", &argv[i+1]);
+               status = id_to_name(id, STRINGS_TABLE, &argv[i+1]);
            } else if (!strcmp(argv[i], "NONE")) {
                status = 0;
                free(argv[i+1]);
@@ -1209,13 +1182,12 @@ followup_gzcl(q, sq, v, action, actarg, cl)
 /* followup_gsha:
  */
 
-followup_gsha(q, sq, v, action, actarg, cl)
-    register struct query *q;
-    register struct save_queue *sq;
-    register struct validate *v;
-    register int (*action)();
-    int actarg;
-    client *cl;
+int followup_gsha(q, sq, v, action, actarg, cl)
+     struct query *q;
+     struct save_queue *sq;
+     struct validate *v;
+     int (*action)(), actarg;
+     client *cl;
 {
     char **argv;
     int i, id, status;
@@ -1225,19 +1197,19 @@ followup_gsha(q, sq, v, action, actarg, cl)
 
        id = atoi(argv[4]);
        if (id > 0)
-         status = id_to_name(id, "USER", &argv[4]);
+         status = id_to_name(id, USERS_TABLE, &argv[4]);
        else
-         status = id_to_name(-id, "STRING", &argv[4]);
+         status = id_to_name(-id, STRINGS_TABLE, &argv[4]);
        if (status && status != MR_NO_MATCH)
          return(status);
 
        id = atoi(argv[2]);
        if (!strcmp(argv[1], "LIST")) {
-           status = id_to_name(id, "LIST", &argv[2]);
+           status = id_to_name(id, LIST_TABLE, &argv[2]);
        } else if (!strcmp(argv[1], "USER")) {
-           status = id_to_name(id, "USER", &argv[2]);
+           status = id_to_name(id, USERS_TABLE, &argv[2]);
        } else if (!strcmp(argv[1], "KERBEROS")) {
-           status = id_to_name(id, "STRING", &argv[2]);
+           status = id_to_name(id, STRINGS_TABLE, &argv[2]);
        } else if (!strcmp(argv[1], "NONE")) {
            status = 0;
            free(argv[2]);
@@ -1264,28 +1236,27 @@ followup_gsha(q, sq, v, action, actarg, cl)
 
 
 int _sdl_followup(q, argv, cl)
-    struct query *q;
-    char **argv;
-    client *cl;
+     struct query *q;
+     char *argv[];
+     client *cl;
 {
     int i;
     i = atoi(argv[0]);
     log_flags = i;
+#ifsql INGRES
     if (i & LOG_SQL) {
        EXEC SQL set printqry;
     } else {
        EXEC SQL set noprintqry;
     }
+#endsql
     return(MR_SUCCESS);
 }
 
 
-static hex_dump(p)
-unsigned  char *p;
+static void hex_dump(p)
+     unsigned char *p;
 {
-    char buf[BUFSIZ];
-    int i;
-
     fprintf(stderr, "Size: %d\n", strlen(p));
     while (strlen(p) >= 8) {
        fprintf(stderr, "%02x %02x %02x %02x %02x %02x %02x %02x\n",
@@ -1325,4 +1296,3 @@ unsigned  char *p;
        return;
     }
 }
-
index 154e4007da3376536334514912e91bc7d3edbda4..21c415147ebc6ce51fc89d9ff39628fcd8354eae 100644 (file)
@@ -15,13 +15,13 @@ static char *rcsid_qrtn_dc = "$Header$";
 
 #include <mit-copyright.h>
 #include <string.h>
-#include "query.h"
 #include "mr_server.h"
+#include "query.h"
 EXEC SQL INCLUDE sqlca;  /* SQL Communications Area */
 EXEC SQL INCLUDE sqlda;  /* SQL Descriptor Area */
 #include "qrtn.h"
 
-MR_SQLDA_T *SQLDA;
+SQLDA *mr_sqlda;
 EXEC SQL BEGIN DECLARE SECTION; 
 int mr_sig_length;
 int idummy;                            
@@ -30,8 +30,10 @@ char stmt_buf[MR_STMTBUF_LEN];
 EXEC SQL END DECLARE SECTION; 
 
 char *Argv[QMAXARGS];
+extern char *table_name[];
+extern char *sqlbuffer[QMAXARGS];
 
-int ingres_errno = 0;
+int dbms_errno = 0;
 int mr_errcode = 0;
 EXEC SQL BEGIN DECLARE SECTION; 
 int query_timeout = 30;
@@ -40,77 +42,52 @@ EXEC SQL END DECLARE SECTION;
 extern char *whoami;
 extern FILE *journal;
 
-#define INGRES_BAD_DATE1  40206
-#define INGRES_BAD_DATE2  40207
-#define INGRES_DEADLOCK   49900
-#define INGRES_TIMEOUT    39100
-#define INGRES_BAD_COLUMN 30110
-#define INGRES_ASGN_ERR   40204
-#define INGRES_NO_CURSOR  30120
-#define INGRES_NO_STMT    30130
+int mr_verify_query(client *cl, struct query *q, int argc, char *argv_ro[]);
+int do_retrieve(struct query *q, char *pqual, char *psort,
+               int (*action)(), char *actarg);
+int do_update(struct query *q, char *argv[], char *qual,
+             int (*action)(), char *actarg);
+int do_append(struct query *q, char *argv[], char *pqual,
+             int (*action)(), char *actarg);
+int do_delete(struct query *q, char *qual,
+             int (*action)(), char *actarg);
+void build_sql_stmt(char *result_buf, char *cmd, char *targetlist,
+                   char *argv[], char *qual);
+char *build_sort(struct validate *v, char *sort);
+
+/* from qvalidate.dc */
+int validate_fields(struct query *q, char *argv[], struct valobj *vo, int n);
+int validate_row(struct query *q, char *argv[], struct validate *v);
+
 
 /*
- * ingerr: Called when Ingres indicates an error.
+ * dbmserr: Called when the DBMS indicates an error.
  */
 
-void ingerr()
+void dbmserr(void)
 {
     EXEC SQL BEGIN DECLARE SECTION; 
     char err_msg[256];
     EXEC SQL END DECLARE SECTION;
-    ingres_errno = -sqlca.sqlcode;
-
-    switch (ingres_errno) {
-      case INGRES_BAD_DATE1:
-      case INGRES_BAD_DATE2:
-       mr_errcode = MR_DATE;
-       break;
-      case INGRES_DEADLOCK:
-       mr_errcode = MR_DEADLOCK;
-       com_err(whoami, 0, "INGRES deadlock detected");
-       break;
-      case INGRES_TIMEOUT:
-/* May be something other than timeout! #39100 is "Unknown error" 
- * Really should parse the error message enough to decide if it's a timeout */
-       mr_errcode = MR_BUSY;
-       com_err(whoami, 0, "timed out getting lock");
-       break;
-/* These should never come up unless someone breaks the query table */
-      case INGRES_NO_CURSOR:
-       if (mr_errcode != MR_BUSY &&
-           mr_errcode != MR_DEADLOCK)
-         mr_errcode = MR_INTERNAL;
-       com_err(whoami, 0, "Cursor not opened");
-       break;
-      case INGRES_NO_STMT:
-       mr_errcode = MR_INTERNAL;
-       com_err(whoami, 0, "Statement not declared");
-       break;
-      case INGRES_BAD_COLUMN:
-       mr_errcode = MR_INTERNAL;
-       com_err(whoami, 0, "Bad column name in query table");
-        break;
-      case INGRES_ASGN_ERR:
-       mr_errcode = MR_INTERNAL;
-       com_err(whoami, 0, "Error in SQL assignment statement");
-       break;
-/* Others ??? */
-      default:
-       mr_errcode = MR_INGRES_ERR;
-       com_err(whoami, MR_INGRES_ERR, " code %d\n", ingres_errno);
-       EXEC SQL INQUIRE_SQL(:err_msg = errortext);
-       com_err(whoami, 0, "SQL error text = %s", err_msg);
-       critical_alert("MOIRA", "Moira server encountered INGRES ERROR %d", ingres_errno);
-    }
+    int bufsize=256, msglength=0;
+
+    dbms_errno = -sqlca.sqlcode;
+    mr_errcode = MR_DBMS_ERR;
+    com_err(whoami, MR_DBMS_ERR, " code %d\n", dbms_errno);
+    sqlglm(err_msg, &bufsize, &msglength);
+    err_msg[msglength]=0;
+    com_err(whoami, 0, "SQL error text = %s", err_msg);
+    critical_alert("MOIRA", "Moira server encountered DBMS ERROR %d\n%s",
+                      dbms_errno, err_msg);
 }
 
 /* This is declarative, not executed.  Applies from here on, in this file. */
-EXEC SQL WHENEVER SQLERROR CALL ingerr;
+EXEC SQL WHENEVER SQLERROR DO dbmserr();
 
-int mr_open_database()
+int mr_open_database(void)
 {
     register int i;
-    MR_SQLDA_T *mr_alloc_SQLDA();
+    SQLDA *mr_alloc_sqlda();
     static first_open = 1;
 
     if (first_open) {
@@ -120,57 +97,43 @@ int mr_open_database()
        for (i = 0; i < 16; i++)
          Argv[i] = malloc(ARGLEN);
 
-       SQLDA = mr_alloc_SQLDA();       
+       mr_sqlda = mr_alloc_sqlda();       
 
        incremental_init();
        flush_cache();
     }
        
-    ingres_errno = 0;
+    dbms_errno = 0;
     mr_errcode = 0;
 
     /* open the database */
-#ifsql INGRES
-    EXEC SQL CONNECT :database;
-    if(ingres_errno) 
-      return (ingres_errno);
-    EXEC SQL set lockmode session where level = table, timeout = :query_timeout;
-    EXEC SQL set lockmode on capacls where readlock = shared;
-    EXEC SQL set lockmode on alias where readlock = shared;
-#endsql
-#ifsql INFORMIX
-    EXEC SQL DATABASE moira
-#endsql
-
-    if(ingres_errno) 
+    EXEC SQL CONNECT :database IDENTIFIED BY :database;
+
+    if(dbms_errno) 
         return(mr_errcode);
 
-    EXEC SQL SELECT SIZE(signature) INTO :mr_sig_length FROM users WHERE users_id=0; /* Harmless on second open */
+    EXEC SQL SELECT data_length INTO :mr_sig_length FROM user_tab_columns WHERE table_name='USERS' and column_name='SIGNATURE';
     EXEC SQL COMMIT WORK;
-    if(ingres_errno)
+    if(dbms_errno)
         return(mr_errcode);
 
     return(MR_SUCCESS);
 }
 
-int mr_close_database()
+void mr_close_database(void)
 {
     flush_cache();
-#ifsql INGRES
-    EXEC SQL DISCONNECT;
-#endsql
+    EXEC SQL COMMIT RELEASE;
 }
 
-mr_check_access(cl, name, argc, argv_ro)
-    client *cl;
-    char *name;
-    int argc;
-    char *argv_ro[];
+int mr_check_access(cl, name, argc, argv_ro)
+     client *cl;
+     char *name, *argv_ro[];
+     int argc;
 {
     struct query *q;
-    struct query *get_query_by_name();
 
-    ingres_errno = 0;
+    dbms_errno = 0;
     mr_errcode = 0;
 
     q = get_query_by_name(name, cl->args->mr_version_no);
@@ -180,13 +143,10 @@ mr_check_access(cl, name, argc, argv_ro)
     return(mr_verify_query(cl, q, argc, argv_ro));    
 }
 
-mr_process_query(cl, name, argc, argv_ro, action, actarg)
-    client *cl;
-    char *name;
-    int argc;
-    char *argv_ro[];
-    int (*action)();
-    char *actarg;
+int mr_process_query(cl, name, argc, argv_ro, action, actarg)
+     client *cl;
+     char *name, *argv_ro[], *actarg;
+     int argc, (*action)();
 {
     register struct query *q;
     register int status;
@@ -196,15 +156,11 @@ mr_process_query(cl, name, argc, argv_ro, action, actarg)
     char *pqual;
     char *psort;
     EXEC SQL BEGIN DECLARE SECTION; 
-    char *table_name;
+    char *table;
     EXEC SQL END DECLARE SECTION; 
     struct save_queue *sq;
-    struct query *get_query_by_name();
-    int sq_save_args();
-    struct save_queue *sq_create();
-    char *build_sort();
 
-    ingres_errno = 0;
+    dbms_errno = 0;
     mr_errcode = 0;
 
     /* list queries command */
@@ -302,11 +258,11 @@ mr_process_query(cl, name, argc, argv_ro, action, actarg)
            incremental_after(q->rtable, qual, argv_ro);
            if (status != MR_SUCCESS) break;
            flush_name(argv_ro[0], q->rtable);
-           table_name = q->rtable;
+           table = table_name[q->rtable];
            if (strcmp(q->shortname, "sshi") && strcmp(q->shortname, "ssif")) {
                EXEC SQL UPDATE tblstats
-                  SET updates = updates + 1, modtime = 'now'
-                 WHERE table_name = :table_name;
+                  SET updates = updates + 1, modtime = SYSDATE
+                 WHERE table_name = :table;
            }
        }
 
@@ -343,10 +299,10 @@ mr_process_query(cl, name, argc, argv_ro, action, actarg)
            } else
              incremental_after(q->rtable, pqual, argv_ro);
 
-           table_name = q->rtable;
+           table = table_name[q->rtable];
            EXEC SQL UPDATE tblstats
-             SET appends = appends + 1, modtime = 'now'
-             WHERE table_name = :table_name;
+             SET appends = appends + 1, modtime = SYSDATE
+             WHERE table_name = :table;
        }
        
        /* execute followup routine */
@@ -364,15 +320,15 @@ mr_process_query(cl, name, argc, argv_ro, action, actarg)
        /* if q->rvar = NULL, perform post_rtn only */
        if (q->rvar) {
            build_qual(q->qual, q->argc, Argv, qual);
-           table_name = q->rtable;
+           table = table_name[q->rtable];
            incremental_before(q->rtable, qual, argv_ro);
            status = do_delete(q, qual, action, actarg);
            incremental_clear_after();
            if (status != MR_SUCCESS) break;
            flush_name(argv_ro[0], q->rtable);
            EXEC SQL UPDATE tblstats
-             SET deletes = deletes + 1, modtime = 'now'
-             WHERE table_name = :table_name;
+             SET deletes = deletes + 1, modtime = SYSDATE
+             WHERE table_name = :table;
        }
 
        /* execute followup routine */
@@ -382,9 +338,9 @@ mr_process_query(cl, name, argc, argv_ro, action, actarg)
     }
 
 out:
-    if (status == MR_SUCCESS && ingres_errno != 0) {
-       com_err(whoami, MR_INTERNAL, "Server didn't notice INGRES ERROR %d",
-                      ingres_errno);
+    if (status == MR_SUCCESS && dbms_errno != 0) {
+       com_err(whoami, MR_INTERNAL, "Server didn't notice DBMS ERROR %d",
+                      dbms_errno);
        status = mr_errcode;
     }
 
@@ -394,7 +350,7 @@ out:
         if (status == MR_SUCCESS) {
         EXEC SQL COMMIT WORK;
            if (journal) {
-               char buf[1024], *bp;
+               char buf[1024];
                int i;
                extern time_t now;
 
@@ -414,9 +370,7 @@ out:
            incremental_update();
        } else {
            cache_abort();
-           if (ingres_errno != INGRES_DEADLOCK) {
-                EXEC SQL ROLLBACK WORK;
-           }
+            EXEC SQL ROLLBACK WORK;
            incremental_flush();
        }
     }
@@ -427,71 +381,48 @@ out:
     return(status);
 }
 
-build_qual(fmt, argc, argv, qual)
-       char *fmt;
-       int argc;
-       char *argv[];
-       char *qual;
+int build_qual(fmt_buf, argc, argv, qual)
+     char *fmt_buf, *argv[], *qual;
+     int argc;
 {
-    register char *c;
-    register int i;
-    char *args[4];
-
-    c = fmt;
-    for (i = 0; i < argc; i++) {
-       c = index(c, '%');
-       if (c++ == (char *)0) return(MR_ARGS);
-       if (*c == 's')
-           args[i] = argv[i];
-       else if (*c == 'd')
-           *(int *)&args[i] = *(int *)argv[i]; /* sigh */
-       else
-           return(MR_INGRES_ERR);
-    }
-    if (c = index(c, '%')) {
-       args[i] = args[i - 1];
-    }
-
-    switch (argc) {
-    case 0:
-       strcpy(qual, fmt);
-       break;
+    char *res, *fmt;
 
-    case 1:
-       sprintf(qual, fmt, args[0]);
-       break;
-
-    case 2:
-       sprintf(qual, fmt, args[0], args[1]);
-       break;
-
-    case 3:
-       sprintf(qual, fmt, args[0], args[1], args[2]);
-       break;
-
-    case 4:
-       sprintf(qual, fmt, args[0], args[1], args[2], args[3]);
-       break;
-
-    default:
-       com_err(whoami, MR_INTERNAL,
-               "Internal arg count error processing query");
-       return(MR_INTERNAL);
+    for(res=qual, fmt=fmt_buf; *fmt; fmt++) {
+       if(*fmt=='%') {
+           if(*++fmt) {
+               switch(*fmt) {                       
+                 case '%':                              /* %% -> % */
+                   *res++ = *fmt;           
+                   break;
+                 case 's':
+                   if(*argv[0]) {
+                       char *p=*argv;
+                       while(*p) {
+                           if(*p=='\'') *res++='\'';   /* double the ' */
+                           *res++=*p++;
+                       }
+                   }
+                   argv++;
+                   break;
+                 case 'd':
+                   res+=sprintf(res,"%d",*(int *)*argv++);
+                   break;
+                 default:                               /* Swallow other %? pairs */
+                   break;
+               }
+           } else break;
+       } else *res++ = *fmt;                            /* text -> result buffer */
     }
-    return(MR_SUCCESS);
+    *res='\0';
 }
 
-char *
-build_sort(v, sort)
-    register struct validate *v;
-    char *sort;
+char *build_sort(v, sort)
+     struct validate *v;
+     char *sort;
 {
     register struct valobj *vo;
     register int n;
     char elem[16];
-#ifdef _DEBUG_MALLOC_INC
-#undef index
-#endif
 
     n = v->objcnt;
     vo = v->valobj;
@@ -514,11 +445,11 @@ build_sort(v, sort)
 
 int privileged;
 
-mr_verify_query(cl, q, argc, argv_ro)
-    client *cl;
-    struct query *q;
-    int argc;
-    char *argv_ro[];
+int mr_verify_query(cl, q, argc, argv_ro)
+     client *cl;
+     struct query *q;
+     int argc;
+     char *argv_ro[];
 {
     register int argreq;
     register int status;
@@ -532,12 +463,9 @@ mr_verify_query(cl, q, argc, argv_ro)
     if (argc >= QMAXARGS)
       return(MR_ARGS);
     for (i = 0; i < argc; i++) {
-       /* Single quotes must be doubled for SQL */
-       for (to=Argv[i], fr=argv_ro[i], stop=to+ARGLEN; (*fr) && (to<stop);) {
-           if(*fr=='\'') 
-             *to++ = *fr;
-           *to++ = *fr++;
-       }
+       for (to=Argv[i], fr=argv_ro[i], stop=to+ARGLEN; (*fr) && (to<stop);)
+         *to++ = *fr++;
+
        if (*fr) 
          return(MR_ARG_TOO_LONG);
        *to='\0';
@@ -581,19 +509,16 @@ mr_verify_query(cl, q, argc, argv_ro)
  * in the query structure, and whether that acl contains everybody.
  */
 
-check_query_access(q, argv, cl)
-    struct query *q;
-    char *argv[];
-    client *cl;
+int check_query_access(q, argv, cl)
+     struct query *q;
+     char *argv[];
+     client *cl;
 {
     EXEC SQL BEGIN DECLARE SECTION; 
     char *name;
     int acl_id;
-    int rowcount;
-    int errorno;
     static int def_uid;
     EXEC SQL END DECLARE SECTION; 
-    int status;
     int client_id;
     char *client_type;
 
@@ -608,8 +533,8 @@ check_query_access(q, argv, cl)
     else {
        name = q->shortname;
        EXEC SQL SELECT list_id INTO :acl_id FROM capacls WHERE tag = :name;
-        if (sqlca.sqlcode < 0) return(MR_INGRES_ERR);
-        if (sqlca.sqlcode == 100) return(MR_PERM);
+        if (sqlca.sqlcode < 0) return(MR_DBMS_ERR);
+        if (sqlca.sqlcode == SQL_NO_MATCH) return(MR_PERM);
        q->acl = acl_id;
 
        /* check for default access */
@@ -627,17 +552,17 @@ check_query_access(q, argv, cl)
 
     if (get_client(cl, &client_type, &client_id) != MR_SUCCESS)
       return(MR_PERM);
-    if (find_member("LIST", acl_id, client_type, client_id, 0))
+    if (find_member("LIST", acl_id, client_type, client_id))
       return(MR_SUCCESS);
     else
       return(MR_PERM);
 }
 
 
-get_client(cl, client_type, client_id)
-    client *cl;
-    char **client_type;
-    int *client_id;
+int get_client(cl, client_type, client_id)
+     client *cl;
+     char **client_type;
+     int *client_id;
 {
     if (cl->users_id > 0) {
        *client_id = cl->users_id;
@@ -654,16 +579,12 @@ get_client(cl, client_type, client_id)
     return(MR_PERM);
 }
 
-find_member(list_type, list_id, member_type, member_id)
-    char *list_type;
-    EXEC SQL BEGIN DECLARE SECTION; 
-    int list_id;
-    char *member_type;
-    int member_id;
-    EXEC SQL END DECLARE SECTION;
+int find_member(list_type, list_id, member_type, member_id)
+     char *list_type, *member_type;
+     int list_id, member_id;
 {
     EXEC SQL BEGIN DECLARE SECTION; 
-    int flag, errorno;
+    int flag;
     EXEC SQL END DECLARE SECTION; 
 
     if (!strcmp(strtrim(list_type), strtrim(member_type)) &&
@@ -682,53 +603,22 @@ find_member(list_type, list_id, member_type, member_id)
 }
 
 
-do_retrieve(q, pqual, psort, action, actarg)            
-    register struct query *q;
-EXEC SQL BEGIN DECLARE SECTION; 
-    char *pqual;
-    char *psort;
-EXEC SQL END DECLARE SECTION; 
-    int (*action)();
-    char *actarg;
+int do_retrieve(q, pqual, psort, action, actarg)
+     struct query *q;
+     char *pqual, *psort, *actarg;
+     int (*action)();
 {
-    static char **vaddrs = (char **)NULL;
-    int j, rowcount;
-
-    if (!vaddrs) {
-       register int i;
-
-       if ((vaddrs = (char **)malloc(sizeof(char *) * QMAXARGS)) == NULL) {
-           com_err(whoami, MR_NO_MEM, "setting up static argv");
-           exit(1);
-       }
-       for (i = 0; i < QMAXARGS; i++) {  
-           vaddrs[i]=SQLDA->sqlvar[i].sqldata;
-       }
+    build_sql_stmt(stmt_buf,"SELECT",q->tlist,NULL,pqual);
+    if(psort) {
+      strcat(stmt_buf," ORDER BY ");
+      strcat(stmt_buf,psort);
     }
 
-    build_sql_stmt(stmt_buf,"SELECT",q->tlist,vaddrs,pqual);
-    if(psort) { strcat(stmt_buf," ORDER BY "); strcat(stmt_buf,psort); }
-    EXEC SQL PREPARE stmt INTO :SQLDA USING NAMES FROM :stmt_buf; 
-    if(sqlca.sqlcode)
-      return(MR_INTERNAL);
-    EXEC SQL DECLARE csr001 CURSOR FOR stmt;
-    EXEC SQL OPEN csr001;
-    rowcount = 0;
-    while(1) {
-       EXEC SQL FETCH csr001 USING DESCRIPTOR :SQLDA;
-       if(sqlca.sqlcode != 0) break;
-       (*action)(q->vcnt, vaddrs, actarg);
-       rowcount++;
-    }
-    EXEC SQL CLOSE csr001;
-
-    if (mr_errcode) return(mr_errcode);
-    return ((rowcount == 0) ? MR_NO_MATCH : MR_SUCCESS);
+    return do_for_all_rows(stmt_buf, q->vcnt, action, actarg);
 }
 
-char *sqlstrstr(str,pat)
-    char *str;
-    char *pat;
+char *sqlstrstr(str, pat)
+     char *str, *pat;
 {
     register char *p=pat;
     
@@ -752,7 +642,7 @@ char *sqlstrstr(str,pat)
 }
 
 void optimize_sql_stmt(buf)
-char *buf;
+     char *buf;
 {
     char *point=buf, *pat, *eopat, *esc1, *esc2, *csr;
 
@@ -811,12 +701,8 @@ char *buf;
     }
 }
 
-build_sql_stmt(result_buf,cmd,targetlist,argv,qual)
-    char *result_buf;
-    char *cmd;
-    char *targetlist;
-    char *argv[];
-    char *qual;
+void build_sql_stmt(result_buf, cmd, targetlist, argv, qual)
+     char *result_buf, *cmd, *targetlist, *argv[], *qual;
 {
     char fmt_buf[MR_STMTBUF_LEN];
     register char *res, *fmt;
@@ -835,15 +721,16 @@ build_sql_stmt(result_buf,cmd,targetlist,argv,qual)
                    break;
                  case 's':
                    if(*argv[0]) {
-                       *res='\0';
-                       strcat(res,*argv);
-                       while(*++res) ;
+                       char *p=*argv;
+                       while(*p) {
+                           if(*p=='\'') *res++='\'';   /* double the ' */
+                           *res++=*p++;
+                       }
                    }
                    argv++;
                    break;
                  case 'd':
-                   sprintf(res,"%d",*(int *)*argv++);   /* print to result buffer */
-                   while(*++res) ;
+                   res+=sprintf(res,"%d",*(int *)*argv++);
                    break;
                  default:                               /* Swallow other %? pairs */
                    break;
@@ -856,12 +743,10 @@ build_sql_stmt(result_buf,cmd,targetlist,argv,qual)
     optimize_sql_stmt(result_buf);
 }
 
-do_update(q, argv, qual, action, actarg)
-    register struct query *q;
-    char *argv[];
-    char *qual;
-    int (*action)();
-    char *actarg;
+int do_update(q, argv, qual, action, actarg)
+     struct query *q;
+     char *argv[], *qual, *actarg;
+     int (*action)();
 {
     build_sql_stmt(stmt_buf,"UPDATE",q->tlist,argv,qual);
     EXEC SQL EXECUTE IMMEDIATE :stmt_buf;
@@ -869,12 +754,10 @@ do_update(q, argv, qual, action, actarg)
     return(MR_SUCCESS);
 }
 
-do_append(q, argv, pqual, action, actarg)
-    register struct query *q;
-    char *argv[];
-    char *pqual;
-    int (*action)();
-    char *actarg;
+int do_append(q, argv, pqual, action, actarg)
+     struct query *q;
+     char *argv[], *pqual, *actarg;
+     int (*action)();
 {
     build_sql_stmt(stmt_buf,"INSERT",q->tlist,argv,pqual);
     EXEC SQL EXECUTE IMMEDIATE :stmt_buf;
@@ -882,13 +765,12 @@ do_append(q, argv, pqual, action, actarg)
     return(MR_SUCCESS);
 }
 
-do_delete(q, qual, action, actarg)
-    register struct query *q;
-    char *qual;
-    int (*action)();
-    char *actarg;
+int do_delete(q, qual, action, actarg)
+     struct query *q;
+     char *qual, *actarg;
+     int (*action)();
 {
-    sprintf(stmt_buf,"DELETE FROM %s WHERE %s",q->rtable,qual);
+    sprintf(stmt_buf,"DELETE FROM %s WHERE %s",table_name[q->rtable],qual);
     EXEC SQL EXECUTE IMMEDIATE :stmt_buf;
     if (mr_errcode) return(mr_errcode);
     return(MR_SUCCESS);
@@ -907,12 +789,12 @@ do_delete(q, qual, action, actarg)
  **
  **/
 
-set_next_object_id(object, table_name, limit)
-    EXEC SQL BEGIN DECLARE SECTION; 
-    char *object;
-    char *table_name;
-    int limit;
-    EXEC SQL END DECLARE SECTION; 
+int set_next_object_id(object, table, limit)
+EXEC SQL BEGIN DECLARE SECTION;
+     char *object;
+EXEC SQL END DECLARE SECTION;
+     enum tables table;
+     int limit;
 {
     EXEC SQL BEGIN DECLARE SECTION; 
     int value;
@@ -928,24 +810,18 @@ set_next_object_id(object, table_name, limit)
        if (limit && value > MAX_ID_VALUE) 
            value = MIN_ID_VALUE;
 
-       sprintf(stmt_buf,"SELECT %s FROM %s WHERE %s=%d",object,table_name,object,value);  
-       EXEC SQL PREPARE stmt INTO :SQLDA USING NAMES FROM :stmt_buf; 
-       if(sqlca.sqlcode)
-         return(MR_INTERNAL);
-       EXEC SQL DECLARE csr002 CURSOR FOR stmt;
-       EXEC SQL OPEN csr002;
-       EXEC SQL FETCH csr002 USING DESCRIPTOR :SQLDA;
+       sprintf(stmt_buf,"SELECT %s FROM %s WHERE %s=%d",
+               object,table_name[table],object,value);
+       dosql(sqlbuffer);
        if (sqlca.sqlcode < 0) return(mr_errcode);
-       if (sqlca.sqlcode == 100) break;
+       if (sqlca.sqlcode == SQL_NO_MATCH) break;
 
-       EXEC SQL CLOSE csr002;
        value++;
        if (limit && value == starting_value) {   
            com_err(whoami,0,"All id values have been used");
            return(MR_NO_ID);
        }
     }
-    EXEC SQL CLOSE csr002;
 
     if (LOG_RES)
         com_err(whoami, 0, "setting ID %s to %d", object, value);
@@ -959,11 +835,8 @@ set_next_object_id(object, table_name, limit)
  */
 
 int set_krb_mapping(name, login, ok, kid, uid)
-char *name;
-char *login;
-int ok;
-int *kid;
-int *uid;
+     char *name, *login;
+     int ok, *kid, *uid;
 {
     EXEC SQL BEGIN DECLARE SECTION; 
     int u_id, k_id;
@@ -979,7 +852,7 @@ int *uid;
       WHERE km.string_id = str.string_id AND str.string = :krbname;
     EXEC SQL COMMIT WORK;
 
-    if (ingres_errno) return(mr_errcode);
+    if (dbms_errno) return(mr_errcode);
     
     if (sqlca.sqlerrd[2] == 1) {    /* rowcount */
        *kid = -k_id;
@@ -987,7 +860,7 @@ int *uid;
        return(MR_SUCCESS);
     }
 
-    if (name_to_id(name, "STRINGS", &k_id) == MR_SUCCESS)
+    if (name_to_id(name, STRINGS_TABLE, &k_id) == MR_SUCCESS)
       *kid = -k_id;
 
     if (!ok) {             
@@ -995,12 +868,12 @@ int *uid;
        return(MR_SUCCESS);
     }
 
-    if (name_to_id(login, "USERS", uid) != MR_SUCCESS)
+    if (name_to_id(login, USERS_TABLE, uid) != MR_SUCCESS)
       *uid = 0;
 
     if (*kid == 0)
       *kid = *uid;
-    if (ingres_errno) return(mr_errcode);
+    if (dbms_errno) return(mr_errcode);
     return(MR_SUCCESS);
 }
 
@@ -1009,26 +882,15 @@ int *uid;
  * are no duplicate names.
  */
 
-sanity_check_queries()
+void sanity_check_queries(void)
 {
     register int i;
     int maxv = 0, maxa = 0;
-#ifdef MULTIPROTOCOLS
-    extern int QueryCount1, QueryCount2;
-    extern struct query Queries1[], Queries2[];
-#else
     extern int QueryCount2;
     extern struct query Queries2[];
-#endif MULTIPROTOCOLS
 
 #define MAX(x,y) ((x) > (y) ? (x) : (y))
 
-#ifdef MULTIPROTOCOLS
-    for (i = 0; i < QueryCount1; i++) {
-       maxv = MAX(maxv, Queries1[i].vcnt);
-       maxa = MAX(maxa, Queries1[i].argc);
-    }
-#endif MULTIPROTOCOLS
     for (i = 0; i < QueryCount2; i++) {
        maxv = MAX(maxv, Queries2[i].vcnt);
        maxa = MAX(maxa, Queries2[i].argc);
@@ -1039,4 +901,74 @@ sanity_check_queries()
     }
 }
 
+
+/* Generically do a SELECT, storing the results in the provided buffers */
+
+void dosql(buffers)
+     char *buffers[];
+{
+  int i, errcode=0, errlen;
+
+  EXEC SQL PREPARE inc_stmt FROM :stmt_buf;
+  if(sqlca.sqlcode) return;
+  EXEC SQL DECLARE inc_crs CURSOR FOR inc_stmt;
+  EXEC SQL OPEN inc_crs;
+  mr_sqlda->N = QMAXARGS;
+  EXEC SQL DESCRIBE SELECT LIST FOR inc_stmt INTO mr_sqlda;
+  mr_sqlda->N = mr_sqlda->F;
+  for(i=0; i<mr_sqlda->N; i++) {
+    mr_sqlda->V[i]=buffers[i];
+    mr_sqlda->T[i]=97;
+    mr_sqlda->L[i]=ARGLEN;
+  }
+  EXEC SQL FETCH inc_crs USING DESCRIPTOR mr_sqlda;
+
+  /* if we got an error from the FETCH, we have to preserve it or the
+     close will reset it and the caller will think nothing happened */
+  if(sqlca.sqlcode) {
+    errcode=sqlca.sqlcode;
+    errlen=sqlca.sqlerrm.sqlerrml;
+  }
+
+  EXEC SQL CLOSE inc_crs;
+  if(errcode) {
+    sqlca.sqlcode=errcode;
+    sqlca.sqlerrm.sqlerrml=errlen;
+  }
+}
+
+int do_for_all_rows(query, count, action, actarg)
+EXEC SQL BEGIN DECLARE SECTION;
+     char *query;
+EXEC SQL END DECLARE SECTION;
+     int count, (*action)(), actarg;
+{
+  int i, rowcount=0;
+
+  EXEC SQL PREPARE stmt FROM :query;
+  if(sqlca.sqlcode) return;
+  EXEC SQL DECLARE curs CURSOR FOR stmt;
+  EXEC SQL OPEN curs;
+  mr_sqlda->N = count;
+  EXEC SQL DESCRIBE SELECT LIST FOR stmt INTO mr_sqlda;
+  mr_sqlda->N = mr_sqlda->F;
+  for(i=0; i<mr_sqlda->N; i++) {
+    mr_sqlda->V[i]=sqlbuffer[i];
+    mr_sqlda->T[i]=97;
+    mr_sqlda->L[i]=ARGLEN;
+  }
+
+  while(1) {
+    EXEC SQL FETCH curs USING DESCRIPTOR mr_sqlda;
+    if(sqlca.sqlcode != 0) break;
+    (*action)(count, sqlbuffer, actarg);
+    rowcount++;
+  }
+  EXEC SQL CLOSE curs;
+  
+  if (mr_errcode) return(mr_errcode);
+  return ((rowcount == 0) ? MR_NO_MATCH : MR_SUCCESS);
+}
+
+
 /* eof:qrtn.dc */
index 8b2b4bc7743039d5921aba556a033afbdf1905c5..5f5b0261cc5f09ad3870a708ef82aa97b9684e8c 100644 (file)
@@ -6,13 +6,9 @@
 #define MR_CDUMMY_LEN  256
 #define MR_STMTBUF_LEN 1024
 
-/* Requires having already done EXEC SQL INCLUDE sqlda */
-typedef IISQLDA_TYPE(MR_SQLDA,MR_SQLDA_T,QMAXARGS);
-
-extern MR_SQLDA_T *SQLDA;
 extern int mr_sig_length;
-extern char stmt_buf[];
+extern char stmt_buf[MR_STMTBUF_LEN];
 
-extern void ingerr();
+extern void dbmserr();
 
 /* eof:qtrn.h */
index 3d4e04657705846d86e848222669c33554f83d31..32c828e3a772f44ced7310c71894fc0cfeb1811a 100644 (file)
@@ -14,25 +14,25 @@ static char *rcsid_qsupport_dc = "$Header$";
 #endif lint
 
 #include <mit-copyright.h>
-#include "query.h"
 #include "mr_server.h"
+#include "query.h"
 #include <ctype.h>
-#ifdef GDSS
-#include "gdss.h"
-#endif /* GDSS */
+#include <arpa/inet.h>
 EXEC SQL INCLUDE sqlca;
-EXEC SQL INCLUDE sqlda;
 #include "qrtn.h"
 
 extern char *whoami, *strsave();
-extern int ingres_errno, mr_errcode;
+extern int dbms_errno, mr_errcode;
 
 EXEC SQL BEGIN DECLARE SECTION;
 extern char stmt_buf[];
 EXEC SQL END DECLARE SECTION;
 
-EXEC SQL WHENEVER SQLERROR CALL ingerr;
+EXEC SQL WHENEVER SQLERROR DO dbmserr();
+
 
+int prefetch_value(struct query *q, char **argv, client *cl);
+int check_nfs(int mach_idx, char *name, char *access);
 
 /* Setup Routines */
 
@@ -47,12 +47,12 @@ EXEC SQL WHENEVER SQLERROR CALL ingerr;
  * - if argv[0] == UNIQUE_LOGIN then set argv[0] = "#<uid>"
  */
 
-setup_ausr(q, argv, cl)
-    struct query *q;
-    register char *argv[];
-    client *cl;
+int setup_ausr(q, argv, cl)
+     struct query *q;
+     char *argv[];
+     client *cl;
 {
-    int row;
+    int row, err;
     EXEC SQL BEGIN DECLARE SECTION;
     int nuid;
     EXEC SQL END DECLARE SECTION;
@@ -62,9 +62,9 @@ setup_ausr(q, argv, cl)
     else
       row = 1;
     if (!strcmp(argv[row], UNIQUE_UID) || atoi(argv[row]) == -1) {
-       if (set_next_object_id("uid", "users", 1))
-         return(MR_INGRES_ERR);
-       EXEC SQL SELECT value INTO :nuid FROM numvalues WHERE name = 'uid';
+       if ((err=set_next_object_id("unix_uid", USERS_TABLE, 1)))
+         return(err);
+       EXEC SQL SELECT value INTO :nuid FROM numvalues WHERE name = 'unix_uid';
        if (sqlca.sqlerrd[2] != 1)
          return(MR_INTERNAL);
        sprintf(argv[row], "%d", nuid);
@@ -86,8 +86,8 @@ setup_ausr(q, argv, cl)
  */
 
 int setup_dusr(q, argv)
-    struct query *q;
-    char **argv;
+     struct query *q;
+     char **argv;
 {
     EXEC SQL BEGIN DECLARE SECTION;
     int flag, id, cnt;
@@ -96,34 +96,34 @@ int setup_dusr(q, argv)
     id = *(int *)argv[0];
 
     /* For now, only allow users to be deleted if their status is 0 */
-    EXEC SQL REPEATED SELECT status INTO :flag FROM users
+    EXEC SQL SELECT status INTO :flag FROM users
       WHERE users_id = :id;
     if (flag != 0 && flag != 4)
       return(MR_IN_USE);
 
-    EXEC SQL REPEATED DELETE FROM quota WHERE entity_id = :id AND type='USER';
-    EXEC SQL REPEATED DELETE FROM krbmap WHERE users_id = :id;
-    EXEC SQL REPEATED SELECT COUNT(member_id) INTO :cnt FROM imembers
+    EXEC SQL DELETE FROM quota WHERE entity_id = :id AND type='USER';
+    EXEC SQL DELETE FROM krbmap WHERE users_id = :id;
+    EXEC SQL SELECT COUNT(member_id) INTO :cnt FROM imembers
       WHERE member_id = :id AND member_type = 'USER';
     if (cnt > 0)
        return(MR_IN_USE);
-    EXEC SQL REPEATED SELECT COUNT(label) INTO :cnt FROM filesys 
+    EXEC SQL SELECT COUNT(label) INTO :cnt FROM filesys 
        WHERE owner = :id;
     if (cnt > 0)
        return(MR_IN_USE);
-    EXEC SQL REPEATED SELECT COUNT(name) INTO :cnt FROM list
+    EXEC SQL SELECT COUNT(name) INTO :cnt FROM list
       WHERE acl_id = :id AND acl_type = 'USER';
     if (cnt > 0)
        return(MR_IN_USE);
-    EXEC SQL REPEATED SELECT COUNT(name) INTO :cnt FROM servers
+    EXEC SQL SELECT COUNT(name) INTO :cnt FROM servers
       WHERE acl_id = :id AND acl_type = 'USER';
     if (cnt > 0)
        return(MR_IN_USE);
-    EXEC SQL REPEATED SELECT COUNT(acl_id) INTO :cnt FROM hostaccess
+    EXEC SQL SELECT COUNT(acl_id) INTO :cnt FROM hostaccess
       WHERE acl_id = :id AND acl_type = 'USER';
     if (cnt > 0)
        return(MR_IN_USE);
-    if (ingres_errno)
+    if (dbms_errno)
        return(mr_errcode);
     return(MR_SUCCESS);
 }
@@ -133,20 +133,20 @@ int setup_dusr(q, argv)
  * pop_id field.  Also take care of keeping track of the post office usage.
  */
 int setup_spop(q, argv)
-struct query *q;
-char **argv;
+     struct query *q;
+     char **argv;
 {
     EXEC SQL BEGIN DECLARE SECTION;
-    int id, mid, flag;
+    int id, mid;
     char type[9];
     EXEC SQL END DECLARE SECTION;
 
     id = *(int *)argv[0];
-    EXEC SQL REPEATED SELECT potype, pop_id INTO :type, :mid FROM users
+    EXEC SQL SELECT potype, pop_id INTO :type, :mid FROM users
       WHERE users_id = :id;
     if(sqlca.sqlerrd[2] = 0)
       return(MR_MACHINE);
-    EXEC SQL REPEATED SELECT mach_id INTO :mid FROM machine
+    EXEC SQL SELECT mach_id INTO :mid FROM machine
       WHERE mach_id = :mid;
     if (sqlca.sqlerrd[2] = 0)
       return(MR_MACHINE);
@@ -168,9 +168,9 @@ int setup_dpob(q, argv)
     EXEC SQL END DECLARE SECTION;
 
     user = *(int *)argv[0];
-    EXEC SQL REPEATED SELECT potype, pop_id INTO :type, :id FROM users
+    EXEC SQL SELECT potype, pop_id INTO :type, :id FROM users
       WHERE users_id = :user;
-    if (ingres_errno) return(mr_errcode);
+    if (dbms_errno) return(mr_errcode);
 
     if (!strcmp(strtrim(type), "POP"))
       set_pop_usage(id, -1);
@@ -183,8 +183,8 @@ int setup_dpob(q, argv)
  */
 
 int setup_dmac(q, argv)
-    struct query *q;
-    char **argv;
+     struct query *q;
+     char **argv;
 {
     EXEC SQL BEGIN DECLARE SECTION;
     int flag, id, cnt;
@@ -192,41 +192,41 @@ int setup_dmac(q, argv)
 
     id = *(int *)argv[0];
 
-    EXEC SQL REPEATED SELECT status INTO :flag FROM machine
+    EXEC SQL SELECT status INTO :flag FROM machine
       WHERE mach_id = :id;
     if (flag != 3)
       return(MR_IN_USE);
-    EXEC SQL REPEATED SELECT COUNT(login) INTO :cnt FROM users
+    EXEC SQL SELECT COUNT(login) INTO :cnt FROM users
       WHERE potype='POP' AND pop_id = :id;
     if (cnt > 0)
        return(MR_IN_USE);
-    EXEC SQL REPEATED SELECT COUNT(mach_id) INTO :cnt FROM serverhosts
+    EXEC SQL SELECT COUNT(mach_id) INTO :cnt FROM serverhosts
       WHERE mach_id = :id;
     if (cnt > 0)
        return(MR_IN_USE);
-    EXEC SQL REPEATED SELECT COUNT(mach_id) INTO :cnt FROM nfsphys
+    EXEC SQL SELECT COUNT(mach_id) INTO :cnt FROM nfsphys
       WHERE mach_id = :id;
     if (cnt > 0)
        return(MR_IN_USE);
-    EXEC SQL REPEATED SELECT COUNT(mach_id) INTO :cnt FROM hostaccess
+    EXEC SQL SELECT COUNT(mach_id) INTO :cnt FROM hostaccess
       WHERE mach_id = :id;
     if (cnt > 0)
        return(MR_IN_USE);
-    EXEC SQL REPEATED SELECT COUNT(mach_id) INTO :cnt FROM printcap
+    EXEC SQL SELECT COUNT(mach_id) INTO :cnt FROM printcap
       WHERE mach_id = :id;
     if (cnt > 0)
        return(MR_IN_USE);
-    EXEC SQL REPEATED SELECT COUNT(quotaserver) INTO :cnt FROM printcap
+    EXEC SQL SELECT COUNT(quotaserver) INTO :cnt FROM printcap
       WHERE quotaserver = :id;
     if (cnt > 0)
        return(MR_IN_USE);
-    EXEC SQL REPEATED SELECT COUNT(mach_id) INTO :cnt FROM palladium
+    EXEC SQL SELECT COUNT(mach_id) INTO :cnt FROM palladium
       WHERE mach_id = :id;
     if (cnt > 0)
        return(MR_IN_USE);
 
-    EXEC SQL REPEATED DELETE FROM mcmap WHERE mach_id = :id;
-    if (ingres_errno) return(mr_errcode);
+    EXEC SQL DELETE FROM mcmap WHERE mach_id = :id;
+    if (dbms_errno) return(mr_errcode);
     return(MR_SUCCESS);
 }
 
@@ -236,15 +236,15 @@ int setup_dmac(q, argv)
  */
 
 int setup_dsnt(q, argv)
-    struct query *q;
-    char **argv;
+     struct query *q;
+     char **argv;
 {
     EXEC SQL BEGIN DECLARE SECTION;
-    int flag, id, cnt = 0;
+    int id, cnt = 0;
     EXEC SQL END DECLARE SECTION;
 
     id = *(int *)argv[0];
-    EXEC SQL REPEATED SELECT COUNT(mach_id) INTO :cnt FROM machine
+    EXEC SQL SELECT COUNT(mach_id) INTO :cnt FROM machine
       WHERE snet_id = :id;
     if (cnt > 0)
        return(MR_IN_USE);
@@ -257,23 +257,23 @@ int setup_dsnt(q, argv)
  */
 
 int setup_dclu(q, argv)
-    struct query *q;
-    char **argv;
+     struct query *q;
+     char **argv;
 {
     EXEC SQL BEGIN DECLARE SECTION;
     int id, cnt;
     EXEC SQL END DECLARE SECTION;
 
     id = *(int *)argv[0];
-    EXEC SQL REPEATED SELECT COUNT(mach_id) INTO :cnt FROM mcmap
+    EXEC SQL SELECT COUNT(mach_id) INTO :cnt FROM mcmap
       WHERE clu_id = :id;
     if (cnt > 0)
        return(MR_IN_USE);
-    EXEC SQL REPEATED SELECT COUNT(clu_id) INTO :cnt FROM svc
+    EXEC SQL SELECT COUNT(clu_id) INTO :cnt FROM svc
       WHERE clu_id = :id;
     if (cnt > 0)
        return(MR_IN_USE);
-    if (ingres_errno)
+    if (dbms_errno)
        return(mr_errcode);
     return(MR_SUCCESS);
 }
@@ -307,15 +307,15 @@ static int badlistchars[] = {
 };
 
 int setup_alis(q, argv, cl)
-    struct query *q;
-    char *argv[];
-    client *cl;
+     struct query *q;
+     char *argv[];
+     client *cl;
 {
     EXEC SQL BEGIN DECLARE SECTION;
     int ngid;
     EXEC SQL END DECLARE SECTION;
     unsigned char *p;
-    int idx;
+    int idx, err;
 
     if (!strcmp(q->shortname, "alis"))
       idx = 0;
@@ -328,11 +328,11 @@ int setup_alis(q, argv, cl)
  
     if (!strcmp(argv[6 + idx], UNIQUE_GID) || atoi(argv[6 + idx]) == -1) {
        if (atoi(argv[5 + idx])) {
-           if (set_next_object_id("gid", "list", 1))
-             return(MR_INGRES_ERR);
-           EXEC SQL REPEATED SELECT value INTO :ngid FROM numvalues
+           if ((err=set_next_object_id("gid", LIST_TABLE, 1)))
+             return(err);
+           EXEC SQL SELECT value INTO :ngid FROM numvalues
              WHERE name = 'gid';
-           if (ingres_errno) return(mr_errcode);
+           if (dbms_errno) return(mr_errcode);
            sprintf(argv[6 + idx], "%d", ngid);
        } else {
            strcpy(argv[6 + idx], "-1");
@@ -351,60 +351,56 @@ int setup_alis(q, argv, cl)
  */
 
 int setup_dlis(q, argv)
-    struct query *q;
-    char *argv[];
+     struct query *q;
+     char *argv[];
 {
-    int flag, id, ec;
+    int id;
+    EXEC SQL BEGIN DECLARE SECTION;
+    int cnt;
+    EXEC SQL END DECLARE SECTION;
 
     id = *(int *)argv[0];
-    sprintf(stmt_buf,"SELECT member_id FROM imembers WHERE member_id = %d AND member_type='LIST'",id);
-    if(ec=mr_select_any(stmt_buf)) {
-       if(ec==MR_EXISTS) return(MR_IN_USE); else return(ec);
-    }
+
+    EXEC SQL SELECT COUNT(member_id) INTO :cnt FROM imembers
+      WHERE member_id = :id AND member_type='LIST';
+    if(cnt>0) return MR_IN_USE;
+
+    EXEC SQL SELECT COUNT(member_id) INTO :cnt FROM imembers
+      WHERE member_id = :id AND member_type='LIST';
+    if(cnt>0) return MR_IN_USE;
     
-    sprintf(stmt_buf,"SELECT member_id FROM imembers WHERE list_id = %d",id);
-    if(ec=mr_select_any(stmt_buf)) {
-       if(ec==MR_EXISTS) return(MR_IN_USE); else return(ec);
-    }
+    EXEC SQL SELECT COUNT(member_id) INTO :cnt FROM imembers
+      WHERE list_id = :id;
+    if(cnt>0) return MR_IN_USE;
 
-    sprintf(stmt_buf,"SELECT label FROM filesys WHERE owners = %d",id);
-    if(ec=mr_select_any(stmt_buf)) {
-       if(ec==MR_EXISTS) return(MR_IN_USE); else return(ec);
-    }
+    EXEC SQL SELECT COUNT(label) INTO :cnt FROM filesys WHERE owners = :id;
+    if(cnt>0) return MR_IN_USE;
 
-    sprintf(stmt_buf,"SELECT tag FROM capacls WHERE list_id = %d",id);
-    if(ec=mr_select_any(stmt_buf)) {
-       if(ec==MR_EXISTS) return(MR_IN_USE); else return(ec);
-    }
+    EXEC SQL SELECT COUNT(tag) INTO :cnt FROM capacls WHERE list_id = :id;
+    if(cnt>0) return MR_IN_USE;
 
-    sprintf(stmt_buf,"SELECT name FROM list WHERE acl_id = %d AND acl_type='LIST' AND list_id != %d",id,id);
-    if(ec=mr_select_any(stmt_buf)) {
-       if(ec==MR_EXISTS) return(MR_IN_USE); else return(ec);
-    }
+    EXEC SQL SELECT COUNT(name) INTO :cnt FROM list
+      WHERE acl_id = :id AND acl_type='LIST' AND list_id != :id;
+    if(cnt>0) return MR_IN_USE;
 
-    sprintf(stmt_buf,"SELECT name FROM servers WHERE acl_id = %d AND acl_type='LIST'",id);
-    if(ec=mr_select_any(stmt_buf)) {
-       if(ec==MR_EXISTS) return(MR_IN_USE); else return(ec);
-    }
+    EXEC SQL SELECT COUNT(name) INTO :cnt FROM servers
+      WHERE acl_id = :id AND acl_type='LIST';
+    if(cnt>0) return MR_IN_USE;
 
-    sprintf(stmt_buf,"SELECT entity_id FROM quota WHERE entity_id = %d AND type='GROUP'",id);
-    if(ec=mr_select_any(stmt_buf)) {
-       if(ec==MR_EXISTS) return(MR_IN_USE); else return(ec);
-    }
+    EXEC SQL SELECT COUNT(entity_id) INTO :cnt FROM quota
+      WHERE entity_id = :id AND type='GROUP';
+    if(cnt>0) return MR_IN_USE;
  
-    sprintf(stmt_buf,"SELECT acl_id  FROM hostaccess WHERE acl_id = %d AND acl_type='LIST'",id);
-    if(ec=mr_select_any(stmt_buf)) {
-       if(ec==MR_EXISTS) return(MR_IN_USE); else return(ec);
-    }
+    EXEC SQL SELECT COUNT(acl_id) INTO :cnt FROM hostaccess
+      WHERE acl_id = :id AND acl_type='LIST';
+    if(cnt>0) return MR_IN_USE;
 
-    sprintf(stmt_buf,"SELECT class FROM zephyr z \
-WHERE z.xmt_type = 'LIST' AND z.xmt_id = %d \
-OR z.sub_type = 'LIST' AND z.sub_id = %d \
-OR z.iws_type = 'LIST' AND z.iws_id = %d \
-OR z.iui_type = 'LIST' AND z.iui_id = %d",id,id,id,id);
-    if(ec=mr_select_any(stmt_buf)) {
-       if(ec==MR_EXISTS) return(MR_IN_USE); else return(ec);
-    }
+    EXEC SQL SELECT COUNT(class) INTO :cnt FROM zephyr z
+      WHERE z.xmt_type = 'LIST' AND z.xmt_id = :id
+      OR z.sub_type = 'LIST' AND z.sub_id = :id
+      OR z.iws_type = 'LIST' AND z.iws_id = :id
+      OR z.iui_type = 'LIST' AND z.iui_id = :id;
+    if(cnt>0) return MR_IN_USE;
 
     return(MR_SUCCESS);
 }
@@ -415,26 +411,22 @@ OR z.iui_type = 'LIST' AND z.iui_id = %d",id,id,id,id);
  */
 
 int setup_dsin(q, argv)
-    struct query *q;
-    char **argv;
+     struct query *q;
+     char **argv;
 {
     EXEC SQL BEGIN DECLARE SECTION;     
-    int ec;
+    int ec, cnt;
     char *svrname;
     EXEC SQL END DECLARE SECTION;
 
-    sprintf(stmt_buf,"SELECT service FROM serverhosts WHERE service = UPPERCASE('%s')",argv[0]);
-    if(ec=mr_select_any(stmt_buf)) {
-       if(ec==MR_EXISTS) 
-           return(MR_IN_USE); 
-       else 
-           return(ec);
-    }
-
     svrname=argv[0];
+    EXEC SQL SELECT COUNT(service) INTO :cnt FROM serverhosts
+      WHERE service = UPPER(:svrname);
+    if(cnt>0) return MR_IN_USE;
+
     EXEC SQL SELECT inprogress INTO :ec FROM servers 
-      WHERE name=UPPERCASE(:svrname);
-    if(ingres_errno) 
+      WHERE name=UPPER(:svrname);
+    if(dbms_errno) 
        return(mr_errcode);
     if(ec) 
        return(MR_IN_USE); 
@@ -448,8 +440,8 @@ int setup_dsin(q, argv)
  */
 
 int setup_dshi(q, argv)
-    struct query *q;
-    char **argv;
+     struct query *q;
+     char **argv;
 {
     EXEC SQL BEGIN DECLARE SECTION;
     int id, ec;
@@ -460,8 +452,8 @@ int setup_dshi(q, argv)
     id = *(int *)argv[1];
 
     EXEC SQL SELECT inprogress INTO :ec FROM serverhosts 
-      WHERE service=UPPERCASE(:svrname) AND mach_id = :id;
-    if(ingres_errno) 
+      WHERE service=UPPER(:svrname) AND mach_id = :id;
+    if(dbms_errno) 
        return(mr_errcode);
     if(ec) 
        return(MR_IN_USE); 
@@ -478,7 +470,7 @@ int setup_dshi(q, argv)
  **   argv[1] - type
  **   argv[2] - mach_id
  **   argv[3] - name
- **   argv[5] - access
+ **   argv[5] - rwaccess
  **
  ** Description:
  **   - for type = RVD:
@@ -486,7 +478,7 @@ int setup_dshi(q, argv)
  **   - for type = NFS:
  **        * extract directory prefix from name
  **        * verify mach_id/dir in nfsphys
- **        * verify access in {r, w, R, W}
+ **        * verify rwaccess in {r, w, R, W}
  **
  **  Side effect: sets variable _var_phys_id to the ID of the physical
  **    filesystem (nfsphys_id for NFS, 0 for RVD)
@@ -501,35 +493,35 @@ EXEC SQL BEGIN DECLARE SECTION;
 int _var_phys_id;
 EXEC SQL END DECLARE SECTION;
 
-setup_afil(q, argv, cl)
-    struct query *q;
-    char *argv[];
-    client *cl;
+int setup_afil(q, argv, cl)
+     struct query *q;
+     char *argv[];
+     client *cl;
 {
     char *type, *name;
     int mach_id;
     EXEC SQL BEGIN DECLARE SECTION;
     int ok;
-    char ftype[32], *access;
+    char ftype[32], *rwaccess;
     EXEC SQL END DECLARE SECTION;
 
     type = argv[1];
     mach_id = *(int *)argv[2];
     name = argv[3];
-    access = argv[5];
+    rwaccess = argv[5];
     _var_phys_id = 0;
 
     sprintf(ftype, "fs_access_%s", type);
     EXEC SQL SELECT COUNT(trans) INTO :ok FROM alias
-       WHERE name = :ftype AND type = 'TYPE' and trans = :access;   
-    if (ingres_errno) return(mr_errcode);
+       WHERE name = :ftype AND type = 'TYPE' and trans = :rwaccess;
+    if (dbms_errno) return(mr_errcode);
     if (ok == 0) return(MR_FILESYS_ACCESS);
 
     if((mr_errcode=prefetch_value(q,argv,cl))!=MR_SUCCESS)
       return(mr_errcode);
 
     if (!strcmp(type, "NFS"))
-       return (check_nfs(mach_id, name, access));
+       return (check_nfs(mach_id, name, rwaccess));
 
     return(MR_SUCCESS);
 }
@@ -540,10 +532,10 @@ setup_afil(q, argv, cl)
  * the new phys_id.
  */
 
-setup_ufil(q, argv, cl)
-    struct query *q;
-    char *argv[];
-    client *cl;
+int setup_ufil(q, argv, cl)
+     struct query *q;
+     char *argv[];
+     client *cl;
 {
     int mach_id, status;
     char *type, *name;
@@ -565,27 +557,26 @@ setup_ufil(q, argv, cl)
     sprintf(ftype, "fs_access_%s", type);
     EXEC SQL SELECT COUNT(trans) INTO :ok FROM alias
       WHERE name = :ftype AND type='TYPE' AND trans = :access;
-    if (ingres_errno) return(mr_errcode);
+    if (dbms_errno) return(mr_errcode);
     if (ok == 0) return(MR_FILESYS_ACCESS);
 
     EXEC SQL SELECT type INTO :ftype FROM filesys
       WHERE filsys_id = :fid;
-    strtrim(ftype);
-    if (ingres_errno) return(mr_errcode);
+    if (dbms_errno) return(mr_errcode);
 
     if (!strcmp(type, "NFS")) {
        status = check_nfs(mach_id, name, access);
        EXEC SQL UPDATE quota SET phys_id = :_var_phys_id
          WHERE filsys_id = :fid;
-       if (ingres_errno) return(mr_errcode);
+       if (dbms_errno) return(mr_errcode);
        return(status);
-    } else if (!strcmp(type, "AFS") && strcmp(ftype, "AFS")) {
+    } else if (!strcmp(type, "AFS") && strcmp(strtrim(ftype), "AFS")) {
        total = 0;
-       EXEC SQL REPEATED DELETE FROM quota
+       EXEC SQL DELETE FROM quota
          WHERE type = 'ANY' AND filsys_id = :fid;
        EXEC SQL SELECT SUM (quota) INTO :total:total_null FROM quota
          WHERE filsys_id = :fid AND phys_id != 0;
-       if (ingres_errno) return(mr_errcode);
+       if (dbms_errno) return(mr_errcode);
        if (!total_null && (total != 0)) {
 /*
  *             append quota (quota = total, filsys_id = fid,
@@ -595,12 +586,12 @@ setup_ufil(q, argv, cl)
            EXEC SQL INSERT INTO quota (quota, filsys_id, phys_id, entity_id,
                                        type, modtime, modby, modwith)
              VALUES (:total, :fid, 0, 0,
-                     'ANY', 'now', :who, :entity) ;
-           if (ingres_errno) return(mr_errcode);
+                     'ANY', SYSDATE, :who, :entity) ;
+           if (dbms_errno) return(mr_errcode);
        }
     } else {
        EXEC SQL UPDATE quota SET phys_id = 0 WHERE filsys_id = :fid;
-       if (ingres_errno) return(mr_errcode);
+       if (dbms_errno) return(mr_errcode);
     }
     return(MR_SUCCESS);
 }
@@ -612,36 +603,34 @@ setup_ufil(q, argv, cl)
  * more than one, we sort the query in reverse order by dir name.
  */
 
-check_nfs(mach_id, name, access)
-    EXEC SQL BEGIN DECLARE SECTION;
+int check_nfs(mach_id, name, access)
+EXEC SQL BEGIN DECLARE SECTION;
     int mach_id;
-    EXEC SQL END DECLARE SECTION;
-    char *name;
-    char *access;
+EXEC SQL END DECLARE SECTION;
+    char *name, *access;
 {
     EXEC SQL BEGIN DECLARE SECTION;
     char dir[81];
     EXEC SQL END DECLARE SECTION;
-    char caccess;
     register int status;
     register char *cp1;
     register char *cp2;
 
     status = MR_NFS;
     EXEC SQL DECLARE csr101 CURSOR FOR
-      SELECT nfsphys_id, TRIM (dir) FROM nfsphys
+      SELECT nfsphys_id, dir FROM nfsphys
        WHERE mach_id = :mach_id
        ORDER BY 2 DESC;
-    if (ingres_errno)
+    if (dbms_errno)
        return(mr_errcode);
     EXEC SQL OPEN csr101;
-    if (ingres_errno)
+    if (dbms_errno)
        return(mr_errcode);
     while(1) {
        EXEC SQL FETCH csr101 INTO :_var_phys_id, :dir;
        if(sqlca.sqlcode != 0) break;
        cp1 = name;
-       cp2 = dir;
+       cp2 = strtrim(dir);
        while (*cp2) {
            if (*cp1++ != *cp2) break;
            cp2++;
@@ -652,7 +641,7 @@ check_nfs(mach_id, name, access)
        }
     }
     EXEC SQL CLOSE csr101;
-    if (ingres_errno)
+    if (dbms_errno)
        return(mr_errcode);
     return(status);
 }
@@ -662,10 +651,10 @@ check_nfs(mach_id, name, access)
  * a filesystem when it is deleted.  Also adjust the allocation numbers.
  */
 
-setup_dfil(q, argv, cl)
-    struct query  *q;
-    char **argv;
-    client *cl;
+int setup_dfil(q, argv, cl)
+     struct query *q;
+     char **argv;
+     client *cl;
 {
     EXEC SQL BEGIN DECLARE SECTION;
     int id, total, phys_id;
@@ -673,23 +662,23 @@ setup_dfil(q, argv, cl)
     EXEC SQL END DECLARE SECTION;
 
     id = *(int *)argv[0];
-    EXEC SQL REPEATED SELECT SUM (quota) INTO :total:none FROM quota
+    EXEC SQL SELECT SUM (quota) INTO :total:none FROM quota
       WHERE filsys_id = :id;
 
     if(none) total=0;
 
     /** What if there are multiple phys_id's per f/s? (bad data) **/
-    EXEC SQL REPEATED SELECT phys_id INTO :phys_id FROM filesys
+    EXEC SQL SELECT phys_id INTO :phys_id FROM filesys
       WHERE filsys_id = :id;
-    EXEC SQL REPEATED UPDATE nfsphys SET allocated = allocated - :total
+    EXEC SQL UPDATE nfsphys SET allocated = allocated - :total
       WHERE nfsphys_id = :phys_id;
 
     if(!none) {
-       EXEC SQL REPEATED DELETE FROM quota WHERE filsys_id = :id;
+       EXEC SQL DELETE FROM quota WHERE filsys_id = :id;
     }
-    EXEC SQL REPEATED DELETE FROM fsgroup WHERE filsys_id = :id;
-    EXEC SQL REPEATED DELETE FROM fsgroup WHERE group_id = :id;
-    if (ingres_errno) return(mr_errcode);
+    EXEC SQL DELETE FROM fsgroup WHERE filsys_id = :id;
+    EXEC SQL DELETE FROM fsgroup WHERE group_id = :id;
+    if (dbms_errno) return(mr_errcode);
     return(MR_SUCCESS);
 }
 
@@ -698,10 +687,10 @@ setup_dfil(q, argv, cl)
  * any filesystems assigned to it before allowing it to be deleted.
  */
 
-setup_dnfp(q, argv, cl)
-    struct query  *q;
-    char **argv;
-    client *cl;
+int setup_dnfp(q, argv, cl)
+     struct query *q;
+     char **argv;
+     client *cl;
 {
     EXEC SQL BEGIN DECLARE SECTION;
     int id, cnt;
@@ -710,12 +699,12 @@ setup_dnfp(q, argv, cl)
 
     id = *(int *)argv[0];
     dir = argv[1];
-    EXEC SQL REPEATED SELECT count(fs.tid) INTO :cnt FROM filesys fs, nfsphys np
+    EXEC SQL SELECT count(fs.rowid) INTO :cnt FROM filesys fs, nfsphys np
       WHERE fs.mach_id = :id AND fs.phys_id = np.nfsphys_id
        AND np.mach_id = :id AND np.dir = :dir;
     if (cnt > 0)
       return(MR_IN_USE);
-    if (ingres_errno)
+    if (dbms_errno)
       return(mr_errcode);
     return(MR_SUCCESS);
 }
@@ -727,10 +716,10 @@ setup_dnfp(q, argv, cl)
  *   argv[2 or 1] = users_id or list_id
  */
 
-setup_dqot(q, argv, cl)
-    struct query  *q;
-    char **argv;
-    client *cl;
+int setup_dqot(q, argv, cl)
+     struct query *q;
+     char **argv;
+     client *cl;
 {
     EXEC SQL BEGIN DECLARE SECTION;
     int quota, fs, id, physid;
@@ -746,32 +735,14 @@ setup_dqot(q, argv, cl)
        id = *(int *)argv[1];
     }
 
-    EXEC SQL REPEATED SELECT quota INTO :quota FROM quota
+    EXEC SQL SELECT quota INTO :quota FROM quota
       WHERE type = :qtype AND entity_id = :id AND filsys_id = :fs;
-    EXEC SQL REPEATED SELECT phys_id INTO :physid FROM filesys 
+    EXEC SQL SELECT phys_id INTO :physid FROM filesys 
       WHERE filsys_id = :fs;
-    EXEC SQL REPEATED UPDATE nfsphys SET allocated = allocated - :quota
+    EXEC SQL UPDATE nfsphys SET allocated = allocated - :quota
       WHERE nfsphys_id = :physid;
 
-    if (ingres_errno) return(mr_errcode);
-    return(MR_SUCCESS);
-}
-
-
-/* setup_sshi: don't exclusive lock the machine table during
- * set_server_host_internal.
- */
-/** Not allowed under (INGRES) SQL **/
-setup_sshi(q, argv, cl)
-    struct query  *q;
-    char **argv;
-    client *cl;
-{
-#if 0
-#ifsql INGRES
-    EXEC SQL set lockmode session where readlock = system;
-#endsql
-#endif
+    if (dbms_errno) return(mr_errcode);
     return(MR_SUCCESS);
 }
 
@@ -780,23 +751,23 @@ setup_sshi(q, argv, cl)
  * table if necessary.
  */
 
-setup_akum(q, argv, cl)
-struct query *q;
-char **argv;
-client *cl;
+int setup_akum(q, argv, cl)
+     struct query *q;
+     char **argv;
+     client *cl;
 {
     EXEC SQL BEGIN DECLARE SECTION;
-    int id, rowcount;
+    int id;
     char *name;
     EXEC SQL END DECLARE SECTION;
 
     name = argv[1];
-    if (name_to_id(name, "STRING", &id) != MR_SUCCESS) {
+    if (name_to_id(name, STRINGS_TABLE, &id) != MR_SUCCESS) {
        if (q->type != APPEND) return(MR_STRING);
        id=add_string(name);
-       cache_entry(name, "STRING", id);
+       cache_entry(name, STRINGS_TABLE, id);
     }
-    if (ingres_errno) return(mr_errcode);
+    if (dbms_errno) return(mr_errcode);
     *(int *)argv[1] = id;
     return(MR_SUCCESS);
 }
@@ -814,10 +785,10 @@ client *cl;
  * that this query is an APPEND.
  */
 
-prefetch_value(q,argv,cl)
-    struct query *q;
-    char **argv;
-    client *cl;
+int prefetch_value(q, argv, cl)
+     struct query *q;
+     char **argv;
+     client *cl;
 {
     EXEC SQL BEGIN DECLARE SECTION;
     char *name = q->validate->object_id;
@@ -826,7 +797,7 @@ prefetch_value(q,argv,cl)
     int status, limit, argc;
 
     /* set next object id, limiting it if necessary */
-    if(!strcmp(name, "uid") || !strcmp(name, "gid"))
+    if(!strcmp(name, "unix_uid") || !strcmp(name, "gid"))
       limit = 1; /* So far as I know, this isn't needed.  Just CMA. */
     else
       limit = 0;
@@ -835,7 +806,7 @@ prefetch_value(q,argv,cl)
 
     /* fetch object id */
     EXEC SQL SELECT value INTO :value FROM numvalues WHERE name=:name;
-    if(ingres_errno) return(mr_errcode);
+    if(dbms_errno) return(mr_errcode);
     if(sqlca.sqlerrd[2] != 1) return(MR_INTERNAL);
 
     argc = q->argc + q->vcnt;   /* end of Argv for APPENDs */
@@ -853,10 +824,10 @@ prefetch_value(q,argv,cl)
  * Assumes the existence of a row where filsys_id = argv[0], since a
  * filesys label has already been resolved to a filsys_id.
  */
-prefetch_filesys(q,argv,cl)
-    struct query *q;
-    char **argv;
-    client *cl;
+int prefetch_filesys(q, argv, cl)
+     struct query *q;
+     char **argv;
+     client *cl;
 {
     EXEC SQL BEGIN DECLARE SECTION;
     int fid,phid;
@@ -865,7 +836,7 @@ prefetch_filesys(q,argv,cl)
 
     fid = *(int *)argv[0];
     EXEC SQL SELECT phys_id INTO :phid FROM filesys WHERE filsys_id = :fid;
-    if(ingres_errno) return(mr_errcode);
+    if(dbms_errno) return(mr_errcode);
 
     argc=q->argc+q->vcnt;
     sprintf(argv[argc++],"%d",phid);
@@ -878,17 +849,17 @@ prefetch_filesys(q,argv,cl)
 /* setup_ahst():
  */
 
-setup_ahst(q,argv,cl)
-    struct query *q;
-    char **argv;
-    client *cl;
+int setup_ahst(q, argv, cl)
+     struct query *q;
+     char **argv;
+     client *cl;
 {
     EXEC SQL BEGIN DECLARE SECTION;
     char *name;
-    int value, id, addr, mask, high, low, cnt;
+    int value, id, saddr, mask, high, low, cnt;
     EXEC SQL END DECLARE SECTION;
-    char buf[BUFSIZ];
     int row;
+    struct in_addr addr;
     extern int host_access_level, privileged;
 
     if (!strcmp(q->shortname, "uhst"))
@@ -960,7 +931,7 @@ setup_ahst(q,argv,cl)
     name = argv[row];
     EXEC SQL SELECT count(mach_id) INTO :cnt FROM hostalias
       WHERE name = :name;
-    if (ingres_errno) return(mr_errcode);
+    if (dbms_errno) return(mr_errcode);
     if (cnt != 0) return(MR_EXISTS);
 
     /* check address */
@@ -981,14 +952,14 @@ setup_ahst(q,argv,cl)
          * an address or unique was specified.
          */
        id = *(int *)argv[8+row];
-       EXEC SQL SELECT saddr, mask, high, low INTO :addr, :mask, :high, :low
+       EXEC SQL SELECT saddr, mask, high, low INTO :saddr, :mask, :high, :low
          FROM subnet WHERE snet_id = :id;
-       if (ingres_errno) return(mr_errcode);
+       if (dbms_errno) return(mr_errcode);
        if (value != -2) {
             /*
              * someone specified an IP address for the host record
              */
-           if ((value & mask) != addr) return(MR_ADDRESS);
+           if ((value & mask) != saddr) return(MR_ADDRESS);
             /* 
              * run the address argument through inet_addr(). This
              * has the effect that any out of bounds host addrs will
@@ -997,10 +968,11 @@ setup_ahst(q,argv,cl)
              * link in an inet_addr() that returns an error for
              * this case. 
              */
-           name = (char *) inet_ntoa(inet_addr(argv[9+row]));
+           addr.s_addr=inet_addr(argv[9+row]);
+           name = inet_ntoa(addr);
            EXEC SQL SELECT count(mach_id) INTO :cnt FROM machine
              WHERE address = :name;
-           if (ingres_errno) return(mr_errcode);
+           if (dbms_errno) return(mr_errcode);
            if (cnt > 0) {
                 /*
                  * make IP address is unique. If this a modify request
@@ -1023,23 +995,23 @@ setup_ahst(q,argv,cl)
                if (((id & 0xff) == 0) ||
                    ((id & 0xff) == 255))
                  continue;
-               value = htonl(id);
-               name = (char *)inet_ntoa(value);
+               addr.s_addr = htonl(id);
+               name = (char *)inet_ntoa(addr);
                EXEC SQL SELECT count(mach_id) INTO :cnt FROM machine
                  WHERE address = :name;
-               if (ingres_errno) return(mr_errcode);
+               if (dbms_errno) return(mr_errcode);
                if (cnt == 0) break;
            }
            if (cnt != 0)
              return(MR_ADDRESS);
            else
-             value = htonl(value);
+             value = htonl(id);
        }
         /*
          * we have an address in value. Convert it to a string and store it.
          */
-       value = htonl(value);
-       strcpy(argv[9+row], inet_ntoa(value));
+       addr.s_addr = htonl(value);
+       strcpy(argv[9+row], inet_ntoa(addr));
     } else {
        strcpy(argv[9+row], "unassigned");
     }
@@ -1051,9 +1023,9 @@ setup_ahst(q,argv,cl)
     if (row == 1) {
        id = *(int *)argv[0];
        EXEC SQL SELECT status INTO :cnt FROM machine WHERE mach_id = :id;
-       if (ingres_errno) return(mr_errcode);
+       if (dbms_errno) return(mr_errcode);
        if (value != cnt) {
-           EXEC SQL UPDATE machine SET statuschange = date('now')
+           EXEC SQL UPDATE machine SET statuschange = SYSDATE
                  WHERE mach_id = :id;
        }
     }
@@ -1069,10 +1041,10 @@ setup_ahst(q,argv,cl)
        EXEC SQL END DECLARE SECTION;
        /* Non-query owner is restricted in changes that can be made */
        id = *(int *)argv[0];
-       EXEC SQL SELECT contact, status, address, owner_type, owner_id, 
-         acomment, use, snet_id, ocomment INTO :s6, :i8, :s10, :s11, :i12,
-         :i13, :i7, :i9, :i14 FROM machine WHERE mach_id = :id;
-       if (ingres_errno) return(mr_errcode);
+       EXEC SQL SELECT contact, status, address, owner_type, owner_id,
+         acomment, use, snet_id, ocomment INTO :s6, :i8, :s10, :s11,
+         :i12, :i13, :i7, :i9, :i14 FROM machine WHERE mach_id = :id;
+       if (dbms_errno) return(mr_errcode);
        /* subnet owner cannot change use, comment, or network */
        if ((i7 != atoi(argv[7])) || (i14 != *(int *)argv[14]) ||
             (i9 != *(int *)argv[9]))
@@ -1108,10 +1080,10 @@ setup_ahst(q,argv,cl)
 /* setup_ahal():
  */
 
-setup_ahal(q,argv,cl)
-    struct query *q;
-    char **argv;
-    client *cl;
+int setup_ahal(q, argv, cl)
+     struct query *q;
+     char **argv;
+     client *cl;
 {
     EXEC SQL BEGIN DECLARE SECTION;
     char *name;
@@ -1130,7 +1102,7 @@ setup_ahal(q,argv,cl)
 
     EXEC SQL SELECT count(mach_id) INTO :cnt FROM machine WHERE
       name = :name;
-    if (ingres_errno) return(mr_errcode);
+    if (dbms_errno) return(mr_errcode);
     if (cnt > 0) return(MR_EXISTS);
 
     return(MR_SUCCESS);
index 8325ee65a2e5bc2ab4b737e044f29a9e27a11d51..2f239885b54005ab10055ab348d4d7f2d31d7898 100644 (file)
@@ -15,6 +15,7 @@ static char *rcsid_qsubs_c = "$Header$";
 
 #include <mit-copyright.h>
 #include <moira.h>
+#include "mr_server.h"
 #include "query.h"
 
 #ifdef MULTIPROTOCOLS
@@ -60,7 +61,7 @@ get_query_by_name(name, version)
     return((struct query *)0);
 }
 
-list_queries(version, action, actarg)
+void list_queries(version, action, actarg)
     int version;
     int (*action)();
     int actarg;
@@ -118,7 +119,7 @@ list_queries(version, action, actarg)
   (*action)(1, &qnp, actarg);
 }
 
-help_query(q, action, actarg)
+void help_query(q, action, actarg)
     register struct query *q;
     int (*action)();
     int actarg;
index 038e92a32cfebbb7783356a4bb44499ac4b71842..b27183cd60c4c254151e8a5595a3454f2bebd6b8 100644 (file)
@@ -14,24 +14,27 @@ static char *rcsid_qsupport_dc = "$Header$";
 #endif lint
 
 #include <mit-copyright.h>
-#include "query.h"
 #include "mr_server.h"
+#include "query.h"
 #include <ctype.h>
-#ifdef GDSS
-#include "gdss.h"
-#endif /* GDSS */
+#include <string.h>
 EXEC SQL INCLUDE sqlca;
-EXEC SQL INCLUDE sqlda;
 #include "qrtn.h"
 
-extern char *whoami, *strsave();
-extern int ingres_errno, mr_errcode;
+extern char *whoami, *table_name[];
+extern int dbms_errno, mr_errcode;
 
 EXEC SQL BEGIN DECLARE SECTION;
 extern char stmt_buf[];
 EXEC SQL END DECLARE SECTION;
 
-EXEC SQL WHENEVER SQLERROR CALL ingerr;
+EXEC SQL WHENEVER SQLERROR DO dbmserr();
+
+int get_ace_internal(char *atypex, int aid, int (*action)(), int actarg);
+int gmol_internal(struct query *q, char *argv[], client *cl,
+                 int (*action)(), int actarg, int flag);
+int qualified_get(struct query *q, char *argv[], int (*action)(), int actarg,
+                 char *start, char *range, char *field, char *flags[]);
 
 
 /* Special query routines */
@@ -43,10 +46,11 @@ EXEC SQL WHENEVER SQLERROR CALL ingerr;
  * be put in box_id.  If type is NONE, then box doesn't matter.
  */
 
+
 int set_pobox(q, argv, cl)
-    struct query *q;
-    char **argv;
-    client *cl;
+     struct query *q;
+     char **argv;
+     client *cl;
 {
     EXEC SQL BEGIN DECLARE SECTION;
     int user, id;
@@ -57,40 +61,40 @@ int set_pobox(q, argv, cl)
     box = argv[2];
     user = *(int *)argv[0];
 
-    EXEC SQL REPEATED SELECT pop_id, potype INTO :id, :potype FROM users
+    EXEC SQL SELECT pop_id, potype INTO :id, :potype FROM users
       WHERE users_id = :user;
-    if (ingres_errno) return(mr_errcode);
+    if (dbms_errno) return(mr_errcode);
     if (!strcmp(strtrim(potype), "POP"))
       set_pop_usage(id, -1);
 
     if (!strcmp(argv[1], "POP")) {
-       status = name_to_id(box, "MACHINE", &id);
+       status = name_to_id(box, MACHINE_TABLE, &id);
        if (status == MR_NO_MATCH)
          return(MR_MACHINE);
        else if (status)
          return(status);
-       EXEC SQL REPEATED UPDATE users SET potype = 'POP', pop_id = :id
+       EXEC SQL UPDATE users SET potype = 'POP', pop_id = :id
          WHERE users_id = :user;
        set_pop_usage(id, 1);
     } else if (!strcmp(argv[1], "SMTP")) {
-       if (index(box, '/') || index(box, '|'))
+       if (strchr(box, '/') || strchr(box, '|'))
          return(MR_BAD_CHAR);
-       status = name_to_id(box, "STRING", &id);
+       status = name_to_id(box, STRINGS_TABLE, &id);
        if (status == MR_NO_MATCH) {
            id=add_string(box);
        } else if (status)
          return(status);
-       EXEC SQL REPEATED UPDATE users SET potype='SMTP', box_id = :id
+       EXEC SQL UPDATE users SET potype='SMTP', box_id = :id
          WHERE users_id = :user;
     } else /* argv[1] == "NONE" */ {
-       EXEC SQL REPEATED UPDATE users SET potype='NONE'
+       EXEC SQL UPDATE users SET potype='NONE'
          WHERE users_id = :user;
     }
 
     set_pobox_modtime(q, argv, cl);
-    EXEC SQL REPEATED UPDATE tblstats SET updates = updates+1, modtime='now'
+    EXEC SQL UPDATE tblstats SET updates = updates+1, modtime=SYSDATE
       WHERE table_name='users';
-    if (ingres_errno) return(mr_errcode);
+    if (dbms_errno) return(mr_errcode);
     return(MR_SUCCESS);
 }
 
@@ -100,20 +104,18 @@ int set_pobox(q, argv, cl)
  * data.  Rest of processing consists of fixing gid, ace_name, and modby.
  */
 
-get_list_info(q, aargv, cl, action, actarg)
-    register struct query *q;
-    char **aargv;
-    client *cl;
-    register int (*action)();
-    int actarg;
+int get_list_info(q, aargv, cl, action, actarg)
+     struct query *q;
+     char **aargv;
+     client *cl;
+     int (*action)(), actarg;
 {
     char *argv[13];
     EXEC SQL BEGIN DECLARE SECTION;
     char *name, acl_type[9], listname[33], active[5], public[5], hidden[5];
-    char maillist[5], grouplist[5], gid_str[6], acl_name[256], desc[256];
-    char modtime[27], modby[256], modwith[9];
+    char maillist[5], grouplist[5], gid_str[6], desc[256];
+    char modtime[27], modwith[9];
     int id, rowcount, acl_id, hid, modby_id;
-    char qual[80];
     EXEC SQL END DECLARE SECTION;
     int returned, status;
     struct save_queue *sq, *sq_create();
@@ -123,14 +125,12 @@ get_list_info(q, aargv, cl, action, actarg)
     convert_wildcards(name);
 
     sq = sq_create();
-    sprintf(qual,"name LIKE '%s' ESCAPE '*'",name);
-    optimize_sql_stmt(qual);
     EXEC SQL DECLARE csr102 CURSOR FOR SELECT list_id FROM list
-      WHERE :qual;
-    if (ingres_errno)
+      WHERE name LIKE :name ESCAPE '*';
+    if (dbms_errno)
        return(mr_errcode);
     EXEC SQL OPEN csr102;
-    if (ingres_errno)
+    if (dbms_errno)
        return(mr_errcode);
     while(1)
     {
@@ -141,7 +141,7 @@ get_list_info(q, aargv, cl, action, actarg)
     }
     EXEC SQL CLOSE csr102;
 
-    if (ingres_errno) return(mr_errcode);
+    if (dbms_errno) return(mr_errcode);
     if (rowcount == 0)
       return(MR_NO_MATCH);
 
@@ -153,26 +153,28 @@ get_list_info(q, aargv, cl, action, actarg)
        if (id == 0)
          continue;
        argv[6] = gid_str;
-       EXEC SQL REPEATED SELECT name, CHAR(active), CHAR(publicflg),
-           CHAR(hidden), hidden, CHAR(maillist), CHAR(grouplist), CHAR(gid),
-           TRIM(acl_type), acl_id, description, CHAR(modtime), modby, modwith
+       EXEC SQL SELECT name, active, publicflg,
+           hidden, hidden, maillist, grouplist, gid,
+           acl_type, acl_id, description,
+           TO_CHAR(modtime, 'DD-mon-YYYY HH24:MI:SS'), modby, modwith
          INTO :listname, :active, :public, :hidden, :hid, :maillist,
             :grouplist, :gid_str, :acl_type, :acl_id, :desc,
            :modtime, :modby_id, :modwith
           FROM list WHERE list_id = :id;
 
-       if (ingres_errno) return(mr_errcode);
+       if (dbms_errno) return(mr_errcode);
+       strtrim(acl_type);
 
        if (atoi(gid_str) == -1)
            argv[6] = UNIQUE_GID;
 
        argv[8] = malloc(0);
        if (!strcmp(acl_type, "LIST")) {
-           status = id_to_name(acl_id, "LIST", &argv[8]);
+           status = id_to_name(acl_id, LIST_TABLE, &argv[8]);
        } else if (!strcmp(acl_type, "USER")) {
-           status = id_to_name(acl_id, "USER", &argv[8]);
+           status = id_to_name(acl_id, USERS_TABLE, &argv[8]);
        } else if (!strcmp(acl_type, "KERBEROS")) {
-           status = id_to_name(acl_id, "STRING", &argv[8]);
+           status = id_to_name(acl_id, STRINGS_TABLE, &argv[8]);
        } else if (!strcmp(acl_type, "NONE")) {
            status = 0;
            free(argv[8]);
@@ -186,9 +188,9 @@ get_list_info(q, aargv, cl, action, actarg)
 
        argv[11] = malloc(0);
        if (modby_id > 0)
-         status = id_to_name(modby_id, "USER", &argv[11]);
+         status = id_to_name(modby_id, USERS_TABLE, &argv[11]);
        else
-         status = id_to_name(-modby_id, "STRING", &argv[11]);
+         status = id_to_name(-modby_id, STRINGS_TABLE, &argv[11]);
        if (status && status != MR_NO_MATCH) return(status);
 
        mr_trim_args(q->vcnt, argv);
@@ -199,7 +201,7 @@ get_list_info(q, aargv, cl, action, actarg)
     }
 
     sq_destroy(sq);
-    if (ingres_errno) return(mr_errcode);
+    if (dbms_errno) return(mr_errcode);
     return (MR_SUCCESS);
 }
 
@@ -211,9 +213,9 @@ get_list_info(q, aargv, cl, action, actarg)
 #define MAXLISTDEPTH   1024
 
 int add_member_to_list(q, argv, cl)
-    struct query *q;
-    char **argv;
-    client *cl;
+     struct query *q;
+     char **argv;
+     client *cl;
 {
     EXEC SQL BEGIN DECLARE SECTION;
     int id, lid, mid, error, who, ref, rowcnt;
@@ -229,16 +231,16 @@ int add_member_to_list(q, argv, cl)
     mtype = argv[1];
     mid = *(int *)argv[2];
     /* if the member is already a direct member of the list, punt */
-    EXEC SQL REPEATED SELECT COUNT(list_id) INTO :rowcnt FROM imembers
+    EXEC SQL SELECT COUNT(list_id) INTO :rowcnt FROM imembers
       WHERE list_id = :lid AND member_id = :mid
        AND member_type = :mtype AND direct = 1;
     if (rowcnt > 0)
       return(MR_EXISTS);
     if (!strcasecmp(mtype, "STRING")) {
        buf = malloc(0);
-       status = id_to_name(mid, "STRING", &buf);
+       status = id_to_name(mid, STRINGS_TABLE, &buf);
        if (status) return(status);
-       if (index(buf, '/') || index(buf, '|')) {
+       if (strchr(buf, '/') || strchr(buf, '|')) {
            free(buf);
            return(MR_BAD_CHAR);
        }
@@ -251,10 +253,10 @@ int add_member_to_list(q, argv, cl)
     EXEC SQL DECLARE csr103 CURSOR FOR
       SELECT list_id, ref_count        FROM imembers
        WHERE member_id = :lid AND member_type='LIST';
-    if (ingres_errno)
+    if (dbms_errno)
        return(mr_errcode);
     EXEC SQL OPEN csr103;
-    if (ingres_errno)
+    if (dbms_errno)
        return(mr_errcode);
     while(1) {
        EXEC SQL FETCH csr103 INTO :id, :ref;
@@ -264,7 +266,7 @@ int add_member_to_list(q, argv, cl)
        if (acount >= MAXLISTDEPTH) break;
     }
     EXEC SQL CLOSE csr103;
-    if (ingres_errno) return(mr_errcode);
+    if (dbms_errno) return(mr_errcode);
     if (acount >= MAXLISTDEPTH) {
        return(MR_INTERNAL);
     }
@@ -278,10 +280,10 @@ int add_member_to_list(q, argv, cl)
          SELECT member_id, member_type, ref_count
          FROM imembers
          WHERE list_id = :mid;
-       if (ingres_errno)
+       if (dbms_errno)
            return(mr_errcode);
        EXEC SQL OPEN csr104;
-       if (ingres_errno)
+       if (dbms_errno)
            return(mr_errcode);
        while(1) {
            EXEC SQL FETCH csr104 INTO :id, :dtype, :ref;
@@ -311,7 +313,7 @@ int add_member_to_list(q, argv, cl)
            }
        }
        EXEC SQL CLOSE csr104;
-       if (ingres_errno) return(mr_errcode);
+       if (dbms_errno) return(mr_errcode);
        if (error)
          return(MR_INTERNAL);
     }
@@ -323,7 +325,7 @@ int add_member_to_list(q, argv, cl)
            if (mid == lid && !strcmp(mtype, "LIST")) {
                return(MR_LISTLOOP);
            }
-           EXEC SQL REPEATED SELECT COUNT(ref_count) INTO :rowcnt 
+           EXEC SQL SELECT COUNT(ref_count) INTO :rowcnt 
                FROM imembers
              WHERE list_id = :lid AND member_id = :mid
                AND member_type = :mtype;
@@ -343,28 +345,28 @@ int add_member_to_list(q, argv, cl)
            } else {
                incremental_clear_before();
                if (a == 0 && d == 0) {
-                   EXEC SQL INSERT INTO imembers
-                     (list_id, member_id, direct, member_type, ref_count)
-                     VALUES (:lid, :mid, 1, :mtype, 1);
+                 EXEC SQL INSERT INTO imembers
+                   (list_id, member_id, direct, member_type, ref_count)
+                   VALUES (:lid, :mid, 1, :mtype, 1);
                } else {
-                   EXEC SQL INSERT INTO imembers
-                     (list_id, member_id, member_type, ref_count)
-                     VALUES (:lid, :mid, :mtype, 1);
+                 EXEC SQL INSERT INTO imembers
+                   (list_id, member_id, direct, member_type, ref_count)
+                   VALUES (:lid, :mid, 0, :mtype, 1);
                }
                iargv[0] = (char *)lid;
                iargv[1] = mtype;
                iargv[2] = (char *)mid;
-               incremental_after("members", 0, iargv);
+               incremental_after(IMEMBERS_TABLE, 0, iargv);
            }
        }
     }
     lid = *(int *)argv[0];
     entity = cl->entity;
     who = cl->client_id;
-    EXEC SQL REPEATED UPDATE list
-      SET modtime='now', modby = :who, modwith = :entity
+    EXEC SQL UPDATE list
+      SET modtime=SYSDATE, modby = :who, modwith = :entity
       WHERE list_id = :lid;
-    if (ingres_errno) return(mr_errcode);
+    if (dbms_errno) return(mr_errcode);
     return(MR_SUCCESS);
 }
 
@@ -373,9 +375,9 @@ int add_member_to_list(q, argv, cl)
  */
 
 int delete_member_from_list(q, argv, cl)
-    struct query *q;
-    char **argv;
-    client *cl;
+     struct query *q;
+     char **argv;
+     client *cl;
 {
     EXEC SQL BEGIN DECLARE SECTION;
     int id, lid, mid, cnt, error, who, ref;
@@ -390,10 +392,10 @@ int delete_member_from_list(q, argv, cl)
     mtype = argv[1];
     mid = *(int *)argv[2];
     /* if the member is not a direct member of the list, punt */
-    EXEC SQL REPEATED SELECT COUNT(list_id) INTO :cnt FROM imembers
+    EXEC SQL SELECT COUNT(list_id) INTO :cnt FROM imembers
       WHERE list_id = :lid AND member_id = :mid
        AND member_type = :mtype AND direct = 1;
-    if (ingres_errno) return(mr_errcode);
+    if (dbms_errno) return(mr_errcode);
     if (cnt == 0)
       return(MR_NO_MATCH);
     ancestors[0] = lid;
@@ -402,10 +404,10 @@ int delete_member_from_list(q, argv, cl)
     EXEC SQL DECLARE csr105 CURSOR FOR
       SELECT list_id, ref_count FROM imembers
        WHERE member_id = :lid AND member_type = 'LIST';
-    if (ingres_errno)
+    if (dbms_errno)
        return(mr_errcode);
     EXEC SQL OPEN csr105;
-    if (ingres_errno)
+    if (dbms_errno)
        return(mr_errcode);
     while(1) {
        EXEC SQL FETCH csr105 INTO :id, :ref;
@@ -415,7 +417,7 @@ int delete_member_from_list(q, argv, cl)
        if (acount >= MAXLISTDEPTH) break;
     }
     EXEC SQL CLOSE csr105;
-    if (ingres_errno)
+    if (dbms_errno)
       return(mr_errcode);
     if (acount >= MAXLISTDEPTH)
       return(MR_INTERNAL);
@@ -428,10 +430,10 @@ int delete_member_from_list(q, argv, cl)
        EXEC SQL DECLARE csr106 CURSOR FOR
          SELECT member_id, member_type, ref_count FROM imembers
            WHERE list_id = :mid;
-       if (ingres_errno)
+       if (dbms_errno)
            return(mr_errcode);
        EXEC SQL OPEN csr106;
-       if (ingres_errno)
+       if (dbms_errno)
            return(mr_errcode);
        while(1) {
            EXEC SQL FETCH csr106 INTO :id, :dtype, :ref;
@@ -458,7 +460,7 @@ int delete_member_from_list(q, argv, cl)
            if (dcount >= MAXLISTDEPTH) break;
        }
        EXEC SQL CLOSE csr106;
-       if (ingres_errno)
+       if (dbms_errno)
          return(mr_errcode);
        if (error)
          return(MR_INTERNAL);
@@ -471,14 +473,14 @@ int delete_member_from_list(q, argv, cl)
            if (mid == lid && !strcmp(mtype, "LIST")) {
                return(MR_LISTLOOP);
            }
-           EXEC SQL REPEATED SELECT ref_count INTO :cnt FROM imembers
+           EXEC SQL SELECT ref_count INTO :cnt FROM imembers
              WHERE list_id = :lid AND member_id = :mid AND member_type = :mtype;
            ref = aref[a] * dref[d];
            if (cnt <= ref) {
                iargv[0] = (char *)lid;
                iargv[1] = mtype;
                iargv[2] = (char *)mid;
-               incremental_before("members", 0, iargv);
+               incremental_before(IMEMBERS_TABLE, 0, iargv);
                EXEC SQL DELETE FROM imembers
                  WHERE list_id = :lid AND member_id = :mid
                    AND member_type= :mtype;
@@ -499,9 +501,9 @@ int delete_member_from_list(q, argv, cl)
     lid = *(int *)argv[0];
     entity = cl->entity;
     who = cl->client_id;
-    EXEC SQL UPDATE list SET modtime = 'now', modby = :who, modwith = :entity
+    EXEC SQL UPDATE list SET modtime = SYSDATE, modby = :who, modwith = :entity
       WHERE list_id = :lid;
-    if (ingres_errno) return(mr_errcode);
+    if (dbms_errno) return(mr_errcode);
     return(MR_SUCCESS);
 }
 
@@ -515,11 +517,10 @@ int delete_member_from_list(q, argv, cl)
  */
 
 int get_ace_use(q, argv, cl, action, actarg)
-    struct query *q;
-    char *argv[];
-    client *cl;
-    int (*action)();
-    int actarg;
+     struct query *q;
+     char *argv[];
+     client *cl;
+     int (*action)(), actarg;
 {
     int found = 0;
     EXEC SQL BEGIN DECLARE SECTION;
@@ -542,10 +543,10 @@ int get_ace_use(q, argv, cl, action, actarg)
        EXEC SQL DECLARE csr107 CURSOR FOR
          SELECT list_id FROM imembers
            WHERE member_type='LIST' AND member_id = :aid;
-       if (ingres_errno)
+       if (dbms_errno)
            return(mr_errcode);
        EXEC SQL OPEN csr107;
-       if (ingres_errno)
+       if (dbms_errno)
            return(mr_errcode);
        while(1) {
            EXEC SQL FETCH csr107 INTO :listid;
@@ -564,10 +565,10 @@ int get_ace_use(q, argv, cl, action, actarg)
        EXEC SQL DECLARE csr108 CURSOR FOR
          SELECT list_id FROM imembers
            WHERE member_type='USER' AND member_id = :aid;
-       if (ingres_errno)
+       if (dbms_errno)
            return(mr_errcode);
        EXEC SQL OPEN csr108;
-       if (ingres_errno)
+       if (dbms_errno)
            return(mr_errcode);
        while(1) {
            EXEC SQL FETCH csr108 INTO :listid;
@@ -588,10 +589,10 @@ int get_ace_use(q, argv, cl, action, actarg)
        EXEC SQL DECLARE csr109 CURSOR FOR
          SELECT list_id FROM imembers
            WHERE member_type='KERBEROS' AND member_id = :aid;
-       if (ingres_errno)
+       if (dbms_errno)
            return(mr_errcode);
        EXEC SQL OPEN csr109;
-       if (ingres_errno)
+       if (dbms_errno)
            return(mr_errcode);
        while(1) {
            EXEC SQL FETCH csr109 INTO :listid;
@@ -609,7 +610,7 @@ int get_ace_use(q, argv, cl, action, actarg)
     }
 
     sq_destroy(sq);
-    if (ingres_errno) return(mr_errcode);
+    if (dbms_errno) return(mr_errcode);
     if (!found) return(MR_NO_MATCH);
     return(MR_SUCCESS);
 }
@@ -620,13 +621,11 @@ int get_ace_use(q, argv, cl, action, actarg)
  * by get_ace_use above.
  */
 
-get_ace_internal(atype, aid, action, actarg)
-    EXEC SQL BEGIN DECLARE SECTION;
-    char *atype;
-    int aid;
-    EXEC SQL END DECLARE SECTION;
-    int (*action)();
-    int actarg;
+int get_ace_internal(atype, aid, action, actarg)
+EXEC SQL BEGIN DECLARE SECTION;
+     char *atype;
+EXEC SQL END DECLARE SECTION;
+     int aid, (*action)(), actarg;
 {
     char *rargv[2];
     int found = 0;
@@ -640,10 +639,10 @@ get_ace_internal(atype, aid, action, actarg)
        EXEC SQL DECLARE csr110 CURSOR FOR
          SELECT label FROM filesys
            WHERE owners = :aid;
-       if (ingres_errno)
+       if (dbms_errno)
            return(mr_errcode);
        EXEC SQL OPEN csr110;
-       if (ingres_errno)
+       if (dbms_errno)
            return(mr_errcode);
        while(1) {
            EXEC SQL FETCH csr110 INTO :name;
@@ -657,10 +656,10 @@ get_ace_internal(atype, aid, action, actarg)
        EXEC SQL DECLARE csr111 CURSOR FOR
          SELECT capability FROM capacls
            WHERE list_id = :aid ;
-       if (ingres_errno)
+       if (dbms_errno)
            return(mr_errcode);
        EXEC SQL OPEN csr111;
-       if (ingres_errno)
+       if (dbms_errno)
            return(mr_errcode);
        while(1) {
            EXEC SQL FETCH csr111 INTO :name ;
@@ -674,10 +673,10 @@ get_ace_internal(atype, aid, action, actarg)
        EXEC SQL DECLARE csr112 CURSOR FOR
          SELECT label FROM filesys
            WHERE owner = :aid;
-       if (ingres_errno)
+       if (dbms_errno)
            return(mr_errcode);
        EXEC SQL OPEN csr112;
-       if (ingres_errno)
+       if (dbms_errno)
            return(mr_errcode);
        while(1) {
            EXEC SQL FETCH csr112 INTO :name ;
@@ -692,10 +691,10 @@ get_ace_internal(atype, aid, action, actarg)
     EXEC SQL DECLARE csr113 CURSOR FOR
       SELECT name FROM list
        WHERE acl_type = :atype AND acl_id = :aid;
-    if (ingres_errno)
+    if (dbms_errno)
        return(mr_errcode);
     EXEC SQL OPEN csr113;
-    if (ingres_errno)
+    if (dbms_errno)
        return(mr_errcode);
     while(1) {
        EXEC SQL FETCH csr113 INTO :name;
@@ -709,10 +708,10 @@ get_ace_internal(atype, aid, action, actarg)
     EXEC SQL DECLARE csr114 CURSOR FOR
       SELECT name FROM servers
        WHERE acl_type = :atype AND acl_id = :aid;
-    if (ingres_errno)
+    if (dbms_errno)
        return(mr_errcode);
     EXEC SQL OPEN csr114;
-    if (ingres_errno)
+    if (dbms_errno)
        return(mr_errcode);
     while(1) {
        EXEC SQL FETCH csr114 INTO :name;
@@ -727,10 +726,10 @@ get_ace_internal(atype, aid, action, actarg)
       SELECT name FROM machine m, hostaccess ha
        WHERE m.mach_id = ha.mach_id AND ha.acl_type = :atype
          AND ha.acl_id = :aid;
-    if (ingres_errno)
+    if (dbms_errno)
        return(mr_errcode);
     EXEC SQL OPEN csr115;
-    if (ingres_errno)
+    if (dbms_errno)
        return(mr_errcode);
     while(1) {
        EXEC SQL FETCH csr115 INTO :name;
@@ -747,10 +746,10 @@ get_ace_internal(atype, aid, action, actarg)
          OR z.sub_type = :atype AND z.sub_id = :aid
          OR z.iws_type = :atype AND z.iws_id = :aid
           OR z.iui_type = :atype AND z.iui_id = :aid;
-    if (ingres_errno)
+    if (dbms_errno)
        return(mr_errcode);
     EXEC SQL OPEN csr116;
-    if (ingres_errno)
+    if (dbms_errno)
        return(mr_errcode);
     while(1) {
        EXEC SQL FETCH csr116 INTO :name;
@@ -774,17 +773,16 @@ get_ace_internal(atype, aid, action, actarg)
  */
 
 int get_lists_of_member(q, argv, cl, action, actarg)
-    struct query *q;
-    char *argv[];
-    client *cl;
-    int (*action)();
-    int actarg;
+     struct query *q;
+     char *argv[];
+     client *cl;
+     int (*action)(), actarg;
 {
     int found = 0, direct = 1;
     char *rargv[6];
     EXEC SQL BEGIN DECLARE SECTION;
     char *atype;
-    int aid, listid, id;
+    int aid;
     char name[33], active[5], public[5], hidden[5], maillist[5], grouplist[5];
     EXEC SQL END DECLARE SECTION;
 
@@ -815,15 +813,15 @@ int get_lists_of_member(q, argv, cl, action, actarg)
     rargv[5] = grouplist;
     if (direct) {
        EXEC SQL DECLARE csr117a CURSOR FOR
-         SELECT l.name, CHAR(l.active), CHAR(l.publicflg), CHAR(l.hidden),
-             CHAR(l.maillist), CHAR(l.grouplist)
+         SELECT l.name, l.active, l.publicflg, l.hidden,
+             l.maillist, l.grouplist
            FROM list l, imembers im
            WHERE l.list_id = im.list_id AND im.direct = 1
              AND im.member_type = :atype AND im.member_id = :aid;
-       if (ingres_errno)
+       if (dbms_errno)
            return(mr_errcode);
        EXEC SQL OPEN csr117a;
-       if (ingres_errno)
+       if (dbms_errno)
            return(mr_errcode);
        while(1) {
            EXEC SQL FETCH csr117a
@@ -835,15 +833,15 @@ int get_lists_of_member(q, argv, cl, action, actarg)
        EXEC SQL CLOSE csr117a;
     } else {
        EXEC SQL DECLARE csr117b CURSOR FOR
-         SELECT l.name, CHAR(l.active), CHAR(l.publicflg), CHAR(l.hidden),
-             CHAR(l.maillist), CHAR(l.grouplist)
+         SELECT l.name, l.active, l.publicflg, l.hidden,
+             l.maillist, l.grouplist
            FROM list l, imembers im
            WHERE l.list_id = im.list_id
              AND im.member_type = :atype AND im.member_id = :aid;
-       if (ingres_errno)
+       if (dbms_errno)
            return(mr_errcode);
        EXEC SQL OPEN csr117b;
-       if (ingres_errno)
+       if (dbms_errno)
            return(mr_errcode);
        while(1) {
            EXEC SQL FETCH csr117b
@@ -855,7 +853,7 @@ int get_lists_of_member(q, argv, cl, action, actarg)
        EXEC SQL CLOSE csr117b;
     }
 
-    if (ingres_errno) return(mr_errcode);
+    if (dbms_errno) return(mr_errcode);
     if (!found) return(MR_NO_MATCH);
     return(MR_SUCCESS);
 }
@@ -870,11 +868,10 @@ int get_lists_of_member(q, argv, cl, action, actarg)
 static char *lflags[5] = { "active", "publicflg", "hidden", "maillist", "grouplist" };
 
 int qualified_get_lists(q, argv, cl, action, actarg)
-    struct query *q;
-    char *argv[];
-    client *cl;
-    int (*action)();
-    int actarg;
+     struct query *q;
+     char *argv[];
+     client *cl;
+     int (*action)(), actarg;
 {
     return(qualified_get(q, argv, action, actarg, "l.list_id != 0",
                         "l", "name", lflags));
@@ -883,24 +880,22 @@ int qualified_get_lists(q, argv, cl, action, actarg)
 
 /* get_members_of_list - this gets only direct members */
  
-get_members_of_list(q, argv, cl, action, actarg)
-    struct query *q;
-    char *argv[];
-    client *cl;
-    int (*action)();
-    int actarg;
+int get_members_of_list(q, argv, cl, action, actarg)
+     struct query *q;
+     char *argv[];
+     client *cl;
+     int (*action)(), actarg;
 {
     return(gmol_internal(q, argv, cl, action, actarg, 1));
 }
  
 /* get_end_members_of_list - this gets direct or indirect members */
  
-get_end_members_of_list(q, argv, cl, action, actarg)
-    struct query *q;
-    char *argv[];
-    client *cl;
-    int (*action)();
-    int actarg;
+int get_end_members_of_list(q, argv, cl, action, actarg)
+     struct query *q;
+     char *argv[];
+     client *cl;
+     int (*action)(), actarg;
 {
     return(gmol_internal(q, argv, cl, action, actarg, 0));
 }
@@ -915,13 +910,11 @@ get_end_members_of_list(q, argv, cl, action, actarg)
  **   - retrieve USER members, then LIST members, then STRING members
  **/
 
-gmol_internal(q, argv, cl, action, actarg, flag)
-    struct query *q;
-    char *argv[];
-    client *cl;
-    int (*action)();
-    int actarg;
-    int flag;
+int gmol_internal(q, argv, cl, action, actarg, flag)
+     struct query *q;
+     char *argv[];
+     client *cl;
+     int (*action)(), actarg, flag;
 {
     EXEC SQL BEGIN DECLARE SECTION;
     int list_id, member_id, direct;
@@ -944,10 +937,10 @@ gmol_internal(q, argv, cl, action, actarg, flag)
     EXEC SQL DECLARE csr118 CURSOR FOR
       SELECT member_type, member_id FROM imembers
        WHERE list_id = :list_id AND direct > :direct;
-    if (ingres_errno)
+    if (dbms_errno)
        return(mr_errcode);
     EXEC SQL OPEN csr118;
-    if (ingres_errno)
+    if (dbms_errno)
        return(mr_errcode);
     while(1) {
        EXEC SQL FETCH csr118 INTO :member_type, :member_id;
@@ -964,22 +957,22 @@ gmol_internal(q, argv, cl, action, actarg, flag)
            switch (member_id >> 24) {
            case 'U':
                targv[0] = "USER";
-               id_to_name(member_id & 0xffffff, "USER", &targv[1]);
+               id_to_name(member_id & 0xffffff, USERS_TABLE, &targv[1]);
                (*action)(2, targv, actarg);
                break;
            case 'L':
                targv[0] = "LIST";
-               id_to_name(member_id & 0xffffff, "LIST", &targv[1]);
+               id_to_name(member_id & 0xffffff, LIST_TABLE, &targv[1]);
                (*action)(2, targv, actarg);
                break;
            case 'S':
                targv[0] = "STRING";
-               id_to_name(member_id & 0xffffff, "STRING", &targv[1]);
+               id_to_name(member_id & 0xffffff, STRINGS_TABLE, &targv[1]);
                (*action)(2, targv, actarg);
                break;
            case 'K':
                targv[0] = "KERBEROS";
-               id_to_name(member_id & 0xffffff, "STRING", &targv[1]);
+               id_to_name(member_id & 0xffffff, STRINGS_TABLE, &targv[1]);
                (*action)(2, targv, actarg);
                break;
            default:
@@ -1000,10 +993,10 @@ gmol_internal(q, argv, cl, action, actarg, flag)
        WHERE im.list_id = :list_id AND im.member_type = 'USER'
          AND im.member_id = u.users_id AND im.direct > :direct
        ORDER BY 1;
-    if (ingres_errno)
+    if (dbms_errno)
        return(mr_errcode);
     EXEC SQL OPEN csr119;
-    if (ingres_errno)
+    if (dbms_errno)
        return(mr_errcode);
     while(1) {
        EXEC SQL FETCH csr119 INTO :member_name;
@@ -1011,7 +1004,7 @@ gmol_internal(q, argv, cl, action, actarg, flag)
        (*action)(2, targv, actarg);
     }
     EXEC SQL CLOSE csr119;
-    if (ingres_errno) return(mr_errcode);
+    if (dbms_errno) return(mr_errcode);
 
     targv[0] = "LIST";
     EXEC SQL DECLARE csr120 CURSOR FOR
@@ -1019,10 +1012,10 @@ gmol_internal(q, argv, cl, action, actarg, flag)
        WHERE im.list_id = :list_id AND im.member_type='LIST'
          AND im.member_id = l.list_id AND im.direct > :direct
         ORDER BY 1;
-    if (ingres_errno)
+    if (dbms_errno)
        return(mr_errcode);
     EXEC SQL OPEN csr120;
-    if (ingres_errno)
+    if (dbms_errno)
        return(mr_errcode);
     while(1) {
        EXEC SQL FETCH csr120 INTO :member_name;
@@ -1030,18 +1023,18 @@ gmol_internal(q, argv, cl, action, actarg, flag)
        (*action)(2, targv, actarg);
     }
     EXEC SQL CLOSE csr120;
-    if (ingres_errno) return(mr_errcode);
+    if (dbms_errno) return(mr_errcode);
 
     targv[0] = "STRING";
     EXEC SQL DECLARE csr121 CURSOR FOR
-      SELECT CHAR(str.string) FROM strings str, imembers im
+      SELECT str.string FROM strings str, imembers im
        WHERE im.list_id = :list_id AND im.member_type='STRING'
          AND im.member_id = str.string_id AND im.direct > :direct
        ORDER BY 1;
-    if (ingres_errno)
+    if (dbms_errno)
        return(mr_errcode);
     EXEC SQL OPEN csr121;
-    if (ingres_errno)
+    if (dbms_errno)
        return(mr_errcode);
     while(1) {
        EXEC SQL FETCH csr121 INTO :member_name;
@@ -1049,19 +1042,19 @@ gmol_internal(q, argv, cl, action, actarg, flag)
        (*action)(2, targv, actarg);
     }
     EXEC SQL CLOSE csr121;
-    if (ingres_errno) return(mr_errcode);
+    if (dbms_errno) return(mr_errcode);
 
     targv[0] = "KERBEROS";
     EXEC SQL DECLARE csr122 CURSOR FOR
-      SELECT CHAR(str.string) FROM strings str, imembers im
+      SELECT str.string FROM strings str, imembers im
        WHERE im.list_id = :list_id AND im.member_type='KERBEROS'
          AND im.member_id = str.string_id 
          AND im.direct > :direct
        ORDER BY 1;
-    if (ingres_errno)
+    if (dbms_errno)
        return(mr_errcode);
     EXEC SQL OPEN csr122;
-    if (ingres_errno)
+    if (dbms_errno)
        return(mr_errcode);
     while(1) {
        EXEC SQL FETCH csr122 INTO :member_name;
@@ -1069,7 +1062,7 @@ gmol_internal(q, argv, cl, action, actarg, flag)
        (*action)(2, targv, actarg);
     }
     EXEC SQL CLOSE csr122;
-    if (ingres_errno) return(mr_errcode);
+    if (dbms_errno) return(mr_errcode);
 
     return(MR_SUCCESS);
 }
@@ -1080,11 +1073,10 @@ gmol_internal(q, argv, cl, action, actarg, flag)
  */
 
 int count_members_of_list(q, argv, cl, action, actarg)
-    struct query *q;
-    char *argv[];
-    client *cl;
-    int (*action)();
-    int actarg;
+     struct query *q;
+     char *argv[];
+     client *cl;
+     int (*action)(), actarg;
 {
     EXEC SQL BEGIN DECLARE SECTION;
     int  list, ct = 0;
@@ -1093,9 +1085,9 @@ int count_members_of_list(q, argv, cl, action, actarg)
 
     list = *(int *)argv[0];
     rargv[0] = countbuf;
-    EXEC SQL REPEATED SELECT count (*) INTO :ct FROM imembers
+    EXEC SQL SELECT count (*) INTO :ct FROM imembers
       WHERE list_id = :list AND direct=1;
-    if (ingres_errno) return(mr_errcode);
+    if (dbms_errno) return(mr_errcode);
     sprintf(countbuf, "%d", ct);
     (*action)(1, rargv, actarg);
     return(MR_SUCCESS);
@@ -1111,14 +1103,15 @@ int count_members_of_list(q, argv, cl, action, actarg)
 static char *sflags[3] = { "enable", "inprogress", "harderror" };
 
 int qualified_get_server(q, argv, cl, action, actarg)
-    struct query *q;
-    char *argv[];
-    client *cl;
-    int (*action)();
-    int actarg;
+     struct query *q;
+     char *argv[];
+     client *cl;
+     int (*action)(), actarg;
 {
-    return(qualified_get(q, argv, action, actarg, "s.name != ''",
+    return(qualified_get(q, argv, action, actarg, "s.name is not null",
                         "s", "name", sflags));
+    /* of course, name will never be null, but we need something there
+       to make qualified_get happy */
 }
 
 
@@ -1132,18 +1125,13 @@ int qualified_get_server(q, argv, cl, action, actarg)
  */
 
 int qualified_get(q, argv, action, actarg, start, range, field, flags)
-    struct query *q;
-    char *argv[];
-    int (*action)();
-    int actarg;
-    char *start;
-    char *range;
-    char *field;
-    char *flags[];
+     struct query *q;
+     char *argv[], *start, *range, *field, *flags[];
+     int (*action)(), actarg;            
 {
-    char name[33], qual[256];
-    int rowcount=0, i;
-    char *rargv[1], buf[32];
+    char qual[256];
+    int i;
+    char buf[32];
 
     strcpy(qual, start);
     for (i = 0; i < q->argc; i++) {
@@ -1156,24 +1144,9 @@ int qualified_get(q, argv, action, actarg, start, range, field, flags)
        }
     }
 
-    rargv[0] = SQLDA->sqlvar[0].sqldata;
-    sprintf(stmt_buf,"SELECT CHAR(%s.%s) FROM %s %s WHERE %s",range,field,q->rtable,range,qual);
-    EXEC SQL PREPARE stmt INTO :SQLDA USING NAMES FROM :stmt_buf;
-    if(sqlca.sqlcode)
-      return(MR_INTERNAL);
-    EXEC SQL DECLARE csr123 CURSOR FOR stmt;
-    EXEC SQL OPEN csr123;
-    while(1) {
-        EXEC SQL FETCH csr123 USING DESCRIPTOR :SQLDA;
-        if(sqlca.sqlcode != 0) break;
-        rowcount++;
-       (*action)(1, rargv, actarg);
-    }
-    EXEC SQL CLOSE csr123;
-    if (ingres_errno) return(mr_errcode);
-    if (rowcount == 0)
-      return(MR_NO_MATCH);
-    return(MR_SUCCESS);
+    sprintf(stmt_buf,"SELECT %s.%s FROM %s %s WHERE %s",range,field,
+           table_name[q->rtable],range,qual);
+    return do_for_all_rows(stmt_buf, 1, action, actarg);
 }
 
 
@@ -1187,19 +1160,15 @@ static char *shflags[6] = { "service", "enable", "override", "success",
                            "inprogress", "hosterror" };
 
 int qualified_get_serverhost(q, argv, cl, action, actarg)
-    struct query *q;
-    char *argv[];
-    client *cl;
-    int (*action)();
-    int actarg;
+     struct query *q;
+     char *argv[];
+     client *cl;
+     int (*action)(), actarg;
 {
-    EXEC SQL BEGIN DECLARE SECTION;
-    char sname[33], mname[33], qual[256];
-    EXEC SQL END DECLARE SECTION;
-    char *rargv[2], buf[32];
-    int i, rowcount;
+    char qual[256], buf[32];
+    int i;
 
-    sprintf(qual, "m.mach_id = sh.mach_id AND sh.service = uppercase('%s')",
+    sprintf(qual, "m.mach_id = sh.mach_id AND sh.service = UPPER('%s')",
            argv[0]);
     for (i = 1; i < q->argc; i++) {
        if (!strcmp(argv[i], "TRUE")) {
@@ -1211,28 +1180,9 @@ int qualified_get_serverhost(q, argv, cl, action, actarg)
        }
     }
 
-    rargv[0] = sname;
-    rargv[1] = mname;
-    EXEC SQL DECLARE csr124 CURSOR FOR
-      SELECT sh.service, m.name FROM serverhosts sh, machine m
-       WHERE :qual;
-    if (ingres_errno)
-       return(mr_errcode);
-    EXEC SQL OPEN csr124;
-    if (ingres_errno)
-       return(mr_errcode);
-    while(1) {
-        EXEC SQL FETCH csr124 INTO :sname, :mname;
-       if(sqlca.sqlcode != 0) break;
-       rowcount++;
-       (*action)(2, rargv, actarg);
-    }
-    EXEC SQL CLOSE csr124;
-
-    if (ingres_errno) return(mr_errcode);
-    if (rowcount == 0)
-      return(MR_NO_MATCH);
-    return(MR_SUCCESS);
+    sprintf(stmt_buf, "SELECT sh.service, m.name FROM serverhosts sh, "
+           "machine m WHERE %s", qual);
+    return do_for_all_rows(stmt_buf, 2, action, actarg);
 }
 
 
@@ -1243,15 +1193,15 @@ int qualified_get_serverhost(q, argv, cl, action, actarg)
  * MR_FS_STAFF, MR_FS_MISC).
  */
 
-register_user(q, argv, cl)
-    struct query *q;
-    char **argv;
-    client *cl;
+int register_user(q, argv, cl)
+     struct query *q;
+     char **argv;
+     client *cl;
 {
     EXEC SQL BEGIN DECLARE SECTION;
-    char *login, dir[65], *entity, directory[129], machname[33];
-    int who, rowcount, mid, uid, users_id, flag, utype, nid, list_id, quota;
-    int size, alloc, pid, ostatus, nstatus, gidval, fsidval, npidval;
+    char *login, *entity, directory[129], machname[33];
+    int who, rowcount, mid, uid, users_id, utype, list_id;
+    int ostatus, nstatus, gidval, fsidval;
     static int m_id = 0, def_quota = 0;
     EXEC SQL END DECLARE SECTION;
     char buffer[256], *aargv[3];
@@ -1264,9 +1214,9 @@ register_user(q, argv, cl)
     utype = atoi(argv[2]);
 
     /* find user */
-    EXEC SQL REPEATED SELECT users_id, status INTO :users_id, :ostatus
+    EXEC SQL SELECT users_id, status INTO :users_id, :ostatus
       FROM users
-      WHERE uid = :uid AND (status=0 OR status=5 OR status=6);
+      WHERE unix_uid = :uid AND (status=0 OR status=5 OR status=6);
 
     if (sqlca.sqlerrd[2] == 0)
       return(MR_NO_MATCH);
@@ -1274,17 +1224,17 @@ register_user(q, argv, cl)
       return(MR_NOT_UNIQUE);
 
     /* check new login name */
-    EXEC SQL REPEATED SELECT COUNT(login) INTO :rowcount FROM users
+    EXEC SQL SELECT COUNT(login) INTO :rowcount FROM users
       WHERE login = :login AND users_id != :users_id;
-    if (ingres_errno) return(mr_errcode);
+    if (dbms_errno) return(mr_errcode);
     if (rowcount > 0) return(MR_IN_USE);
-    EXEC SQL REPEATED SELECT COUNT(name) INTO :rowcount FROM list
+    EXEC SQL SELECT COUNT(name) INTO :rowcount FROM list
       WHERE name = :login;
-    if (ingres_errno) return(mr_errcode);
+    if (dbms_errno) return(mr_errcode);
     if (rowcount > 0) return(MR_IN_USE);
-    EXEC SQL REPEATED SELECT COUNT(label) INTO :rowcount FROM filesys
+    EXEC SQL SELECT COUNT(label) INTO :rowcount FROM filesys
       WHERE label = :login;
-    if (ingres_errno) return(mr_errcode);
+    if (dbms_errno) return(mr_errcode);
     if (rowcount > 0) return(MR_IN_USE);
     com_err(whoami, 0, "login name OK");
 
@@ -1295,75 +1245,75 @@ register_user(q, argv, cl)
        AND sh.value2 - sh.value1 =
          (SELECT MAX(value2 - value1) FROM serverhosts
            WHERE service = 'POP');
-    if (ingres_errno)
+    if (dbms_errno)
        return(mr_errcode);
     EXEC SQL OPEN csr130;
-    if (ingres_errno)
+    if (dbms_errno)
        return(mr_errcode);
     EXEC SQL FETCH csr130 INTO :mid, :machname;
     if (sqlca.sqlerrd[2] == 0) {
        EXEC SQL CLOSE csr130;
-       if (ingres_errno) return(mr_errcode);
+       if (dbms_errno) return(mr_errcode);
        return(MR_NO_POBOX);
     } else {
        EXEC SQL CLOSE csr130;
-       if (ingres_errno) return(mr_errcode);
+       if (dbms_errno) return(mr_errcode);
     }
 
     /* change login name, set pobox */
     sprintf(buffer, "u.users_id = %d", users_id);
-    incremental_before("users", buffer, 0);
+    incremental_before(USERS_TABLE, buffer, 0);
     nstatus = 2;
     if (ostatus == 5 || ostatus == 6)
       nstatus = 1;
-    EXEC SQL REPEATED UPDATE users SET login = :login, status = :nstatus,
-        modtime='now', modby = :who, modwith = :entity, potype='POP',
-        pop_id = :mid, pmodtime='now', pmodby = :who, pmodwith = :entity
+    EXEC SQL UPDATE users SET login = :login, status = :nstatus,
+        modtime=SYSDATE, modby = :who, modwith = :entity, potype='POP',
+        pop_id = :mid, pmodtime=SYSDATE, pmodby = :who, pmodwith = :entity
       WHERE users_id = :users_id;
 
-    if (ingres_errno) return(mr_errcode);
+    if (dbms_errno) return(mr_errcode);
     if (sqlca.sqlerrd[2] != 1)
       return(MR_INTERNAL);
     set_pop_usage(mid, 1);
     com_err(whoami, 0, "set login name to %s and pobox to %s", login,
            strtrim(machname));
-    incremental_after("users", buffer, 0);
+    incremental_after(USERS_TABLE, buffer, 0);
 
     /* create group list */
-    if (set_next_object_id("gid", "list", 1))
+    if (set_next_object_id("gid", LIST_TABLE, 1))
       return(MR_NO_ID);
-    if (set_next_object_id("list_id", "list", 0))
+    if (set_next_object_id("list_id", LIST_TABLE, 0))
       return(MR_NO_ID);
-    EXEC SQL REPEATED SELECT value INTO :list_id FROM numvalues
+    EXEC SQL SELECT value INTO :list_id FROM numvalues
       WHERE name='list_id';
-    if (ingres_errno) return(mr_errcode);
+    if (dbms_errno) return(mr_errcode);
     if (sqlca.sqlerrd[2] != 1)
       return(MR_INTERNAL);
     incremental_clear_before();
     EXEC SQL SELECT value INTO :gidval FROM numvalues WHERE name = 'gid';
-    EXEC SQL REPEATED INSERT INTO list
-             (name, list_id, active, publicflg, hidden, maillist, grouplist,
-              gid, description, acl_type, acl_id,
-             modtime, modby, modwith)
+    EXEC SQL INSERT INTO list
+      (name, list_id, active, publicflg, hidden, maillist, grouplist,
+       gid, description, acl_type, acl_id,
+       modtime, modby, modwith)
       VALUES (:login, :list_id, 1, 0, 0, 0, 1,
              :gidval, 'User Group', 'USER', :users_id,
-             'now', :who, :entity);
-    if (ingres_errno) return(mr_errcode);
+             SYSDATE, :who, :entity);
+    if (dbms_errno) return(mr_errcode);
     if (sqlca.sqlerrd[2] != 1)
       return(MR_INTERNAL);
     sprintf(buffer, "l.list_id = %d", list_id);
-    incremental_after("list", buffer, 0);
+    incremental_after(LIST_TABLE, buffer, 0);
     aargv[0] = (char *) list_id;
     aargv[1] = "USER";
     aargv[2] = (char *) users_id;
     incremental_clear_before();
-    EXEC SQL REPEATED INSERT INTO imembers
+    EXEC SQL INSERT INTO imembers
              (list_id, member_type, member_id, ref_count, direct)
       VALUES (:list_id, 'USER', :users_id, 1, 1);
-    if (ingres_errno) return(mr_errcode);
+    if (dbms_errno) return(mr_errcode);
     if (sqlca.sqlerrd[2] != 1)
       return(MR_INTERNAL);
-    incremental_after("members", 0, aargv);
+    incremental_after(IMEMBERS_TABLE, 0, aargv);
 
     if (m_id == 0) {
         /* Cell Name (I know, it shouldn't be hard coded...) */
@@ -1373,7 +1323,7 @@ register_user(q, argv, cl)
     }
 
     /* create filesystem */
-    if (set_next_object_id("filsys_id", "filesys", 0))
+    if (set_next_object_id("filsys_id", FILESYS_TABLE, 0))
       return(MR_NO_ID);
     incremental_clear_before();
     if (islower(login[0]) && islower(login[1])) {
@@ -1385,53 +1335,53 @@ register_user(q, argv, cl)
  
     EXEC SQL SELECT value INTO :fsidval FROM numvalues
       WHERE numvalues.name='filsys_id';
-    EXEC SQL REPEATED INSERT INTO filesys
+    EXEC SQL INSERT INTO filesys
         (filsys_id, phys_id, label, type, mach_id, name,
-        mount, access, comments, owner, owners, createflg,
+        mount, rwaccess, comments, owner, owners, createflg,
         lockertype, modtime, modby, modwith)
       VALUES
        (:fsidval, 0, :login, 'AFS', :m_id, :directory,
-        '/mit/'+:login, 'w', 'User Locker', :users_id, :list_id, 1,
-        'HOMEDIR', 'now', :who, :entity);
+        '/mit/' || :login, 'w', 'User Locker', :users_id, :list_id, 1,
+        'HOMEDIR', SYSDATE, :who, :entity);
 
-    if (ingres_errno) return(mr_errcode);
+    if (dbms_errno) return(mr_errcode);
     if (sqlca.sqlerrd[2]  != 1)
       return(MR_INTERNAL);
     sprintf(buffer,"fs.filsys_id = %d",fsidval);
-    incremental_after("filesys", buffer, 0);
+    incremental_after(FILESYS_TABLE, buffer, 0);
 
     /* set quota */
     if (def_quota == 0) {
-       EXEC SQL REPEATED SELECT value INTO :def_quota FROM numvalues
+       EXEC SQL SELECT value INTO :def_quota FROM numvalues
          WHERE name='def_quota';
-       if (ingres_errno) return(mr_errcode);
+       if (dbms_errno) return(mr_errcode);
        if (sqlca.sqlerrd[2] != 1)
          return(MR_NO_QUOTA);
        
     }
     incremental_clear_before();
-    EXEC SQL REPEATED INSERT INTO quota
+    EXEC SQL INSERT INTO quota
         (entity_id, filsys_id, type, quota, phys_id, modtime, modby, modwith)
       VALUES
-        (0, :fsidval, 'ANY', :def_quota, 0, 'now', :who, :entity);
-    if (ingres_errno) return(mr_errcode);
+        (0, :fsidval, 'ANY', :def_quota, 0, SYSDATE, :who, :entity);
+    if (dbms_errno) return(mr_errcode);
     if (sqlca.sqlerrd[2] != 1)
       return(MR_INTERNAL);
     aargv[0] = login;
     aargv[1] = "ANY";
     aargv[2] = login;
     sprintf(buffer, "q.entity_id = 0 and q.filsys_id = %d and q.type = 'ANY'", fsidval);
-    incremental_after("quota", buffer, aargv);
+    incremental_after(QUOTA_TABLE, buffer, aargv);
     com_err(whoami, 0, "quota of %d assigned", def_quota);
-    if (ingres_errno) return(mr_errcode);
+    if (dbms_errno) return(mr_errcode);
 
-    cache_entry(login, "USER", users_id);
+    cache_entry(login, USERS_TABLE, users_id);
 
-    EXEC SQL REPEATED UPDATE tblstats SET updates=updates+1, modtime='now'
+    EXEC SQL UPDATE tblstats SET updates=updates+1, modtime=SYSDATE
       WHERE table_name='users';
-    EXEC SQL REPEATED UPDATE tblstats SET appends=appends+1, modtime='now'
+    EXEC SQL UPDATE tblstats SET appends=appends+1, modtime=SYSDATE
       WHERE table_name='list' OR table_name='filesys' OR table_name='quota';
-    if (ingres_errno) return(mr_errcode);
+    if (dbms_errno) return(mr_errcode);
     return(MR_SUCCESS);
 }
 
@@ -1449,54 +1399,15 @@ register_user(q, argv, cl)
  **/
 
 int set_pop_usage(id, cnt)
-    EXEC SQL BEGIN DECLARE SECTION;
-    int id;
-    int cnt;
-    EXEC SQL END DECLARE SECTION;
+EXEC SQL BEGIN DECLARE SECTION;
+    int id, cnt;
+EXEC SQL END DECLARE SECTION;
 {
-    EXEC SQL REPEATED UPDATE serverhosts SET value1 = value1 + :cnt
+
+    EXEC SQL UPDATE serverhosts SET value1 = value1 + :cnt
       WHERE serverhosts.service = 'POP' AND serverhosts.mach_id = :id;
 
-    if (ingres_errno) return(mr_errcode);
+    if (dbms_errno) return(mr_errcode);
     return(MR_SUCCESS);
 }
 
-
-/* BEGIN KLUDGE
-   special-case `ghal "*" "name"' since Ingres does it slowly */
-
-int get_hostalias(q, argv, cl, action, actarg)
-    struct query *q;
-    char *argv[];
-    client *cl;
-    int (*action)();
-    int actarg;
-{
-    EXEC SQL BEGIN DECLARE SECTION;
-    char *alias=argv[0], *machine=argv[1], qual[BUFSIZ], *p;
-    int id;
-    EXEC SQL END DECLARE SECTION;
-
-    for(p=machine; *p; p++) {
-      if(*p=='%' || *p=='_') break;
-      if(*p=='*') {
-      p++;
-      if(*p=='%') p++;
-      }
-    }
-    if(!*p) {
-      /* machine has no wildcards, so we can do it the fast way */
-      EXEC SQL REPEATED SELECT mach_id INTO :id FROM machine
-      WHERE name=:machine;
-      if(ingres_errno) return(mr_errcode);
-      
-      sprintf(qual, "a.mach_id = %d AND m.mach_id = %d AND a.name LIKE '%s' ESCAPE '*'", id, id, alias);
-      return do_retrieve(q, qual, 0, action, actarg);
-    }
-
-    /* not the special case... do the normal query */
-    build_qual(q->qual, q->argc, argv, qual); 
-    return do_retrieve(q, qual, 0, action, actarg);
-}
-
-/* END KLUDGE */
index cf0dcb14a730714d212c7f8e14cb250f17deaf30..b347445fc3f77dd02df2c63f23ac4b0278ea7b32 100644 (file)
@@ -8,6 +8,10 @@
  */
 
 #include <mit-copyright.h>
+#include "mr_server.h"
+#undef ACE_TYPE
+#undef ACE_NAME
+#undef NAME
 #include "query.h"
 #include "mr_et.h"
 
@@ -47,7 +51,6 @@ int setup_dfil();
 int setup_aftg();
 int setup_dnfp();
 int setup_dqot();
-int setup_sshi();
 int setup_akum();
 int setup_dsnt();
 int setup_ahst();
@@ -97,7 +100,6 @@ int count_members_of_list();
 int get_lists_of_member();
 int register_user();
 int _sdl_followup();
-int get_hostalias();
 
 
 \f
@@ -112,16 +114,17 @@ static char ADDRESS[] = "address";
 static char ALIAS[] = "alias";
 static char CLASS[] = "class";
 static char CLU_ID[] = "clu_id";
-static char CLUSTER[] = "cluster";
+static char CLUSTER[] = "clusters";
 static char COMMENTS[] = "comments";
 static char DESC[] = "description";
 static char DEVICE[] = "device";
 static char DIR[] = "dir";
 static char FILESYS[] = "filesys";
 static char FILSYS_ID[] = "filsys_id";
-static char FIRST[] = "firstname";
+static char FIRST[] = "first";
+static char HOSTACCESS[] = "hostaccess";
 static char LABEL[] = "label";
-static char LAST[] = "lastname";
+static char LAST[] = "last";
 static char LIST[] = "list";
 static char LIST_ID[] = "list_id";
 static char LOCATION[] = "location";
@@ -134,10 +137,12 @@ static char MOD1[] = "modtime";
 static char MOD2[] = "modby";
 static char MOD3[] = "modwith";
 static char NAME[] = "name";
+static char PRINTCAP[] = "printcap";
 static char QUOTA[] = "quota";
 static char QUOTA_TYPE[] = "quota_type";
 static char SECURE[] = "secure";
 static char SERVICE[] = "service";
+static char SERVERS[] = "servers";
 static char SHELL[] = "shell";
 static char SIGNATURE[] = "signature";
 static char SNET_ID[] = "snet_id";
@@ -146,8 +151,18 @@ static char STATUS[] = "status";
 static char TYPE[] = "type";
 static char USERS[] = "users";
 static char USERS_ID[] = "users_id";
-static char UID[] = "uid";
+static char UID[] = "unix_uid";
+static char ZEPH[] = "zephyr";
+static char ZEPH_ID[] = "xmt_id";
 
+/* Table Names */
+char *table_name[] = {
+  "none", USERS, "krbmap", MACHINE, "hostalias", SUBNET, CLUSTER,
+  "mcmap", "svc", LIST, "imembers", SERVERS, "serverhosts", FILESYS,
+  "fsgroup", "nfsphys", "quota", ZEPH, HOSTACCESS, "strings", "services",
+  PRINTCAP, "palladium", "capacls", "alias", "numvalues", "tblstats",
+  "incremental"};
+int num_tables = 27;
 
 
 /* VALOBJS
@@ -155,6 +170,14 @@ static char UID[] = "uid";
  * can be shared.
  */
 
+/*
+ * A word about validation objects and locking:  The validation object
+ * for a query should also request locks on behalf of the pre-processing
+ * and post-processing routines.  This helps to ensure that tables are
+ * accessed and locked in the proper order and thus avoids deadlock 
+ * situations
+ */
+
 static struct valobj VOsort0[] = {
   {V_SORT, 0},
 };
@@ -197,53 +220,40 @@ static struct valobj VOwild012sort0[] = {  /* get_alias */
   {V_SORT, 0},
 };
 
-static struct valobj VOdate1[] = {
-  {V_DATE, 1, 0, 0, 0, MR_DATE},
-};
 
 static struct valobj VOuser0[] = {
-  {V_ID, 0, USERS, LOGIN, USERS_ID, MR_USER},
+  {V_ID, 0, USERS_TABLE, LOGIN, USERS_ID, MR_USER},
 };
 
+
 static struct valobj VOuser0lock[] = {
-  {V_LOCK, 0, USERS, 0, USERS_ID, MR_DEADLOCK},
-  {V_ID, 0, USERS, LOGIN, USERS_ID, MR_USER},
+  {V_LOCK, 0, USERS_TABLE, 0, USERS_ID, MR_DEADLOCK},
+  {V_ID, 0, USERS_TABLE, LOGIN, USERS_ID, MR_USER},
 };
 
 static struct valobj VOmach0[] = {
-  {V_ID, 0, MACHINE, NAME, MACH_ID, MR_MACHINE},
+  {V_ID, 0, MACHINE_TABLE, NAME, MACH_ID, MR_MACHINE},
 };
 
 static struct valobj VOclu0[] = {
-  {V_ID, 0, CLUSTER, NAME, CLU_ID, MR_CLUSTER},
+  {V_ID, 0, CLUSTER_TABLE, NAME, CLU_ID, MR_CLUSTER},
 };
 
 static struct valobj VOlist0[] = {
-  {V_ID, 0, LIST, NAME, LIST_ID, MR_LIST},
+  {V_ID, 0, LIST_TABLE, NAME, LIST_ID, MR_LIST},
 };
 
-static struct valobj VOfilsys0[] = {
-  {V_ID, 0, FILESYS, LABEL, FILSYS_ID, MR_FILESYS},
-};
 
 static struct valobj VOchar0[] = {
   {V_CHAR, 0},
 };
 
-static struct valobj VOsort01[] = {
-  {V_SORT, 1},
-  {V_SORT, 0},
-};
 
-static struct valobj VOuser0sort[] = {
-  {V_ID, 0, USERS, LOGIN, USERS_ID, MR_USER},
-  {V_SORT, 0},
-};
 
 static struct valobj VOfilsys0user1[] = {
-  {V_LOCK, 0, FILESYS, 0, FILSYS_ID, MR_DEADLOCK},
-  {V_ID, 0, FILESYS, LABEL, FILSYS_ID, MR_FILESYS},
-  {V_ID, 1, USERS, LOGIN, USERS_ID, MR_USER},
+  {V_LOCK, 0, FILESYS_TABLE, 0, FILSYS_ID, MR_DEADLOCK},
+  {V_ID, 0, FILESYS_TABLE, LABEL, FILSYS_ID, MR_FILESYS},
+  {V_ID, 1, USERS_TABLE, LOGIN, USERS_ID, MR_USER},
 };
 
 
@@ -253,10 +263,8 @@ static struct valobj VOfilsys0user1[] = {
  */
 
 static struct validate VDmach = { VOmach0, 1 };
-static struct validate VDsort0= { VOsort0, 1 };
 static struct validate VDwild0= { VOwild0, 1 };
 static struct validate VDupwild0= { VOupwild0, 1 };
-static struct validate VDsort2= { VOsort01,2 };
 static struct validate VDwild2sort2 = { VOwild01sort01,4 };
 static struct validate VDwild3sort1 = { VOwild012sort0,4 };
 static struct validate VDsortf = { 
@@ -282,20 +290,10 @@ static struct validate VDwildsortf = {
   0,
   followup_fix_modby,
 };
+static struct validate VDsort0= { VOsort0, 1 };
 
-static struct validate VDwild2sortf = { 
-  VOwild01sort01,
-  4,
-  0,
-  0,
-  0,
-  0,
-  0,
-  0,
-  followup_fix_modby,
-};
 
-static struct validate VDupwildsortf = { 
+static struct validate VDupwildsortf = {
   VOupwild0sort,
   2,
   0,
@@ -306,9 +304,6 @@ static struct validate VDupwildsortf = {
   0,
   followup_fix_modby,
 };
-
-
-\f
 /* Query data */
 
 static char *galo_fields[] = {
@@ -433,21 +428,22 @@ static char *auac_fields[] = {
 };
 
 static struct valobj auac_valobj[] = {
-  {V_LOCK, 0, USERS, 0, USERS_ID, MR_DEADLOCK},
-  {V_CHAR, 0},
-  {V_CHAR, 3},
-  {V_CHAR, 4},
-  {V_CHAR, 5},
-  {V_CHAR, 7},
-  {V_TYPE, 8, CLASS, 0, 0, MR_BAD_CLASS},
-  {V_ID, 9, "strings", "string", "string_id", MR_NO_MATCH},
+  {V_LOCK, 0, USERS_TABLE, 0, USERS_ID, MR_DEADLOCK},
+  {V_CHAR, 0, USERS_TABLE, LOGIN},
+  {V_CHAR, 2, USERS_TABLE, SHELL},
+  {V_CHAR, 3, USERS_TABLE, LAST},
+  {V_CHAR, 4, USERS_TABLE, FIRST},
+  {V_CHAR, 5, USERS_TABLE, MIDDLE},
+  {V_CHAR, 7, USERS_TABLE, MIT_ID},
+  {V_TYPE, 8, 0, CLASS, 0, MR_BAD_CLASS},
+  {V_ID, 9, STRINGS_TABLE, "string", "string_id", MR_NO_MATCH},
 };
 
 static struct validate auac_validate = {
   auac_valobj,
-  8,
+  9,
   LOGIN,
-  "login = LEFT('%s',SIZE(login))",
+  "login = '%s'",
   1,
   USERS_ID,
   0,
@@ -457,9 +453,9 @@ static struct validate auac_validate = {
 
 static struct validate ausr_validate = {
   auac_valobj,
-  7,
+  8,
   LOGIN,
-  "login = LEFT('%s',SIZE(login))",  
+  "login = '%s'",
   1,
   USERS_ID,
   0,
@@ -469,18 +465,22 @@ static struct validate ausr_validate = {
 
 static char *rusr_fields[] = {
   UID, LOGIN, "fs_type"
-    };
+};
 
 static struct valobj rusr_valobj[] = {
-  {V_LOCK, 0, USERS, 0, USERS_ID, MR_DEADLOCK},
-  {V_LOCK, 0, LIST, 0, LIST_ID, MR_DEADLOCK},
-  {V_LOCK, 0, FILESYS, 0, FILSYS_ID, MR_DEADLOCK},
-  {V_LOCK, 0, "nfsphys", 0, "nfsphys_id", MR_DEADLOCK},
+  {V_LOCK, 0, IMEMBERS_TABLE, 0, LIST_ID, MR_DEADLOCK},
+  {V_LOCK, 0, FILESYS_TABLE, 0, FILSYS_ID, MR_DEADLOCK},
+  {V_LOCK, 0, USERS_TABLE, 0, USERS_ID, MR_DEADLOCK},
+  {V_RLOCK, 0, MACHINE_TABLE, 0,MACH_ID, MR_DEADLOCK},
+  {V_LOCK, 0, LIST_TABLE, 0, LIST_ID, MR_DEADLOCK},
+  {V_LOCK, 0, NFSPHYS_TABLE, 0, "nfsphys_id", MR_DEADLOCK},
+  {V_LOCK, 0, QUOTA_TABLE,0, FILSYS_ID, MR_DEADLOCK},
+  {V_RLOCK,0, SERVERHOSTS_TABLE,0, MACH_ID, MR_DEADLOCK},
 };
 
 static struct validate rusr_validate = {
   rusr_valobj,
-  4,
+  8,
   0,
   0,
   0,
@@ -497,20 +497,21 @@ static char *uuac_fields[] = {
 };
 
 static struct valobj uuac_valobj[] = {
-  {V_LOCK, 0, USERS, 0, USERS_ID, MR_DEADLOCK},
-  {V_ID, 0, USERS, LOGIN, USERS_ID, MR_USER},
-  {V_RENAME, 1, USERS, LOGIN, USERS_ID, MR_NOT_UNIQUE},
-  {V_CHAR, 4},
-  {V_CHAR, 5},
-  {V_CHAR, 6},
-  {V_CHAR, 8},
-  {V_TYPE, 9, CLASS, 0, 0, MR_BAD_CLASS},
-  {V_ID, 10, "strings", "string", "string_id", MR_NO_MATCH},
+  {V_LOCK, 0, USERS_TABLE, 0, USERS_ID, MR_DEADLOCK},
+  {V_ID, 0, USERS_TABLE, LOGIN, USERS_ID, MR_USER},
+  {V_RENAME, 1, USERS_TABLE, LOGIN, USERS_ID, MR_NOT_UNIQUE},
+  {V_CHAR, 3, USERS_TABLE, SHELL},
+  {V_CHAR, 4, USERS_TABLE, FIRST},
+  {V_CHAR, 5, USERS_TABLE, LAST},
+  {V_CHAR, 6, USERS_TABLE, MIDDLE},
+  {V_CHAR, 8, USERS_TABLE, MIT_ID},
+  {V_TYPE, 9, 0, CLASS, 0, MR_BAD_CLASS},
+  {V_ID, 10, STRINGS_TABLE, "string", "string_id", MR_NO_MATCH},
 };
 
 static struct validate uuac_validate = {
   uuac_valobj,
-  9,
+  10,
   0,
   0,
   0,
@@ -522,7 +523,7 @@ static struct validate uuac_validate = {
 
 static struct validate uusr_validate = {
   uuac_valobj,
-  8,
+  10,
   0,
   0,
   0,
@@ -537,9 +538,15 @@ static char *uush_fields[] = {
   SHELL,
 };
 
+static struct valobj uush_valobj[] = {
+  {V_LOCK, 0, USERS_TABLE, 0, USERS_ID, MR_DEADLOCK},
+  {V_ID, 0, USERS_TABLE, LOGIN, USERS_ID, MR_USER},
+  {V_CHAR, 1, USERS_TABLE, SHELL},
+};
+
 static struct validate uush_validate = {
-  VOuser0lock,
-  2,
+  uush_valobj,
+  3,
   0,
   0,
   0,
@@ -575,9 +582,20 @@ static char *dusr_fields[] = {
   LOGIN,
 };
 
+struct valobj dusr_valobj[]= {
+  {V_LOCK, 0, IMEMBERS_TABLE, 0, LIST_ID, MR_DEADLOCK},
+  {V_LOCK, 0, FILESYS_TABLE, 0,  FILSYS_ID, MR_DEADLOCK},
+  {V_LOCK, 0, USERS_TABLE, 0, USERS_ID, MR_DEADLOCK},
+  {V_LOCK, 0, LIST_TABLE, 0, LIST_ID, MR_DEADLOCK},
+  {V_LOCK, 0, QUOTA_TABLE, 0, FILSYS_ID, MR_DEADLOCK},
+  {V_LOCK, 0, HOSTACCESS_TABLE, 0, MACH_ID, MR_DEADLOCK},
+  {V_LOCK, 0, KRBMAP_TABLE, 0, "users_id", MR_DEADLOCK},
+  {V_ID, 0, USERS_TABLE, LOGIN, USERS_ID, MR_USER},
+};
+
 static struct validate dusr_validate = {
-  VOuser0lock,
-  2,
+  dusr_valobj,
+  8,
   0,
   0,
   0,
@@ -592,8 +610,8 @@ static char *dubu_fields[] = {
 };
 
 static struct valobj dubu_valobj[] = {
-  {V_LOCK, 0, USERS, 0, USERS_ID, MR_DEADLOCK},
-  {V_ID, 0, USERS, UID, USERS_ID, MR_USER}
+  {V_LOCK, 0, USERS_TABLE, 0, USERS_ID, MR_DEADLOCK},
+  {V_ID, 0, USERS_TABLE, UID, USERS_ID, MR_USER}
 };
 
 static struct validate dubu_validate = {
@@ -615,14 +633,16 @@ static char *akum_fields[] = { LOGIN, "kerberos" };
 
 static struct valobj akum_valobj[] =
 {
-  {V_ID, 0, USERS, LOGIN, USERS_ID, MR_USER},
-  {V_ID, 1, "strings", "string", "string_id", MR_NO_MATCH},
+  {V_LOCK, 0, KRBMAP_TABLE, 0, "users_id", MR_DEADLOCK},
+  {V_ID, 0, USERS_TABLE, LOGIN, USERS_ID, MR_USER},
+  {V_ID, 1, STRINGS_TABLE, "string", "string_id", MR_NO_MATCH},
+
 };
 
 static struct validate akum_validate =
 {
   akum_valobj,
-  1,
+  3,
   USERS_ID,
   "users_id = %d or string_id = %d",
   2,
@@ -635,7 +655,7 @@ static struct validate akum_validate =
 static struct validate dkum_validate =
 {
   akum_valobj,
-  2,
+  3,
   USERS_ID,
   "users_id = %d and string_id = %d",
   2,
@@ -671,9 +691,22 @@ static char *ufbl_fields[] = {
   "affiliation",
 };
 
+static struct valobj ufbl_valobj[] = {
+  {V_LOCK, 0, USERS_TABLE, 0, USERS_ID, MR_DEADLOCK},
+  {V_ID, 0, USERS_TABLE, LOGIN, USERS_ID, MR_USER},
+  {V_LEN, 1, USERS_TABLE, "fullname"},
+  {V_LEN, 2, USERS_TABLE, "nickname"},
+  {V_LEN, 3, USERS_TABLE, "home_addr"},
+  {V_LEN, 4, USERS_TABLE, "home_phone"},
+  {V_LEN, 5, USERS_TABLE, "office_addr"},
+  {V_LEN, 6, USERS_TABLE, "office_phone"},
+  {V_LEN, 7, USERS_TABLE, "department"},
+  {V_LEN, 8, USERS_TABLE, "affiliation"},
+};
+
 static struct validate ufbl_validate = {
-  VOuser0lock,
-  2,
+  ufbl_valobj,
+  10,
   0,
   0,
   0,
@@ -704,9 +737,14 @@ static char *gpox_fields[] = {
   LOGIN, TYPE, "box",
 };
 
+struct valobj gpox_valobj[]={
+  {V_RLOCK, 0, USERS_TABLE, 0, USERS_ID, MR_DEADLOCK},
+  {V_RLOCK, 0, MACHINE_TABLE, 0, MACH_ID, MR_DEADLOCK}
+};
+
 static struct validate gpox_validate = {
-  0,
-  0,
+  gpox_valobj,
+  2,
   0,
   0,
   0,
@@ -721,15 +759,16 @@ static char *spob_fields[] = {
 };
 
 static struct valobj spob_valobj[] = {
-  {V_LOCK, 0, USERS, 0, USERS_ID, MR_DEADLOCK},
-  {V_ID, 0, USERS, LOGIN, USERS_ID, MR_USER},
-  {V_TYPE, 1, "pobox", 0, 0, MR_TYPE},
+  {V_LOCK, 0, USERS_TABLE, 0, USERS_ID, MR_DEADLOCK},
+  {V_RLOCK, 0, MACHINE_TABLE, 0, MACH_ID, MR_DEADLOCK},
+  {V_ID, 0, USERS_TABLE, LOGIN, USERS_ID, MR_USER},
+  {V_TYPE, 1, 0, "pobox", 0, MR_TYPE},
 };
 
 static struct validate spob_validate = /* SET_POBOX */
 {
   spob_valobj,
-  3,
+  4,
   0,
   0,
   0,
@@ -739,10 +778,16 @@ static struct validate spob_validate =    /* SET_POBOX */
   set_pobox,
 };
 
+struct valobj spop_valobj[] = {
+  {V_LOCK, 0, USERS_TABLE, 0, USERS_ID, MR_DEADLOCK},
+  {V_RLOCK, 0, MACHINE_TABLE, 0, MACH_ID, MR_DEADLOCK},
+  {V_ID, 0, USERS_TABLE, LOGIN, USERS_ID, MR_USER},
+};
+
 static struct validate spop_validate = /* SET_POBOX_POP */
 {
-  VOuser0lock,
-  2,
+  spop_valobj,
+  3,
   0,
   0,
   0,
@@ -754,8 +799,8 @@ static struct validate spop_validate =      /* SET_POBOX_POP */
 
 static struct validate dpob_validate = /* DELETE_POBOX */
 {
-  VOuser0lock,
-  2,
+  spop_valobj,
+  3,
   0,
   0,
   0,
@@ -800,24 +845,29 @@ static char *ahst_fields[] = {
 };
 
 static struct valobj ahst_valobj[] = {
-  {V_CHAR, 0},
-  {V_CHAR, 1},
-  {V_CHAR, 2},
-  {V_CHAR, 3},
-  {V_CHAR, 4},
-  {V_LOCK, 0, MACHINE, 0, MACH_ID, MR_DEADLOCK},
-  {V_ID, 8, SUBNET, NAME, SNET_ID, MR_SUBNET},
-  {V_TYPE, 10, ACE_TYPE, 0, 0, MR_ACE},
+  {V_CHAR, 0, MACHINE_TABLE, NAME},
+  {V_CHAR, 1, MACHINE_TABLE, "vendor"},
+  {V_CHAR, 2, MACHINE_TABLE, "model"},
+  {V_CHAR, 3, MACHINE_TABLE, "os"},
+  {V_CHAR, 4, MACHINE_TABLE, "location"},
+  {V_CHAR, 5, MACHINE_TABLE, "contact"},
+  {V_RLOCK,0, USERS_TABLE, 0, USERS_ID, MR_DEADLOCK},
+  {V_LOCK, 0, MACHINE_TABLE, 0, MACH_ID, MR_DEADLOCK},
+  {V_RLOCK, 0, SUBNET_TABLE, 0, SNET_ID, MR_DEADLOCK},
+  {V_RLOCK, 0, LIST_TABLE, 0, LIST_ID, MR_DEADLOCK},
+  {V_RLOCK, 0, HOSTALIAS_TABLE, 0, MACH_ID, MR_DEADLOCK},
+  {V_ID, 8, SUBNET_TABLE, NAME, SNET_ID, MR_SUBNET},
+  {V_TYPE, 10, 0, ACE_TYPE, 0, MR_ACE},
   {V_TYPEDATA, 11, 0, 0, 0, MR_ACE},
-  {V_ID, 12, "strings", "string", "string_id", MR_NO_MATCH},
-  {V_ID, 13, "strings", "string", "string_id", MR_NO_MATCH},
+  {V_ID, 12, STRINGS_TABLE, "string", "string_id", MR_NO_MATCH},
+  {V_ID, 13, STRINGS_TABLE, "string", "string_id", MR_NO_MATCH},
 };
 
 static struct validate ahst_validate = {
   ahst_valobj,
-  11,
+  16,
   NAME,
-  "name = uppercase(LEFT('%s',SIZE(name)))",
+  "name = UPPER('%s')",
   1,
   MACH_ID,
   access_host,
@@ -831,24 +881,27 @@ static char *uhst_fields[] = {
 };
 
 static struct valobj uhst_valobj[] = {
-  {V_CHAR, 0},
-  {V_ID, 0, MACHINE, NAME, MACH_ID, MR_MACHINE},
-  {V_RENAME, 1, MACHINE, NAME, MACH_ID, MR_NOT_UNIQUE},
-  {V_CHAR, 2},
-  {V_CHAR, 3},
-  {V_CHAR, 4},
-  {V_CHAR, 5},
-  {V_LOCK, 0, MACHINE, 0, MACH_ID, MR_DEADLOCK},
-  {V_ID, 9, SUBNET, NAME, SNET_ID, MR_SUBNET},
-  {V_TYPE, 11, ACE_TYPE, 0, 0, MR_ACE},
+  {V_RLOCK, 0, USERS_TABLE, 0, USERS_ID, MR_DEADLOCK},
+  {V_LOCK, 0, MACHINE_TABLE, 0, MACH_ID, MR_DEADLOCK},
+  {V_RLOCK, 0, SUBNET_TABLE, 0, SNET_ID, MR_DEADLOCK},
+  {V_RLOCK, 0, LIST_TABLE, 0, LIST_ID, MR_DEADLOCK},
+  {V_CHAR, 0, MACHINE_TABLE, "name"},
+  {V_ID, 0, MACHINE_TABLE, NAME, MACH_ID, MR_MACHINE},
+  {V_RENAME, 1, MACHINE_TABLE, NAME, MACH_ID, MR_NOT_UNIQUE},
+  {V_CHAR, 2, MACHINE_TABLE, "vendor"},
+  {V_CHAR, 3, MACHINE_TABLE, "model"},
+  {V_CHAR, 4, MACHINE_TABLE, "os"},
+  {V_CHAR, 5, MACHINE_TABLE, "location"},
+  {V_ID, 9, SUBNET_TABLE, NAME, SNET_ID, MR_SUBNET},
+  {V_TYPE, 11, 0, ACE_TYPE, 0, MR_ACE},
   {V_TYPEDATA, 12, 0, 0, 0, MR_ACE},
-  {V_ID, 13, "strings", "string", "string_id", MR_NO_MATCH},
-  {V_ID, 14, "strings", "string", "string_id", MR_NO_MATCH},
+  {V_ID, 13, STRINGS_TABLE, "string", "string_id", MR_NO_MATCH},
+  {V_ID, 14, STRINGS_TABLE, "string", "string_id", MR_NO_MATCH},
 };
 
 static struct validate uhst_validate = {
   uhst_valobj,
-  13,
+  16,
   0,
   0,
   0,
@@ -863,13 +916,21 @@ static char *dhst_fields[] = {
 };
 
 static struct valobj dhst_valobj[] = {
-  {V_LOCK, 0, MACHINE, 0, MACH_ID, MR_DEADLOCK},
-  {V_ID, 0, MACHINE, NAME, MACH_ID, MR_MACHINE},
+  {V_RLOCK, 0, USERS_TABLE, 0, USERS_ID, MR_DEADLOCK},
+  {V_LOCK, 0, MACHINE_TABLE, 0, MACH_ID, MR_DEADLOCK},
+  {V_RLOCK, 0, NFSPHYS_TABLE, 0, "nfsphys_id", MR_DEADLOCK},
+  {V_RLOCK, 0, SERVERHOSTS_TABLE, 0, MACH_ID, MR_DEADLOCK},
+  {V_RLOCK, 0, HOSTACCESS_TABLE, 0, MACH_ID, MR_DEADLOCK},
+  {V_RLOCK, 0, HOSTALIAS_TABLE, 0, MACH_ID, MR_DEADLOCK},
+  {V_LOCK, 0, MCMAP_TABLE, 0, MACH_ID, MR_DEADLOCK},
+  {V_RLOCK, 0, PRINTCAP_TABLE, 0, MACH_ID, MR_DEADLOCK},
+  {V_RLOCK, 0, PALLADIUM_TABLE, 0, MACH_ID, MR_DEADLOCK},
+  {V_ID, 0, MACHINE_TABLE, NAME, MACH_ID, MR_MACHINE},
 };
 
 static struct validate dhst_validate = {
   dhst_valobj,
-  2,
+  10,
   0,
   0,
   0,
@@ -899,20 +960,20 @@ static struct validate ghal_validate = {
   0,
   access_ahal,
   0,
-  get_hostalias,
+  0,
 };
 
 static struct valobj ahal_valobj[] = {
-  {V_CHAR, 0},
+  {V_CHAR, 0, HOSTALIAS_TABLE, NAME},
   {V_UPWILD, 0},
-  {V_ID, 1, MACHINE, NAME, MACH_ID, MR_MACHINE},
+  {V_ID, 1, MACHINE_TABLE, NAME, MACH_ID, MR_MACHINE},
 };
 
 static struct validate ahal_validate = {
   ahal_valobj,
   3,
   NAME,
-  "name = LEFT('%s',SIZE(name))",
+  "name = '%s'",
   1,
   MACH_ID,
   access_ahal,
@@ -921,16 +982,16 @@ static struct validate ahal_validate = {
 };
 
 static struct valobj dhal_valobj[] = {
-    {V_UPWILD, 0},
-    {V_LOCK, 0, MACHINE, 0, MACH_ID, MR_DEADLOCK},
-    {V_ID, 1, MACHINE, NAME, MACH_ID, MR_MACHINE},
+  {V_UPWILD, 0},
+  {V_LOCK, 0, MACHINE_TABLE, 0, MACH_ID, MR_DEADLOCK},
+  {V_ID, 1, MACHINE_TABLE, NAME, MACH_ID, MR_MACHINE},
 };
 
 static struct validate dhal_validate = {
   dhal_valobj,
   3,
   NAME,
-  "name = LEFT('%s',SIZE(name)) AND mach_id = %d",
+  "name = '%s' AND mach_id = %d",
   2,
   MACH_ID,
   access_ahal,
@@ -945,13 +1006,16 @@ static char *gsnt_fields[] = {
 };
 
 static struct valobj gsnt_valobj[] = {
+  {V_RLOCK, 0, USERS_TABLE, 0, USERS_ID, MR_DEADLOCK},
+  {V_RLOCK, 0, SUBNET_TABLE, 0, SNET_ID, MR_DEADLOCK},
+  {V_RLOCK, 0, LIST_TABLE, 0, LIST_ID, MR_DEADLOCK},
   {V_UPWILD, 0},
   {V_SORT, 0},
 };
 
 static struct validate gsnt_validate = {
   gsnt_valobj,
-  2,
+  5,
   0,
   0,
   0,
@@ -966,18 +1030,22 @@ static char *asnt_fields[] = {
 };
 
 static struct valobj asnt_valobj[] = {
-  {V_LOCK, 0, SUBNET, 0, SNET_ID, MR_DEADLOCK},
-  {V_CHAR, 0},
-  {V_TYPE, 7, ACE_TYPE, 0, 0, MR_ACE},
+  {V_RLOCK, 0, USERS_TABLE, 0, USERS_ID, MR_DEADLOCK},
+  {V_LOCK, 0, SUBNET_TABLE, 0, SNET_ID, MR_DEADLOCK},
+  {V_RLOCK, 0, LIST_TABLE, 0, LIST_ID, MR_DEADLOCK},
+  {V_CHAR, 0, SUBNET_TABLE, NAME},
+  {V_LEN, 1, SUBNET_TABLE, DESC},
+  {V_LEN, 6, SUBNET_TABLE, "prefix"},
+  {V_TYPE, 7, 0, ACE_TYPE, 0, MR_ACE},
   {V_TYPEDATA, 8, 0, 0, 0, MR_ACE},
 };
 
 static struct validate asnt_validate = 
 {
     asnt_valobj,
-    4,
+    8,
     NAME,
-    "name = uppercase(LEFT('%s',SIZE(name)))",
+    "name = UPPER('%s')",
     1,
     SNET_ID,
     0,
@@ -991,17 +1059,21 @@ static char *usnt_fields[] = {
 };
 
 static struct valobj usnt_valobj[] = {
-  {V_LOCK, 0, SUBNET, 0, SNET_ID, MR_DEADLOCK},
-  {V_ID, 0, SUBNET, NAME, SNET_ID, MR_NO_MATCH},
-  {V_RENAME, 1, SUBNET, NAME, SNET_ID, MR_NOT_UNIQUE},
-  {V_TYPE, 8, ACE_TYPE, 0, 0, MR_ACE},
+  {V_RLOCK, 0, USERS_TABLE, 0, USERS_ID, MR_DEADLOCK},
+  {V_LOCK, 0, SUBNET_TABLE, 0, SNET_ID, MR_DEADLOCK},
+  {V_RLOCK, 0, LIST_TABLE, 0, LIST_ID, MR_DEADLOCK},
+  {V_ID, 0, SUBNET_TABLE, NAME, SNET_ID, MR_NO_MATCH},
+  {V_RENAME, 1, SUBNET_TABLE, NAME, SNET_ID, MR_NOT_UNIQUE},
+  {V_LEN, 2, SUBNET_TABLE, DESC},
+  {V_LEN, 7, SUBNET_TABLE, "prefix"},
+  {V_TYPE, 8, 0, ACE_TYPE, 0, MR_ACE},
   {V_TYPEDATA, 9, 0, 0, 0, MR_ACE},
 };
 
 static struct validate usnt_validate = 
 {
     usnt_valobj,
-    5,
+    9,
     NAME,
     "snet_id = %d",
     1,
@@ -1016,13 +1088,14 @@ static char *dsnt_fields[] = {
 };
 
 static struct valobj dsnt_valobj[] = {
-  {V_LOCK, 0, SUBNET, 0, SNET_ID, MR_DEADLOCK},
-  {V_ID, 0, SUBNET, NAME, SNET_ID, MR_SUBNET},
+  {V_RLOCK, 0, MACHINE_TABLE, 0, MACH_ID, MR_DEADLOCK},
+  {V_LOCK, 0, SUBNET_TABLE, 0, SNET_ID, MR_DEADLOCK},
+  {V_ID, 0, SUBNET_TABLE, NAME, SNET_ID, MR_SUBNET},
 };
 
 static struct validate dsnt_validate = {
   dsnt_valobj,
-  2,
+  3,
   0,
   0,
   0,
@@ -1042,16 +1115,18 @@ static char *aclu_fields[] = {
 };
 
 static struct valobj aclu_valobj[] = {
-  {V_LOCK, 0, CLUSTER, 0, CLU_ID, MR_DEADLOCK},
-  {V_CHAR, 0}
+  {V_LOCK, 0, CLUSTER_TABLE, 0, CLU_ID, MR_DEADLOCK},
+  {V_CHAR, 0, CLUSTER_TABLE, NAME},
+  {V_LEN, 1, CLUSTER_TABLE, DESC},
+  {V_LEN, 2, CLUSTER_TABLE, LOCATION},
 };
 
 static struct validate aclu_validate = 
 {
   aclu_valobj,
-  2,
+  4,
   NAME,
-  "name = LEFT('%s',SIZE(name))",
+  "name = '%s'",
   1,
   CLU_ID,
   0,
@@ -1065,14 +1140,16 @@ static char *uclu_fields[] = {
 };
 
 static struct valobj uclu_valobj[] = {
-  {V_LOCK, 0, CLUSTER, 0, CLU_ID, MR_DEADLOCK},
-  {V_ID, 0, CLUSTER, NAME, CLU_ID, MR_CLUSTER},
-  {V_RENAME, 1, CLUSTER, NAME, CLU_ID, MR_NOT_UNIQUE},
+  {V_LOCK, 0, CLUSTER_TABLE, 0, CLU_ID, MR_DEADLOCK},
+  {V_ID, 0, CLUSTER_TABLE, NAME, CLU_ID, MR_CLUSTER},
+  {V_RENAME, 1, CLUSTER_TABLE, NAME, CLU_ID, MR_NOT_UNIQUE},
+  {V_LEN, 2, CLUSTER_TABLE, DESC},
+  {V_LEN, 3, CLUSTER_TABLE, LOCATION},
 };
 
 static struct validate uclu_validate = {
   uclu_valobj,
-  3,
+  5,
   0,
   0,
   0,
@@ -1115,8 +1192,8 @@ static struct validate gmcm_validate = { gmcm_valobj, 4 };
 
 static struct valobj amtc_valobj[] =   /* ADD_MACHINE_TO_CLUSTER */
 {                                      /* DELETE_MACHINE_FROM_CLUSTER */
-  {V_ID, 0, MACHINE, NAME, MACH_ID, MR_MACHINE},
-  {V_ID, 1, CLUSTER, NAME, CLU_ID, MR_CLUSTER},
+  {V_ID, 0, MACHINE_TABLE, NAME, MACH_ID, MR_MACHINE},
+  {V_ID, 1, CLUSTER_TABLE, NAME, CLU_ID, MR_CLUSTER},
 };
 
 static struct validate amtc_validate = /* for amtc and dmfc */
@@ -1143,9 +1220,9 @@ static char *acld_fields[] = {
 
 static struct valobj acld_valobj[] =
 {
-  {V_ID, 0, CLUSTER, NAME, CLU_ID, MR_CLUSTER},
-  {V_CHAR, 1},
-  {V_CHAR, 2},
+  {V_ID, 0, CLUSTER_TABLE, NAME, CLU_ID, MR_CLUSTER},
+  {V_CHAR, 1, SVC_TABLE, "serv_label"},
+  {V_CHAR, 2, SVC_TABLE, "serv_cluster"}
 };
 
 static struct validate acld_validate = 
@@ -1153,7 +1230,7 @@ static struct validate acld_validate =
   acld_valobj,
   3,
   CLU_ID,
-  "clu_id = %d AND serv_label = '%s' AND serv_cluster = LEFT('%s',SIZE(serv_cluster))",
+  "clu_id = %d AND serv_label = '%s' AND serv_cluster = '%s'",
   3,
   0,
   0,
@@ -1163,14 +1240,13 @@ static struct validate acld_validate =
 
 static struct valobj dcld_valobj[] =
 {
-  {V_ID, 0, CLUSTER, NAME, CLU_ID, MR_CLUSTER},
-  {V_CHAR, 2},
+  {V_ID, 0, CLUSTER_TABLE, NAME, CLU_ID, MR_CLUSTER},
 };
 
 static struct validate dcld_validate = 
 {                                      
   dcld_valobj,
-  2,
+  1,
   CLU_ID,
   "clu_id = %d AND serv_label = '%s' AND serv_cluster = '%s'",
   3,
@@ -1180,587 +1256,520 @@ static struct validate dcld_validate =
   set_cluster_modtime_by_id,
 };
 
-static char *gsin_fields[] = {
-  SERVICE,
-  SERVICE, "update_int", "target_file", "script", "dfgen", "dfcheck",
-  TYPE, "enable", "inprogress", "harderror", "errmsg",
-  ACE_TYPE, ACE_NAME, MOD1, MOD2, MOD3,
-};
-
-static struct valobj gsin_valobj[] =
-{
-  { V_UPWILD, 0 },
+static char *glin_fields[] = {
+  NAME,
+  NAME, "active", "publicflg", "hidden", "maillist", "grouplist", "gid",
+  ACE_TYPE, ACE_NAME, DESC, MOD1, MOD2, MOD3,
 };
 
-static struct validate gsin_validate = 
-{
-  gsin_valobj,
-  1,
-  0,
-  0,
-  0,
-  0,
-  access_service,
+static struct validate glin_validate = {
   0,
-  followup_glin,
-};
-
-static char *qgsv_fields[] = {
-  "enable", "inprogress", "harderror",
-  "service",
-};
-
-static struct valobj qgsv_valobj[] = {
-  {V_TYPE, 0, "boolean", 0, 0, MR_TYPE},
-  {V_TYPE, 1, "boolean", 0, 0, MR_TYPE},
-  {V_TYPE, 2, "boolean", 0, 0, MR_TYPE},
-};
-
-static struct validate qgsv_validate = {
-  qgsv_valobj,
-  3,
   0,
   0,
   0,
   0,
   0,
+  access_vis_list_by_name,
   0,
-  qualified_get_server,
+  get_list_info,
 };
 
-static char *asin_fields[] = {
-  SERVICE, "update_int", "target_file", "script", TYPE, "enable",
-  ACE_TYPE, ACE_NAME,
+static char *alis_fields[] = {
+  NAME, "active", "publicflg", "hidden", "maillist", "grouplist", "gid",
+  ACE_TYPE, ACE_NAME, DESC,
 };
 
-static struct valobj asin_valobj[] = {
-  {V_LOCK, 0, MACHINE, 0, MACH_ID, MR_DEADLOCK},
-  {V_CHAR, 0},
-  {V_TYPE, 4, "service", 0, 0, MR_TYPE},
-  {V_TYPE, 6, ACE_TYPE, 0, 0, MR_ACE},
-  {V_TYPEDATA, 7, 0, 0, 0, MR_ACE},
+static struct valobj alis_valobj[] = {
+  {V_RLOCK, 0, USERS_TABLE, 0, USERS_ID, MR_DEADLOCK},
+  {V_LOCK, 0, LIST_TABLE, 0, LIST_ID, MR_DEADLOCK},
+  {V_CHAR, 0, LIST_TABLE, NAME},
+  {V_TYPE, 7, 0, ACE_TYPE, 0, MR_ACE},
+  {V_TYPEDATA, 8, 0, 0, LIST_ID, MR_ACE},
+  {V_LEN, 9, LIST_TABLE, DESC},
 };
 
-static struct validate asin_validate = /* for asin, usin */
-{
-  asin_valobj,
-  5,
+static struct validate alis_validate = {
+  alis_valobj,
+  6,
   NAME,
-  "name = uppercase(LEFT('%s',SIZE(name)))",
+  "name = '%s'",
   1,
+  LIST_ID,
   0,
-  0,
-  0,
-  set_uppercase_modtime,
+  setup_alis,
+  set_modtime,
 };
 
-static struct validate rsve_validate = {
-  asin_valobj,
-  1,
+static char *ulis_fields[] = {
   NAME,
-  "name = uppercase('%s')",
-  1,
-  0,
-  access_service,
-  0,
-  set_uppercase_modtime,
+  "newname", "active", "publicflg", "hidden", "maillist", "grouplist", "gid",
+  ACE_TYPE, ACE_NAME, DESC,
 };
 
-static char *ssif_fields[] = {
-  SERVICE, "dfgen", "dfcheck", "inprogress", "harderror", "errmsg",
+static struct valobj ulis_valobj[] = {
+  {V_RLOCK, 0, USERS_TABLE, 0, USERS_ID, MR_DEADLOCK},
+  {V_LOCK, 0, LIST_TABLE, 0, LIST_ID, MR_DEADLOCK},
+  {V_ID, 0, LIST_TABLE, NAME, LIST_ID, MR_LIST},
+  {V_RENAME, 1, LIST_TABLE, NAME, LIST_ID, MR_NOT_UNIQUE},
+  {V_TYPEDATA, 9, 0, 0, LIST_ID, MR_ACE},
+  {V_CHAR, 1, LIST_TABLE, NAME},
+  {V_LEN, 10, LIST_TABLE, DESC},
 };
 
-static struct validate ssif_validate = {
-  asin_valobj,
-  1,
+static struct validate ulis_validate = {
+  ulis_valobj,
+  7,
   NAME,
-  "name = uppercase('%s')",
+  "list_id = %d",
   1,
-  0,
-  0,
-  0,
-  0,
+  LIST_ID,
+  access_list,
+  setup_alis,
+  set_modtime_by_id,
 };
 
-static char *dsin_fields[] = {
-  SERVICE,
+static char *dlis_fields[] = {
+  NAME,
 };
 
-static struct validate dsin_validate = {
-  asin_valobj,
-  1,
+static struct valobj dlis_valobj[] ={
+  {V_RLOCK, 0, CAPACLS_TABLE, 0, LIST_ID, MR_DEADLOCK},
+  {V_RLOCK, 0, IMEMBERS_TABLE, 0, LIST_ID, MR_DEADLOCK},
+  {V_RLOCK, 0, FILESYS_TABLE, 0, FILSYS_ID, MR_DEADLOCK},
+  {V_LOCK, 0, LIST_TABLE, 0, LIST_ID, MR_DEADLOCK},
+  {V_RLOCK, 0, QUOTA_TABLE, 0, FILSYS_ID, MR_DEADLOCK},
+  {V_RLOCK, 0, ZEPHYR_TABLE, 0, ZEPH_ID, MR_DEADLOCK},  
+  {V_RLOCK, 0, HOSTACCESS_TABLE, 0, MACH_ID, MR_DEADLOCK},
+  {V_ID, 0, LIST_TABLE, NAME, LIST_ID, MR_LIST}
+};
+
+static struct validate dlis_validate = {
+  dlis_valobj,
+  8,
   NAME,
-  "name = uppercase('%s')",
+  "list_id = %d",
   1,
   0,
-  0,
-  setup_dsin,
+  access_list,
+  setup_dlis,
   0,
 };
 
-static char *gshi_fields[] = {
-  SERVICE, MACHINE,
-  SERVICE, MACHINE, "enable", "override", "success", "inprogress",
-  "hosterror", "hosterrormsg", "ltt", "lts", "value1", "value2",
-  "value3", MOD1, MOD2, MOD3, 
+static char *amtl_fields[] = {
+  "list_name", "member_type", "member_name",
 };
 
-static struct valobj gshi_valobj[] = {
-  { V_UPWILD, 0 },
-  { V_UPWILD, 1 },
+static struct valobj amtl_valobj[] = {
+  {V_RLOCK, 0, USERS_TABLE, 0, USERS_ID, MR_DEADLOCK},
+  {V_LOCK, 0, LIST_TABLE, 0, LIST_ID, MR_DEADLOCK},
+  {V_ID, 0, LIST_TABLE, NAME, LIST_ID, MR_LIST},
+  {V_TYPE, 1, 0, "member", 0, MR_TYPE},
+  {V_TYPEDATA, 2, 0, 0, 0, MR_NO_MATCH},
 };
 
-static struct validate gshi_validate = {
-  gshi_valobj,
-  2,
+static struct validate amtl_validate =
+{
+  amtl_valobj,
+  5,
   0,
   0,
   0,
   0,
-  access_service,
+  access_list,
   0,
-  followup_fix_modby,
-};
-
-static char *qgsh_fields[] = {
-  "service", "enable", "override", "success", "inprogress", "hosterror",
-  "service", MACHINE,
-};
-
-static struct valobj qgsh_valobj[] = {
-  {V_TYPE, 1, "boolean", 0, 0, MR_TYPE},
-  {V_TYPE, 2, "boolean", 0, 0, MR_TYPE},
-  {V_TYPE, 3, "boolean", 0, 0, MR_TYPE},
-  {V_TYPE, 4, "boolean", 0, 0, MR_TYPE},
-  {V_TYPE, 5, "boolean", 0, 0, MR_TYPE},
+  add_member_to_list,
 };
 
-static struct validate qgsh_validate = {
-  qgsh_valobj,
+static struct validate dmfl_validate =
+{
+  amtl_valobj,
   5,
   0,
   0,
   0,
   0,
+  access_list,
   0,
-  0,
-  qualified_get_serverhost,
+  delete_member_from_list,
 };
 
-static char *ashi_fields[] = {
-  SERVICE, MACHINE, "enable", "value1", "value2", "value3",
+static char *gaus_fields[] = {
+  ACE_TYPE, ACE_NAME,
+  "use_type", "use_name",
 };
 
-static struct valobj ashi_valobj[] = {
-  {V_LOCK, 0, MACHINE, 0, MACH_ID, MR_DEADLOCK},
-  {V_NAME, 0, "servers", NAME, 0, MR_SERVICE},
-  {V_ID, 1, MACHINE, NAME, MACH_ID, MR_MACHINE},
+static struct valobj gaus_valobj[] = {
+  {V_RLOCK, 0, FILESYS_TABLE, 0, FILSYS_ID, MR_DEADLOCK},
+  {V_RLOCK, 0, USERS_TABLE, 0, USERS_ID, MR_DEADLOCK},
+  {V_RLOCK, 0, LIST_TABLE, 0, LIST_ID, MR_DEADLOCK},
+  {V_RLOCK, 0, ZEPHYR_TABLE, 0, ZEPH_ID, MR_DEADLOCK},
+  {V_RLOCK, 0, HOSTACCESS_TABLE, 0, MACH_ID, MR_DEADLOCK},
+  {V_TYPE, 0, 0, "gaus", 0, MR_TYPE},
+  {V_TYPEDATA, 1, 0, 0, 0, MR_NO_MATCH},
 };
 
-static struct validate ashi_validate = /* ashi & ushi */
-{
-  ashi_valobj,
-  3,
-  SERVICE,
-  "service = uppercase(LEFT('%s',SIZE(service))) AND mach_id = %d",
-  2,
-  0,
-  access_service,
+static struct validate gaus_validate = {
+  gaus_valobj,
+  7,
   0,
-  set_serverhost_modtime,
-};
-
-static struct validate rshe_validate = 
-{
-  ashi_valobj,
-  3,
-  SERVICE,
-  "service = uppercase('%s') AND mach_id = %d",
-  2,
   0,
-  access_service,
   0,
-  set_serverhost_modtime,
-};
-
-static struct validate ssho_validate = 
-{
-  ashi_valobj,
-  3,
-  SERVICE,
-  "service = uppercase('%s') AND mach_id = %d",
-  2,
   0,
-  access_service,
+  access_member,
   0,
-  trigger_dcm,
+  get_ace_use,
 };
 
-static char *sshi_fields[] = {
-  "service", MACHINE, "override", "success", "inprogress",
-  "hosterror", "errmsg", "ltt", "lts",
+static char *qgli_fields[] = {
+  "active", "publicflg", "hidden", "maillist", "grouplist",
+  "list",
 };
 
-static struct valobj sshi_valobj[] = {
-  {V_NAME, 0, "servers", NAME, 0, MR_SERVICE},
-  {V_ID, 1, MACHINE, NAME, MACH_ID, MR_MACHINE},  /** Was this ok to add? */
+static struct valobj qgli_valobj[] = {
+  {V_TYPE, 0, 0, "boolean", 0, MR_TYPE},
+  {V_TYPE, 1, 0, "boolean", 0, MR_TYPE},
+  {V_TYPE, 2, 0, "boolean", 0, MR_TYPE},
+  {V_TYPE, 3, 0, "boolean", 0, MR_TYPE},
+  {V_TYPE, 4, 0, "boolean", 0, MR_TYPE},
 };
 
-static struct validate sshi_validate = 
-{
-  sshi_valobj,
-  2,
-  0,
+static struct validate qgli_validate = {
+  qgli_valobj,
+  5,
   0,
   0,
   0,
   0,
-  setup_sshi,
+  access_qgli,
   0,
+  qualified_get_lists,
 };
 
-static char *dshi_fields[] = {
-  SERVICE, MACHINE,
+static char *gmol_fields[] = {
+  "list_name",
+  "member_type", "member_name",
 };
 
-static struct validate dshi_validate = 
-{
-  ashi_valobj,
+static struct valobj gmol_valobj[]={
+  {V_LOCK, 0, IMEMBERS_TABLE, 0, LIST_ID, MR_DEADLOCK},
+  {V_RLOCK, 0, USERS_TABLE, 0, USERS_ID, MR_DEADLOCK},
+  {V_ID, 0, LIST_TABLE, NAME, LIST_ID, MR_LIST},
+
+};
+static struct validate gmol_validate = {
+ gmol_valobj,
   3,
-  SERVICE,
-  "service = uppercase('%s') AND mach_id = %d",
-  2,
   0,
-  access_service,
-  setup_dshi,
   0,
+  0,
+  0,
+  access_visible_list,
+  0,
+  get_members_of_list,
 };
 
-static char *gsha_fields[] = {
-  MACHINE,
-  MACHINE, ACE_TYPE, ACE_NAME, MOD1, MOD2, MOD3,
-};
-
-static struct validate gsha_validate = 
-{
-  VOupwild0,
-  1,
-  0,
+static struct validate geml_validate = {
+  gmol_valobj,
+  3,
   0,
   0,
   0,
   0,
+  access_visible_list,
   0,
-  followup_gsha,
+  get_end_members_of_list,
 };
 
-static char *asha_fields[] = {
-  MACHINE, ACE_TYPE, ACE_NAME,
+static char *glom_fields[] = {
+  "member_type", "member_name",
+  "list_name", "active", "publicflg", "hidden", "maillist", "grouplist",
 };
 
-static struct valobj asha_valobj[] = {
-  {V_ID, 0, MACHINE, NAME, MACH_ID, MR_MACHINE},
-  {V_TYPE, 1, ACE_TYPE, 0, 0, MR_ACE},
-  {V_TYPEDATA, 2, 0, 0, 0, MR_ACE},
+static struct valobj glom_valobj[] = {
+   {V_LOCK, 0, IMEMBERS_TABLE, 0, LIST_ID, MR_DEADLOCK},
+   {V_RLOCK, 0, USERS_TABLE, 0, USERS_ID, MR_DEADLOCK},
+   {V_RLOCK, 0, LIST_TABLE, 0, LIST_ID, MR_DEADLOCK},
+   {V_TYPE, 0, 0, "rmember", 0, MR_TYPE},
+   {V_TYPEDATA, 1, 0, 0, 0, MR_NO_MATCH},
+   {V_SORT, 0},
 };
 
-static struct validate asha_validate = 
-{
-  asha_valobj,
-  3,
-  MACH_ID,
-  "mach_id = %d",
-  1,
-  MACH_ID,
+static struct validate glom_validate = {
+  glom_valobj,
+  6,
   0,
   0,
-  set_modtime_by_id,
-};
-
-static char *gslo_fields[] = {
-  "server",
-  "server", MACHINE,
-};
-
-static char *gfsl_fields[] = {
-  LABEL,
-  LABEL, TYPE, MACHINE, NAME, "mount", "access", COMMENTS, "owner", "owners",
-  "create", "lockertype", MOD1, MOD2, MOD3,
+  0,
+  0,
+  access_member,
+  0,
+  get_lists_of_member,
 };
 
-static char *gfsm_fields[] = {
-  MACHINE,
-  LABEL, TYPE, MACHINE, NAME, "mount", "access", COMMENTS, "owner", "owners",
-  "create", "lockertype", MOD1, MOD2, MOD3,
+static char *cmol_fields[] = {
+  "list_name",
+  "count",
 };
 
-static struct validate gfsm_validate = {
-  VOmach0,
+static struct validate cmol_validate = {
+  VOlist0,
   1,
   0,
   0,
   0,
   0,
+  access_visible_list,
   0,
-  0,
-  followup_fix_modby,
+  count_members_of_list,
 };
 
-static char *gfsn_fields[] = {
-  MACHINE, "parition",
-  LABEL, TYPE, MACHINE, NAME, "mount", "access", COMMENTS, "owner", "owners",
-  "create", "lockertype", MOD1, MOD2, MOD3,
+static char *gsin_fields[] = {
+  SERVICE,
+  SERVICE, "update_int", "target_file", "script", "dfgen", "dfcheck",
+  TYPE, "enable", "inprogress", "harderror", "errmsg",
+  ACE_TYPE, ACE_NAME, MOD1, MOD2, MOD3,
 };
 
-static struct valobj gfsn_valobj[] =
+static struct valobj gsin_valobj[] =
 {
-  {V_ID, 0, MACHINE, NAME, MACH_ID, MR_MACHINE},
-  {V_WILD, 1},
+  {V_RLOCK, 0, USERS_TABLE, 0, USERS_ID, MR_DEADLOCK},
+  {V_RLOCK, 0, LIST_TABLE, 0, LIST_ID, MR_DEADLOCK},
+  {V_UPWILD, 0 },
 };
 
-static struct validate gfsn_validate = {
-  gfsn_valobj,
-  2,
-  0,
+static struct validate gsin_validate = 
+{
+  gsin_valobj,
+  3,
   0,
   0,
   0,
   0,
+  access_service,
   0,
-  followup_fix_modby,
+  followup_glin,
 };
 
-static char *gfsp_fields[] = {
-  "path",
-  LABEL, TYPE, MACHINE, NAME, "mount", "access", COMMENTS, "owner", "owners",
-  "create", "lockertype", MOD1, MOD2, MOD3,
+static char *qgsv_fields[] = {
+  "enable", "inprogress", "harderror",
+  "service",
 };
 
-static char *gfsg_fields[] = {
-  LIST,
-  LABEL, TYPE, MACHINE, NAME, "mount", "access", COMMENTS, "owner", "owners",
-  "create", "lockertype", MOD1, MOD2, MOD3,
+static struct valobj qgsv_valobj[] = {
+  {V_TYPE, 0, 0, "boolean", 0, MR_TYPE},
+  {V_TYPE, 1, 0, "boolean", 0, MR_TYPE},
+  {V_TYPE, 2, 0, "boolean", 0, MR_TYPE},
 };
 
-static struct validate gfsg_validate = {
-  VOlist0,
-  1,
+static struct validate qgsv_validate = {
+  qgsv_valobj,
+  3,
   0,
   0,
   0,
   0,
-  access_list,
   0,
-  followup_fix_modby,
+  0,
+  qualified_get_server,
 };
 
-static char *afil_fields[] = {
-  LABEL, TYPE, MACHINE, NAME, "mount", "access", COMMENTS, "owner", "owners",
-  "create", "lockertype",
+static char *asin_fields[] = {
+  SERVICE, "update_int", "target_file", "script", TYPE, "enable",
+  ACE_TYPE, ACE_NAME,
 };
 
-static struct valobj afil_valobj[] = {
-  {V_CHAR, 0},
-  {V_LOCK, 0, FILESYS, 0, FILSYS_ID, MR_DEADLOCK},
-  {V_TYPE, 1, FILESYS, 0, 0, MR_FSTYPE},
-  {V_ID, 2, MACHINE, NAME, MACH_ID, MR_MACHINE},
-  {V_CHAR, 3},
-  {V_ID, 7, USERS, LOGIN, USERS_ID, MR_USER},
-  {V_ID, 8, LIST, NAME, LIST_ID, MR_LIST},
-  {V_TYPE, 10, "lockertype", 0, 0, MR_TYPE}
+static struct valobj asin_valobj[] = {
+  {V_RLOCK, 0, USERS_TABLE, 0, USERS_ID, MR_DEADLOCK},
+  {V_LOCK, 0, MACHINE_TABLE, 0, MACH_ID, MR_DEADLOCK},
+  {V_RLOCK, 0, LIST_TABLE, 0, LIST_ID, MR_DEADLOCK},
+  {V_CHAR, 0, SERVERS_TABLE, SERVICE},
+  {V_LEN, 2, SERVERS_TABLE, "target_file"},
+  {V_LEN, 3, SERVERS_TABLE, "script"},
+  {V_TYPE, 4, 0, "service", 0, MR_TYPE},
+  {V_TYPE, 6, 0, ACE_TYPE, 0, MR_ACE},
+  {V_TYPEDATA, 7, 0, 0, 0, MR_ACE},
 };
 
-static struct validate afil_validate = {
-  afil_valobj,
-  8,
-  LABEL,
-  "label = LEFT('%s',SIZE(label))",
+static struct validate asin_validate = /* for asin, usin */
+{
+  asin_valobj,
+  9,
+  NAME,
+  "name = UPPER('%s')",
   1,
-  FILSYS_ID,
   0,
-  setup_afil,
-  set_filesys_modtime,
-};
-
-static char *ufil_fields[] = {
-  LABEL, "newlabel", TYPE, MACHINE, NAME, "mount", "access", COMMENTS,
-  "owner", "owners", "create", "lockertype",
-};
-
-static struct valobj ufil_valobj[] = {
-  {V_LOCK, 0, FILESYS, 0, FILSYS_ID, MR_DEADLOCK},
-  {V_ID, 0, FILESYS, LABEL, FILSYS_ID, MR_FILESYS},
-  {V_RENAME, 1, FILESYS, LABEL, FILSYS_ID, MR_NOT_UNIQUE},
-  {V_TYPE, 2, FILESYS, 0, 0, MR_FSTYPE},
-  {V_ID, 3, MACHINE, NAME, MACH_ID, MR_MACHINE},
-  {V_CHAR, 4},
-  {V_ID, 8, USERS, LOGIN, USERS_ID, MR_USER},
-  {V_ID, 9, LIST, NAME, LIST_ID, MR_LIST},
-  {V_TYPE, 11, "lockertype", 0, 0, MR_TYPE}
+  0,
+  0,
+  set_uppercase_modtime,
 };
 
-static struct validate ufil_validate = {
-  ufil_valobj,
-  9,
-  LABEL,
-  "filsys_id = %d",
+static struct validate rsve_validate = {
+  asin_valobj,
+  3,
+  NAME,
+  "name = UPPER('%s')",
   1,
-  FILSYS_ID,
   0,
-  setup_ufil,
-  set_filesys_modtime,
+  access_service,
+  0,
+  set_uppercase_modtime,
 };
 
-static char *dfil_fields[] = {
-  LABEL,
+static char *ssif_fields[] = {
+  SERVICE, "dfgen", "dfcheck", "inprogress", "harderror", "errmsg",
 };
 
-static struct valobj dfil_valobj[] = {
-  {V_LOCK, 0, FILESYS, 0, FILSYS_ID, MR_DEADLOCK},
-  {V_ID, 0, FILESYS, LABEL, FILSYS_ID, MR_FILESYS},
+static struct valobj ssif_valobj[] = {
+  {V_RLOCK, 0, USERS_TABLE, 0, USERS_ID, MR_DEADLOCK},
+  {V_LOCK, 0, MACHINE_TABLE, 0, MACH_ID, MR_DEADLOCK},
+  {V_RLOCK, 0, LIST_TABLE, 0, LIST_ID, MR_DEADLOCK},
+  {V_LEN, 5, SERVERS_TABLE, "errmsg"},
 };
 
-static struct validate dfil_validate = {
-  dfil_valobj,
-  2,
-  "label",
-  "filsys_id = %d",
+static struct validate ssif_validate = {
+  ssif_valobj,
+  4,
+  NAME,
+  "name = UPPER('%s')",
   1,
   0,
   0,
-  setup_dfil,
+  0,
   0,
 };
 
-static char *gfgm_fields[] = {
-  "fsgroup", FILESYS, "sortkey"
-    };
-
-static struct valobj gfgm_valobj[] = {
-  {V_ID, 0, FILESYS, LABEL, FILSYS_ID, MR_FILESYS},
-  {V_SORT, 1},
-  {V_SORT, 0},
+static char *dsin_fields[] = {
+  SERVICE,
 };
 
-static struct validate gfgm_validate = {
-  gfgm_valobj,
+static struct validate dsin_validate = {
+  asin_valobj,
   3,
+  NAME,
+  "name = UPPER('%s')",
+  1,
   0,
   0,
-  0,
-  0,
-  0,
-  0,
+  setup_dsin,
   0,
 };
 
-static struct valobj aftg_valobj[] = {
-  {V_LOCK, 0, FILESYS, 0, FILSYS_ID, MR_DEADLOCK},
-  {V_ID, 0, FILESYS, LABEL, FILSYS_ID, MR_FILESYS},
-  {V_ID, 1, FILESYS, LABEL, FILSYS_ID, MR_FILESYS},
+static char *gshi_fields[] = {
+  SERVICE, MACHINE,
+  SERVICE, MACHINE, "enable", "override", "success", "inprogress",
+  "hosterror", "hosterrormsg", "ltt", "lts", "value1", "value2",
+  "value3", MOD1, MOD2, MOD3, 
 };
 
-static struct validate aftg_validate = {
-  aftg_valobj,
-  3,
-  "group_id",
-  "group_id = %d and filsys_id = %d",
+static struct valobj gshi_valobj[] = {
+  { V_UPWILD, 0 },
+  { V_UPWILD, 1 },
+};
+
+static struct validate gshi_validate = {
+  gshi_valobj,
   2,
   0,
   0,
   0,
   0,
+  access_service,
+  0,
+  followup_fix_modby,
 };
 
-static char *ganf_fields[] = {
-  MACHINE, DIR, DEVICE, STATUS, "allocated", "size", MOD1, MOD2, MOD3,
-};
-
-static char *gnfp_fields[] = {
-  MACHINE, DIR,
-  MACHINE, DIR, DEVICE, STATUS, "allocated", "size", MOD1, MOD2, MOD3,
+static char *qgsh_fields[] = {
+  "service", "enable", "override", "success", "inprogress", "hosterror",
+  "service", MACHINE,
 };
 
-static struct valobj gnfp_valobj[] = {
-  {V_ID, 0, MACHINE, NAME, MACH_ID, MR_MACHINE},
-  {V_WILD, 1},
+static struct valobj qgsh_valobj[] = {
+  {V_TYPE, 1, 0, "boolean", 0, MR_TYPE},
+  {V_TYPE, 2, 0, "boolean", 0, MR_TYPE},
+  {V_TYPE, 3, 0, "boolean", 0, MR_TYPE},
+  {V_TYPE, 4, 0, "boolean", 0, MR_TYPE},
+  {V_TYPE, 5, 0, "boolean", 0, MR_TYPE},
 };
 
-static struct validate gnfp_validate = {
-  gnfp_valobj,
-  2,
+static struct validate qgsh_validate = {
+  qgsh_valobj,
+  5,
   0,
   0,
   0,
   0,
   0,
   0,
-  followup_fix_modby,
+  qualified_get_serverhost,
 };
 
-static struct valobj anfp_valobj[] = {
-  {V_ID, 0, MACHINE, NAME, MACH_ID, MR_MACHINE},
-  {V_CHAR, 1},
+static char *ashi_fields[] = {
+  SERVICE, MACHINE, "enable", "value1", "value2", "value3",
 };
 
-static struct validate anfp_validate = {
-  anfp_valobj,
-  2,
-  DIR,
-  "mach_id = %d and dir = LEFT('%s',SIZE(dir))",
-  2,
-  "nfsphys_id",
-  0,
-  prefetch_value,
-  set_nfsphys_modtime,
+static struct valobj ashi_valobj[] = {
+  {V_LOCK, 0, MACHINE_TABLE, 0, MACH_ID, MR_DEADLOCK},
+  {V_NAME, 0, SERVERS_TABLE, NAME, 0, MR_SERVICE},
+  {V_LOCK, 0, SERVERHOSTS_TABLE,0, MACH_ID, MR_DEADLOCK},
+  {V_ID, 1, MACHINE_TABLE, NAME, MACH_ID, MR_MACHINE},
+  {V_CHAR, 0, SERVERHOSTS_TABLE, NAME},
+  {V_LEN, 5, SERVERHOSTS_TABLE, "value3"},
 };
 
-static struct validate unfp_validate = {
-  anfp_valobj,
-  2,
-  DIR,
-  "mach_id = %d and dir = '%s'",
+static struct validate ashi_validate = /* ashi & ushi */
+{
+  ashi_valobj,
+  6,
+  SERVICE,
+  "service = UPPER('%s') AND mach_id = %d",
   2,
-  "nfsphys_id",
   0,
+  access_service,
   0,
-  set_nfsphys_modtime,
-};
-
-static char *ajnf_fields[] = {
-  MACHINE, DIR, "adjustment",
+  set_serverhost_modtime,
 };
 
-static char *dnfp_fields[] = {
-  MACHINE, DIR,
+static struct validate rshe_validate = 
+{
+  ashi_valobj,
+  4,
+  SERVICE,
+  "service = UPPER('%s') AND mach_id = %d",
+  2,
+  0,
+  access_service,
+  0,
+  set_serverhost_modtime,
 };
 
-static struct validate dnfp_validate = {
-  VOmach0,
-  1,
-  DIR,
-  "mach_id = %d and dir = '%s'",
+static struct validate ssho_validate = 
+{
+  ashi_valobj,
+  4,
+  SERVICE,
+  "service = UPPER('%s') AND mach_id = %d",
   2,
-  "nfsphys_id",
   0,
-  setup_dnfp,
-  set_nfsphys_modtime,
+  access_service,
+  0,
+  trigger_dcm,
 };
 
-static char *gqot_fields[] = {
-  FILESYS, TYPE, NAME,
-  FILESYS, TYPE, NAME, QUOTA, DIR, MACHINE, MOD1, MOD2, MOD3,
+static char *sshi_fields[] = {
+  "service", MACHINE, "override", "success", "inprogress",
+  "hosterror", "errmsg", "ltt", "lts",
 };
 
-static struct valobj gqot_valobj[] = {
-  {V_WILD, 0},
-  {V_TYPE, 1, QUOTA_TYPE, 0, 0, MR_TYPE},
-  {V_TYPEDATA, 2, 0, 0, 0, MR_ACE},
-  {V_SORT, 0, 0, 0, 0, 0},
+static struct valobj sshi_valobj[] = {
+  {V_RLOCK, 0, MACHINE_TABLE, 0, MACH_ID, MR_DEADLOCK},
+  {V_NAME, 0, SERVERS_TABLE, NAME, 0, MR_SERVICE},
+  {V_ID, 1, MACHINE_TABLE, NAME, MACH_ID, MR_MACHINE},  /** Was this ok to add? */
+  {V_LEN, 5, SERVERS_TABLE, "errmsg"},
 };
 
-static struct validate gqot_validate = {
-  gqot_valobj,
+static struct validate sshi_validate = 
+{
+  sshi_valobj,
   4,
   0,
   0,
@@ -1768,377 +1777,498 @@ static struct validate gqot_validate = {
   0,
   0,
   0,
-  followup_gqot,
+  0,
 };
 
-static char *gqbf_fields[] = {
-  FILESYS,
-  FILESYS, TYPE, NAME, QUOTA, DIR, MACHINE, MOD1, MOD2, MOD3,
+static char *dshi_fields[] = {
+  SERVICE, MACHINE,
 };
 
-static struct validate gqbf_validate = {
-  VOwild0sort,
+static struct validate dshi_validate = 
+{
+  ashi_valobj,
+  4,
+  SERVICE,
+  "service = UPPER('%s') AND mach_id = %d",
   2,
   0,
+  access_service,
+  setup_dshi,
   0,
+};
+
+static char *gslo_fields[] = {
+  "server",
+  "server", MACHINE,
+};
+
+static char *gfsl_fields[] = {
+  LABEL,
+  LABEL, TYPE, MACHINE, NAME, "mount", "access", COMMENTS, "owner", "owners",
+  "create", "lockertype", MOD1, MOD2, MOD3,
+};
+
+static char *gfsm_fields[] = {
+  MACHINE,
+  LABEL, TYPE, MACHINE, NAME, "mount", "access", COMMENTS, "owner", "owners",
+  "create", "lockertype", MOD1, MOD2, MOD3,
+};
+
+static struct valobj gfsm_valobj[] = {
+  {V_RLOCK, 0, FILESYS_TABLE, 0, FILSYS_ID, MR_DEADLOCK},
+  {V_ID, 0, MACHINE_TABLE, NAME, MACH_ID, MR_MACHINE},
+};
+
+static struct validate gfsm_validate = {
+  gfsm_valobj,
+  2,
   0,
   0,
-  access_filesys,
   0,
-  followup_gqot,
+  0,
+  0,
+  0,
+  followup_fix_modby,
 };
 
-static char *aqot_fields[] = {
-  FILESYS, TYPE, NAME, QUOTA,
+static char *gfsn_fields[] = {
+  MACHINE, "parition",
+  LABEL, TYPE, MACHINE, NAME, "mount", "access", COMMENTS, "owner", "owners",
+  "create", "lockertype", MOD1, MOD2, MOD3,
 };
 
-static struct valobj aqot_valobj[] = {
-  {V_LOCK, 0, FILESYS, 0, FILSYS_ID, MR_DEADLOCK},
-  {V_ID, 0, FILESYS, LABEL, FILSYS_ID, MR_FILESYS},
-  {V_TYPE, 1, QUOTA_TYPE, 0, 0, MR_TYPE},
-  {V_TYPEDATA, 2, 0, 0, 0, MR_ACE},
+static struct valobj gfsn_valobj[] =
+{
+  {V_RLOCK, 0, FILESYS_TABLE, 0, FILSYS_ID, MR_DEADLOCK},
+  {V_ID, 0, MACHINE_TABLE, NAME, MACH_ID, MR_MACHINE},
+  {V_WILD, 1},
 };
 
-static struct validate aqot_validate = {
-  aqot_valobj,
-  4,
-  FILSYS_ID,
-  "filsys_id = %d and type = '%s' and entity_id = %d",
+static struct validate gfsn_validate = {
+  gfsn_valobj,
   3,
   0,
   0,
-  prefetch_filesys,
-  followup_aqot,
-};
-
-static struct validate uqot_validate = {
-  aqot_valobj,
-  4,
-  FILSYS_ID,
-  "filsys_id = %d AND type = '%s' AND entity_id = %d",
-  3,
   0,
   0,
-  setup_dqot,
-  followup_aqot,
-};
-
-static struct validate dqot_validate = {
-  aqot_valobj,
-  4,
-  FILSYS_ID,
-  "filsys_id = %d AND type = '%s' AND entity_id = %d",
-  3,
   0,
   0,
-  setup_dqot,
-  followup_dqot,
+  followup_fix_modby,
 };
 
-static char *gnfq_fields[] = {
-  FILESYS, LOGIN,
-  FILESYS, LOGIN, QUOTA, DIR, MACHINE, MOD1, MOD2, MOD3,
+static char *gfsp_fields[] = {
+  "path",
+  LABEL, TYPE, MACHINE, NAME, "mount", "access", COMMENTS, "owner", "owners",
+  "create", "lockertype", MOD1, MOD2, MOD3,
 };
 
-static struct validate gnfq_validate = {
-  VOwild0sort,
+static char *gfsg_fields[] = {
+  LIST,
+  LABEL, TYPE, MACHINE, NAME, "mount", "access", COMMENTS, "owner", "owners",
+  "create", "lockertype", MOD1, MOD2, MOD3,
+};
+
+static struct valobj gfsg_valobj[] = {
+  {V_RLOCK, 0, FILESYS_TABLE, 0, FILSYS_ID, MR_DEADLOCK},
+  {V_ID, 0, LIST_TABLE, NAME, LIST_ID, MR_LIST}
+};
+
+static struct validate gfsg_validate = {
+  gfsg_valobj,
   2,
   0,
   0,
   0,
   0,
-  access_filesys,
+  access_list,
   0,
-  followup_gqot,
+  followup_fix_modby,
 };
 
-static char *gnqp_fields[] = {
-  MACHINE, DIR,
-  FILESYS, LOGIN, QUOTA, DIR, MACHINE, MOD1, MOD2, MOD3,
+static char *afil_fields[] = {
+  LABEL, TYPE, MACHINE, NAME, "mount", "access", COMMENTS, "owner", "owners",
+  "create", "lockertype",
 };
 
-static struct valobj gnqp_valobj[] = {
-  {V_ID, 0, MACHINE, NAME, MACH_ID, MR_MACHINE},
-  {V_WILD, 1},
+static struct valobj afil_valobj[] = {
+  {V_LOCK, 0, FILESYS_TABLE, 0, FILSYS_ID, MR_DEADLOCK},
+  {V_RLOCK, 0, USERS_TABLE, 0, USERS_ID, MR_DEADLOCK},
+  {V_RLOCK, 0, MACHINE_TABLE, 0, MACH_ID, MR_DEADLOCK},
+  {V_RLOCK, 0, LIST_TABLE, 0, LIST_ID, MR_DEADLOCK},
+  {V_CHAR, 0, FILESYS_TABLE, LABEL},
+  {V_TYPE, 1, 0, "filesys", 0, MR_FSTYPE},
+  {V_ID, 2, MACHINE_TABLE, NAME, MACH_ID, MR_MACHINE},
+  {V_CHAR, 3, FILESYS_TABLE, NAME},
+  {V_LEN, 4, FILESYS_TABLE, "mount"},
+  {V_LEN, 6, FILESYS_TABLE, COMMENTS},
+  {V_ID, 7, USERS_TABLE, LOGIN, USERS_ID, MR_USER},
+  {V_ID, 8, LIST_TABLE, NAME, LIST_ID, MR_LIST},
+  {V_TYPE, 10, 0, "lockertype", 0, MR_TYPE},
 };
 
-static struct validate gnqp_validate = { gnqp_valobj, 2, };
+static struct validate afil_validate = {
+  afil_valobj,
+  13,
+  LABEL,
+  "label = '%s'",
+  1,
+  FILSYS_ID,
+  0,
+  setup_afil,
+  set_filesys_modtime,
+};
 
-static char *anfq_fields[] = {
-  FILESYS, LOGIN, QUOTA,
+static char *ufil_fields[] = {
+  LABEL, "newlabel", TYPE, MACHINE, NAME, "mount", "access", COMMENTS,
+  "owner", "owners", "create", "lockertype",
 };
 
-static struct validate anfq_validate = {
-  VOfilsys0user1,
-  3,
-  FILSYS_ID,
-  "filsys_id = %d AND type = 'USER' AND entity_id = %d",
-  2,
-  0, /* object ? */
-  0,
-  prefetch_filesys,
-  followup_aqot,
+static struct valobj ufil_valobj[] = {
+  {V_LOCK, 0, FILESYS_TABLE, 0, FILSYS_ID, MR_DEADLOCK},
+  {V_RLOCK, 0, USERS_TABLE, 0, USERS_ID, MR_DEADLOCK},
+  {V_RLOCK, 0, MACHINE_TABLE, 0, MACH_ID, MR_DEADLOCK},
+  {V_RLOCK, 0, LIST_TABLE, 0, LIST_ID, MR_DEADLOCK},
+  {V_LOCK, 0, QUOTA_TABLE, 0, FILSYS_ID, MR_DEADLOCK},
+  {V_ID, 0, FILESYS_TABLE, LABEL, FILSYS_ID, MR_FILESYS},
+  {V_RENAME, 1, FILESYS_TABLE, LABEL, FILSYS_ID, MR_NOT_UNIQUE},
+  {V_TYPE, 2, 0, "filesys", 0, MR_FSTYPE},
+  {V_ID, 3, MACHINE_TABLE, NAME, MACH_ID, MR_MACHINE},
+  {V_CHAR, 4, FILESYS_TABLE, NAME},
+  {V_LEN, 5, FILESYS_TABLE, "mount"},
+  {V_LEN, 7, FILESYS_TABLE, COMMENTS},
+  {V_ID, 8, USERS_TABLE, LOGIN, USERS_ID, MR_USER},
+  {V_ID, 9, LIST_TABLE, NAME, LIST_ID, MR_LIST},
+  {V_TYPE, 11, 0, "lockertype", 0, MR_TYPE},
 };
 
-static struct validate unfq_validate = {
-  VOfilsys0user1,
-  3,
+static struct validate ufil_validate = {
+  ufil_valobj,
+  15,
+  LABEL,
+  "filsys_id = %d",
+  1,
   FILSYS_ID,
-  "filsys_id = %d AND type = 'USER' AND entity_id = %d",
-  2,
   0,
-  0,
-  setup_dqot,
-  followup_aqot,
+  setup_ufil,
+  set_filesys_modtime,
 };
 
-static struct validate dnfq_validate = {
-  VOfilsys0user1,
-  3,
-  FILSYS_ID,
-  "filsys_id = %d AND entity_id = %d",
-  2,
+static char *dfil_fields[] = {
+  LABEL,
+};
+
+static struct valobj dfil_valobj[] = {
+  {V_LOCK, 0, FILESYS_TABLE, 0, FILSYS_ID, MR_DEADLOCK},
+  {V_LOCK, 0, NFSPHYS_TABLE, 0, "nfsphys_id", MR_DEADLOCK},
+  {V_LOCK, 0, QUOTA_TABLE, 0, FILSYS_ID, MR_DEADLOCK},
+  {V_LOCK, 0, FSGROUP_TABLE, 0, "filsys_id", MR_DEADLOCK},
+  {V_ID, 0, FILESYS_TABLE, LABEL, FILSYS_ID, MR_FILESYS},
+};
+
+static struct validate dfil_validate = {
+  dfil_valobj,
+  5,
+  "label",
+  "filsys_id = %d",
+  1,
   0,
   0,
-  setup_dqot,
-  followup_dqot,
+  setup_dfil,
+  0,
 };
 
-static char *glin_fields[] = {
-  NAME,
-  NAME, "active", "publicflg", "hidden", "maillist", "grouplist", "gid",
-  ACE_TYPE, ACE_NAME, DESC, MOD1, MOD2, MOD3,
+static char *gfgm_fields[] = {
+  "fsgroup", FILESYS, "sortkey"
+    };
+
+static struct valobj gfgm_valobj[] = {
+  {V_ID, 0, FILESYS_TABLE, LABEL, FILSYS_ID, MR_FILESYS},
+  {V_SORT, 1},
+  {V_SORT, 0},
 };
 
-static struct validate glin_validate = {
+static struct validate gfgm_validate = {
+  gfgm_valobj,
+  3,
   0,
   0,
   0,
   0,
   0,
   0,
-  access_vis_list_by_name,
   0,
-  get_list_info,
 };
 
-static char *alis_fields[] = {
-  NAME, "active", "publicflg", "hidden", "maillist", "grouplist", "gid",
-  ACE_TYPE, ACE_NAME, DESC,
-};
-
-static struct valobj alis_valobj[] = {
-  {V_LOCK, 0, LIST, 0, LIST_ID, MR_DEADLOCK},
-  {V_CHAR, 0},
-  {V_TYPE, 7, ACE_TYPE, 0, 0, MR_ACE},
-  {V_TYPEDATA, 8, 0, 0, LIST_ID, MR_ACE},
+static struct valobj aftg_valobj[] = {
+  {V_LOCK, 0, FILESYS_TABLE, 0, FILSYS_ID, MR_DEADLOCK},
+  {V_LOCK, 0, FSGROUP_TABLE, 0, "filsys_id", MR_DEADLOCK},
+  {V_ID, 0, FILESYS_TABLE, LABEL, FILSYS_ID, MR_FILESYS},
+  {V_ID, 1, FILESYS_TABLE, LABEL, FILSYS_ID, MR_FILESYS},
 };
 
-static struct validate alis_validate = {
-  alis_valobj,
+static struct validate aftg_validate = {
+  aftg_valobj,
   4,
-  NAME,
-  "name = LEFT('%s',SIZE(name))",
-  1,
-  LIST_ID,
+  "group_id",
+  "group_id = %d and filsys_id = %d",
+  2,
+  0,
+  0,
+  0,
   0,
-  setup_alis,
-  set_modtime,
 };
 
-static char *ulis_fields[] = {
-  NAME,
-  "newname", "active", "publicflg", "hidden", "maillist", "grouplist", "gid",
-  ACE_TYPE, ACE_NAME, DESC,
+static char *ganf_fields[] = {
+  MACHINE, DIR, DEVICE, STATUS, "allocated", "size", MOD1, MOD2, MOD3,
 };
 
-static struct valobj ulis_valobj[] = {
-  {V_LOCK, 0, LIST, 0, LIST_ID, MR_DEADLOCK},
-  {V_ID, 0, LIST, NAME, LIST_ID, MR_LIST},
-  {V_RENAME, 1, LIST, NAME, LIST_ID, MR_NOT_UNIQUE},
-  {V_TYPE, 8, ACE_TYPE, 0, 0, MR_ACE},
-  {V_TYPEDATA, 9, 0, 0, LIST_ID, MR_ACE},
+static char *gnfp_fields[] = {
+  MACHINE, DIR,
+  MACHINE, DIR, DEVICE, STATUS, "allocated", "size", MOD1, MOD2, MOD3,
 };
 
-static struct validate ulis_validate = {
-  ulis_valobj,
-  5,
-  NAME,
-  "list_id = %d",
-  1,
-  LIST_ID,
-  access_list,
-  setup_alis,
-  set_modtime_by_id,
+static struct valobj gnfp_valobj[] = {
+  {V_ID, 0, MACHINE_TABLE, NAME, MACH_ID, MR_MACHINE},
+  {V_RLOCK, 0, NFSPHYS_TABLE, 0, "nfsphys_id", MR_DEADLOCK},
+  {V_WILD, 1},
 };
 
-static char *dlis_fields[] = {
-  NAME,
+static struct validate gnfp_validate = {
+  gnfp_valobj,
+  3,
+  0,
+  0,
+  0,
+  0,
+  0,
+  0,
+  followup_fix_modby,
 };
 
-static struct validate dlis_validate = {
-  VOlist0,
-  1,
-  NAME,
-  "list_id = %d",
-  1,
+static struct valobj anfp_valobj[] = {
+  {V_RLOCK, 0, MACHINE_TABLE, 0, MACH_ID, MR_DEADLOCK},
+  {V_LOCK, 0, NFSPHYS_TABLE, 0, "nfsphys_id", MR_DEADLOCK},
+  {V_ID, 0, MACHINE_TABLE, NAME, MACH_ID, MR_MACHINE},
+  {V_CHAR, 1, NFSPHYS_TABLE, "dir"},
+  {V_LEN, 2, NFSPHYS_TABLE, "device"},
+};
+
+static struct validate anfp_validate = {
+  anfp_valobj,
+  5,
+  DIR,
+  "mach_id = %d and dir = '%s'",
+  2,
+  "nfsphys_id",
   0,
-  access_list,
-  setup_dlis,
+  prefetch_value,
+  set_nfsphys_modtime,
+};
+
+static struct validate unfp_validate = {
+  anfp_valobj,
+  5,
+  DIR,
+  "mach_id = %d and dir = '%s'",
+  2,
+  "nfsphys_id",
   0,
+  0,
+  set_nfsphys_modtime,
 };
 
-static char *amtl_fields[] = {
-  "list_name", "member_type", "member_name",
+static char *ajnf_fields[] = {
+  MACHINE, DIR, "adjustment",
 };
 
-static struct valobj amtl_valobj[] = {
-  {V_LOCK, 0, LIST, 0, LIST_ID, MR_DEADLOCK},
-  {V_ID, 0, LIST, NAME, LIST_ID, MR_LIST},
-  {V_TYPE, 1, "member", 0, 0, MR_TYPE},
-  {V_TYPEDATA, 2, 0, 0, 0, MR_NO_MATCH},
+static char *dnfp_fields[] = {
+  MACHINE, DIR,
 };
 
-static struct validate amtl_validate =
-{
-  amtl_valobj,
+static struct valobj dnfp_valobj[] = {
+  {V_RLOCK, 0, FILESYS_TABLE, 0, FILSYS_ID, MR_DEADLOCK},
+  {V_LOCK, 0, MACHINE_TABLE, 0, MACH_ID, MR_DEADLOCK},
+  {V_LOCK, 0, NFSPHYS_TABLE, 0, "nfsphys_id", MR_DEADLOCK},
+  {V_ID, 0, MACHINE_TABLE, NAME, MACH_ID, MR_MACHINE},
+
+};
+
+static struct validate dnfp_validate = {
+  dnfp_valobj,
   4,
+  DIR,
+  "mach_id = %d and dir = '%s'",
+  2,
+  "nfsphys_id",
   0,
-  0,
-  0,
-  0,
-  access_list,
-  0,
-  add_member_to_list,
+  setup_dnfp,
+  set_nfsphys_modtime,
+};
+
+static char *gqot_fields[] = {
+  FILESYS, TYPE, NAME,
+  FILESYS, TYPE, NAME, QUOTA, DIR, MACHINE, MOD1, MOD2, MOD3,
 };
 
-static struct validate dmfl_validate =
-{
-  amtl_valobj,
-  4,
+static struct valobj gqot_valobj[] = {
+  {V_RLOCK, 0, FILESYS_TABLE, 0, FILSYS_ID, MR_DEADLOCK},
+  {V_RLOCK, 0, USERS_TABLE, 0, USERS_ID, MR_DEADLOCK},
+  {V_RLOCK, 0, LIST_TABLE, 0, LIST_ID, MR_DEADLOCK},
+  {V_RLOCK, 0, NFSPHYS_TABLE, 0, "nfsphys_id", MR_DEADLOCK},
+  {V_RLOCK, 0, QUOTA_TABLE, 0, FILSYS_ID, MR_DEADLOCK},
+  {V_WILD, 0},
+  {V_TYPE, 1, 0, QUOTA_TYPE, 0, MR_TYPE},
+  {V_TYPEDATA, 2, 0, 0, 0, MR_ACE},
+  {V_SORT, 0, 0, 0, 0, 0},
+};
+
+static struct validate gqot_validate = {
+  gqot_valobj,
+  9,
   0,
   0,
   0,
   0,
-  access_list,
   0,
-  delete_member_from_list,
-};
-
-static char *gaus_fields[] = {
-  ACE_TYPE, ACE_NAME,
-  "use_type", "use_name",
+  0,
+  followup_gqot,
 };
 
-static struct valobj gaus_valobj[] = {
-  {V_TYPE, 0, "gaus", 0, 0, MR_TYPE},
-  {V_TYPEDATA, 1, 0, 0, 0, MR_NO_MATCH},
+static char *gqbf_fields[] = {
+  FILESYS,
+  FILESYS, TYPE, NAME, QUOTA, DIR, MACHINE, MOD1, MOD2, MOD3,
 };
 
-static struct validate gaus_validate = {
-  gaus_valobj,
+static struct validate gqbf_validate = {
+  VOwild0sort,
   2,
   0,
   0,
   0,
   0,
-  access_member,
+  access_filesys,
   0,
-  get_ace_use,
+  followup_gqot,
 };
 
-static char *qgli_fields[] = {
-  "active", "publicflg", "hidden", "maillist", "grouplist",
-  "list",
+static char *aqot_fields[] = {
+  FILESYS, TYPE, NAME, QUOTA,
 };
 
-static struct valobj qgli_valobj[] = {
-  {V_TYPE, 0, "boolean", 0, 0, MR_TYPE},
-  {V_TYPE, 1, "boolean", 0, 0, MR_TYPE},
-  {V_TYPE, 2, "boolean", 0, 0, MR_TYPE},
-  {V_TYPE, 3, "boolean", 0, 0, MR_TYPE},
-  {V_TYPE, 4, "boolean", 0, 0, MR_TYPE},
+static struct valobj aqot_valobj[] = {
+  {V_LOCK, 0, FILESYS_TABLE, 0, FILSYS_ID, MR_DEADLOCK},
+  {V_RLOCK, 0, USERS_TABLE, 0, USERS_ID, MR_DEADLOCK},
+  {V_RLOCK, 0, LIST_TABLE, 0, LIST_ID, MR_DEADLOCK},
+  {V_LOCK, 0, NFSPHYS_TABLE, 0, "nfsphys_id", MR_DEADLOCK},
+  {V_LOCK, 0, QUOTA_TABLE, 0, FILSYS_ID, MR_DEADLOCK},
+  {V_ID, 0, FILESYS_TABLE, LABEL, FILSYS_ID, MR_FILESYS},
+  {V_TYPE, 1, 0, QUOTA_TYPE, 0, MR_TYPE},
+  {V_TYPEDATA, 2, 0, 0, 0, MR_ACE},
 };
 
-static struct validate qgli_validate = {
-  qgli_valobj,
-  5,
+static struct validate aqot_validate = {
+  aqot_valobj,
+  8,
+  FILSYS_ID,
+  "filsys_id = %d and type = '%s' and entity_id = %d",
+  3,
   0,
   0,
+  prefetch_filesys,
+  followup_aqot,
+};
+
+static struct validate uqot_validate = {
+  aqot_valobj,
+  8,
+  FILSYS_ID,
+  "filsys_id = %d AND type = '%s' AND entity_id = %d",
+  3,
+  0,
   0,
+  setup_dqot,
+  followup_aqot,
+};
+
+static struct validate dqot_validate = {
+  aqot_valobj,
+  8,
+  FILSYS_ID,
+  "filsys_id = %d AND type = '%s' AND entity_id = %d",
+  3,
   0,
-  access_qgli,
   0,
-  qualified_get_lists,
+  setup_dqot,
+  followup_dqot,
 };
 
-static char *gmol_fields[] = {
-  "list_name",
-  "member_type", "member_name",
+static char *gnfq_fields[] = {
+  FILESYS, LOGIN,
+  FILESYS, LOGIN, QUOTA, DIR, MACHINE, MOD1, MOD2, MOD3,
 };
 
-static struct validate gmol_validate = {
-  VOlist0,
-  1,
+static struct validate gnfq_validate = {
+  VOwild0sort,
+  2,
   0,
   0,
   0,
   0,
-  access_visible_list,
+  access_filesys,
   0,
-  get_members_of_list,
+  followup_gqot,
 };
 
-static struct validate geml_validate = {
-  VOlist0,
-  1,
-  0,
-  0,
-  0,
-  0,
-  access_visible_list,
-  0,
-  get_end_members_of_list,
+static char *gnqp_fields[] = {
+  MACHINE, DIR,
+  FILESYS, LOGIN, QUOTA, DIR, MACHINE, MOD1, MOD2, MOD3,
 };
 
-static char *glom_fields[] = {
-  "member_type", "member_name",
-  "list_name", "active", "publicflg", "hidden", "maillist", "grouplist",
+static struct valobj gnqp_valobj[] = {
+  {V_ID, 0, MACHINE_TABLE, NAME, MACH_ID, MR_MACHINE},
+  {V_WILD, 1},
 };
 
-static struct valobj glom_valobj[] = {
-  {V_TYPE, 0, "rmember", 0, 0, MR_TYPE},
-  {V_TYPEDATA, 1, 0, 0, 0, MR_NO_MATCH},
-  {V_SORT, 0},
+static struct validate gnqp_validate = { gnqp_valobj, 2, };
+
+static char *anfq_fields[] = {
+  FILESYS, LOGIN, QUOTA,
 };
 
-static struct validate glom_validate = {
-  glom_valobj,
+static struct validate anfq_validate = {
+  VOfilsys0user1,
   3,
+  FILSYS_ID,
+  "filsys_id = %d AND type = 'USER' AND entity_id = %d",
+  2,
+  0, /* object ? */
   0,
-  0,
-  0,
-  0,
-  access_member,
-  0,
-  get_lists_of_member,
-};
-
-static char *cmol_fields[] = {
-  "list_name",
-  "count",
+  prefetch_filesys,
+  followup_aqot,
 };
 
-static struct validate cmol_validate = {
-  VOlist0,
-  1,
-  0,
+static struct validate unfq_validate = {
+  VOfilsys0user1,
+  3,
+  FILSYS_ID,
+  "filsys_id = %d AND type = 'USER' AND entity_id = %d",
+  2,
   0,
   0,
+  setup_dqot,
+  followup_aqot,
+};
+
+static struct validate dnfq_validate = {
+  VOfilsys0user1,
+  3,
+  FILSYS_ID,
+  "filsys_id = %d AND entity_id = %d",
+  2,
   0,
-  access_visible_list,
   0,
-  count_members_of_list,
+  setup_dqot,
+  followup_dqot,
 };
 
 static char *gzcl_fields[] = {
@@ -2147,9 +2277,16 @@ static char *gzcl_fields[] = {
   "iws_type", "iws_name", "iui_type", "iui_name", MOD1, MOD2, MOD3, 
 };
 
+static struct valobj gzcl_valobj[] = {
+  {V_RLOCK, 0, USERS_TABLE, 0, USERS_ID, MR_DEADLOCK},
+  {V_RLOCK, 0, LIST_TABLE, 0, LIST_ID, MR_DEADLOCK},
+  {V_RLOCK, 0, ZEPHYR_TABLE, 0, ZEPH_ID, MR_DEADLOCK},
+  {V_WILD, 0},
+  {V_SORT, 0},
+};
 static struct validate gzcl_validate = {
-  VOwild0sort,
-  2,
+  gzcl_valobj,
+  5,
   0,
   0,
   0,
@@ -2165,22 +2302,25 @@ static char *azcl_fields[] = {
 };
 
 static struct valobj azcl_valobj[] = {
-  {V_CHAR, 0},
-  {V_TYPE, 1, ACE_TYPE, 0, 0, MR_ACE},
+  {V_RLOCK, 0, USERS_TABLE, 0, USERS_ID, MR_DEADLOCK},
+  {V_RLOCK, 0, LIST_TABLE, 0, LIST_ID, MR_DEADLOCK},
+  {V_LOCK, 0, ZEPHYR_TABLE, 0, ZEPH_ID, MR_DEADLOCK}, 
+  {V_CHAR, 0, ZEPHYR_TABLE, CLASS},
+  {V_TYPE, 1, 0, ACE_TYPE, 0, MR_ACE},
   {V_TYPEDATA, 2, 0, 0, LIST_ID, MR_ACE},
-  {V_TYPE, 3, ACE_TYPE, 0, 0, MR_ACE},
+  {V_TYPE, 3, 0, ACE_TYPE, 0, MR_ACE},
   {V_TYPEDATA, 4, 0, 0, LIST_ID, MR_ACE},
-  {V_TYPE, 5, ACE_TYPE, 0, 0, MR_ACE},
+  {V_TYPE, 5, 0, ACE_TYPE, 0, MR_ACE},
   {V_TYPEDATA, 6, 0, 0, LIST_ID, MR_ACE},
-  {V_TYPE, 7, ACE_TYPE, 0, 0, MR_ACE},
+  {V_TYPE, 7, 0, ACE_TYPE, 0, MR_ACE},
   {V_TYPEDATA, 8, 0, 0, LIST_ID, MR_ACE},
 };
 
 static struct validate azcl_validate = {
   azcl_valobj,
-  9,
+  12,
   CLASS,
-  "class = LEFT('%s',SIZE(class))",
+  "class = '%s'",
   1,
   0,
   0,
@@ -2194,20 +2334,23 @@ static char *uzcl_fields[] = {
 };
 
 static struct valobj uzcl_valobj[] = {
-  {V_RENAME, 1, "zephyr", CLASS, 0, MR_NOT_UNIQUE},
-  {V_TYPE, 2, ACE_TYPE, 0, 0, MR_ACE},
+  {V_RLOCK, 0, USERS_TABLE, 0, USERS_ID, MR_DEADLOCK},
+  {V_RLOCK, 0, LIST_TABLE, 0, LIST_ID, MR_DEADLOCK},
+  {V_LOCK, 0, ZEPHYR_TABLE, 0, ZEPH_ID, MR_DEADLOCK},
+  {V_RENAME, 1, ZEPHYR_TABLE, CLASS, 0, MR_NOT_UNIQUE},
+  {V_TYPE, 2, 0, ACE_TYPE, 0, MR_ACE},
   {V_TYPEDATA, 3, 0, 0, LIST_ID, MR_ACE},
-  {V_TYPE, 4, ACE_TYPE, 0, 0, MR_ACE},
+  {V_TYPE, 4, 0, ACE_TYPE, 0, MR_ACE},
   {V_TYPEDATA, 5, 0, 0, LIST_ID, MR_ACE},
-  {V_TYPE, 6, ACE_TYPE, 0, 0, MR_ACE},
+  {V_TYPE, 6, 0, ACE_TYPE, 0, MR_ACE},
   {V_TYPEDATA, 7, 0, 0, LIST_ID, MR_ACE},
-  {V_TYPE, 8, ACE_TYPE, 0, 0, MR_ACE},
+  {V_TYPE, 8, 0, ACE_TYPE, 0, MR_ACE},
   {V_TYPEDATA, 9, 0, 0, LIST_ID, MR_ACE},
 };
 
 static struct validate uzcl_validate = {
   uzcl_valobj,
-  9,
+  12,
   CLASS,
   "class = '%s'",
   1,
@@ -2229,6 +2372,49 @@ static struct validate dzcl_validate = {
   0,
 };
 
+static char *gsha_fields[] = {
+  MACHINE,
+  MACHINE, ACE_TYPE, ACE_NAME, MOD1, MOD2, MOD3,
+};
+
+static struct validate gsha_validate = 
+{
+  VOupwild0,
+  1,
+  0,
+  0,
+  0,
+  0,
+  0,
+  0,
+  followup_gsha,
+};
+
+static char *asha_fields[] = {
+  MACHINE, ACE_TYPE, ACE_NAME,
+};
+
+static struct valobj asha_valobj[] = {
+  {V_RLOCK, 0, USERS_TABLE, 0, USERS_ID, MR_DEADLOCK},
+  {V_ID, 0, MACHINE_TABLE, NAME, MACH_ID, MR_MACHINE},
+  {V_RLOCK, 0, LIST_TABLE, 0, LIST_ID, MR_DEADLOCK},
+  {V_TYPE, 1, 0, ACE_TYPE, 0, MR_ACE},
+  {V_TYPEDATA, 2, 0, 0, 0, MR_ACE},
+};
+
+static struct validate asha_validate = 
+{
+  asha_valobj,
+  5,
+  MACH_ID,
+  "mach_id = %d",
+  1,
+  MACH_ID,
+  0,
+  0,
+  set_modtime_by_id,
+};
+
 static char *gsvc_fields[] = {
   SERVICE,
   SERVICE, "protocol", "port", DESC, MOD1, MOD2, MOD3,
@@ -2238,11 +2424,17 @@ static char *asvc_fields[] = {
   SERVICE, "protocol", "port", DESC,
 };
 
+static struct valobj asvc_valobj[] = {
+  {V_CHAR, 0, SERVICES_TABLE, NAME},
+  {V_CHAR, 1, SERVICES_TABLE, "protocol"},
+  {V_CHAR, 3, SERVICES_TABLE, DESC},
+};
+
 static struct validate asvc_validate = {
-  VOchar0,
-  1,
+  asvc_valobj,
+  3,
   NAME,
-  "name = LEFT('%s',SIZE(name))",
+  "name = '%s'",
   1,
   0,
   0,
@@ -2257,9 +2449,17 @@ static char *gpce_fields[] = {
   MOD1, MOD2, MOD3,
 };
 
+static struct valobj gpce_valobj[]={
+  {V_RLOCK, 0, USERS_TABLE, 0, USERS_ID, MR_DEADLOCK},
+  {V_RLOCK, 0, MACHINE_TABLE, 0, MACH_ID, MR_DEADLOCK},
+  {V_RLOCK, 0, PRINTCAP_TABLE, 0, MACH_ID, MR_DEADLOCK},
+  {V_WILD, 0},
+  {V_SORT, 0},
+};
+
 static struct validate gpce_validate = {
-  VOwild0sort,
-  2,
+  gpce_valobj,
+  5,
   0,
   0,
   0,
@@ -2276,16 +2476,19 @@ static char *apce_fields[] = {
 };
 
 static struct valobj apce_valobj[] = {
-  {V_CHAR, 0},
-  {V_ID, 1, MACHINE, NAME, MACH_ID, MR_MACHINE},
-  {V_ID, 4, MACHINE, NAME, MACH_ID, MR_MACHINE},
+  {V_CHAR, 0, PRINTCAP_TABLE, NAME},
+  {V_ID, 1, MACHINE_TABLE, NAME, MACH_ID, MR_MACHINE},
+  {V_LEN, 2, PRINTCAP_TABLE, "dir"},
+  {V_LEN, 3, PRINTCAP_TABLE, "rp"},
+  {V_ID, 4, MACHINE_TABLE, NAME, MACH_ID, MR_MACHINE},
+  {V_CHAR, 7, PRINTCAP_TABLE, "comments"},
 };
 
 static struct validate apce_validate = {
   apce_valobj,
-  3,
+  6,
   NAME,
-  "name = LEFT('%s',SIZE(name))",
+  "name = '%s'",
   1,
   0,
   0,
@@ -2318,18 +2521,18 @@ static char *gpdm_fields[] = {
 
 static char *apdm_fields[] = {
   NAME, "rpcnum", "host"
-    };
+};
 
 static struct valobj apdm_valobj[] = {
-  {V_CHAR, 0},
-  {V_ID, 2, MACHINE, NAME, MACH_ID, MR_MACHINE},
+  {V_CHAR, 0, PALLADIUM_TABLE, NAME},
+  {V_ID, 2, MACHINE_TABLE, NAME, MACH_ID, MR_MACHINE},
 };
 
 static struct validate apdm_validate = {
   apdm_valobj,
   2,
   NAME,
-  "name = LEFT('%s',SIZE(name))",
+  "name = '%s'",
   1,
   0,
   0,
@@ -2359,16 +2562,16 @@ static char *aali_fields[] = {
 };
 
 static struct valobj aali_valobj[] = {
-  {V_CHAR, 0},
-  {V_TYPE, 1, ALIAS, 0, 0, MR_TYPE},
-  {V_CHAR, 2},
+  {V_CHAR, 0, ALIAS_TABLE, NAME},
+  {V_TYPE, 1, 0, ALIAS, 0, MR_TYPE},
+  {V_CHAR, 2, ALIAS_TABLE, "trans"},
 };
 
 static struct validate aali_validate = {
   aali_valobj,
   3,
   "trans",
-  "name = LEFT('%s',SIZE(name)) and type = '%s' and trans = LEFT('%s',SIZE(trans))",
+  "name = '%s' and type = '%s' and trans = '%s'",
   3,
   0,
   0,
@@ -2394,7 +2597,7 @@ static char *gval_fields[] = {
 };
 
 static struct valobj gval_valobj[] = {
-  {V_NAME, 0, "numvalues", NAME, 0, MR_NO_MATCH},
+  {V_NAME, 0, NUMVALUES_TABLE, NAME, 0, MR_NO_MATCH},
 };
 
 static struct validate gval_validate = {
@@ -2413,12 +2616,16 @@ static char *aval_fields[] = {
   NAME, "value",
 };
 
+static struct valobj aval_valobj[] = {
+  {V_CHAR, 0, NUMVALUES_TABLE, NAME},
+};
+
 static struct validate aval_validate = /* for aval, uval, and dval */
 {
-  VOchar0,
+  aval_valobj,
   1,
   NAME,
-  "name = LEFT('%s',SIZE(name))",  /* LEFT() only needed for aval */
+  "name = '%s'",
   1,
   0,
   0,
@@ -2466,8 +2673,8 @@ struct query Queries2[] = {
     "galo",
     RETRIEVE,
     "u",
-    USERS,
-    "CHAR(u.login), CHAR(u.uid), u.shell, CHAR(u.last), CHAR(u.first), u.middle FROM users u",
+    USERS_TABLE,
+    "u.login, u.unix_uid, u.shell, u.last, u.first, u.middle FROM users u",
     galo_fields,
     6,
     "u.users_id != 0",
@@ -2481,8 +2688,8 @@ struct query Queries2[] = {
     "gaal",
     RETRIEVE,
     "u",
-    USERS,
-    "CHAR(u.login), CHAR(u.uid), u.shell, CHAR(u.last), CHAR(u.first), u.middle FROM users u",
+    USERS_TABLE,
+    "u.login, u.unix_uid, u.shell, u.last, u.first, u.middle FROM users u",
     galo_fields,
     6,
     "u.status = 1",
@@ -2496,11 +2703,11 @@ struct query Queries2[] = {
     "gual",
     RETRIEVE,
     "u",
-    USERS,
-    "CHAR(u.login), CHAR(u.uid), u.shell, CHAR(u.last), CHAR(u.first), u.middle, CHAR(u.status), CHAR(u.clearid), u.type, CHAR(str.string), CHAR(u.signature), CHAR(u.secure), CHAR(u.modtime), CHAR(u.modby), u.modwith FROM users u, strings str",
+    USERS_TABLE,
+    "u.login, u.unix_uid, u.shell, u.last, u.first, u.middle, u.status, u.clearid, u.type, str.string, u.signature, u.secure, TO_CHAR(u.modtime, 'DD-mon-YYYY HH24:MI:SS'), u.modby, u.modwith FROM users u, strings str",
     gual_fields,
     15,
-    "u.login LIKE '%s' ESCAPE '*' AND u.users_id != 0 AND u.comment = str.string_id",
+    "u.login LIKE '%s' ESCAPE '*' AND u.users_id != 0 AND u.comments = str.string_id",
     1,
     &gubl_validate,
   },
@@ -2511,11 +2718,11 @@ struct query Queries2[] = {
     "guau",
     RETRIEVE,
     "u",
-    USERS,
-    "CHAR(u.login), CHAR(u.uid), u.shell, CHAR(u.last), CHAR(u.first), u.middle, CHAR(u.status), CHAR(u.clearid), u.type, CHAR(str.string), CHAR(u.signature), CHAR(u.secure), CHAR(u.modtime), CHAR(u.modby), u.modwith FROM users u, strings str",
+    USERS_TABLE,
+    "u.login, u.unix_uid, u.shell, u.last, u.first, u.middle, u.status, u.clearid, u.type, str.string, u.signature, u.secure, TO_CHAR(u.modtime, 'DD-mon-YYYY HH24:MI:SS'), u.modby, u.modwith FROM users u, strings str",
     guau_fields,
     15,
-    "u.uid = %s AND u.users_id != 0 AND u.comment = str.string_id",
+    "u.unix_uid = %s AND u.users_id != 0 AND u.comments = str.string_id",
     1,
     &gubu_validate,
   },
@@ -2526,11 +2733,11 @@ struct query Queries2[] = {
     "guan",
     RETRIEVE,
     "u",
-    USERS,
-    "CHAR(u.login), CHAR(u.uid), u.shell, CHAR(u.last), CHAR(u.first), u.middle, CHAR(u.status), CHAR(u.clearid), u.type, CHAR(str.string), CHAR(u.signature), CHAR(u.secure), CHAR(u.modtime), CHAR(u.modby), u.modwith FROM users u, strings str",
+    USERS_TABLE,
+    "u.login, u.unix_uid, u.shell, u.last, u.first, u.middle, u.status, u.clearid, u.type, str.string, u.signature, u.secure, TO_CHAR(u.modtime, 'DD-mon-YYYY HH24:MI:SS'), u.modby, u.modwith FROM users u, strings str",
     guan_fields,
     15,
-    "u.first LIKE '%s' ESCAPE '*' AND u.last LIKE '%s' ESCAPE '*' AND u.users_id != 0 and u.comment = str.string_id",
+    "u.first LIKE '%s' ESCAPE '*' AND u.last LIKE '%s' ESCAPE '*' AND u.users_id != 0 and u.comments = str.string_id",
     2,
     &guan_validate,
   },
@@ -2541,11 +2748,11 @@ struct query Queries2[] = {
     "guac",
     RETRIEVE,
     "u",
-    USERS,
-    "CHAR(u.login), CHAR(u.uid), u.shell, CHAR(u.last), CHAR(u.first), u.middle, CHAR(u.status), CHAR(u.clearid), u.type, CHAR(str.string), CHAR(u.signature), CHAR(u.secure), CHAR(u.modtime), CHAR(u.modby), u.modwith FROM users u, strings str",
+    USERS_TABLE,
+    "u.login, u.unix_uid, u.shell, u.last, u.first, u.middle, u.status, u.clearid, u.type, str.string, u.signature, u.secure, TO_CHAR(u.modtime, 'DD-mon-YYYY HH24:MI:SS'), u.modby, u.modwith FROM users u, strings str",
     guac_fields,
     15,
-    "u.type = uppercase('%s') AND u.users_id != 0 AND u.comment = str.string_id",
+    "u.type = UPPER('%s') AND u.users_id != 0 AND u.comments = str.string_id",
     1,
     &VDsortf,
   },
@@ -2556,11 +2763,11 @@ struct query Queries2[] = {
     "guai",
     RETRIEVE,
     "u",
-    USERS,
-    "CHAR(u.login), CHAR(u.uid), u.shell, CHAR(u.last), CHAR(u.first), u.middle, CHAR(u.status), CHAR(u.clearid), u.type, CHAR(str.string), CHAR(u.signature), CHAR(u.secure), CHAR(u.modtime), CHAR(u.modby), u.modwith FROM users u, strings str",
+    USERS_TABLE,
+    "u.login, u.unix_uid, u.shell, u.last, u.first, u.middle, u.status, u.clearid, u.type, str.string, u.signature, u.secure, TO_CHAR(u.modtime, 'DD-mon-YYYY HH24:MI:SS'), u.modby, u.modwith FROM users u, strings str",
     guam_fields,
     15,
-    "u.clearid LIKE '%s' ESCAPE '*' AND u.users_id != 0 AND u.comment = str.string_id",
+    "u.clearid LIKE '%s' ESCAPE '*' AND u.users_id != 0 AND u.comments = str.string_id",
     1,
     &VDwildsortf,
   },
@@ -2571,8 +2778,8 @@ struct query Queries2[] = {
     "gubl",
     RETRIEVE,
     "u",
-    USERS,  
-    "CHAR(u.login), CHAR(u.uid), u.shell, CHAR(u.last), CHAR(u.first), u.middle, CHAR(u.status), CHAR(u.clearid), u.type, CHAR(u.modtime), CHAR(u.modby), u.modwith FROM users u",
+    USERS_TABLE,  
+    "u.login, u.unix_uid, u.shell, u.last, u.first, u.middle, u.status, u.clearid, u.type, TO_CHAR(u.modtime, 'DD-mon-YYYY HH24:MI:SS'), u.modby, u.modwith FROM users u",
     gubl_fields,
     12,
     "u.login LIKE '%s' ESCAPE '*' AND u.users_id != 0",
@@ -2586,11 +2793,11 @@ struct query Queries2[] = {
     "gubu",
     RETRIEVE,
     "u",
-    USERS,
-    "CHAR(u.login), CHAR(u.uid), u.shell, CHAR(u.last), CHAR(u.first), u.middle, CHAR(u.status), CHAR(u.clearid), u.type, CHAR(u.modtime), CHAR(u.modby), u.modwith FROM users u",
+    USERS_TABLE,
+    "u.login, u.unix_uid, u.shell, u.last, u.first, u.middle, u.status, u.clearid, u.type, TO_CHAR(u.modtime, 'DD-mon-YYYY HH24:MI:SS'), u.modby, u.modwith FROM users u",
     gubu_fields,
     12,
-    "u.uid = %s AND u.users_id != 0",
+    "u.unix_uid = %s AND u.users_id != 0",
     1,
     &gubu_validate,
   },
@@ -2601,8 +2808,8 @@ struct query Queries2[] = {
     "gubn",
     RETRIEVE,
     "u",
-    USERS,
-    "CHAR(u.login), CHAR(u.uid), u.shell, CHAR(u.last), CHAR(u.first), u.middle, CHAR(u.status), CHAR(u.clearid), u.type, CHAR(u.modtime), CHAR(u.modby), u.modwith FROM users u",
+    USERS_TABLE,
+    "u.login, u.unix_uid, u.shell, u.last, u.first, u.middle, u.status, u.clearid, u.type, TO_CHAR(u.modtime, 'DD-mon-YYYY HH24:MI:SS'), u.modby, u.modwith FROM users u",
     gubn_fields,
     12,
     "u.first LIKE '%s' ESCAPE '*' AND u.last LIKE '%s' ESCAPE '*' AND u.users_id != 0",
@@ -2616,11 +2823,11 @@ struct query Queries2[] = {
     "gubc",
     RETRIEVE,
     "u",
-    USERS,
-    "CHAR(u.login), CHAR(u.uid), u.shell, CHAR(u.last), CHAR(u.first), u.middle, CHAR(u.status), CHAR(u.clearid), u.type, CHAR(u.modtime), CHAR(u.modby), u.modwith FROM users u",
+    USERS_TABLE,
+    "u.login, u.unix_uid, u.shell, u.last, u.first, u.middle, u.status, u.clearid, u.type, TO_CHAR(u.modtime, 'DD-mon-YYYY HH24:MI:SS'), u.modby, u.modwith FROM users u",
     gubc_fields,
     12,
-    "u.type = uppercase('%s') AND u.users_id != 0",
+    "u.type = UPPER('%s') AND u.users_id != 0",
     1,
     &VDsortf,
   },
@@ -2631,8 +2838,8 @@ struct query Queries2[] = {
     "gubm",
     RETRIEVE,
     "u",
-    USERS,
-    "CHAR(u.login), CHAR(u.uid), u.shell, CHAR(u.last), CHAR(u.first), u.middle, CHAR(u.status), CHAR(u.clearid), u.type, CHAR(u.modtime), CHAR(u.modby), u.modwith FROM users u",
+    USERS_TABLE,
+    "u.login, u.unix_uid, u.shell, u.last, u.first, u.middle, u.status, u.clearid, u.type, TO_CHAR(u.modtime, 'DD-mon-YYYY HH24:MI:SS'), u.modby, u.modwith FROM users u",
     gubm_fields,
     12,
     "u.clearid LIKE '%s' ESCAPE '*' AND u.users_id != 0",
@@ -2646,8 +2853,8 @@ struct query Queries2[] = {
     "auac",
     APPEND,
     "u",
-    USERS,
-    "INTO users (login, uid, shell, last, first, middle, status, clearid, type, comment, signature, secure, users_id) VALUES ('%s', %s, '%s', '%s', '%s', '%s', %s, '%s', '%s', %d, '%s', %s, %s)",
+    USERS_TABLE,
+    "INTO users (login, unix_uid, shell, last, first, middle, status, clearid, type, comments, signature, secure, users_id) VALUES ('%s', %s, '%s', NVL('%s',CHR(0)), NVL('%s',CHR(0)), NVL('%s',CHR(0)), %s, NVL('%s',CHR(0)), '%s', %d, LENGTH(NVL('%s',CHR(0))), %s, %s)", /* followup_ausr fixes signature field */
     auac_fields,
     12,
     (char *)0,
@@ -2661,8 +2868,8 @@ struct query Queries2[] = {
     "ausr",
     APPEND,
     "u",
-    USERS,
-    "INTO users (login, uid, shell, last, first, middle, status, clearid, type, comment, signature, secure, users_id) VALUES ('%s', %s, '%s', '%s', '%s', '%s', %s, '%s', '%s', 0, '', 0, %s)",
+    USERS_TABLE,
+    "INTO users (login, unix_uid, shell, last, first, middle, status, clearid, type, comments, signature, secure, users_id) VALUES ('%s', %s, '%s', NVL('%s',CHR(0)), NVL('%s',CHR(0)), NVL('%s',CHR(0)), %s, NVL('%s',CHR(0)), '%s', 0, CHR(0), 0, %s)",
     auac_fields,
     9,
     0,
@@ -2691,8 +2898,8 @@ struct query Queries2[] = {
     "uuac",
     UPDATE,
     "u",
-    USERS,
-    "users SET login = '%s', uid = %s, shell = '%s', last = '%s', first = '%s', middle = '%s', status = %s, clearid = '%s', type = '%s', comment = %d, signature = '%s', secure = %s",
+    USERS_TABLE,
+    "users SET login = '%s', unix_uid = %s, shell = '%s', last = NVL('%s',CHR(0)), first = NVL('%s',CHR(0)), middle = NVL('%s',CHR(0)), status = %s, clearid = NVL('%s',CHR(0)), type = '%s', comments = %d, signature = LENGTH(NVL('%s',CHR(0))), secure = %s", /* followup_uuac fixes signature */
     uuac_fields,
     12,
     "users_id = %d",
@@ -2706,8 +2913,8 @@ struct query Queries2[] = {
     "uusr",
     UPDATE,
     "u",
-    USERS,
-    "users SET login = '%s', uid = %s, shell = '%s', last = '%s', first = '%s', middle = '%s', status = %s, clearid = '%s',  type = '%s'",
+    USERS_TABLE,
+    "users SET login = '%s', unix_uid = %s, shell = '%s', last = NVL('%s',CHR(0)), first = NVL('%s',CHR(0)), middle = NVL('%s',CHR(0)), status = %s, clearid = NVL('%s',CHR(0)),  type = '%s'",
     uuac_fields,
     9,
     "users_id = %d",
@@ -2721,7 +2928,7 @@ struct query Queries2[] = {
     "uush",
     UPDATE,
     "u",
-    USERS,
+    USERS_TABLE,
     "users SET shell = '%s'",  
     uush_fields,
     1,
@@ -2736,7 +2943,7 @@ struct query Queries2[] = {
     "uust",
     UPDATE,
     "u",
-    USERS,
+    USERS_TABLE,
     "users SET status = %s",
     uust_fields,
     1,
@@ -2751,7 +2958,7 @@ struct query Queries2[] = {
     "uuss",
     UPDATE,
     "u",
-    USERS,
+    USERS_TABLE,
     "users SET secure = %s",
     uuss_fields,
     1,
@@ -2766,7 +2973,7 @@ struct query Queries2[] = {
     "dusr",
     DELETE,
     "u",
-    USERS,
+    USERS_TABLE,
     (char *)0,
     dusr_fields,
     0,
@@ -2781,7 +2988,7 @@ struct query Queries2[] = {
     "dubu",
     DELETE,
     "u",
-    USERS,
+    USERS_TABLE,
     (char *)0,
     dubu_fields,
     0,
@@ -2796,8 +3003,8 @@ struct query Queries2[] = {
     "gkum",
     RETRIEVE,
     "k",
-    "krbmap",
-    "CHAR(u.login), CHAR(str.string) FROM krbmap km, users u, strings str",
+    KRBMAP_TABLE,
+    "u.login, str.string FROM krbmap km, users u, strings str",
     gkum_fields,
     2,
     "u.login LIKE '%s' ESCAPE '*' AND str.string LIKE '%s' ESCAPE '*' AND km.users_id = u.users_id AND km.string_id = str.string_id",
@@ -2811,7 +3018,7 @@ struct query Queries2[] = {
     "akum",
     APPEND,
     "k",
-    "krbmap",
+    KRBMAP_TABLE,
     "INTO krbmap (users_id, string_id) VALUES (%d, %d)",
     akum_fields,
     2,
@@ -2826,7 +3033,7 @@ struct query Queries2[] = {
     "dkum",
     DELETE,
     "k",
-    "krbmap",
+    KRBMAP_TABLE,
     0,
     akum_fields,
     0,
@@ -2841,11 +3048,11 @@ struct query Queries2[] = {
     "gfbl",
     RETRIEVE,
     "u",
-    USERS,
-    "CHAR(u.login), u.fullname, u.nickname, u.home_addr, u.home_phone, u.office_addr, u.office_phone, u.department, u.affiliation, CHAR(u.fmodtime), CHAR(u.fmodby), u.fmodwith FROM users u",
+    USERS_TABLE,
+    "login, fullname, nickname, home_addr, home_phone, office_addr, office_phone, department, affiliation, TO_CHAR(fmodtime, 'DD-mon-YYYY HH24:MI:SS'), fmodby, fmodwith FROM users",
     gfbl_fields,
     12,
-    "u.users_id = %d",
+    "users_id = %d",
     1,
     &gfbl_validate,
   },
@@ -2856,8 +3063,8 @@ struct query Queries2[] = {
     "ufbl",
     UPDATE,
     "u",
-    USERS,
-    "users SET fullname= '%s',nickname= '%s',home_addr= '%s',home_phone= '%s',office_addr= '%s',office_phone= '%s',department= '%s',affiliation= '%s'",
+    USERS_TABLE,
+    "users SET fullname= NVL('%s',CHR(0)),nickname= NVL('%s',CHR(0)),home_addr= NVL('%s',CHR(0)),home_phone= NVL('%s',CHR(0)),office_addr= NVL('%s',CHR(0)),office_phone= NVL('%s',CHR(0)),department= NVL('%s',CHR(0)),affiliation= NVL('%s',CHR(0))",
     ufbl_fields,
     8,
     "users_id = %d",
@@ -2871,11 +3078,11 @@ struct query Queries2[] = {
     "gpob",
     RETRIEVE,
     "u",
-    USERS,
-    "CHAR(u.login), u.potype, CHAR(u.pop_id) + ':' + CHAR(u.box_id), CHAR(u.pmodtime), CHAR(u.pmodby), u.pmodwith FROM users u",
+    USERS_TABLE,
+    "login, potype, pop_id || ':' || box_id, TO_CHAR(pmodtime, 'DD-mon-YYYY HH24:MI:SS'), pmodby, pmodwith FROM users",
     gpob_fields,
     6,
-    "u.users_id = %d",
+    "users_id = %d",
     1,
     &gpob_validate,
   },
@@ -2886,11 +3093,11 @@ struct query Queries2[] = {
     "gapo",
     RETRIEVE,
     "u",
-    USERS,
-    "CHAR(u.login), u.potype, CHAR(u.pop_id) + ':' + CHAR(u.box_id) FROM users u",
+    USERS_TABLE,
+    "login, potype, pop_id || ':' || box_id FROM users",
     gpox_fields,
     3,
-    "u.potype != 'NONE'",
+    "potype != 'NONE'",
     0,
     &gpox_validate,
   },
@@ -2901,11 +3108,11 @@ struct query Queries2[] = {
     "gpop",
     RETRIEVE,
     "u",
-    USERS,
-    "CHAR(u.login), u.potype, CHAR(u.pop_id) + ':' + CHAR(u.box_id) FROM users u",
+    USERS_TABLE,
+    "login, potype, pop_id || ':' || box_id FROM users",
     gpox_fields,
     3,
-    "u.potype = 'POP'",
+    "potype = 'POP'",
     0,
     &gpox_validate
   },
@@ -2916,11 +3123,11 @@ struct query Queries2[] = {
     "gpos",
     RETRIEVE,
     "u",
-    USERS,
-    "CHAR(u.login), u.potype, CHAR(u.pop_id) + ':' + CHAR(u.box_id) FROM users u",
+    USERS_TABLE,
+    "login, potype, pop_id || ':' || box_id FROM users",
     gpox_fields,
     3,
-    "u.potype = 'SMTP'",
+    "potype = 'SMTP'",
     0,
     &gpox_validate
   },
@@ -2931,7 +3138,7 @@ struct query Queries2[] = {
     "spob",
     UPDATE,
     0,
-    USERS,
+    USERS_TABLE,
     0,
     spob_fields,
     3,
@@ -2946,7 +3153,7 @@ struct query Queries2[] = {
     "spop",
     UPDATE,
     "u",
-    USERS,
+    USERS_TABLE,
     "users SET potype = 'POP'",
     spob_fields,
     0,
@@ -2961,28 +3168,13 @@ struct query Queries2[] = {
     "dpob",
     UPDATE,
     "u",
-    USERS,
-    "users SET potype = 'NONE'",
-    spob_fields,
-    0,
-    "users_id = %d",
-    1,
-    &dpob_validate,
-  },
-
-  {
-    /* Q_GMAC - GET_MACHINE */
-    "get_machine",
-    "gmac",
-    RETRIEVE,
-    "m",
-    MACHINE,
-    "CHAR(m.name), m.vendor, CHAR(m.modtime), CHAR(m.modby), m.modwith FROM machine m",
-    gmac_fields,
-    5,
-    "m.name LIKE '%s' ESCAPE '*' AND m.mach_id != 0", 
+    USERS_TABLE,
+    "users SET potype = 'NONE'",
+    spob_fields,
+    0,
+    "users_id = %d",
     1,
-    &VDupwildsortf,
+    &dpob_validate,
   },
 
   {
@@ -2991,8 +3183,8 @@ struct query Queries2[] = {
     "ghst",
     RETRIEVE,
     "m",
-    MACHINE,
-    "CHAR(m.name), m.vendor, m.model, m.os, m.location, m.contact, CHAR(m.use), CHAR(m.status), CHAR(m.statuschange), CHAR(s.name), m.address, m.owner_type, CHAR(m.owner_id), CHAR(m.acomment), CHAR(m.ocomment), CHAR(m.created), CHAR(m.creator), CHAR(m.inuse), CHAR(m.modtime), CHAR(m.modby), m.modwith FROM machine m, subnet s",
+    MACHINE_TABLE,
+    "m.name, m.vendor, m.model, m.os, m.location, m.contact, m.use, m.status, TO_CHAR(m.statuschange, 'DD-mon-YYYY HH24:MI:SS'), s.name, m.address, m.owner_type, m.owner_id, m.acomment, m.ocomment, TO_CHAR(m.created, 'DD-mon-YYYY HH24:MI:SS'), m.creator, TO_CHAR(m.inuse, 'DD-mon-YYYY HH24:MI:SS'), TO_CHAR(m.modtime, 'DD-mon-YYYY HH24:MI:SS'), m.modby, m.modwith FROM machine m, subnet s",
     ghst_fields,
     21,
     "m.name LIKE '%s' ESCAPE '*' AND m.address LIKE '%s' ESCAPE '*' AND m.location LIKE '%s' ESCAPE '*' AND s.name LIKE '%s' ESCAPE '*' AND m.mach_id != 0 AND s.snet_id = m.snet_id", 
@@ -3006,8 +3198,8 @@ struct query Queries2[] = {
     "ahst",
     APPEND,
     "m",
-    MACHINE,
-    "INTO machine (name, vendor, model, os, location, contact, use, status, statuschange, snet_id, address, owner_type, owner_id, acomment, ocomment, created, inuse, mach_id, creator) VALUES (uppercase('%s'),uppercase('%s'),uppercase('%s'),uppercase('%s'),uppercase('%s'),'%s',%s,%s,date('now'),%d,'%s','%s',%d,%d,%d,date('now'),date('now'),%s,%s)",
+    MACHINE_TABLE,
+    "INTO machine (name, vendor, model, os, location, contact, use, status, statuschange, snet_id, address, owner_type, owner_id, acomment, ocomment, created, inuse, mach_id, creator) VALUES (UPPER('%s'),NVL(UPPER('%s'),CHR(0)),NVL(UPPER('%s'),CHR(0)),NVL(UPPER('%s'),CHR(0)),NVL(UPPER('%s'),CHR(0)),NVL('%s',CHR(0)),%s,%s,SYSDATE,%d,'%s','%s',%d,%d,%d,SYSDATE,SYSDATE,%s,%s)",
     ahst_fields,
     14,
     0,
@@ -3021,8 +3213,8 @@ struct query Queries2[] = {
     "uhst",
     UPDATE,
     "m",
-    MACHINE,
-    "machine SET name=uppercase('%s'),vendor=uppercase('%s'),model=uppercase('%s'),os=uppercase('%s'),location=uppercase('%s'),contact='%s',use=%s,status=%s,snet_id=%d,address='%s',owner_type='%s',owner_id=%d,acomment=%d,ocomment=%d",
+    MACHINE_TABLE,
+    "machine SET name=NVL(UPPER('%s'),CHR(0)),vendor=NVL(UPPER('%s'),CHR(0)),model=NVL(UPPER('%s'),CHR(0)),os=NVL(UPPER('%s'),CHR(0)),location=NVL(UPPER('%s'),CHR(0)),contact=NVL('%s',CHR(0)),use=%s,status=%s,snet_id=%d,address='%s',owner_type='%s',owner_id=%d,acomment=%d,ocomment=%d",
     uhst_fields,
     14,
     "mach_id = %d",
@@ -3036,7 +3228,7 @@ struct query Queries2[] = {
     "dhst",
     DELETE,
     "m",
-    MACHINE,
+    MACHINE_TABLE,
     (char *)0,
     dhst_fields,
     0,
@@ -3045,14 +3237,29 @@ struct query Queries2[] = {
     &dhst_validate,
   },
 
+  {
+    /* Q_GMAC - GET_MACHINE */
+    "get_machine",
+    "gmac",
+    RETRIEVE,
+    "m",
+    MACHINE_TABLE,
+    "name, vendor, TO_CHAR(modtime, 'DD-mon-YYYY HH24:MI:SS'), modby, modwith FROM machine",
+    gmac_fields,
+    5,
+    "name LIKE '%s' ESCAPE '*' AND mach_id != 0", 
+    1,
+    &VDupwildsortf,
+  },
+
   {
     /* Q_GHAL - GET_HOSTALIAS */
     "get_hostalias",
     "ghal",
     RETRIEVE,
-    0,
-    "hostalias",
-    "CHAR(a.name), CHAR(m.name) FROM hostalias a, machine m",
+    "a",
+    HOSTALIAS_TABLE,
+    "a.name, m.name FROM hostalias a, machine m",
     ghal_fields,
     2,
     "m.mach_id = a.mach_id and a.name LIKE '%s' ESCAPE '*' AND m.name LIKE '%s' ESCAPE '*'",
@@ -3066,8 +3273,8 @@ struct query Queries2[] = {
     "ahal",
     APPEND,
     "a",
-    "hostalias",
-    "INTO hostalias (name, mach_id) VALUES (uppercase('%s'),%d)",
+    HOSTALIAS_TABLE,
+    "INTO hostalias (name, mach_id) VALUES (UPPER('%s'),%d)",
     ghal_fields,
     2,
     0,
@@ -3081,11 +3288,11 @@ struct query Queries2[] = {
     "dhal",
     DELETE,
     "a",
-    "hostalias",
+    HOSTALIAS_TABLE,
     (char *)0,
     ghal_fields,
     0,
-    "name = uppercase('%s') AND mach_id = %d",
+    "name = UPPER('%s') AND mach_id = %d",
     2,
     &dhal_validate,
   },
@@ -3096,11 +3303,11 @@ struct query Queries2[] = {
     "gsnt",
     RETRIEVE,
     "s",
-    SUBNET,
-    "CHAR(s.name), CHAR(s.description), CHAR(s.saddr), CHAR(s.mask), CHAR(s.low), CHAR(s.high), s.prefix, s.owner_type, CHAR(s.owner_id), CHAR(s.modtime), CHAR(s.modby), s.modwith FROM subnet s",
+    SUBNET_TABLE,
+    "name, description, saddr, mask, low, high, prefix, owner_type, owner_id, TO_CHAR(modtime, 'DD-mon-YYYY HH24:MI:SS'), modby, modwith FROM subnet",
     gsnt_fields,
     12,
-    "s.name LIKE '%s' ESCAPE '*' and s.snet_id != 0",
+    "name LIKE '%s' ESCAPE '*' and snet_id != 0",
     1,
     &gsnt_validate,
   },
@@ -3111,8 +3318,8 @@ struct query Queries2[] = {
     "asnt",
     APPEND,
     "s",
-    SUBNET,
-    "INTO subnet (name, description, saddr, mask, low, high, prefix, owner_type, owner_id, snet_id) VALUES (uppercase('%s'), '%s', %s, %s, %s, %s, '%s', '%s', %d, %s)",
+    SUBNET_TABLE,
+    "INTO subnet (name, description, saddr, mask, low, high, prefix, owner_type, owner_id, snet_id) VALUES (UPPER('%s'), NVL('%s',CHR(0)), %s, %s, %s, %s, NVL('%s',CHR(0)), '%s', %d, %s)",
     asnt_fields,
     9,
     0,
@@ -3126,8 +3333,8 @@ struct query Queries2[] = {
     "usnt",
     UPDATE,
     "s",
-    SUBNET,
-    "subnet SET name=uppercase('%s'), description='%s', saddr=%s, mask=%s, low=%s, high=%s, prefix='%s', owner_type='%s', owner_id=%d",
+    SUBNET_TABLE,
+    "subnet SET name=UPPER('%s'), description=NVL('%s',CHR(0)), saddr=%s, mask=%s, low=%s, high=%s, prefix=NVL('%s',CHR(0)), owner_type='%s', owner_id=%d",
     usnt_fields,
     9,
     "snet_id = %d",
@@ -3141,7 +3348,7 @@ struct query Queries2[] = {
     "dsnt",
     DELETE,
     "s",
-    SUBNET,
+    SUBNET_TABLE,
     (char *)0,
     dsnt_fields,
     0,
@@ -3156,11 +3363,11 @@ struct query Queries2[] = {
     "gclu",
     RETRIEVE,
     "c",
-    CLUSTER,
-    "CHAR(c.name), c.description, c.location, CHAR(c.modtime), CHAR(c.modby), c.modwith FROM cluster c",
+    CLUSTER_TABLE,
+    "name, description, location, TO_CHAR(modtime, 'DD-mon-YYYY HH24:MI:SS'), modby, modwith FROM clusters",
     gclu_fields,
     6,
-    "c.name LIKE '%s' ESCAPE '*' AND c.clu_id != 0",
+    "name LIKE '%s' ESCAPE '*' AND clu_id != 0",
     1,
     &VDwildsortf,
   },
@@ -3171,8 +3378,8 @@ struct query Queries2[] = {
     "aclu",
     APPEND,
     "c",
-    CLUSTER,
-    "INTO cluster (name, description, location, clu_id) VALUES ('%s','%s','%s',%s)",
+    CLUSTER_TABLE,
+    "INTO clusters (name, description, location, clu_id) VALUES ('%s',NVL('%s',CHR(0)),NVL('%s',CHR(0)),%s)",
     aclu_fields,
     3,
     0,
@@ -3186,8 +3393,8 @@ struct query Queries2[] = {
     "uclu",
     UPDATE,
     "c",
-    CLUSTER,
-    "cluster SET name = '%s', description = '%s', location = '%s'",
+    CLUSTER_TABLE,
+    "clusters SET name = '%s', description = NVL('%s',CHR(0)), location = NVL('%s',CHR(0))",
     uclu_fields,
     3,
     "clu_id = %d",
@@ -3201,7 +3408,7 @@ struct query Queries2[] = {
     "dclu",
     DELETE,
     "c",
-    CLUSTER,
+    CLUSTER_TABLE,
     (char *)0,
     dclu_fields,
     0,
@@ -3216,8 +3423,8 @@ struct query Queries2[] = {
     "gmcm",
     RETRIEVE,
     "mcm",
-    "mcmap",
-    "CHAR(m.name), CHAR(c.name) FROM machine m, cluster c, mcmap mcm",
+    MCMAP_TABLE,
+    "m.name, c.name FROM machine m, clusters c, mcmap mcm",
     gmcm_fields,
     2,
     "m.name LIKE '%s' ESCAPE '*' AND c.name LIKE '%s' ESCAPE '*' AND mcm.clu_id = c.clu_id AND mcm.mach_id = m.mach_id",
@@ -3231,7 +3438,7 @@ struct query Queries2[] = {
     "amtc",
     APPEND,
     "mcm",
-    "mcmap",
+    MCMAP_TABLE,
     "INTO mcmap (mach_id, clu_id) VALUES (%d, %d)",
     gmcm_fields,
     2,
@@ -3246,7 +3453,7 @@ struct query Queries2[] = {
     "dmfc",
     DELETE,
     "mcm",
-    "mcmap",
+    MCMAP_TABLE,
     0,
     gmcm_fields,
     0,
@@ -3261,8 +3468,8 @@ struct query Queries2[] = {
     "gcld",
     RETRIEVE,
     "svc",
-    "svc",
-    "CHAR(c.name), CHAR(svc.serv_label), svc.serv_cluster FROM svc svc, cluster c",
+    SVC_TABLE,
+    "c.name, svc.serv_label, svc.serv_cluster FROM svc svc, clusters c",
     gcld_fields,
     3,
     "c.clu_id = svc.clu_id AND c.name LIKE '%s' ESCAPE '*' AND svc.serv_label LIKE '%s' ESCAPE '*'",
@@ -3276,7 +3483,7 @@ struct query Queries2[] = {
     "acld",
     APPEND,
     "svc",
-    "svc",
+    SVC_TABLE,
     "INTO svc (clu_id, serv_label, serv_cluster) VALUES (%d,'%s','%s')",
     acld_fields,
     3,
@@ -3291,7 +3498,7 @@ struct query Queries2[] = {
     "dcld",
     DELETE,
     "svc",
-    "svc",
+    SVC_TABLE,
     (char *)0,
     acld_fields,
     0,
@@ -3300,17 +3507,212 @@ struct query Queries2[] = {
     &dcld_validate,
   },
 
+  {
+    /* Q_GLIN - GET_LIST_INFO */
+    "get_list_info",
+    "glin",
+    RETRIEVE,
+    0,
+    LIST_TABLE,
+    0,
+    glin_fields,
+    13,
+    0,
+    1,              
+    &glin_validate, 
+  },
+    
+  {
+    /* Q_EXLN - EXPAND_LIST_NAMES */
+    "expand_list_names",
+    "exln",
+    RETRIEVE,
+    "l",
+    LIST_TABLE,
+    "name FROM list",
+    glin_fields,
+    1,
+    "name LIKE '%s' ESCAPE '*' AND list_id != 0",
+    1,
+    &VDwild0,
+  },
+    
+  {
+    /* Q_ALIS - ADD_LIST */ /* uses prefetch_value() for list_id */
+    "add_list",
+    "alis",
+    APPEND,
+    "l",
+    LIST_TABLE, 
+    "INTO list (name, active, publicflg, hidden, maillist, grouplist, gid, acl_type, acl_id, description, list_id) VALUES ('%s',%s,%s,%s,%s,%s,%s,'%s',%d,NVL('%s',CHR(0)),%s)",
+    alis_fields,
+    10,
+    0,
+    0,
+    &alis_validate,
+  },
+
+  {
+    /* Q_ULIS - UPDATE_LIST */
+    "update_list",
+    "ulis",
+    UPDATE,
+    "l",
+    LIST_TABLE,
+    "list SET name='%s', active=%s, publicflg=%s, hidden=%s, maillist=%s, grouplist=%s, gid=%s, acl_type='%s', acl_id=%d, description=NVL('%s',CHR(0))",
+    ulis_fields,
+    10,
+    "list_id = %d",
+    1,
+    &ulis_validate,
+  },
+
+  {
+    /* Q_DLIS - DELETE_LIST */
+    "delete_list",
+    "dlis",
+    DELETE,
+    "l",
+    LIST_TABLE,
+    (char *)0,
+    dlis_fields,
+    0,
+    "list_id = %d",
+    1,
+    &dlis_validate,
+  },
+
+  {
+    /* Q_AMTL - ADD_MEMBER_TO_LIST */
+    "add_member_to_list",
+    "amtl",
+    APPEND,
+    0,
+    IMEMBERS_TABLE,
+    0,
+    amtl_fields,
+    3,
+    (char *)0,
+    0,
+    &amtl_validate,
+  },
+
+  {
+    /* Q_DMFL - DELETE_MEMBER_FROM_LIST */
+    "delete_member_from_list",
+    "dmfl",
+    DELETE,
+    0,
+    IMEMBERS_TABLE,
+    (char *)0,
+    amtl_fields,
+    0,
+    0,
+    3,
+    &dmfl_validate,
+  },
+
+  {
+    /* Q_GAUS - GET_ACE_USE */
+    "get_ace_use",
+    "gaus",
+    RETRIEVE,
+    0,
+    0,
+    0,
+    gaus_fields,
+    2,
+    0,
+    2,
+    &gaus_validate,
+  },
+
+  {
+    /* Q_QGLI - QUALIFIED_GET_LISTS */
+    "qualified_get_lists",
+    "qgli",
+    RETRIEVE,
+    0,
+    LIST_TABLE,
+    0,
+    qgli_fields,
+    1,
+    0,
+    5,
+    &qgli_validate,
+  },
+
+  {
+    /* Q_GMOL - GET_MEMBERS_OF_LIST */
+    "get_members_of_list",
+    "gmol",
+    RETRIEVE,
+    (char *)0,
+    IMEMBERS_TABLE,
+    (char *)0,
+    gmol_fields,
+    2,
+    (char *)0,
+    1,
+    &gmol_validate,
+  },
+
+  {
+    /* Q_GEML - GET_END_MEMBERS_OF_LIST */
+    "get_end_members_of_list",
+    "geml",
+    RETRIEVE,
+    (char *)0,
+    IMEMBERS_TABLE,
+    (char *)0,
+    gmol_fields,
+    0,
+    (char *)0,
+    1,
+    &geml_validate,
+  },
+  {
+    /* Q_GLOM - GET_LISTS_OF_MEMBER */
+    "get_lists_of_member",
+    "glom",
+    RETRIEVE,
+    0,
+    IMEMBERS_TABLE,
+    0,
+    glom_fields,
+    6,
+    0,
+    2,
+    &glom_validate,
+  },
+
+  {
+    /* Q_CMOL - COUNT_MEMBERS_OF_LIST */
+    "count_members_of_list",
+    "cmol",
+    RETRIEVE,
+    0,
+    IMEMBERS_TABLE,
+    0,
+    cmol_fields,
+    1,
+    0,
+    1,
+    &cmol_validate,
+  },
+
   {
     /* Q_GSIN - GET_SERVER_INFO */
     "get_server_info",
     "gsin",
     RETRIEVE,
     "s",
-    "servers",
-    "CHAR(s.name), CHAR(s.update_int), s.target_file, s.script, CHAR(s.dfgen), CHAR(s.dfcheck), s.type, CHAR(s.enable), CHAR(s.inprogress), CHAR(s.harderror), s.errmsg, s.acl_type, CHAR(s.acl_id), CHAR(s.modtime), CHAR(s.modby), s.modwith FROM servers s",
+    SERVERS_TABLE,
+    "name, update_int, target_file, script, dfgen, dfcheck, type, enable, inprogress, harderror, errmsg, acl_type, acl_id, TO_CHAR(modtime, 'DD-mon-YYYY HH24:MI:SS'), modby, modwith FROM servers",
     gsin_fields,
     16,
-    "s.name LIKE '%s' ESCAPE '*'",
+    "name LIKE '%s' ESCAPE '*'",
     1,
     &gsin_validate,
   },
@@ -3321,7 +3723,7 @@ struct query Queries2[] = {
     "qgsv",
     RETRIEVE,
     0,
-    "servers",
+    SERVERS_TABLE,
     0,
     qgsv_fields,
     1,
@@ -3336,8 +3738,8 @@ struct query Queries2[] = {
     "asin",
     APPEND,
     "s",
-    "servers",
-    "INTO servers (name, update_int, target_file, script, type, enable, acl_type, acl_id) VALUES (uppercase('%s'),%s,'%s','%s','%s',%s,'%s',%d)",
+    SERVERS_TABLE,
+    "INTO servers (name, update_int, target_file, script, type, enable, acl_type, acl_id) VALUES (UPPER('%s'),%s,'%s','%s','%s',%s,'%s',%d)",
     asin_fields,
     8,
     (char *)0,
@@ -3351,11 +3753,11 @@ struct query Queries2[] = {
     "usin",
     UPDATE,
     "s",
-    "servers",
+    SERVERS_TABLE,
     "servers SET update_int = %s, target_file = '%s', script = '%s', type = '%s', enable = %s, acl_type = '%s', acl_id = %d",
     asin_fields,
     7,
-    "name = uppercase('%s')",
+    "name = UPPER('%s')",
     1,
     &asin_validate,
   },
@@ -3366,11 +3768,11 @@ struct query Queries2[] = {
     "rsve",
     UPDATE,
     "s",
-    "servers",
+    SERVERS_TABLE,
     "servers SET harderror = 0, dfcheck = dfgen",
     dsin_fields,
     0,
-    "name = uppercase('%s')",
+    "name = UPPER('%s')",
     1,
     &rsve_validate,
   },
@@ -3381,11 +3783,11 @@ struct query Queries2[] = {
     "ssif",
     UPDATE,
     "s",
-    "servers",
-    "servers SET dfgen = %s, dfcheck = %s, inprogress = %s, harderror = %s, errmsg = '%s'",
+    SERVERS_TABLE,
+    "servers SET dfgen = %s, dfcheck = %s, inprogress = %s, harderror = %s, errmsg = NVL('%s',CHR(0))",
     ssif_fields,
     5,
-    "name = uppercase('%s')",
+    "name = UPPER('%s')",
     1,
     &ssif_validate,
   },
@@ -3396,11 +3798,11 @@ struct query Queries2[] = {
     "dsin",
     DELETE,
     "s",
-    "servers",
+    SERVERS_TABLE,
     (char *)0,
     dsin_fields,
     0,
-    "name = uppercase('%s')",
+    "name = UPPER('%s')",
     1,
     &dsin_validate,
   },
@@ -3411,8 +3813,8 @@ struct query Queries2[] = {
     "gshi",
     RETRIEVE,
     "sh",
-    "serverhosts",
-    "CHAR(sh.service), CHAR(m.name), CHAR(sh.enable), CHAR(sh.override), CHAR(sh.success), CHAR(sh.inprogress), CHAR(sh.hosterror), sh.hosterrmsg, CHAR(sh.ltt), CHAR(sh.lts), CHAR(sh.value1), CHAR(sh.value2), sh.value3, CHAR(sh.modtime), CHAR(sh.modby), sh.modwith FROM serverhosts sh, machine m",
+    SERVERHOSTS_TABLE,
+    "sh.service, m.name, sh.enable, sh.override, sh.success, sh.inprogress, sh.hosterror, sh.hosterrmsg, sh.ltt, sh.lts, sh.value1, sh.value2, sh.value3, TO_CHAR(sh.modtime, 'DD-mon-YYYY HH24:MI:SS'), sh.modby, sh.modwith FROM serverhosts sh, machine m",
     gshi_fields,
     16,
     "sh.service LIKE '%s' ESCAPE '*' AND m.name LIKE '%s' ESCAPE '*' AND m.mach_id = sh.mach_id",
@@ -3426,7 +3828,7 @@ struct query Queries2[] = {
     "qgsh",
     RETRIEVE,
     0,
-    "serverhosts",
+    SERVERHOSTS_TABLE,
     0,
     qgsh_fields,
     2,
@@ -3441,8 +3843,8 @@ struct query Queries2[] = {
     "ashi",
     APPEND,
     "sh",
-    "serverhosts",
-    "INTO serverhosts (service, mach_id, enable, value1, value2, value3) VALUES (uppercase('%s'), %d, %s, %s, %s, '%s')",
+    SERVERHOSTS_TABLE,
+    "INTO serverhosts (service, mach_id, enable, value1, value2, value3) VALUES (UPPER('%s'), %d, %s, %s, %s, NVL('%s',CHR(0)))",
     ashi_fields,
     6,
     (char *)0,
@@ -3456,11 +3858,11 @@ struct query Queries2[] = {
     "ushi",
     UPDATE,
     "sh",
-    "serverhosts",
-    "serverhosts SET enable = %s, value1 = %s, value2 = %s, value3 = '%s'",
+    SERVERHOSTS_TABLE,
+    "serverhosts SET enable = %s, value1 = %s, value2 = %s, value3 = NVL('%s',CHR(0))",
     ashi_fields,
     4,
-    "service = uppercase('%s') AND mach_id = %d",
+    "service = UPPER('%s') AND mach_id = %d",
     2,
     &ashi_validate,
   },
@@ -3471,11 +3873,11 @@ struct query Queries2[] = {
     "rshe",
     UPDATE,
     "sh",
-    "serverhosts",
+    SERVERHOSTS_TABLE,
     "serverhosts SET hosterror = 0",
     dshi_fields,
     0,
-    "service = uppercase('%s') AND mach_id = %d",
+    "service = UPPER('%s') AND mach_id = %d",
     2,
     &rshe_validate,
   },
@@ -3486,11 +3888,11 @@ struct query Queries2[] = {
     "ssho",
     UPDATE,
     "sh",
-    "serverhosts",
+    SERVERHOSTS_TABLE,
     "serverhosts SET override = 1",
     dshi_fields,
     0,
-    "service = uppercase('%s') AND mach_id = %d",
+    "service = UPPER('%s') AND mach_id = %d",
     2,
     &ssho_validate,
   },
@@ -3501,88 +3903,28 @@ struct query Queries2[] = {
     "sshi",
     UPDATE,
     "s",
-    "serverhosts",
-    "serverhosts SET override = %s, success = %s, inprogress = %s, hosterror = %s, hosterrmsg = '%s', ltt = %s, lts = %s",
+    SERVERHOSTS_TABLE,
+    "serverhosts SET override = %s, success = %s, inprogress = %s, hosterror = %s, hosterrmsg = NVL('%s',CHR(0)), ltt = %s, lts = %s",
     sshi_fields,
     7,
-    "service = uppercase('%s') AND mach_id = %d", 
+    "service = UPPER('%s') AND mach_id = %d", 
     2,
     &sshi_validate,
   },
 
   {
-    /* Q_DSHI - DELETE_SERVER_HOST_INFO */
-    "delete_server_host_info",
-    "dshi",
-    DELETE,
-    "sh",
-    "serverhosts",
-    (char *)0,
-    dshi_fields,
-    0,
-    "service = uppercase('%s') AND mach_id = %d",
-    2,
-    &dshi_validate,
-  },
-
-  {
-    /* Q_GSHA - GET_SERVER_HOST_ACCESS */ 
-    "get_server_host_access",
-    "gsha",
-    RETRIEVE,
-    "ha",
-    "hostaccess",
-    "CHAR(m.name), ha.acl_type, CHAR(ha.acl_id), CHAR(ha.modtime), CHAR(ha.modby), ha.modwith FROM hostaccess ha, machine m",
-    gsha_fields,
-    6,
-    "m.name LIKE '%s' ESCAPE '*' AND ha.mach_id = m.mach_id",
-    1,
-    &gsha_validate,
-  },
-
-  {
-    /* Q_ASHA - ADD_SERVER_HOST_ACCESS */
-    "add_server_host_access",
-    "asha",
-    APPEND,
-    "ha",
-    "hostaccess",
-    "INTO hostaccess (mach_id, acl_type, acl_id) VALUES (%d,'%s',%d)",
-    asha_fields,
-    3,
-    0,
-    0,
-    &asha_validate,
-  },
-
-  {
-    /* Q_USHA - UPDATE_SERVER_HOST_ACCESS */
-    "update_server_host_access",
-    "usha",
-    UPDATE,
-    "ha",
-    "hostaccess",
-    "hostaccess SET acl_type = '%s', acl_id = %d",
-    asha_fields,
-    2,
-    "mach_id = %d",
-    1,
-    &asha_validate,
-  },
-
-  {
-    /* Q_DSHA - DELETE_SERVER_HOST_ACCESS */
-    "delete_server_host_access",
-    "dsha",
+    /* Q_DSHI - DELETE_SERVER_HOST_INFO */
+    "delete_server_host_info",
+    "dshi",
     DELETE,
-    "ha",
-    "hostaccess",
-    0,
-    asha_fields,
+    "sh",
+    SERVERHOSTS_TABLE,
+    (char *)0,
+    dshi_fields,
     0,
-    "mach_id = %d",
-    1,
-    &VDmach,
+    "service = UPPER('%s') AND mach_id = %d",
+    2,
+    &dshi_validate,
   },
 
   {
@@ -3591,8 +3933,8 @@ struct query Queries2[] = {
     "gslo",
     RETRIEVE,
     "sh",
-    "serverhosts",
-    "CHAR(sh.service), CHAR(m.name) FROM serverhosts sh, machine m",
+    SERVERHOSTS_TABLE,
+    "sh.service, m.name FROM serverhosts sh, machine m",
     gslo_fields,
     2,
     "sh.service LIKE '%s' ESCAPE '*' AND sh.mach_id = m.mach_id",
@@ -3606,8 +3948,8 @@ struct query Queries2[] = {
     "gfsl",
     RETRIEVE,
     "fs",
-    FILESYS,
-    "CHAR(fs.label), fs.type, CHAR(m.name), CHAR(fs.name), fs.mount, fs.access, fs.comments, CHAR(u.login), CHAR(l.name), CHAR(fs.createflg), fs.lockertype, CHAR(fs.modtime), CHAR(fs.modby), fs.modwith FROM filesys fs, machine m, users u, list l",
+    FILESYS_TABLE,
+    "fs.label, fs.type, m.name, fs.name, fs.mount, fs.rwaccess, fs.comments, u.login, l.name, fs.createflg, fs.lockertype, TO_CHAR(fs.modtime, 'DD-mon-YYYY HH24:MI:SS'), fs.modby, fs.modwith FROM filesys fs, machine m, users u, list l",
     gfsl_fields,
     14,
     "fs.label LIKE '%s' ESCAPE '*' AND fs.mach_id = m.mach_id AND fs.owner = u.users_id AND fs.owners = l.list_id",
@@ -3621,8 +3963,8 @@ struct query Queries2[] = {
     "gfsm",
     RETRIEVE,
     "fs",
-    FILESYS,
-    "CHAR(fs.label), fs.type, CHAR(m.name), CHAR(fs.name), fs.mount, fs.access, fs.comments, CHAR(u.login), CHAR(l.name), CHAR(fs.createflg), fs.lockertype, CHAR(fs.modtime), CHAR(fs.modby), fs.modwith FROM filesys fs, machine m, users u, list l",
+    FILESYS_TABLE,
+    "fs.label, fs.type, m.name, fs.name, fs.mount, fs.rwaccess, fs.comments, u.login, l.name, fs.createflg, fs.lockertype, TO_CHAR(fs.modtime, 'DD-mon-YYYY HH24:MI:SS'), fs.modby, fs.modwith FROM filesys fs, machine m, users u, list l",
     gfsm_fields,
     14,
     "fs.mach_id = %d AND m.mach_id = fs.mach_id AND fs.owner = u.users_id AND fs.owners = l.list_id",
@@ -3636,8 +3978,8 @@ struct query Queries2[] = {
     "gfsn",
     RETRIEVE,
     "fs",
-    FILESYS,
-    "CHAR(fs.label), fs.type, CHAR(m.name), CHAR(fs.name), fs.mount, fs.access, fs.comments, CHAR(u.login), CHAR(l.name), CHAR(fs.createflg), fs.lockertype, CHAR(fs.modtime), CHAR(fs.modby), fs.modwith FROM filesys fs, machine m, users u, list l, nfsphys np",
+    FILESYS_TABLE,
+    "fs.label, fs.type, m.name, fs.name, fs.mount, fs.rwaccess, fs.comments, u.login, l.name, fs.createflg, fs.lockertype, TO_CHAR(fs.modtime, 'DD-mon-YYYY HH24:MI:SS'), fs.modby, fs.modwith FROM filesys fs, machine m, users u, list l, nfsphys np",
     gfsn_fields,
     14,
     "fs.mach_id = %d AND m.mach_id = fs.mach_id AND fs.owner = u.users_id AND fs.owners = l.list_id AND np.nfsphys_id = fs.phys_id AND np.dir LIKE '%s' ESCAPE '*' AND fs.type = 'NFS'", 
@@ -3651,8 +3993,8 @@ struct query Queries2[] = {
     "gfsg",
     RETRIEVE,
     "fs",
-    FILESYS,
-    "CHAR(fs.label), fs.type, CHAR(m.name), CHAR(fs.name), fs.mount, fs.access, fs.comments, CHAR(u.login), CHAR(l.name), CHAR(fs.createflg), fs.lockertype, CHAR(fs.modtime), CHAR(fs.modby), fs.modwith FROM filesys fs, machine m, users u, list l",
+    FILESYS_TABLE,
+    "fs.label, fs.type, m.name, fs.name, fs.mount, fs.rwaccess, fs.comments, u.login, l.name, fs.createflg, fs.lockertype, TO_CHAR(fs.modtime, 'DD-mon-YYYY HH24:MI:SS'), fs.modby, fs.modwith FROM filesys fs, machine m, users u, list l",
     gfsg_fields,
     14,
     "fs.owners = %d AND m.mach_id = fs.mach_id AND fs.owner = u.users_id AND fs.owners = l.list_id",
@@ -3666,8 +4008,8 @@ struct query Queries2[] = {
     "gfsp",
     RETRIEVE,
     "fs",
-    FILESYS,
-    "CHAR(fs.label), fs.type, CHAR(m.name), CHAR(fs.name), fs.mount, fs.access, fs.comments, CHAR(u.login), CHAR(l.name), CHAR(fs.createflg), fs.lockertype, CHAR(fs.modtime), CHAR(fs.modby), fs.modwith FROM filesys fs, machine m, users u, list l",
+    FILESYS_TABLE,
+    "fs.label, fs.type, m.name, fs.name, fs.mount, fs.rwaccess, fs.comments, u.login, l.name, fs.createflg, fs.lockertype, TO_CHAR(fs.modtime, 'DD-mon-YYYY HH24:MI:SS'), fs.modby, fs.modwith FROM filesys fs, machine m, users u, list l",
     gfsp_fields,
     14,
     "fs.name LIKE '%s' ESCAPE '*' AND m.mach_id = fs.mach_id AND fs.owner = u.users_id AND fs.owners = list_id",
@@ -3681,8 +4023,8 @@ struct query Queries2[] = {
     "afil",
     APPEND,
     "fs",
-    FILESYS,
-    "INTO filesys (label, type, mach_id, name, mount, access, comments, owner, owners, createflg, lockertype, filsys_id) VALUES ('%s','%s',%d,'%s','%s','%s','%s',%d,%d,%s,'%s',%s)",
+    FILESYS_TABLE,
+    "INTO filesys (label, type, mach_id, name, mount, rwaccess, comments, owner, owners, createflg, lockertype, filsys_id) VALUES ('%s','%s',%d,NVL('%s',CHR(0)),'%s','%s',NVL('%s',CHR(0)),%d,%d,%s,'%s',%s)",
     afil_fields,
     11,
     0,
@@ -3696,8 +4038,8 @@ struct query Queries2[] = {
     "ufil",
     UPDATE,
     "fs",
-    FILESYS,
-    "filesys SET label = '%s', type = '%s', mach_id = %d, name = '%s', mount = '%s', access = '%s', comments = '%s', owner = %d, owners = %d, createflg = %s, lockertype = '%s'",
+    FILESYS_TABLE,
+    "filesys SET label = '%s', type = '%s', mach_id = %d, name = NVL('%s',CHR(0)), mount = '%s', rwaccess = '%s', comments = NVL('%s',CHR(0)), owner = %d, owners = %d, createflg = %s, lockertype = '%s'",
     ufil_fields,
     11,
     "filsys_id = %d",
@@ -3711,7 +4053,7 @@ struct query Queries2[] = {
     "dfil",
     DELETE,
     "fs",
-    FILESYS,
+    FILESYS_TABLE,
     (char *)0,
     dfil_fields,
     0,
@@ -3726,8 +4068,8 @@ struct query Queries2[] = {
     "gfgm",
     RETRIEVE,
     "fg",
-    "fsgroup",
-    "CHAR(fs.label), fg.key FROM fsgroup fg, filesys fs",
+    FSGROUP_TABLE,
+    "fs.label, fg.key FROM fsgroup fg, filesys fs",
     gfgm_fields,
     2,
     "fg.group_id = %d AND fs.filsys_id = fg.filsys_id",
@@ -3741,7 +4083,7 @@ struct query Queries2[] = {
     "aftg",
     APPEND,
     "fg",
-    "fsgroup",
+    FSGROUP_TABLE,
     "INTO fsgroup (group_id,filsys_id,key) VALUES (%d, %d, '%s')",
     gfgm_fields,
     3,
@@ -3756,7 +4098,7 @@ struct query Queries2[] = {
     "rffg",
     DELETE,
     "fg",
-    "fsgroup",
+    FSGROUP_TABLE,
     (char *)0,
     gfgm_fields,
     0,
@@ -3771,8 +4113,8 @@ struct query Queries2[] = {
     "ganf",
     RETRIEVE,
     "np",
-    "nfsphys",
-    "CHAR(m.name), CHAR(np.dir), np.device, CHAR(np.status), CHAR(np.allocated), CHAR(np.partsize), CHAR(np.modtime), CHAR(np.modby), np.modwith FROM nfsphys np, machine m",
+    NFSPHYS_TABLE,
+    "m.name, np.dir, np.device, np.status, np.allocated, np.partsize, TO_CHAR(np.modtime, 'DD-mon-YYYY HH24:MI:SS'), np.modby, np.modwith FROM nfsphys np, machine m",
     ganf_fields,
     9,
     "m.mach_id = np.mach_id",
@@ -3786,8 +4128,8 @@ struct query Queries2[] = {
     "gnfp",
     RETRIEVE,
     "np",
-    "nfsphys",
-    "CHAR(m.name), CHAR(np.dir), np.device, CHAR(np.status), CHAR(np.allocated), CHAR(np.partsize), CHAR(np.modtime), CHAR(np.modby), np.modwith FROM nfsphys np, machine m",
+    NFSPHYS_TABLE,
+    "m.name, np.dir, np.device, np.status, np.allocated, np.partsize, TO_CHAR(np.modtime, 'DD-mon-YYYY HH24:MI:SS'), np.modby, np.modwith FROM nfsphys np, machine m",
     gnfp_fields,
     9,
     "np.mach_id = %d AND np.dir LIKE '%s' ESCAPE '*' AND m.mach_id = np.mach_id", 
@@ -3801,8 +4143,8 @@ struct query Queries2[] = {
     "anfp",
     APPEND,
     "np",
-    "nfsphys",
-    "INTO nfsphys (mach_id, dir, device, status, allocated, partsize, nfsphys_id) VALUES (%d, '%s', '%s', %s, %s, %s, %s)",
+    NFSPHYS_TABLE,
+    "INTO nfsphys (mach_id, dir, device, status, allocated, partsize, nfsphys_id) VALUES (%d, '%s', NVL('%s',CHR(0)), %s, %s, %s, %s)",
     ganf_fields,
     6,
     0,
@@ -3816,8 +4158,8 @@ struct query Queries2[] = {
     "unfp",
     UPDATE,
     "np",
-    "nfsphys",
-    "nfsphys SET device = '%s', status = %s, allocated = %s, partsize = %s",
+    NFSPHYS_TABLE,
+    "nfsphys SET device = NVL('%s',CHR(0)), status = %s, allocated = %s, partsize = %s",
     ganf_fields,
     4,
     "mach_id = %d AND dir = '%s'", 
@@ -3831,7 +4173,7 @@ struct query Queries2[] = {
     "ajnf",
     UPDATE,
     "np",
-    "nfsphys",
+    NFSPHYS_TABLE,
     "nfsphys SET allocated = allocated + %s",
     ajnf_fields,
     1,
@@ -3846,7 +4188,7 @@ struct query Queries2[] = {
     "dnfp",
     DELETE,
     "np",
-    "nfsphys",
+    NFSPHYS_TABLE,
     (char *)0,
     dnfp_fields,
     0,
@@ -3861,8 +4203,8 @@ struct query Queries2[] = {
     "gqot",
     RETRIEVE,
     "q",
-    QUOTA,
-    "CHAR(fs.label), q.type, CHAR(q.entity_id), CHAR(q.quota), CHAR(q.phys_id), CHAR(m.name), CHAR(q.modtime), CHAR(q.modby), q.modwith FROM quota q, filesys fs, machine m",
+    QUOTA_TABLE,
+    "fs.label, q.type, q.entity_id, q.quota, q.phys_id, m.name, TO_CHAR(q.modtime, 'DD-mon-YYYY HH24:MI:SS'), q.modby, q.modwith FROM quota q, filesys fs, machine m",
     gqot_fields,
     9,
     "fs.label LIKE '%s' ESCAPE '*' AND q.type = '%s' AND q.entity_id = %d AND fs.filsys_id = q.filsys_id AND m.mach_id = fs.mach_id",
@@ -3876,8 +4218,8 @@ struct query Queries2[] = {
     "gqbf",
     RETRIEVE,
     "q",
-    QUOTA,
-    "CHAR(fs.label), q.type, CHAR(q.entity_id), CHAR(q.quota), CHAR(q.phys_id), CHAR(m.name), CHAR(q.modtime), CHAR(q.modby), q.modwith FROM quota q, filesys fs, machine m",
+    QUOTA_TABLE,
+    "fs.label, q.type, q.entity_id, q.quota, q.phys_id, m.name, TO_CHAR(q.modtime, 'DD-mon-YYYY HH24:MI:SS'), q.modby, q.modwith FROM quota q, filesys fs, machine m",
     gqbf_fields,
     9,
     "fs.label LIKE '%s' ESCAPE '*' AND fs.filsys_id = q.filsys_id AND m.mach_id = fs.mach_id",
@@ -3891,7 +4233,7 @@ struct query Queries2[] = {
     "aqot",
     APPEND,
     0,
-    QUOTA,
+    QUOTA_TABLE,
     "INTO quota (filsys_id, type, entity_id, quota, phys_id) VALUES ('%s', %d, %d, %s, %s)",
     aqot_fields,
     4,
@@ -3906,7 +4248,7 @@ struct query Queries2[] = {
     "uqot",
     UPDATE,
     0,
-    QUOTA,
+    QUOTA_TABLE,
     "quota SET quota = %s",
     aqot_fields,
     1,
@@ -3921,7 +4263,7 @@ struct query Queries2[] = {
     "dqot",
     DELETE,
     0,
-    QUOTA,
+    QUOTA_TABLE,
     (char *)0,
     aqot_fields,
     0,
@@ -3936,8 +4278,8 @@ struct query Queries2[] = {
     "gnfq",
     RETRIEVE,
     "q",
-    QUOTA,
-    "CHAR(fs.label), CHAR(u.login), CHAR(q.quota), CHAR(q.phys_id), CHAR(m.name), CHAR(q.modtime), CHAR(q.modby), q.modwith FROM quota q, filesys fs, users u, machine m",
+    QUOTA_TABLE,
+    "fs.label, u.login, q.quota, q.phys_id, m.name, TO_CHAR(q.modtime, 'DD-mon-YYYY HH24:MI:SS'), q.modby, q.modwith FROM quota q, filesys fs, users u, machine m",
     gnfq_fields,
     8,
     "fs.label LIKE '%s' ESCAPE '*' AND q.type = 'USER' AND q.entity_id = u.users_id AND fs.filsys_id = q.filsys_id AND m.mach_id = fs.mach_id AND u.login = '%s'",
@@ -3951,8 +4293,8 @@ struct query Queries2[] = {
     "gnqp",
     RETRIEVE,
     "q",
-    QUOTA,
-    "CHAR(fs.label), CHAR(u.login), CHAR(q.quota), CHAR(np.dir), CHAR(m.name) FROM quota q, filesys fs, users u, nfsphys np, machine m",
+    QUOTA_TABLE,
+    "fs.label, u.login, q.quota, np.dir, m.name FROM quota q, filesys fs, users u, nfsphys np, machine m",
     gnqp_fields,
     5,
     "np.mach_id = %d AND np.dir LIKE '%s' ESCAPE '*' AND q.phys_id = np.nfsphys_id AND fs.filsys_id = q.filsys_id AND q.type = 'USER' AND u.users_id = q.entity_id AND m.mach_id = np.mach_id",
@@ -3966,7 +4308,7 @@ struct query Queries2[] = {
     "anfq",
     APPEND,
     0,
-    QUOTA,
+    QUOTA_TABLE,
     "INTO quota (type, filsys_id, entity_id, quota, phys_id ) VALUES ('USER', %d, %d, %s, %s)",
     anfq_fields,
     3,
@@ -3981,7 +4323,7 @@ struct query Queries2[] = {
     "unfq",
     UPDATE,
     0,
-    QUOTA,
+    QUOTA_TABLE,
     "quota SET quota = %s",
     anfq_fields,
     1,
@@ -3996,7 +4338,7 @@ struct query Queries2[] = {
     "dnfq",
     DELETE,
     0,
-    QUOTA,
+    QUOTA_TABLE,
     (char *)0,
     anfq_fields,
     0,
@@ -4005,215 +4347,20 @@ struct query Queries2[] = {
     &dnfq_validate,
   },
 
-  {
-    /* Q_GLIN - GET_LIST_INFO */
-    "get_list_info",
-    "glin",
-    RETRIEVE,
-    0,
-    LIST,
-    0,
-    glin_fields,
-    13,
-    0,
-    1,              
-    &glin_validate, 
-  },
-    
-  {
-    /* Q_EXLN - EXPAND_LIST_NAMES */
-    "expand_list_names",
-    "exln",
-    RETRIEVE,
-    "l",
-    LIST,
-    "CHAR(l.name) FROM list l",
-    glin_fields,
-    1,
-    "l.name LIKE '%s' ESCAPE '*' AND l.list_id != 0",
-    1,
-    &VDwild0,
-  },
-    
-  {
-    /* Q_ALIS - ADD_LIST */ /* uses prefetch_value() for list_id */
-    "add_list",
-    "alis",
-    APPEND,
-    "l",
-    LIST, 
-    "INTO list (name, active, publicflg, hidden, maillist, grouplist, gid, acl_type, acl_id, description, list_id) VALUES ('%s',%s,%s,%s,%s,%s,%s,'%s',%d,'%s',%s)",
-    alis_fields,
-    10,
-    0,
-    0,
-    &alis_validate,
-  },
-
-  {
-    /* Q_ULIS - UPDATE_LIST */
-    "update_list",
-    "ulis",
-    UPDATE,
-    "l",
-    LIST,
-    "list SET name='%s', active=%s, publicflg=%s, hidden=%s, maillist=%s, grouplist=%s, gid=%s, acl_type='%s', acl_id=%d, description='%s'",
-    ulis_fields,
-    10,
-    "list_id = %d",
-    1,
-    &ulis_validate,
-  },
-
-  {
-    /* Q_DLIS - DELETE_LIST */
-    "delete_list",
-    "dlis",
-    DELETE,
-    "l",
-    LIST,
-    (char *)0,
-    dlis_fields,
-    0,
-    "list_id = %d",
-    1,
-    &dlis_validate,
-  },
-
-  {
-    /* Q_AMTL - ADD_MEMBER_TO_LIST */
-    "add_member_to_list",
-    "amtl",
-    APPEND,
-    0,
-    "imembers",
-    0,
-    amtl_fields,
-    3,
-    (char *)0,
-    0,
-    &amtl_validate,
-  },
-
-  {
-    /* Q_DMFL - DELETE_MEMBER_FROM_LIST */
-    "delete_member_from_list",
-    "dmfl",
-    DELETE,
-    0,
-    "imembers",
-    (char *)0,
-    amtl_fields,
-    0,
-    0,
-    3,
-    &dmfl_validate,
-  },
-
-  {
-    /* Q_GAUS - GET_ACE_USE */
-    "get_ace_use",
-    "gaus",
-    RETRIEVE,
-    0,
-    0,
-    0,
-    gaus_fields,
-    2,
-    0,
-    2,
-    &gaus_validate,
-  },
-
-  {
-    /* Q_QGLI - QUALIFIED_GET_LISTS */
-    "qualified_get_lists",
-    "qgli",
-    RETRIEVE,
-    0,
-    LIST,
-    0,
-    qgli_fields,
-    1,
-    0,
-    5,
-    &qgli_validate,
-  },
-
-  {
-    /* Q_GMOL - GET_MEMBERS_OF_LIST */
-    "get_members_of_list",
-    "gmol",
-    RETRIEVE,
-    (char *)0,
-    "imembers",
-    (char *)0,
-    gmol_fields,
-    2,
-    (char *)0,
-    1,
-    &gmol_validate,
-  },
-
-  {
-    /* Q_GEML - GET_END_MEMBERS_OF_LIST */
-    "get_end_members_of_list",
-    "geml",
-    RETRIEVE,
-    (char *)0,
-    "imembers",
-    (char *)0,
-    gmol_fields,
-    0,
-    (char *)0,
-    1,
-    &geml_validate,
-  },
-  {
-    /* Q_GLOM - GET_LISTS_OF_MEMBER */
-    "get_lists_of_member",
-    "glom",
-    RETRIEVE,
-    0,
-    "imembers",
-    0,
-    glom_fields,
-    6,
-    0,
-    2,
-    &glom_validate,
-  },
-
-  {
-    /* Q_CMOL - COUNT_MEMBERS_OF_LIST */
-    "count_members_of_list",
-    "cmol",
-    RETRIEVE,
-    0,
-    "imembers",
-    0,
-    cmol_fields,
-    1,
-    0,
-    1,
-    &cmol_validate,
-  },
-
   {
     /* Q_GZCL - GET_ZEPHYR_CLASS */
     "get_zephyr_class",
     "gzcl",
     RETRIEVE,
     "z",
-    "zephyr",
-    "CHAR(z.class), z.xmt_type, CHAR(z.xmt_id), z.sub_type, CHAR(z.sub_id), z.iws_type, CHAR(z.iws_id), z.iui_type, CHAR(z.iui_id), CHAR(z.modtime), CHAR(z.modby), z.modwith FROM zephyr z",
+    ZEPHYR_TABLE,
+    "class, xmt_type, xmt_id, sub_type, sub_id, iws_type, iws_id, iui_type, iui_id, TO_CHAR(modtime, 'DD-mon-YYYY HH24:MI:SS'), modby, modwith FROM zephyr",
     gzcl_fields,
     12,
-    "z.class LIKE '%s' ESCAPE '*'",
+    "class LIKE '%s' ESCAPE '*'",
     1,
     &gzcl_validate,
-  },    
+  },
 
   {
     /* Q_AZCL - ADD_ZEPHYR_CLASS */
@@ -4221,7 +4368,7 @@ struct query Queries2[] = {
     "azcl",
     APPEND,
     "z",
-    "zephyr",
+    ZEPHYR_TABLE,
     "INTO zephyr (class, xmt_type, xmt_id, sub_type, sub_id, iws_type, iws_id, iui_type, iui_id) VALUES ('%s','%s',%d,'%s',%d,'%s',%d,'%s',%d)",
     azcl_fields,
     9,
@@ -4236,7 +4383,7 @@ struct query Queries2[] = {
     "uzcl",
     UPDATE,
     "z",
-    "zephyr",
+    ZEPHYR_TABLE,
     "zephyr SET class = '%s', xmt_type = '%s', xmt_id = %d, sub_type = '%s', sub_id = %d, iws_type = '%s', iws_id = %d, iui_type = '%s', iui_id = %d",
     uzcl_fields,
     9,
@@ -4251,7 +4398,7 @@ struct query Queries2[] = {
     "dzcl",
     DELETE,
     "z",
-    "zephyr",
+    ZEPHYR_TABLE,
     0,
     uzcl_fields,
     0,
@@ -4260,17 +4407,77 @@ struct query Queries2[] = {
     &dzcl_validate,
   },    
 
+  {
+    /* Q_GSHA - GET_SERVER_HOST_ACCESS */ 
+    "get_server_host_access",
+    "gsha",
+    RETRIEVE,
+    "ha",
+    HOSTACCESS_TABLE,
+    "m.name, ha.acl_type, ha.acl_id, TO_CHAR(ha.modtime, 'DD-mon-YYYY HH24:MI:SS'), ha.modby, ha.modwith FROM hostaccess ha, machine m",
+    gsha_fields,
+    6,
+    "m.name LIKE '%s' ESCAPE '*' AND ha.mach_id = m.mach_id",
+    1,
+    &gsha_validate,
+  },
+
+  {
+    /* Q_ASHA - ADD_SERVER_HOST_ACCESS */
+    "add_server_host_access",
+    "asha",
+    APPEND,
+    "ha",
+    HOSTACCESS_TABLE,
+    "INTO hostaccess (mach_id, acl_type, acl_id) VALUES (%d,'%s',%d)",
+    asha_fields,
+    3,
+    0,
+    0,
+    &asha_validate,
+  },
+
+  {
+    /* Q_USHA - UPDATE_SERVER_HOST_ACCESS */
+    "update_server_host_access",
+    "usha",
+    UPDATE,
+    "ha",
+    HOSTACCESS_TABLE,
+    "hostaccess SET acl_type = '%s', acl_id = %d",
+    asha_fields,
+    2,
+    "mach_id = %d",
+    1,
+    &asha_validate,
+  },
+
+  {
+    /* Q_DSHA - DELETE_SERVER_HOST_ACCESS */
+    "delete_server_host_access",
+    "dsha",
+    DELETE,
+    "ha",
+    HOSTACCESS_TABLE,
+    0,
+    asha_fields,
+    0,
+    "mach_id = %d",
+    1,
+    &VDmach,
+  },
+
   {
     /* Q_GSVC - GET_SERVICE */
     "get_service",
     "gsvc",
     RETRIEVE,
     "ss",
-    "services",
-    "CHAR(ss.name), ss.protocol, CHAR(ss.port), ss.description, CHAR(ss.modtime), CHAR(ss.modby), ss.modwith FROM services ss",
+    SERVICES_TABLE,
+    "name, protocol, port, description, TO_CHAR(modtime, 'DD-mon-YYYY HH24:MI:SS'), modby, modwith FROM services",
     gsvc_fields,
     7,
-    "ss.name LIKE '%s' ESCAPE '*'",
+    "name LIKE '%s' ESCAPE '*'",
     1,
     &VDwildsortf,
   },
@@ -4281,8 +4488,8 @@ struct query Queries2[] = {
     "asvc",
     APPEND,
     "ss",
-    "services",
-    "INTO services (name, protocol, port, description) VALUES ('%s','%s',%s,'%s')",
+    SERVICES_TABLE,
+    "INTO services (name, protocol, port, description) VALUES ('%s','%s',%s,NVL('%s',CHR(0)))",
     asvc_fields,
     4,
     (char *)0,
@@ -4296,7 +4503,7 @@ struct query Queries2[] = {
     "dsvc",
     DELETE,
     "ss",
-    "services",
+    SERVICES_TABLE,
     0,
     asvc_fields,
     0,
@@ -4311,8 +4518,8 @@ struct query Queries2[] = {
     "gpce",
     RETRIEVE,
     "pc",
-    "printcap",
-    "CHAR(pc.name), CHAR(m.name), pc.dir, pc.rp, CHAR(pc.quotaserver), CHAR(pc.auth), CHAR(pc.price), pc.comments, CHAR(pc.modtime), CHAR(pc.modby), pc.modwith FROM printcap pc, machine m",
+    PRINTCAP_TABLE,
+    "pc.name, m.name, pc.dir, pc.rp, pc.quotaserver, pc.auth, pc.price, pc.comments, TO_CHAR(pc.modtime, 'DD-mon-YYYY HH24:MI:SS'), pc.modby, pc.modwith FROM printcap pc, machine m",
     gpce_fields,
     11,
     "pc.name LIKE '%s' ESCAPE '*' AND m.mach_id = pc.mach_id",
@@ -4326,8 +4533,8 @@ struct query Queries2[] = {
     "apce",
     APPEND,
     "pc",
-    "printcap",
-    "INTO printcap (name, mach_id, dir, rp, quotaserver, auth, price, comments) VALUES ('%s',%d,'%s','%s',%d,%s,%s,'%s')",
+    PRINTCAP_TABLE,
+    "INTO printcap (name, mach_id, dir, rp, quotaserver, auth, price, comments) VALUES ('%s',%d,'%s','%s',%d,%s,%s,NVL('%s',CHR(0)))",
     apce_fields,
     8,
     0,
@@ -4341,7 +4548,7 @@ struct query Queries2[] = {
     "dpce",
     DELETE,
     "pc",
-    "printcap",
+    PRINTCAP_TABLE,
     0,
     apce_fields,
     0,
@@ -4356,8 +4563,8 @@ struct query Queries2[] = {
     "gpcp",
     RETRIEVE,
     "pc",
-    "printcap",
-    "CHAR(pc.name), CHAR(m.name), pc.dir, pc.rp, pc.comments, CHAR(pc.modtime), CHAR(pc.modby), pc.modwith FROM printcap pc, machine m",
+    PRINTCAP_TABLE,
+    "pc.name, m.name, pc.dir, pc.rp, pc.comments, TO_CHAR(pc.modtime, 'DD-mon-YYYY HH24:MI:SS'), pc.modby, pc.modwith FROM printcap pc, machine m",
     gpcp_fields,
     8,
     "pc.name LIKE '%s' ESCAPE '*' AND m.mach_id = pc.mach_id",
@@ -4371,7 +4578,7 @@ struct query Queries2[] = {
     "dpcp",
     DELETE,
     "pc",
-    "printcap",
+    PRINTCAP_TABLE,
     0,
     apce_fields,
     0,
@@ -4386,8 +4593,8 @@ struct query Queries2[] = {
     "gpdm",
     RETRIEVE,
     "pal",
-    "palladium",
-    "CHAR(pal.name), CHAR(pal.ident), CHAR(m.name), CHAR(pal.modtime), CHAR(pal.modby), pal.modwith FROM palladium pal, machine m",
+    PALLADIUM_TABLE,
+    "pal.name, pal.identifier, m.name, TO_CHAR(pal.modtime, 'DD-mon-YYYY HH24:MI:SS'), pal.modby, pal.modwith FROM palladium pal, machine m",
     gpdm_fields,
     6,
     "pal.name LIKE '%s' ESCAPE '*' AND m.mach_id = pal.mach_id",
@@ -4401,8 +4608,8 @@ struct query Queries2[] = {
     "apdm",
     APPEND,
     "pal",
-    "palladium",
-    "INTO palladium (name, ident, mach_id) VALUES ('%s',%s,%d)",
+    PALLADIUM_TABLE,
+    "INTO palladium (name, identifier, mach_id) VALUES ('%s',%s,%d)",
     apdm_fields,
     3,
     0,
@@ -4416,7 +4623,7 @@ struct query Queries2[] = {
     "dpdm",
     DELETE,
     "pal",
-    "palladium",
+    PALLADIUM_TABLE,
     0,
     apdm_fields,
     0,
@@ -4431,11 +4638,11 @@ struct query Queries2[] = {
     "gali",
     RETRIEVE,
     "a",
-    ALIAS,
-    "CHAR(a.name), CHAR(a.type), CHAR(a.trans) FROM alias a",
+    ALIAS_TABLE,
+    "name, type, trans FROM alias",
     gali_fields,
     3,
-    "a.name LIKE '%s' ESCAPE '*' AND a.type LIKE '%s' ESCAPE '*' AND a.trans LIKE '%s' ESCAPE '*'",
+    "name LIKE '%s' ESCAPE '*' AND type LIKE '%s' ESCAPE '*' AND trans LIKE '%s' ESCAPE '*'",
     3,
     &VDwild3sort1,
   },
@@ -4446,7 +4653,7 @@ struct query Queries2[] = {
     "aali",
     APPEND,
     "a",
-    ALIAS,
+    ALIAS_TABLE,
     "INTO alias (name, type, trans) VALUES ('%s', '%s', '%s')",
     aali_fields,
     3,
@@ -4461,7 +4668,7 @@ struct query Queries2[] = {
     "dali",
     DELETE,
     "a",
-    ALIAS,
+    ALIAS_TABLE,
     (char *)0,
     aali_fields,
     0,
@@ -4476,11 +4683,11 @@ struct query Queries2[] = {
     "gval",
     RETRIEVE,
     "val",
-    "numvalues",
-    "CHAR(val.value) FROM numvalues val",
+    NUMVALUES_TABLE,
+    "value FROM numvalues",
     gval_fields,
     1,
-    "val.name = '%s'",
+    "name = '%s'",
     1,
     &gval_validate,
   },
@@ -4491,7 +4698,7 @@ struct query Queries2[] = {
     "aval",
     APPEND,
     "val",
-    "numvalues",
+    NUMVALUES_TABLE,
     "INTO numvalues (name, value) VALUES ('%s', %s)",
     aval_fields,
     2,
@@ -4506,7 +4713,7 @@ struct query Queries2[] = {
     "uval",
     UPDATE,
     "val",
-    "numvalues",
+    NUMVALUES_TABLE,
     "numvalues SET value = %s",
     aval_fields,
     1,
@@ -4521,7 +4728,7 @@ struct query Queries2[] = {
     "dval",
     DELETE,
     "val",
-    "numvalues",
+    NUMVALUES_TABLE,
     (char *)0,
     dval_fields,
     0,
@@ -4536,8 +4743,8 @@ struct query Queries2[] = {
     "gats",
     RETRIEVE,
     "tbs",
-    "tblstats",
-    "tbs.table_name, CHAR(tbs.appends), CHAR(tbs.updates), CHAR(tbs.deletes), CHAR(tbs.modtime) FROM tblstats tbs",
+    TBLSTATS_TABLE,
+    "table_name, appends, updates, deletes, TO_CHAR(modtime, 'DD-mon-YYYY HH24:MI:SS') FROM tblstats",
     gats_fields,
     5,
     (char *)0,
@@ -4551,7 +4758,7 @@ struct query Queries2[] = {
     "_sdl",
     UPDATE,
     (char *)0,
-    (char *)0,
+    0,
     (char *)0,
     _sdl_fields,
     1,
index 9a0e9aef7f049ada01da61ad6f424a6e0764fdc0..16defd14433d6fb99320a1789e3db1ce7ff61d51 100644 (file)
@@ -6,6 +6,15 @@
 /* Query Types */
 enum query_type {RETRIEVE, UPDATE, APPEND, DELETE, SPECIAL};
 
+/* Tables */
+enum tables {NO_TABLE, USERS_TABLE, KRBMAP_TABLE, MACHINE_TABLE,
+            HOSTALIAS_TABLE, SUBNET_TABLE, CLUSTER_TABLE, MCMAP_TABLE,
+            SVC_TABLE, LIST_TABLE, IMEMBERS_TABLE, SERVERS_TABLE,
+            SERVERHOSTS_TABLE, FILESYS_TABLE, FSGROUP_TABLE, NFSPHYS_TABLE,
+            QUOTA_TABLE, ZEPHYR_TABLE, HOSTACCESS_TABLE, STRINGS_TABLE,
+            SERVICES_TABLE, PRINTCAP_TABLE, PALLADIUM_TABLE, CAPACLS_TABLE,
+            ALIAS_TABLE, NUMVALUES_TABLE, TBLSTATS_TABLE, INCREMENTAL_TABLE};
+
 /* Query Definition Structure */
 struct query
 {
@@ -13,7 +22,7 @@ struct query
     char *shortname;           /* abbreviated query name (must be 4 chars) */
     enum query_type type;      /* query type */
     char *rvar;                        /* range variable */
-    char *rtable;              /* range table */
+    enum tables rtable;                /* range table */
     char *tlist;               /* target list */
     char **fields;             /* input and output variable names (for help) */
     int  vcnt;                 /* variable count */
@@ -46,15 +55,44 @@ struct validate
        
 /* Validated Object Types */
 enum vo_type {V_NAME, V_ID, V_TYPE, V_TYPEDATA, V_DATE, 
-             V_SORT, V_RENAME, V_CHAR, V_LOCK, V_WILD, V_UPWILD};
+             V_SORT, V_RENAME, V_CHAR, V_LOCK, V_WILD, V_UPWILD,
+              V_RLOCK, V_LEN};
 
 /* Validated Object Definition */
 struct valobj
 {
     enum vo_type type;
     int index;                 /* index of object to validate */
-    char *table;               /* table containing object */
+    enum tables table;         /* table containing object */
     char *namefield;           /* table's fieldname for object */
     char *idfield;             /* table's corresponding id field (if any) */
     int error;
 };
+
+
+/* prototypes from cache.dc */
+void flush_cache(void);
+int name_to_id(char *name, enum tables type, int *id);
+int id_to_name(int id, enum tables type, char **name);
+int cache_entry(char *name, enum tables type, int id);
+void flush_name(char *name, enum tables type);
+void cache_commit(void);
+void cache_abort(void);
+
+/* prototypes from increment.dc */
+void incremental_before(enum tables table, char *qualx, char **argv);
+void incremental_clear_before(void);
+void incremental_after(enum tables table, char *qualx, char **argv);
+void incremental_clear_after(void);
+
+/* prototypes from qfollow.dc */
+int set_pobox_modtime(struct query *q, char *argv[], client *cl);
+
+/* prototypes from qrtn.dc */
+int check_query_access(struct query *q, char *argv[], client *cl);
+int set_next_object_id(char *objectx, enum tables table, int limit);
+
+/* prototypes from qsubs.c */
+void list_queries(int version, int (*action)(), int actarg);
+void help_query(struct query *q, int (*action)(), int actarg);
+struct query *get_query_by_name(char *name, int version);
index 188d4ffb88a36748698e69cb5960b9e71795dcce..b2966b4c3caf53260625f91f1a416e0a11d46184 100644 (file)
@@ -15,38 +15,42 @@ static char *rcsid_qsupport_dc = "$Header$";
 
 #include <mit-copyright.h>
 #include <unistd.h>
-#include "query.h"
 #include "mr_server.h"
+#include "query.h"
 #include <ctype.h>
+#include <string.h>
 EXEC SQL INCLUDE sqlca;
 EXEC SQL INCLUDE sqlda;
 #include "qrtn.h"
 
-extern char *whoami;
-extern int ingres_errno, mr_errcode;
+extern char *whoami, *table_name[], *sqlbuffer[QMAXARGS];
+extern int dbms_errno, mr_errcode;
 
 EXEC SQL BEGIN DECLARE SECTION;
 extern char stmt_buf[];
 EXEC SQL END DECLARE SECTION;
 
-EXEC SQL WHENEVER SQLERROR CALL ingerr;
+int validate_chars(char *argv[], struct valobj *vo);
+int validate_id(struct query *, char *argv[], struct valobj *vo);
+int validate_name(char *argv[], struct valobj *vo);
+int validate_rename(char *argv[], struct valobj *vo);
+int validate_type(char *argv[], struct valobj *vo);
+int validate_typedata(struct query *, char *argv[], struct valobj *vo);
+int validate_len(char *argv[], struct valobj *vo);
+int lock_table(struct valobj *vo);
+int readlock_table(struct valobj *vo);
+int convert_wildcards_uppercase(char *arg);
 
-#ifdef _DEBUG_MALLOC_INC
-#undef index
-#define dbg_index(str1,c)             DBindex(__FILE__, __LINE__, str1, c)
-#else
-#define dbg_index index
-#endif
+EXEC SQL WHENEVER SQLERROR DO dbmserr();
 
 /* Validation Routines */
 
-validate_row(q, argv, v)
+int validate_row(q, argv, v)
     register struct query *q;
     char *argv[];
     register struct validate *v;
 {
     EXEC SQL BEGIN DECLARE SECTION;
-    char *name;
     char qual[128];
     int rowcount;
     EXEC SQL END DECLARE SECTION;
@@ -59,23 +63,18 @@ validate_row(q, argv, v)
        com_err(whoami, 0, "validating row: %s", qual);
 
     /* look for the record */
-    sprintf(stmt_buf,"SELECT COUNT (*) FROM %s WHERE %s",q->rtable,qual);
-    EXEC SQL PREPARE stmt INTO :SQLDA USING NAMES FROM :stmt_buf;
-    if(sqlca.sqlcode)
-      return(MR_INTERNAL);
-    EXEC SQL DECLARE csr126 CURSOR FOR stmt;
-    EXEC SQL OPEN csr126;
-    EXEC SQL FETCH csr126 USING DESCRIPTOR :SQLDA;
-    EXEC SQL CLOSE csr126;
-    rowcount = *(int *)SQLDA->sqlvar[0].sqldata;
-
-    if (ingres_errno) return(mr_errcode);
+    sprintf(stmt_buf,"SELECT COUNT (*) FROM %s WHERE %s",
+           table_name[q->rtable],qual);
+    dosql(sqlbuffer);
+    if (dbms_errno) return(mr_errcode);
+
+    rowcount = atoi(sqlbuffer[0]);
     if (rowcount == 0) return(MR_NO_MATCH);
     if (rowcount > 1) return(MR_NOT_UNIQUE);
     return(MR_EXISTS);
 }
 
-validate_fields(q, argv, vo, n)
+int validate_fields(q, argv, vo, n)
     struct query *q;
     register char *argv[];
     register struct valobj *vo;
@@ -88,27 +87,29 @@ validate_fields(q, argv, vo, n)
        case V_NAME:
            if (log_flags & LOG_VALID)
                com_err(whoami, 0, "validating %s in %s: %s",
-                   vo->namefield, vo->table, argv[vo->index]);
+                   vo->namefield, table_name[vo->table], argv[vo->index]);
            status = validate_name(argv, vo);
            break;
 
        case V_ID:
            if (log_flags & LOG_VALID)
                com_err(whoami, 0, "validating %s in %s: %s",
-                   vo->idfield, vo->table, argv[vo->index]);
+                   vo->idfield, table_name[vo->table], argv[vo->index]);
            status = validate_id(q, argv, vo);
            break;
 
+           /*
        case V_DATE:
            if (log_flags & LOG_VALID)
                com_err(whoami, 0, "validating date: %s", argv[vo->index]);
            status = validate_date(argv, vo);
            break;
+           */
 
        case V_TYPE:
            if (log_flags & LOG_VALID)
                com_err(whoami, 0, "validating %s type: %s",
-                   vo->table, argv[vo->index]);
+                   table_name[vo->table], argv[vo->index]);
            status = validate_type(argv, vo);
            break;
 
@@ -122,14 +123,20 @@ validate_fields(q, argv, vo, n)
        case V_RENAME:
            if (log_flags & LOG_VALID)
                com_err(whoami, 0, "validating rename %s in %s",
-                       argv[vo->index], vo->table);
+                       argv[vo->index], table_name[vo->table]);
            status = validate_rename(argv, vo);
            break;
 
        case V_CHAR:
            if (log_flags & LOG_VALID)
              com_err(whoami, 0, "validating chars: %s", argv[vo->index]);
-           status = validate_chars(argv[vo->index]);
+           status = validate_chars(argv, vo);
+           break;
+
+       case V_LEN:
+           if (log_flags & LOG_VALID)
+             com_err(whoami, 0, "validating length: %s", argv[vo->index]);
+           status = validate_len(argv, vo);
            break;
 
        case V_SORT:
@@ -140,7 +147,11 @@ validate_fields(q, argv, vo, n)
            status = lock_table(vo);
            break;
 
-       case V_WILD:
+        case V_RLOCK:
+            status = readlock_table(vo);
+            break;
+
+        case V_WILD:
            status = convert_wildcards(argv[vo->index]);
            break;
 
@@ -154,7 +165,7 @@ validate_fields(q, argv, vo, n)
        vo++;
     }
 
-    if (ingres_errno) return(mr_errcode);
+    if (dbms_errno) return(mr_errcode);
     return(MR_SUCCESS);
 }
 
@@ -182,24 +193,45 @@ static int illegalchars[] = {
     1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
 };
 
-validate_chars(s)
-register char *s;
+int validate_chars(argv, vo)
+    char *argv[];
+    register struct valobj *vo;
 {
+    char *s=argv[vo->index];
+    int arg;
+    EXEC SQL BEGIN DECLARE SECTION;
+    int len;
+    char *tname, *cname;
+    EXEC SQL END DECLARE SECTION;
+
+
+    /* check for bad characters */
     while (*s)
       if (illegalchars[*s++])
        return(MR_BAD_CHAR);
-    return(MR_EXISTS);
+
+    /* check for length */
+    tname = table_name[vo->table];
+    cname = vo->namefield;
+    EXEC SQL SELECT data_length INTO :len FROM user_tab_columns
+      WHERE table_name=UPPER(:tname) AND column_name=UPPER(:cname);
+
+    if((strlen(argv[vo->index]) > len) &&
+       strcmp(argv[vo->index], UNIQUE_LOGIN)) /* kludge... sigh */
+      argv[vo->index][len]='\0'; /* truncate */
+
+    return MR_EXISTS;
 }
 
 
-validate_id(q, argv, vo)
+int validate_id(q, argv, vo)
     struct query *q;
     char *argv[];
     register struct valobj *vo;
 {
     EXEC SQL BEGIN DECLARE SECTION;
-    char *name, *tbl, *namefield, *idfield;
-    int id, rowcount;
+    char *name, *namefield, *idfield;
+    int id, rowcount, tbl;
     EXEC SQL END DECLARE SECTION;
     int status;
     register char *c;
@@ -209,90 +241,61 @@ validate_id(q, argv, vo)
     namefield = vo->namefield;
     idfield = vo->idfield;
 
-    if ((!strcmp(tbl, "users") && !strcmp(namefield, "login")) ||
-       !strcmp(tbl, "machine") ||
-       !strcmp(tbl, "subnet") ||
-       !strcmp(tbl, "filesys") ||
-       !strcmp(tbl, "list") ||
-       !strcmp(tbl, "cluster") ||
-       !strcmp(tbl, "strings")) {
-       if (!strcmp(tbl, "machine") || !strcmp(tbl, "subnet"))
-         for (c = name; *c; c++) if (islower(*c)) *c = toupper(*c);
-       status = name_to_id(name, tbl, &id);
-       if (status == 0) {
-           *(int *)argv[vo->index] = id;
-           return(MR_EXISTS);
-       } else if (status == MR_NO_MATCH && !strcmp(tbl, "strings") &&
-                  (q->type == APPEND || q->type == UPDATE)) {
-           id=add_string(name);
-           cache_entry(name, "STRING", id);
-           *(int *)argv[vo->index] = id;
-           return(MR_EXISTS);
-       } else if (status == MR_NO_MATCH || status == MR_NOT_UNIQUE)
-         return(vo->error);
-       else
-         return(status);
-    }
-
-    if (!strcmp(namefield, "uid")) {
-       sprintf(stmt_buf,"SELECT %s FROM %s WHERE %s = %s",idfield,tbl,namefield,name);
+    if ((tbl==USERS_TABLE && !strcmp(namefield, "login")) ||
+       tbl==MACHINE_TABLE || tbl==SUBNET_TABLE || tbl==FILESYS_TABLE ||
+       tbl==LIST_TABLE || tbl==CLUSTER_TABLE || tbl==STRINGS_TABLE) {
+      if (tbl==MACHINE_TABLE || tbl==SUBNET_TABLE)
+       for (c = name; *c; c++) if (islower(*c)) *c = toupper(*c);
+      status = name_to_id(name, tbl, &id);
+      if (status == 0) {
+       *(int *)argv[vo->index] = id;
+       return(MR_EXISTS);
+      } else if (status == MR_NO_MATCH && tbl==STRINGS_TABLE &&
+                (q->type == APPEND || q->type == UPDATE)) {
+       id=add_string(name);
+       cache_entry(name, STRINGS_TABLE, id);
+       *(int *)argv[vo->index] = id;
+       return(MR_EXISTS);
+      } else if (status == MR_NO_MATCH || status == MR_NOT_UNIQUE)
+       return(vo->error);
+      else
+       return(status);
     } else {
-       sprintf(stmt_buf,"SELECT %s FROM %s WHERE %s = '%s'",idfield,tbl,namefield,name);
-    }
-    EXEC SQL PREPARE stmt INTO :SQLDA USING NAMES FROM :stmt_buf;
-    if(sqlca.sqlcode)
-      return(MR_INTERNAL);
-    EXEC SQL DECLARE csr127 CURSOR FOR stmt;
-    EXEC SQL OPEN csr127;
-    rowcount=0;
-    EXEC SQL FETCH csr127 USING DESCRIPTOR :SQLDA;
-    if(sqlca.sqlcode == 0) {
-       rowcount++;
-       EXEC SQL FETCH csr127 USING DESCRIPTOR :SQLDA;
-       if(sqlca.sqlcode == 0) rowcount++;
+      /* else, it's `dubu', which uses unix_uid from users */
+      EXEC SQL SELECT COUNT(*) INTO :rowcount FROM users
+       WHERE unix_uid = :name;
+      if (dbms_errno) return(mr_errcode);
+      if (rowcount != 1) return(vo->error);
+      EXEC SQL SELECT users_id INTO :id FROM users
+       WHERE unix_uid = :name;
+      *(int *)argv[vo->index] = id;
+      return(MR_EXISTS);
     }
-    EXEC SQL CLOSE csr127;
-    if (ingres_errno)
-      return(mr_errcode);
-
-    if (rowcount != 1) return(vo->error);
-    bcopy(SQLDA->sqlvar[0].sqldata,argv[vo->index],sizeof(int));
-    return(MR_EXISTS);
 }
 
-validate_name(argv, vo)
+int validate_name(argv, vo)
     char *argv[];
     register struct valobj *vo;
 {
-    EXEC SQL BEGIN DECLARE SECTION;
-    char *name, *tbl, *namefield;
-    int rowcount;
-    EXEC SQL END DECLARE SECTION;
+    char *name, *namefield;
     register char *c;
 
     name = argv[vo->index];
-    tbl = vo->table;
     namefield = vo->namefield;
-    if (!strcmp(tbl, "servers") && !strcmp(namefield, "name")) {
+    if (vo->table==SERVERS_TABLE && !strcmp(namefield, "name")) {
        for (c = name; *c; c++)
          if (islower(*c))
            *c = toupper(*c);
     }
     sprintf(stmt_buf,"SELECT DISTINCT COUNT(*) FROM %s WHERE %s.%s = '%s'",
-           tbl,tbl,namefield,name);
-    EXEC SQL PREPARE stmt INTO :SQLDA USING NAMES FROM :stmt_buf;
-    if(sqlca.sqlcode)
-      return(MR_INTERNAL);
-    EXEC SQL DECLARE csr128 CURSOR FOR stmt;
-    EXEC SQL OPEN csr128;
-    EXEC SQL FETCH csr128 USING DESCRIPTOR :SQLDA;
-    rowcount = *(int *)SQLDA->sqlvar[0].sqldata;
-    EXEC SQL CLOSE csr128;
-
-    if (ingres_errno) return(mr_errcode);
-    return ((rowcount == 1) ? MR_EXISTS : vo->error);
+           table_name[vo->table],table_name[vo->table],namefield,name);
+    dosql(sqlbuffer);
+
+    if (dbms_errno) return(mr_errcode);
+    return ((atoi(sqlbuffer[0]) == 1) ? MR_EXISTS : vo->error);
 }
 
+/*
 validate_date(argv, vo)
     char *argv[];
     struct valobj *vo;
@@ -305,30 +308,27 @@ validate_date(argv, vo)
 
     idate = argv[vo->index];
     EXEC SQL SELECT interval('years',date(:idate)-date('today')) INTO :dd;
-
     if (sqlca.sqlcode != 0 || dd > 5.0) return(MR_DATE);
     return(MR_EXISTS);
 }
+*/
 
-
-validate_rename(argv, vo)
-char *argv[];
-struct valobj *vo;
+int validate_rename(argv, vo)
+     char *argv[];
+     struct valobj *vo;
 {
     EXEC SQL BEGIN DECLARE SECTION;
-    char *name, *tbl, *namefield, *idfield;
+    char *name, *namefield, *idfield;
     int id;
     EXEC SQL END DECLARE SECTION;
     int status;
     register char *c;
 
-    c = name = argv[vo->index];
-    while (*c)
-      if (illegalchars[*c++])
-       return(MR_BAD_CHAR);
-    tbl = vo->table;
+    status = validate_chars(argv, vo);
+    if(status != MR_EXISTS) return status;
+    name=argv[vo->index];
     /* minor kludge to upcasify machine names */
-    if (!strcmp(tbl, "machine"))
+    if (vo->table == MACHINE_TABLE)
        for (c = name; *c; c++) if (islower(*c)) *c = toupper(*c);
     namefield = vo->namefield;
     idfield = vo->idfield;
@@ -336,24 +336,17 @@ struct valobj *vo;
     if (idfield == 0) {
        if (!strcmp(argv[vo->index], argv[vo->index - 1]))
          return(MR_EXISTS);
-       sprintf(stmt_buf,"SELECT %s FROM %s WHERE %s = LEFT('%s',SIZE(%s))",
-               namefield,tbl,namefield,name,namefield);
-       EXEC SQL PREPARE stmt INTO :SQLDA USING NAMES FROM :stmt_buf;
-       if(sqlca.sqlcode)
-         return(MR_INTERNAL);
-        EXEC SQL DECLARE csr129 CURSOR FOR stmt;
-       EXEC SQL OPEN csr129;
-        EXEC SQL FETCH csr129 USING DESCRIPTOR :SQLDA;
-       if(sqlca.sqlcode == 0) id=1; else id=0;
-       EXEC SQL CLOSE csr129;
-
-       if (ingres_errno) return(mr_errcode);
-       if (id)
-         return(vo->error);
+       sprintf(stmt_buf,"SELECT %s FROM %s WHERE %s = '%s'",
+               namefield,table_name[vo->table],namefield,name);
+       dosql(sqlbuffer);
+
+       if (dbms_errno) return(mr_errcode);
+       if (sqlca.sqlcode==SQL_NO_MATCH)
+         return(MR_EXISTS); /* how's _that_ for intuitive? */
        else
-         return(MR_EXISTS);
+         return(vo->error);
     }
-    status = name_to_id(name, tbl, &id);
+    status = name_to_id(name, vo->table, &id);
     if (status == MR_NO_MATCH || id == *(int *)argv[vo->index - 1])
       return(MR_EXISTS);
     else
@@ -361,7 +354,7 @@ struct valobj *vo;
 }
 
 
-validate_type(argv, vo)
+int validate_type(argv, vo)
     char *argv[];
     register struct valobj *vo;
 {
@@ -372,7 +365,7 @@ validate_type(argv, vo)
     EXEC SQL END DECLARE SECTION;
     register char *c;
 
-    typename = vo->table;
+    typename = vo->namefield;
     c = val = argv[vo->index];
     while (*c) {
        if (illegalchars[*c++])
@@ -384,13 +377,13 @@ validate_type(argv, vo)
 
     EXEC SQL SELECT COUNT(trans) INTO :cnt FROM alias
       WHERE name = :typename AND type='TYPE' AND trans = :val;
-    if (ingres_errno) return(mr_errcode);
+    if (dbms_errno) return(mr_errcode);
     return (cnt ? MR_EXISTS : vo->error);
 }
 
 /* validate member or type-specific data field */
 
-validate_typedata(q, argv, vo)
+int validate_typedata(q, argv, vo)
     register struct query *q;
     register char *argv[];
     register struct valobj *vo;
@@ -413,23 +406,23 @@ validate_typedata(q, argv, vo)
     /* get corresponding data type associated with field type name */
     EXEC SQL SELECT trans INTO :data_type FROM alias
       WHERE name = :field_type AND type='TYPEDATA';
-    if (ingres_errno) return(mr_errcode);
+    if (dbms_errno) return(mr_errcode);
     if (sqlca.sqlerrd[2] != 1) return(MR_TYPE);
 
     /* now retrieve the record id corresponding to the named object */
-    if (dbg_index(data_type, ' '))
-       *dbg_index(data_type, ' ') = 0;
+    if (strchr(data_type, ' '))
+       *strchr(data_type, ' ') = 0;
     if (!strcmp(data_type, "user")) {
        /* USER */
-       if (dbg_index(name, '@'))
+       if (strchr(name, '@'))
          return(MR_USER);
-       status = name_to_id(name, data_type, &id);
+       status = name_to_id(name, USERS_TABLE, &id);
        if (status && (status == MR_NO_MATCH || status == MR_NOT_UNIQUE))
          return(MR_USER);
        if (status) return(status);
     } else if (!strcmp(data_type, "list")) {
        /* LIST */
-       status = name_to_id(name, data_type, &id);
+       status = name_to_id(name, LIST_TABLE, &id);
        if (status && status == MR_NOT_UNIQUE)
          return(MR_LIST);
        if (status == MR_NO_MATCH) {
@@ -440,7 +433,7 @@ validate_typedata(q, argv, vo)
            if (vo->idfield && !strcmp(argv[0], argv[vo->index])) {
                set_next_object_id(q->validate->object_id, q->rtable, 0);
                name = vo->idfield;
-               EXEC SQL REPEATED SELECT value INTO :id FROM numvalues
+               EXEC SQL SELECT value INTO :id FROM numvalues
                  WHERE name = :name;
                if (sqlca.sqlerrd[2] != 1) return(MR_LIST);
            } else
@@ -449,19 +442,19 @@ validate_typedata(q, argv, vo)
     } else if (!strcmp(data_type, "machine")) {
        /* MACHINE */
        for (c = name; *c; c++) if (islower(*c)) *c = toupper(*c);
-       status = name_to_id(name, data_type, &id);
+       status = name_to_id(name, MACHINE_TABLE, &id);
        if (status && (status == MR_NO_MATCH || status == MR_NOT_UNIQUE))
          return(MR_MACHINE);
        if (status) return(status);
     } else if (!strcmp(data_type, "string")) {
        /* STRING */
-       status = name_to_id(name, data_type, &id);
+       status = name_to_id(name, STRINGS_TABLE, &id);
        if (status && status == MR_NOT_UNIQUE)
          return(MR_STRING);
        if (status == MR_NO_MATCH) {
            if (q->type != APPEND && q->type != UPDATE) return(MR_STRING);
            id=add_string(name);
-           cache_entry(name, "STRING", id);
+           cache_entry(name, STRINGS_TABLE, id);
        } else if (status) return(status);
     } else if (!strcmp(data_type, "none")) {
        id = 0;
@@ -476,95 +469,101 @@ validate_typedata(q, argv, vo)
 }
 
 
+/* Make sure the data fits in the field */
+int validate_len(argv, vo)
+    register char *argv[];
+    register struct valobj *vo;
+{
+    EXEC SQL BEGIN DECLARE SECTION;
+    int len;
+    char *tname, *cname;
+    EXEC SQL END DECLARE SECTION;
+
+    tname = table_name[vo->table];
+    cname = vo->namefield;
+    EXEC SQL SELECT data_length INTO :len FROM user_tab_columns
+      WHERE table_name=UPPER(:tname) AND column_name=UPPER(:cname);
+
+    if((strlen(argv[vo->index]) > len) &&
+       strcmp(argv[vo->index], UNIQUE_LOGIN)) /* kludge... sigh */
+      argv[vo->index][len]='\0'; /* truncate */
+
+    return MR_EXISTS;
+}
+
 /* Lock the table named by the validation object */
 
-lock_table(vo)
-struct valobj *vo;
+int lock_table(vo)
+     struct valobj *vo;
 {
-    sprintf(stmt_buf,"UPDATE %s SET modtime='now' WHERE %s.%s = 0",
-           vo->table,vo->table,vo->idfield);
+#ifdef DO_LOCKING
+    sprintf(stmt_buf, "LOCK TABLE %s IN EXCLUSIVE MODE", table_name[vo->table]);
     EXEC SQL EXECUTE IMMEDIATE :stmt_buf;
-    if (ingres_errno) return(mr_errcode);
-    if (sqlca.sqlerrd[2] != 1)
-      return(vo->error);
+    if (dbms_errno) 
+        return(mr_errcode);
     else
+#endif
       return(MR_EXISTS);
 }
 
-
-/* Check the database at startup time.  For now this just resets the
- * inprogress flags that the DCM uses.
+/*
+ * Get a read lock on the table by accessing the magic lock
+ * record.  Certain tables are constructed so that they contain
+ * an id field whose value is zero and a modtime field.  We 
+ * manipulate the modtime field of the id 0 record to effect 
+ * locking of the table
  */
 
-sanity_check_database()
+int readlock_table(vo)
+    struct valobj *vo;
 {
+#ifdef DO_LOCKING
+    sprintf(stmt_buf, "LOCK TABLE %s IN SHARE MODE", table_name[vo->table]);
+    EXEC SQL EXECUTE IMMEDIATE :stmt_buf;
+
+    if (dbms_errno)
+        return(mr_errcode);
+    if (sqlca.sqlcode)
+        return(vo->error);
+#endif
+    return(MR_EXISTS);  /* validate_fields expects us to return
+                           * this value if everything went okay
+                           */
 }
 
+/* Check the database at startup time. NOT! */
+
+void sanity_check_database(void)
+{
+}
+
+
+char *sqlbuffer[QMAXARGS];
 
 /* Dynamic SQL support routines */
-MR_SQLDA_T *mr_alloc_SQLDA()
+SQLDA *mr_alloc_sqlda()
 {
-    MR_SQLDA_T *it;
-    short *null_indicators;
+    SQLDA *it;
     register int j;
 
-    if((it=(MR_SQLDA_T *)malloc(sizeof(MR_SQLDA_T)))==NULL) {
+    it=sqlald(QMAXARGS, ARGLEN, 0);
+    if(it==NULL) {
        com_err(whoami, MR_NO_MEM, "setting up SQLDA");
        exit(1);
     }
 
-    if((null_indicators=(short *)calloc(QMAXARGS,sizeof(short)))==NULL) {
-       com_err(whoami, MR_NO_MEM, "setting up SQLDA null indicators");
-       exit(1);
-    }
-
     for(j=0; j<QMAXARGS; j++) {
-       if((it->sqlvar[j].sqldata=(char *)malloc(sizeof(short)+ARGLEN))==NULL) {
-           com_err(whoami, MR_NO_MEM, "setting up SQLDA variables");
-           exit(1);
-       }
-       it->sqlvar[j].sqllen=ARGLEN;
-       it->sqlvar[j].sqlind=null_indicators+j;
-       null_indicators[j]=0;
+        it->V[j]=sqlbuffer[j]=malloc(ARGLEN);
+       it->T[j]=97; /* 97 = CHARZ = null-terminated string */
+       it->L[j]=ARGLEN;
     }
-    it->sqln=QMAXARGS;
+
     return it;
 }
 
 
-/* Use this after FETCH USING DESCRIPTOR one or more
- * result columns may contain NULLs.  This routine is
- * not currently needed, since db/schema creates all
- * columns with a NOT NULL WITH DEFAULT clause.
- *
- * This is currently dead flesh, since no Moira columns
- * allow null values; all use default values.
- */
-mr_fix_nulls_in_SQLDA(da)
-    MR_SQLDA_T *da;
-{
-    register IISQLVAR *var;
-    register int j;
-    int *intp;
-
-    for(j=0, var=da->sqlvar; j<da->sqld; j++, var++) {
-       switch(var->sqltype) {
-         case -IISQ_CHA_TYPE:
-           if(*var->sqlind)
-             *var->sqldata='\0';
-           break;
-         case -IISQ_INT_TYPE:
-           if(*var->sqlind) {
-               intp=(int *)var->sqldata;
-               *intp=0;
-           }
-           break;
-       }
-    }
-}
-
 /* Convert normal Unix-style wildcards to SQL voodoo */
-convert_wildcards(arg)
+int convert_wildcards(arg)
     char *arg;
 {
     static char buffer[ARGLEN];
@@ -594,7 +593,7 @@ convert_wildcards(arg)
  * Including it in a wildcard routine saves making two passes over
  * the argument string.
  */
-convert_wildcards_uppercase(arg)
+int convert_wildcards_uppercase(arg)
     char *arg;
 {
     static char buffer[ARGLEN];
@@ -620,33 +619,6 @@ convert_wildcards_uppercase(arg)
 }
 
 
-/* Looks like it's time to build an abstraction barrier, Yogi */
-mr_select_any(stmt)
-    EXEC SQL BEGIN DECLARE SECTION; 
-    char *stmt;
-    EXEC SQL END DECLARE SECTION; 
-{
-    int result=0;
-
-    EXEC SQL PREPARE stmt FROM :stmt;
-    EXEC SQL DESCRIBE stmt INTO :SQLDA;
-    if(SQLDA->sqld==0)                       /* Not a SELECT */
-        return(MR_INTERNAL);        
-    EXEC SQL DECLARE csr CURSOR FOR stmt;
-    EXEC SQL OPEN csr;
-    EXEC SQL FETCH csr USING DESCRIPTOR :SQLDA;
-    if(sqlca.sqlcode==0) 
-        result=MR_EXISTS;
-    else if((sqlca.sqlcode<0) && mr_errcode)
-        result=mr_errcode;
-    else
-        result=0;
-    EXEC SQL CLOSE csr;
-    return(result);
-} 
-
-
-
 /*  Adds a string to the string table.  Returns the id number.
  * 
  */
@@ -664,10 +636,7 @@ int add_string(name)
     id++;
     EXEC SQL UPDATE numvalues SET value = :id WHERE name = 'strings_id';
     
-    /* Use sprintf to get around problem with doubled single quotes */
-    sprintf(buf,"INSERT INTO strings (string_id, string) VALUES (%d, '%s')",id,name);
-    EXEC SQL EXECUTE IMMEDIATE :buf;
+    EXEC SQL INSERT INTO strings (string_id, string) VALUES (:id, :name);
  
     return(id);
 }
-
index 59a57bd71b593d95867c40f77c4402cdd2664705..71323cf9582742704f46ad070744e326f42743c3 100644 (file)
@@ -25,36 +25,40 @@ static char *rcsid_mr_starter_c = "$Header$";
 #include <sys/signal.h>
 #include <sys/ioctl.h>
 #include <moira_site.h>
+#include <sys/stat.h>
+#include <sys/resource.h>
+#include <fcntl.h>
+
 
 #define PROG   "moirad"
-char *whoami;
 
 int rdpipe[2];
-extern char *sys_siglist[];
+char *whoami;
 
 cleanup()
 {
-       union wait stat;
+       int stat;
+
        char buf[BUFSIZ];
        extern int errno;
        int serrno = errno;
 
        buf[0]='\0';
        
-       while (wait3(&stat, WNOHANG, 0) > 0) {
+       while (waitpid(-1, &stat, WNOHANG) > 0) {
                if (WIFEXITED(stat)) {
-                       if (stat.w_retcode) {
+                       if (WEXITSTATUS(stat)) {
                                sprintf(buf,
-                                       "moirad exited with code %d\n",
-                                       stat.w_retcode);
+                                       "exited with code %d\n",
+                                       WEXITSTATUS(stat));
                                send_zgram("startmoira", buf);
                        }
                }
                if (WIFSIGNALED(stat)) {
-                       sprintf(buf, "moirad exited on %s signal%s\n",
-                               sys_siglist[stat.w_termsig],
-                               (stat.w_coredump?"; Core dumped":0));
-                       if(stat.w_coredump) send_zgram("startmoira", buf);
+                       sprintf(buf, "exited on signal %d%s\n",
+                               WTERMSIG(stat),
+                               (WCOREDUMP(stat)?"; Core dumped":0));
+                       if(WCOREDUMP(stat)) send_zgram("startmoira", buf);
                }
                write(rdpipe[1], buf, strlen(buf));
                close(rdpipe[1]);
@@ -63,22 +67,29 @@ cleanup()
 }
 
 main(argc, argv)
-       int argc;
-       char **argv;
+     int argc;
+     char *argv[];
 {
        char buf[BUFSIZ];
        FILE *log, *prog;
        int logf, inf, i, done, pid, tty;
+       struct rlimit rl;
        
        extern int errno;
        extern char *sys_errlist[];
        
-       int nfds = getdtablesize();
-       
+       struct sigaction action;
+       int nfds;
+
        whoami = argv[0];
 
-       setreuid(0);
-       signal(SIGCHLD, cleanup);
+       getrlimit(RLIMIT_NOFILE, &rl);
+       nfds = rl.rlim_cur;
+
+       action.sa_handler = cleanup;
+       action.sa_flags = 0;
+       sigemptyset(&action.sa_mask);
+       sigaction(SIGCHLD, &action, NULL);
        
        sprintf(buf, "%s/moira.log", SMS_DIR);
        logf = open(buf, O_CREAT|O_WRONLY|O_APPEND, 0640);
@@ -103,9 +114,7 @@ main(argc, argv)
        dup2(inf, 1);
        dup2(inf, 2);
        
-       tty = open("/dev/tty");
-       ioctl(tty, TIOCNOTTY, 0);
-       close(tty);
+       setpgrp();
        sprintf(buf, "%s/%s", BIN_DIR, PROG);
        
        if ((pid = fork()) == 0) {
This page took 0.701528 seconds and 5 git commands to generate.