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

regtape/Imakefile
regtape/employee.dc
regtape/nodups.qc [deleted file]
regtape/sign.dc
regtape/students.dc
regtape/verify.dc
regtape/vote.dc

index 3b83999a09d5e5c81b3c95574e9e891a713a6d4b..39260ce6bd63dde824dda0377ff41630812cf7a2 100644 (file)
@@ -7,17 +7,17 @@
 #
 # Imakefile for moira regtape programs.
 
-SRCS= students.c employee.c sign.c rafnu.c
-CODE= students.dc employee.dc sign.dc rafnu.c
+SRCS= students.c employee.c sign.c verify.c vote.c rafnu.c
+CODE= students.dc employee.dc sign.dc verify.dc vote.dc rafnu.c
 SRCDIR = $(SRCTOP)/regtape
-DEFINES = -I/mit/gdss/include
+DEFINES = $(GDSSINC)
 sqlrule()
 
 program(students, students.o rafnu.o,,$(CLIBS) $(SQL_LIB), $(PROGDIR))
 program(employee, employee.o rafnu.o,,$(CLIBS) $(SQL_LIB), $(PROGDIR))
-/* program(verify, verify.o rafnu.o,,/mit/gdss/`machtype`/libgdss.a $(CLIBS) $(SQL_LIB), $(PROGDIR)) */
-program(sign, sign.o rafnu.o,,/mit/gdss/`machtype`/libgdss.a $(CLIBS) $(SQL_LIB), $(PROGDIR))
-/* program(vote, vote.o rafnu.o,,$(CLIBS) $(SQL_LIB), $(PROGDIR)) */
+program(verify, verify.o rafnu.o,,$(LIBGDSS) $(CLIBS) $(SQL_LIB), $(PROGDIR))
+program(sign, sign.o rafnu.o,,$(LIBGDSS) $(CLIBS) $(SQL_LIB), $(PROGDIR))
+program(vote, vote.o rafnu.o,,$(CLIBS) $(SQL_LIB), $(PROGDIR))
 
 sqlfile(students)
 sqlfile(employee)
index a313c8069beac7decc6eff26c032468bdca1e2b1..939df7f6235374b2f453f792445766ceaef2de2c 100644 (file)
@@ -2,7 +2,7 @@
  */
 
 #include <stdio.h>
-#include <strings.h>
+#include <string.h>
 #include <ctype.h>
 #include <sys/time.h>
 #include <moira.h>
@@ -71,9 +71,8 @@ struct entry {
 char *whoami;
 int newfinger = 0;
 
-#define sqlfail() (sqlca.sqlcode && sqlca.sqlcode != 100)
-#define SQL_DUPLICATE -40100
-#define SQL_DEADLOCK -49900
+#define sqlfail() (sqlca.sqlcode && sqlca.sqlcode != 1403)
+#define SQL_DUPLICATE 1422
 
 
 main(argc, argv)
@@ -84,13 +83,19 @@ char **argv;
     struct entry *e, *get_next_entry();
     int i, wait = 0;
     char buf[BUFSIZ], *file = NULL;
+EXEC SQL BEGIN DECLARE SECTION;
+    char *db="moira";
+EXEC SQL END DECLARE SECTION;
 
-    whoami = rindex(argv[0], '/');
+    whoami = strrchr(argv[0], '/');
     if (whoami)
       whoami++;
     else
       whoami = argv[0];
 
+    setvbuf(stdout, NULL, _IOLBF, BUFSIZ);
+    setvbuf(stderr, NULL, _IOLBF, BUFSIZ);
+
     for (i = 1; i < argc; i++) {
        if (!strcmp(argv[i], "-w"))
          wait++;
@@ -110,13 +115,11 @@ char **argv;
        exit(1);
     }
 
-    setlinebuf(stdout);
-    setlinebuf(stderr);
     initialize_sms_error_table();
 
-    EXEC SQL CONNECT moira;
+    EXEC SQL CONNECT :db IDENTIFIED BY :db;
     if (sqlca.sqlcode != 0) {
-       com_err(whoami, 0, "ingres error %d opening database", sqlca.sqlcode);
+       dbmserr("opening database", sqlca.sqlcode);
        exit(1);
     }
 
@@ -125,13 +128,8 @@ char **argv;
        process_entry(e);
        EXEC SQL COMMIT WORK;
        if (sqlca.sqlcode != 0) {
-            if (sqlca.sqlcode == SQL_DEADLOCK) {
-                com_err(whoami, MR_DEADLOCK, "commiting work");
-                goto again;
-            } else {
-                com_err(whoami, 0, "ingres error %d committing work", sqlca.sqlcode);
-                exit(1);
-            }
+         dbmserr("committing work", sqlca.sqlcode);
+         exit(1);
        }
        if (wait) {
            printf("Next");
@@ -184,7 +182,7 @@ FILE *in;
 
     strcpy(sname, name);
     e.name = strtrim(sname);
-    p = index(name, ',');
+    p = strchr(name, ',');
     if (p)
       *p = 0;
     e.last = strtrim(name);
@@ -193,7 +191,7 @@ FILE *in;
        while (isspace(*p))
          p++;
        e.first = p;
-       if (p = index(e.first, ' ')) {
+       if (p = strchr(e.first, ' ')) {
            *p = 0;
            e.first = strtrim(e.first);
            e.middle = strtrim(p + 1);
@@ -278,10 +276,6 @@ struct entry *e;
        if (sqlca.sqlcode == SQL_DUPLICATE) {
            com_err(whoami, 0, "duplicate ID number %s on user %s %s", sid, first, last);
            return;
-        } else if (sqlca.sqlcode == SQL_DEADLOCK) {
-            com_err(whoami, MR_DEADLOCK, "looking up user %s", sid);
-            EXEC SQL ROLLBACK;
-            return process_entry(e);
        } else
          sqlexit();
     }
@@ -290,12 +284,7 @@ struct entry *e;
          INTO :id, :dfirst, :dlast, :dmiddle, :class, :oaddr, :ophone, :dept, :status
          FROM users
          WHERE last = :last and first = :first and clearid = :eid;
-        if (sqlfail()) {
-            if (sqlca.sqlcode == SQL_DEADLOCK) {
-                com_err(whoami, MR_DEADLOCK, "looking up user %s", sid);
-                EXEC SQL ROLLBACK;
-                return process_entry(e);
-            } else if (sqlca.sqlcode != SQL_DUPLICATE)
+        if (sqlfail() && sqlca.sqlcode != SQL_DUPLICATE) {
               sqlexit();
         }
        encrypted++;
@@ -317,17 +306,12 @@ struct entry *e;
          status = US_ENROLLED;
        strcpy(class, e->class);
        EXEC SQL UPDATE users
-         SET type = :class, status = :status, modtime = 'now',
+         SET type = NVL(:class,CHR(0)), status = :status, modtime = SYSDATE,
                modby = :who, modwith = :prog
          WHERE users_id = :id;
        if (sqlca.sqlcode != 0) {
-            if (sqlca.sqlcode == SQL_DEADLOCK) {
-                com_err(whoami, MR_DEADLOCK, "updating user");
-               return;
-            } else {
-                com_err(whoami, 0, "ingres error %d updating user", sqlca.sqlcode);
-                exit(1);
-           }
+         dbmserr("updating user", sqlca.sqlcode);
+         exit(1);
        }
     }
 
@@ -337,26 +321,22 @@ struct entry *e;
        strcmp(middle, strtrim(dmiddle))) {
        com_err(whoami, 0, "updating real name for %s %s", first, last);
        EXEC SQL UPDATE users
-         SET first = :first, last = :last, middle = :middle,
-               modby = :who, modwith = :prog, modtime = 'now'
+         SET first = NVL(:first,CHR(0)), last = NVL(:last,CHR(0)),
+         middle = NVL(:middle,CHR(0)), modby = :who, modwith = :prog,
+         modtime = SYSDATE
          WHERE users_id = :id;
        if (sqlca.sqlcode != 0) {
-            if (sqlca.sqlcode == SQL_DEADLOCK) {
-                com_err(whoami, MR_DEADLOCK, "updating name");
-               return;
-            } else {
-                com_err(whoami, 0, "ingres error %d updating name", sqlca.sqlcode);
-                exit(1);
-            }
+         dbmserr("updating name", sqlca.sqlcode);
+         exit(1);
        }
     }
 
     changed = nochange = 0;
     if (encrypted) changed++;
     strcpy(buf, e->address);
-    while (to = index(buf, ','))
+    while (to = strchr(buf, ','))
       *to = ';';
-    while (to = index(buf, ':'))
+    while (to = strchr(buf, ':'))
       *to = ';';
     if (newfinger) {
        if (oaddr[0] == ' ' && buf[0]) {
@@ -414,38 +394,29 @@ struct entry *e;
     rophone = e->phone2;
     if (changed) {
        com_err(whoami, 0, "updating finger for %s %s", first, last);
-       EXEC SQL REPEATED UPDATE users
-         SET office_addr = :oaddr, office_phone = :ophone, department = :dept,
-           fmodtime = 'now', fmodby = :who, fmodwith = :prog,
-           xname = :name, xdept = :rdept, xtitle = :rtitle,
-           xaddress = :raddr, xphone1 = :rhphone, xphone2 = :rophone,
-           xmodtime = 'now', clearid = :sid
+       EXEC SQL UPDATE users
+         SET office_addr = NVL(:oaddr,CHR(0)),
+         office_phone = NVL(:ophone,CHR(0)), department = NVL(:dept,CHR(0)),
+         fmodtime = SYSDATE, fmodby = :who, fmodwith = :prog,
+         xname = NVL(:name,CHR(0)), xdept = NVL(:rdept,CHR(0)),
+         xtitle = NVL(:rtitle,CHR(0)), xaddress = NVL(:raddr,CHR(0)),
+         xphone1 = NVL(:rhphone,CHR(0)), xphone2 = NVL(:rophone,CHR(0)),
+         xmodtime = SYSDATE, clearid = NVL(:sid,CHR(0))
          WHERE users_id = :id;
        if (sqlca.sqlcode != 0) {
-            if (sqlca.sqlcode == SQL_DEADLOCK) {
-                com_err(whoami, MR_DEADLOCK, "updating user %s", sid);
-                EXEC SQL ROLLBACK;
-                return process_entry(e);
-            } else {
-                com_err(whoami, 0, "ingres error %d", sqlca.sqlcode);
-                exit(1);
-            }
+         dbmserr(NULL, sqlca.sqlcode);
+         exit(1);
        }
     } else {
-       EXEC SQL REPEATED UPDATE users
-         SET xname = :name, xdept = :rdept, xtitle = :rtitle,
-           xaddress = :raddr, xphone1 = :rhphone, xphone2 = :rophone,
-           xmodtime = 'now', clearid = :sid
+       EXEC SQL UPDATE users
+         SET xname = NVL(:name,CHR(0)), xdept = NVL(:rdept,CHR(0)),
+         xtitle = NVL(:rtitle,CHR(0)), xaddress = NVL(:raddr,CHR(0)),
+         xphone1 = NVL(:rhphone,CHR(0)), xphone2 = NVL(:rophone,CHR(0)),
+         xmodtime = SYSDATE, clearid = NVL(:sid,CHR(0))
          WHERE users_id = :id;
        if (sqlca.sqlcode != 0) {
-            if (sqlca.sqlcode == SQL_DEADLOCK) {
-                com_err(whoami, MR_DEADLOCK, "updating user %s", sid);
-                EXEC SQL ROLLBACK;
-                return process_entry(e);
-            } else {
-                com_err(whoami, 0, "ingres error %d", sqlca.sqlcode);
-                exit(1);
-            }
+         dbmserr(NULL, sqlca.sqlcode);
+         exit(1);
        }
     }
 }
@@ -466,9 +437,9 @@ struct entry *e;
     prog = PROG;
     strncpy(oaddr, e->address, 16);
     oaddr[16] = 0;
-    while (to = index(oaddr, ','))
+    while (to = strchr(oaddr, ','))
       *to = ';';
-    while (to = index(oaddr, ':'))
+    while (to = strchr(oaddr, ':'))
       *to = ';';
     from = e->phone;
     to = ophone;
@@ -502,23 +473,22 @@ struct entry *e;
     rhphone = e->phone;
     rophone = e->phone2;
 
-    EXEC SQL REPEATED INSERT INTO users
-      (login, users_id, uid, shell, last, first, middle, status,
+    EXEC SQL INSERT INTO users
+      (login, users_id, unix_uid, shell, last, first, middle, status,
        clearid, type, modtime, modby, modwith, fullname, office_addr,
        office_phone, department, fmodtime, fmodby, fmodwith,
        potype, xname, xdept, xtitle, xaddress, xphone1, xphone2, xmodtime)
-      VALUES (:login, :id, :uid, '/bin/athena/tcsh', :last, :first,
-             :middle, :st, :sid, :class, 'now', :who, :prog,
-             :fullname, :oaddr, :ophone, :dept, 'now', :who, :prog,
-             'NONE', :name, :rdept, :title, :oaddr, :rhphone,
-             :rophone, 'now');
+      VALUES (:login, :id, :uid, '/bin/athena/tcsh',
+             NVL(:last,CHR(0)), NVL(:first,CHR(0)), NVL(:middle,CHR(0)),
+             :st, NVL(:sid,CHR(0)), NVL(:class,CHR(0)), SYSDATE, :who, :prog,
+             NVL(:fullname,CHR(0)), NVL(:oaddr,CHR(0)), NVL(:ophone,CHR(0)),
+             NVL(:dept,CHR(0)), SYSDATE, :who, :prog, 'NONE',
+             NVL(:name,CHR(0)), NVL(:rdept,CHR(0)), NVL(:title,CHR(0)),
+             NVL(:oaddr,CHR(0)), NVL(:rhphone,CHR(0)), NVL(:rophone,CHR(0)),
+             SYSDATE);
     if (sqlca.sqlcode != 0) {
-       if (sqlca.sqlcode == SQL_DEADLOCK) {
-           com_err(whoami, MR_DEADLOCK, "adding user");
-       } else {
-           com_err(whoami, 0, "ingres error %d adding user", sqlca.sqlcode);
-           exit(1);
-       }
+      dbmserr("adding user", sqlca.sqlcode);
+      exit(1);
     } else
       com_err(whoami, 0, "adding user %s %s", e->first, e->last);
 }
@@ -531,7 +501,7 @@ set_next_users_id(limit)
     int rowcount, flag, value, retval;
     EXEC SQL END DECLARE SECTION;
 
-    EXEC SQL REPEATED SELECT value INTO :value FROM numvalues 
+    EXEC SQL SELECT value INTO :value FROM numvalues 
       WHERE name = 'users_id';
     if (sqlfail()) sqlexit();
     if (sqlca.sqlerrd[2] != 1) {
@@ -541,7 +511,7 @@ set_next_users_id(limit)
     }
 
     flag = 0;
-    EXEC SQL REPEATED SELECT users_id INTO :flag FROM users
+    EXEC SQL SELECT users_id INTO :flag FROM users
       WHERE users_id = :value;
     if (sqlfail()) sqlexit();
     if (sqlca.sqlerrd[2] == 0)
@@ -551,7 +521,7 @@ set_next_users_id(limit)
        if (limit && value > MAX_ID_VALUE)
            value = MIN_ID_VALUE;
        flag = 0;
-       EXEC SQL REPEATED SELECT users_id INTO :flag FROM users 
+       EXEC SQL SELECT users_id INTO :flag FROM users 
          WHERE users_id = :value;
        if (sqlfail()) sqlexit();
        if (sqlca.sqlerrd[2] == 0)
@@ -561,10 +531,10 @@ set_next_users_id(limit)
     retval = value++;
     if (limit && value > MAX_ID_VALUE)
       value = MIN_ID_VALUE;
-    EXEC SQL REPEATED UPDATE numvalues SET value = :value
+    EXEC SQL UPDATE numvalues SET value = :value
       WHERE name = 'users_id';
     if (sqlca.sqlcode != 0) {
-       com_err(whoami, 0, "ingres error %d assigning ID", sqlca.sqlcode);
+       dbmserr("assigning ID", sqlca.sqlcode);
        exit(1);
     }
     return(retval);
@@ -577,8 +547,8 @@ set_next_uid(limit)
     int rowcount, flag, value, retval;
     EXEC SQL END DECLARE SECTION;
 
-    EXEC SQL REPEATED SELECT value INTO :value FROM numvalues 
-      WHERE name = 'uid';
+    EXEC SQL SELECT value INTO :value FROM numvalues 
+      WHERE name = 'unix_uid';
     if (sqlfail()) sqlexit();
     if (sqlca.sqlerrd[2] != 1) {
        EXEC SQL ROLLBACK;
@@ -587,7 +557,7 @@ set_next_uid(limit)
     }
 
     flag = 0;
-    EXEC SQL REPEATED SELECT uid INTO :flag FROM users WHERE uid = :value;
+    EXEC SQL SELECT unix_uid INTO :flag FROM users WHERE unix_uid = :value;
     if (sqlfail()) sqlexit();
     if (sqlca.sqlerrd[2] == 0)
       flag = 0;
@@ -596,7 +566,7 @@ set_next_uid(limit)
        if (limit && value > MAX_ID_VALUE)
            value = MIN_ID_VALUE;
        flag = 0;
-       EXEC SQL REPEATED SELECT uid INTO :flag FROM users WHERE uid = :value;
+       EXEC SQL SELECT unix_uid INTO :flag FROM users WHERE unix_uid = :value;
        if (sqlfail()) sqlexit();
        if (sqlca.sqlerrd[2] == 0)
          flag = 0;
@@ -605,9 +575,9 @@ set_next_uid(limit)
     retval = value++;
     if (limit && value > MAX_ID_VALUE)
       value = MIN_ID_VALUE;
-    EXEC SQL REPEATED UPDATE numvalues SET value = :value WHERE name = 'uid';
+    EXEC SQL UPDATE numvalues SET value = :value WHERE name = 'unix_uid';
     if (sqlca.sqlcode != 0) {
-       com_err(whoami, 0, "ingres error %d assigning ID", sqlca.sqlcode);
+       dbmserr("assigning ID", sqlca.sqlcode);
        exit(1);
     }
     return(retval);
@@ -616,11 +586,21 @@ set_next_uid(limit)
 
 sqlexit()
 {
-    if (sqlca.sqlcode == SQL_DEADLOCK)
-      com_err(whoami, MR_DEADLOCK, "unrecoverable ingres error %d",
-              sqlca.sqlcode);
-    else
-      com_err(whoami, 0, "ingres error %d", sqlca.sqlcode);
+    dbmserr(NULL, sqlca.sqlcode);
     EXEC SQL ROLLBACK WORK;
     exit(1);
 }
+
+dbmserr(char *where, int what)
+{
+  char err_msg[256];
+  int bufsize=256, msglength=0;
+
+  sqlglm(err_msg, &bufsize, &msglength);
+  err_msg[msglength]=0;
+
+  if(where)
+    com_err(whoami, 0, "DBMS error %swhile %s", err_msg, where);
+  else
+    com_err(whoami, 0, "DBMS error %s", err_msg);
+}
diff --git a/regtape/nodups.qc b/regtape/nodups.qc
deleted file mode 100644 (file)
index 8f7fc92..0000000
+++ /dev/null
@@ -1,254 +0,0 @@
-/* $Header$ */
-
-#include <stdio.h>
-#include <ctype.h>
-#include <moira.h>
-
-struct user {
-    int        users_id;
-    char first[33];
-    char last[33];
-    int status;
-};
-
-extern int errno;
-int debug;
-char *program;
-
-
-main(argc, argv)
-int argc;
-char  **argv;
-{
-    char buf[1024], first[33], last[33];
-    int i;
-    char *inputfile;
-    FILE *in;
-    struct user *u;
-    struct user users[32];
-    struct user *get_user();
-
-    program = argv[0];
-
-    for (i = 1; i < argc; i++) {
-       if (!strcmp(argv[i], "-d"))
-         debug++;
-       else if (!strcmp(argv[i], "-D"))
-         setenv("ING_SET", "set printqry");
-       else if (argv[i][0] == '-')
-         usage(argv);
-       else if (inputfile != NULL)
-         usage(argv);
-       else inputfile = argv[i];
-    }
-
-    if (inputfile) {
-       in = fopen(inputfile, "r");
-       if (in == NULL) {
-           com_err(program, errno, "opening file \"%s\" for input", inputfile);
-           exit(1);
-       }
-    } else
-      in = stdin;
-
-##  ingres sms
-
-    i = 0;
-    while (!feof(in)) {
-       fgets(buf, sizeof(buf), in);
-       u = get_user(buf);
-       if (!u) continue;
-       if (strcmp(u->last, users[0].last) ||
-           strcmp(u->first, users[0].first)) {
-           /* We've got a matching group! */
-           process_users(users, i);
-           bcopy(u, &(users[0]), sizeof(*u));
-           i = 1;
-       } else {
-           bcopy(u, &(users[i]), sizeof(*u));
-           i++;
-       }
-    }
-}
-
-usage(argv)
-char **argv;
-{
-    fprintf(stderr, "Usage: %s [-w] [-D]\n", argv[0]);
-    exit(1);
-}
-
-struct user *get_user(buf)
-char *buf;
-{
-    static struct user u;
-
-    if (sscanf(buf, "| %d|%s |%s | %d|", &u.users_id, u.first,
-              u.last, &u.status) != 4) {
-       com_err(program, 0, " parsing input line %s", buf);
-       return(NULL);
-    }
-    return(&u);
-}
-
-
-process_users(users, count)
-struct user users[];
-int count;
-##{
-    char buf[256];
-    int i;
-##  char login[9], id[17], class[9], modtime[26], modwith[9], xmodtime[26];
-##  char login2[9], id2[17], class2[9], modtime2[26],modwith2[9],xmodtime2[26];
-##  char login3[9], id3[17], class3[9], modtime3[26],modwith3[9],xmodtime3[26];
-##  int users_id, users_id2, users_id3, status, status2, status3, rowcount;
-
-    printf("\nGot %d users named %s %s\n", count, users[0].first, users[0].last);
-    if (count < 2) return;
-
-    users_id = users[0].users_id;
-##  range of u is users
-##  retrieve (login = u.#login, id = u.mit_id, class = u.mit_year,
-##           modtime = u.#modtime, modwith = u.#modwith,
-##           xmodtime = u.#xmodtime, status = u.#status)
-##     where u.#users_id = users_id
-
-    users_id2 = users[1].users_id;
-##  retrieve (login2 = u.#login, id2 = u.mit_id, class2 = u.mit_year,
-##           modtime2 = u.#modtime, modwith2 = u.#modwith,
-##           xmodtime2 = u.#xmodtime, status2 = u.#status)
-##     where u.#users_id = users_id2
-
-    modtime[20] = modtime2[20] = xmodtime[20] = xmodtime2[20] = 0;
-
-    printf("A: %s %5d %d\t\t\tB: %s %5d %d\n", login, users_id, status,
-          login2, users_id2, status2);
-    printf("   %s %s\t\t   %s %s\n", class, id, class2, id2);
-    printf("   %s %s\t   %s %s\n", modtime, modwith, modtime2, modwith2);
-    printf("   %s\t\t\t   %s\n", xmodtime, xmodtime2);
-
-    if (count > 2) {
-       for (i = 2; i < count; i++) {
-           users_id3 = users[i].users_id;
-##         retrieve (login3 = u.#login, id3 = u.mit_id, class3 = u.mit_year,
-##                   modtime3 = u.#modtime, modwith3 = u.#modwith,
-##                   xmodtime3 = u.#xmodtime, status3 = u.#status)
-##             where u.#users_id = users_id3
-           modtime3[20] = xmodtime3[20] = 0;
-           printf("\n%c: %s %5d %d\n", 'A' + i,
-                  login3, users_id3, status3);
-           printf("   %s %s\n", class3, id3);
-           printf("   %s %s\n", modtime3, modwith3);
-           printf("   %s\n", xmodtime3);
-       }
-    }
-
-    if (count == 2) {
-       if (status == 3 || status2 == 3) return;
-       if ((status == 0 || status == 4) &&
-           !isdigit(id[0]) && !isdigit(xmodtime[0])) {
-           printf("DELETING %s\n", login);
-##         replace u (#status = 3, #modtime=date("now"), #modwith="nodups",
-##                    modby=8873) where u.#users_id = users_id
-##         inquire_equel(rowcount = "rowcount")
-           if (rowcount != 1)
-             printf("Failed!\007\007\007\n");
-           else
-             printf("User %s marked for deletion.\n", login);
-           return;
-       }
-       if ((status2 == 0 || status2 == 4) &&
-           !isdigit(id2[0]) && !isdigit(xmodtime2[0])) {
-           printf("DELETING %s\n", login2);
-##         replace u (#status = 3, #modtime=date("now"), #modwith="nodups",
-##                    modby=8873) where u.#users_id = users_id2
-##         inquire_equel(rowcount = "rowcount")
-           if (rowcount != 1)
-             printf("Failed!\007\007\007\n");
-           else
-             printf("User %s marked for deletion.\n", login2);
-           return;
-       }
-    }
-
-    printf("\n0,sp: Do nothing\n1: Delete B\n2: Delete A\n");
-    printf("3: A<-B's ID; Delete B\n4: B<-A's ID; Delete A\n");
-    if (count > 2)
-      printf("5: Delete C\n");
-    if (count > 3)
-      printf("6: Delete D\n");
-    printf("?");fflush(stdout);
-    gets(buf);
-    switch (buf[0]) {
-    case '1':
-##     replace u (#status = 3, #modtime=date("now"), #modwith="nodups",
-##                modby=8873) where u.#users_id = users_id2
-##     inquire_equel(rowcount = "rowcount")
-       if (rowcount != 1)
-         printf("Failed!\007\007\007\n");
-       else
-         printf("User %s marked for deletion.\n", login2);
-       break;
-    case '2':
-##     replace u (#status = 3, #modtime=date("now"), #modwith="nodups",
-##                modby=8873) where u.#users_id = users_id
-##     inquire_equel(rowcount = "rowcount")
-       if (rowcount != 1)
-         printf("Failed!\007\007\007\n");
-       else
-         printf("User %s marked for deletion.\n", login);
-       break;
-    case '3':
-##     replace u (#mit_id = id2, #modtime=date("now"), #modwith="nodups",
-##                modby=8873) where u.#users_id = users_id
-##     inquire_equel(rowcount = "rowcount")
-       if (rowcount != 1)
-         printf("Failed!\007\007\007\n");
-##     replace u (#status = 3, #modtime=date("now"), #modwith="nodups",
-##                modby=8873) where u.#users_id = users_id2
-##     inquire_equel(rowcount = "rowcount")
-       if (rowcount != 1)
-         printf("Failed!\007\007\007\n");
-       else
-         printf("User %s updated, %s marked for deletion.\n", login, login2);
-       break;
-    case '4':
-##     replace u (#mit_id = id, #modtime=date("now"), #modwith="nodups",
-##                modby=8873) where u.#users_id = users_id2
-##     inquire_equel(rowcount = "rowcount")
-       if (rowcount != 1)
-         printf("Failed!\007\007\007\n");
-##     replace u (#status = 3, #modtime=date("now"), #modwith="nodups",
-##                modby=8873) where u.#users_id = users_id
-##     inquire_equel(rowcount = "rowcount")
-       if (rowcount != 1)
-         printf("Failed!\007\007\007\n");
-       else
-         printf("User %s updated, %s marked for deletion.\n", login2, login);
-       break;
-    case '5':
-       users_id = users[2].users_id;
-##     replace u (#status = 3, #modtime=date("now"), #modwith="nodups",
-##                modby=8873) where u.#users_id = users_id
-##     inquire_equel(rowcount = "rowcount")
-       if (rowcount != 1)
-         printf("Failed!\007\007\007\n");
-       else
-         printf("User %d marked for deletion.\n", users[2].users_id);
-       break;
-    case '6':
-       users_id = users[3].users_id;
-##     replace u (#status = 3, #modtime=date("now"), #modwith="nodups",
-##                modby=8873) where u.#users_id = users_id
-##     inquire_equel(rowcount = "rowcount")
-       if (rowcount != 1)
-         printf("Failed!\007\007\007\n");
-       else
-         printf("User %d marked for deletion.\n", users[3].users_id);
-       break;
-    case 'q':
-       exit(0);
-    default:
-       printf("Leaving unchanged\n");
-    }
-##}
index 887a937097bbbecd1204b23e5b625a915120593d..1e5f3d63ef14156d89e15ff4f05d7286dcaab856 100644 (file)
@@ -4,7 +4,7 @@
  */
 
 #include <stdio.h>
-#include <strings.h>
+#include <string.h>
 #include <ctype.h>
 #include <sys/time.h>
 #include <moira.h>
@@ -27,7 +27,7 @@ char **argv;
      SigInfo si;
      int found, status, i, wait;
      EXEC SQL BEGIN DECLARE SECTION;
-     char login[10], mid[32], rawsig[256];
+     char login[10], mid[32], rawsig[256], *db="moira";
      int id, timestamp, sms;
      EXEC SQL END DECLARE SECTION;
 
@@ -56,9 +56,9 @@ char **argv;
           com_err(program, status + krb_err_base, " in krb_get_pw_in_tkt");
      }
 
-     EXEC SQL CONNECT moira;
+     EXEC SQL CONNECT :db IDENTIFIED BY :db;
      if (sqlca.sqlcode != 0) {
-        com_err(program, 0, "ingres error %d", sqlca.sqlcode);
+        com_err(program, 0, "dbms error %d", sqlca.sqlcode);
         exit(1);
      }
 
@@ -78,12 +78,12 @@ char **argv;
        SELECT users_id, login, clearid
        FROM users WHERE signature = '';
      if (sqlca.sqlcode != 0) {
-        com_err(program, 0, "ingres error %d", sqlca.sqlcode);
+        com_err(program, 0, "dbms error %d", sqlca.sqlcode);
         exit(1);
      }
      EXEC SQL OPEN c;
      if (sqlca.sqlcode != 0) {
-        com_err(program, 0, "ingres error %d", sqlca.sqlcode);
+        com_err(program, 0, "dbms error %d", sqlca.sqlcode);
         exit(1);
      }
      while (1) {
@@ -102,7 +102,7 @@ char **argv;
      si.rawsig = (unsigned char *) &rawsig[0];
 
      while (sq_get_data(sq, &data)) {
-        p = index(data, ':');
+        p = strchr(data, ':');
         if (!p) {
             com_err(program, 0, " malformatted data");
             continue;
@@ -127,11 +127,11 @@ char **argv;
         }
 
         timestamp = si.timestamp;
-        EXEC SQL REPEATED UPDATE users 
+        EXEC SQL UPDATE users 
           SET signature = :rawsig, sigwho = :sms, sigdate = :timestamp
           WHERE users_id = :id;
         if (sqlca.sqlcode != 0) {
-            com_err(program, 0, "ingres error %d", sqlca.sqlcode);
+            com_err(program, 0, "dbms error %d", sqlca.sqlcode);
             exit(1);
         }
         EXEC SQL COMMIT WORK;
index 79f2cfb32bb6586fa1583ae41c9cc233a5fa48d3..07a58e3095620f00a1775e02885bf3fa2ab41574 100644 (file)
@@ -2,7 +2,7 @@
  */
 
 #include <stdio.h>
-#include <strings.h>
+#include <string.h>
 #include <ctype.h>
 #include <sys/time.h>
 #include <moira.h>
@@ -77,9 +77,8 @@ struct entry {
 char *whoami;
 int newfinger = 0;
 
-#define SQL_DUPLICATE -40100
-#define SQL_DEADLOCK -49900
-#define sqlfail() (sqlca.sqlcode && sqlca.sqlcode != 100)
+#define SQL_DUPLICATE 1422
+#define sqlfail() (sqlca.sqlcode && sqlca.sqlcode != 1403)
 
 main(argc, argv)
 int argc;
@@ -89,13 +88,19 @@ char **argv;
     struct entry *e, *get_next_entry();
     int i, wait = 0;
     char buf[BUFSIZ], *file = NULL;
+EXEC SQL BEGIN DECLARE SECTION;
+    char *db="moira";
+EXEC SQL END DECLARE SECTION;
 
-    whoami = rindex(argv[0], '/');
+    whoami = strrchr(argv[0], '/');
     if (whoami)
       whoami++;
     else
       whoami = argv[0];
 
+    setvbuf(stdout, NULL, _IOLBF, BUFSIZ);
+    setvbuf(stderr, NULL, _IOLBF, BUFSIZ);
+
     for (i = 1; i < argc; i++) {
        if (!strcmp(argv[i], "-w"))
          wait++;
@@ -115,13 +120,11 @@ char **argv;
        exit(1);
     }
 
-    setlinebuf(stdout);
-    setlinebuf(stderr);
     initialize_sms_error_table();
 
-    EXEC SQL CONNECT moira;
+    EXEC SQL CONNECT :db IDENTIFIED BY :db;
     if (sqlca.sqlcode != 0) {
-       com_err(whoami, 0, "ingres error %d", sqlca.sqlcode);
+       dbmserr("connecting", sqlca.sqlcode);
        exit(1);
     }
 
@@ -130,13 +133,8 @@ char **argv;
        process_entry(e);
        EXEC SQL COMMIT WORK;
        if (sqlca.sqlcode != 0) {
-           if (sqlca.sqlcode == SQL_DEADLOCK) {
-               com_err(whoami, MR_DEADLOCK, "commiting work");
-               goto again;
-           } else {
-               com_err(whoami, 0, "ingres error %d", sqlca.sqlcode);
-               exit(1);
-           }
+         dbmserr("committing work", sqlca.sqlcode);
+         exit(1);
        }
        if (wait) {
            printf("Next");
@@ -190,7 +188,7 @@ FILE *in;
 
     strcpy(sname, name);
     e.name = strtrim(sname);
-    p = index(name, ',');
+    p = strchr(name, ',');
     if (p)
       *p = 0;
     e.last = strtrim(name);
@@ -199,7 +197,7 @@ FILE *in;
        while (isspace(*p))
          p++;
        e.first = p;    
-       if (p = index(e.first, ' ')) {
+       if (p = strchr(e.first, ' ')) {
            *p = 0;
            e.first = strtrim(e.first);
            e.middle = strtrim(p + 1);
@@ -277,7 +275,7 @@ struct entry *e;
     encrypted = 0;
 
     /* Get user info */
-    EXEC SQL REPEATED SELECT users_id, first, last, middle, type, home_addr, home_phone, office_phone, status, department
+    EXEC SQL SELECT users_id, first, last, middle, type, home_addr, home_phone, office_phone, status, department
       INTO :id, :dfirst, :dlast, :dmiddle, :class, :haddr, :hphone, :ophone, :status, :dept
       FROM users
       WHERE clearid = :sid;
@@ -285,26 +283,15 @@ struct entry *e;
        if (sqlca.sqlcode == SQL_DUPLICATE) {
            com_err(whoami, 0, "duplicate ID number %s on user %s %s", sid, first, last);
            return;
-       } else if (sqlca.sqlcode == SQL_DEADLOCK) {
-           com_err(whoami, MR_DEADLOCK, "looking up user %s", sid);
-           EXEC SQL ROLLBACK;
-           return process_entry(e);
        } else
          sqlexit();
     }
     if (id == 0) {
-       EXEC SQL REPEATED SELECT users_id, first, last, middle, type, home_addr, home_phone, office_phone, status, department
+       EXEC SQL SELECT users_id, first, last, middle, type, home_addr, home_phone, office_phone, status, department
          INTO :id, :dfirst, :dlast, :dmiddle, :class, :haddr, :hphone, :ophone, :status, :dept
          FROM users
          WHERE last = :last and first = :first and clearid = :eid;
-       if (sqlfail()) {
-           if (sqlca.sqlcode == SQL_DEADLOCK) {
-               com_err(whoami, MR_DEADLOCK, "looking up user %s", sid);
-               EXEC SQL ROLLBACK;
-               return process_entry(e);
-           } else if (sqlca.sqlcode != SQL_DUPLICATE)
-             sqlexit();
-       }
+       if (sqlfail()) sqlexit();
        encrypted++;
        if (id == 0) {
            newuser(e);
@@ -323,12 +310,12 @@ struct entry *e;
        if (status == US_NOT_ALLOWED) status = US_NO_LOGIN_YET;
        if (status == US_ENROLL_NOT_ALLOWED) status = US_ENROLLED;
        strcpy(class, e->class);
-       EXEC SQL REPEATED UPDATE users
-         SET type = :class, status = :status, modtime = 'now',
+       EXEC SQL UPDATE users
+         SET type = NVL(:class,CHR(0)), status = :status, modtime = SYSDATE,
            modby = :who, modwith = :prog
          WHERE users_id = :id;   
        if (sqlca.sqlcode != 0) {
-           com_err(whoami, 0, "ingres error %d", sqlca.sqlcode);
+           dbmserr("updating class", sqlca.sqlcode);
            exit(1);
        }
     }
@@ -339,11 +326,12 @@ struct entry *e;
        strcmp(middle, strtrim(dmiddle))) {
        com_err(whoami, 0, "updating real name for %s %s", first, last);
        EXEC SQL UPDATE users
-         SET first = :first, last = :last, middle = :middle,
-               modby = :who, modwith = :prog, modtime = 'now'
+         SET first = NVL(:first,CHR(0)), last = NVL(:last,CHR(0)),
+         middle = NVL(:middle,CHR(0)), modby = :who, modwith = :prog,
+         modtime = SYSDATE
          WHERE users_id = :id;
        if (sqlca.sqlcode != 0) {
-           com_err(whoami, 0, "ingres error %d", sqlca.sqlcode);
+           dbmserr("updating name", sqlca.sqlcode);
            exit(1);
        }
     }
@@ -365,9 +353,9 @@ struct entry *e;
        strcat(buf, " ");
        strcat(buf, e->state);
     }
-    while (to = index(buf, ','))
+    while (to = strchr(buf, ','))
       *to = ';';
-    while (to = index(buf, ':'))
+    while (to = strchr(buf, ':'))
       *to = ';';
     if (newfinger) {
        if (haddr[0] == ' ') {
@@ -468,39 +456,29 @@ struct entry *e;
     }
     if (changed) {
        com_err(whoami, 0, "updating finger for %s %s", first, last);
-       EXEC SQL REPEATED UPDATE users
-         SET home_addr = :haddr, home_phone = :hphone,
-           office_phone = :ophone, department = :dept,
-           fmodtime = 'now', fmodby = :who, fmodwith = :prog,
-           xname = :name, xdept = :rdept, xtitle = :rtitle,
-           xaddress = :raddr, xphone1 = :rhphone, xphone2 = :rophone,
-           xmodtime = date('now'), clearid = :sid
+       EXEC SQL UPDATE users
+         SET home_addr = NVL(:haddr,CHR(0)), home_phone = NVL(:hphone,CHR(0)),
+         office_phone = NVL(:ophone,CHR(0)), department = NVL(:dept,CHR(0)),
+         fmodtime = SYSDATE, fmodby = :who, fmodwith = :prog,
+         xname = NVL(:name,CHR(0)), xdept = NVL(:rdept,CHR(0)),
+         xtitle = NVL(:rtitle,CHR(0)), xaddress = NVL(:raddr,CHR(0)),
+         xphone1 = NVL(:rhphone,CHR(0)), xphone2 = NVL(:rophone,CHR(0)),
+         xmodtime = SYSDATE, clearid = NVL(:sid,CHR(0))
          WHERE users_id = :id;
        if (sqlca.sqlcode != 0) {
-           if (sqlca.sqlcode == SQL_DEADLOCK) {
-               com_err(whoami, MR_DEADLOCK, "updating user %s", sid);
-               EXEC SQL ROLLBACK;
-               return process_entry(e);
-           } else {
-               com_err(whoami, 0, "ingres error %d", sqlca.sqlcode);
-               exit(1);
-           }
+         dbmserr(NULL, sqlca.sqlcode);
+         exit(1);
        }
     }  else {
-       EXEC SQL REPEATED UPDATE users
-         SET xname = :name, xdept = :rdept, xtitle = :rtitle,
-           xaddress = :raddr, xphone1 = :rhphone, xphone2 = :rophone,
-           xmodtime = date('now'), clearid = :sid
+       EXEC SQL UPDATE users
+         SET xname = NVL(:name,CHR(0)), xdept = NVL(:rdept,CHR(0)),
+         xtitle = NVL(:rtitle,CHR(0)), xaddress = NVL(:raddr,CHR(0)),
+         xphone1 = NVL(:rhphone,CHR(0)), xphone2 = NVL(:rophone,CHR(0)),
+         xmodtime = SYSDATE, clearid = NVL(:sid,CHR(0))
          WHERE users_id = :id;
        if (sqlca.sqlcode != 0) {
-           if (sqlca.sqlcode == SQL_DEADLOCK) {
-               com_err(whoami, MR_DEADLOCK, "updating user %s", sid);
-               EXEC SQL ROLLBACK;
-               return process_entry(e);
-           } else {
-               com_err(whoami, 0, "ingres error %d", sqlca.sqlcode);
-               exit(1);
-           }
+         dbmserr(NULL, sqlca.sqlcode);
+         exit(1);
        }
     }
 }
@@ -591,24 +569,22 @@ struct entry *e;
        FixCase(raddr);
        strcat(raddr, "MIT INTERDEPARTMENTAL MAIL");
     }
-    EXEC SQL REPEATED INSERT INTO users
-      (login, users_id, uid, shell, last, first, middle, status,
+    EXEC SQL INSERT INTO users
+      (login, users_id, unix_uid, shell, last, first, middle, status,
        clearid, type, modtime, modby, modwith, fullname, home_addr,
        home_phone, office_phone, department, fmodtime, fmodby, fmodwith,
        potype, xname, xdept, xtitle, xaddress, xphone1, xphone2, xmodtime)
-      VALUES (:login, :id, :uid, '/bin/csh', :last, :first, :middle, 0,
-             :sid, :class, 'now', :who, :prog, :fullname, :haddr, :hphone,
-             :ophone, :dept, 'now', :who, :prog, 'NONE', :name, :dept,
-             :title, :raddr, :hphone, :ophone, date('now'));
+      VALUES (:login, :id, :uid, '/bin/athena/tcsh', NVL(:last,CHR(0)),
+             NVL(:first,CHR(0)), NVL(:middle,CHR(0)), 0, NVL(:sid,CHR(0)),
+             NVL(:class,CHR(0)), SYSDATE, :who, :prog, NVL(:fullname,CHR(0)),
+             NVL(:haddr,CHR(0)), NVL(:hphone,CHR(0)), NVL(:ophone,CHR(0)),
+             NVL(:dept,CHR(0)), SYSDATE, :who, :prog, 'NONE',
+             NVL(:name,CHR(0)), NVL(:dept,CHR(0)), NVL(:title,CHR(0)),
+             NVL(:raddr,CHR(0)), NVL(:hphone,CHR(0)), NVL(:ophone,CHR(0)),
+             SYSDATE);
     if (sqlca.sqlcode != 0) {
-       if (sqlca.sqlcode == SQL_DEADLOCK) {
-           com_err(whoami, MR_DEADLOCK, "adding user %s", sid);
-           EXEC SQL ROLLBACK;
-           return newuser(e);
-       } else {
-           com_err(whoami, 0, "ingres error %d", sqlca.sqlcode);
-           exit(1);
-       }
+      dbmserr("adding user", sqlca.sqlcode);
+      exit(1);
     } else
       com_err(whoami, 0, "adding user %s %s", e->first, e->last);
 }
@@ -622,7 +598,7 @@ set_next_users_id(limit)
     int rowcount, flag, value, retval;
     EXEC SQL END DECLARE SECTION;
 
-    EXEC SQL REPEATED SELECT value INTO :value FROM numvalues 
+    EXEC SQL SELECT value INTO :value FROM numvalues 
       WHERE name = 'users_id';
     if (sqlfail()) sqlexit();
     if (sqlca.sqlerrd[2] != 1) {
@@ -632,7 +608,7 @@ set_next_users_id(limit)
     }
 
     flag = 0;
-    EXEC SQL REPEATED SELECT users_id INTO :flag FROM users
+    EXEC SQL SELECT users_id INTO :flag FROM users
       WHERE users_id = :value;
     if (sqlfail()) sqlexit();
     if (sqlca.sqlerrd[2] == 0)
@@ -642,7 +618,7 @@ set_next_users_id(limit)
        if (limit && value > MAX_ID_VALUE)
            value = MIN_ID_VALUE;
        flag = 0;
-       EXEC SQL REPEATED SELECT users_id INTO :flag FROM users 
+       EXEC SQL SELECT users_id INTO :flag FROM users 
          WHERE users_id = :value;
        if (sqlfail()) sqlexit();
        if (sqlca.sqlerrd[2] == 0)
@@ -652,10 +628,10 @@ set_next_users_id(limit)
     retval = value++;
     if (limit && value > MAX_ID_VALUE)
       value = MIN_ID_VALUE;
-    EXEC SQL REPEATED UPDATE numvalues SET value = :value
+    EXEC SQL UPDATE numvalues SET value = :value
       WHERE name = 'users_id';
     if (sqlca.sqlcode != 0) {
-       com_err(whoami, 0, "ingres error %d", sqlca.sqlcode);
+       dbmserr("updating numvalues", sqlca.sqlcode);
        exit(1);
     }
     return(retval);
@@ -668,8 +644,8 @@ set_next_uid(limit)
     int rowcount, flag, value, retval;
     EXEC SQL END DECLARE SECTION;
 
-    EXEC SQL REPEATED SELECT value INTO :value FROM numvalues 
-      WHERE name = 'uid';
+    EXEC SQL SELECT value INTO :value FROM numvalues 
+      WHERE name = 'unix_uid';
     if (sqlfail()) sqlexit();
     if (sqlca.sqlerrd[2] != 1) {
        EXEC SQL ROLLBACK;
@@ -678,7 +654,7 @@ set_next_uid(limit)
     }
 
     flag = 0;
-    EXEC SQL REPEATED SELECT uid INTO :flag FROM users WHERE uid = :value;
+    EXEC SQL SELECT unix_uid INTO :flag FROM users WHERE unix_uid = :value;
     if (sqlfail()) sqlexit();
     if (sqlca.sqlerrd[2] == 0)
       flag = 0;
@@ -687,7 +663,7 @@ set_next_uid(limit)
        if (limit && value > MAX_ID_VALUE)
            value = MIN_ID_VALUE;
        flag = 0;
-       EXEC SQL REPEATED SELECT uid INTO :flag FROM users WHERE uid = :value;
+       EXEC SQL SELECT unix_uid INTO :flag FROM users WHERE unix_uid = :value;
        if (sqlfail()) sqlexit();
        if (sqlca.sqlerrd[2] == 0)
          flag = 0;
@@ -696,9 +672,9 @@ set_next_uid(limit)
     retval = value++;
     if (limit && value > MAX_ID_VALUE)
       value = MIN_ID_VALUE;
-    EXEC SQL REPEATED UPDATE numvalues SET value = :value WHERE name = 'uid';
+    EXEC SQL UPDATE numvalues SET value = :value WHERE name = 'unix_uid';
     if (sqlca.sqlcode != 0) {
-       com_err(whoami, 0, "ingres error %d", sqlca.sqlcode);
+       dbmserr("updating numvalues", sqlca.sqlcode);
        exit(1);
     }
     return(retval);
@@ -707,11 +683,21 @@ set_next_uid(limit)
 
 sqlexit()
 {
-    if (sqlca.sqlcode == SQL_DEADLOCK)
-      com_err(whoami, MR_DEADLOCK, "unrecoverable ingres error %d",
-             sqlca.sqlcode);
-    else
-      com_err(whoami, 0, "ingres error %d", sqlca.sqlcode);
+    dbmserr(NULL, sqlca.sqlcode);
     EXEC SQL ROLLBACK WORK;
     exit(1);
 }
+
+dbmserr(char *where, int what)
+{
+  char err_msg[256];
+  int bufsize=256, msglength=0;
+
+  sqlglm(err_msg, &bufsize, &msglength);
+  err_msg[msglength]=0;
+
+  if(where)
+    com_err(whoami, 0, "DBMS error %swhile %s", err_msg, where);
+  else
+    com_err(whoami, 0, "DBMS error %s", err_msg);
+}
index 687a2cb7535a1754e37cc3c26d7694b53521ee30..5a42ff7c74b5031da20f5494cece0da1d8709a19 100644 (file)
@@ -4,7 +4,7 @@
  */
 
 #include <stdio.h>
-#include <strings.h>
+#include <string.h>
 #include <ctype.h>
 #include <sys/time.h>
 #include <moira.h>
@@ -22,12 +22,13 @@ main(argc, argv)
 int argc;
 char **argv;
 {
-    char buf[BUFSIZ], *usercheck[100], sigbuf[256], *data;
+    char buf[BUFSIZ], *usercheck[100], sigbuf[256], *data, *db="moira";
     SigInfo si;
     struct save_queue *sq;
     int status, i, wait, check, debug, fix;
     EXEC SQL BEGIN DECLARE SECTION;
     char login[10], mid[32], rawsig[256], who[257];
+    EXEC SQL VAR rawsig IS STRING(256);
     int id, timestamp, sms;
     EXEC SQL END DECLARE SECTION;
 
@@ -52,7 +53,7 @@ char **argv;
        else usercheck[check++] = argv[i];
     }
 
-    EXEC SQL CONNECT moira;
+    EXEC SQL CONNECT :db IDENTIFIED BY :db;
 
     if (fix) {
        /* Set the name of our kerberos ticket file */
@@ -84,7 +85,7 @@ char **argv;
        EXEC SQL DECLARE c CURSOR FOR
          SELECT login, clearid, signature, string, sigdate
          FROM users, strings
-         WHERE signature != '' and sigwho = string_id;
+         WHERE signature != CHR(0) and sigwho = string_id;
        EXEC SQL OPEN c;
        while (1) {
            EXEC SQL FETCH c INTO :login, :mid, :rawsig, :who, :timestamp;
@@ -117,8 +118,8 @@ char **argv;
        if (fix) {
            while (sq_get_data(sq, &data)) {
                strncpy(login, data, 8);
-               if (index(login, ':'))
-                 *index(login, ':') = 0;
+               if (strchr(login, ':'))
+                 *strchr(login, ':') = 0;
            again:
                com_err(program, 0, "fixing sig for %s", login);
                status = GDSS_Sign(data, strlen(data), sigbuf, &si);
@@ -138,11 +139,11 @@ char **argv;
                }
 
                timestamp = si.timestamp;
-               EXEC SQL REPEATED UPDATE users 
+               EXEC SQL UPDATE users 
                  SET signature = :rawsig, sigwho = :sms, sigdate = :timestamp
                    WHERE login = :login;
                if (sqlca.sqlcode != 0) {
-                   com_err(program, 0, "ingres error %d", sqlca.sqlcode);
+                   com_err(program, 0, "dbms error %d", sqlca.sqlcode);
                    dest_tkt();
                    exit(1);
                }
@@ -155,7 +156,7 @@ char **argv;
            EXEC SQL DECLARE s CURSOR FOR
              SELECT clearid, signature, string, sigdate
              FROM users, strings
-             WHERE signature != '' and sigwho = string_id and login = :login;
+             WHERE sigwho = string_id and login = :login;
            EXEC SQL OPEN s;
            while (1) {
                EXEC SQL FETCH s INTO :mid, :rawsig, :who, :timestamp;
@@ -195,11 +196,11 @@ char **argv;
                    }
 
                    timestamp = si.timestamp;
-                   EXEC SQL REPEATED UPDATE users 
+                   EXEC SQL UPDATE users 
                      SET signature = :rawsig, sigwho = :sms, sigdate = :timestamp
                        WHERE login = :login;
                    if (sqlca.sqlcode != 0) {
-                       com_err(program, 0, "ingres error %d", sqlca.sqlcode);
+                       com_err(program, 0, "dbms error %d", sqlca.sqlcode);
                        dest_tkt();
                        exit(1);
                    }
index 5c140c7907f30d08ebc29bf302dc1c3e7600a247..90b71fa32af70580ee0baabdb02cce54dbb66dc5 100644 (file)
@@ -2,7 +2,7 @@
  */
 
 #include <stdio.h>
-#include <strings.h>
+#include <string.h>
 #include <ctype.h>
 #include <sys/time.h>
 #include <moira.h>
@@ -27,15 +27,18 @@ char **argv;
     FILE *in;
     struct entry *e, *get_next_entry();
     int i, wait = 0;
-    char buf[BUFSIZ], *file = NULL, *p, *p1;
+    char buf[BUFSIZ], *file = NULL, *p, *p1, *db="moira";
 
     debug = 0;
-    whoami = rindex(argv[0], '/');
+    whoami = strrchr(argv[0], '/');
     if (whoami)
       whoami++;
     else
       whoami = argv[0];
 
+    setvbuf(stdout, NULL, _IOLBF, BUFSIZ);
+    setvbuf(stderr, NULL, _IOLBF, BUFSIZ);
+
     for (i = 1; i < argc; i++) {
        if (!strcmp(argv[i], "-w"))
          wait++;
@@ -55,10 +58,7 @@ char **argv;
        exit(1);
     }
 
-    setlinebuf(stdout);
-    setlinebuf(stderr);
-
-    EXEC SQL CONNECT moira;
+    EXEC SQL CONNECT :db IDENTIFIED BY :db;
     if (sqlca.sqlcode != 0) {
        com_err(whoami, 0, "ingres error %d", sqlca.sqlcode);
        exit(1);
@@ -109,12 +109,12 @@ struct entry *e;
 {
     EXEC SQL BEGIN DECLARE SECTION;
     char *id, *login;
+    EXEC SQL VAR login is STRING(9);
     EXEC SQL END DECLARE SECTION;
 
     id = e->id;
     login = e->login;
-    EXEC SQL REPEATED SELECT login INTO :login FROM users
-      WHERE clearid = :id;
+    EXEC SQL SELECT login INTO :login FROM users WHERE clearid = :id;
     if (sqlca.sqlcode != 0) {
        fprintf(stderr, "Error %d on %s\n", sqlca.sqlcode, e->line);
        return(-1);
This page took 0.741236 seconds and 5 git commands to generate.