]> andersk Git - moira.git/commitdiff
second code style cleanup: void/void * usage, proper #includes. try to
authordanw <danw>
Thu, 5 Feb 1998 22:50:19 +0000 (22:50 +0000)
committerdanw <danw>
Thu, 5 Feb 1998 22:50:19 +0000 (22:50 +0000)
pacify gcc -Wall.
fix rcsid strings and copyrights

147 files changed:
backup/Imakefile
backup/db2bkup.awk
backup/db2rest.awk
backup/dump_db.h
backup/dump_db.pc
backup/dumprest.pc
backup/rest_db.pc
clients/addusr/addusr.c
clients/blanche/blanche.c
clients/mailmaint/mailmaint.c
clients/moira/Imakefile
clients/moira/attach.c
clients/moira/cluster.c
clients/moira/dcmmaint.c
clients/moira/defs.h
clients/moira/delete.c
clients/moira/f_defs.h
clients/moira/globals.c
clients/moira/globals.h
clients/moira/lists.c
clients/moira/main.c
clients/moira/menu.c
clients/moira/menu.h
clients/moira/menus.c
clients/moira/misc.c
clients/moira/namespace.c
clients/moira/nfs.c
clients/moira/pobox.c
clients/moira/printer.c
clients/moira/quota.c
clients/moira/user.c
clients/moira/utils.c
clients/moira/zephyr.c
clients/mrcheck/mrcheck.c
clients/mrtest/mrtest.c
clients/passwd/chfn.c
clients/passwd/chpobox.c
clients/passwd/chsh.c
clients/userreg/disable.c
clients/userreg/display.c
clients/userreg/files.h
clients/userreg/reg_stubs.c
clients/userreg/userreg.c
clients/userreg/userreg.h
dbck/Imakefile
dbck/dbck.h
dbck/dbck.pc
dbck/fix.pc
dbck/nhash.c [deleted file]
dbck/phase1.pc
dbck/phase2.pc
dbck/phase3.pc
dbck/phase4.pc
dcm/dcm.pc
dcm/startdcm.c
gen/directory.pc
gen/hesiod.pc
gen/hosts.pc
gen/mailhub.pc
gen/moddiff.pc
gen/ndb.pc
gen/network.pc
gen/nfs.pc
gen/passwd.pc
gen/pobox.pc
gen/util.c
gen/util.h [new file with mode: 0644]
gen/warehouse.pc
include/gdb.h
include/mit-copyright.h
include/moira.h
include/moira_site.h
include/mr_proto.h
include/update.h
include/ureg_proto.h
incremental/afs.c
incremental/ksrvtgt.c
lib/critical.c
lib/fixhost.c
lib/fixname.c
lib/gdss_convert.c
lib/hash.c
lib/idno.c
lib/kname_unparse.c
lib/mr_access.c
lib/mr_auth.c
lib/mr_call.c
lib/mr_connect.c
lib/mr_data.c
lib/mr_init.c
lib/mr_ops.c
lib/mr_param.c
lib/mr_private.h
lib/mr_query.c
lib/nfsparttype.c
lib/sq.c
lib/strs.c
reg_svr/reg_svr.c
reg_svr/reg_svr.h
reg_svr/requests.c
reg_svr/startreg.c
regtape/Imakefile
regtape/employee.pc
regtape/rafnu.c [deleted file]
regtape/sign.pc
regtape/students.pc
regtape/verify.pc
regtape/vote.pc
server/Imakefile
server/cache.pc
server/increment.pc
server/mr_glue.c
server/mr_main.c
server/mr_sauth.c
server/mr_scall.c
server/mr_server.h
server/mr_shutdown.c
server/mr_srvdata.c
server/mr_util.c
server/qaccess.pc
server/qfollow.pc
server/qrtn.h
server/qrtn.pc
server/qsetup.pc
server/qsubs.c
server/qsupport.pc
server/queries2.c
server/query.h
server/qvalidate.pc
server/startmoira.c
update/Imakefile
update/auth_002.c
update/checksum.c
update/client.c
update/config.c
update/exec_002.c
update/get_file.c
update/hostname.c [deleted file]
update/log.c
update/send_file.c
update/smskey.c
update/ticket.c
update/update_server.c
update/update_server.h [new file with mode: 0644]
update/update_test.c
update/xfer_002.c
update/xfer_003.c

index b86a0e2f2e558d01fc2ec5a659228bc1a9bc04a2..21cba441500b9f3011b6dfadc574f374ca933aff 100644 (file)
@@ -26,7 +26,7 @@ rest.pc: ../db/schema.sql db2rest.awk
        awk -f db2rest.awk < ../db/schema.sql > rest.pc
 rest1.pc: rest.pc
 clean::
-       $(RM) bkup.pc bkup1.pc rest.pc rest1.pc
+       $(RM) bkup.pc bkup1.pc bkup.h rest.pc rest1.pc rest.h
 sqlfile(dump_db)
 sqlfile(rest_db)
 sqlfile(dumprest)
index 16ada41851c9e61a79850f44a48616779295e10b..5185d7dad7977de3baea0d57791bbb397de2436f 100644 (file)
@@ -1,5 +1,4 @@
-#      $Source$
-#      $Header$
+#      $Id $
 #
 #      This converts the file used to originally create the database
 #      into a program to back it up.
@@ -9,24 +8,28 @@
 BEGIN {
        print "/* This file automatically generated */";
        print "/* Do not edit */\n";
-       print "#include <stdio.h>";
        print "EXEC SQL INCLUDE sqlca;";
        print "EXEC SQL WHENEVER SQLERROR DO dbmserr();";
        print "#include \"dump_db.h\"";
+       print "#include \"bkup.h\"";
        print "#define dump_bin dump_str\n";
 
        print "/* This file automatically generated */" > "bkup1.pc";
        print "/* Do not edit */\n" >> "bkup1.pc";
-       print "#include <stdio.h>" >> "bkup1.pc";
-       print "FILE *open_file(char *prefix, char *suffix);\n" >> "bkup1.pc";
-       print "int do_backups(char *prefix)\n{" >> "bkup1.pc";
+       print "#include \"dump_db.h\"" >> "bkup1.pc";
+       print "#include \"bkup.h\"" >> "bkup1.pc";
+       print "void do_backups(char *prefix)\n{" >> "bkup1.pc";
+
+       print "/* This file automatically generated */" > "bkup.h";
+       print "/* Do not edit */\n" >> "bkup.h";
 }
 
 $1=="#" { next; }
 
 /^create/ {
-       printf "int dump_%s(FILE *f)\n{\n  EXEC SQL BEGIN DECLARE SECTION;\n", $3;
+       printf "void dump_%s(FILE *f)\n{\n  EXEC SQL BEGIN DECLARE SECTION;\n", $3;
        printf "  dump_%s(open_file(prefix, \"%s\"));\n", $3, $3 >> "bkup1.pc";
+       printf "void dump_%s(FILE *f);\n", $3 >> "bkup.h";
 
        tablename = $3;
        rangename = substr(tablename, 1, 1);
index 269cad436b54a80786ff03df1e583e032c079f86..ab9a41bd868255776c667933a0eae92b82071d11 100644 (file)
@@ -1,5 +1,4 @@
-#      $Source$
-#      $Header$
+#      $Id $
 #
 #      This converts the file used to originally create the database
 #      into a program to restore it from a backup.
@@ -9,24 +8,29 @@
 BEGIN {
        print "/* This file automatically generated */";
        print "/* Do not edit */\n";
-       print "#include <stdio.h>";
        print "EXEC SQL INCLUDE sqlca;";
        print "EXEC SQL WHENEVER SQLERROR DO dbmserr();";
-       print "void parse_nl(FILE *), parse_str(FILE *, char *, int), parse_sep(FILE *);\n";
+       print "#include <com_err.h>";
+       print "#include \"dump_db.h\"";
+       print "#include \"rest.h\"";
 
        print "/* This file automatically generated */" > "rest1.pc";
        print "/* Do not edit */\n" >> "rest1.pc";
-       print "#include <stdio.h>" >> "rest1.pc";
-       print "FILE *open_file(char *prefix, char *suffix);\n" >> "rest1.pc";
-       print "int do_restores(char *prefix)\n{" >> "rest1.pc";
+       print "#include \"dump_db.h\"" >> "rest1.pc";
+       print "#include \"rest.h\"" >> "rest1.pc";
+       print "void do_restores(char *prefix)\n{" >> "rest1.pc";
+
+       print "/* This file automatically generated */" > "bkup.h";
+       print "/* Do not edit */\n" >> "bkup.h";
 }
 
 $1=="#" { next; }
 
 /^create/ {
-       printf "int restore_%s(FILE *f)\n", $3;
+       printf "void restore_%s(FILE *f)\n", $3;
        print "{\n  EXEC SQL BEGIN DECLARE SECTION;";
        printf "  restore_%s(open_file(prefix, \"%s\"));\n", $3, $3 >> "rest1.pc";
+       printf "void restore_%s(FILE *f);\n", $3 >> "rest.h";
 
        tablename = $3;
        rangename = substr(tablename, 1, 1);
index c68ed880c5223acd8e723abef29e84b92b5ba756..9f920271c5057e97717ea2f01bb59b82d1de8d27 100644 (file)
@@ -1,6 +1,25 @@
-/* $Header$ */
+/* $Id $ */
+
+#include <stdio.h>
+#include <moira.h>
 
 #define SEP_CHAR ('|')
 
+void do_backups(char *prefix);
+void do_restores(char *prefix);
+
+void dump_int(FILE *f, int n);
+void dump_str(FILE *f, char *str);
 #define dump_nl(f) { if (putc('\n', f) < 0) wpunt(); }
 #define dump_sep(f) { if (putc(SEP_CHAR, f) < 0) wpunt(); }
+
+int parse_int(FILE *f);
+void parse_str(FILE *f, char *buf, int maxlen);
+void parse_sep(FILE *f);
+void parse_nl(FILE *f);
+
+void wpunt(void);
+void punt(char *msg);
+void dbmserr(void);
+void safe_close(FILE *stream);
+FILE *open_file(char *prefix, char *suffix);
index c1258bbcbb5ea1fdad22ed86167dcd5a85d2b44d..d67c5595e7fa7bc72d548ae7c6c44172eccb3527 100644 (file)
@@ -1,36 +1,25 @@
-/*
- *     $Source$
- *     $Author$
- *     $Header$
- *
- *     (c) Copyright 1988 by the Massachusetts Institute of Technology.
- *     For copying and distribution information, please see the file
- *     <mit-copyright.h>.
+/* $Id $
  *
  *     This program dumps the Moira database to a series of output files
  * which can be later read back into Moira in the event of a crash.
  *
+ * Copyright (C) 1988-1998 by the Massachusetts Institute of Technology.
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
  */
 
-#ifndef lint
-static char *rcsid_dump_db_c = "$Header$";
-#endif lint
-
-#include <stdio.h>
-#include <sys/file.h>
-#include <fcntl.h>
-#include <ctype.h>
 #include <mit-copyright.h>
-EXEC SQL INCLUDE sqlca;
+#include <moira.h>
 #include "dump_db.h"
 
-/* putc without the line buffer hair */
+#include <fcntl.h>
+#include <stdio.h>
+#include <string.h>
+#include <unistd.h>
 
-#define putc1(x, p)    (--(p)->_cnt >= 0 ?\
-       (int)(*(unsigned char *)(p)->_ptr++ = (x)) :\
-               _flsbuf((unsigned char)(x), p))
+EXEC SQL INCLUDE sqlca;
 
-FILE *open_file();
+RCSID("$Header$");
 
 EXEC SQL BEGIN DECLARE SECTION;
 char *db = "moira";
@@ -39,7 +28,6 @@ EXEC SQL END DECLARE SECTION;
 int main(int argc, char **argv)
 {
   char *prefix;
-  int i;
 
   if (argc != 2)
     {
@@ -56,48 +44,48 @@ int main(int argc, char **argv)
   exit(0);
 }
 
-int dump_int(FILE *f, int n)
+void dump_int(FILE *f, int n)
 {
   char buf[1024];
   sprintf(buf, "%d", n);
   dump_str(f, buf);
 }
 
-int wpunt(void)
+void wpunt(void)
 {
   punt("can't write backup file");
 }
 
-int dump_str(FILE *f, char *str)
+void dump_str(FILE *f, char *str)
 {
   char *ibp, c;
   int t;
 
-  for (ibp = str; c = (unsigned char) *ibp; ibp++)
+  for (ibp = str; (c = *ibp); ibp++)
     {
       if (c < 32 || c > 126 || c == SEP_CHAR || c == '\\')
        {
-         if (putc1('\\', f) < 0)
+         if (putc('\\', f) < 0)
            wpunt();
          t = ((c >> 6) & 7) + '0';
-         if (putc1(t, f) < 0)
+         if (putc(t, f) < 0)
            wpunt();
          t = ((c >> 3) & 7) + '0';
-         if (putc1(t, f) < 0)
+         if (putc(t, f) < 0)
            wpunt();
          t = (c & 7) + '0';
-         if (putc1(t, f) < 0)
+         if (putc(t, f) < 0)
            wpunt();
        }
       else
        {
-         if (putc1(c, f) < 0)
+         if (putc(c, f) < 0)
            wpunt();
        }
     }
 }
 
-int safe_close(FILE *stream)
+void safe_close(FILE *stream)
 {
   if (fflush(stream) == EOF)
     punt("Unable to fflush");
@@ -127,36 +115,3 @@ FILE *open_file(char *prefix, char *suffix)
   fprintf(stderr, "Working on %s\n", name);
   return f;
 }
-
-
-/*
- * Trim whitespace off both ends of a string.
- */
-char *strtrim(char *save)
-{
-  char *t, *s;
-
-  s = save;
-  while (isspace(*s))
-    s++;
-  /* skip to end of string */
-  if (*s == '\0')
-    {
-      *save = '\0';
-      return save;
-    }
-
-  for (t = s; *t; t++)
-    continue;
-  while (t > s)
-    {
-      --t;
-      if (!isspace(*t))
-       {
-         t++;
-         break;
-       }
-    }
-  *t = '\0';
-  return s;
-}
index dd224f02acb5e467b6966507b98516243e2815f6..cd44b316b6587c10e57bf2991c925016745decd0 100644 (file)
@@ -1,28 +1,27 @@
-/*
- *     $Source$
- *     $Author$
- *     $Header$
- *
- *  (c) Copyright 1988 by the Massachusetts Institute of Technology.
- *  For copying and distribution information, please see the file
- *  <mit-copyright.h>.
+/* $Id$
  *
+ * (c) Copyright 1988-1998 by the Massachusetts Institute of Technology.
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
  */
 
-#ifndef lint
-static char *rcsid_dumprest_qc = "$Header$";
-#endif lint
+#include <mit-copyright.h>
+#include <moira.h>
+#include "dump_db.h"
 
 #include <stdio.h>
-#include <mit-copyright.h>
 
-int punt(char *msg)
+RCSID("$Header$");
+
+extern void sqlglm(char *, unsigned int *, unsigned int *);
+
+void punt(char *msg)
 {
   perror(msg);
   exit(1);
 }
 
-int dbmserr(void)
+void dbmserr(void)
 {
   EXEC SQL BEGIN DECLARE SECTION;
   char err_msg[256];
index 43e7bb11f52bb6124e652bf2b7fae64cf4e4ddde..7477be81ac19e6b6cff0ce1a98f918cdb755cb4d 100644 (file)
@@ -1,26 +1,27 @@
-/*
- *     $Source$
- *     $Author$
- *     $Header$
+/* $Id $
  *
- *  (c) Copyright 1988 by the Massachusetts Institute of Technology.
- *  For copying and distribution information, please see the file
- *  <mit-copyright.h>.
+ *     This program restores the Moira database from an mrbackup.
  *
+ * Copyright (C) 1988-1998 by the Massachusetts Institute of Technology.
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
  */
 
-#ifndef lint
-static char *rcsid_rest_db_qc = "$Header$";
-#endif lint
+#include <mit-copyright.h>
+#include <moira.h>
+#include "dump_db.h"
 
-#include <sys/file.h>
-#include <stdio.h>
-#include <fcntl.h>
 #include <ctype.h>
-#include <mit-copyright.h>
+#include <fcntl.h>
+#include <stdio.h>
+#include <string.h>
+#include <unistd.h>
+
 EXEC SQL INCLUDE sqlca;
-#include "dump_db.h"
 
+RCSID("$Header$");
+
+int yes_or_no(char *prompt);
 
 int main(int argc, char **argv)
 {
@@ -203,13 +204,13 @@ void parse_sep(FILE *f)
   if (getc(f) != SEP_CHAR)
     punt("Expected Separator");
 }
+
 void parse_nl(FILE *f)
 {
   if (getc(f) != '\n')
     punt("Expected newline");
 }
 
-
 FILE *open_file(char *prefix, char *suffix)
 {
   char name[BUFSIZ];
index 8d5bbac3fbacce02ff1eee6e2223c8175bd88ce9..e70ee023108effcea0574978b366051199bbef6f 100644 (file)
@@ -1,28 +1,24 @@
-/* $Header$
+/* $Id $
  *
- * Program to add users en batch to the moira database
+ * Program to add users en masse to the moira database
  *
  * by Mark Rosenstein, July 1992.
  *
- * Copyright 1992 by the Massachusetts Institute of Technology.
- *
- * (c) Copyright 1992 by the Massachusetts Institute of Technology.
+ * Copyright (C) 1992-1998 by the Massachusetts Institute of Technology.
  * For copying and distribution information, please see the file
  * <mit-copyright.h>.
  */
 
 #include <mit-copyright.h>
-#include <string.h>
-#include <stdio.h>
-#include <ctype.h>
-#include <des.h>
-#include <krb.h>
 #include <moira.h>
 #include <moira_site.h>
 
-#ifndef LINT
-static char adduser_rcsid[] = "$Header$";
-#endif
+#include <ctype.h>
+#include <errno.h>
+#include <stdio.h>
+#include <string.h>
+
+RCSID("$Header$");
 
 #ifdef ATHENA
 #define DEFAULT_SHELL "/bin/athena/tcsh"
@@ -40,10 +36,15 @@ int reg_only, reg, verbose, nodupcheck;
 char *whoami;
 int duplicate, errors;
 
-extern char *FixCase(), *RemoveHyphens(), *strtrim();
-extern int errno;
-int usercheck(), scream();
+extern int ureg_init(void);
+extern int grab_login(char *first, char *last, char *idnumber,
+                     char *hashidnumber, char *login);
+extern int set_password(char *first, char *last, char *idnumber,
+                       char *hashidnumber, char *password);
+
 
+void usage(char **argv);
+int usercheck(int argc, char **argv, void *qargv);
 
 int main(int argc, char **argv)
 {
@@ -296,7 +297,7 @@ int main(int argc, char **argv)
              dargv[1] = qargv[U_LAST];
              duplicate = 0;
              status = mr_query("get_user_account_by_name", 2, dargv,
-                               usercheck, (char *) qargv);
+                               usercheck, qargv);
              if (status && status != MR_NO_MATCH)
                {
                  com_err(whoami, status,
@@ -323,7 +324,7 @@ int main(int argc, char **argv)
                }
            }
          status = mr_query("add_user_account", U_SECURE + 1, qargv,
-                           scream, NULL);
+                           NULL, NULL);
          if (status)
            {
              com_err(whoami, status, "adding user %s %s", first, last);
@@ -369,7 +370,7 @@ int main(int argc, char **argv)
 }
 
 
-usage(char **argv)
+void usage(char **argv)
 {
   fprintf(stderr, "Usage: %s [options]\n", argv[0]);
   fprintf(stderr, "Options are\n");
@@ -387,21 +388,14 @@ usage(char **argv)
 }
 
 
-/* Called only if a query returns a value that we weren't expecting */
-
-scream(void)
-{
-  fprintf(stderr, "Programmer botch\n");
-  exit(3);
-}
-
-
 /* query callback routine to check for duplicate users */
 
-usercheck(int argc, char **argv, char **qargv)
+int usercheck(int argc, char **argv, void *qargv)
 {
-  if (!strcmp(argv[U_MITID], qargv[U_MITID]))
+  if (!strcmp(argv[U_MITID], ((char **)qargv)[U_MITID]))
     duplicate++;
   else
     duplicate--;
+
+  return MR_CONT;
 }
index be7e60346ef89671886e9cff0bfd6cbc696a2895..eb3ae3ec83d271c5238681a251b767da76ed7c38 100644 (file)
@@ -1,32 +1,25 @@
-/* $Header$
+/* $Id $
  *
  * Command line oriented Moira List tool.
  *
  * by Mark Rosenstein, September 1988.
  *
- * Copyright 1989 by the Massachusetts Institute of Technology.
- *
- * (c) Copyright 1988 by the Massachusetts Institute of Technology.
+ * Copyright (C) 1988-1998 by the Massachusetts Institute of Technology.
  * For copying and distribution information, please see the file
  * <mit-copyright.h>.
  */
 
-/* ### Aren't there a lot of sq abstraction barrier violations here?
-   Do we need to improve the support for queue operations? */
-
 #include <mit-copyright.h>
+#include <moira.h>
+#include <moira_site.h>
+
+#include <ctype.h>
 #include <errno.h>
 #include <stdio.h>
 #include <stdlib.h>
-#include <ctype.h>
 #include <string.h>
-#include <moira.h>
-#include <moira_site.h>
-
-#ifndef LINT
-static char blanche_rcsid[] = "$Header$";
-#endif
 
+RCSID("$Header$");
 
 struct member {
   int type;
@@ -55,9 +48,19 @@ struct save_queue *addlist, *dellist, *memberlist, *synclist;
 
 char *listname, *whoami;
 
-int show_list_info(), show_list_count(), get_list_members(), scream();
-int show_list_members(), membercmp(), save_list_info();
-struct member *parse_member();
+void usage(char **argv);
+void show_list_member(struct member *memberstruct);
+int show_list_info(int argc, char **argv, void *hint);
+int save_list_info(int argc, char **argv, void *hint);
+int show_list_count(int argc, char **argv, void *hint);
+void recursive_display_list_members(void);
+void unique_add_member(struct save_queue *q, struct member *m);
+int get_list_members(int argc, char **argv, void *sq);
+void get_members_from_file(char *filename, struct save_queue *queue);
+int collect(int argc, char **argv, void *l);
+struct member *parse_member(char *s);
+int membercmp(const void *mem1, const void *mem2);
+int sq_count_elts(struct save_queue *q);
 
 int main(int argc, char **argv)
 {
@@ -327,18 +330,18 @@ int main(int argc, char **argv)
            case M_ANY:
            case M_USER:
              argv[7] = "USER";
-             status = mr_query("add_list", 10, argv, scream, NULL);
+             status = mr_query("add_list", 10, argv, NULL, NULL);
              if (owner->type != M_ANY || status != MR_USER)
                break;
 
            case M_LIST:
              argv[7] = "LIST";
-             status = mr_query("add_list", 10, argv, scream, NULL);
+             status = mr_query("add_list", 10, argv, NULL, NULL);
              break;
 
            case M_KERBEROS:
              argv[7] = "KERBEROS";
-             status = mr_query("add_list", 10, argv, scream, NULL);
+             status = mr_query("add_list", 10, argv, NULL, NULL);
              break;
            }
        }
@@ -347,7 +350,7 @@ int main(int argc, char **argv)
          argv[7] = "USER";
          argv[8] = getenv("USER");
 
-         status = mr_query("add_list", 10, argv, scream, NULL);
+         status = mr_query("add_list", 10, argv, NULL, NULL);
        }
 
       if (status)
@@ -361,7 +364,7 @@ int main(int argc, char **argv)
       char *argv[11];
 
       status = mr_query("get_list_info", 1, &listname,
-                       save_list_info, (char *)argv);
+                       save_list_info, argv);
       if (status)
        {
          com_err(whoami, status, "while getting list information");
@@ -392,23 +395,23 @@ int main(int argc, char **argv)
            case M_ANY:
            case M_USER:
              argv[8] = "USER";
-             status = mr_query("update_list", 11, argv, scream, NULL);
+             status = mr_query("update_list", 11, argv, NULL, NULL);
              if (owner->type != M_ANY || status != MR_USER)
                break;
 
            case M_LIST:
              argv[8] = "LIST";
-             status = mr_query("update_list", 11, argv, scream, NULL);
+             status = mr_query("update_list", 11, argv, NULL, NULL);
              break;
 
            case M_KERBEROS:
              argv[8] = "KERBEROS";
-             status = mr_query("update_list", 11, argv, scream, NULL);
+             status = mr_query("update_list", 11, argv, NULL, NULL);
              break;
            }
        }
       else
-       status = mr_query("update_list", 11, argv, scream, NULL);
+       status = mr_query("update_list", 11, argv, NULL, NULL);
 
       if (status)
        com_err(whoami, status, "while updating list.");
@@ -442,7 +445,7 @@ int main(int argc, char **argv)
   if (syncflg)
     {
       status = mr_query("get_members_of_list", 1, &listname,
-                       get_list_members, (char *)memberlist);
+                       get_list_members, memberlist);
       if (status)
        {
          com_err(whoami, status, "getting members of list %s", listname);
@@ -479,10 +482,10 @@ int main(int argc, char **argv)
       if (memberstruct->type == M_STRING &&
          (p = strchr(memberstruct->name, '@')))
        {
-         char *host = canonicalize_hostname(strsave(++p));
+         char *host = canonicalize_hostname(strdup(++p));
          static char **mailhubs = NULL;
          char *argv[4];
-         int i, collect();
+         int i;
 
          if (!mailhubs)
            {
@@ -492,7 +495,7 @@ int main(int argc, char **argv)
              mailhubs = malloc(sizeof(char *));
              mailhubs[0] = NULL;
              status = mr_query("get_alias", 3, argv, collect,
-                               (char *)&mailhubs);
+                               &mailhubs);
              if (status != MR_SUCCESS && status != MR_NO_MATCH)
                {
                  com_err(whoami, status,
@@ -504,7 +507,7 @@ int main(int argc, char **argv)
            {
              if (!strcasecmp(p, host))
                {
-                 host = strsave(memberstruct->name);
+                 host = strdup(memberstruct->name);
                  *(strchr(memberstruct->name, '@')) = 0;
                  memberstruct->type = M_ANY;
                  fprintf(stderr, "Warning: \"STRING:%s\" converted to "
@@ -528,7 +531,7 @@ int main(int argc, char **argv)
        case M_ANY:
        case M_USER:
          membervec[1] = "USER";
-         status = mr_query("add_member_to_list", 3, membervec, scream, NULL);
+         status = mr_query("add_member_to_list", 3, membervec, NULL, NULL);
          if (status == MR_SUCCESS)
            break;
          else if (status != MR_USER || memberstruct->type != M_ANY)
@@ -541,7 +544,7 @@ int main(int argc, char **argv)
        case M_LIST:
          membervec[1] = "LIST";
          status = mr_query("add_member_to_list", 3, membervec,
-                           scream, NULL);
+                           NULL, NULL);
          if (status == MR_SUCCESS)
            {
              if (!strcmp(membervec[0], getenv("USER")))
@@ -581,7 +584,7 @@ int main(int argc, char **argv)
 
          membervec[1] = "STRING";
          status = mr_query("add_member_to_list", 3, membervec,
-                           scream, NULL);
+                           NULL, NULL);
          if (status != MR_SUCCESS)
            {
              com_err(whoami, status, "while adding member %s to %s",
@@ -592,7 +595,7 @@ int main(int argc, char **argv)
        case M_KERBEROS:
          membervec[1] = "KERBEROS";
          status = mr_query("add_member_to_list", 3, membervec,
-                           scream, NULL);
+                           NULL, NULL);
          if (status != MR_SUCCESS)
            {
              com_err(whoami, status, "while adding member %s to %s",
@@ -618,7 +621,7 @@ int main(int argc, char **argv)
        case M_USER:
          membervec[1] = "USER";
          status = mr_query("delete_member_from_list", 3, membervec,
-                           scream, NULL);
+                           NULL, NULL);
          if (status == MR_SUCCESS)
            break;
          else if ((status != MR_USER && status != MR_NO_MATCH) ||
@@ -632,7 +635,7 @@ int main(int argc, char **argv)
        case M_LIST:
          membervec[1] = "LIST";
          status = mr_query("delete_member_from_list", 3, membervec,
-                           scream, NULL);
+                           NULL, NULL);
          if (status == MR_SUCCESS)
            break;
          else if ((status != MR_LIST && status != MR_NO_MATCH) ||
@@ -662,7 +665,7 @@ int main(int argc, char **argv)
        case M_STRING:
          membervec[1] = "STRING";
          status = mr_query("delete_member_from_list", 3, membervec,
-                           scream, NULL);
+                           NULL, NULL);
          if (status == MR_STRING && memberstruct->type == M_ANY)
            {
              com_err(whoami, 0, " Unable to find member %s to delete from %s",
@@ -686,7 +689,7 @@ int main(int argc, char **argv)
        case M_KERBEROS:
          membervec[1] = "KERBEROS";
          status = mr_query("delete_member_from_list", 3, membervec,
-                           scream, NULL);
+                           NULL, NULL);
          if (status != MR_SUCCESS)
            {
              com_err(whoami, status, "while deleting member %s from %s",
@@ -704,7 +707,7 @@ int main(int argc, char **argv)
       else
        {
          status = mr_query("get_members_of_list", 1, &listname,
-                           get_list_members, (char *)memberlist);
+                           get_list_members, memberlist);
          if (status)
            com_err(whoami, status, "while getting members of list %s",
                    listname);
@@ -718,7 +721,7 @@ int main(int argc, char **argv)
   exit(success ? 0 : 1);
 }
 
-usage(char **argv)
+void usage(char **argv)
 {
   fprintf(stderr, "Usage: %s listname [options]\n", argv[0]);
   fprintf(stderr, "Options are\n");
@@ -758,7 +761,7 @@ usage(char **argv)
 
 /* Display the members stored in the queue */
 
-show_list_member(struct member *memberstruct)
+void show_list_member(struct member *memberstruct)
 {
   char *s = "";
 
@@ -808,7 +811,7 @@ show_list_member(struct member *memberstruct)
 
 /* Show the retrieved information about a list */
 
-int show_list_info(int argc, char **argv, int hint)
+int show_list_info(int argc, char **argv, void *hint)
 {
   printf("List: %s\n", argv[0]);
   printf("Description: %s\n", argv[9]);
@@ -831,9 +834,9 @@ int show_list_info(int argc, char **argv, int hint)
 
 /* Copy retrieved information about a list into a new argv */
 
-int save_list_info(int argc, char **argv, int hint)
+int save_list_info(int argc, char **argv, void *hint)
 {
-  char **nargv = (char **)hint;
+  char **nargv = hint;
 
   for (argc = 0; argc < 10; argc++)
     nargv[argc + 1] = strdup(argv[argc]);
@@ -842,15 +845,16 @@ int save_list_info(int argc, char **argv, int hint)
 
 /* Show the retrieve list member count */
 
-show_list_count(int argc, char **argv, int hint)
+int show_list_count(int argc, char **argv, void *hint)
 {
   printf("Members: %s\n", argv[0]);
+  return MR_CONT;
 }
 
 
 /* Recursively find all of the members of listname, and then display them */
 
-recursive_display_list_members(void)
+void recursive_display_list_members(void)
 {
   int status, count, savecount;
   struct save_queue *lists, *members;
@@ -868,7 +872,7 @@ recursive_display_list_members(void)
       sq_destroy(memberlist);
       memberlist = sq_create();
       status = mr_query("get_members_of_list", 1, &(m->name),
-                       get_list_members, (char *)memberlist);
+                       get_list_members, memberlist);
       if (status)
        com_err(whoami, status, "while getting members of list %s", m->name);
       while (sq_get_data(memberlist, &m1))
@@ -892,7 +896,7 @@ recursive_display_list_members(void)
 
 /* add a struct member to a queue if that member isn't already there. */
 
-unique_add_member(struct save_queue *q, struct member *m)
+void unique_add_member(struct save_queue *q, struct member *m)
 {
   struct save_queue *qp;
 
@@ -907,8 +911,9 @@ unique_add_member(struct save_queue *q, struct member *m)
 
 /* Collect the retrieved members of the list */
 
-int get_list_members(int argc, char **argv, struct save_queue *q)
+int get_list_members(int argc, char **argv, void *sq)
 {
+  struct save_queue *q = sq;
   struct member *m;
 
   m = malloc(sizeof(struct member));
@@ -927,23 +932,14 @@ int get_list_members(int argc, char **argv, struct save_queue *q)
       m->type = M_KERBEROS;
       break;
     }
-  m->name = strsave(argv[1]);
+  m->name = strdup(argv[1]);
   sq_save_data(q, m);
   return MR_CONT;
 }
 
 
-/* Called only if a query returns a value that we weren't expecting */
-
-scream(void)
-{
-  fprintf(stderr, "Programmer botch\n");
-  exit(3);
-}
-
-
 /* Open file, parse members from file, and put them on the specified queue */
-get_members_from_file(char *filename, struct save_queue *queue)
+void get_members_from_file(char *filename, struct save_queue *queue)
 {
   FILE *in;
   char buf[BUFSIZ];
@@ -976,14 +972,15 @@ get_members_from_file(char *filename, struct save_queue *queue)
 
 /* Collect the possible expansions of the alias MAILHUB */
 
-int collect(int argc, char **argv, char ***list)
+int collect(int argc, char **argv, void *l)
 {
+  char ***list = l;
   int i;
 
   for (i = 0; (*list)[i]; i++)
     ;
   *list = realloc(*list, (i + 2) * sizeof(char *));
-  (*list)[i] = strsave(argv[2]);
+  (*list)[i] = strdup(argv[2]);
   (*list)[i + 1] = NULL;
   return MR_CONT;
 }
@@ -1034,11 +1031,11 @@ struct member *parse_member(char *s)
          *(--p) = ':';
          m->name = s;
        }
-      m->name = strsave(m->name);
+      m->name = strdup(m->name);
     }
   else
     {
-      m->name = strsave(s);
+      m->name = strdup(s);
       m->type = M_ANY;
     }
   return m;
@@ -1055,8 +1052,10 @@ struct member *parse_member(char *s)
  * > 0 if the second member is less (the first member is greater).
  */
 
-int membercmp(struct member *m1, struct member *m2)
+int membercmp(const void *mem1, const void *mem2)
 {
+  const struct member *m1 = mem1, *m2 = mem2;
+
   if (m1->type == M_ANY || m2->type == M_ANY || (m1->type == m2->type))
     return strcmp(m1->name, m2->name);
   else
index 51d2f98ede3d32bc2d7c4daa237b427e20d745ca..43a4e305690b367d904025b605f5c820a2e1fefc 100644 (file)
@@ -1,33 +1,27 @@
-/*
- *     $Source$
- *     $Header$
+/* $Id $
+ *
+ * Simple add-me-to/remove-me-from list client
+ *
+ *  mailmaint.c - pjlevine - 20 August 1987
+ *
+ * Copyright (C) 1988-1998 by the Massachusetts Institute of Technology.
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
  */
 
-/*  (c) Copyright 1988 by the Massachusetts Institute of Technology. */
-/*  For copying and distribution information, please see the file */
-/*  <mit-copyright.h>. */
-
-#ifndef lint
-static char rcsid_mailmaint_c[] = "$Header$";
-#endif
+#include <mit-copyright.h>
+#include <moira.h>
+#include <moira_site.h>
 
-/***********************************************************************/
-/*  mailmaint.c - pjlevine - 20 August 1987 */
-/***********************************************************************/
-#include <stdio.h>
-#include <pwd.h>
-#include <signal.h>
-#include <string.h>
+#include <ctype.h>
 #include <curses.h>
-#include <sys/types.h>
-#include <stdarg.h>
+#include <pwd.h>
+#include <stdio.h>
 #include <stdlib.h>
-#include <com_err.h>
-#include <ctype.h>
-#include <moira.h>
-#include <moira_site.h>
-#include <mit-copyright.h>
+#include <string.h>
+#include <unistd.h>
 
+RCSID("$Header$");
 
 #define STARTCOL 0
 #define STARTROW 3
@@ -39,8 +33,6 @@ static char rcsid_mailmaint_c[] = "$Header$";
 
 char *whoami;          /* should not be static, for logging package */
 static int status;
-static int scream();
-void menu_err_hook(const char *who, long code, const char *fmt, va_list args);
 
 typedef struct list_info {
   int active;
@@ -57,10 +49,7 @@ typedef struct list_info {
 } List_info;
 
 static char *ascbuff = {"0123456789"};
-static int print_2(), print_1();
 static List_info *current_li = (List_info *) NULL;
-static int get_list_info();
-static int fetch_list_info();
 
 typedef struct _menu {
   int num_items;
@@ -75,6 +64,36 @@ int level, found_some, currow, page, num_members;
 int moreflg, toggle, first_time;
 char *username;
 
+void get_main_input(void);
+void show_list_info(void);
+void display_buff(char *buf);
+void start_display_buff(char *buff);
+void add_member(void);
+void delete_member(void);
+void list_by_member(void);
+void show_all(void);
+static int print_1(int argc, char *argv[], void *callback);
+static int print_all(int argc, char *argv[], void *callback);
+void list_all_groups(void);
+void list_members(void);
+static int print_2(int argc, char *argv[], void *callback);
+void start_display(char *buff);
+void end_display(void);
+void display_menu(MENU *menu);
+void pack_main_menu(void);
+void pack_help_menu(void);
+void highlight(MENU *menu);
+void title(char *buff);
+void center_text(int row, char *buff);
+void show_text(int row, int col, char *buff);
+void erase_line(int row, int col);
+void cls(void);
+void clrwin(int erase_row);
+static int fetch_list_info(char *list, List_info *li);
+static int get_list_info(int argc, char **argv, void *hint);
+int Prompt(char *prompt, char *buf, int buflen, int crok);
+void menu_err_hook(const char *who, long code, const char *fmt, va_list args);
+
 /* This crock is because the original code was very broken and this makes
  * it work.  Someday, we should abandon the code or fix it right.
  */
@@ -107,12 +126,8 @@ int main(int argc, char *argv[])
       current_li->modwith = NULL;
     }
   if (!(username = getlogin()))
-    {
-      struct passwd *getpwuid();
-
-      username = getpwuid(getuid())->pw_name;
-    }
-  username = (username && strlen(username)) ? strsave(username) : "";
+    username = getpwuid(getuid())->pw_name;
+  username = username ? strdup(username) : "";
 
   printf("Connecting to database for %s...please hold on.\n", username);
 
@@ -179,7 +194,7 @@ punt:
 }
 
 /****************************************************/
-int get_main_input(void)
+void get_main_input(void)
 {
   int c;
   int retflg;
@@ -276,7 +291,7 @@ int get_main_input(void)
 }
 
 /****************************************************/
-int show_list_info(void)
+void show_list_info(void)
 {
   char *buf;
 
@@ -315,7 +330,7 @@ int show_list_info(void)
 }
 
 /****************************************************/
-int display_buff(char *buf)
+void display_buff(char *buf)
 {
   int i, cnt;
   char *printbuf;
@@ -342,17 +357,17 @@ int display_buff(char *buf)
       start_display_buff(printbuf);
       free(printbuf);
     }
-  return 0;
+  return;
 }
 
 /****************************************************/
-int start_display_buff(char *buff)
+void start_display_buff(char *buff)
 {
   char buffer[5];
 
   num_members++;
   if (moreflg)
-    return 0;
+    return;
   if (currow >= LINES - 2)
     {
       page++;
@@ -364,7 +379,7 @@ int start_display_buff(char *buff)
          erase_line(currow, STARTCOL);
          show_text(currow, STARTCOL, "Flushing query...");
          moreflg = 1;
-         return 0;
+         return;
        }
       clrwin(DISPROW + 2);
       currow = DISPROW + 2;
@@ -373,11 +388,11 @@ int start_display_buff(char *buff)
     }
   show_text(currow, STARTCOL, buff);
   currow++;
-  return 0;
+  return;
 }
 
 /****************************************************/
-int add_member(void)
+void add_member(void)
 {
   char *argv[3];
   char *buf;
@@ -387,10 +402,10 @@ int add_member(void)
   if (Prompt("Enter List Name: ", buf, LISTSIZE, 1) == 1)
     {
       display_buff("\n");
-      argv[0] = strsave(buf);
-      argv[1] = strsave("user");
-      argv[2] = strsave(username);
-      if ((status = mr_query("add_member_to_list", 3, argv, scream, NULL)))
+      argv[0] = strdup(buf);
+      argv[1] = strdup("user");
+      argv[2] = strdup(username);
+      if ((status = mr_query("add_member_to_list", 3, argv, NULL, NULL)))
        {
          display_buff("\n");
          com_err(whoami, status, " found.\n");
@@ -408,7 +423,7 @@ int add_member(void)
 }
 
 /****************************************************/
-int delete_member(void)
+void delete_member(void)
 {
   char *argv[3];
   char *buf;
@@ -418,10 +433,10 @@ int delete_member(void)
   if (Prompt("Enter List Name: ", buf, LISTSIZE, 1) == 1)
     {
       display_buff("\n");
-      argv[0] = strsave(buf);
-      argv[1] = strsave("user");
-      argv[2] = strsave(username);
-      if ((status = mr_query("delete_member_from_list", 3, argv, scream, NULL)))
+      argv[0] = strdup(buf);
+      argv[1] = strdup("user");
+      argv[2] = strdup(username);
+      if ((status = mr_query("delete_member_from_list", 3, argv, NULL, NULL)))
        {
          display_buff("\n");
          com_err(whoami, status, " found.\n");
@@ -439,13 +454,13 @@ int delete_member(void)
 }
 
 /****************************************************/
-int list_by_member(void)
+void list_by_member(void)
 {
   char *nargv[3];
   char *buf;
 
-  nargv[1] = strsave("ruser");
-  nargv[2] = strsave(username);
+  nargv[1] = strdup("ruser");
+  nargv[2] = strdup(username);
   buf = calloc(BUFSIZ, 1);
   sprintf(buf, "%s is on the following lists:\n", username);
   show_text(DISPROW, STARTCOL, buf);
@@ -460,11 +475,10 @@ int list_by_member(void)
   show_text(currow, STARTCOL, "Press any Key to continue...");
   getchar();
   clrwin(DISPROW);
-  return;
 }
 
 /****************************************************/
-int show_all(void)
+void show_all(void)
 {
   char c;
 
@@ -479,11 +493,10 @@ int show_all(void)
     }
   else
     erase_line(DISPROW, STARTCOL);
-  return;
 }
 
 /****************************************************/
-static int print_1(int argc, char *argv[], char *callback)
+static int print_1(int argc, char *argv[], void *callback)
 {
   char buf[BUFSIZ];
 
@@ -491,11 +504,11 @@ static int print_1(int argc, char *argv[], char *callback)
   sprintf(buf, "%s\n", argv[0]);
   start_display(buf);
 
-  return 0;
+  return MR_CONT;
 }
 
 /****************************************************/
-static int print_all(int argc, char *argv[], char *callback)
+static int print_all(int argc, char *argv[], void *callback)
 {
   char buf[BUFSIZ];
 
@@ -510,11 +523,11 @@ static int print_all(int argc, char *argv[], char *callback)
   sprintf(buf, "%s\n", argv[0]);
   start_display(buf);
 
-  return 0;
+  return MR_CONT;
 }
 
 /****************************************************/
-int list_all_groups(void)
+void list_all_groups(void)
 {
   char *argv[5];
   argv[0] = argv[1] = argv[3] = "true";
@@ -527,12 +540,10 @@ int list_all_groups(void)
       com_err(whoami, status, " in list_all_groups\n");
     }
   end_display();
-
-  return 0;
 }
 
 /****************************************************/
-int list_members(void)
+void list_members(void)
 {
   char *argv[1];
   char *buf;
@@ -564,14 +575,13 @@ int list_members(void)
          return;
        }
       end_display();
-      return 0;
+      return;
     }
   clrwin(DISPROW);
-  return 0;
 }
 
 /****************************************************/
-static int print_2(int argc, char *argv[], char *callback)
+static int print_2(int argc, char *argv[], void *callback)
 {
   char buf[BUFSIZ];
 
@@ -579,11 +589,11 @@ static int print_2(int argc, char *argv[], char *callback)
   sprintf(buf, "%s %s", argv[0], argv[1]);
   start_display(buf);
 
-  return 0;
+  return MR_CONT;
 }
 
 /****************************************************/
-int start_display(char *buff)
+void start_display(char *buff)
 {
   char *buffer;
   int secondcol;   /* where to start the second column of text */
@@ -591,7 +601,7 @@ int start_display(char *buff)
   secondcol = (COLS / 2);  /* 1/2 was accross the screen */
   num_members++;
   if (moreflg)
-    return 0;
+    return;
   buffer = calloc(50, 1);
   if (currow >= LINES - 2)
     {
@@ -603,7 +613,7 @@ int start_display(char *buff)
          erase_line(currow, STARTCOL);
          show_text(currow, STARTCOL, "Flushing query...");
          moreflg = 1;
-         return 0;
+         return;
        }
       clrwin(DISPROW + 2);
       currow = DISPROW + 2;
@@ -621,11 +631,10 @@ int start_display(char *buff)
       currow++;
     }
   toggle = !toggle;
-  return 0;
 }
 
 /****************************************************/
-int end_display(void)
+void end_display(void)
 {
   char *buffer;
 
@@ -646,7 +655,7 @@ int end_display(void)
 }
 
 /****************************************************/
-int display_menu(MENU *menu)
+void display_menu(MENU *menu)
 {
   int i;
 
@@ -680,7 +689,7 @@ int display_menu(MENU *menu)
 }
 
 /****************************************************/
-int pack_main_menu(void)
+void pack_main_menu(void)
 {
   char *buf;
 
@@ -690,33 +699,33 @@ int pack_main_menu(void)
 
   buf = calloc(50, 1);
   sprintf(buf, "Mail List Program for %s", username);
-  main_menu->title = strsave(buf);
-  main_menu->items[0] = strsave("1.  Show all public mailing lists.");
-  main_menu->items[1] = strsave("2.  Get all members of a mailing list.");
-  main_menu->items[2] = strsave("3.  Display lists of which you are a member.");
-  main_menu->items[3] = strsave("4.  Show description of list.");
-  main_menu->items[4] = strsave("5.  Add yourself to a mailing list.");
-  main_menu->items[5] = strsave("6.  Delete yourself from a mailing list.");
-  main_menu->items[6] = strsave("q.  Quit.");
+  main_menu->title = strdup(buf);
+  main_menu->items[0] = strdup("1.  Show all public mailing lists.");
+  main_menu->items[1] = strdup("2.  Get all members of a mailing list.");
+  main_menu->items[2] = strdup("3.  Display lists of which you are a member.");
+  main_menu->items[3] = strdup("4.  Show description of list.");
+  main_menu->items[4] = strdup("5.  Add yourself to a mailing list.");
+  main_menu->items[5] = strdup("6.  Delete yourself from a mailing list.");
+  main_menu->items[6] = strdup("q.  Quit.");
 }
 
 /****************************************************/
-int pack_help_menu(void)
+void pack_help_menu(void)
 {
   help_menu = malloc(sizeof(MENU));
   help_menu->num_items = 5;
   help_menu->items = malloc(sizeof(char *) * help_menu->num_items);
 
-  help_menu->title = strsave("mailmaint is designed as a basic mail list administration program.");
-  help_menu->items[0] = strsave("if you need to perform more advanced list manipulation like");
-  help_menu->items[1] = strsave("adding lists, or changing list characteristics, refer to the");
-  help_menu->items[2] = strsave("program listmaint.");
-  help_menu->items[3] = strsave(" ");
-  help_menu->items[4] = strsave("Press any key to continue.");
+  help_menu->title = strdup("mailmaint is designed as a basic mail list administration program.");
+  help_menu->items[0] = strdup("if you need to perform more advanced list manipulation like");
+  help_menu->items[1] = strdup("adding lists, or changing list characteristics, refer to the");
+  help_menu->items[2] = strdup("program listmaint.");
+  help_menu->items[3] = strdup(" ");
+  help_menu->items[4] = strdup("Press any key to continue.");
 }
 
 /****************************************************/
-int highlight(MENU *menu)
+void highlight(MENU *menu)
 {
   if (oldpos[level] != position[level])
     {
@@ -735,7 +744,7 @@ int highlight(MENU *menu)
 }
 
 /****************************************************/
-int title(char *buff)
+void title(char *buff)
 {
   move(0, MAX(0, (COLS - strlen(buff)) >> 1));
   standout();
@@ -745,7 +754,7 @@ int title(char *buff)
 }
 
 /****************************************************/
-int center_text(int row, char *buff)
+void center_text(int row, char *buff)
 {
   move(row, MAX(0, (COLS - strlen(buff)) >> 1));
   addstr(buff);
@@ -753,7 +762,7 @@ int center_text(int row, char *buff)
 }
 
 /****************************************************/
-int show_text(int row, int col, char *buff)
+void show_text(int row, int col, char *buff)
 {
   mvcur(0, 0, row, col);
   addstr(buff);
@@ -761,7 +770,7 @@ int show_text(int row, int col, char *buff)
 }
 
 /****************************************************/
-int erase_line(int row, int col)
+void erase_line(int row, int col)
 {
   char *buff;
   int i;
@@ -778,14 +787,14 @@ int erase_line(int row, int col)
 }
 
 /****************************************************/
-int cls(void)
+void cls(void)
 {
   clear();
   refresh();
 }
 
 /****************************************************/
-int clrwin(int erase_row)
+void clrwin(int erase_row)
 {
   int i;
   char *buff;
@@ -807,16 +816,6 @@ int clrwin(int erase_row)
   free(buff);
 }
 
-/****************************************************/
-static int scream(void)
-{
-  com_err(whoami, status,
-         "\nA Moira update returned a value -- programmer botch\n");
-  mr_disconnect();
-  exit(1);
-  return 0;    /* to keep compiler happy */
-}
-
 /****************************************************/
 static int fetch_list_info(char *list, List_info *li)
 {
@@ -826,27 +825,27 @@ static int fetch_list_info(char *list, List_info *li)
   return mr_query("get_list_info", 1, argv, get_list_info, NULL);
 }
 
-static int get_list_info(int argc, char **argv)
+static int get_list_info(int argc, char **argv, void *hint)
 {
   if (current_li->acl_type)
     free(current_li->acl_type);
-  current_li->acl_type = strsave(argv[7]);
+  current_li->acl_type = strdup(argv[7]);
   if (current_li->acl_name)
     free(current_li->acl_name);
-  current_li->acl_name = strsave(argv[8]);
+  current_li->acl_name = strdup(argv[8]);
   if (current_li->desc)
     free(current_li->desc);
-  current_li->desc = strsave(argv[9]);
+  current_li->desc = strdup(argv[9]);
   if (current_li->modtime)
     free(current_li->modtime);
-  current_li->modtime = strsave(argv[10]);
+  current_li->modtime = strdup(argv[10]);
   if (current_li->modby)
     free(current_li->modby);
-  current_li->modby = strsave(argv[11]);
+  current_li->modby = strdup(argv[11]);
   if (current_li->modwith)
     free(current_li->modwith);
-  current_li->modwith = strsave(argv[12]);
-  return 0;
+  current_li->modwith = strdup(argv[12]);
+  return MR_CONT;
 }
 
 
index 12b1d2ef94161004d0382d1bfa5e063dd7c877ea..1ffa5f5a3b4f2ebc1028e1e4cbee914b9d799778 100644 (file)
@@ -20,7 +20,7 @@ MOBJS=        attach.o cluster.o delete.o globals.o lists.o main.o menu.o \
 NOBJS= namespace.o globals.o lists.o menu.o \
        pobox.o user.o utils.o misc.o
 OBJS=  ${MOBJS} ${NOBJS}
-INCLUDE= -I$(BUILDTOP)/include -I$(BUILDTOP)/lib ${GDSSINC} -I/usr/athena/include -I.
+INCLUDE= -I$(BUILDTOP)/include -I$(BUILDTOP)/lib ${GDSSINC} ${COM_ERR_INC} -I/usr/athena/include -I.
 
 program(moira, ${MOBJS},${MR_LIBDEP} ${GDB_LIBDEP}, ${LIBGDSS} ${CLIBS} ${CRYPT} ${CURSES},${PROGDIR})
 program(namespace, ${NOBJS},${MR_LIBDEP} ${GDB_LIBDEP}, ${LIBGDSS} ${CLIBS} ${CRYPT} ${CURSES},${PROGDIR})
index 5b9b10c25170435353725f837f3a0679f2f2de8c..12d1ba68710ffe93dd6fe437498b0d652827e83c 100644 (file)
@@ -1,8 +1,6 @@
-#if (!defined(lint) && !defined(SABER))
-  static char rcsid_module_c[] = "$Header$";
-#endif
-
-/*     This is the file attach.c for the Moira Client, which allows users
+/* $Id $
+ *
+ *     This is the file attach.c for the Moira Client, which allows users
  *      to quickly and easily maintain most parts of the Moira database.
  *     It Contains: Functions for maintaining data used by Hesiod
  *                   to map courses/projects/users to their file systems,
  *     Created:        5/4/88
  *     By:             Chris D. Peterson
  *
- *      $Source$
- *      $Author$
- *      $Header$
- *     
- *     Copyright 1988 by the Massachusetts Institute of Technology.
- *
- *     For further information on copyright and distribution
- *     see the file mit-copyright.h
+ * Copyright (C) 1988-1998 by the Massachusetts Institute of Technology.
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
  */
 
-#include <stdio.h>
-#include <string.h>
+#include <mit-copyright.h>
 #include <moira.h>
 #include <moira_site.h>
-#include <menu.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <ctype.h>
 
-#include "mit-copyright.h"
 #include "defs.h"
 #include "f_defs.h"
 #include "globals.h"
 
+#include <sys/stat.h>
+
+#include <ctype.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+RCSID("$Header$");
+
+char *canonicalize_cell(char *c);
+int GetAliasValue(int argc, char **argv, void *retval);
+void RealDeleteFS(char **info, Bool one_item);
+char *SortAfter(struct qelem *elem, int count);
+void RealDeleteFSAlias(char **info, Bool one_item);
+
 #define FS_ALIAS_TYPE "FILESYS"
 
 #define LABEL        0
@@ -65,18 +68,18 @@ static char **SetDefaults(char **info, char *name)
 {
   char buf[BUFSIZ];
 
-  info[FS_NAME] =     Strsave(name);
-  info[FS_TYPE] =     Strsave(DEFAULT_TYPE);
-  info[FS_MACHINE] =  Strsave(DEFAULT_MACHINE);
-  info[FS_PACK] =     Strsave(DEFAULT_PACK);
+  info[FS_NAME] =     strdup(name);
+  info[FS_TYPE] =     strdup(DEFAULT_TYPE);
+  info[FS_MACHINE] =  strdup(DEFAULT_MACHINE);
+  info[FS_PACK] =     strdup(DEFAULT_PACK);
   sprintf(buf, "/mit/%s", name);
-  info[FS_M_POINT] =  Strsave(buf);
-  info[FS_ACCESS] =   Strsave(DEFAULT_ACCESS);
-  info[FS_COMMENTS] = Strsave(DEFAULT_COMMENTS);
-  info[FS_OWNER] =    Strsave(DEFAULT_OWNER);
-  info[FS_OWNERS] =   Strsave(DEFAULT_OWNERS);
-  info[FS_CREATE] =   Strsave(DEFAULT_CREATE);
-  info[FS_L_TYPE] =   Strsave(DEFAULT_L_TYPE);
+  info[FS_M_POINT] =  strdup(buf);
+  info[FS_ACCESS] =   strdup(DEFAULT_ACCESS);
+  info[FS_COMMENTS] = strdup(DEFAULT_COMMENTS);
+  info[FS_OWNER] =    strdup(DEFAULT_OWNER);
+  info[FS_OWNERS] =   strdup(DEFAULT_OWNERS);
+  info[FS_CREATE] =   strdup(DEFAULT_CREATE);
+  info[FS_L_TYPE] =   strdup(DEFAULT_L_TYPE);
   info[FS_MODTIME] = info[FS_MODBY] = info[FS_MODWITH] = info[FS_END] = NULL;
   return info;
 }
@@ -98,7 +101,7 @@ static struct qelem *GetFSInfo(int type, char *name)
     {
     case LABEL:
       if ((stat = do_mr_query("get_filesys_by_label", 1, &name,
-                             StoreInfo, (char *)&elem)))
+                             StoreInfo, &elem)))
        {
          com_err(program_name, stat, " in GetFSInfo");
          return NULL;
@@ -106,7 +109,7 @@ static struct qelem *GetFSInfo(int type, char *name)
       break;
     case MACHINE:
       if ((stat = do_mr_query("get_filesys_by_machine", 1, &name,
-                             StoreInfo, (char *)&elem)))
+                             StoreInfo, &elem)))
        {
          com_err(program_name, stat, " in GetFSInfo");
          return NULL;
@@ -114,7 +117,7 @@ static struct qelem *GetFSInfo(int type, char *name)
       break;
     case GROUP:
       if ((stat = do_mr_query("get_filesys_by_group", 1, &name,
-                             StoreInfo, (char *)&elem)))
+                             StoreInfo, &elem)))
        {
          com_err(program_name, stat, " in GetFSInfo");
          return NULL;
@@ -124,8 +127,7 @@ static struct qelem *GetFSInfo(int type, char *name)
       args[ALIAS_NAME] = name;
       args[ALIAS_TYPE] = FS_ALIAS_TYPE;
       args[ALIAS_TRANS] = "*";
-      if ((stat = do_mr_query("get_alias", 3, args, StoreInfo,
-                             (char *) &elem)))
+      if ((stat = do_mr_query("get_alias", 3, args, StoreInfo, &elem)))
        {
          com_err(program_name, stat, " in get_alias.");
          return NULL;
@@ -153,14 +155,13 @@ static char *PrintFSAlias(char **info)
 
 static int fsgCount = 1;
 
-static char *PrintFSGMembers(char **info)
+static void PrintFSGMembers(char **info)
 {
   char print_buf[BUFSIZ];
 
   sprintf(print_buf, "  %d. Filesystem: %-32s (sort key: %s)",
          fsgCount++, info[0], info[1]);
   Put_message(print_buf);
-  return info[0];
 }
 
 
@@ -194,7 +195,7 @@ static char *PrintFSInfo(char **info)
       Put_message(print_buf);
       Put_message("Containing the filesystems (in order):");
       if ((stat = do_mr_query("get_fsgroup_members", 1, &info[FS_NAME],
-                             StoreInfo, (char *)&elem)))
+                             StoreInfo, &elem)))
        {
          if (stat == MR_NO_MATCH)
            Put_message("    [no members]");
@@ -248,13 +249,13 @@ char *canonicalize_cell(char *c)
     return c;
   path[count] = 0;
   free(c);
-  return strsave(path);
+  return strdup(path);
 }
 
 
-int GetAliasValue(int argc, char **argv, char **retval)
+int GetAliasValue(int argc, char **argv, void *retval)
 {
-  *retval = strsave(argv[2]);
+  *(char **)retval = strdup(argv[2]);
   return MR_CONT;
 }
 
@@ -279,7 +280,7 @@ static char **AskFSInfo(char **info, Bool name)
 
   if (name)
     {
-      newname = Strsave(info[FS_NAME]);
+      newname = strdup(info[FS_NAME]);
       if (GetValueFromUser("The new name for this filesystem",
                           &newname) == SUB_ERROR)
        return NULL;
@@ -297,7 +298,7 @@ static char **AskFSInfo(char **info, Bool name)
   if (fsgroup)
     {
       free(info[FS_MACHINE]);
-      info[FS_MACHINE] = Strsave(NO_MACHINE);
+      info[FS_MACHINE] = strdup(NO_MACHINE);
     }
   else
     {
@@ -306,7 +307,7 @@ static char **AskFSInfo(char **info, Bool name)
          if (!name || newdefaults)
            {
              free(info[FS_MACHINE]);
-             info[FS_MACHINE] = strsave(DEFAULT_CELL);
+             info[FS_MACHINE] = strdup(DEFAULT_CELL);
            }
          if (GetValueFromUser("Filesystem's Cell", &info[FS_MACHINE]) ==
                SUB_ERROR)
@@ -397,7 +398,7 @@ static char **AskFSInfo(char **info, Bool name)
                  sprintf(temp_buf, "/afs/%s/%s/%s", info[FS_MACHINE],
                          lowercase(info[FS_L_TYPE]), info[FS_NAME]);
                }
-             info[FS_PACK] = strsave(temp_buf);
+             info[FS_PACK] = strdup(temp_buf);
            }
        }
       if (GetValueFromUser("Filesystem's Pack Name", &info[FS_PACK]) ==
@@ -455,7 +456,7 @@ int GetFS(int argc, char **argv)
   struct qelem *top;
 
   top = GetFSInfo(LABEL, argv[1]); /* get info. */
-  Loop(top, PrintFSInfo);
+  Loop(top, (void (*)(char **))PrintFSInfo);
   FreeQueue(top);              /* clean the queue. */
   return DM_NORMAL;
 }
@@ -470,9 +471,9 @@ int GetFSM(int argc, char **argv)
 {
   struct qelem *top;
 
-  argv[1] = canonicalize_hostname(strsave(argv[1]));
+  argv[1] = canonicalize_hostname(strdup(argv[1]));
   top = GetFSInfo(MACHINE, argv[1]); /* get info. */
-  Loop(top, PrintFSInfo);
+  Loop(top, (void (*)(char **))PrintFSInfo);
   FreeQueue(top);              /* clean the queue. */
   return DM_NORMAL;
 }
@@ -499,7 +500,7 @@ void RealDeleteFS(char **info, Bool one_item)
   if (!one_item || Confirm(temp_buf))
     {
       if ((stat = do_mr_query("delete_filesys", 1,
-                             &info[FS_NAME], Scream, NULL)))
+                             &info[FS_NAME], NULL, NULL)))
        com_err(program_name, stat, " filesystem not deleted.");
       else
        Put_message("Filesystem deleted.");
@@ -542,7 +543,7 @@ static void RealChangeFS(char **info, Bool junk)
       Put_message("Aborted.");
       return;
     }
-  stat = do_mr_query("update_filesys", CountArgs(args), args, NullFunc, NULL);
+  stat = do_mr_query("update_filesys", CountArgs(args), args, NULL, NULL);
   switch (stat)
     {
     case MR_NFS:
@@ -553,7 +554,7 @@ static void RealChangeFS(char **info, Bool junk)
          if (YesNoQuestion("Retry filesystem update now (Y/N)", TRUE) == TRUE)
            {
              if ((stat = do_mr_query("update_filesys", CountArgs(args), args,
-                                     NullFunc, NULL)))
+                                     NULL, NULL)))
                com_err(program_name, stat, " filesystem not updated");
              else
                Put_message("filesystem sucessfully updated.");
@@ -598,7 +599,7 @@ int AddFS(int argc, char **argv)
     return DM_NORMAL;
 
   if (!(stat = do_mr_query("get_filesys_by_label", 1, argv + 1,
-                             NullFunc, NULL)))
+                             NULL, NULL)))
     {
       Put_message ("A Filesystem by that name already exists.");
       return DM_NORMAL;
@@ -615,7 +616,7 @@ int AddFS(int argc, char **argv)
       return DM_NORMAL;
     }
 
-  stat = do_mr_query("add_filesys", CountArgs(args), args, NullFunc, NULL);
+  stat = do_mr_query("add_filesys", CountArgs(args), args, NULL, NULL);
   switch (stat)
     {
     case MR_NFS:
@@ -626,7 +627,7 @@ int AddFS(int argc, char **argv)
          if (YesNoQuestion("Retry filesystem creation now (Y/N)", TRUE)
              == TRUE) {
            if ((stat = do_mr_query("add_filesys", CountArgs(args), args,
-                                   NullFunc, NULL)))
+                                   NULL, NULL)))
              com_err(program_name, stat, " in AddFS");
            else
              Put_message("Created.");
@@ -649,13 +650,13 @@ int AddFS(int argc, char **argv)
       if (!def_quota)
        {
          stat = do_mr_query("get_value", CountArgs(val), val,
-                            StoreInfo, (char *) &top);
+                            StoreInfo, &top);
          if (stat != MR_SUCCESS)
            com_err(program_name, stat, " getting default quota");
          else
            {
              top = QueueTop(top);
-             def_quota = Strsave(((char **)top->q_data)[0]);
+             def_quota = strdup(((char **)top->q_data)[0]);
              FreeQueue(top);
            }
        }
@@ -671,7 +672,7 @@ int AddFS(int argc, char **argv)
              else
                argv[Q_TYPE] = "ANY";
              argv[Q_QUOTA] = def_quota;
-             if ((stat = do_mr_query("add_quota", Q_QUOTA + 1, argv, Scream,
+             if ((stat = do_mr_query("add_quota", Q_QUOTA + 1, argv, NULL,
                                      NULL)))
                com_err(program_name, stat, " while adding quota");
            }
@@ -683,7 +684,7 @@ int AddFS(int argc, char **argv)
        {
          parsed_argc = 1;
          parsed_argv[0] = info[FS_NAME];
-         AddQuota();
+         AddQuota(parsed_argc, parsed_argv);
        }
     }
 
@@ -738,7 +739,7 @@ char *SortAfter(struct qelem *elem, int count)
       *key++ = (prevnext + 'Z') / 2;
     }
   *key = 0;
-  return Strsave(keybuf);
+  return strdup(keybuf);
 }
 
 /*     Function Name: AddFSToGroup
@@ -754,7 +755,7 @@ int AddFSToGroup(int argc, char **argv)
   char buf[BUFSIZ], *args[5], *bufp;
 
   if ((stat = do_mr_query("get_fsgroup_members", 1, argv + 1, StoreInfo,
-                         (char *)&elem)))
+                         &elem)))
     {
       if (stat != MR_NO_MATCH)
        com_err(program_name, stat, " in AddFSToGroup");
@@ -764,7 +765,7 @@ int AddFSToGroup(int argc, char **argv)
       args[0] = argv[1];
       args[1] = argv[2];
       args[2] = "M";
-      stat = do_mr_query("add_filesys_to_fsgroup", 3, args, Scream, NULL);
+      stat = do_mr_query("add_filesys_to_fsgroup", 3, args, NULL, NULL);
       if (stat)
        com_err(program_name, stat, " in AddFSToGroup");
       return DM_NORMAL;
@@ -773,7 +774,7 @@ int AddFSToGroup(int argc, char **argv)
   fsgCount = 1;
   Loop(elem, PrintFSGMembers);
   sprintf(buf, "%d", QueueCount(elem));
-  bufp = Strsave(buf);
+  bufp = strdup(buf);
   if (GetValueFromUser("Enter number of filesystem it should follow "
                       "(0 to make it first):", &bufp) == SUB_ERROR)
     return DM_NORMAL;
@@ -784,7 +785,7 @@ int AddFSToGroup(int argc, char **argv)
   FreeQueue(QueueTop(elem));
   args[0] = argv[1];
   args[1] = argv[2];
-  stat = do_mr_query("add_filesys_to_fsgroup", 3, args, Scream, NULL);
+  stat = do_mr_query("add_filesys_to_fsgroup", 3, args, NULL, NULL);
   if (stat == MR_EXISTS)
     {
       Put_message("That filesystem is already a member of the group.");
@@ -812,7 +813,7 @@ int RemoveFSFromGroup(int argc, char **argv)
   if (!Confirm(buf))
     return DM_NORMAL;
   if ((stat = do_mr_query("remove_filesys_from_fsgroup", 2, argv + 1,
-                         Scream, NULL)))
+                         NULL, NULL)))
     com_err(program_name, stat, ", not removed.");
   return DM_NORMAL;
 }
@@ -830,7 +831,7 @@ int ChangeFSGroupOrder(int argc, char **argv)
   char buf[BUFSIZ], *bufp, *args[3];
 
   if ((stat = do_mr_query("get_fsgroup_members", 1, argv + 1, StoreInfo,
-                         (char *)&elem)))
+                         &elem)))
     {
       if (stat == MR_NO_MATCH)
        {
@@ -848,7 +849,7 @@ int ChangeFSGroupOrder(int argc, char **argv)
   Loop(top, PrintFSGMembers);
   while (1)
     {
-      bufp = Strsave("1");
+      bufp = strdup("1");
       if (GetValueFromUser("Enter number of the filesystem to move:",
                           &bufp) == SUB_ERROR)
        return DM_NORMAL;
@@ -875,7 +876,7 @@ int ChangeFSGroupOrder(int argc, char **argv)
     }
   while (1)
     {
-      bufp = Strsave("0");
+      bufp = strdup("0");
       if (GetValueFromUser("Enter number of filesystem it should follow "
                           "(0 to make it first):", &bufp) == SUB_ERROR)
        return DM_NORMAL;
@@ -905,13 +906,13 @@ int ChangeFSGroupOrder(int argc, char **argv)
   args[0] = argv[1];
   args[1] = ((char **)elem->q_data)[0];
   if ((stat = do_mr_query("remove_filesys_from_fsgroup", 2, args,
-                         Scream, NULL)))
+                         NULL, NULL)))
     {
       com_err(program_name, stat, " in ChangeFSGroupOrder");
       return DM_NORMAL;
     }
   if ((stat = do_mr_query("add_filesys_to_fsgroup", 3, args,
-                            Scream, NULL)))
+                            NULL, NULL)))
     com_err(program_name, stat, " in ChangeFSGroupOrder");
   return DM_NORMAL;
 }
@@ -957,22 +958,21 @@ int CreateFSAlias(int argc, char **argv)
   if (!ValidName(argv[1]))
     return DM_NORMAL;
 
-  args[ALIAS_NAME] = Strsave(argv[1]);
-  args[ALIAS_TYPE] = Strsave(FS_ALIAS_TYPE);
-  args[ALIAS_TRANS] = Strsave("*");
+  args[ALIAS_NAME] = strdup(argv[1]);
+  args[ALIAS_TYPE] = strdup(FS_ALIAS_TYPE);
+  args[ALIAS_TRANS] = strdup("*");
 
   /*
    * Check to see if this alias already exists in the database, if so then
    * print out values, free memory used and then exit.
    */
 
-  if (!(stat = do_mr_query("get_alias", 3, args, StoreInfo,
-                          (char *)&elem)))
+  if (!(stat = do_mr_query("get_alias", 3, args, StoreInfo, &elem)))
     {
       top = elem = QueueTop(elem);
       while (elem)
        {
-         info = (char **) elem->q_data;
+         info = elem->q_data;
          sprintf(buf, "The alias: %s currently describes the filesystem %s",
                  info[ALIAS_NAME], info[ALIAS_TRANS]);
          Put_message(buf);
@@ -987,13 +987,13 @@ int CreateFSAlias(int argc, char **argv)
       return DM_NORMAL;
     }
 
-  args[ALIAS_TRANS] = Strsave("");
+  args[ALIAS_TRANS] = strdup("");
   args[ALIAS_END] = NULL;
   if (GetValueFromUser("Which filesystem will this alias point to?",
                       &args[ALIAS_TRANS]) == SUB_ERROR)
     return DM_NORMAL;
 
-  if ((stat = do_mr_query("add_alias", 3, args, NullFunc, NULL)))
+  if ((stat = do_mr_query("add_alias", 3, args, NULL, NULL)))
     com_err(program_name, stat, " in CreateFSAlias.");
 
   FreeInfo(args);
@@ -1023,7 +1023,7 @@ void RealDeleteFSAlias(char **info, Bool one_item)
   if (!one_item || Confirm(temp_buf))
     {
       if ((stat = do_mr_query("delete_alias", CountArgs(info),
-                             info, Scream, NULL)))
+                             info, NULL, NULL)))
        com_err(program_name, stat, " filesystem alias not deleted.");
       else
        Put_message("Filesystem alias deleted.");
@@ -1080,7 +1080,7 @@ int AttachHelp(void)
  *     Returns: DM_NORMAL.
  */
 
-int FSGroupHelp(void)
+int FSGroupHelp(int argc, char **argv)
 {
   static char *message[] = {
     "A filesystem group is a named sorted list of filesystems.",
index 5ad2b03808a5d47609f6eda0733479276934b23a..5138fcd67322f3b7ef03e3fb5754165a18d0abd4 100644 (file)
@@ -1,43 +1,44 @@
-#if (!defined(lint) && !defined(SABER))
-  static char rcsid_module_c[] = "$Header$";
-#endif
-
-/*     This is the file cluster.c for the Moira Client, which allows users
+/* $Id $
+ *
+ *     This is the file cluster.c for the Moira Client, which allows users
  *      to quickly and easily maintain most parts of the Moira database.
  *     It Contains:
  *
  *     Created:        4/22/88
  *     By:             Chris D. Peterson
  *
- *      $Source$
- *      $Author$
- *      $Header$
- *
- *     Copyright 1988 by the Massachusetts Institute of Technology.
- *
- *     For further information on copyright and distribution
- *     see the file mit-copyright.h
+ * Copyright (C) 1988-1998 by the Massachusetts Institute of Technology.
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
  */
 
 /* BTW: for anyone who cares MCD is short for Machine, Cluster, Data. */
 
-#include <stdio.h>
-#include <string.h>
+#include <mit-copyright.h>
 #include <moira.h>
 #include <moira_site.h>
-#include <menu.h>
-#include <sys/types.h>
-#include <sys/socket.h>
+
+#include "defs.h"
+#include "f_defs.h"
+#include "globals.h"
+
+#include <sys/utsname.h>
+
 #include <netinet/in.h>
 #include <arpa/inet.h>
-#include <sys/utsname.h>
 #include <netdb.h>
+
 #include <ctype.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
 
-#include "mit-copyright.h"
-#include "defs.h"
-#include "f_defs.h"
-#include "globals.h"
+void PrintAliases(char **info);
+struct qelem *GetMCInfo(int type, char *name1, char *name2);
+char **AskMCDInfo(char **info, int type, Bool name);
+int CheckAndRemoveFromCluster(char *name, Bool ask_user);
+int CheckAndRemoveMachines(char *name, Bool ask_first);
+char *partial_canonicalize_hostname(char *s);
 
 #define MACHINE  0
 #define CLUSTER  1
@@ -89,20 +90,20 @@ static char *MacState(int state)
 
 static char **SetMachineDefaults(char **info, char *name)
 {
-  info[M_NAME] = Strsave(name);
-  info[M_VENDOR] = Strsave(M_DEFAULT_TYPE);
-  info[M_MODEL] = Strsave(M_DEFAULT_TYPE);
-  info[M_OS] = Strsave(M_DEFAULT_TYPE);
-  info[M_LOC] = Strsave(M_DEFAULT_TYPE);
-  info[M_CONTACT] = Strsave(M_DEFAULT_TYPE);
-  info[M_USE] = Strsave("0");
-  info[M_STAT] = Strsave("1");
-  info[M_SUBNET] = Strsave("NONE");
-  info[M_ADDR] = Strsave("unique");
-  info[M_OWNER_TYPE] = Strsave("NONE");
-  info[M_OWNER_NAME] = Strsave("NONE");
-  info[M_ACOMMENT] = Strsave("");
-  info[M_OCOMMENT] = Strsave("");
+  info[M_NAME] = strdup(name);
+  info[M_VENDOR] = strdup(M_DEFAULT_TYPE);
+  info[M_MODEL] = strdup(M_DEFAULT_TYPE);
+  info[M_OS] = strdup(M_DEFAULT_TYPE);
+  info[M_LOC] = strdup(M_DEFAULT_TYPE);
+  info[M_CONTACT] = strdup(M_DEFAULT_TYPE);
+  info[M_USE] = strdup("0");
+  info[M_STAT] = strdup("1");
+  info[M_SUBNET] = strdup("NONE");
+  info[M_ADDR] = strdup("unique");
+  info[M_OWNER_TYPE] = strdup("NONE");
+  info[M_OWNER_NAME] = strdup("NONE");
+  info[M_ACOMMENT] = strdup("");
+  info[M_OCOMMENT] = strdup("");
   info[15] = info[16] = NULL;
   return info;
 }
@@ -116,9 +117,9 @@ static char **SetMachineDefaults(char **info, char *name)
 
 static char **SetClusterDefaults(char **info, char *name)
 {
-  info[C_NAME] = Strsave(name);
-  info[C_DESCRIPT] = Strsave(C_DEFAULT_DESCRIPT);
-  info[C_LOCATION] = Strsave(C_DEFAULT_LOCATION);
+  info[C_NAME] = strdup(name);
+  info[C_DESCRIPT] = strdup(C_DEFAULT_DESCRIPT);
+  info[C_LOCATION] = strdup(C_DEFAULT_LOCATION);
   info[C_MODBY] = info[C_MODTIME] = info[C_MODWITH] = info[C_END] = NULL;
   return info;
 }
@@ -134,19 +135,19 @@ static char **SetSubnetDefaults(char **info, char *name)
 {
   char buf[256];
 
-  info[C_NAME] = Strsave(name);
-  info[SN_DESC] = Strsave("");
+  info[C_NAME] = strdup(name);
+  info[SN_DESC] = strdup("");
   sprintf(buf, "%ld", ntohl(inet_addr("18.255.0.0")));
-  info[SN_ADDRESS] = Strsave(buf);
+  info[SN_ADDRESS] = strdup(buf);
   sprintf(buf, "%ld", ntohl(inet_addr("255.255.0.0")));
-  info[SN_MASK] = Strsave(buf);
+  info[SN_MASK] = strdup(buf);
   sprintf(buf, "%ld", ntohl(inet_addr(S_DEFAULT_LOW)));
-  info[SN_LOW] = Strsave(buf);
+  info[SN_LOW] = strdup(buf);
   sprintf(buf, "%ld", ntohl(inet_addr(S_DEFAULT_HIGH)));
-  info[SN_HIGH] = Strsave(buf);
-  info[SN_PREFIX] = Strsave("");
-  info[SN_ACE_TYPE] = Strsave("LIST");
-  info[SN_ACE_NAME] = Strsave("network");
+  info[SN_HIGH] = strdup(buf);
+  info[SN_PREFIX] = strdup("");
+  info[SN_ACE_TYPE] = strdup("LIST");
+  info[SN_ACE_NAME] = strdup("network");
   info[SN_MODBY] = info[SN_MODTIME] = info[SN_MODWITH] = info[SN_END] = NULL;
   return info;
 }
@@ -155,7 +156,7 @@ static char **SetSubnetDefaults(char **info, char *name)
 
 static char aliasbuf[256];
 
-static char *PrintAliases(char **info)
+void PrintAliases(char **info)
 {
   if (strlen(aliasbuf) == 0)
     sprintf(aliasbuf, "Aliases:  %s", info[0]);
@@ -186,7 +187,7 @@ static char *PrintMachInfo(char **info)
   Put_message(buf);
   args[0] = "*";
   args[1] = info[M_NAME];
-  if ((stat = do_mr_query("get_hostalias", 2, args, StoreInfo, (char *)&elem)))
+  if ((stat = do_mr_query("get_hostalias", 2, args, StoreInfo, &elem)))
     {
       if (stat != MR_NO_MATCH)
        com_err(program_name, stat, " looking up aliases");
@@ -358,8 +359,7 @@ struct qelem *GetMCInfo(int type, char *name1, char *name2)
     case MACHINE:
       args[0] = name1;
       args[1] = args[2] = args[3] = "*";
-      if ((stat = do_mr_query("get_host", 4, args,
-                             StoreInfo, (char *)&elem)))
+      if ((stat = do_mr_query("get_host", 4, args, StoreInfo, &elem)))
        {
          if (stat == MR_NO_MATCH)
            {
@@ -375,16 +375,14 @@ struct qelem *GetMCInfo(int type, char *name1, char *name2)
     case CNAME:
       args[0] = name1;
       args[1] = name2;
-      if ((stat = do_mr_query("get_hostalias", 2, args,
-                             StoreInfo, (char *)&elem)))
+      if ((stat = do_mr_query("get_hostalias", 2, args, StoreInfo, &elem)))
        {
          com_err(program_name, stat, " in get_hostalias.");
          return NULL;
        }
       break;
     case SUBNET:
-      if ((stat = do_mr_query("get_subnet", 1, &name1,
-                             StoreInfo, (char *)&elem)))
+      if ((stat = do_mr_query("get_subnet", 1, &name1, StoreInfo, &elem)))
        {
          if (stat == MR_NO_MATCH)
            {
@@ -398,8 +396,7 @@ struct qelem *GetMCInfo(int type, char *name1, char *name2)
        }
       break;
     case CLUSTER:
-      if ((stat = do_mr_query("get_cluster", 1, &name1,
-                             StoreInfo, (char *)&elem)))
+      if ((stat = do_mr_query("get_cluster", 1, &name1, StoreInfo, &elem)))
        {
          com_err(program_name, stat, " in get_cluster.");
          return NULL;
@@ -409,7 +406,7 @@ struct qelem *GetMCInfo(int type, char *name1, char *name2)
       args[MAP_MACHINE] = name1;
       args[MAP_CLUSTER] = name2;
       if ((stat = do_mr_query("get_machine_to_cluster_map", 2, args,
-                             StoreInfo, (char *)&elem)))
+                             StoreInfo, &elem)))
        {
          com_err(program_name, stat, " in get_machine_to_cluster_map.");
          return NULL;
@@ -418,8 +415,7 @@ struct qelem *GetMCInfo(int type, char *name1, char *name2)
     case DATA:
       args[CD_NAME] = name1;
       args[CD_LABEL] = name2;
-      if ((stat = do_mr_query("get_cluster_data", 2, args,
-                             StoreInfo, (char *)&elem)))
+      if ((stat = do_mr_query("get_cluster_data", 2, args, StoreInfo, &elem)))
        {
          com_err(program_name, stat, " in get_cluster_data.");
          return NULL;
@@ -469,11 +465,11 @@ char **AskMCDInfo(char **info, int type, Bool name)
       switch (type)
        {
        case MACHINE:
-         newname = Strsave(info[M_NAME]);
+         newname = strdup(info[M_NAME]);
          if (GetValueFromUser("The new name for this machine? ", &newname) ==
              SUB_ERROR)
            return NULL;
-         oldnewname = Strsave(newname);
+         oldnewname = strdup(newname);
          newname = canonicalize_hostname(newname);
          if (strcasecmp(newname, oldnewname) && *oldnewname != '"')
            {
@@ -484,13 +480,13 @@ char **AskMCDInfo(char **info, int type, Bool name)
          free(oldnewname);
          break;
        case SUBNET:
-         newname = Strsave(info[SN_NAME]);
+         newname = strdup(info[SN_NAME]);
          if (GetValueFromUser("The new name for this network? ", &newname) ==
              SUB_ERROR)
            return NULL;
          break;
        case CLUSTER:
-         newname = Strsave(info[C_NAME]);
+         newname = strdup(info[C_NAME]);
          if (GetValueFromUser("The new name for this cluster? ", &newname) ==
              SUB_ERROR)
            return NULL;
@@ -597,8 +593,8 @@ char **AskMCDInfo(char **info, int type, Bool name)
          low.s_addr = atoi(info[SN_LOW]);
          low.s_addr = (low.s_addr & ~mask) | (addr & mask);
          free(info[SN_LOW]);
-         sprintf(temp_buf, "%d", low.s_addr);
-         info[SN_LOW] = strsave(temp_buf);
+         sprintf(temp_buf, "%ld", low.s_addr);
+         info[SN_LOW] = strdup(temp_buf);
        }
       if (GetAddressFromUser("Lowest assignable address", &info[SN_LOW]) ==
          SUB_ERROR)
@@ -613,8 +609,8 @@ char **AskMCDInfo(char **info, int type, Bool name)
          high.s_addr = atoi(info[SN_HIGH]);
          high.s_addr = (high.s_addr & ~mask) | (addr & mask);
          free(info[SN_HIGH]);
-         sprintf(temp_buf, "%d", high.s_addr);
-         info[SN_HIGH] = strsave(temp_buf);
+         sprintf(temp_buf, "%ld", high.s_addr);
+         info[SN_HIGH] = strdup(temp_buf);
        }
       if (GetAddressFromUser("Highest assignable address", &info[SN_HIGH]) ==
          SUB_ERROR)
@@ -674,7 +670,7 @@ int ShowMachineInfo(int argc, char **argv)
   struct qelem *top;
   char *tmpname;
 
-  tmpname = canonicalize_hostname(strsave(argv[1]));
+  tmpname = canonicalize_hostname(strdup(argv[1]));
   top = GetMCInfo(MACHINE, tmpname, NULL);
   Loop(top, ((void *) PrintMachInfo));
   FreeQueue(top);
@@ -707,7 +703,7 @@ int ShowMachineQuery(int argc, char **argv)
     }
 
   if (*argv[1])
-    args[0] = canonicalize_hostname(strsave(argv[1]));
+    args[0] = canonicalize_hostname(strdup(argv[1]));
   else
     args[0] = "*";
   if (*argv[2])
@@ -723,8 +719,7 @@ int ShowMachineQuery(int argc, char **argv)
   else
     args[3] = "*";
 
-  if ((stat = do_mr_query("get_host", 4, args, StoreInfo,
-                         (char *)&elem)))
+  if ((stat = do_mr_query("get_host", 4, args, StoreInfo, &elem)))
     {
       if (stat == MR_NO_MATCH)
        Put_message("No machine(s) found matching query in the database.");
@@ -759,8 +754,7 @@ int AddMachine(int argc, char **argv)
    */
 
   if (strcasecmp(argv[1], "none") &&
-      (stat = do_mr_query("get_subnet", 1, &argv[1],
-                         StoreInfo, (char *)&elem)))
+      (stat = do_mr_query("get_subnet", 1, &argv[1], StoreInfo, &elem)))
     {
       if (stat == MR_NO_MATCH)
        {
@@ -776,15 +770,15 @@ int AddMachine(int argc, char **argv)
    * Check to see if this machine already exists.
    */
 
-  name = strsave(""); /* want to put prefix here */
+  name = strdup(""); /* want to put prefix here */
   if (GetValueFromUser("Machine name", &name) == SUB_ERROR)
     return 0;
 
-  name = canonicalize_hostname(strsave(name));
+  name = canonicalize_hostname(strdup(name));
 
   xargs[0] = name;
   xargs[1] = xargs[2] = xargs[3] = "*";
-  if (!(stat = do_mr_query("get_host", 4, xargs, NullFunc, NULL)))
+  if (!(stat = do_mr_query("get_host", 4, xargs, NULL, NULL)))
     {
       sprintf(buf, "The machine '%s' already exists.", name);
       Put_message(buf);
@@ -799,7 +793,7 @@ int AddMachine(int argc, char **argv)
       return DM_NORMAL;
     }
   rinfo = SetMachineDefaults(info, name);
-  rinfo[M_SUBNET] = strsave(argv[1]);
+  rinfo[M_SUBNET] = strdup(argv[1]);
   if (!(args = AskMCDInfo(rinfo, MACHINE, FALSE)))
     {
       Put_message("Aborted.");
@@ -810,8 +804,7 @@ int AddMachine(int argc, char **argv)
    * Actually create the new Machine.
    */
 
-  if ((stat = do_mr_query("add_host", CountArgs(args),
-                         args, Scream, NULL)))
+  if ((stat = do_mr_query("add_host", CountArgs(args), args, NULL, NULL)))
     com_err(program_name, stat, " in AddMachine.");
 
   FreeInfo(info);
@@ -835,8 +828,7 @@ static void RealUpdateMachine(char **info, Bool junk)
       Put_message("Aborted.");
       return;
     }
-  if ((stat = do_mr_query("update_host", CountArgs(args),
-                         args, Scream, NULL)))
+  if ((stat = do_mr_query("update_host", CountArgs(args), args, NULL, NULL)))
     com_err(program_name, stat, " in UpdateMachine.");
   else
     Put_message("Machine successfully updated.");
@@ -853,7 +845,7 @@ int UpdateMachine(int argc, char **argv)
   struct qelem *top;
   char *tmpname;
 
-  tmpname = canonicalize_hostname(strsave(argv[1]));
+  tmpname = canonicalize_hostname(strdup(argv[1]));
   top = GetMCInfo(MACHINE, tmpname, NULL);
   QueryLoop(top, NullPrint, RealUpdateMachine, "Update the machine");
 
@@ -880,8 +872,7 @@ int CheckAndRemoveFromCluster(char *name, Bool ask_user)
   ret_value = SUB_NORMAL;      /* initialize ret_value. */
   args[0] = name;
   args[1] = "*";
-  stat = do_mr_query("get_machine_to_cluster_map", 2, args,
-                    StoreInfo, (char *)&elem);
+  stat = do_mr_query("get_machine_to_cluster_map", 2, args, StoreInfo, &elem);
   if (stat && stat != MR_NO_MATCH)
     {
       com_err(program_name, stat, " in get_machine_to_cluster_map.");
@@ -912,9 +903,9 @@ int CheckAndRemoveFromCluster(char *name, Bool ask_user)
        {
          while (elem)
            {
-             char **info = (char **) elem->q_data;
+             char **info = elem->q_data;
              if ((stat = do_mr_query("delete_machine_from_cluster",
-                                      2, info, Scream, NULL)))
+                                      2, info, NULL, NULL)))
                {
                  ret_value = SUB_ERROR;
                  com_err(program_name, stat,
@@ -951,7 +942,7 @@ static void RealDeleteMachine(char **info, Bool one_machine)
       if (CheckAndRemoveFromCluster(info[M_NAME], TRUE) != SUB_ERROR)
        {
          if ((stat = do_mr_query("delete_host", 1,
-                                 &info[M_NAME], Scream, NULL)))
+                                 &info[M_NAME], NULL, NULL)))
            {
              com_err(program_name, stat, " in DeleteMachine.");
              sprintf(temp_buf, "%s ** NOT ** deleted.",
@@ -980,7 +971,7 @@ int DeleteMachine(int argc, char **argv)
   struct qelem *top;
   char *tmpname;
 
-  tmpname = canonicalize_hostname(strsave(argv[1]));
+  tmpname = canonicalize_hostname(strdup(argv[1]));
   top = GetMCInfo(MACHINE, tmpname, (char *) NULL);
   QueryLoop(top, PrintMachInfo, RealDeleteMachine, "Delete the machine");
   FreeQueue(top);
@@ -1002,7 +993,7 @@ char *partial_canonicalize_hostname(char *s)
       hp = gethostbyname(name.nodename);
       cp = strchr(hp->h_name, '.');
       if (cp)
-       def_domain = strsave(++cp);
+       def_domain = strdup(++cp);
       else
        def_domain = "";
     }
@@ -1011,7 +1002,7 @@ char *partial_canonicalize_hostname(char *s)
     return s;
   sprintf(buf, "%s.%s", s, def_domain);
   free(s);
-  return strsave(buf);
+  return strdup(buf);
 }
 
 
@@ -1026,8 +1017,8 @@ int ShowCname(int argc, char **argv)
   struct qelem *top;
   char *tmpalias, *tmpname;
 
-  tmpalias = partial_canonicalize_hostname(strsave(argv[1]));
-  tmpname = canonicalize_hostname(strsave(argv[2]));
+  tmpalias = partial_canonicalize_hostname(strdup(argv[1]));
+  tmpname = canonicalize_hostname(strdup(argv[2]));
   top = GetMCInfo(CNAME, tmpalias, tmpname);
   Put_message("");             /* blank line on screen */
   Loop(top, ((void *) PrintCname));
@@ -1041,9 +1032,9 @@ int AddCname(int argc, char **argv)
   int stat;
   char *args[10];
 
-  args[0] = partial_canonicalize_hostname(strsave(argv[1]));
-  args[1] = canonicalize_hostname(strsave(argv[2]));
-  stat = do_mr_query("add_hostalias", 2, args, Scream, NULL);
+  args[0] = partial_canonicalize_hostname(strdup(argv[1]));
+  args[1] = canonicalize_hostname(strdup(argv[2]));
+  stat = do_mr_query("add_hostalias", 2, args, NULL, NULL);
   switch (stat)
     {
     case MR_SUCCESS:
@@ -1065,13 +1056,11 @@ int AddCname(int argc, char **argv)
 int DeleteCname(int argc, char **argv)
 {
   int stat;
-  char *machine, *cluster, temp_buf[BUFSIZ], *args[10];
-  Bool add_it, one_machine, one_cluster;
-  struct qelem *melem, *mtop, *celem, *ctop;
+  char *args[10];
 
-  args[0] = partial_canonicalize_hostname(strsave(argv[1]));
-  args[1] = canonicalize_hostname(strsave(argv[2]));
-  stat = do_mr_query("delete_hostalias", 2, args, Scream, NULL);
+  args[0] = partial_canonicalize_hostname(strdup(argv[1]));
+  args[1] = canonicalize_hostname(strdup(argv[2]));
+  stat = do_mr_query("delete_hostalias", 2, args, NULL, NULL);
   if (stat)
     com_err(program_name, stat, " in delete_hostalias");
   return DM_NORMAL;
@@ -1092,7 +1081,7 @@ int AddMachineToCluster(int argc, char **argv)
   Bool add_it, one_machine, one_cluster;
   struct qelem *melem, *mtop, *celem, *ctop;
 
-  machine = canonicalize_hostname(strsave(argv[1]));
+  machine = canonicalize_hostname(strdup(argv[1]));
   if (strcasecmp(machine, argv[1]) && *argv[1] != '"')
     {
       sprintf(temp_buf, "Warning: '%s' canonicalized to '%s'.",
@@ -1112,10 +1101,10 @@ int AddMachineToCluster(int argc, char **argv)
 
   while (melem)
     {
-      char **minfo = (char **) melem->q_data;
+      char **minfo = melem->q_data;
       while (celem)
        {
-         char **cinfo = (char **) celem->q_data;
+         char **cinfo = celem->q_data;
          if (one_machine && one_cluster)
            add_it = TRUE;
          else
@@ -1142,7 +1131,7 @@ int AddMachineToCluster(int argc, char **argv)
              args[0] = minfo[M_NAME];
              args[1] = cinfo[C_NAME];
              stat = do_mr_query("add_machine_to_cluster", 2, args,
-                                Scream, NULL);
+                                NULL, NULL);
              switch (stat)
                {
                case MR_SUCCESS:
@@ -1186,7 +1175,7 @@ static void RealRemoveMachineFromCluster(char **info, Bool one_map)
   if (!one_map || Confirm(temp_buf))
     {
       if ((stat = do_mr_query("delete_machine_from_cluster", 2,
-                             info, Scream, NULL)))
+                             info, NULL, NULL)))
        com_err(program_name, stat, " in delete_machine_from_cluster");
       else
        {
@@ -1212,7 +1201,7 @@ int RemoveMachineFromCluster(int argc, char **argv)
   char buf[BUFSIZ], * args[10];
   int stat;
 
-  args[MAP_MACHINE] = canonicalize_hostname(strsave(argv[1]));
+  args[MAP_MACHINE] = canonicalize_hostname(strdup(argv[1]));
   if (strcasecmp(args[MAP_MACHINE], argv[1]) && *argv[1] != '"')
     {
       sprintf(buf, "Warning: '%s' canonicalized to '%s'.",
@@ -1223,7 +1212,7 @@ int RemoveMachineFromCluster(int argc, char **argv)
   args[MAP_END] = NULL;
 
   stat = do_mr_query("get_machine_to_cluster_map", CountArgs(args), args,
-                    StoreInfo, (char *)&elem);
+                    StoreInfo, &elem);
   if (stat == MR_NO_MATCH)
     {
       sprintf(buf, "The machine %s is not is the cluster %s.",
@@ -1279,8 +1268,7 @@ int AddSubnet(int argc, char **argv)
   if (!ValidName(name))
     return DM_NORMAL;
 
-  if ((stat = do_mr_query("get_subnet", 1, &name,
-                         NullFunc, NULL)) == MR_SUCCESS)
+  if ((stat = do_mr_query("get_subnet", 1, &name, NULL, NULL)) == MR_SUCCESS)
     {
       Put_message("This subnet already exists.");
       return DM_NORMAL;
@@ -1300,8 +1288,7 @@ int AddSubnet(int argc, char **argv)
   /*
    * Actually create the new Subnet.
    */
-  if ((stat = do_mr_query("add_subnet", CountArgs(args),
-                         args, Scream, NULL)))
+  if ((stat = do_mr_query("add_subnet", CountArgs(args), args, NULL, NULL)))
     com_err(program_name, stat, " in AddSubnet.");
 
   FreeInfo(info);
@@ -1324,8 +1311,7 @@ static void RealUpdateSubnet(char **info, Bool junk)
       Put_message("Aborted.");
       return;
     }
-  if ((stat = do_mr_query("update_subnet", CountArgs(args),
-                         args, Scream, NULL)))
+  if ((stat = do_mr_query("update_subnet", CountArgs(args), args, NULL, NULL)))
     com_err(program_name, stat, " in UpdateSubnet.");
   else
     Put_message("Subnet successfully updated.");
@@ -1365,8 +1351,7 @@ static void RealDeleteSubnet(char **info, Bool one_subnet)
          info[C_NAME]);
   if (!one_subnet || Confirm(temp_buf))
     {
-      if ((stat = do_mr_query("delete_subnet", 1,
-                             &info[C_NAME], Scream, NULL)))
+      if ((stat = do_mr_query("delete_subnet", 1, &info[C_NAME], NULL, NULL)))
        {
          com_err(program_name, stat, " in delete_subnet.");
          sprintf(temp_buf, "Subnet %s ** NOT ** deleted.", info[C_NAME]);
@@ -1433,8 +1418,7 @@ int AddCluster(int argc, char **argv)
   if (!ValidName(name))
     return DM_NORMAL;
 
-  if ((stat = do_mr_query("get_cluster", 1, &name,
-                         NullFunc, NULL)) == MR_SUCCESS)
+  if ((stat = do_mr_query("get_cluster", 1, &name, NULL, NULL)) == MR_SUCCESS)
     {
       Put_message("This cluster already exists.");
       return DM_NORMAL;
@@ -1454,8 +1438,7 @@ int AddCluster(int argc, char **argv)
   /*
    * Actually create the new Cluster.
    */
-  if ((stat = do_mr_query("add_cluster", CountArgs(args),
-                         args, Scream, NULL)))
+  if ((stat = do_mr_query("add_cluster", CountArgs(args), args, NULL, NULL)))
     com_err(program_name, stat, " in AddCluster.");
 
   FreeInfo(info);
@@ -1480,7 +1463,7 @@ static void RealUpdateCluster(char **info, Bool junk)
       return;
     }
   if ((stat = do_mr_query("update_cluster", CountArgs(args),
-                         args, Scream, NULL)))
+                         args, NULL, NULL)))
     com_err(program_name, stat, " in UpdateCluster.");
   else
     Put_message("Cluster successfully updated.");
@@ -1521,8 +1504,7 @@ int CheckAndRemoveMachines(char *name, Bool ask_first)
   ret_value = SUB_NORMAL;
   args[MAP_MACHINE] = "*";
   args[MAP_CLUSTER] = name;
-  stat = do_mr_query("get_machine_to_cluster_map", 2, args,
-                    StoreInfo, (char *)&elem);
+  stat = do_mr_query("get_machine_to_cluster_map", 2, args, StoreInfo, &elem);
   if (stat && stat != MR_NO_MATCH)
     {
       com_err(program_name, stat, " in get_machine_to_cluster_map.");
@@ -1538,7 +1520,7 @@ int CheckAndRemoveMachines(char *name, Bool ask_first)
          Put_message(temp_buf);
          while (elem)
            {
-             char **info = (char **) elem->q_data;
+             char **info = elem->q_data;
              Print(1, &info[MAP_MACHINE], (char *) NULL);
              elem = elem->q_forw;
            }
@@ -1561,9 +1543,9 @@ int CheckAndRemoveMachines(char *name, Bool ask_first)
          elem = top;
          while (elem)
            {
-             char **info = (char **) elem->q_data;
+             char **info = elem->q_data;
              if ((stat = do_mr_query("delete_machine_from_cluster",
-                                     2, info, Scream, NULL)))
+                                     2, info, NULL, NULL)))
                {
                  ret_value = SUB_ERROR;
                  com_err(program_name, stat,
@@ -1601,7 +1583,7 @@ static void RealDeleteCluster(char **info, Bool one_cluster)
       if (CheckAndRemoveMachines(info[C_NAME], TRUE) != SUB_ERROR)
        {
          if ((stat = do_mr_query("delete_cluster", 1,
-                                 &info[C_NAME], Scream, NULL)))
+                                 &info[C_NAME], NULL, NULL)))
            {
              com_err(program_name, stat, " in delete_cluster.");
              sprintf(temp_buf, "Cluster %s ** NOT ** deleted.", info[C_NAME]);
@@ -1651,7 +1633,7 @@ int ShowClusterData(int argc, char **argv)
   top = elem = GetMCInfo(DATA, argv[1], argv[2]);
   while (elem)
     {
-      info = (char **) elem->q_data;
+      info = elem->q_data;
       PrintClusterData(info);
       elem = elem->q_forw;
     }
@@ -1671,8 +1653,7 @@ int AddClusterData(int argc, char **argv)
 {
   int stat;
 
-  if ((stat = do_mr_query("add_cluster_data", 3, argv + 1,
-                         Scream, (char *) NULL)))
+  if ((stat = do_mr_query("add_cluster_data", 3, argv + 1, NULL, NULL)))
     com_err(program_name, stat, " in AddClusterData.");
   return DM_NORMAL;
 }
@@ -1696,8 +1677,7 @@ static void RealRemoveClusterData(char **info, Bool one_item)
   PrintClusterData(info);
   if (!one_item || Confirm(temp_ptr))
     {
-      if ((stat = do_mr_query("delete_cluster_data", 3, info,
-                             Scream, (char *) NULL)))
+      if ((stat = do_mr_query("delete_cluster_data", 3, info, NULL, NULL)))
        {
          com_err(program_name, stat, " in DeleteClusterData.");
          Put_message("Data not removed.");
@@ -1739,7 +1719,7 @@ int MachineToClusterMap(int argc, char **argv)
   struct qelem *elem, *top;
   char *tmpname, temp_buf[256];
 
-  tmpname = canonicalize_hostname(strsave(argv[1]));
+  tmpname = canonicalize_hostname(strdup(argv[1]));
   if (strcasecmp(tmpname, argv[1]) && *argv[1] != '"')
     {
       sprintf(temp_buf, "Warning: '%s' canonicalized to '%s'.",
@@ -1751,7 +1731,7 @@ int MachineToClusterMap(int argc, char **argv)
   Put_message("");             /* blank line on screen */
   while (elem)
     {
-      char **info = (char **) elem->q_data;
+      char **info = elem->q_data;
       PrintMCMap(info);
       elem = elem->q_forw;
     }
index 103147afcba22e8676f4b48676d20dc557b31d42..8b04c9631d648d2cb919ba8a9d05176100327152 100644 (file)
@@ -1,32 +1,46 @@
-/* $Header$
+/* $Id $
  *
- * Copyright 1987, 1988 by the Massachusetts Institute of Technology.
+ * DCM-related functions for Moira client
+ *
+ * Copyright (C) 1987-1998 by the Massachusetts Institute of Technology.
  * For copying and distribution information, please see the file
  * <mit-copyright.h>.
  */
 
-#include <stdio.h>
-#include <string.h>
-#include <ctype.h>
+#include <mit-copyright.h>
 #include <moira.h>
 #include <moira_site.h>
-#include <menu.h>
-
-#include "mit-copyright.h"
 #include "defs.h"
 #include "f_defs.h"
 #include "globals.h"
 
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+
+RCSID("$Header$");
+
 extern char *whoami;
 static char buf[BUFSIZ];
-char *unparse_interval(), *canonicalize_hostname();
-char *atot();
+
+int genable(int argc, char **argv, void *info);
+int shserv(int argc, char **argv, void *hint);
+char *unparse_interval(int i);
+char **askserv(char **info);
+int gserv(int argc, char **argv, void *hint);
+void initserv(char *name, char **argv);
+int shhost(int argc, char **argv, void *hint);
+int ghost(int argc, char **argv, void *hint);
+void inithost(char **info);
+char **askhost(char **info);
+int pserv(int argc, char **argv, void *count);
+int phost(int argc, char **argv, void *count);
 
 #define DCM_ENABLE_FLAG 0
 
-int genable(int argc, char **argv, char **info)
+int genable(int argc, char **argv, void *info)
 {
-  info[1] = strsave(argv[0]);
+  ((char **)info)[1] = strdup(argv[0]);
   return MR_CONT;
 }
 
@@ -40,7 +54,7 @@ int EnableDcm(int argc, char **argv)
     com_err(whoami, status, " while getting value of dcm_enable");
   if (GetValueFromUser("Enable value", &info[1]) == SUB_ERROR)
     return DM_NORMAL;
-  if ((status = do_mr_query("update_value", 2, info, Scream, NULL)))
+  if ((status = do_mr_query("update_value", 2, info, NULL, NULL)))
     com_err(whoami, status, " while updating value of dcm_enable");
   FreeAndClear(&info[0], FALSE);
   FreeAndClear(&info[1], TRUE);
@@ -48,7 +62,7 @@ int EnableDcm(int argc, char **argv)
 }
 
 
-int shserv(int argc, char **argv)
+int shserv(int argc, char **argv, void *hint)
 {
   char tmp[64], *dfgen;
 
@@ -66,7 +80,7 @@ int shserv(int argc, char **argv)
     sprintf(tmp, "Error %d: %s", atoi(argv[SVC_HARDERROR]), argv[SVC_ERRMSG]);
   else
     strcpy(tmp, "No error");
-  dfgen = strsave(atot(argv[SVC_DFGEN]));
+  dfgen = strdup(atot(argv[SVC_DFGEN]));
   sprintf(buf, "  Generated %s; Last Checked %s", dfgen,
          atot(argv[SVC_DFCHECK]));
   free(dfgen);
@@ -102,7 +116,7 @@ char *unparse_interval(int i)
 int addserv(int argc, char **argv)
 {
   int status;
-  char *info[SC_END + 1], **askserv();
+  char *info[SC_END + 1];
 
   initserv(argv[1], info);
   if (!askserv(info))
@@ -110,7 +124,7 @@ int addserv(int argc, char **argv)
       Put_message("Aborted.");
       return DM_NORMAL;
     }
-  if ((status = do_mr_query("add_server_info", SC_END, info, Scream, NULL)))
+  if ((status = do_mr_query("add_server_info", SC_END, info, NULL, NULL)))
     com_err(whoami, status, " while updating server info");
   FreeInfo(info);
   return DM_NORMAL;
@@ -139,34 +153,36 @@ char **askserv(char **info)
 }
 
 
-int gserv(int argc, char **argv, char **cargv)
+int gserv(int argc, char **argv, void *hint)
 {
-  cargv[SC_SERVICE] = strsave(argv[SVC_SERVICE]);
-  cargv[SC_INTERVAL] = strsave(argv[SVC_INTERVAL]);
-  cargv[SC_TARGET] = strsave(argv[SVC_TARGET]);
-  cargv[SC_SCRIPT] = strsave(argv[SVC_SCRIPT]);
-  cargv[SC_TYPE] = strsave(argv[SVC_TYPE]);
-  cargv[SC_ENABLE] = strsave(argv[SVC_ENABLE]);
-  cargv[SC_ACE_TYPE] = strsave(argv[SVC_ACE_TYPE]);
-  cargv[SC_ACE_NAME] = strsave(argv[SVC_ACE_NAME]);
+  char **cargv = hint;
+
+  cargv[SC_SERVICE] = strdup(argv[SVC_SERVICE]);
+  cargv[SC_INTERVAL] = strdup(argv[SVC_INTERVAL]);
+  cargv[SC_TARGET] = strdup(argv[SVC_TARGET]);
+  cargv[SC_SCRIPT] = strdup(argv[SVC_SCRIPT]);
+  cargv[SC_TYPE] = strdup(argv[SVC_TYPE]);
+  cargv[SC_ENABLE] = strdup(argv[SVC_ENABLE]);
+  cargv[SC_ACE_TYPE] = strdup(argv[SVC_ACE_TYPE]);
+  cargv[SC_ACE_NAME] = strdup(argv[SVC_ACE_NAME]);
   cargv[SC_END] = NULL;
   return MR_CONT;
 }
 
-int initserv(char *name, char **argv)
+void initserv(char *name, char **argv)
 {
   char tmp[BUFSIZ];
 
-  argv[SC_SERVICE] = strsave(name);
-  argv[SC_INTERVAL] = strsave("1440");
+  argv[SC_SERVICE] = strdup(name);
+  argv[SC_INTERVAL] = strdup("1440");
   sprintf(tmp, "/tmp/%s.out", name);
-  argv[SC_TARGET] = strsave(tmp);
+  argv[SC_TARGET] = strdup(tmp);
   sprintf(tmp, "%s/%s.sh", BIN_DIR, name);
-  argv[SC_SCRIPT] = strsave(tmp);
-  argv[SC_TYPE] = strsave("UNIQUE");
-  argv[SC_ENABLE] = strsave("1");
-  argv[SC_ACE_TYPE] = strsave("LIST");
-  argv[SC_ACE_NAME] = strsave("dbadmin");
+  argv[SC_SCRIPT] = strdup(tmp);
+  argv[SC_TYPE] = strdup("UNIQUE");
+  argv[SC_ENABLE] = strdup("1");
+  argv[SC_ACE_TYPE] = strdup("LIST");
+  argv[SC_ACE_NAME] = strdup("dbadmin");
   argv[SC_END] = NULL;
 }
 
@@ -177,8 +193,7 @@ int updateserv(int argc, char **argv)
   int status;
 
   qargv[0] = (char *)argv[1];
-  if ((status = do_mr_query("get_server_info", 1,
-                           qargv, gserv, (char *)qargv)))
+  if ((status = do_mr_query("get_server_info", 1, qargv, gserv, qargv)))
     {
       com_err(whoami, status, " while getting server info");
       return DM_NORMAL;
@@ -188,13 +203,13 @@ int updateserv(int argc, char **argv)
       Put_message("Aborted.");
       return DM_NORMAL;
     }
-  if ((status = do_mr_query("update_server_info", SC_END, qargv, Scream, NULL)))
+  if ((status = do_mr_query("update_server_info", SC_END, qargv, NULL, NULL)))
     com_err(whoami, status, " while updating server info");
   return DM_NORMAL;
 }
 
 
-int shhost(int argc, char **argv)
+int shhost(int argc, char **argv, void *hint)
 {
   char tmp[64], *ltt;
 
@@ -213,7 +228,7 @@ int shhost(int argc, char **argv)
          atoi(argv[SH_OVERRIDE]) ? "Override" : "Normal", tmp);
   Put_message(buf);
   Put_message("  Last Try             Last Success         Value1    Value2    Value3");
-  ltt = strsave(atot(argv[SH_LASTTRY]));
+  ltt = strdup(atot(argv[SH_LASTTRY]));
   sprintf(buf, "  %-20s %-20s %-9d %-9d %s", ltt, atot(argv[SH_LASTSUCCESS]),
          atoi(argv[SH_VALUE1]), atoi(argv[SH_VALUE2]), argv[SH_VALUE3]);
   free(ltt);
@@ -229,7 +244,7 @@ int showhost(int argc, char **argv)
   int status;
 
   qargv[SHI_SERVICE] = argv[1];
-  qargv[SHI_MACHINE] = canonicalize_hostname(strsave(argv[2]));
+  qargv[SHI_MACHINE] = canonicalize_hostname(strdup(argv[2]));
   if ((status = do_mr_query("get_server_host_info", 2, qargv, shhost, NULL)))
     com_err(whoami, status, " getting server/host info");
   return DM_NORMAL;
@@ -239,7 +254,7 @@ int showhost(int argc, char **argv)
 int resetsrverr(int argc, char **argv)
 {
   int status;
-  if ((status = do_mr_query("reset_server_error", 1, &argv[1], Scream, NULL)))
+  if ((status = do_mr_query("reset_server_error", 1, &argv[1], NULL, NULL)))
     com_err(whoami, status, " while resetting server error");
   return DM_NORMAL;
 }
@@ -260,7 +275,7 @@ int resetsrvc(int argc, char **argv)
   qargv[4] = "0";
   qargv[5] = "";
   if ((status = do_mr_query("set_server_internal_flags", 6, qargv,
-                           Scream, NULL)))
+                           NULL, NULL)))
     com_err(whoami, status, " while resetting server error");
   return DM_NORMAL;
 }
@@ -270,9 +285,9 @@ int resethosterr(int argc, char **argv)
 {
   int status;
 
-  argv[2] = canonicalize_hostname(strsave(argv[2]));
+  argv[2] = canonicalize_hostname(strdup(argv[2]));
   if ((status = do_mr_query("reset_server_host_error", 2, &argv[1],
-                           Scream, NULL)))
+                           NULL, NULL)))
     com_err(whoami, status, " while resetting server/host error");
   return DM_NORMAL;
 }
@@ -284,11 +299,11 @@ int resethost(int argc, char **argv)
   char *qargv[9], buf[BUFSIZ];
 
   sprintf(buf, "Reset state for service %s on host %s (Y/N)", argv[1],
-         canonicalize_hostname(strsave(argv[2])));
+         canonicalize_hostname(strdup(argv[2])));
   if (!Confirm(buf))
     return DM_NORMAL;
   qargv[0] = argv[1];
-  qargv[1] = canonicalize_hostname(strsave(argv[2]));
+  qargv[1] = canonicalize_hostname(strdup(argv[2]));
   qargv[2] = "0";
   qargv[3] = "0";
   qargv[4] = "0";
@@ -297,7 +312,7 @@ int resethost(int argc, char **argv)
   qargv[7] = "0";
   qargv[8] = "0";
   if ((status = do_mr_query("set_server_host_internal", 9, qargv,
-                           Scream, NULL)))
+                           NULL, NULL)))
     com_err(whoami, status, " while resetting server/host error");
   return DM_NORMAL;
 }
@@ -307,34 +322,36 @@ int sethostor(int argc, char **argv)
 {
   int status;
 
-  argv[2] = canonicalize_hostname(strsave(argv[2]));
+  argv[2] = canonicalize_hostname(strdup(argv[2]));
   if ((status = do_mr_query("set_server_host_override", 2, &argv[1],
-                           Scream, NULL)))
+                           NULL, NULL)))
     com_err(whoami, status, " while setting server/host override");
   return DM_NORMAL;
 }
 
 
-int ghost(int argc, char **argv, char **cargv)
+int ghost(int argc, char **argv, void *hint)
 {
-  cargv[SHI_SERVICE] = strsave(argv[SH_SERVICE]);
-  cargv[SHI_MACHINE] = strsave(argv[SH_MACHINE]);
-  cargv[SHI_ENABLE] = strsave(argv[SH_ENABLE]);
-  cargv[SHI_VALUE1] = strsave(argv[SH_VALUE1]);
-  cargv[SHI_VALUE2] = strsave(argv[SH_VALUE2]);
-  cargv[SHI_VALUE3] = strsave(argv[SH_VALUE3]);
+  char **cargv = hint;
+
+  cargv[SHI_SERVICE] = strdup(argv[SH_SERVICE]);
+  cargv[SHI_MACHINE] = strdup(argv[SH_MACHINE]);
+  cargv[SHI_ENABLE] = strdup(argv[SH_ENABLE]);
+  cargv[SHI_VALUE1] = strdup(argv[SH_VALUE1]);
+  cargv[SHI_VALUE2] = strdup(argv[SH_VALUE2]);
+  cargv[SHI_VALUE3] = strdup(argv[SH_VALUE3]);
   cargv[SHI_END] = NULL;
   return MR_CONT;
 }
 
 
-int inithost(char **info)
+void inithost(char **info)
 {
-  info[SHI_MACHINE] = canonicalize_hostname(strsave(info[SH_MACHINE]));
-  info[SHI_ENABLE] = strsave("1");
-  info[SHI_VALUE1] = strsave("0");
-  info[SHI_VALUE2] = strsave("0");
-  info[SHI_VALUE3] = strsave("");
+  info[SHI_MACHINE] = canonicalize_hostname(strdup(info[SH_MACHINE]));
+  info[SHI_ENABLE] = strdup("1");
+  info[SHI_VALUE1] = strdup("0");
+  info[SHI_VALUE2] = strdup("0");
+  info[SHI_VALUE3] = strdup("");
   info[SHI_END] = NULL;
 }
 
@@ -358,10 +375,9 @@ int updatehost(int argc, char **argv)
   char *info[SHI_END + 1];
   int status;
 
-  info[SHI_SERVICE] = strsave(argv[1]);
-  info[SHI_MACHINE] = canonicalize_hostname(strsave(argv[2]));
-  if ((status = do_mr_query("get_server_host_info", 2, info, ghost,
-                           (char *)info)))
+  info[SHI_SERVICE] = strdup(argv[1]);
+  info[SHI_MACHINE] = canonicalize_hostname(strdup(argv[2]));
+  if ((status = do_mr_query("get_server_host_info", 2, info, ghost, info)))
     {
       com_err(whoami, status, " while getting server/host info");
       return DM_NORMAL;
@@ -372,7 +388,7 @@ int updatehost(int argc, char **argv)
       return DM_NORMAL;
     }
   if ((status = do_mr_query("update_server_host_info", SHI_END, info,
-                           Scream, NULL)))
+                           NULL, NULL)))
     com_err(whoami, status, " while updating server/host info");
   FreeInfo(info);
   return DM_NORMAL;
@@ -384,8 +400,8 @@ int addhost(int argc, char **argv)
   char *info[SHI_END + 1];
   int status;
 
-  info[SHI_SERVICE] = strsave(argv[1]);
-  info[SHI_MACHINE] = canonicalize_hostname(strsave(argv[2]));
+  info[SHI_SERVICE] = strdup(argv[1]);
+  info[SHI_MACHINE] = canonicalize_hostname(strdup(argv[2]));
   inithost(info);
   if (!askhost(info))
     {
@@ -393,7 +409,7 @@ int addhost(int argc, char **argv)
       return DM_NORMAL;
     }
   if ((status = do_mr_query("add_server_host_info", SHI_END, info,
-                           Scream, NULL)))
+                           NULL, NULL)))
     com_err(whoami, status, " while adding server/host info");
   FreeInfo(info);
   return DM_NORMAL;
@@ -404,7 +420,7 @@ int delserv(int argc, char **argv)
 {
   int status;
 
-  if ((status = do_mr_query("delete_server_info", 1, &argv[1], Scream, NULL)))
+  if ((status = do_mr_query("delete_server_info", 1, &argv[1], NULL, NULL)))
     com_err(whoami, status, " while deleting server info");
   return DM_NORMAL;
 }
@@ -414,32 +430,32 @@ int delhost(int argc, char **argv)
 {
   int status;
 
-  argv[2] = canonicalize_hostname(strsave(argv[2]));
+  argv[2] = canonicalize_hostname(strdup(argv[2]));
   if ((status = do_mr_query("delete_server_host_info", 2, &argv[1],
-                           Scream, NULL)))
+                           NULL, NULL)))
     com_err(whoami, status, " while deleting server/host info");
   return DM_NORMAL;
 }
 
 
-int pserv(int argc, char **argv, int *count)
+int pserv(int argc, char **argv, void *count)
 {
   sprintf(buf, "Service %s", argv[0]);
   Put_message(buf);
-  (*count)++;
+  (*(int *)count)++;
   return MR_CONT;
 }
 
-int phost(int argc, char **argv, int *count)
+int phost(int argc, char **argv, void *count)
 {
   sprintf(buf, "Host %s:%s", argv[0], argv[1]);
   Put_message(buf);
-  (*count)++;
+  (*(int *)count)++;
   return MR_CONT;
 }
 
 
-int InProgress(void)
+int InProgress(int argc, char **oargv)
 {
   char *argv[6];
   int status, count = 0;
@@ -447,13 +463,13 @@ int InProgress(void)
   argv[0] = argv[2] = "DONTCARE";
   argv[1] = "TRUE";
   if ((status = do_mr_query("qualified_get_server", 3, argv, pserv,
-                           (char *)&count)) && status != MR_NO_MATCH)
+                           &count)) && status != MR_NO_MATCH)
     com_err(whoami, status, " while getting servers");
   argv[0] = "*";
   argv[1] = argv[2] = argv[3] = argv[5] = "DONTCARE";
   argv[4] = "TRUE";
   if ((status = do_mr_query("qualified_get_server_host", 6, argv, phost,
-                           (char *)&count)) && status != MR_NO_MATCH)
+                           &count)) && status != MR_NO_MATCH)
     com_err(whoami, status, " while getting server/hosts");
   if (!count)
     strcpy(buf, "Nothing is in progress at this time");
@@ -464,7 +480,7 @@ int InProgress(void)
   return DM_NORMAL;
 }
 
-int DcmFailed(void)
+int DcmFailed(int argc, char **oargv)
 {
   char *argv[6];
   int status, count = 0;
@@ -472,13 +488,13 @@ int DcmFailed(void)
   argv[0] = argv[1] = "DONTCARE";
   argv[2] = "TRUE";
   if ((status = do_mr_query("qualified_get_server", 3, argv, pserv,
-                           (char *)&count)) && status != MR_NO_MATCH)
+                           &count)) && status != MR_NO_MATCH)
     com_err(whoami, status, " while getting servers");
   argv[0] = "*";
   argv[1] = argv[2] = argv[3] = argv[4] = "DONTCARE";
   argv[5] = "TRUE";
   if ((status = do_mr_query("qualified_get_server_host", 6, argv, phost,
-                           (char *)&count)) && status != MR_NO_MATCH)
+                           &count)) && status != MR_NO_MATCH)
     com_err(whoami, status, " while getting server/hosts");
   if (!count)
     strcpy(buf, "Nothing has failed at this time");
@@ -490,7 +506,7 @@ int DcmFailed(void)
 }
 
 
-int Dcm(void)
+int Dcm(int argc, char **argv)
 {
   int status;
   if (Confirm("Are you sure you want to start a DCM now"))
index f7cd9766af677f1a3919738ce340f1e4254ecd0d..062c44be134e3caa5af404d9e1a3ded6b8251a02 100644 (file)
@@ -1,21 +1,18 @@
-/*     This is the file defs.h for the Moira Client, which allows users
+/* $Id $
+ *
+ *     This is the file defs.h for the Moira Client, which allows users
  *      to quickly and easily maintain most parts of the Moira database.
  *     It Contains: useful definitions.
  *
  *     Created:        4/12/88
  *     By:             Chris D. Peterson
  *
- *      $Source$
- *      $Author$
- *      $Header$
- *
- *     Copyright 1988 by the Massachusetts Institute of Technology.
- *
- *     For further information on copyright and distribution
- *     see the file mit-copyright.h
+ * Copyright (C) 1988-1998 by the Massachusetts Institute of Technology.
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
  */
 
-#include "mit-copyright.h"
+#include <mit-copyright.h>
 
 #ifndef _defs_header_
 #define _defs_header_
 
 #define MAX_ARGS_SIZE 100
 
-typedef void (*FVoid)();       /* function pointer typedef. */
-typedef char *(*FCharStar)();  /* function pointer typedef. */
-typedef int (*FInt)();         /* function pointer typedef. */
-
 typedef int Bool;
 
 #define IS_EMPTY(s)  (strlen((s)) == 0)
@@ -64,7 +57,7 @@ typedef int Bool;
 struct qelem {
   struct qelem *q_forw;
   struct qelem *q_back;
-  char *q_data;
+  void *q_data;
 };
 
 #endif /* _defs_header_ */     /* Do Not Add Anything After This Line */
index 54f69191b1a7aaf761af8cdfd138fdecc84d104a..6a92fa99fba74e97bb172f983ff250c5b98cef70 100644 (file)
@@ -1,35 +1,40 @@
-#if (!defined(lint) && !defined(SABER))
-  static char rcsid_module_c[] = "$Header$";
-#endif
-
-/*     This is the file delete.c for the Moira Client, which allows users
+/* $Id $
+ *
+ *     This is the file delete.c for the Moira Client, which allows users
  *      to quickly and easily maintain most parts of the Moira database.
  *     It Contains: functions for deleting users and lists.
  *
  *     Created:        5/18/88
  *     By:             Chris D. Peterson
  *
- *      $Source$
- *      $Author$
- *      $Header$
- *
- *     Copyright 1988 by the Massachusetts Institute of Technology.
- *
- *     For further information on copyright and distribution
- *     see the file mit-copyright.h
+ * Copyright (C) 1988-1998 by the Massachusetts Institute of Technology.
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
  */
 
-#include <stdio.h>
-#include <string.h>
+#include <mit-copyright.h>
 #include <moira.h>
 #include <moira_site.h>
-#include <menu.h>
-
-#include "mit-copyright.h"
 #include "defs.h"
 #include "f_defs.h"
 #include "globals.h"
 
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+RCSID("$Header$");
+
+int CheckListForDeletion(char *name, Bool verbose);
+void CheckAce(char *type, char *name, Bool verbose);
+int CheckIfAce(char *name, char *type, Bool verbose);
+int RemoveItemFromLists(char *name, char *type, struct qelem **elem,
+                       int verbose);
+int RemoveMembersOfList(char *name, Bool verbose);
+int DeleteUserGroup(char *name, Bool verbose);
+int DeleteHomeFilesys(char *name, Bool verbose);
+void AttemptToDeleteList(char **list_info, Bool ask_first);
+
 /*     Function Name: CheckListForDeletion
  *     Description: Check one of the lists in which we just removed a member.
  *                   if the list is empty then it will delete it.
@@ -45,12 +50,12 @@ int CheckListForDeletion(char *name, Bool verbose)
   char *args[2], buf[BUFSIZ], **info;
 
   if ((status = do_mr_query("count_members_of_list", 1, &name, StoreInfo,
-                           (char *) &elem)))
+                           &elem)))
     {
       com_err(program_name, status, " in DeleteList (count_members_of_list).");
       return SUB_NORMAL;
     }
-  info = (char **) elem->q_data;
+  info = elem->q_data;
   if (!strcmp(info[NAME], "0"))
     {
       if (verbose)
@@ -96,7 +101,7 @@ void CheckAce(char *type, char *name, Bool verbose)
 
   args[0] = type;
   args[1] = name;
-  status = do_mr_query("get_ace_use", 2, args, NullFunc, NULL);
+  status = do_mr_query("get_ace_use", 2, args, NULL, NULL);
   if (status != MR_NO_MATCH)
     return;                    /* If this query fails the ace will
                                   not be deleted even if it is empty. */
@@ -136,14 +141,13 @@ int CheckIfAce(char *name, char *type, Bool verbose)
 
   args[0] = type;
   args[1] = name;
-  switch ((status = do_mr_query("get_ace_use", 2, args,
-                               StoreInfo, (char *) &elem)))
+  switch ((status = do_mr_query("get_ace_use", 2, args, StoreInfo, &elem)))
     {
     case MR_NO_MATCH:
       return DM_NORMAL;
     case MR_SUCCESS:
       local = elem = QueueTop(elem);
-      info = (char **) local->q_data;
+      info = local->q_data;
       if (QueueCount(elem) == 1 &&
          !strcmp(info[0], "LIST") &&
          !strcmp(info[1], name))
@@ -159,7 +163,7 @@ int CheckIfAce(char *name, char *type, Bool verbose)
          Put_message("");
          for (; local != NULL; local = local->q_forw)
            {
-             info = (char **) local->q_data;
+             info = local->q_data;
              if (!strcmp(info[0], "LIST") &&
                  !strcmp(info[1], name))
                continue;
@@ -204,8 +208,7 @@ int RemoveItemFromLists(char *name, char *type, struct qelem **elem,
    * Get all list of which this item is a member, and store them in a queue.
    */
 
-  status = do_mr_query("get_lists_of_member", 2, args, StoreInfo,
-                      (char *) elem);
+  status = do_mr_query("get_lists_of_member", 2, args, StoreInfo, elem);
 
   if (status == MR_NO_MATCH)
     return SUB_NORMAL;
@@ -232,7 +235,7 @@ int RemoveItemFromLists(char *name, char *type, struct qelem **elem,
       Put_message(temp_buf);
       while (local)
        {
-         char **info = (char **) local->q_data;
+         char **info = local->q_data;
          Print(1, &info[GLOM_NAME], (char *) NULL);
            local = local->q_forw;
        }
@@ -256,10 +259,10 @@ int RemoveItemFromLists(char *name, char *type, struct qelem **elem,
   args[DM_TYPE] = type;
   while (local)
     {
-      char **info = (char **) local->q_data;
+      char **info = local->q_data;
       args[DM_LIST] = info[GLOM_NAME];
       if ((status = do_mr_query("delete_member_from_list",
-                               3, args, Scream, NULL)))
+                               3, args, NULL, NULL)))
        {
          com_err(program_name, status, " in delete_member\nAborting\n");
          FreeQueue(*elem);
@@ -285,8 +288,7 @@ int RemoveMembersOfList(char *name, Bool verbose)
   /*
    * Get the members of this list.
    */
-  status = do_mr_query("get_members_of_list", 1, &name, StoreInfo,
-                      (char *) &elem);
+  status = do_mr_query("get_members_of_list", 1, &name, StoreInfo, &elem);
   if (status == MR_NO_MATCH)
     return SUB_NORMAL;
 
@@ -309,7 +311,7 @@ int RemoveMembersOfList(char *name, Bool verbose)
       Put_message(" ");        /* Blank Line. */
       while (local)
        {
-         char **info = (char **) local->q_data;
+         char **info = local->q_data;
          Print(CountArgs(info), info, NULL);
          local = local->q_forw;
        }
@@ -331,11 +333,11 @@ int RemoveMembersOfList(char *name, Bool verbose)
   args[0] = name;
   while (local)
     {
-      char **info = (char **) local->q_data;
+      char **info = local->q_data;
       args[1] = info[0];
       args[2] = info[1];
       if ((status = do_mr_query("delete_member_from_list",
-                               3, args, Scream, NULL)))
+                               3, args, NULL, NULL)))
        {
          com_err(program_name, status, " in delete_member\nAborting\n");
          FreeQueue(elem);
@@ -360,7 +362,7 @@ int DeleteUserGroup(char *name, Bool verbose)
   int status, ans;
   char buf[BUFSIZ], *args[10];
 
-  status = do_mr_query("get_list_info", 1, &name, NullFunc, (char *) NULL);
+  status = do_mr_query("get_list_info", 1, &name, NULL, NULL);
   if (!status)
     {
       if (verbose)
@@ -403,8 +405,7 @@ int DeleteHomeFilesys(char *name, Bool verbose)
   int status;
   char buf[BUFSIZ];
 
-  switch ((status = do_mr_query("get_filesys_by_label", 1, &name, NullFunc,
-                               NULL)))
+  switch ((status = do_mr_query("get_filesys_by_label", 1, &name, NULL, NULL)))
     {
     case MR_NO_MATCH:
       break;
@@ -424,7 +425,7 @@ int DeleteHomeFilesys(char *name, Bool verbose)
              return SUB_ERROR;
            }
        }
-      if ((status = do_mr_query("delete_filesys", 1, &name, Scream,
+      if ((status = do_mr_query("delete_filesys", 1, &name, NULL,
                                NULL)) != MR_SUCCESS)
        {
          com_err(program_name, status, " in delete_filesys.");
@@ -452,7 +453,7 @@ static int RealDeleteUser(char *name)
   char buf[BUFSIZ];
   int status;
 
-  if ((status = do_mr_query("delete_user", 1, &name, Scream,
+  if ((status = do_mr_query("delete_user", 1, &name, NULL,
                            NULL)) != MR_SUCCESS)
     {
       com_err(program_name, status, ": user not deleted");
@@ -475,7 +476,7 @@ static int RealDeleteList(char *name)
   char buf[BUFSIZ];
   int status;
 
-  if ((status = do_mr_query("delete_list", 1, &name, Scream,
+  if ((status = do_mr_query("delete_list", 1, &name, NULL,
                            NULL)) != MR_SUCCESS)
     {
       com_err(program_name, status, ": list not deleted");
@@ -513,7 +514,7 @@ void AttemptToDeleteList(char **list_info, Bool ask_first)
    * 3) This list is not an ace of another object.
    */
 
-  switch ((status = do_mr_query("delete_list", 1, &name, Scream, NULL)))
+  switch ((status = do_mr_query("delete_list", 1, &name, NULL, NULL)))
     {
     case MR_SUCCESS:
       Put_message("List Sucessfully Deleted.");
@@ -539,11 +540,11 @@ void AttemptToDeleteList(char **list_info, Bool ask_first)
        {
          free(list_info[L_ACE_TYPE]);
          free(list_info[L_ACE_NAME]);
-         list_info[L_ACE_TYPE] = Strsave("USER");
-         list_info[L_ACE_NAME] = Strsave(user);
-         SlipInNewName(list_info, Strsave(list_info[L_NAME]));
+         list_info[L_ACE_TYPE] = strdup("USER");
+         list_info[L_ACE_NAME] = strdup(user);
+         SlipInNewName(list_info, strdup(list_info[L_NAME]));
          if ((status = do_mr_query("update_list", CountArgs(list_info) - 3,
-                                   list_info, Scream, NULL)) != MR_SUCCESS)
+                                   list_info, NULL, NULL)) != MR_SUCCESS)
            {
              com_err(program_name, status, " while updating list owner");
              Put_message("List may be only partly deleted.");
@@ -557,7 +558,7 @@ void AttemptToDeleteList(char **list_info, Bool ask_first)
          local = QueueTop(member_of);
          while (local)
            {
-             char **info = (char **) local->q_data;
+             char **info = local->q_data;
              if (CheckListForDeletion(info[LM_LIST], ask_first) == SUB_ERROR)
                break;
              local = local->q_forw;
@@ -587,7 +588,7 @@ int DeleteList(int argc, char *argv[])
   list = NULL;
 
   switch ((status = do_mr_query("get_list_info", 1, argv + 1,
-                               StoreInfo, (char *) &list)))
+                               StoreInfo, &list)))
     {
     case MR_SUCCESS:
       break;
@@ -609,7 +610,7 @@ int DeleteList(int argc, char *argv[])
   one_list = (QueueCount(list) == 1);
   while (list)
     {
-      char **info = (char **) list->q_data;
+      char **info = list->q_data;
       if (one_list)
        {
          sprintf(buf, "Are you sure that you want to delete the list %s",
@@ -660,7 +661,7 @@ int DeleteUser(int argc, char **argv)
   if (!Confirm("Are you sure that you want to delete this user?"))
     return DM_NORMAL;
 
-  status = do_mr_query("delete_user", 1, &name, Scream, NULL);
+  status = do_mr_query("delete_user", 1, &name, NULL, NULL);
   if (status != MR_IN_USE && status != 0)
     {
       com_err(program_name, status, ": user not deleted");
@@ -709,7 +710,7 @@ int DeleteUser(int argc, char **argv)
   local = member_of;
   while (local)
     {
-      char **info = (char **) local->q_data;
+      char **info = local->q_data;
       if (CheckListForDeletion(info[0], TRUE) == SUB_ERROR)
        break;
       local = local->q_forw;
index 429e2ab7ab7f847b646484be568385064b85cae3..d6b5a1176eba9ba014629e4a623deea7f8677290 100644 (file)
-/*     This is the file f_defs.h for the Moira Client, which allows users
+/* $Id $
+ *
+ *     This is the file f_defs.h for the Moira Client, which allows users
  *      to quickly and easily maintain most parts of the Moira database.
  *     It Contains: useful definitions.
  *
  *     Created:        4/12/88
  *     By:             Chris D. Peterson
  *
- *      $Source$
- *      $Author$
- *      $Header$
- *
- *     Copyright 1988 by the Massachusetts Institute of Technology.
- *
- *     For further information on copyright and distribution
- *     see the file mit-copyright.h
+ * Copyright (C) 1988-1998 by the Massachusetts Institute of Technology.
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
  */
 
-#include "mit-copyright.h"
+#include <mit-copyright.h>
+#include "menu.h"
 
 #ifndef _f_defs_
 #define _f_defs_
 
 /* attach.c */
 
-int GetFS();                   /* Get information about named filsys. */
-int GetFSM();                  /* Get filesys by machine */
-int AddFS();                   /* Adds a new Filsys to the database. */
-int ChangeFS();                        /* Changes information in a Filsys entry. */
-int DeleteFS();                        /* Delete a filesystem from the database. */
+int GetFS(int argc, char **argv);
+int GetFSM(int argc, char **argv);
+int AddFS(int argc, char **argv);
+int ChangeFS(int argc, char **argv);
+int DeleteFS(int argc, char **argv);
 
-int AddFSToGroup();            /* Add a filesystem to an fsgroup */
-int RemoveFSFromGroup();       /* remove a filesystem from an fsgroup */
-int ChangeFSGroupOrder();      /* change the sortorder on an fsgrouop */
-int FSGroupHelp();             /* print info about fsgroups */
+int AddFSToGroup(int argc, char **argv);
+int RemoveFSFromGroup(int argc, char **argv);
+int ChangeFSGroupOrder(int argc, char **argv);
+int FSGroupHelp(int argc, char **argv);
 
-int GetFSAlias();              /* Gets the value for a Filsys alias. */
-int CreateFSAlias();           /* Creates a new alias in the database. */
-int DeleteFSAlias();           /* Deletes an FS alias from the database. */
+int GetFSAlias(int argc, char **argv);
+int CreateFSAlias(int argc, char **argv);
+int DeleteFSAlias(int argc, char **argv);
 
-int AttachHelp();              /* Help information specific to filsys. */
+int AttachHelp(void);
 
 /* cluster.c */
 
-int ShowMachineInfo();         /* Show information on a(many) machine(s). */
-int ShowMachineQuery();                /* Show mach info based on complex query */
-int AddMachine();              /* add a new machine to teh database. */
-int UpdateMachine();           /* updates machine information. */
-int DeleteMachine();           /* delete a machine from the database. */
-int MachineToClusterMap();     /* show machines in clusters. */
-int AddMachineToCluster();     /* add a machine to a new cluster. */
-int RemoveMachineFromCluster();        /* remove a machine from a cluster. */
-
-int ShowClusterInfo();         /* Show information about a cluster. */
-int AddCluster();              /* adds a new cluster to the database. */
-int UpdateCluster();           /* updates information about a cluster. */
-int DeleteCluster();           /* removes a cluste from the database. */
-
-int ShowClusterInfo();         /* show information about a cluster. */
-int MachinesInCluster();       /* list all machines in a give cluster. */
-int AddCluster();
-int UpdateCluster();           /* add, update, and delete clusters. */
-int DeleteCluster();
-
-int ShowClusterData();         /* Show, add, and remove data  */
-int AddClusterData();          /* associated with a cluster. */
-int RemoveClusterData();
-
-int ShowSubnetInfo();
-int AddSubnet();
-int UpdateSubnet();
-int DeleteSubnet();
-
-int ShowCname();
-int AddCname();
-int DeleteCname();
+int ShowMachineInfo(int argc, char **argv);
+int ShowMachineQuery(int argc, char **argv);
+int AddMachine(int argc, char **argv);
+int UpdateMachine(int argc, char **argv);
+int DeleteMachine(int argc, char **argv);
+int MachineToClusterMap(int argc, char **argv);
+int AddMachineToCluster(int argc, char **argv);
+int RemoveMachineFromCluster(int argc, char **argv);
+
+int ShowClusterInfo(int argc, char **argv);
+int AddCluster(int argc, char **argv);
+int UpdateCluster(int argc, char **argv);
+int DeleteCluster(int argc, char **argv);
+
+int ShowClusterInfo(int argc, char **argv);
+int AddCluster(int argc, char **argv);
+int UpdateCluster(int argc, char **argv);
+int DeleteCluster(int argc, char **argv);
+
+int ShowClusterData(int argc, char **argv);
+int AddClusterData(int argc, char **argv);
+int RemoveClusterData(int argc, char **argv);
+
+int ShowSubnetInfo(int argc, char **argv);
+int AddSubnet(int argc, char **argv);
+int UpdateSubnet(int argc, char **argv);
+int DeleteSubnet(int argc, char **argv);
+
+int ShowCname(int argc, char **argv);
+int AddCname(int argc, char **argv);
+int DeleteCname(int argc, char **argv);
 
 /* delete.c */
 
-int DeleteList(), DeleteUser();
+int DeleteList(int argc, char **argv);
+int DeleteUser(int argc, char **argv);
 
 /* lists.c */
 
-int ListByMember();            /* list all list to which a member belongs. */
-int ListByAdministrator();     /* list all list to which a given member can
-                                administer. */
-int ListAllGroups();
-int ListAllPublicMailLists();  /* List misc. types of lists. */
-int ListAllMailLists();
+int ListByMember(int argc, char **argv);
+int ListByAdministrator(int argc, char **argv);
+int ListAllPublicMailLists(int argc, char **argv);
 
-int AddMember(), DeleteMember(); /* add and delete mamber of current list. */
-int ListAllMembers();
-int ListUserMembers();         /* List various members of the current list. */
-int ListListMembers();
-int ListStringMembers();
+int AddMember(int argc, char **argv);
+int DeleteMember(int argc, char **argv);
+int ListAllMembers(int argc, char **argv);
+int ListUserMembers(int argc, char **argv);
+int ListListMembers(int argc, char **argv);
+int ListStringMembers(int argc, char **argv);
 
-int ShowListInfo();            /* show info about a list. */
-int UpdateList();              /* change info about a list. */
-int InterRemoveItemFromLists();        /* Interactivly remove item from all lists */
+int ShowListInfo(int argc, char **argv);
+int UpdateList(int argc, char **argv);
+int InterRemoveItemFromLists(int argc, char **argv);
 
-int ListmaintMemberMenuEntry();        /* entry and exit functions for member menu. */
-int ListmaintMemberMenuExit();
-int ListHelp();                        /* help function for lists. */
+int ListmaintMemberMenuEntry(Menu *m, int argc, char **argv);
+int ListmaintMemberMenuExit(Menu *m);
+int ListHelp(int argc, char **argv);
 
 /* nfs.c */
 
-int ShowNFSService();          /* functions that manipulate nfs physical  */
-int AddNFSService();           /* services. */
-int UpdateNFSService();
-int DeleteNFSService();
+int ShowNFSService(int argc, char **argv);
+int AddNFSService(int argc, char **argv);
+int UpdateNFSService(int argc, char **argv);
+int DeleteNFSService(int argc, char **argv);
 
 /* pobox.c */
 
-int GetUserPOBox();            /* operate on user post office boxes. */
-int SetUserPOBox();
-int RemoveUserPOBox();
+int GetUserPOBox(int argc, char **argv);
+int SetUserPOBox(int argc, char **argv);
+int RemoveUserPOBox(int argc, char **argv);
 
 /* quota.c */
 
-int ShowDefaultQuota();                /* show or change system default quota. */
-int ChangeDefaultQuota();
+int ShowDefaultQuota(int argc, char **argv);
+int ChangeDefaultQuota(int argc, char **argv);
 
-int GetQuota();                        /* modify a user's quota. */
-int GetQuotaByFilesys();
-int AddQuota();
-int UpdateQuota();
-int DeleteQuota();
+int GetQuota(int argc, char **argv);
+int GetQuotaByFilesys(int argc, char **argv);
+int AddQuota(int argc, char **argv);
+int UpdateQuota(int argc, char **argv);
+int DeleteQuota(int argc, char **argv);
 
 /* user.c */
 
-int ShowUserByLogin();         /* misc. ways to show user. */
-int ShowUserByName();
-int ShowUserByClass();
-int ShowUserById();
-int AddNewUser();              /* add a new user to the database. */
-int RegisterUser();            /* register a user. */
-int UpdateUser();              /* modify info about a user. */
-int DeactivateUser();          /* change a user's status to DELETED */
-int ChangeUserPOBox();         /* change the PO box of a user. */
-int DeleteUserByUid();         /* detete a user by uid. */
-int GetKrbmap();               /* fetch a user->kerberos mapping */
-int AddKrbmap();
-int DeleteKrbmap();
-int GetDirFlags();
-int SetDirFlags();
+int ShowUserByLogin(int argc, char **argv);
+int ShowUserByName(int argc, char **argv);
+int ShowUserByClass(int argc, char **argv);
+int ShowUserById(int argc, char **argv);
+int AddNewUser(int argc, char **argv);
+int RegisterUser(int argc, char **argv);
+int UpdateUser(int argc, char **argv);
+int DeactivateUser(int argc, char **argv);
+int DeleteUserByUid(int argc, char **argv);
+int GetKrbmap(int argc, char **argv);
+int AddKrbmap(int argc, char **argv);
+int DeleteKrbmap(int argc, char **argv);
+int GetDirFlags(int argc, char **argv);
+int SetDirFlags(int argc, char **argv);
 
 /* printer.c */
-int AddPcap();
-int GetPcap();
-int ChngPcap();
-int DeletePcap();
-int GetPalladium(), AddPalladium(), ChngPalladium(), DeletePalladium();
-int ShowPalladiumAlias(), AddPalladiumAlias(), DeletePalladiumAlias();
+int AddPcap(int argc, char **argv);
+int GetPcap(int argc, char **argv);
+int ChngPcap(int argc, char **argv);
+int DeletePcap(int argc, char **argv);
+int GetPalladium(int argc, char **argv);
+int AddPalladium(int argc, char **argv);
+int ChngPalladium(int argc, char **argv);
+int DeletePalladium(int argc, char **argv);
+int ShowPalladiumAlias(int argc, char **argv);
+int AddPalladiumAlias(int argc, char **argv);
+int DeletePalladiumAlias(int argc, char **argv);
 
 /* zephyr.c */
-int AddZephyr();
-int GetZephyr();
-int ChngZephyr();
-int DeleteZephyr();
-
-/* dcm.c */
-int EnableDcm(), InProgress(), DcmFailed(), Dcm();
-int enabledcm(), showserv(), addserv(), updateserv(), delserv();
-int showhost(), resetsrverr(), resetsrvc(), resethosterr();
-int resethost(), sethostor(), addhost(), updatehost(), delhost();
-int inprogress(), failed(), dcm();
+int AddZephyr(int argc, char **argv);
+int GetZephyr(int argc, char **argv);
+int ChngZephyr(int argc, char **argv);
+int DeleteZephyr(int argc, char **argv);
+
+/* dcmmaint.c */
+int EnableDcm(int argc, char **argv);
+int InProgress(int argc, char **argv);
+int DcmFailed(int argc, char **argv);
+int Dcm(int argc, char **argv);
+int showserv(int argc, char **argv);
+int addserv(int argc, char **argv);
+int updateserv(int argc, char **argv);
+int delserv(int argc, char **argv);
+int showhost(int argc, char **argv);
+int resetsrverr(int argc, char **argv);
+int resetsrvc(int argc, char **argv);
+int resethosterr(int argc, char **argv);
+int resethost(int argc, char **argv);
+int sethostor(int argc, char **argv);
+int addhost(int argc, char **argv);
+int updatehost(int argc, char **argv);
+int delhost(int argc, char **argv);
 
 /* misc.c */
-int TableStats(), ShowClients(), ShowValue(), ShowAlias();
+int TableStats(int argc, char **argv);
+int ShowClients(int argc, char **argv);
+int ShowValue(int argc, char **argv);
+int ShowAlias(int argc, char **argv);
 
 /* utils.c */
 
@@ -174,41 +189,36 @@ int TableStats(), ShowClients(), ShowValue(), ShowAlias();
  * internals documentation.
  */
 
-void EncryptMITID();           /* Encrypts an mit id number. */
-char **CopyInfo();             /* Copies a NULL terminated array of strings */
-void FreeInfo();               /* Frees a NULL terminated array of strings. */
-void FreeQueue();              /* Frees an entire queue. */
-void FreeAndClear();           /* Frees a single pointer. */
-void Loop();                   /* Performs an operation on every item in
-                                  a queue. */
-void QueryLoop();              /* Queries the user before performing
-                                  an operation on every item in
-                                  a queue. */
-void RemoveHyphens();          /* Removes the hyphens from a string. */
-void SlipInNewName();          /* Slips a new name into an argument list in
-                                  the correct place. */
-int CountArgs();               /* Counts the strings in a NULL terminated
-                                  array. */
-int GetValueFromUser();                /* Updates value by asking the user. */
-int GetYesNoValueFromUser();   /* Updates yes/no value by asking the user. */
-int GetFSTypes();              /* Gets Filesystem types from a user. */
-int NullFunc();                        /* NULL return function. */
-int Print();                   /* Prints out array of strings. */
-int PrintByType();             /* Prints out array of strings by type. */
-int PrintHelp();               /* Prints out help information. */
-int StoreInfo();               /* Stores info returned from a Moira query
-                                  in a queue. */
-int Scream();                  /* Query Return function that yells if called*/
-int ToggleVerboseMode();       /* Turns on and off the verbose variable. */
-char *CanonicalizeHostname();  /* this is what it does. */
-char *NullPrint();             /* Prints nothing, returns argv[0]. */
-char *Strsave();               /* allocated space for a copy of the string. */
-char *atot();                  /* convert unix time to date string */
-struct qelem *QueueTop();      /* Finds the top of a queue. */
-Bool Confirm();                        /* Confirms a delete operation, with user. */
-Bool YesNoQuestion();          /* Asks a user a yes no type question. */
-Bool YesNoQuitQuestion();      /* Asks a user a yes - no - quit question. */
-
-#endif /* _f_defs_ */          /* Do Not Add Anything After This Line */
-
-
+char **CopyInfo(char **info);
+void FreeInfo(char **);
+void FreeQueue(struct qelem *elem);
+void FreeAndClear(char **pointer, Bool free_it);
+void Loop(struct qelem *elem, void (*func)(char **));
+void QueryLoop(struct qelem *elem, char * (*print_func)(char **),
+              void (*op_func)(char **, Bool), char *query_string);
+void SlipInNewName(char **info, char *name);
+int CountArgs(char **args);
+int GetValueFromUser(char *prompt, char **pointer);
+int GetYesNoValueFromUser(char *prompt, char **pointer);
+int GetFSTypes(char **current, int options);
+int Print(int argc, char **argv, void *callback);
+int PrintByType(int argc, char **argv, void *callback);
+int PrintHelp(char **help);
+int StoreInfo(int argc, char **argv, void *data);
+int ToggleVerboseMode(int argc, char **argv);
+char *NullPrint(char **info);
+char *atot(char *itime);
+struct qelem *QueueTop(struct qelem *elem);
+Bool Confirm(char *prompt);
+Bool YesNoQuestion(char *prompt, int bool_def);
+Bool YesNoQuitQuestion(char *prompt, int bool_def);
+int do_mr_query(char *name, int argc, char **argv,
+               int (*proc)(int, char **, void *), void *hint);
+int GetTypeFromUser(char *prompt, char *tname, char **pointer);
+int GetAddressFromUser(char *prompt, char **pointer);
+Bool ValidName(char *s);
+int QueueCount(struct qelem *elem);
+int PromptWithDefault(char *prompt, char *buf, int buflen, char *def);
+struct qelem *GetTypeValues(char *tname);
+
+#endif /* _f_defs_ */
index 47963a944eafec189b158dd3ae31fc9a431aed04..ca2640863b5f01359a081bafc672b0eb1addfaca 100644 (file)
@@ -1,27 +1,23 @@
-#if (!defined(lint) && !defined(SABER))
-  static char rcsid_module_c[] = "$Header$";
-#endif
-
-/*     This is the file globals.c for the Moira Client, which allows users
+/* $Id $
+ *
+ *     This is the file globals.c for the Moira Client, which allows users
  *      to quickly and easily maintain most parts of the Moira database.
  *     It Contains:  globals variable definitions.
  *
  *     Created:        4/12/88
  *     By:             Chris D. Peterson
  *
- *      $Source$
- *      $Author$
- *      $Header$
- *
- *     Copyright 1988 by the Massachusetts Institute of Technology.
- *
- *     For further information on copyright and distribution
- *     see the file mit-copyright.h
+ * Copyright (C) 1988-1998 by the Massachusetts Institute of Technology.
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
  */
 
-#include "mit-copyright.h"
+#include <mit-copyright.h>
+#include <moira.h>
 #include "defs.h"
 
+RCSID("$Header$");
+
 Bool verbose;                  /* TRUE if verbose mode is active (default). */
 Bool found_some;               /* used by lists.c for determining if there
                                   are any members of a given type. */
index c1c02bd5032db64ef096d539ae5381578fa3b134..626e4e8d705a7196e15e00da1f36f694f1e5be9a 100644 (file)
@@ -1,21 +1,18 @@
-/*     This is the file globals.h for the Moira Client, which allows users
+/* $Id $
+ *
+ *     This is the file globals.h for the Moira Client, which allows users
  *      to quickly and easily maintain most parts of the Moira database.
  *     It Contains:  globals variable definitions.
  *
  *     Created:        4/12/88
  *     By:             Chris D. Peterson
  *
- *      $Source$
- *      $Author$
- *      $Header$
- *
- *     Copyright 1988 by the Massachusetts Institute of Technology.
- *
- *     For further information on copyright and distribution
- *     see the file mit-copyright.h
+ * Copyright (C) 1988-1998 by the Massachusetts Institute of Technology.
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
  */
 
-#include "mit-copyright.h"
+#include <mit-copyright.h>
 #include "defs.h"
 
 #ifndef _moira_client_globals_
index 1ff4c1cd115ca80c8c461205e416ca138fd7dda8..4776e71b1e53601d9699135b5a9da4a03afe5914 100644 (file)
@@ -1,35 +1,36 @@
-#if (!defined(lint) && !defined(SABER))
-  static char rcsid_module_c[] = "$Header$";
-#endif
-
-/*     This is the file lists.c for the Moira Client, which allows users
+/* $Id $
+ *
+ *     This is the file lists.c for the Moira Client, which allows users
  *      to quickly and easily maintain most parts of the Moira database.
  *     It Contains: All list manipulation functions, except delete.
  *
  *     Created:        4/12/88
  *     By:             Chris D. Peterson
  *
- *      $Source$
- *      $Author$
- *      $Header$
- *
- *     Copyright 1988 by the Massachusetts Institute of Technology.
- *
- *     For further information on copyright and distribution
- *     see the file mit-copyright.h
+ * Copyright (C) 1988-1998 by the Massachusetts Institute of Technology.
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
  */
 
-#include <stdio.h>
-#include <string.h>
+#include <mit-copyright.h>
 #include <moira.h>
 #include <moira_site.h>
-#include <menu.h>
-
-#include "mit-copyright.h"
 #include "defs.h"
 #include "f_defs.h"
 #include "globals.h"
 
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+RCSID("$Header$");
+
+struct qelem *GetListInfo(int type, char *name1, char *name2);
+char **AskListInfo(char **info, Bool name);
+int AddList(int argc, char **argv);
+void ListMembersByType(char *type);
+int GetMemberInfo(char *action, char **ret_argv);
+
 #define LIST    0
 #define MEMBERS 1
 #define GLOM    2
@@ -126,8 +127,7 @@ struct qelem *GetListInfo(int type, char *name1, char *name2)
     {
     case LIST:
       args[0] = name1;
-      if ((status = do_mr_query("get_list_info", 1, args,
-                               StoreInfo, (char *) &elem)))
+      if ((status = do_mr_query("get_list_info", 1, args, StoreInfo, &elem)))
        {
          com_err(program_name, status, " in get_list_info");
          return NULL;
@@ -136,7 +136,7 @@ struct qelem *GetListInfo(int type, char *name1, char *name2)
     case MEMBERS:
       args[0] = name1;
       if ((status = do_mr_query("get_members_of_list", 1, args,
-                               StoreInfo, (char *) &elem)))
+                               StoreInfo, &elem)))
        {
          com_err(program_name, status, " in get_members_of_list");
          return NULL;
@@ -146,7 +146,7 @@ struct qelem *GetListInfo(int type, char *name1, char *name2)
       args[0] = name1;
       args[1] = name2;
       if ((status = do_mr_query("get_lists_of_member", 2, args,
-                               StoreInfo, (char *) &elem)))
+                               StoreInfo, &elem)))
        {
          com_err(program_name, status, " in get_list_of_members");
          return NULL;
@@ -155,8 +155,7 @@ struct qelem *GetListInfo(int type, char *name1, char *name2)
     case ACE_USE:
       args[0] = name1;
       args[1] = name2;
-      if ((status = do_mr_query("get_ace_use", 2, args,
-                               StoreInfo, (char *) &elem)))
+      if ((status = do_mr_query("get_ace_use", 2, args, StoreInfo, &elem)))
        {
          com_err(program_name, status, " in get_ace_use");
          return NULL;
@@ -188,7 +187,7 @@ char **AskListInfo(char **info, Bool name)
     {
       while (1)
        {
-         newname = Strsave(info[L_NAME]);
+         newname = strdup(info[L_NAME]);
          if (GetValueFromUser("The new name for this list", &newname) ==
              SUB_ERROR)
            return NULL;
@@ -259,7 +258,7 @@ int ShowListInfo(int argc, char **argv)
   top = list = GetListInfo(LIST, argv[1], NULL);
   while (list)
     {
-      PrintListInfo((char **) list->q_data);
+      PrintListInfo(list->q_data);
       list = list->q_forw;
     }
 
@@ -292,7 +291,7 @@ static void RealUpdateList(char **info, Bool junk)
    */
   if ((strlen(args[2]) <= 8) &&
       do_mr_query("get_user_account_by_login", 1, args + 1,
-                 StoreInfo, (char *) &elem) != MR_NO_MATCH)
+                 StoreInfo, &elem) != MR_NO_MATCH)
     {
       char buf[256];
 
@@ -310,7 +309,7 @@ static void RealUpdateList(char **info, Bool junk)
     }
 
   if ((stat = do_mr_query("update_list", CountArgs(args), args,
-                         Scream, (char *) NULL)) != MR_SUCCESS)
+                         NULL, NULL)) != MR_SUCCESS)
     {
       com_err(program_name, stat, " in UpdateList.");
       Put_message("List ** NOT ** Updated.");
@@ -345,16 +344,16 @@ int UpdateList(int argc, char **argv)
 
 static char **SetDefaults(char **info, char *name)
 {
-  info[L_NAME] =     Strsave(name);
-  info[L_ACTIVE] =   Strsave(DEFAULT_ACTIVE);
-  info[L_PUBLIC] =   Strsave(DEFAULT_PUBLIC);
-  info[L_HIDDEN] =   Strsave(DEFAULT_HIDDEN);
-  info[L_MAILLIST] = Strsave(DEFAULT_MAILLIST);
-  info[L_GROUP] =    Strsave(DEFAULT_GROUP);
-  info[L_GID] =      Strsave(DEFAULT_GID);
-  info[L_ACE_TYPE] = Strsave(DEFAULT_ACE_TYPE);
-  info[L_ACE_NAME] = Strsave(DEFAULT_ACE_NAME);
-  info[L_DESC] =     Strsave(DEFAULT_DESCRIPTION);
+  info[L_NAME] =     strdup(name);
+  info[L_ACTIVE] =   strdup(DEFAULT_ACTIVE);
+  info[L_PUBLIC] =   strdup(DEFAULT_PUBLIC);
+  info[L_HIDDEN] =   strdup(DEFAULT_HIDDEN);
+  info[L_MAILLIST] = strdup(DEFAULT_MAILLIST);
+  info[L_GROUP] =    strdup(DEFAULT_GROUP);
+  info[L_GID] =      strdup(DEFAULT_GID);
+  info[L_ACE_TYPE] = strdup(DEFAULT_ACE_TYPE);
+  info[L_ACE_NAME] = strdup(DEFAULT_ACE_NAME);
+  info[L_DESC] =     strdup(DEFAULT_DESCRIPTION);
   info[L_MODTIME] = info[L_MODBY] = info[L_MODWITH] = info[L_END] = NULL;
   return info;
 }
@@ -373,7 +372,7 @@ int AddList(int argc, char **argv)
 
   if (!ValidName(argv[1]))
     return DM_NORMAL;
-  status = do_mr_query("get_list_info", 1, argv + 1, NullFunc, NULL);
+  status = do_mr_query("get_list_info", 1, argv + 1, NULL, NULL);
   if (status != MR_NO_MATCH)
     {
       if (status == MR_SUCCESS)
@@ -389,7 +388,7 @@ int AddList(int argc, char **argv)
    */
   if ((strlen(argv[1]) <= 8) &&
       do_mr_query("get_user_account_by_login", 1, argv + 1,
-                 StoreInfo, (char *) &elem) != MR_NO_MATCH)
+                 StoreInfo, &elem) != MR_NO_MATCH)
     {
       char buf[256];
 
@@ -409,7 +408,7 @@ int AddList(int argc, char **argv)
     }
 
   if ((status = do_mr_query("add_list", CountArgs(add_args), add_args,
-                           Scream, (char *) NULL)) != MR_SUCCESS)
+                           NULL, NULL)) != MR_SUCCESS)
     {
       com_err(program_name, status, " in AddList.");
       Put_message("List Not Created.");
@@ -426,7 +425,7 @@ int AddList(int argc, char **argv)
  *     Returns: DM Status Code.
  */
 
-int ListHelp(void)
+int ListHelp(int argc, char **argv)
 {
   static char *message[] = {
     "Listmaint handles the creation, deletion, and updating of lists.",
@@ -476,7 +475,7 @@ int ListmaintMemberMenuEntry(Menu *m, int argc, char **argv)
   else
     /* All we want to know is if it exists. */
     switch ((stat = do_mr_query("count_members_of_list", 1, argv + 1,
-                               NullFunc, NULL)))
+                               NULL, NULL)))
       {
       case MR_SUCCESS:
        break;
@@ -492,7 +491,7 @@ int ListmaintMemberMenuEntry(Menu *m, int argc, char **argv)
       }
 
   sprintf(temp_buf, "Change/Display membership of '%s'", list_name);
-  m->m_title = Strsave(temp_buf);
+  m->m_title = strdup(temp_buf);
   strcpy(current_list, list_name);
   return DM_NORMAL;
 }
@@ -518,7 +517,7 @@ int ListmaintMemberMenuExit(Menu *m)
  *      NOTE: if type is NULL, all lists members are listed.
  */
 
-int ListMembersByType(char *type)
+void ListMembersByType(char *type)
 {
   char temp_buf[BUFSIZ];
   int status;
@@ -530,10 +529,7 @@ int ListMembersByType(char *type)
   found_some = FALSE;
   if ((status = do_mr_query("get_members_of_list", CountArgs(args), args,
                            PrintByType, type)))
-    {
-      com_err(program_name, status, " in ListMembersByType");
-      return DM_NORMAL;
-    }
+    com_err(program_name, status, " in ListMembersByType");
   if (!found_some)
     {
       if (!type)
@@ -552,7 +548,7 @@ int ListMembersByType(char *type)
  *     Returns: DM_NORMAL
  */
 
-int ListAllMembers(void)
+int ListAllMembers(int argc, char **argv)
 {
   ListMembersByType(NULL);
   return DM_NORMAL;
@@ -564,7 +560,7 @@ int ListAllMembers(void)
  *     Returns: DM_NORMAL.
  */
 
-int ListUserMembers(void)
+int ListUserMembers(int argc, char **argv)
 {
   ListMembersByType("USER");
   return DM_NORMAL;
@@ -576,7 +572,7 @@ int ListUserMembers(void)
  *     Returns: DM_NORMAL.
  */
 
-int ListListMembers(void)
+int ListListMembers(int argc, char **argv)
 {
   ListMembersByType("LIST");
   return DM_NORMAL;
@@ -588,7 +584,7 @@ int ListListMembers(void)
  *     Returns: DM_NORMAL.
  */
 
-int ListStringMembers(void)
+int ListStringMembers(int argc, char **argv)
 {
   ListMembersByType("STRING");
   return DM_NORMAL;
@@ -608,15 +604,15 @@ int GetMemberInfo(char *action, char **ret_argv)
 {
   char temp_buf[BUFSIZ];
 
-  ret_argv[LM_LIST] = Strsave(current_list);
+  ret_argv[LM_LIST] = strdup(current_list);
 
-  ret_argv[LM_TYPE] = Strsave("user");
+  ret_argv[LM_TYPE] = strdup("user");
   if (GetTypeFromUser("Type of member", "member", &ret_argv[LM_TYPE]) ==
       SUB_ERROR)
     return SUB_ERROR;
 
   sprintf(temp_buf, "Name of %s to %s", ret_argv[LM_TYPE], action);
-  ret_argv[LM_MEMBER] = Strsave(user);
+  ret_argv[LM_MEMBER] = strdup(user);
   if (GetValueFromUser(temp_buf, &ret_argv[LM_MEMBER]) == SUB_ERROR)
     return SUB_ERROR;
   ret_argv[LM_END] = NULL;             /* NULL terminate this list. */
@@ -636,11 +632,11 @@ int GetMemberInfo(char *action, char **ret_argv)
  *     Returns: DM_NORMAL.
  */
 
-int AddMember(void)
+int AddMember(int argc, char **argv)
 {
   char *args[10], temp_buf[BUFSIZ], *p;
   int status;
-  struct qelem *mailhubs, *elem, *GetTypeValues();
+  struct qelem *mailhubs, *elem;
 
   if (GetMemberInfo("add", args) == SUB_ERROR)
     return DM_NORMAL;
@@ -649,14 +645,14 @@ int AddMember(void)
     {
       if ((p = strchr(args[LM_MEMBER], '@')))
        {
-         char *host = canonicalize_hostname(strsave(++p));
+         char *host = canonicalize_hostname(strdup(++p));
          mailhubs = GetTypeValues("mailhub");
          for (elem = mailhubs; elem; elem = elem->q_forw)
            {
              if (!strcasecmp(host, elem->q_data))
                {
                  free(host);
-                 host = strsave(args[LM_MEMBER]);
+                 host = strdup(args[LM_MEMBER]);
                  *(--p) = 0;
                  sprintf(temp_buf, "String \"%s\" should be USER or LIST "
                          "\"%s\" because it is a local name.", host,
@@ -678,7 +674,7 @@ int AddMember(void)
     }
 
   if ((status = do_mr_query("add_member_to_list", CountArgs(args), args,
-                           Scream, NULL)) != MR_SUCCESS)
+                           NULL, NULL)) != MR_SUCCESS)
     {
       if (status == MR_EXISTS)
        {
@@ -700,7 +696,7 @@ int AddMember(void)
  *     Returns: DM_NORMAL
  */
 
-int DeleteMember(void)
+int DeleteMember(int argc, char **argv)
 {
   char *args[10];
   int status;
@@ -711,7 +707,7 @@ int DeleteMember(void)
   if (Confirm("Are you sure you want to delete this member?"))
     {
       if ((status = do_mr_query("delete_member_from_list", CountArgs(args),
-                               args, Scream, NULL)))
+                               args, NULL, NULL)))
        com_err(program_name, status, " in DeleteMember");
       else
        Put_message("Deletion Completed.");
@@ -732,18 +728,18 @@ int DeleteMember(void)
  *             enough information in it to delete the member from the list.
  */
 
-int InterRemoveItemFromLists(void)
+int InterRemoveItemFromLists(int argc, char **argv)
 {
   int status;
   char *type, *name, *args[10], buf[BUFSIZ];
   struct qelem *top, *elem;
 
-  type = strsave("USER");
+  type = strdup("USER");
   if (GetTypeFromUser("Type of member", "member", &type) == SUB_ERROR)
     return DM_NORMAL;
 
   sprintf(buf, "Name of %s", type);
-  name = strsave(user);
+  name = strdup(user);
   if (GetValueFromUser(buf, &name) == SUB_ERROR)
     return DM_NORMAL;
 
@@ -755,7 +751,7 @@ int InterRemoveItemFromLists(void)
   while (elem)
     {
       char line[BUFSIZ];
-      char **info = (char **) elem->q_data;
+      char **info = elem->q_data;
       sprintf(line, "Delete %s %s from the list \"%s\" (y/n/q)? ", type,
              name, info[GLOM_NAME]);
       switch (YesNoQuitQuestion(line, FALSE))
@@ -766,7 +762,7 @@ int InterRemoveItemFromLists(void)
          args[DM_TYPE] = type;
          args[DM_MEMBER] = name;
          if ((status = do_mr_query("delete_member_from_list", 3, args,
-                                   Scream, (char *) NULL)))
+                                   NULL, NULL)))
            {
              /* should probabally check to delete list. */
              com_err(program_name, status, " in delete_member");
@@ -793,25 +789,25 @@ int InterRemoveItemFromLists(void)
  *     Returns: DM_NORMAL.
  */
 
-int ListByMember(void)
+int ListByMember(int argc, char **argv)
 {
   char buf[BUFSIZ], temp_buf[BUFSIZ], *type, *name, **info;
   Bool maillist, group;
   struct qelem *top, *elem;
 
-  type = strsave("USER");
+  type = strdup("USER");
   if (GetTypeFromUser("Type of member", "member", &type) == SUB_ERROR)
     return DM_NORMAL;
 
   sprintf(buf, "Name of %s", type);
-  name = strsave(user);
+  name = strdup(user);
   if (GetValueFromUser(buf, &name) == SUB_ERROR)
     return DM_NORMAL;
 
   /* What we really want is a recursive search */
   sprintf(temp_buf, "R%s", type);
   free(type);
-  type = Strsave(temp_buf);
+  type = strdup(temp_buf);
 
   if ((maillist = YesNoQuestion("Show Lists that are Maillists (y/n) ?",
                                TRUE)) == -1)
@@ -824,7 +820,7 @@ int ListByMember(void)
 
   while (elem)
     {
-      info = (char **) elem->q_data;
+      info = elem->q_data;
       if ((maillist == TRUE && !strcmp(info[GLOM_MAILLIST], "1")) ||
          (group == TRUE && !strcmp(info[GLOM_GROUP], "1")))
        Put_message(info[GLOM_NAME]);
@@ -841,17 +837,17 @@ int ListByMember(void)
  *     Returns: DM_NORMAL.
  */
 
-int ListByAdministrator(void)
+int ListByAdministrator(int argc, char **argv)
 {
   char buf[BUFSIZ], temp_buf[BUFSIZ], *type, *name;
   struct qelem *top;
 
-  type = strsave("USER");
+  type = strdup("USER");
   if (GetTypeFromUser("Type of member", "member", &type) == SUB_ERROR)
     return DM_NORMAL;
 
   sprintf(buf, "Name of %s", type);
-  name = strsave(user);
+  name = strdup(user);
   if (GetValueFromUser(buf, &name) == SUB_ERROR)
     return DM_NORMAL;
 
@@ -860,7 +856,7 @@ int ListByAdministrator(void)
     case TRUE:
       sprintf(temp_buf, "R%s", type);  /* "USER" to "RUSER" etc. */
       free(type);
-      type = Strsave(temp_buf);
+      type = strdup(temp_buf);
       break;
     case FALSE:
       break;
@@ -881,7 +877,7 @@ int ListByAdministrator(void)
  *     Returns: DM_NORMAL.
  */
 
-int ListAllPublicMailLists(void)
+int ListAllPublicMailLists(int argc, char **argv)
 {
   int status;
   static char *args[] = {
@@ -895,8 +891,8 @@ int ListAllPublicMailLists(void)
   if (YesNoQuestion("This query will take a while. Do you wish to continue?",
                    TRUE) == TRUE)
     {
-      if (status = do_mr_query("qualified_get_lists", 5, args,
-                              Print, NULL) != MR_SUCCESS)
+      if ((status = do_mr_query("qualified_get_lists", 5, args,
+                               Print, NULL)) != MR_SUCCESS)
        com_err(program_name, status, " in ListAllGroups");
     }
 
index e668fb3ad190d0e9fd476bfaf21c21ad405c1d86..3507931fd9ae6981ed3aed127e09255d6a3621ac 100644 (file)
@@ -1,37 +1,35 @@
-#if (!defined(lint) && !defined(SABER))
-  static char rcsid_module_c[] = "$Header$";
-#endif
-
-/*     This is the file main.c for the Moira Client, which allows users
+/* $Id $
+ *
+ *     This is the file main.c for the Moira Client, which allows users
  *      to quickly and easily maintain most parts of the Moira database.
  *     It Contains: The main driver for the Moira Client.
  *
  *     Created:        4/12/88
  *     By:             Chris D. Peterson
  *
- *      $Source$
- *      $Author$
- *      $Header$
- *
- *     Copyright 1988 by the Massachusetts Institute of Technology.
- *
- *     For further information on copyright and distribution
- *     see the file mit-copyright.h
+ * Copyright (C) 1988-1998 by the Massachusetts Institute of Technology.
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
  */
 
+#include <mit-copyright.h>
+#include <moira.h>
+#include "defs.h"
+#include "f_defs.h"
+#include "globals.h"
+
 #include <pwd.h>
 #include <signal.h>
 #include <stdio.h>
 #include <string.h>
-#include <sys/types.h>
-#include <moira.h>
-#include <menu.h>
-#include <krb_et.h>
+#include <unistd.h>
 
-#include "mit-copyright.h"
-#include "defs.h"
-#include "f_defs.h"
-#include "globals.h"
+RCSID("$Header$");
+
+static void ErrorExit(char *buf, int status);
+static void Usage(void);
+static void Signal_Handler(void);
+static void CatchInterrupt(void);
 
 char *whoami;                  /* used by menu.c ugh!!! */
 char *moira_server;
@@ -39,13 +37,6 @@ int interrupt = 0;
 
 extern Menu moira_top_menu, list_menu, user_menu, dcm_menu;
 
-static void Signal_Handler(), CatchInterrupt();
-
-static void ErrorExit(), Usage();
-char *getlogin();
-uid_t getuid();
-struct passwd *getpwuid();
-
 Bool use_menu = TRUE;          /* whether or not we are using a menu. */
 
 /*     Function Name: main
@@ -63,14 +54,14 @@ void main(int argc, char **argv)
 
   if (!(user = getlogin()))
     user = getpwuid(getuid())->pw_name;
-  user = (user && strlen(user)) ? Strsave(user) : "";
+  user = (user && strlen(user)) ? strdup(user) : "";
 
   if (!(program_name = strrchr(argv[0], '/')))
     program_name = argv[0];
   else
     program_name++;
-  program_name = Strsave(program_name);
-  whoami = Strsave(program_name); /* used by menu.c,  ugh !!! */
+  program_name = strdup(program_name);
+  whoami = strdup(program_name); /* used by menu.c,  ugh !!! */
 
   verbose = TRUE;
   arg = argv;
@@ -91,10 +82,10 @@ void main(int argc, char **argv)
                  ++arg;
                  moira_server = *arg;
                } else
-                 Usage(argv);
+                 Usage();
            }
          else
-           Usage(argv);
+           Usage();
        }
     }
 
@@ -136,14 +127,14 @@ void main(int argc, char **argv)
 
   sigemptyset(&act.sa_mask);
   act.sa_flags = 0;
-  act.sa_handler = (void (*)()) Signal_Handler;
+  act.sa_handler = Signal_Handler;
   sigaction(SIGHUP, &act, NULL);
   sigaction(SIGQUIT, &act, NULL);
   if (use_menu)
     sigaction(SIGINT, &act, NULL);
   else
     {
-      act.sa_handler = (void (*)()) CatchInterrupt;
+      act.sa_handler = CatchInterrupt;
       sigaction(SIGINT, &act, NULL);
     }
 
index b0b87e292b865fc94754d63b1db58920740a873f..b0a9a18528c4060c23594e4ef8381097db920c3f 100644 (file)
@@ -1,40 +1,25 @@
-/*
- * Copyright 1987 by the Massachusetts Institute of Technology.
- * For copying and distribution information, see the file
- * "mit-copyright.h".
- *
- * $Source$
- * $Author$
- * $Header$
+/* $Id $
  *
  * Generic menu system module.
  *
- * Basically, we define an enormous tree structure which represents the
- * menu.  Some extra pieces (ml_command, ma_doc) get thrown in so we can
- * also use the structure for a command-based system.
- *
- * By making the menu descriptions so general, we can ease porting to just
- * about anything.
+ * Copyright (C) 1987-1998 by the Massachusetts Institute of Technology.
+ * For copying and distribution information, see the file
+ * <mit-copyright.h>.
  */
 
-#ifndef lint
-static char rcsid_menu_c[] = "$Header$";
-#endif
-
 #include <mit-copyright.h>
-#include <sys/types.h>
+#include <moira.h>
+#include "menu.h"
+
+#include <ctype.h>
+#include <curses.h>
+#include <signal.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-#include <signal.h>
-#include <curses.h>
 #include <unistd.h>
-#include <termios.h>
-#include <stdarg.h>
-#include <ctype.h>
-#include <com_err.h>
-#include <moira.h>
-#include "menu.h"
+
+RCSID("$Header$");
 
 #define MAX(A, B)      ((A) > (B) ? (A) : (B))
 #define MIN(A, B)      ((A) < (B) ? (A) : (B))
@@ -63,17 +48,26 @@ Menu *top_menu;                     /* Root for command search */
 int parsed_argc;               /* used by extern routines to get additional */
 char **parsed_argv;            /*   comand line input */
 
+int Parse_words(char *buf, char *argv[], int n);
+void refresh_ms(struct menu_screen *ms);
+void Put_line(char *msg);
+void menu_com_err_hook(const char *who, long code, const char *fmt, ...);
+struct menu_screen *make_ms(int length);
+void destroy_ms(struct menu_screen *ms);
+struct menu_line *find_command_from(char *c, struct menu *m, int d);
+struct menu_line *Find_command(Menu *m, char *command);
+int toggle_logging(int argc, char *argv[]);
+
 /*
  * Hook function to cause error messages to be printed through
  * curses instead of around it.  Takes at most 5 args to the
  * printf string (crock...)
  */
 
-void menu_com_err_hook(const char *who, long code, const char *fmt,
-                      caddr_t arg1, caddr_t arg2, caddr_t arg3,
-                      caddr_t arg4, caddr_t arg5)
+void menu_com_err_hook(const char *who, long code, const char *fmt, ...)
 {
   char buf[BUFSIZ], *cp;
+  va_list ap;
 
   strcpy(buf, who);
   for (cp = buf; *cp; cp++)
@@ -86,7 +80,9 @@ void menu_com_err_hook(const char *who, long code, const char *fmt,
       while (*cp)
        cp++;
     }
-  sprintf(cp, fmt, arg1, arg2, arg3, arg4, arg5);
+  va_start(ap, fmt);
+  vsprintf(cp, fmt, ap);
+  va_end(ap);
   Put_message(buf);
 }
 
@@ -96,9 +92,8 @@ void menu_com_err_hook(const char *who, long code, const char *fmt,
  * if user functions which run their own menus don't cooperate.)
  * Start_menu should only be called once, at the start of the program.
  */
-int Start_menu(Menu *m)
+void Start_menu(Menu *m)
 {
-  struct menu_screen *make_ms();
   void (*old_hook)(const char *, long, const char *, va_list) =
     set_com_err_hook((void (*) (const char *, long, const char *, va_list))menu_com_err_hook);
 
@@ -120,7 +115,7 @@ int Start_menu(Menu *m)
   Cleanup_menu();
 }
 
-int Cleanup_menu(void)
+void Cleanup_menu(void)
 {
   if (cur_ms)
     {
@@ -132,7 +127,7 @@ int Cleanup_menu(void)
 
 
 /* Like Start_menu, except it doesn't print menus and doesn't use curses */
-int Start_no_menu(Menu *m)
+void Start_no_menu(Menu *m)
 {
   cur_ms = NULLMS;
   COLS = 80;
@@ -173,7 +168,7 @@ struct menu_screen *make_ms(int length)
 /*
  * This routine destroys a menu_screen.
  */
-int destroy_ms(struct menu_screen *ms)
+void destroy_ms(struct menu_screen *ms)
 {
   delwin(ms->ms_title);
   delwin(ms->ms_menu);
@@ -195,10 +190,9 @@ int Do_menu(Menu *m, int margc, char *margv[])
   char *argv[MAX_ARGC];
   int line;
   int i;
-  struct menu_line *command, *Find_command();
+  struct menu_line *command;
   int argc;
   int quitflag, is_topmenu = (margc < 0);
-  int toggle_logging();
 
   /* Entry function gets called with old menu_screen still current */
   if (m->m_entry != NULLFUNC)
@@ -413,7 +407,7 @@ int Do_menu(Menu *m, int margc, char *margv[])
     }
 }
 
-int refresh_screen(void)
+void refresh_screen(void)
 {
   if (cur_ms != NULLMS)
     {
@@ -555,7 +549,7 @@ int lines_left;
 /* Start paging */
 /* This routine will cause the most recently put message to be the
    one at the top of the screen when a ---More--- prompt is displayed */
-int Start_paging(void)
+void Start_paging(void)
 {
   if (cur_ms != NULLMS)
     lines_left = LINES - cur_ms->ms_input_y - 1;
@@ -564,13 +558,13 @@ int Start_paging(void)
 }
 
 /* Turn off paging */
-int Stop_paging(void)
+void Stop_paging(void)
 {
   lines_left = -1;
 }
 
 /* Print a message in the input window of cur_ms.  */
-int Put_message(char *msg)
+void Put_message(char *msg)
 {
   char *copy, *line, *s;
 
@@ -607,7 +601,7 @@ int Put_message(char *msg)
 }
 
 /* Will be truncated to COLS characters.  */
-int Put_line(char *msg)
+void Put_line(char *msg)
 {
   int y, x, i;
   char *msg1, chr;
@@ -660,7 +654,7 @@ int Put_line(char *msg)
 }
 
 /* Refresh a menu_screen onto the real screen */
-int refresh_ms(struct menu_screen *ms)
+void refresh_ms(struct menu_screen *ms)
 {
   wrefresh(ms->ms_title);
   wrefresh(ms->ms_menu);
index b6b513d02fb13235150c990adce432410e2fbee7..374a6fd9e21673e82bdb494f939fb6e0e4c4c487 100644 (file)
@@ -1,4 +1,4 @@
-/* $Header$ */
+/* $Id $ */
 
 #define MAX_ARGC 16            /* Maximum argument count per line */
 #define MAX_ARGLEN 128         /* Maximum length of an argument */
@@ -15,7 +15,7 @@ typedef struct menu_arg {
 } Menu_Arg;
 
 typedef struct menu_line {
-  int (*ml_function)();
+  int (*ml_function)(int argc, char **argv);
   struct menu *ml_submenu;
   int ml_argc;
   struct menu_arg ml_args[MAX_ARGC];
@@ -25,8 +25,8 @@ typedef struct menu_line {
 #define ml_command ml_args[0].ma_doc
 
 typedef struct menu {
-  int (*m_entry)();
-  int (*m_exit)();
+  int (*m_entry)(struct menu *m, int argc, char **argv);
+  int (*m_exit)(struct menu *m);
   char *m_title;
   int m_length;
   struct menu_line m_lines[MAX_LINES];
@@ -38,7 +38,7 @@ typedef struct menu {
 #define DM_QUIT 1              /* Quit; ^C or q command received */
 
 /* Macros for initializing menu lines */
-#define NULLFUNC ((int (*)()) 0)
+#define NULLFUNC (0)
 #define NULLMENU NULL
 #define SUBMENU(cmd, doc, menu) { NULLFUNC, menu, 1, { { cmd, doc } } }
 #define SIMPLEFUNC(cmd, doc, func) { func, NULLMENU, 1, { { cmd, doc } } }
@@ -46,3 +46,14 @@ typedef struct menu {
 /* Unused words found on parsed command line */
 extern int parsed_argc;
 extern char **parsed_argv;
+
+/* prototypes */
+void Put_message(char *msg);
+void Start_menu(Menu *m);
+void Start_no_menu(Menu *m);
+int Do_menu(Menu *m, int margc, char *margv[]);
+void Cleanup_menu(void);
+void Start_paging(void);
+void Stop_paging(void);
+int Prompt_input(char *prompt, char *buf, int buflen);
+void refresh_screen(void);
index 7233bae9bda747e630516d58fa820b82cdadd5eb..15c8b73db27099b6fd215c6c45e0e99a5af338de 100644 (file)
@@ -1,32 +1,26 @@
-#if (!defined(lint) && !defined(SABER))
-  static char rcsid_module_c[] = "$Header$";
-#endif
-
-/*     This is the file menus.c for the Moira Client, which allows users
+/* $Id $
+ *
+ *     This is the file menus.c for the Moira Client, which allows users
  *      to quickly and easily maintain most parts of the Moira database.
  *     It Contains: All menu definitions.
  *
  *     Created:        4/11/88
  *     By:             Chris D. Peterson
  *
- *      $Source$
- *      $Author$
- *      $Header$
- *
- *     Copyright 1988 by the Massachusetts Institute of Technology.
- *
- *     For further information on copyright and distribution
- *     see the file mit-copyright.h
+ * Copyright (C) 1988-1998 by the Massachusetts Institute of Technology.
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
  */
 
-#include <stdio.h>
-#include <menu.h>
-
-#include "mit-copyright.h"
+#include <mit-copyright.h>
+#include <moira.h>
 #include "defs.h"
 #include "f_defs.h"
 #include "globals.h"
 
+#include <stdio.h>
+
+RCSID("$Header$");
 
 /* ------------------------- Second Tier Menus ------------------------- */
 
index ec77ba59460288ecd71d838bda0fce0c46140f6a..8ac7d7b024ab13531d4199647052743e9105a848 100644 (file)
@@ -1,4 +1,6 @@
-/*     This is the file misc.c for the Moira Client, which allows a naieve
+/* $Id $
+ *
+ *     This is the file misc.c for the Moira Client, which allows a naieve
  *      to quickly and easily maintain most parts of the Moira database.
  *     It Contains:
  *             TableStats
  *     Created:        5 October 1988
  *     By:             Mark A. Rosenstein
  *
- *      $Source$
- *      $Author$
- *      $Header$
- *
- *     Copyright 1988 by the Massachusetts Institute of Technology.
- *
- *     For further information on copyright and distribution
- *     see the file mit-copyright.h
+ * Copyright (C) 1988-1998 by the Massachusetts Institute of Technology.
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
  */
 
-#include <stdio.h>
-#include <string.h>
+#include <mit-copyright.h>
 #include <moira.h>
 #include <moira_site.h>
-#include <menu.h>
+#include "defs.h"
+#include "f_defs.h"
+#include "globals.h"
+
 #include <sys/types.h>
-#include <netdb.h>
 #include <sys/socket.h>
 #include <netinet/in.h>
+#include <arpa/inet.h>
+#include <netdb.h>
 
-#include "mit-copyright.h"
-#include "defs.h"
-#include "f_defs.h"
-#include "globals.h"
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+RCSID("$Header$");
 
+void PrintStats(char **info);
+void PrintClients(char **info);
+void PrintValue(char **info);
+void PrintAlias(char **info);
 
 /*     Function Name: PrintStats
  *     Description: print statistics from argv
@@ -40,7 +45,7 @@
  *     Returns: DM_NORMAL
  */
 
-int PrintStats(char **info)
+void PrintStats(char **info)
 {
   char buf[BUFSIZ];
 
@@ -58,13 +63,12 @@ int PrintStats(char **info)
  *     Returns: DM_NORMAL
  */
 
-int TableStats(void)
+int TableStats(int argc, char **argv)
 {
   int status;
   struct qelem *elem = NULL;
 
-  if ((status = do_mr_query("get_all_table_stats", 0, NULL,
-                           StoreInfo, (char *)&elem)))
+  if ((status = do_mr_query("get_all_table_stats", 0, NULL, StoreInfo, &elem)))
     {
       com_err(program_name, status, " in TableStats");
       return DM_NORMAL;
@@ -80,7 +84,7 @@ int TableStats(void)
  *     Arguments: argv
  */
 
-int PrintClients(char **info)
+void PrintClients(char **info)
 {
   char buf[BUFSIZ];
   unsigned long host_address;
@@ -93,7 +97,7 @@ int PrintClients(char **info)
       if (host_entry)
        {
          free(info[1]);
-         info[1] = Strsave(host_entry->h_name);
+         info[1] = strdup(host_entry->h_name);
        }
     }
   sprintf(buf, "Principal %s on %s (%s)", info[0], info[1], info[2]);
@@ -109,13 +113,12 @@ int PrintClients(char **info)
  *     Returns: DM_NORMAL
  */
 
-int ShowClients(void)
+int ShowClients(int argc, char **argv)
 {
   int status;
   struct qelem *elem = NULL;
 
-  if ((status = do_mr_query("_list_users", 0, NULL,
-                           StoreInfo, (char *) &elem)))
+  if ((status = do_mr_query("_list_users", 0, NULL, StoreInfo, &elem)))
     {
       com_err(program_name, status, " in ShowClients");
       return DM_NORMAL;
@@ -131,7 +134,7 @@ int ShowClients(void)
  *     Arguments: argv
  */
 
-int PrintValue(char **info)
+void PrintValue(char **info)
 {
   char buf[BUFSIZ];
 
@@ -151,8 +154,7 @@ int ShowValue(int argc, char **argv)
   int status;
   struct qelem *elem = NULL;
 
-  if ((status = do_mr_query("get_value", 1, &argv[1],
-                           StoreInfo, (char *) &elem)))
+  if ((status = do_mr_query("get_value", 1, &argv[1], StoreInfo, &elem)))
     {
       com_err(program_name, status, " in ShowValue");
       return DM_NORMAL;
@@ -168,7 +170,7 @@ int ShowValue(int argc, char **argv)
  *     Arguments: argv
  */
 
-int PrintAlias(char **info)
+void PrintAlias(char **info)
 {
   char buf[BUFSIZ];
 
@@ -193,8 +195,7 @@ int ShowAlias(int argc, char **argv)
   info[0] = argv[1];
   info[1] = argv[2];
   info[2] = "*";
-  if ((status = do_mr_query("get_alias", 3, info,
-                           StoreInfo, (char *) &elem)))
+  if ((status = do_mr_query("get_alias", 3, info, StoreInfo, &elem)))
     {
       com_err(program_name, status, " in ShowAlias");
       return DM_NORMAL;
index e9325d6718a709ce0020e0afc2f55f7e9b4638ec..17eb2005e5d9b8efd71466b0aa951893ac5bf540 100644 (file)
@@ -1,43 +1,44 @@
-#if (!defined(lint) && !defined(SABER))
-  static char rcsid_module_c[] = "$Header$";
-#endif
-
-/*     This is the file main.c for the Moira Client, which allows users
+/* $Id $
+ *
+ *     This is the file main.c for the Moira Client, which allows users
  *      to quickly and easily maintain most parts of the Moira database.
  *     It Contains: The main driver for the Moira Client.
  *
  *     Created:        4/12/88
  *     By:             Chris D. Peterson
  *
- *      $Source$
- *      $Author$
- *      $Header$
- *
- *     Copyright 1988 by the Massachusetts Institute of Technology.
- *
- *     For further information on copyright and distribution
- *     see the file mit-copyright.h
+ * Copyright (C) 1988-1998 by the Massachusetts Institute of Technology.
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
  */
 
-#include <pwd.h>
+#include <mit-copyright.h>
+#include <moira.h>
+#include "defs.h"
+#include "f_defs.h"
+#include "globals.h"
+
 #include <signal.h>
 #include <stdio.h>
 #include <string.h>
+#if 0
+#include <pwd.h>
 #include <sys/types.h>
-#include <moira.h>
-#include <menu.h>
+#endif
+
 #include <krb.h>
 
+RCSID("$Header$");
 
-#include "mit-copyright.h"
-#include "defs.h"
-#include "f_defs.h"
-#include "globals.h"
+static void ErrorExit(char *buf, int status);
+static void Usage(void);
+static void Signal_Handler(void);
+static void CatchInterrupt(void);
+int NewListHelp(int argc, char **argv);
 
 char *whoami;                  /* used by menu.c ugh!!! */
 char *moira_server;
 int interrupt = 0;
-int NewListHelp();
 
 /*
  * List Information Menu
@@ -163,14 +164,6 @@ Menu namespace_menu = {
   }
 };
 
-
-static void Signal_Handler(), CatchInterrupt();
-
-static void ErrorExit(), Usage();
-char *getlogin();
-uid_t getuid();
-struct passwd *getpwuid();
-
 Bool use_menu = TRUE;          /* whether or not we are using a menu. */
 
 /*     Function Name: main
@@ -191,8 +184,8 @@ void main(int argc, char **argv)
     program_name = argv[0];
   else
     program_name++;
-  program_name = Strsave(program_name);
-  whoami = Strsave(program_name); /* used by menu.c,  ugh !!! */
+  program_name = strdup(program_name);
+  whoami = strdup(program_name); /* used by menu.c,  ugh !!! */
 
   verbose = TRUE;
   arg = argv;
@@ -211,9 +204,9 @@ void main(int argc, char **argv)
                moira_server = *arg;
              }
            else
-             Usage(argv);
+             Usage();
          else
-           Usage(argv);
+           Usage();
        }
     }
 
@@ -230,7 +223,7 @@ void main(int argc, char **argv)
       exit(1);
     }
   tf_close();
-  user = Strsave(pname);
+  user = strdup(pname);
 
   if ((status = mr_motd(&motd)))
     ErrorExit("\nUnable to check server status", status);
@@ -261,14 +254,14 @@ void main(int argc, char **argv)
 
   sigemptyset(&act.sa_mask);
   act.sa_flags = 0;
-  act.sa_handler = (void (*)()) Signal_Handler;
+  act.sa_handler = Signal_Handler;
   sigaction(SIGHUP, &act, NULL);
   sigaction(SIGQUIT, &act, NULL);
   if (use_menu)
     sigaction(SIGINT, &act, NULL);
   else
     {
-      act.sa_handler = (void (*)()) CatchInterrupt;
+      act.sa_handler = CatchInterrupt;
       sigaction(SIGINT, &act, NULL);
     }
 
@@ -338,13 +331,13 @@ static void CatchInterrupt(void)
 
 /* Dummy routine to be able to link against the rest of the moira client */
 
-int DeleteUser(void)
+int DeleteUser(int argc, char **argv)
 {
   return DM_QUIT;
 }
 
 
-int NewListHelp(void)
+int NewListHelp(int argc, char **argv)
 {
   static char *message[] = {
     "A list can be a mailing list, an Athena group list, or both.  Each",
index b7ea9f5ca9c6d93c18ea239334c1e07e99803656..47ae6195b31f23c345edcb50dc88a4c6e1a68654 100644 (file)
@@ -1,35 +1,31 @@
-#if (!defined(lint) && !defined(SABER))
-  static char rcsid_module_c[] = "$Header$";
-#endif
-
-/*     This is the file nfs.c for the Moira Client, which allows users
+/* $Id $
+ *
+ *     This is the file nfs.c for the Moira Client, which allows users
  *      to quickly and easily maintain most parts of the Moira database.
  *     It Contains: All functions for manipulating NFS Physical directories.
  *
  *     Created:        5/6/88
  *     By:             Chris D. Peterson
  *
- *      $Source$
- *      $Author$
- *      $Header$
- *
- *     Copyright 1988 by the Massachusetts Institute of Technology.
- *
- *     For further information on copyright and distribution
- *     see the file mit-copyright.h
+ * Copyright (C) 1988-1998 by the Massachusetts Institute of Technology.
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
  */
 
-#include <stdio.h>
-#include <string.h>
+#include <mit-copyright.h>
 #include <moira.h>
 #include <moira_site.h>
-#include <menu.h>
-
-#include "mit-copyright.h"
 #include "defs.h"
 #include "f_defs.h"
 #include "globals.h"
 
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+RCSID("$Header$");
+
+char **AskNFSInfo(char **info);
 
 #define TYPE_NFS    "NFS"
 
@@ -49,7 +45,7 @@ static char *UpdatePrint(char **info)
 {
   char temp_buf[BUFSIZ];
   sprintf(temp_buf, "Machine %s Directory %s", info[NFS_NAME], info[NFS_DIR]);
-  return Strsave(temp_buf);    /* Small memory leak here, but no good way
+  return strdup(temp_buf);     /* Small memory leak here, but no good way
                                   to avoid it that I see. */
 }
 
@@ -165,13 +161,12 @@ int ShowNFSService(int argc, char **argv)
   if (!ValidName(argv[1]))
     return DM_NORMAL;
 
-  args[0] = canonicalize_hostname(strsave(argv[1]));
-  args[1] = strsave(DEFAULT_DIR);
+  args[0] = canonicalize_hostname(strdup(argv[1]));
+  args[1] = strdup(DEFAULT_DIR);
   if (GetValueFromUser("Directory:", &args[1]) == SUB_ERROR)
     return DM_NORMAL;
 
-  if ((stat = do_mr_query("get_nfsphys", 2, args,
-                         StoreInfo, &elem)))
+  if ((stat = do_mr_query("get_nfsphys", 2, args, StoreInfo, &elem)))
     com_err(program_name, stat, " in ShowNFSServices.");
   free(args[0]);
   free(args[1]);               /* prevents memory leaks. */
@@ -195,15 +190,15 @@ int AddNFSService(int argc, char **argv)
   char *info[MAX_ARGS_SIZE];
   int stat;
 
-  args[0] = canonicalize_hostname(strsave(argv[1]));
-  args[1] = strsave(DEFAULT_DIR);
+  args[0] = canonicalize_hostname(strdup(argv[1]));
+  args[1] = strdup(DEFAULT_DIR);
   if (GetValueFromUser("Directory:", &args[1]) == SUB_ERROR)
     return DM_NORMAL;
 
   if (!ValidName(args[0]) || !ValidName(args[1]))
     return DM_NORMAL;
 
-  if (!(stat = do_mr_query("get_nfsphys", 2, args, NullFunc, NULL)))
+  if (!(stat = do_mr_query("get_nfsphys", 2, args, NULL, NULL)))
     stat = MR_EXISTS;
   if (stat != MR_NO_MATCH)
     {
@@ -211,12 +206,12 @@ int AddNFSService(int argc, char **argv)
       return DM_NORMAL;
     }
 
-  info[NFS_NAME]   = Strsave(args[0]);
+  info[NFS_NAME]   = strdup(args[0]);
   info[NFS_DIR]    = args[1];  /* already saved. */
-  info[NFS_DEVICE] = Strsave(DEFAULT_DEVICE);
-  info[NFS_STATUS] = Strsave(DEFAULT_STATUS);
-  info[NFS_ALLOC]  = Strsave(DEFAULT_ALLOC);
-  info[NFS_SIZE]   = Strsave(DEFAULT_SIZE);
+  info[NFS_DEVICE] = strdup(DEFAULT_DEVICE);
+  info[NFS_STATUS] = strdup(DEFAULT_STATUS);
+  info[NFS_ALLOC]  = strdup(DEFAULT_ALLOC);
+  info[NFS_SIZE]   = strdup(DEFAULT_SIZE);
   info[NFS_MODBY] = info[NFS_MODWITH] = info[NFS_MODTIME] = NULL;
   info[NFS_END] = NULL;
 
@@ -227,7 +222,7 @@ int AddNFSService(int argc, char **argv)
     }
 
   if ((stat = do_mr_query("add_nfsphys", CountArgs(add_args), add_args,
-                         Scream, NULL)))
+                         NULL, NULL)))
     com_err(program_name, stat, " in AdsNFSService");
 
   FreeInfo(info);
@@ -254,7 +249,7 @@ static void RealUpdateNFSService(char **info, Bool junk)
     }
 
   if ((stat = do_mr_query("update_nfsphys", CountArgs(args), args,
-                         Scream, NULL)))
+                         NULL, NULL)))
     com_err(program_name, stat, " in RealUpdateNFSService");
 }
 
@@ -273,12 +268,12 @@ int UpdateNFSService(int argc, char **argv)
   if (!ValidName(argv[1]))
     return DM_NORMAL;
 
-  args[0] = canonicalize_hostname(strsave(argv[1]));
-  args[1] = strsave(DEFAULT_DIR);
+  args[0] = canonicalize_hostname(strdup(argv[1]));
+  args[1] = strdup(DEFAULT_DIR);
   if (GetValueFromUser("Directory:", &args[1]) == SUB_ERROR)
     return DM_NORMAL;
 
-  if ((stat = do_mr_query("get_nfsphys", 2, args, StoreInfo, (char *) &elem)))
+  if ((stat = do_mr_query("get_nfsphys", 2, args, StoreInfo, &elem)))
     {
       com_err(program_name, stat, " in UpdateNFSService.");
       return DM_NORMAL;
@@ -334,10 +329,10 @@ static void RealDeleteNFSService(char **info, Bool one_item)
       args[1] = info[NFS_DIR];
       args[2] = NULL;
       switch ((stat = do_mr_query("get_filesys_by_nfsphys", CountArgs(args),
-                                 args, StoreInfo, (char *)&elem)))
+                                 args, StoreInfo, &elem)))
        {
        case MR_NO_MATCH:       /* it is unused, delete it. */
-         if ((stat = do_mr_query("delete_nfsphys", 2, info, Scream, NULL)))
+         if ((stat = do_mr_query("delete_nfsphys", 2, info, NULL, NULL)))
            com_err(program_name, stat, " in DeleteNFSService");
          else
            Put_message("Physical Filesystem Deleted.");
@@ -375,13 +370,12 @@ int DeleteNFSService(int argc, char **argv)
   if (!ValidName(argv[1]))
     return DM_NORMAL;
 
-  args[0] = canonicalize_hostname(strsave(argv[1]));
-  args[1] = strsave(DEFAULT_DIR);
+  args[0] = canonicalize_hostname(strdup(argv[1]));
+  args[1] = strdup(DEFAULT_DIR);
   if (GetValueFromUser("Directory:", &args[1]) == SUB_ERROR)
     return DM_NORMAL;
 
-  switch ((stat = do_mr_query("get_nfsphys", 2, args,
-                             StoreInfo, (char *) &elem)))
+  switch ((stat = do_mr_query("get_nfsphys", 2, args, StoreInfo, &elem)))
     {
     case MR_NO_MATCH:
       Put_message("This filsystem does not exist!");
index 9535cf4ca17d006be68d836772bed8cc41b82fa9..c19e20ddf3dbef8e0749fbc1c878f0b712bf607b 100644 (file)
@@ -1,36 +1,30 @@
-#if (!defined(lint) && !defined(SABER))
-  static char rcsid_module_c[] = "$Header$";
-#endif
-
-/*     This is the file pobox.c for the Moira Client, which allows users
+/* $Id $
+ *
+ *     This is the file pobox.c for the Moira Client, which allows users
  *      to quickly and easily maintain most parts of the Moira database.
  *     It Contains: Functions for handling the poboxes.
  *
  *     Created:        7/10/88
  *     By:             Chris D. Peterson
  *
- *      $Source$
- *      $Author$
- *      $Header$
- *
- *     Copyright 1988 by the Massachusetts Institute of Technology.
- *
- *     For further information on copyright and distribution
- *     see the file mit-copyright.h
+ * Copyright (C) 1988-1998 by the Massachusetts Institute of Technology.
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
  */
 
-#include <stdio.h>
-#include <string.h>
-#include <ctype.h>
+#include <mit-copyright.h>
 #include <moira.h>
 #include <moira_site.h>
-#include <menu.h>
-
-#include "mit-copyright.h"
 #include "defs.h"
 #include "f_defs.h"
 #include "globals.h"
 
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+RCSID("$Header$");
+
 #define FOREIGN_BOX ("SMTP")
 #define LOCAL_BOX ("POP")
 
@@ -75,7 +69,7 @@ static int PrintPOMachines(void)
   struct qelem *top = NULL;
 
   if ((status = do_mr_query("get_server_locations", CountArgs(args), args,
-                           StoreInfo, (char *)&top)))
+                           StoreInfo, &top)))
     {
       com_err(program_name, status, " in get_server_locations.");
       return SUB_ERROR;
@@ -102,8 +96,7 @@ int GetUserPOBox(int argc, char **argv)
   if (!ValidName(argv[1]))
     return DM_NORMAL;
 
-  switch ((status = do_mr_query("get_pobox", 1, argv + 1, StoreInfo,
-                               (char *)&top)))
+  switch ((status = do_mr_query("get_pobox", 1, argv + 1, StoreInfo, &top)))
     {
     case MR_NO_MATCH:
       Put_message("This user has no P.O. Box.");
@@ -140,7 +133,7 @@ static char *GetNewLocalPOBox(char *local_user)
       Put_message("");
       if (!Prompt_input("Which Machine? ", temp_buf, BUFSIZ))
        return (char *) SUB_ERROR;
-      return canonicalize_hostname(strsave(temp_buf));
+      return canonicalize_hostname(strdup(temp_buf));
     }
   Put_message("Could not get machines to choose from, quitting.");
   return (char *) SUB_ERROR;
@@ -164,8 +157,7 @@ int SetUserPOBox(int argc, char **argv)
     return DM_NORMAL;
 
   /* Print the current PO Box info */
-  switch ((status = do_mr_query("get_pobox", 1, argv + 1, StoreInfo,
-                               (char *)&top)))
+  switch ((status = do_mr_query("get_pobox", 1, argv + 1, StoreInfo, &top)))
     {
     case MR_SUCCESS:
       sprintf(temp_buf, "Current pobox for user %s: \n", local_user);
@@ -191,7 +183,7 @@ int SetUserPOBox(int argc, char **argv)
        {
        case TRUE:
          switch ((status = do_mr_query("set_pobox_pop", 1,
-                                       &local_user, Scream, NULL)))
+                                       &local_user, NULL, NULL)))
            {
            case MR_SUCCESS:
              return DM_NORMAL;
@@ -251,7 +243,7 @@ int SetUserPOBox(int argc, char **argv)
   args[PO_BOX] = box;
   args[PO_END] = NULL;
   if ((status = do_mr_query("set_pobox", CountArgs(args), args,
-                           Scream, NULL)))
+                           NULL, NULL)))
     com_err(program_name, status, " in ChangeUserPOBox");
   else
     Put_message("PO Box assigned.");
@@ -279,7 +271,7 @@ int RemoveUserPOBox(int argc, char **argv)
   if (Confirm(temp_buf))
     {
       if ((status = do_mr_query("delete_pobox", 1, argv + 1,
-                               Scream, NULL)))
+                               NULL, NULL)))
        com_err(program_name, status, " in delete_pobox.");
       else
        Put_message("PO Box removed.");
index 8fa8e1b84581d148364cbfa48e82780fa81caccc..0188d779e221c2ae34c1f1b23d94596aeca26c25 100644 (file)
@@ -1,36 +1,35 @@
-#if (!defined(lint) && !defined(SABER))
-  static char rcsid_module_c[] = "$Header$";
-#endif
-
-/*     This is the file printer.c for the Moira Client, which allows users
+/* $Id $
+ *
+ *     This is the file printer.c for the Moira Client, which allows users
  *      to quickly and easily maintain most parts of the Moira database.
  *     It Contains: Functions for handling the printers.
  *
  *     Created:        8/16/88
  *     By:             Theodore Y. Ts'o
  *
- *      $Source$
- *      $Author$
- *      $Header$
- *
- *     Copyright 1988 by the Massachusetts Institute of Technology.
- *
- *     For further information on copyright and distribution
- *     see the file mit-copyright.h
+ * Copyright (C) 1988-1998 by the Massachusetts Institute of Technology.
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
  */
 
-#include <stdio.h>
-#include <string.h>
-#include <ctype.h>
+#include <mit-copyright.h>
 #include <moira.h>
 #include <moira_site.h>
-#include <menu.h>
-
-#include "mit-copyright.h"
 #include "defs.h"
 #include "f_defs.h"
 #include "globals.h"
 
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+RCSID("$Header$");
+
+void RealDeletePcap(char **info, Bool one_item);
+void ChangePcap(char **info, Bool one_item);
+void ChangePalladium(char **info, Bool one_item);
+void RealDeletePalladium(char **info, Bool one_item);
+
 #define DEFAULT_MACHINE "E40-PRINT-SERVER-1.MIT.EDU"
 
 /*     Function Name: SetDefaults
@@ -46,14 +45,14 @@ static char **SetDefaults(char **info, char *name)
   strcpy(spool_dir, "/usr/spool/printer/");
   strcat(spool_dir, name);
 
-  info[PCAP_NAME] = Strsave(name);
-  info[PCAP_SPOOL_HOST] = Strsave(DEFAULT_MACHINE);
-  info[PCAP_SPOOL_DIR] = Strsave(spool_dir);
-  info[PCAP_RPRINTER] = Strsave(name);
-  info[PCAP_QSERVER] = Strsave("[NONE]");
-  info[PCAP_AUTH] = Strsave("1");
-  info[PCAP_PRICE] = Strsave("10");
-  info[PCAP_COMMENTS] = Strsave("");
+  info[PCAP_NAME] = strdup(name);
+  info[PCAP_SPOOL_HOST] = strdup(DEFAULT_MACHINE);
+  info[PCAP_SPOOL_DIR] = strdup(spool_dir);
+  info[PCAP_RPRINTER] = strdup(name);
+  info[PCAP_QSERVER] = strdup("[NONE]");
+  info[PCAP_AUTH] = strdup("1");
+  info[PCAP_PRICE] = strdup("10");
+  info[PCAP_COMMENTS] = strdup("");
   info[PCAP_MODTIME] = info[PCAP_MODBY] = info[PCAP_MODWITH] = NULL;
 
   info[PCAP_END] = NULL;
@@ -72,8 +71,7 @@ static struct qelem *GetPcapInfo(char *name)
   int stat;
   struct qelem *elem = NULL;
 
-  if ((stat = do_mr_query("get_printcap_entry", 1, &name,
-                         StoreInfo, (char *)&elem)))
+  if ((stat = do_mr_query("get_printcap_entry", 1, &name, StoreInfo, &elem)))
     {
       com_err(program_name, stat, " in GetPcapInfo");
       return NULL;
@@ -84,17 +82,17 @@ static struct qelem *GetPcapInfo(char *name)
 /*     Function Name: PrintPcapInfo
  *     Description: Yet another specialized print function.
  *     Arguments: info - all info about this Printer.
- *     Returns: none
+ *     Returns: printer name
  */
 
-static void PrintPcapInfo(char **info)
+static char *PrintPcapInfo(char **info)
 {
   char buf[BUFSIZ];
 
   if (!info)           /* If no informaion */
     {
       Put_message("PrintPcapInfo called with null info!");
-      return;
+      return NULL;
     }
   sprintf(buf, "Printer: %-35s Spool host: %s", info[PCAP_NAME],
          info[PCAP_SPOOL_HOST]);
@@ -111,6 +109,8 @@ static void PrintPcapInfo(char **info)
   sprintf(buf, MOD_FORMAT, info[PCAP_MODBY], info[PCAP_MODTIME],
          info[PCAP_MODWITH]);
   Put_message(buf);
+
+  return info[PCAP_NAME];
 }
 
 /*     Function Name: AskPcapInfo.
@@ -189,7 +189,7 @@ void RealDeletePcap(char **info, Bool one_item)
   int stat;
 
   if ((stat = do_mr_query("delete_printcap_entry", 1,
-                         &info[PCAP_NAME], Scream, NULL)))
+                         &info[PCAP_NAME], NULL, NULL)))
     com_err(program_name, stat, " printcap entry not deleted.");
   else
     Put_message("Printcap entry deleted.");
@@ -225,7 +225,7 @@ int AddPcap(int argc, char **argv)
     return DM_NORMAL;
 
   if (!(stat = do_mr_query("get_printcap_entry", 1, argv + 1,
-                          NullFunc, NULL)))
+                          NULL, NULL)))
     {
       Put_message ("A Printer by that name already exists.");
       return DM_NORMAL;
@@ -244,7 +244,7 @@ int AddPcap(int argc, char **argv)
     }
 
   if ((stat = do_mr_query("add_printcap_entry", CountArgs(args), args,
-                         NullFunc, NULL)))
+                         NULL, NULL)))
     com_err(program_name, stat, " in AddPcap");
 
   FreeInfo(info);
@@ -258,30 +258,30 @@ int AddPcap(int argc, char **argv)
  *     Returns:
  */
 
-int ChangePcap(char **info, Bool one_item)
+void ChangePcap(char **info, Bool one_item)
 {
   int stat;
   char **oldinfo;
 
   oldinfo = CopyInfo(info);
   if (!AskPcapInfo(info))
-    return DM_QUIT;
+    return;
   if ((stat = do_mr_query("delete_printcap_entry", 1, &info[PCAP_NAME],
-                         Scream, NULL)))
+                         NULL, NULL)))
     {
       com_err(program_name, stat, " printcap entry not deleted.");
-      return DM_NORMAL;
+      return;
     }
   if ((stat = do_mr_query("add_printcap_entry", CountArgs(info), info,
-                         NullFunc, NULL)))
+                         NULL, NULL)))
     {
       com_err(program_name, stat, " in ChngPcap");
       if ((stat = do_mr_query("add_printcap_entry", CountArgs(oldinfo) - 3,
-                             oldinfo, NullFunc, NULL)))
+                             oldinfo, NULL, NULL)))
        com_err(program_name, stat, " while attempting to put old info back");
     }
   FreeInfo(oldinfo);
-  return DM_NORMAL;
+  return;
 }
 
 
@@ -308,9 +308,9 @@ int ChngPcap(int argc, char **argv)
 
 static char **SetPdDefaults(char **info, char *name)
 {
-  info[PD_NAME] = Strsave(name);
-  info[PD_IDENT] = Strsave("10000");
-  info[PD_HOST] = Strsave(DEFAULT_MACHINE);
+  info[PD_NAME] = strdup(name);
+  info[PD_IDENT] = strdup("10000");
+  info[PD_HOST] = strdup(DEFAULT_MACHINE);
   info[PD_MODTIME] = info[PD_MODBY] = info[PD_MODWITH] = NULL;
 
   info[PD_END] = NULL;
@@ -353,17 +353,17 @@ static char **AskPalladiumInfo(char **info)
 /*     Function Name: PrintPalladiumInfo
  *     Description: Yet another specialized print function.
  *     Arguments: info - all info about this Printer.
- *     Returns: none
+ *     Returns: printer name
  */
 
-static void PrintPalladiumInfo(char **info)
+static char *PrintPalladiumInfo(char **info)
 {
   char buf[BUFSIZ];
 
   if (!info)           /* If no informaion */
     {
       Put_message("PrintPalladiumInfo called with null info!");
-      return;
+      return NULL;
     }
 
   sprintf(buf, "Name: %-24s Program #: %s  Host: %s",
@@ -372,6 +372,7 @@ static void PrintPalladiumInfo(char **info)
   sprintf(buf, MOD_FORMAT, info[PD_MODBY], info[PD_MODTIME],
          info[PD_MODWITH]);
   Put_message(buf);
+  return info[PD_NAME];
 }
 
 
@@ -389,22 +390,22 @@ static struct qelem *GetPalladiumInfo(char *name)
 }
 
 
-int ChangePalladium(char **info, Bool one_item)
+void ChangePalladium(char **info, Bool one_item)
 {
   int status;
 
   if (!AskPalladiumInfo(info))
-    return DM_QUIT;
+    return;
   if ((status = do_mr_query("delete_palladium", 1, &info[PD_NAME],
-                           Scream, NULL)))
+                           NULL, NULL)))
     {
       com_err(program_name, status, " palladium entry not deleted.");
-      return DM_NORMAL;
+      return;
     }
   if ((status = do_mr_query("add_palladium", CountArgs(info), info,
-                           NullFunc, NULL)))
+                           NULL, NULL)))
     com_err(program_name, status, " in ChngPalladium");
-  return DM_NORMAL;
+  return;
 }
 
 
@@ -421,7 +422,7 @@ void RealDeletePalladium(char **info, Bool one_item)
   int stat;
 
   if ((stat = do_mr_query("delete_palladium", 1,
-                         &info[PD_NAME], Scream, NULL)))
+                         &info[PD_NAME], NULL, NULL)))
     com_err(program_name, stat, " palladium entry not deleted.");
   else
     Put_message("Palladium entry deleted.");
@@ -433,7 +434,7 @@ int GetPalladium(int argc, char **argv)
   struct qelem *top;
 
   top = GetPalladiumInfo(argv[1]);
-  Loop(top, PrintPalladiumInfo);
+  Loop(top, (void (*)(char **))PrintPalladiumInfo);
   FreeQueue(top);
   return DM_NORMAL;
 }
@@ -447,7 +448,7 @@ int AddPalladium(int argc, char **argv)
   if (!ValidName(argv[1]))
     return DM_NORMAL;
 
-  if (!(status = do_mr_query("get_palladium", 1, &argv[1], NullFunc, NULL)))
+  if (!(status = do_mr_query("get_palladium", 1, &argv[1], NULL, NULL)))
     {
       Put_message("A server or supervisor by that name already exists.");
       return DM_NORMAL;
@@ -466,7 +467,7 @@ int AddPalladium(int argc, char **argv)
     }
 
   if ((status = do_mr_query("add_palladium", CountArgs(args), args,
-                           Scream, NULL)))
+                           NULL, NULL)))
     com_err(program_name, status, " in AddPalladium");
 
   FreeInfo(info);
@@ -510,7 +511,7 @@ int ShowPalladiumAlias(int argc, char **argv)
   Put_message("");
   while (elem)
     {
-      char **info = (char **) elem->q_data;
+      char **info = elem->q_data;
       sprintf(buf, "Printer: %-16s Server/Supervisor: %s", info[0], info[2]);
       Put_message(buf);
       elem = elem->q_forw;
@@ -528,7 +529,7 @@ int AddPalladiumAlias(int argc, char **argv)
   qargv[0] = argv[1];
   qargv[1] = "PALLADIUM";
   qargv[2] = argv[2];
-  if ((status = do_mr_query("add_alias", 3, qargv, Scream, NULL)))
+  if ((status = do_mr_query("add_alias", 3, qargv, NULL, NULL)))
     com_err(program_name, status, " in AddPalladiumAlias");
   return DM_NORMAL;
 }
@@ -541,7 +542,7 @@ int DeletePalladiumAlias(int argc, char **argv)
   qargv[0] = argv[1];
   qargv[1] = "PALLADIUM";
   qargv[2] = argv[2];
-  if ((status = do_mr_query("delete_alias", 3, qargv, Scream, NULL)))
+  if ((status = do_mr_query("delete_alias", 3, qargv, NULL, NULL)))
     com_err(program_name, status, " in DeletePalladiumAlias");
   return DM_NORMAL;
 }
index 397dd205869a7053e36750159c205444f8697f61..7058443e570d8e7c620041fc785055d77b3d63bb 100644 (file)
@@ -1,36 +1,31 @@
-#if (!defined(lint) && !defined(SABER))
-  static char rcsid_module_c[] = "$Header$";
-#endif
-
-/*     This is the file quota.c for the Moira Client, which allows users
+/* $Id $
+ *
+ *     This is the file quota.c for the Moira Client, which allows users
  *      to quickly and easily maintain most parts of the Moira database.
  *     It Contains: Functions for manipulating the quota information.
  *
  *     Created:        7/10/88
  *     By:             Chris D. Peterson
  *
- *      $Source$
- *      $Author$
- *      $Header$
- *
- *     Copyright 1988 by the Massachusetts Institute of Technology.
- *
- *     For further information on copyright and distribution
- *     see the file mit-copyright.h
+ * Copyright (C) 1988-1998 by the Massachusetts Institute of Technology.
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
  */
 
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
+#include <mit-copyright.h>
 #include <moira.h>
 #include <moira_site.h>
-#include <menu.h>
-
-#include "mit-copyright.h"
 #include "defs.h"
 #include "f_defs.h"
 #include "globals.h"
 
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+int afsfilsyshelper(int argc, char **argv, void *hint);
+int afsfilesys(char *name);
+
 static char *def_quota = NULL;
 
 #define DEFAULT_FILESYS DEFAULT_NONE
@@ -57,13 +52,13 @@ static char *GetDefaultUserQuota(Bool override)
   if (override || (def_quota == NULL))
     {
       if ((status = do_mr_query("get_value", CountArgs(val), val,
-                               StoreInfo, (char *) &top)))
+                               StoreInfo, &top)))
        {
          com_err(program_name, status, " in ShowDefaultQuota");
          if (!def_quota)
            {
              Put_message("No default Quota Found, setting default to 0.");
-             def_quota = Strsave("0");
+             def_quota = strdup("0");
            }
          else
            Put_message("No default Quota Found, retaining old value.");
@@ -71,9 +66,9 @@ static char *GetDefaultUserQuota(Bool override)
       else
        {
          top = QueueTop(top);
-         info = (char **) top->q_data;
+         info = top->q_data;
          FreeAndClear(&def_quota, TRUE);
-         def_quota = Strsave(info[0]);
+         def_quota = strdup(info[0]);
          FreeQueue(top);
        }
     }
@@ -123,10 +118,10 @@ static char *PrintQuota(char **info)
 }
 
 
-int afsfilsyshelper(int argc, char **argv, int *hint)
+int afsfilsyshelper(int argc, char **argv, void *hint)
 {
-  *hint = !strcmp(argv[FS_TYPE], "AFS");
-  return 0;
+  *(int *)hint = !strcmp(argv[FS_TYPE], "AFS");
+  return MR_CONT;
 }
 
 
@@ -162,12 +157,12 @@ static char **GetQuotaArgs(Bool quota)
       return NULL;
     }
 
-  args[Q_FILESYS] = Strsave(DEFAULT_FILESYS);
-  args[Q_TYPE] = Strsave(DEFAULT_QTYPE);
-  args[Q_NAME] = Strsave(DEFAULT_USER);
+  args[Q_FILESYS] = strdup(DEFAULT_FILESYS);
+  args[Q_TYPE] = strdup(DEFAULT_QTYPE);
+  args[Q_NAME] = strdup(DEFAULT_USER);
   if (quota)
     {
-      args[Q_QUOTA] = Strsave(GetDefaultUserQuota(FALSE));
+      args[Q_QUOTA] = strdup(GetDefaultUserQuota(FALSE));
       args[Q_QUOTA + 1] = NULL;        /* NULL terminate. */
     }
   else
@@ -191,8 +186,8 @@ static char **GetQuotaArgs(Bool quota)
     }
   if (af)
     {
-      args[Q_TYPE] = strsave("ANY");
-      args[Q_NAME] = strsave(NOBODY);
+      args[Q_TYPE] = strdup("ANY");
+      args[Q_NAME] = strdup(NOBODY);
     }
   else
     {
@@ -221,7 +216,7 @@ static char **GetQuotaArgs(Bool quota)
  *     Returns: DM_NORMAL.
  */
 
-int ShowDefaultQuota(void)
+int ShowDefaultQuota(int argc, char **argv)
 {
   PrintDefaultQuota(GetDefaultUserQuota(TRUE));
   return DM_NORMAL;
@@ -250,10 +245,10 @@ int ChangeDefaultQuota(int argc, char *argv[])
     {
       newval[1] = argv[1];
       if ((status = do_mr_query("update_value", CountArgs(newval),
-                               newval, Scream, NULL)) == MR_SUCCESS)
+                               newval, NULL, NULL)) == MR_SUCCESS)
        {
          FreeAndClear(&def_quota, TRUE);
-         def_quota = Strsave(argv[1]);
+         def_quota = strdup(argv[1]);
        }
       else
        com_err(program_name, status, " in update_value");
@@ -273,7 +268,7 @@ int ChangeDefaultQuota(int argc, char *argv[])
  *      Returns: DM_NORMAL
  */
 
-int GetQuota(void)
+int GetQuota(int argc, char **argv)
 {
   struct qelem *top = NULL;
   int status;
@@ -283,7 +278,7 @@ int GetQuota(void)
     return DM_NORMAL;
 
   if ((status = do_mr_query("get_quota", CountArgs(args), args,
-                           StoreInfo, (char *) &top)) != MR_SUCCESS)
+                           StoreInfo, &top)) != MR_SUCCESS)
     com_err(program_name, status, " in get_quota");
 
   FreeInfo(args);
@@ -303,7 +298,7 @@ int GetQuota(void)
  *        Returns: DM_NORMAL
  */
 
-int GetQuotaByFilesys(void)
+int GetQuotaByFilesys(int argc, char **argv)
 {
   struct qelem *top = NULL;
   int status;
@@ -315,13 +310,13 @@ int GetQuotaByFilesys(void)
       return DM_NORMAL;
     }
 
-  args[0] = Strsave("");
+  args[0] = strdup("");
   args[1] = NULL;
   if (GetValueFromUser("Filesystem", &args[0]) == SUB_ERROR)
     return DM_NORMAL;
 
   if ((status = do_mr_query("get_quota_by_filesys", 1, args,
-                           StoreInfo, (char *) &top)) != MR_SUCCESS)
+                           StoreInfo, &top)) != MR_SUCCESS)
     com_err(program_name, status, " in get_quota_by_filesys");
 
   FreeInfo(args);
@@ -340,7 +335,7 @@ int GetQuotaByFilesys(void)
  *        Arguments: None
  *        Returns: DM_NORMAL
  */
-int AddQuota(void)
+int AddQuota(int argc, char **argv)
 {
   char **args;
   int status;
@@ -349,7 +344,7 @@ int AddQuota(void)
     return DM_NORMAL;
 
   if ((status = do_mr_query("add_quota", CountArgs(args), args,
-                           Scream, NULL)) != MR_SUCCESS)
+                           NULL, NULL)) != MR_SUCCESS)
     com_err(program_name, status, " in add_quota");
 
   FreeInfo(args);
@@ -375,9 +370,9 @@ static void RealUpdateQuota(char **info)
       return;
     }
 
-  if (status = do_mr_query("update_quota", 4, info,
-                           Scream, NULL) != MR_SUCCESS)
-    {
+  if ((status = do_mr_query("update_quota", 4, info,
+                           NULL, NULL)) != MR_SUCCESS)
+      {
       com_err(program_name, status, " in update_quota");
       sprintf(temp_buf, "Could not perform quota change on %s",
              info[Q_FILESYS]);
@@ -392,7 +387,7 @@ static void RealUpdateQuota(char **info)
  *        Returns: DM_NORMAL
  */
 
-int UpdateQuota(void)
+int UpdateQuota(int argc, char **argv)
 {
   int status;
   char **args;
@@ -402,7 +397,7 @@ int UpdateQuota(void)
     return DM_NORMAL;
 
   if ((status = do_mr_query("get_quota", CountArgs(args), args,
-                           StoreInfo, (char *) &top)) != MR_SUCCESS)
+                           StoreInfo, &top)) != MR_SUCCESS)
     com_err(program_name, status, " in get_quota");
 
   FreeInfo(args);              /* done with args, free them. */
@@ -443,7 +438,7 @@ static void RealDeleteQuota(char **info, Bool one_item)
   if (!one_item || Confirm(temp_buf))
     {
       if ((status = do_mr_query("delete_quota", 3, info,
-                               Scream, NULL)) != MR_SUCCESS)
+                               NULL, NULL)) != MR_SUCCESS)
        com_err(program_name, status, " in delete_quota");
       else
        Put_message("Quota sucessfully removed.");
@@ -459,7 +454,7 @@ static void RealDeleteQuota(char **info, Bool one_item)
  *        Returns: DM_NORMAL
  */
 
-int DeleteQuota(void)
+int DeleteQuota(int argc, char **argv)
 {
   int status;
   char **args;
@@ -468,8 +463,7 @@ int DeleteQuota(void)
   if (!(args = GetQuotaArgs(FALSE)))
     return DM_NORMAL;
 
-  if ((status = do_mr_query("get_quota", 3, args,
-                           StoreInfo, (char *) &top)))
+  if ((status = do_mr_query("get_quota", 3, args, StoreInfo, &top)))
     com_err(program_name, status, " in get_quota");
 
   FreeInfo(args);
index 391d03d61c7d83fc2a5cb8304724a98b767057a2..ac544ec34d050db26ec3f9d01f498b123ee4111d 100644 (file)
@@ -1,41 +1,38 @@
-#if (!defined(lint) && !defined(SABER))
-  static char rcsid_module_c[] = "$Header$";
-#endif
-
-/*     This is the file user.c for the Moira Client, which allows users
+/* $Id $
+ *
+ *     This is the file user.c for the Moira Client, which allows users
  *      to quickly and easily maintain most parts of the Moira database.
  *     It Contains: Functions for manipulating user information.
  *
  *     Created:        5/9/88
  *     By:             Chris D. Peterson
  *
- *      $Source$
- *      $Author$
- *      $Header$
- *
- *     Copyright 1988 by the Massachusetts Institute of Technology.
- *
- *     For further information on copyright and distribution
- *     see the file mit-copyright.h
+ * Copyright (C) 1988-1998 by the Massachusetts Institute of Technology.
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
  */
 
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
+#include <mit-copyright.h>
 #include <moira.h>
 #include <moira_site.h>
-#include <menu.h>
+#include "defs.h"
+#include "f_defs.h"
+#include "globals.h"
+
 #include <ctype.h>
-#include <sys/time.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <time.h>
 #ifdef GDSS
-#include <des.h>
-#include <krb.h>
 #include <gdss.h>
 #endif
-#include "mit-copyright.h"
-#include "defs.h"
-#include "f_defs.h"
-#include "globals.h"
+
+RCSID("$Header$");
+
+void CorrectCapitalization(char **name);
+char **AskUserInfo(char **info, Bool name);
+struct qelem *GetUserInfo(int type, char *name1, char *name2);
 
 #define LOGIN 0
 #define UID   1
@@ -148,18 +145,18 @@ static void PrintUserInfo(char **info)
 
 static char **SetUserDefaults(char **info)
 {
-  info[U_NAME] = Strsave(UNIQUE_LOGIN);
-  info[U_UID] = Strsave(UNIQUE_UID);
-  info[U_SHELL] = Strsave(DEFAULT_SHELL);
-  info[U_LAST] = Strsave(DEFAULT_NONE);
-  info[U_FIRST] = Strsave(DEFAULT_NONE);
-  info[U_MIDDLE] = Strsave(DEFAULT_NONE);
-  info[U_STATE] = Strsave(DEFAULT_NO);
-  info[U_MITID] = Strsave(DEFAULT_NONE);
-  info[U_CLASS] = Strsave(DEFAULT_CLASS);
-  info[U_COMMENT] = Strsave("");
-  info[U_SIGNATURE] = Strsave("");
-  info[U_SECURE] = Strsave("0");
+  info[U_NAME] = strdup(UNIQUE_LOGIN);
+  info[U_UID] = strdup(UNIQUE_UID);
+  info[U_SHELL] = strdup(DEFAULT_SHELL);
+  info[U_LAST] = strdup(DEFAULT_NONE);
+  info[U_FIRST] = strdup(DEFAULT_NONE);
+  info[U_MIDDLE] = strdup(DEFAULT_NONE);
+  info[U_STATE] = strdup(DEFAULT_NO);
+  info[U_MITID] = strdup(DEFAULT_NONE);
+  info[U_CLASS] = strdup(DEFAULT_CLASS);
+  info[U_COMMENT] = strdup("");
+  info[U_SIGNATURE] = strdup("");
+  info[U_SECURE] = strdup("0");
   info[U_MODTIME] = info[U_MODBY] = info[U_MODWITH] = info[U_END] = NULL;
   return info;
 }
@@ -169,7 +166,7 @@ static char **SetUserDefaults(char **info)
  * offer to correct it if not.
  */
 
-int CorrectCapitalization(char **name)
+void CorrectCapitalization(char **name)
 {
   char temp_buf[BUFSIZ], fixname[BUFSIZ];
 
@@ -182,7 +179,7 @@ int CorrectCapitalization(char **name)
       if (YesNoQuestion(temp_buf, 1) == TRUE)
        {
          free(*name);
-         *name = strsave(fixname);
+         *name = strdup(fixname);
        }
     }
 }
@@ -228,7 +225,7 @@ char **AskUserInfo(char **info, Bool name)
       argv[0] = info[U_FIRST];
       argv[1] = info[U_LAST];
       if (do_mr_query("get_user_account_by_name", 2, argv,
-                     StoreInfo, (char *) &elem) == MR_SUCCESS)
+                     StoreInfo, &elem) == MR_SUCCESS)
        {
          Put_message("A user by that name already exists in the database.");
          Loop(QueueTop(elem), PrintUserInfo);
@@ -240,7 +237,7 @@ char **AskUserInfo(char **info, Bool name)
     }
   if (name)
     {
-      newname = Strsave(info[U_NAME]);
+      newname = strdup(info[U_NAME]);
       if (GetValueFromUser("The new login name for this user", &newname) ==
          SUB_ERROR)
        return NULL;
@@ -293,7 +290,7 @@ char **AskUserInfo(char **info, Bool name)
                    atoi(info[U_SECURE]) ? TRUE : FALSE) == FALSE)
     {
       free(info[U_SECURE]);
-      info[U_SECURE] = strsave("0");
+      info[U_SECURE] = strdup("0");
     }
   else if (!strcmp(info[U_SECURE], "0"))
     {
@@ -303,7 +300,7 @@ char **AskUserInfo(char **info, Bool name)
       gettimeofday(&tv, NULL);
       sprintf(buf, "%ld", (long) tv.tv_sec);
       free(info[U_SECURE]);
-      info[U_SECURE] = strsave(buf);
+      info[U_SECURE] = strdup(buf);
     }
 
   /* Sign record */
@@ -337,7 +334,7 @@ char **AskUserInfo(char **info, Bool name)
        }
     }
 #else /* GDSS */
-  info[U_SIGNATURE] = strsave("");
+  info[U_SIGNATURE] = strdup("");
 #endif /* GDSS */
 
   FreeAndClear(&info[U_MODTIME], TRUE);
@@ -377,7 +374,7 @@ struct qelem *GetUserInfo(int type, char *name1, char *name2)
     case LOGIN:
       args[0] = name1;
       if ((status = do_mr_query("get_user_account_by_login", 1, args,
-                               StoreInfo, (char *) &elem)))
+                               StoreInfo, &elem)))
        {
          com_err(program_name, status,
                  " when attempting to get_user_account_by_login.");
@@ -387,7 +384,7 @@ struct qelem *GetUserInfo(int type, char *name1, char *name2)
     case UID:
       args[0] = name1;
       if ((status = do_mr_query("get_user_account_by_uid", 1, args,
-                               StoreInfo, (char *) &elem)))
+                               StoreInfo, &elem)))
        {
          com_err(program_name, status,
                  " when attempting to get_user_account_by_uid.");
@@ -398,7 +395,7 @@ struct qelem *GetUserInfo(int type, char *name1, char *name2)
       args[0] = name1;
       args[1] = name2;
       if ((status = do_mr_query("get_user_account_by_name", 2, args,
-                               StoreInfo, (char *) &elem)))
+                               StoreInfo, &elem)))
        {
          com_err(program_name, status,
                  " when attempting to get_user_account_by_name.");
@@ -408,7 +405,7 @@ struct qelem *GetUserInfo(int type, char *name1, char *name2)
     case CLASS:
       args[0] = name1;
       if ((status = do_mr_query("get_user_account_by_class", 1, args,
-                               StoreInfo, (char *) &elem)))
+                               StoreInfo, &elem)))
        {
          com_err(program_name, status,
                  " when attempting to get_user_account_by_class.");
@@ -418,7 +415,7 @@ struct qelem *GetUserInfo(int type, char *name1, char *name2)
     case ID:
       args[0] = name1;
       if ((status = do_mr_query("get_user_account_by_id", 1, args,
-                               StoreInfo, (char *) &elem)))
+                               StoreInfo, &elem)))
        {
          com_err(program_name, status,
                  " when attempting to get_user_account_by_id.");
@@ -435,7 +432,7 @@ struct qelem *GetUserInfo(int type, char *name1, char *name2)
  *     Returns: DM_NORMAL.
  */
 
-int AddNewUser(void)
+int AddNewUser(int argc, char **argv)
 {
   int status;
   char **args, *info[MAX_ARGS_SIZE];
@@ -446,7 +443,7 @@ int AddNewUser(void)
       return DM_NORMAL;
     }
   if ((status = do_mr_query("add_user_account", CountArgs(args),
-                           args, Scream, NULL)))
+                           args, NULL, NULL)))
     com_err(program_name, status, " in add_user_account");
   else
     Put_message("New user added to database.");
@@ -466,7 +463,7 @@ static char *GetLoginName(void)
 {
   char *name;
 
-  name = strsave("");
+  name = strdup("");
   if (GetValueFromUser("Login name for this user? ", &name) == SUB_ERROR)
     return NULL;
   Put_message("KERBEROS code not added, did not reserve name with kerberos.");
@@ -484,12 +481,12 @@ static char *ChooseUser(struct qelem *elem)
 {
   while (elem)
     {
-      char **info = (char **) elem->q_data;
+      char **info = elem->q_data;
       PrintUserInfo(info);
       switch (YesNoQuitQuestion("Is this the user you want (y/n/q)", FALSE))
        {
        case TRUE:
-         return Strsave(info[U_UID]);
+         return strdup(info[U_UID]);
        case FALSE:
          break;
        default:                /* quit or ^C. */
@@ -523,7 +520,7 @@ static char *GetUidNumberFromName(void)
   args[1] = last;
 
   switch ((status = do_mr_query("get_user_account_by_name", 2, args,
-                               StoreInfo, (char *) &top)))
+                               StoreInfo, &top)))
     {
     case MR_SUCCESS:
       break;
@@ -538,13 +535,13 @@ static char *GetUidNumberFromName(void)
   top = QueueTop(top);
   if (QueueCount(top) == 1) /* This is a unique name. */
     {
-      char **info = (char **) top->q_data;
+      char **info = top->q_data;
       Put_message("User ID Number retrieved for the user: ");
       Put_message("");
       PrintUserName(info);
-      uid = Strsave(info[U_UID]);
+      uid = strdup(info[U_UID]);
       FreeQueue(top);
-      return Strsave(uid);
+      return strdup(uid);
     }
 
   Put_message("That name is not unique, choose the user that you want.");
@@ -585,7 +582,7 @@ static void GiveBackLogin(char *name)
  *     Returns: DM_NORMAL.
  */
 
-int RegisterUser(void)
+int RegisterUser(int argc, char **argv)
 {
   char *args[MAX_ARGS_SIZE];
   char *login, *fstype = NULL;
@@ -599,7 +596,7 @@ int RegisterUser(void)
     {
     case TRUE:
       Prompt_input("What is the UID number of the user? ", temp_buf, BUFSIZ);
-      args[0] = Strsave(temp_buf);
+      args[0] = strdup(temp_buf);
       break;
     case FALSE:
       if (!(args[0] = GetUidNumberFromName()))
@@ -610,7 +607,7 @@ int RegisterUser(void)
     }
 
   sprintf(temp_buf, "u%s", args[0]);
-  login = strsave(temp_buf);
+  login = strdup(temp_buf);
   if ((GetValueFromUser("Login name for this user? ", &login) == SUB_ERROR) ||
       (GetFSTypes(&fstype, FALSE) == SUB_ERROR))
     {
@@ -624,7 +621,7 @@ int RegisterUser(void)
   args[3] = NULL;
 
   switch ((status = do_mr_query("register_user", CountArgs(args),
-                               args, Scream, NULL)))
+                               args, NULL, NULL)))
     {
     case MR_SUCCESS:
       sprintf(temp_buf, "User %s successfully registered.", login);
@@ -663,7 +660,7 @@ static void RealUpdateUser(char **info, Bool junk)
       return;
     }
   if ((status = do_mr_query("update_user_account", CountArgs(args),
-                           args, Scream, NULL)))
+                           args, NULL, NULL)))
     {
       com_err(program_name, status, " in ModifyFields");
       sprintf(error_buf, "User %s not updated due to errors.", info[NAME]);
@@ -711,7 +708,7 @@ static void RealDeactivateUser(char **info, Bool one_item)
 
   qargs[0] = info[NAME];
   qargs[1] = "3";
-  if ((status = do_mr_query("update_user_status", 2, qargs, Scream, NULL)))
+  if ((status = do_mr_query("update_user_status", 2, qargs, NULL, NULL)))
     {
       com_err(program_name, status, " in update_user_status");
       sprintf(txt_buf, "User %s not deactivated due to errors.", info[NAME]);
@@ -721,18 +718,18 @@ static void RealDeactivateUser(char **info, Bool one_item)
                         FALSE) == TRUE)
     {
       status = do_mr_query("get_list_info", 1, &(info[NAME]), StoreInfo,
-                          (char *) &elem);
+                          &elem);
       if (status == MR_SUCCESS)
        {
-         args = (char **) (QueueTop(elem)->q_data);
+         args = QueueTop(elem)->q_data;
          free(args[L_ACTIVE]);
-         args[L_ACTIVE] = strsave("0");
+         args[L_ACTIVE] = strdup("0");
          FreeAndClear(&args[L_MODTIME], TRUE);
          FreeAndClear(&args[L_MODBY], TRUE);
          FreeAndClear(&args[L_MODWITH], TRUE);
          SlipInNewName(args, args[L_NAME]);
          if ((status = do_mr_query("update_list", CountArgs(args), args,
-                                   Scream, NULL)))
+                                   NULL, NULL)))
            {
              com_err(program_name, status, " updating list, "
                      "not deactivating list or filesystem");
@@ -752,7 +749,7 @@ static void RealDeactivateUser(char **info, Bool one_item)
        }
 
       if ((status = do_mr_query("get_filesys_by_label", 1, &(info[NAME]),
-                               StoreInfo, (char *) &elem)))
+                               StoreInfo, &elem)))
        {
          com_err(program_name, status, " getting filsys info, "
                  "not deactivating filesystem");
@@ -760,17 +757,17 @@ static void RealDeactivateUser(char **info, Bool one_item)
          FreeQueue(elem);
          return;
        }
-      args = (char **) (QueueTop(elem)->q_data);
+      args = QueueTop(elem)->q_data;
       free(args[FS_TYPE]);
-      args[FS_TYPE] = strsave("ERR");
+      args[FS_TYPE] = strdup("ERR");
       free(args[FS_COMMENTS]);
-      args[FS_COMMENTS] = strsave("Locker disabled; call 3-1325 for help");
+      args[FS_COMMENTS] = strdup("Locker disabled; call 3-1325 for help");
       FreeAndClear(&args[FS_MODTIME], TRUE);
       FreeAndClear(&args[FS_MODBY], TRUE);
       FreeAndClear(&args[FS_MODWITH], TRUE);
       SlipInNewName(args, args[FS_NAME]);
       if ((status = do_mr_query("update_filesys", CountArgs(args), args,
-                               Scream, NULL)))
+                               NULL, NULL)))
        {
          com_err(program_name, status, " updating filesystem, "
                  "not deactivating filesystem");
@@ -824,10 +821,10 @@ int DeleteUserByUid(int argc, char **argv)
     return DM_NORMAL;
 
   if ((status = do_mr_query("get_user_account_by_uid", 1, argv + 1, StoreInfo,
-                           (char *) &elem)))
+                           &elem)))
     com_err(program_name, status, " in get_user_account_by_uid");
 
-  info = (char **) elem->q_data;
+  info = elem->q_data;
   argv[1] = info[U_NAME];
 
   DeleteUser(argc, argv);
@@ -942,7 +939,7 @@ int GetKrbmap(int argc, char **argv)
   char buf[BUFSIZ];
 
   if ((stat = do_mr_query("get_kerberos_user_map", 2, &argv[1],
-                         StoreInfo, (char *)&elem)))
+                         StoreInfo, &elem)))
     {
       com_err(program_name, stat, " in GetKrbMap.");
       return DM_NORMAL;
@@ -952,7 +949,7 @@ int GetKrbmap(int argc, char **argv)
   Put_message("");
   while (elem)
     {
-      char **info = (char **) elem->q_data;
+      char **info = elem->q_data;
       sprintf(buf, "User: %-9s Principal: %s",
              info[KMAP_USER], info[KMAP_PRINCIPAL]);
       Put_message(buf);
@@ -981,7 +978,7 @@ int AddKrbmap(int argc, char **argv)
       return DM_NORMAL;
     }
   if ((stat = do_mr_query("add_kerberos_user_map", 2, &argv[1],
-                         Scream, NULL)))
+                         NULL, NULL)))
     {
       com_err(program_name, stat, " in AddKrbMap.");
       if (stat == MR_EXISTS)
@@ -1003,7 +1000,7 @@ int DeleteKrbmap(int argc, char **argv)
   int stat;
 
   if ((stat = do_mr_query("delete_kerberos_user_map", 2, &argv[1],
-                         Scream, NULL)))
+                         NULL, NULL)))
     com_err(program_name, stat, " in DeleteKrbMap.");
   return DM_NORMAL;
 }
@@ -1025,13 +1022,13 @@ int GetDirFlags(int argc, char **argv)
     return DM_NORMAL;
 
   if ((stat = do_mr_query("get_user_directory_flags", 1, &argv[1],
-                         StoreInfo, (char *)&elem)))
+                         StoreInfo, &elem)))
     {
       com_err(program_name, stat, " in GetDirFlags.");
       return DM_NORMAL;
     }
 
-  info = (char **) QueueTop(elem)->q_data;
+  info = QueueTop(elem)->q_data;
   flags = atoi(info[0]);
   FreeQueue(QueueTop(elem));
 
@@ -1069,12 +1066,12 @@ int SetDirFlags(int argc, char **argv)
 
   /* Fetch current prefs */
   if ((stat = do_mr_query("get_user_directory_flags", 1, &argv[1],
-                         StoreInfo, (char *) &elem)))
+                         StoreInfo, &elem)))
     {
       com_err(program_name, stat, " in GetDirFlags.");
       return DM_NORMAL;
     }
-  info = (char **) QueueTop(elem)->q_data;
+  info = QueueTop(elem)->q_data;
   flags = atoi(info[0]);
   FreeQueue(QueueTop(elem));
 
@@ -1095,7 +1092,7 @@ int SetDirFlags(int argc, char **argv)
   sprintf(buf, "%d", flags);
   args[1] = buf;
   if ((stat = do_mr_query("update_user_directory_flags", 2,
-                         args, Scream, NULL)))
+                         args, NULL, NULL)))
     com_err(program_name, stat, " in SetDirFlags");
   else
     Put_message("Directory preferences set.");
index 5bee4aeabcb0690d34abd44cc89e3cc66ef365a1..a31b62b77171caae93ebe745389e7e81d5e890dd 100644 (file)
@@ -1,41 +1,35 @@
-#if (!defined(lint) && !defined(SABER))
-  static char rcsid_module_c[] = "$Header$";
-#endif
-
-/*     This is the file utils.c for the Moira Client, which allows users
+/* $Id $
+ *
+ *     This is the file utils.c for the Moira Client, which allows users
  *      to quickly and easily maintain most parts of the Moira database.
  *     It Contains:  Many useful utility functions.
  *
  *     Created:        4/25/88
  *     By:             Chris D. Peterson
  *
- *      $Source$
- *      $Author$
- *      $Header$
- *
- *     Copyright 1988 by the Massachusetts Institute of Technology.
- *
- *     For further information on copyright and distribution
- *     see the file mit-copyright.h
+ * Copyright (C) 1988-1998 by the Massachusetts Institute of Technology.
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
  */
 
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
+#include <mit-copyright.h>
 #include <moira.h>
 #include <moira_site.h>
-#include <menu.h>
-#include <ctype.h>
-
-#include "mit-copyright.h"
 #include "defs.h"
 #include "f_defs.h"
 #include "globals.h"
-#include <netdb.h>             /* for gethostbyname. */
-#include <sys/types.h>
+
 #include <netinet/in.h>
 #include <arpa/inet.h>
+#include <netdb.h>             /* for gethostbyname. */
+
+#include <ctype.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <time.h>
 
+RCSID("$Header$");
 
 /*     Function Name: AddQueue
  *     Description: Adds an element to a queue
@@ -84,7 +78,7 @@ char **CopyInfo(char **info)
   if (!ret)
     return ret;
   for (i = 0; info[i]; i++)
-    ret[i] = Strsave(info[i]);
+    ret[i] = strdup(info[i]);
   ret[i] = NULL;
   return ret;
 }
@@ -142,7 +136,7 @@ struct qelem *QueueTop(struct qelem *elem)
 
 static void FreeQueueElem(struct qelem *elem)
 {
-  char **info = (char **) elem->q_data;
+  char **info = elem->q_data;
 
   if (info)
     {
@@ -201,10 +195,10 @@ int QueueCount(struct qelem *elem)
  *     Returns: MR_CONT, or MR_ABORT if it has problems.
  */
 
-int StoreInfo(int argc, char **argv, char *data)
+int StoreInfo(int argc, char **argv, void *data)
 {
   char **info = malloc(MAX_ARGS_SIZE * sizeof(char *));
-  struct qelem **old_elem = (struct qelem **) data;
+  struct qelem **old_elem = data;
   struct qelem *new_elem = malloc(sizeof(struct qelem));
   int count;
 
@@ -217,10 +211,10 @@ int StoreInfo(int argc, char **argv, char *data)
     }
 
   for (count = 0; count < argc; count++)
-    info[count] = Strsave(argv[count]);
+    info[count] = strdup(argv[count]);
   info[count] = NULL;          /* NULL terminate this sucker. */
 
-  new_elem->q_data = (char *) info;
+  new_elem->q_data = info;
   AddQueue(new_elem, *old_elem);
 
   *old_elem = new_elem;
@@ -247,23 +241,6 @@ int CountArgs(char **info)
   return number;
 }
 
-/*     Function Name: Scream
- *     Description: Bitch Loudly and exit, it is intended as a callback
- *                   function for queries that should never return a value.
- *     Arguments: none
- *     Returns: doesn't exit.
- */
-
-int Scream(void)
-{
-  com_err(program_name, 0,
-         "\nA Moira update returned a value -- programmer botch\n");
-  mr_disconnect();
-  exit(1);
-  /*NOTREACHED*/
-  return -1;
-}
-
 /*     Function Name: PromptWithDefault
  *     Description: allows a user to be prompted for input, and given a
  *                   default choice.
@@ -401,7 +378,7 @@ Bool ValidName(char *s)
  *     Returns: DM_NORMAL.
  */
 
-int ToggleVerboseMode(void)
+int ToggleVerboseMode(int argc, char **argv)
 {
   verbose = !verbose;
 
@@ -413,17 +390,6 @@ int ToggleVerboseMode(void)
   return DM_NORMAL;
 }
 
-/*     Function Name: NullFunc
- *     Description:  dummy callback routine
- *     Arguments: none
- *     Returns: MR_CONT
- */
-
-int NullFunc(void)
-{
-  return MR_CONT;
-}
-
 /*     Function Name: SlipInNewName
  *     Description: Slips the new name into the number 2 slot of a list, and
  *                   returns a pointer to the new list.
@@ -471,7 +437,7 @@ int GetValueFromUser(char *prompt, char **pointer)
       if (strcmp(buf, *pointer))
        {
          free(*pointer);
-         *pointer = Strsave(buf);
+         *pointer = strdup(buf);
        }
     }
   return SUB_NORMAL;
@@ -503,12 +469,12 @@ int GetYesNoValueFromUser(char *prompt, char **pointer)
     case TRUE:
       if (*pointer)
        free(*pointer);
-      *pointer = Strsave(DEFAULT_YES);
+      *pointer = strdup(DEFAULT_YES);
       break;
     case FALSE:
       if (*pointer)
        free(*pointer);
-      *pointer = Strsave(DEFAULT_NO);
+      *pointer = strdup(DEFAULT_NO);
       break;
     case -1:
     default:
@@ -576,33 +542,16 @@ int GetFSTypes(char **current, int options)
 
   FreeAndClear(current, TRUE);
   sprintf(ret_value, "%d", new_val);
-  *current = Strsave(ret_value);
+  *current = strdup(ret_value);
   return SUB_NORMAL;
 }
 
-/*     Function Name: Strsave
- *     Description: save a string.
- *     Arguments: string  - the string to save.
- *     Returns: The malloced string, now safely saved, or NULL.
- */
-
-char *Strsave(char *str)
-{
-  char *newstr = malloc(strlen(str) + 1);
-
-  if (!newstr)
-    return NULL;
-  else
-    return strcpy(newstr, str);
-}
-
-
 /* atot: convert ASCII integer unix time into human readable date string */
 
 char *atot(char *itime)
 {
   time_t time;
-  char *ct, *ctime();
+  char *ct;
 
   time = (time_t) atoi(itime);
   ct = ctime(&time);
@@ -618,7 +567,7 @@ char *atot(char *itime)
  *     Returns: MR_CONT
  */
 
-int Print(int argc, char **argv, char *callback)
+int Print(int argc, char **argv, void *callback)
 {
   char buf[BUFSIZ];
   int i;
@@ -641,7 +590,7 @@ int Print(int argc, char **argv, char *callback)
  *     Returns: MR_CONT or MR_QUIT.
  */
 
-int PrintByType(int argc, char **argv, char *callback)
+int PrintByType(int argc, char **argv, void *callback)
 {
   if (!callback)
     return Print(argc, argv, callback);
@@ -675,12 +624,11 @@ int PrintHelp(char **message)
  *     Returns: none.
  */
 
-void Loop(struct qelem *elem, FVoid func)
+void Loop(struct qelem *elem, void (*func)(char **))
 {
   while (elem)
     {
-      char **info = (char **) elem->q_data;
-      (*func) (info);
+      (*func) (elem->q_data);
       elem = elem->q_forw;
     }
 }
@@ -712,8 +660,8 @@ void Loop(struct qelem *elem, FVoid func)
  *                              "Delete the list"
  */
 
-void QueryLoop(struct qelem *elem, FCharStar print_func,
-              FVoid op_func, char *query_string)
+void QueryLoop(struct qelem *elem, char * (*print_func)(char **),
+              void (*op_func)(char **, Bool), char *query_string)
 {
   Bool one_item;
   char temp_buf[BUFSIZ], *name;
@@ -722,7 +670,7 @@ void QueryLoop(struct qelem *elem, FCharStar print_func,
   one_item = (QueueCount(elem) == 1);
   while (elem)
     {
-      char **info = (char **) elem->q_data;
+      char **info = elem->q_data;
 
       if (one_item)
        (*op_func) (info, one_item);
@@ -767,7 +715,7 @@ char *NullPrint(char **info)
 struct qelem *GetTypeValues(char *tname)
 {
   int stat;
-  char *argv[3], *p, **pp, *strsave();
+  char *argv[3], *p, **pp;
   struct qelem *elem, *oelem;
   static struct qelem *cache = NULL;
   struct cache_elem {
@@ -777,7 +725,7 @@ struct qelem *GetTypeValues(char *tname)
 
   for (elem = cache; elem; elem = elem->q_forw)
     {
-      ce = (struct cache_elem *) elem->q_data;
+      ce = elem->q_data;
       if (!strcmp(ce->cache_name, tname))
        return ce->cache_data;
     }
@@ -786,7 +734,7 @@ struct qelem *GetTypeValues(char *tname)
   argv[1] = "TYPE";
   argv[2] = "*";
   elem = NULL;
-  if ((stat = do_mr_query("get_alias", 3, argv, StoreInfo, (char *)&elem)))
+  if ((stat = do_mr_query("get_alias", 3, argv, StoreInfo, &elem)))
     {
       com_err(program_name, stat, " in GetTypeValues");
       return NULL;
@@ -794,16 +742,16 @@ struct qelem *GetTypeValues(char *tname)
   oelem = elem;
   for (elem = QueueTop(elem); elem; elem = elem->q_forw)
     {
-      pp = (char **) elem->q_data;
-      p = strsave(pp[2]);
+      pp = elem->q_data;
+      p = strdup(pp[2]);
       FreeInfo(pp);
       elem->q_data = p;
     }
   elem = malloc(sizeof(struct qelem));
   ce = malloc(sizeof(struct cache_elem));
-  ce->cache_name = strsave(tname);
+  ce->cache_name = strdup(tname);
   ce->cache_data = QueueTop(oelem);
-  elem->q_data = (char *) ce;
+  elem->q_data = ce;
   AddQueue(elem, cache);
   cache = QueueTop(elem);
   return ce->cache_data;
@@ -842,7 +790,7 @@ int GetTypeFromUser(char *prompt, char *tname, char **pointer)
       Put_message(buffer);
       for (elem = GetTypeValues(tname); elem; elem = elem->q_forw)
        Put_message(elem->q_data);
-      *pointer = strsave(def);
+      *pointer = strdup(def);
       return GetTypeFromUser(prompt, tname, pointer);
     }
   for (elem = GetTypeValues(tname); elem; elem = elem->q_forw)
@@ -875,17 +823,17 @@ int GetTypeFromUser(char *prompt, char *tname, char **pointer)
                *p = toupper(*p);
            }
        }
-      if ((stat = do_mr_query("add_alias", 3, argv, Scream, NULL)))
+      if ((stat = do_mr_query("add_alias", 3, argv, NULL, NULL)))
        com_err(program_name, stat, " in add_alias");
       else
        {
          elem = malloc(sizeof(struct qelem));
-         elem->q_data = strsave(*pointer);
+         elem->q_data = strdup(*pointer);
          AddQueue(elem, GetTypeValues(tname));
          Put_message("Done.");
        }
     }
-  *pointer = strsave(def);
+  *pointer = strdup(def);
   return GetTypeFromUser(prompt, tname, pointer);
 }
 
@@ -904,19 +852,20 @@ int GetAddressFromUser(char *prompt, char **pointer)
   int ret;
 
   addr.s_addr = htonl(atoi(*pointer));
-  value = strsave(inet_ntoa(addr));
+  value = strdup(inet_ntoa(addr));
   ret = GetValueFromUser(prompt, &value);
   if (ret == SUB_ERROR)
     return SUB_ERROR;
   addr.s_addr = inet_addr(value);
   free(pointer);
-  sprintf(buf, "%d", ntohl(addr.s_addr));
-  *pointer = strsave(buf);
+  sprintf(buf, "%ld", ntohl(addr.s_addr));
+  *pointer = strdup(buf);
   return SUB_NORMAL;
 }
 
 
-int do_mr_query(char *name, int argc, char **argv, int (*proc)(), char *hint)
+int do_mr_query(char *name, int argc, char **argv,
+               int (*proc)(int, char **, void *), void *hint)
 {
   int status;
   extern char *whoami, *moira_server;
index 10241a5e28a4d8b3b9a80a70f81a9d11a1361acc..96322cc4f11a209f2c4d90bbc6f0ccc83e5830c0 100644 (file)
@@ -1,39 +1,40 @@
-/* $Header$
+/* $Id $
  *
  * Zephyr ACL routines for the Moira client
  *
- * Copyright 1990 by the Massachusetts Institute of Technology.
- *
- * For further information on copyright and distribution see the
- * file mit-copyright.h
+ * Copyright (C) 1990-1998 by the Massachusetts Institute of Technology.
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
  */
 
-#include <stdio.h>
-#include <string.h>
-#include <ctype.h>
+#include <mit-copyright.h>
 #include <moira.h>
 #include <moira_site.h>
-#include <menu.h>
-#include <mit-copyright.h>
-
 #include "defs.h"
 #include "f_defs.h"
 #include "globals.h"
 
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+RCSID("$Header$");
+
+void RealDeleteZephyr(char **info, Bool one_item);
 
 /* Set the default values for zephyr additions. */
 
 static char **SetDefaults(char **info, char *name)
 {
-  info[ZA_CLASS] = strsave(name);
-  info[ZA_XMT_TYPE] = strsave("LIST");
-  info[ZA_SUB_TYPE] = strsave("LIST");
-  info[ZA_IWS_TYPE] = strsave("LIST");
-  info[ZA_IUI_TYPE] = strsave("LIST");
-  info[ZA_XMT_ID] = strsave("empty");
-  info[ZA_SUB_ID] = strsave("empty");
-  info[ZA_IWS_ID] = strsave("empty");
-  info[ZA_IUI_ID] = strsave("empty");
+  info[ZA_CLASS] = strdup(name);
+  info[ZA_XMT_TYPE] = strdup("LIST");
+  info[ZA_SUB_TYPE] = strdup("LIST");
+  info[ZA_IWS_TYPE] = strdup("LIST");
+  info[ZA_IUI_TYPE] = strdup("LIST");
+  info[ZA_XMT_ID] = strdup("empty");
+  info[ZA_SUB_ID] = strdup("empty");
+  info[ZA_IWS_ID] = strdup("empty");
+  info[ZA_IUI_ID] = strdup("empty");
   info[ZA_MODTIME] = info[ZA_MODBY] = info[ZA_MODWITH] = NULL;
   info[ZA_END] = NULL;
   return info;
@@ -47,8 +48,7 @@ static struct qelem *GetZephyrInfo(char *name)
   int stat;
   struct qelem *elem = NULL;
 
-  if ((stat = do_mr_query("get_zephyr_class", 1, &name, StoreInfo,
-                         (char *)&elem)))
+  if ((stat = do_mr_query("get_zephyr_class", 1, &name, StoreInfo, &elem)))
     {
       com_err(program_name, stat, " in GetZephyrInfo");
       return NULL;
@@ -59,21 +59,21 @@ static struct qelem *GetZephyrInfo(char *name)
 
 /* Print zephyr acl info */
 
-static void PrintZephyrInfo(char **info)
+static char *PrintZephyrInfo(char **info)
 {
   char buf[BUFSIZ];
 
   if (!info)
     {
       Put_message("PrintZephyrInfo called with null info!");
-      return;
+      return NULL;
     }
   sprintf(buf, "        Zephyr class: %s", info[ZA_CLASS]);
   Put_message(buf);
   if (!strcmp(info[ZA_XMT_ID], "WILDCARD"))
     {
       free(info[ZA_XMT_ID]);
-      info[ZA_XMT_ID] = strsave("*.*@*");
+      info[ZA_XMT_ID] = strdup("*.*@*");
     }
   sprintf(buf, "Transmit ACL:           %s %s", info[ZA_XMT_TYPE],
          strcasecmp(info[ZA_XMT_TYPE], "NONE") ? info[ZA_XMT_ID] : "");
@@ -81,7 +81,7 @@ static void PrintZephyrInfo(char **info)
   if (!strcmp(info[ZA_SUB_ID], "WILDCARD"))
     {
       free(info[ZA_SUB_ID]);
-      info[ZA_SUB_ID] = strsave("*.*@*");
+      info[ZA_SUB_ID] = strdup("*.*@*");
     }
   sprintf(buf, "Subscription ACL:       %s %s", info[ZA_SUB_TYPE],
          strcasecmp(info[ZA_SUB_TYPE], "NONE") ? info[ZA_SUB_ID] : "");
@@ -89,7 +89,7 @@ static void PrintZephyrInfo(char **info)
   if (!strcmp(info[ZA_IWS_ID], "WILDCARD"))
     {
       free(info[ZA_IWS_ID]);
-      info[ZA_IWS_ID] = strsave("*.*@*");
+      info[ZA_IWS_ID] = strdup("*.*@*");
     }
   sprintf(buf, "Instance Wildcard ACL:  %s %s", info[ZA_IWS_TYPE],
          strcasecmp(info[ZA_IWS_TYPE], "NONE") ? info[ZA_IWS_ID] : "");
@@ -97,13 +97,15 @@ static void PrintZephyrInfo(char **info)
   if (!strcmp(info[ZA_IUI_ID], "WILDCARD"))
     {
       free(info[ZA_IUI_ID]);
-      info[ZA_IUI_ID] = strsave("*.*@*");
+      info[ZA_IUI_ID] = strdup("*.*@*");
     }
   sprintf(buf, "Instance Indentity ACL: %s %s", info[ZA_IUI_TYPE],
          strcasecmp(info[ZA_IUI_TYPE], "NONE") ? info[ZA_IUI_ID] : "");
   Put_message(buf);
   sprintf(buf, MOD_FORMAT, info[ZA_MODBY], info[ZA_MODTIME], info[ZA_MODWITH]);
   Put_message(buf);
+
+  return info[ZA_CLASS];
 }
 
 
@@ -122,7 +124,7 @@ static char **AskZephyrInfo(char **info, Bool rename)
     {
       while (1)
        {
-         newname = Strsave(info[ZA_CLASS]);
+         newname = strdup(info[ZA_CLASS]);
          if (GetValueFromUser("The new name for this class", &newname) ==
              SUB_ERROR)
            return NULL;
@@ -139,7 +141,7 @@ static char **AskZephyrInfo(char **info, Bool rename)
       if (!strcmp(info[ZA_XMT_ID], "WILDCARD"))
        {
          free(info[ZA_XMT_ID]);
-         info[ZA_XMT_ID] = strsave("*.*@*");
+         info[ZA_XMT_ID] = strdup("*.*@*");
        }
       sprintf(buf, "Which %s: ", info[ZA_XMT_TYPE]);
       if (GetValueFromUser(buf, &info[ZA_XMT_ID]) == SUB_ERROR)
@@ -147,7 +149,7 @@ static char **AskZephyrInfo(char **info, Bool rename)
       if (!strcmp(info[ZA_XMT_ID], "*.*@*"))
        {
          free(info[ZA_XMT_ID]);
-         info[ZA_XMT_ID] = strsave("WILDCARD");
+         info[ZA_XMT_ID] = strdup("WILDCARD");
        }
     }
   if (GetTypeFromUser("What kind of subscription restriction", "ace_type",
@@ -158,7 +160,7 @@ static char **AskZephyrInfo(char **info, Bool rename)
       if (!strcmp(info[ZA_SUB_ID], "WILDCARD"))
        {
          free(info[ZA_SUB_ID]);
-         info[ZA_SUB_ID] = strsave("*.*@*");
+         info[ZA_SUB_ID] = strdup("*.*@*");
        }
       sprintf(buf, "Which %s: ", info[ZA_SUB_TYPE]);
       if (GetValueFromUser(buf, &info[ZA_SUB_ID]) == SUB_ERROR)
@@ -166,7 +168,7 @@ static char **AskZephyrInfo(char **info, Bool rename)
       if (!strcmp(info[ZA_SUB_ID], "*.*@*"))
        {
          free(info[ZA_SUB_ID]);
-         info[ZA_SUB_ID] = strsave("WILDCARD");
+         info[ZA_SUB_ID] = strdup("WILDCARD");
        }
     }
   if (GetTypeFromUser("What kind of wildcard instance restriction",
@@ -177,7 +179,7 @@ static char **AskZephyrInfo(char **info, Bool rename)
       if (!strcmp(info[ZA_IWS_ID], "WILDCARD"))
        {
          free(info[ZA_IWS_ID]);
-         info[ZA_IWS_ID] = strsave("*.*@*");
+         info[ZA_IWS_ID] = strdup("*.*@*");
        }
       sprintf(buf, "Which %s: ", info[ZA_IWS_TYPE]);
       if (GetValueFromUser(buf, &info[ZA_IWS_ID]) == SUB_ERROR)
@@ -185,7 +187,7 @@ static char **AskZephyrInfo(char **info, Bool rename)
       if (!strcmp(info[ZA_IWS_ID], "*.*@*"))
        {
          free(info[ZA_IWS_ID]);
-         info[ZA_IWS_ID] = strsave("WILDCARD");
+         info[ZA_IWS_ID] = strdup("WILDCARD");
        }
     }
   if (GetTypeFromUser("What kind of instance identity restriction",
@@ -196,7 +198,7 @@ static char **AskZephyrInfo(char **info, Bool rename)
       if (!strcmp(info[ZA_IUI_ID], "WILDCARD"))
        {
          free(info[ZA_IUI_ID]);
-         info[ZA_IUI_ID] = strsave("*.*@*");
+         info[ZA_IUI_ID] = strdup("*.*@*");
        }
       sprintf(buf, "Which %s: ", info[ZA_IUI_TYPE]);
       if (GetValueFromUser(buf, &info[ZA_IUI_ID]) == SUB_ERROR)
@@ -204,7 +206,7 @@ static char **AskZephyrInfo(char **info, Bool rename)
       if (!strcmp(info[ZA_IUI_ID], "*.*@*"))
        {
          free(info[ZA_IUI_ID]);
-         info[ZA_IUI_ID] = strsave("WILDCARD");
+         info[ZA_IUI_ID] = strdup("WILDCARD");
        }
     }
   FreeAndClear(&info[ZA_MODTIME], TRUE);
@@ -236,7 +238,7 @@ void RealDeleteZephyr(char **info, Bool one_item)
   int stat;
 
   if ((stat = do_mr_query("delete_zephyr_class", 1, &info[ZA_CLASS],
-                         Scream, NULL)))
+                         NULL, NULL)))
     com_err(program_name, stat, " zephyr class restriction not deleted.");
   else
     Put_message("Zephyr class restriction deleted.");
@@ -265,8 +267,7 @@ int AddZephyr(int argc, char **argv)
   if (!ValidName(argv[1]))
     return DM_NORMAL;
 
-  if (!(stat = do_mr_query("get_zephyr_class", 1, argv + 1,
-                          NullFunc, NULL)))
+  if (!(stat = do_mr_query("get_zephyr_class", 1, argv + 1, NULL, NULL)))
     {
       Put_message ("A Zephyr class by that name already exists.");
       return DM_NORMAL;
@@ -285,7 +286,7 @@ int AddZephyr(int argc, char **argv)
     }
 
   if ((stat = do_mr_query("add_zephyr_class", CountArgs(args), args,
-                         NullFunc, NULL)))
+                         NULL, NULL)))
     com_err(program_name, stat, " in AddZephyr");
 
   FreeInfo(info);
@@ -306,7 +307,7 @@ static void RealUpdateZephyr(char **info, Bool junk)
       return;
     }
   if ((stat = do_mr_query("update_zephyr_class", CountArgs(args), args,
-                         Scream, NULL)))
+                         NULL, NULL)))
     {
       com_err(program_name, stat, " in UpdateZephyr.");
       Put_message("Zephyr class ** NOT ** Updated.");
index b1924820effac32bf3bfd4b051fb0520afccc8a4..9e48df4695b88a1ad787424f822b04b90975ecb0 100644 (file)
@@ -1,26 +1,30 @@
-/*
- * Verify that all Moira updates are successful
+/* $Id $
  *
- * Copyright 1988, 1991 by the Massachusetts Institute of Technology.
- * For copying and distribution information, see the file "mit-copyright.h".
+ * Verify that all Moira updates are successful
  *
- * $Header$
- * $Author$
+ * Copyright (C) 1988-1998 by the Massachusetts Institute of Technology.
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
  */
 
-#ifndef lint
-static char *rcsid_chsh_c = "$Header$";
-#endif
-
-#include <stdio.h>
+#include <mit-copyright.h>
 #include <moira.h>
 #include <moira_site.h>
-#include "mit-copyright.h"
-#include <sys/time.h>
+
+#include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 #include <time.h>
 
+RCSID("$Header$");
+
+char *atot(char *itime);
+int process_server(int argc, char **argv, void *sqv);
+void disp_svc(char **argv, char *msg);
+int process_host(int argc, char **argv, void *sqv);
+void disp_sh(char **argv, char *msg);
+int usage(void);
+
 static int count = 0;
 static char *whoami;
 static struct timeval now;
@@ -51,9 +55,10 @@ char *atot(char *itime)
  * interval for later use.
  */
 
-int process_server(int argc, char **argv, struct save_queue *sq)
+int process_server(int argc, char **argv, void *sqv)
 {
   struct service *s;
+  struct save_queue *sq = sqv;
 
   if (atoi(argv[SVC_ENABLE]))
     {
@@ -79,9 +84,9 @@ int process_server(int argc, char **argv, struct save_queue *sq)
 
 /* Format the information about a service. */
 
-int disp_svc(char **argv, char *msg)
+void disp_svc(char **argv, char *msg)
 {
-  char *tmp = strsave(atot(argv[SVC_DFGEN]));
+  char *tmp = strdup(atot(argv[SVC_DFGEN]));
 
   printf("Service %s Interval %s %s/%s/%s %s\n",
         argv[SVC_SERVICE], argv[SVC_INTERVAL],
@@ -100,10 +105,10 @@ int disp_svc(char **argv, char *msg)
 
 /* Decide if the host has an error or not. */
 
-int process_host(int argc, char **argv, struct save_queue *sq)
+int process_host(int argc, char **argv, void *sqv)
 {
   struct service *s = NULL;
-  struct save_queue *sq1;
+  struct save_queue *sq = sqv, *sq1;
   char *update_int = NULL;
 
   for (sq1 = sq->q_next; sq1 != sq; sq1 = sq1->q_next)
@@ -131,9 +136,9 @@ int process_host(int argc, char **argv, struct save_queue *sq)
 
 /* Format the information about a host. */
 
-int disp_sh(char **argv, char *msg)
+void disp_sh(char **argv, char *msg)
 {
-  char *tmp = strsave(atot(argv[SH_LASTTRY]));
+  char *tmp = strdup(atot(argv[SH_LASTTRY]));
 
   printf("Host %s:%s %s/%s/%s/%s/%s %s\n",
         argv[SH_SERVICE], argv[SH_MACHINE],
@@ -158,7 +163,6 @@ int main(int argc, char *argv[])
   char *args[2], buf[BUFSIZ], *motd;
   struct save_queue *sq;
   int status;
-  int scream();
   int auth_required = 1;
 
   if ((whoami = strrchr(argv[0], '/')) == NULL)
@@ -203,14 +207,12 @@ int main(int argc, char *argv[])
 
   /* Check services first */
   args[0] = "*";
-  if ((status = mr_query("get_server_info", 1, args,
-                        process_server, (char *)sq)) &&
+  if ((status = mr_query("get_server_info", 1, args, process_server, sq)) &&
       status != MR_NO_MATCH)
     com_err(whoami, status, " while getting servers");
 
   args[1] = "*";
-  if ((status = mr_query("get_server_host_info", 2, args,
-                        process_host, (char *)sq)) &&
+  if ((status = mr_query("get_server_host_info", 2, args, process_host, sq)) &&
       status != MR_NO_MATCH)
     com_err(whoami, status, " while getting servers");
 
@@ -229,15 +231,6 @@ punt:
   exit(1);
 }
 
-
-int scream(void)
-{
-  com_err(whoami, 0,
-         "Update to Moira returned a value -- programmer botch.\n");
-  mr_disconnect();
-  exit(1);
-}
-
 int usage(void)
 {
   fprintf(stderr, "Usage: %s [-noauth]\n", whoami);
index f858ebd7dc5240df4cc51b6e06f0f4f6af735ff8..7471b36f61297be079e778cf23982b910259d19a 100644 (file)
@@ -1,36 +1,32 @@
-/*
- *     $Source$
- *     $Author$
- *     $Header$
+/* $Id $
  *
- *     Copyright (C) 1987 by the Massachusetts Institute of Technology
- *     For copying and distribution information, please see the file
- *     <mit-copyright.h>.
+ * Bare-bones Moira client
  *
+ * Copyright (C) 1987-1998 by the Massachusetts Institute of Technology
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
  */
 
-#ifndef lint
-static char *rcsid_test_c = "$Header$";
-#endif /* lint */
-
 #include <mit-copyright.h>
-#include <stdio.h>
-#include <sys/types.h>
-#include <sys/file.h>
-#include <fcntl.h>
-#include <ctype.h>
-#include <string.h>
 #include <moira.h>
-#include <com_err.h>
+
+#include <errno.h>
+#include <fcntl.h>
 #include <setjmp.h>
 #include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
 
 #ifdef USE_READLINE
 #include "readline.h"
+#include "history.h"
 #endif
 
+RCSID("$Header$");
+
 int recursion = 0, interactive;
-extern int errno;
 extern int sending_version_no;
 int count, quit = 0, cancel = 0;
 char *whoami;
@@ -38,8 +34,24 @@ sigjmp_buf jb;
 
 #define MAXARGS 20
 
-void discard_input();
-char *mr_gets();
+void discard_input(void);
+char *mr_gets(char *prompt, char *buf, size_t len);
+void execute_line(char *cmdbuf);
+int parse(char *buf, char *argv[MAXARGS]);
+int print_reply(int argc, char **argv, void *hint);
+void test_noop(void);
+void test_connect(int argc, char **argv);
+void test_disconnect(void);
+void test_host(void);
+void test_new(void);
+void test_old(void);
+void test_motd(void);
+void test_query(int argc, char **argv);
+void test_auth(void);
+void test_access(int argc, char **argv);
+void test_dcm(void);
+void test_script(int argc, char **argv);
+void test_list_requests(void);
 
 int main(int argc, char **argv)
 {
@@ -114,7 +126,7 @@ char *mr_gets(char *prompt, char *buf, size_t len)
   return buf;
 }
 
-int execute_line(char *cmdbuf)
+void execute_line(char *cmdbuf)
 {
   int argc;
   char *argv[MAXARGS];
@@ -139,7 +151,7 @@ int execute_line(char *cmdbuf)
   else if (!strcmp(argv[0], "query") || !strcmp(argv[0], "qy"))
     test_query(argc, argv);
   else if (!strcmp(argv[0], "auth") || !strcmp(argv[0], "a"))
-    test_auth(argc, argv);
+    test_auth();
   else if (!strcmp(argv[0], "access"))
     test_access(argc, argv);
   else if (!strcmp(argv[0], "dcm"))
@@ -221,24 +233,24 @@ int parse(char *buf, char *argv[MAXARGS])
   return argc + 1;
 }
 
-int test_noop(void)
+void test_noop(void)
 {
   int status = mr_noop();
   if (status)
     com_err("moira (noop)", status, "");
 }
 
-int test_new(void)
+void test_new(void)
 {
   sending_version_no = MR_VERSION_2;
 }
 
-int test_old(void)
+void test_old(void)
 {
   sending_version_no = MR_VERSION_1;
 }
 
-int test_connect(int argc, char *argv[])
+void test_connect(int argc, char *argv[])
 {
   char *server = "";
   int status;
@@ -250,14 +262,14 @@ int test_connect(int argc, char *argv[])
     com_err("moira (connect)", status, "");
 }
 
-int test_disconnect(void)
+void test_disconnect(void)
 {
   int status = mr_disconnect();
   if (status)
     com_err("moira (disconnect)", status, "");
 }
 
-int test_host(void)
+void test_host(void)
 {
   char host[BUFSIZ];
   int status;
@@ -270,7 +282,7 @@ int test_host(void)
     printf("You are connected to host %s\n", host);
 }
 
-int test_auth(int argc, char *argv[])
+void test_auth(void)
 {
   int status;
 
@@ -279,7 +291,7 @@ int test_auth(int argc, char *argv[])
     com_err("moira (auth)", status, "");
 }
 
-int test_script(int argc, char *argv[])
+void test_script(int argc, char *argv[])
 {
   FILE *inp;
   char input[BUFSIZ], *cp;
@@ -371,7 +383,7 @@ int test_script(int argc, char *argv[])
     }
 }
 
-int print_reply(int argc, char **argv)
+int print_reply(int argc, char **argv, void *hint)
 {
   int i;
   for (i = 0; i < argc; i++)
@@ -385,7 +397,7 @@ int print_reply(int argc, char **argv)
   return MR_CONT;
 }
 
-int test_query(int argc, char **argv)
+void test_query(int argc, char **argv)
 {
   int status;
   sigset_t sigs;
@@ -409,7 +421,7 @@ int test_query(int argc, char **argv)
     com_err("moira (query)", status, "");
 }
 
-int test_access(int argc, char **argv)
+void test_access(int argc, char **argv)
 {
   int status;
   if (argc < 2)
@@ -422,7 +434,7 @@ int test_access(int argc, char **argv)
     com_err("moira (access)", status, "");
 }
 
-int test_dcm(int argc, char **argv)
+void test_dcm()
 {
   int status;
 
@@ -430,7 +442,7 @@ int test_dcm(int argc, char **argv)
     com_err("moira (dcm)", status, " while triggering dcm");
 }
 
-int test_motd(int argc, char **argv)
+void test_motd()
 {
   int status;
   char *motd;
@@ -443,7 +455,7 @@ int test_motd(int argc, char **argv)
     printf("No message of the day.\n");
 }
 
-int test_list_requests(void)
+void test_list_requests(void)
 {
   printf("Available moira requests:\n");
   printf("\n");
index 6323146a294ce37293a8d2351e7d2b56040fcaf2..3b0aaf5a4953f9700c616c669312d7252b817905 100644 (file)
@@ -1,18 +1,5 @@
-/*
- * Copyright 1988 by the Massachusetts Institute of Technology. For copying
- * and distribution information, see the file "mit-copyright.h".
+/* $Id $
  *
- * $Source$
- * $Header$
- * $Author$
- *
- */
-
-#ifndef lint
-static char *rcsid_chfn_c = "$Header$";
-#endif
-
-/*
  * Talk to the Moira database to change a person's GECOS information.
  *
  * chfn with no modifiers changes the information of the user who is
@@ -21,23 +8,25 @@ static char *rcsid_chfn_c = "$Header$";
  * If a commandline argument is given, it is taken to be the username
  * of the user whose information is to be changed.
  *
+ * Copyright (C) 1988-1998 by the Massachusetts Institute of Technology
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
  */
 
-#define FALSE 0
-#define TRUE 1
+#include <mit-copyright.h>
+#include <moira.h>
+#include <moira_site.h>
 
-#include <sys/types.h>
+#include <ctype.h>
 #include <stdio.h>
 #include <string.h>
-#include <sys/file.h>
+
 #include <krb.h>
-#include <ctype.h>
-#include <errno.h>
 
-/* Moira includes */
-#include <moira.h>
-#include <moira_site.h>
-#include "mit-copyright.h"
+RCSID("$Header$");
+
+#define FALSE 0
+#define TRUE 1
 
 char *whoami;
 
@@ -52,6 +41,13 @@ struct finger_info {
   char *mit_year;
 };
 
+int usage(void);
+int leave(int status);
+int chfn(char *uname);
+int get_user_info(int argc, char *argv[], void *message);
+char *ask(char *question, char *def_val, int phone_num);
+void get_new_info(struct finger_info *old_info, struct finger_info *new_info);
+
 int main(int argc, char *argv[])
 {
   char pname[ANAME_SZ];
@@ -81,7 +77,7 @@ int main(int argc, char *argv[])
          exit(1);
        }
 
-      if (k_errno = tf_get_pname(pname))
+      if ((k_errno = tf_get_pname(pname)))
        {
          com_err(whoami, k_errno, "getting kerberos principal name");
          exit(1);
@@ -101,12 +97,6 @@ int leave(int status)
   exit(status);
 }
 
-int scream(void)
-{
-  com_err(whoami, 0, "Unexpected return value from Moira -- programmer botch");
-  leave(1);
-}
-
 int chfn(char *uname)
 {
   int status;                  /* general purpose exit status */
@@ -115,9 +105,6 @@ int chfn(char *uname)
   char *motd;                  /* for Moira server status */
   int i;
 
-  int get_user_info();
-  void get_new_info();
-
   struct finger_info old_info;
   struct finger_info new_info;
 
@@ -171,7 +158,7 @@ int chfn(char *uname)
   q_argv[NAME] = uname;
   q_argc = NAME + 1;
   if ((status = mr_query("get_finger_by_login", q_argc, q_argv,
-                        get_user_info, (char *) &old_info)))
+                        get_user_info, &old_info)))
     {
       com_err(whoami, status, "while getting user information.");
       leave(2);
@@ -197,7 +184,7 @@ int chfn(char *uname)
   q_argc = F_MODTIME;          /* First non-update query argument */
 
   if ((status = mr_query("update_finger_by_login", q_argc, q_argv,
-                        scream, NULL)))
+                        NULL, NULL)))
     {
       com_err(whoami, status, "while updating finger information.");
       leave(1);
@@ -208,9 +195,9 @@ int chfn(char *uname)
   return 0;
 }
 
-int get_user_info(int argc, char *argv[], char *message)
+int get_user_info(int argc, char *argv[], void *message)
 {
-  struct finger_info *old_info = (struct finger_info *) message;
+  struct finger_info *old_info = message;
 
   if (argc != F_END)
     {
@@ -221,14 +208,14 @@ int get_user_info(int argc, char *argv[], char *message)
   printf("Info last changed on %s by user %s with %s.\n",
         argv[F_MODTIME], argv[F_MODBY], argv[F_MODWITH]);
 
-  old_info->fullname = strsave(argv[F_FULLNAME]);
-  old_info->nickname = strsave(argv[F_NICKNAME]);
-  old_info->home_address = strsave(argv[F_HOME_ADDR]);
-  old_info->home_phone = strsave(argv[F_HOME_PHONE]);
-  old_info->office_address = strsave(argv[F_OFFICE_ADDR]);
-  old_info->office_phone = strsave(argv[F_OFFICE_PHONE]);
-  old_info->mit_department = strsave(argv[F_MIT_DEPT]);
-  old_info->mit_year = strsave(argv[F_MIT_AFFIL]);
+  old_info->fullname = strdup(argv[F_FULLNAME]);
+  old_info->nickname = strdup(argv[F_NICKNAME]);
+  old_info->home_address = strdup(argv[F_HOME_ADDR]);
+  old_info->home_phone = strdup(argv[F_HOME_PHONE]);
+  old_info->office_address = strdup(argv[F_OFFICE_ADDR]);
+  old_info->office_phone = strdup(argv[F_OFFICE_PHONE]);
+  old_info->mit_department = strdup(argv[F_MIT_DEPT]);
+  old_info->mit_year = strdup(argv[F_MIT_AFFIL]);
 
   /* Only pay attention to the first match since login names are
      unique in the database. */
@@ -325,7 +312,7 @@ void get_new_info(struct finger_info *old_info, struct finger_info *new_info)
   printf("To accept the default, type <return>.\n");
   printf("To have a blank entry, type the word '%s'.\n\n", BLANK);
 
-#define GETINFO(m, v, n) new_info->v = strsave(ask(m, old_info->v, n))
+#define GETINFO(m, v, n) new_info->v = strdup(ask(m, old_info->v, n))
 
   GETINFO("Full name", fullname, FALSE);
   GETINFO("Nickname", nickname, FALSE);
index d36ed476bd9740363ab9ffb9ae9e3f5453ded06d..2d7ac795fdf635594aa4a1dd81d7fa8f3b2ce12c 100644 (file)
@@ -1,18 +1,5 @@
-/*
- * Copyright 1987 by the Massachusetts Institute of Technology. For copying
- * and distribution information, see the file "mit-copyright.h".
- *
- * $Source$
- * $Header$
- * $Author$
+/* $Id $
  *
- */
-
-#ifndef lint
-static char *rcsid_chpobox_c = "$Header$";
-#endif
-
-/*
  * Talk to the Moira database to change a person's home mail machine. This may
  * be an Athena machine, or a completely arbitrary address.
  *
@@ -26,46 +13,47 @@ static char *rcsid_chpobox_c = "$Header$";
  * are trying to change the email address of another.  You must have
  * Kerberos tickets as the person whose address you are trying to
  * change, or the attempt will fail.
+ *
+ * Copyright (C) 1987-1998 by the Massachusetts Institute of Technology
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
  */
 
-#include <sys/types.h>
-#include <stdio.h>
+#include <mit-copyright.h>
+#include <moira.h>
+#include <moira_site.h>
+
 #include <pwd.h>
+#include <stdio.h>
+#include <stdlib.h>
 #include <string.h>
-#include <ctype.h>
-#include <errno.h>
+#include <unistd.h>
 
-/* Moira includes */
-#include <moira.h>
-#include <moira_site.h>
-#include "mit-copyright.h"
+RCSID("$Header$");
 
-char *getlogin();
-char *malloc();
-char *whoami;
-uid_t getuid();
+int get_pobox(int argc, char **argv, void *callarg);
+char *potype(char *machine);
+int check_match(int argc, char **argv, void *callback);
+int check_match3(int argc, char **argv, void *callback);
+int usage(void);
 
-int getopt();
+char *whoami;
 
 static int match;
 
-
 int main(int argc, char *argv[])
 {
   struct passwd *pwd;
   char *mrarg[3], buf[BUFSIZ];
-  char *potype();
   char *address, *uname, *machine, *motd;
   uid_t u;
-  char *canonicalize_hostname();
-  int get_pobox(), scream();
   int c, setflag, prevpop, usageflag, status;
 
   extern int optind;
   extern char *optarg;
 
   c = setflag = prevpop = usageflag = 0;
-  address = uname = (char *) NULL;
+  address = uname = NULL;
   u = getuid();
 
   if ((whoami = strrchr(argv[0], '/')) == NULL)
@@ -96,7 +84,7 @@ int main(int argc, char *argv[])
          prevpop++;
        break;
       case 'u':
-       uname = strsave(optarg);
+       uname = strdup(optarg);
        break;
       default:
        usageflag++;
@@ -172,7 +160,7 @@ int main(int argc, char *argv[])
                  whoami, address);
          goto show;
        }
-      mrarg[2] = canonicalize_hostname(strsave(machine));
+      mrarg[2] = canonicalize_hostname(strdup(machine));
       mrarg[1] = potype(mrarg[2]);
       if (!strcmp(mrarg[1], "POP"))
        {
@@ -224,7 +212,7 @@ int main(int argc, char *argv[])
          mrarg[2] = address;
        } else
          goto show;
-      status = mr_query("set_pobox", 3, mrarg, scream, NULL);
+      status = mr_query("set_pobox", 3, mrarg, NULL, NULL);
       if (status)
        com_err(whoami, status,
                " while setting pobox for %s to type %s, box %s",
@@ -232,7 +220,7 @@ int main(int argc, char *argv[])
     }
   else if (prevpop)
     {
-      status = mr_query("set_pobox_pop", 1, mrarg, scream, NULL);
+      status = mr_query("set_pobox_pop", 1, mrarg, NULL, NULL);
       if (status == MR_MACHINE)
        {
          fprintf(stderr,
@@ -256,18 +244,11 @@ show:
 }
 
 
-int scream(void)
-{
-  com_err(whoami, 0, "Unexpected return value from Moira -- programmer botch");
-  mr_disconnect();
-  exit(1);
-}
-
 /*
  * get_pobox gets all your poboxes and displays them.
  */
 
-int get_pobox(int argc, char **argv, char *callarg)
+int get_pobox(int argc, char **argv, void *callarg)
 {
   if (!strcmp(argv[1], "POP"))
     printf("User %s, Type %s, Box: %s@%s\n",
@@ -286,7 +267,7 @@ int get_pobox(int argc, char **argv, char *callarg)
 char *potype(char *machine)
 {
   char *service[1], *argv[3];
-  int check_match(), check_match3(), status;
+  int status;
 
   match = 0;
   service[0] = "POP";
@@ -324,7 +305,7 @@ char *potype(char *machine)
     return "SMTP";
 }
 
-int check_match(int argc, char **argv, char *callback)
+int check_match(int argc, char **argv, void *callback)
 {
   if (match)
     return 0;
@@ -335,7 +316,7 @@ int check_match(int argc, char **argv, char *callback)
   return 0;
 }
 
-int check_match3(int argc, char **argv, char *callback)
+int check_match3(int argc, char **argv, void *callback)
 {
   if (match)
     return 0;
index 5ba86718e65dd1a67f37b59398544d003545df1b..d6dd3a1ac7c57c34521398aa73a039da2f021f39 100644 (file)
@@ -1,18 +1,5 @@
-/*
- * Copyright 1988 by the Massachusetts Institute of Technology. For copying
- * and distribution information, see the file "mit-copyright.h".
+/* $Id $
  *
- * $Source$
- * $Header$
- * $Author$
- *
- */
-
-#ifndef lint
-static char *rcsid_chsh_c = "$Header$";
-#endif
-
-/*
  * Talk to the Moira database to change a person's login shell.  The chosen
  * shell must exist.  A warning will be issued if the shell is not in
  * /etc/shells.
@@ -23,24 +10,33 @@ static char *rcsid_chsh_c = "$Header$";
  * If a commandline argument is given, it is taken to be the username
  * of the user whose shell is to be changed.
  *
+ * Copyright (C) 1988-1998 by the Massachusetts Institute of Technology
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
  */
 
-#include <unistd.h>
-#include <sys/types.h>
+#include <mit-copyright.h>
+#include <moira.h>
+#include <moira_site.h>
+
 #include <stdio.h>
 #include <string.h>
-#include <sys/file.h>
+#include <unistd.h>
+
 #include <krb.h>
-#include <ctype.h>
-#include <errno.h>
 
-/* Moira includes */
-#include <moira.h>
-#include <moira_site.h>
-#include "mit-copyright.h"
+RCSID("$Header$");
+
+int usage(void);
+int leave(int status);
+int chsh(char *uname);
+int get_shell(int argc, char **argv, void *uname);
+void check_shell(char *shell);
+#if defined(NEED_GETUSERSHELL) || defined(SOLARIS)
+char *getusershell(void);
+#endif
 
 char *whoami;
-char *getusershell();
 
 int main(int argc, char *argv[])
 {
@@ -91,12 +87,6 @@ int leave(int status)
   exit(status);
 }
 
-int scream(void)
-{
-  com_err(whoami, 0, "Unexpected return value from Moira -- programmer botch");
-  leave(1);
-}
-
 int chsh(char *uname)
 {
   int status;                  /* general purpose exit status */
@@ -106,8 +96,6 @@ int chsh(char *uname)
 
   int got_one = 0;             /* have we got a new shell yet? */
   char shell[BUFSIZ];          /* the new shell */
-  int get_shell();
-  void check_shell();          /* make sure new shell is valid */
 
   /* Try each query.  If we ever fail, print error message and exit. */
 
@@ -159,7 +147,7 @@ int chsh(char *uname)
   q_argc = NAME + 1;
 
   if ((status = mr_query("get_user_account_by_login", q_argc, q_argv,
-                        get_shell, (char *) uname)))
+                        get_shell, uname)))
     {
       com_err(whoami, status, " while getting user information.");
       leave(2);
@@ -186,8 +174,7 @@ int chsh(char *uname)
   q_argv[USH_NAME] = uname;
   q_argv[USH_SHELL] = shell;
   q_argc = USH_END;
-  if ((status = mr_query("update_user_shell", q_argc, q_argv,
-                        scream, NULL)))
+  if ((status = mr_query("update_user_shell", q_argc, q_argv, NULL, NULL)))
     {
       com_err(whoami, status, " while changing shell.");
       leave(2);
@@ -199,7 +186,7 @@ int chsh(char *uname)
   return 0;
 }
 
-int get_shell(int argc, char **argv, char *uname)
+int get_shell(int argc, char **argv, void *uname)
 {
   /* We'll just take the first information we get since login names
      cannot be duplicated in the database. */
@@ -212,7 +199,7 @@ int get_shell(int argc, char **argv, char *uname)
 
   printf("Account information last changed on %s\n", argv[U_MODTIME]);
   printf("by user %s with %s.\n", argv[U_MODBY], argv[U_MODWITH]);
-  printf("Current shell for %s is %s.\n", uname, argv[U_SHELL]);
+  printf("Current shell for %s is %s.\n", (char *)uname, argv[U_SHELL]);
 
   return MR_ABORT;             /* Don't pay attention to other matches. */
 }
@@ -267,7 +254,7 @@ int usage(void)
 }
 
 #ifdef NEED_GETUSERSHELL
-char *getusershell()
+char *getusershell(void)
 {
   static int count = 1;
 
index 2fa13a8520a596b4efb3d27202b36211710d69dc..8b05567e92530ed175badf1b0c4595dc97289cc5 100644 (file)
@@ -1,20 +1,22 @@
-/* $Header$
+/* $Id $
  *
  * disabled: check to see if registration is enabled right now.  Most of this
  * code is stolen from the cron daemon.
  *
- *  (c) Copyright 1988 by the Massachusetts Institute of Technology.
- *  For copying and distribution information, please see the file
- *  <mit-copyright.h>.
+ * Copyright (C) 1988-1998 by the Massachusetts Institute of Technology.
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
  */
 
 #include <mit-copyright.h>
-#include <stdio.h>
+#include <moira.h>
+
 #include <ctype.h>
-#include <sys/types.h>
-#include <sys/time.h>
-#include <sys/file.h>
-#include "files.h"
+#include <stdio.h>
+#include <stdlib.h>
+#include <time.h>
+
+#include "userreg.h"
 
 #define        LISTS   (2 * BUFSIZ)
 #define        MAXLIN  BUFSIZ
 #define        RANGE   103
 #define        EOS     104
 
-time_t itime, time();
+time_t itime;
 struct tm *loct;
-struct tm *localtime();
-char   *malloc();
-char   *realloc();
 int    flag;
 char   *list;
 char   *listend;
 unsigned listsize;
 
-char *cmp();
+char *cmp(char *p, int v);
+void init(void);
+void append(char *fn);
 int number(char c, FILE *f);
 
 /* This routine will determine if registration is enabled at this time.  If
@@ -146,7 +147,7 @@ char *cmp(char *p, int v)
   return cp;
 }
 
-init(void)
+void init(void)
 {
   /*
    * Don't free in case was longer than LISTS.  Trades off
@@ -161,13 +162,13 @@ init(void)
   listend = list;
 }
 
-append(char *fn)
+void append(char *fn)
 {
   int i, c;
   char *cp;
   char *ocp;
   int n;
-  FILE *f, *fopen();
+  FILE *f;
 
   if (!(f = fopen(fn, "r")))
     return;
index e79cb8ca67ff7f7cf60f6057817d4d003ba02dd2..23d7ddbe1382ec75d08167e21e978b6b1af5852c 100644 (file)
@@ -1,24 +1,28 @@
-/*
- *     $Source$
- *     $Author$
- *     $Locker$
- *     $Header$
+/* $Id $
  *
- *  (c) Copyright 1988 by the Massachusetts Institute of Technology.
- *  For copying and distribution information, please see the file
- *  <mit-copyright.h>.
+ * Display function for userreg client
+ *
+ * Copyright (C) 1988-1998 by the Massachusetts Institute of Technology.
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
  */
 
-#ifndef lint
-static char *rcsid_display_c = "$Header$";
-#endif
-
 #include <mit-copyright.h>
-#include <stdio.h>
+#include <moira.h>
+
 #include <curses.h>
-#include <sys/time.h>
+#include <stdio.h>
+#include <time.h>
+#include <unistd.h>
+
 #include "userreg.h"
 
+RCSID("$Header$");
+
+void make_border(int l);
+void query_user(char *prompt, char *buf, int maxsize, int timeout,
+               int echop, int emptyok, int valuep);
+
 #define DESC_WIDTH 18
 #define HEADER "*** Athena User Account Registration ***"
 #define HELP   "    Press backspace to delete a character.  Press Ctrl-C to start over."
@@ -26,16 +30,14 @@ static char *rcsid_display_c = "$Header$";
 #define MIN_COLS 80
 #define MIN_LINES 24
 
-WINDOW * displayw, *queryw;
-WINDOW * dataw, *helpw;
-WINDOW * fnamew, *midw, *lnamew, *idw, *loginw;
+WINDOW *displayw, *queryw;
+WINDOW *dataw, *helpw;
+WINDOW *fnamew, *midw, *lnamew, *idw, *loginw;
 extern char typed_mit_id[100];
 
 /* Set up the windows and subwindows on the display */
-setup_display(void)
+void setup_display(void)
 {
-  FILE *freopen();
-
   initscr();                   /* Start up curses */
 
   if (COLS < MIN_COLS || LINES < MIN_LINES)
@@ -71,7 +73,7 @@ setup_display(void)
 }
 
 /* Clear and restore the display */
-reset_display(void)
+void reset_display(void)
 {
   clear();
 
@@ -100,7 +102,7 @@ reset_display(void)
 
 
 /* Make a one-line border on line l of stdscr */
-make_border(int l)
+void make_border(int l)
 {
   int i;
 
@@ -110,7 +112,7 @@ make_border(int l)
 }
 
 /* This replaces several "useful" display functions in the old userreg */
-redisp(void)
+void redisp(void)
 {
   mvwprintw(fnamew, 0, 0, "%-24s", user.u_first);
   wrefresh(fnamew);
@@ -126,19 +128,19 @@ redisp(void)
 
 
 /* Input and input_no_echo exist only to save on retyping */
-input(char *prompt, char *buf, int maxsize, int timeout, int emptyok)
+void input(char *prompt, char *buf, int maxsize, int timeout, int emptyok)
 {
   query_user(prompt, buf, maxsize, timeout, TRUE, emptyok, TRUE);
 }
 
-input_no_echo(char *prompt, char *buf, int maxsize, int timeout)
+void input_no_echo(char *prompt, char *buf, int maxsize, int timeout)
 {
   query_user(prompt, buf, maxsize, timeout, FALSE, FALSE, TRUE);
 }
 
 
 /* make the user press any key to continue */
-wait_for_user(void)
+void wait_for_user(void)
 {
   char buf[BUFSIZ];
 
@@ -151,8 +153,8 @@ wait_for_user(void)
 /* Gets input through the query buffer */
 /* Exit(1)'s on read errors */
 /* Signals SIGALRM after 'timeout' seconds */
-query_user(char *prompt, char *buf, int maxsize, int timeout,
-          int echop, int emptyok, int valuep)
+void query_user(char *prompt, char *buf, int maxsize, int timeout,
+               int echop, int emptyok, int valuep)
 {
   int c;
   int i;
@@ -331,7 +333,7 @@ start:
 
 /* Display_text_line puts up a line of text in the display window */
 /* Special case: if line is 0, clear the display area */
-display_text_line(char *line)
+void display_text_line(char *line)
 {
   if (line)
     {
@@ -346,7 +348,7 @@ display_text_line(char *line)
 /* Display_text displays a canned message from a file.  The string
  * will get imbedded in any %s's in the text.
  */
-display_text(char *filename, char *string)
+void display_text(char *filename, char *string)
 {
   FILE * fp;
   char buf[100], buf1[110];
@@ -372,7 +374,7 @@ display_text(char *filename, char *string)
 }
 
 /* Clear_display wipes the display and turns off curses */
-restore_display(void)
+void restore_display(void)
 {
   clear();
   refresh();
@@ -381,7 +383,7 @@ restore_display(void)
   endwin();
 }
 
-timer_on(void)
+void timer_on(void)
 {
   struct itimerval it;
 
@@ -392,7 +394,7 @@ timer_on(void)
   setitimer(ITIMER_REAL, &it, NULL);
 }
 
-timer_off(void)
+void timer_off(void)
 {
   struct itimerval it;
 
@@ -404,7 +406,7 @@ timer_off(void)
 }
 
 
-wfeep(void)
+void wfeep(void)
 {
   char buf = '\007';
   write(1, &buf, 1);
index 472f60ed3988289a6eb4258c759a3045fd5d8602..0855396199eaf44fe3ae258819ef481069a6d5d0 100644 (file)
@@ -1,9 +1,4 @@
-/*
- *     $Source$
- *     $Author$
- *     $Locker$
- *     $Header$
- */
+/* $Id $ */
 
 #define WELCOME                "/mit/register/welcome"
 #define USERNAME_BLURB "/mit/register/username_blurb"
index 7a7a934b538f65a7c96c132b407bfd58ff04b7f9..b5b13a6b44caabeb86afb2819a49290bf88a201a 100644 (file)
@@ -1,41 +1,46 @@
-/*
- *     $Source$
- *     $Author$
- *     $Header$
+/* $Id $
  *
- *  (c) Copyright 1988 by the Massachusetts Institute of Technology.
- *  For copying and distribution information, please see the file
- *  <mit-copyright.h>.
+ * Copyright (C) 1988-1998 by the Massachusetts Institute of Technology.
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
  */
 
-#ifndef lint
-static char *rcsid_reg_stubs_c = "$Header$";
-#endif
-
 #include <mit-copyright.h>
-#include <stdio.h>
-#include <stdlib.h>
+#include <moira.h>
+#include <moira_site.h>
+#include "ureg_proto.h"
+
 #include <sys/types.h>
-#include <sys/time.h>
 #include <sys/socket.h>
-#include <netinet/in.h>
+
 #include <netdb.h>
-#include <des.h>
-#include <krb.h>
-#include <krb_err.h>
+#include <netinet/in.h>
+
+#include <ctype.h>
 #include <errno.h>
-#include <moira.h>
-#include <moira_site.h>
-#include <hesiod.h>
-#include "ureg_err.h"
-#include "ureg_proto.h"
+#include <stdio.h>
+#include <stdlib.h>
 #include <string.h>
-#include <ctype.h>
+#include <unistd.h>
+
+#include <des.h>
+#include <hesiod.h>
+#include <kadm_err.h>
+#include <krb.h>
+
+RCSID("$Header$");
+
+int do_operation(char *first, char *last, char *idnumber, char *hashidnumber,
+                char *data, u_long opcode);
+int do_secure_operation(char *login, char *idnumber, char *passwd,
+                       char *newpasswd, u_long opcode);
+int do_call(char *buf, int len, int seq_no, char *login);
+
+char *krb_realmofhost(char *);
 
 static int reg_sock = -1;
 static int seq_no = 0;
 static char *host;
-extern errno;
 #define UNKNOWN_HOST -1
 #define UNKNOWN_SERVICE -2
 
@@ -71,13 +76,13 @@ int ureg_init(void)
 #endif
   if (!host || (strlen(host) == 0))
     {
-      host = strsave(MOIRA_SERVER);
+      host = strdup(MOIRA_SERVER);
       s = strchr(host, ':');
       if (s)
        *s = '\0';
     }
   hp = gethostbyname(host);
-  host = strsave(hp->h_name);
+  host = strdup(hp->h_name);
   if (hp == NULL)
     return UNKNOWN_HOST;
 
@@ -246,11 +251,10 @@ int do_secure_operation(char *login, char *idnumber, char *passwd,
   int call = ntohl(opcode);
   char inst[INST_SZ], hosti[INST_SZ];
   char *bp = buf, *src, *dst, *realm;
-  int len, status, i;
+  int len, status;
   KTEXT_ST cred;
   CREDENTIALS creds;
   Key_schedule keys;
-  char *krb_get_phost(), *krb_realmofhost();
 
   memmove(bp, &version, sizeof(int));
   bp += sizeof(int);
@@ -271,7 +275,7 @@ int do_secure_operation(char *login, char *idnumber, char *passwd,
   bp += strlen(bp) + 1;
 
   /* don't overwrite existing ticket file */
-  sprintf(tktstring, "/tmp/tkt_cpw_%d", getpid());
+  sprintf(tktstring, "/tmp/tkt_cpw_%ld", (long)getpid());
   krb_set_tkt_string(tktstring);
 
   /* get realm and canonizalized hostname of server */
index c66840529d4f5798d04e6af0cc72f7b19c0f601f..4ee9670504154ccd752562c011ad7bb23bdc2d16 100644 (file)
@@ -9,48 +9,58 @@
  *  <mit-copyright.h>.
  */
 
-#ifndef lint
-static char    *rcsid_userreg_c = "$Header$";
-#endif
-
 #include <mit-copyright.h>
-#include <string.h>
+#include <moira.h>
+#include "userreg.h"
+
+#include <errno.h>
+#include <ctype.h>
 #include <curses.h>
-#include <signal.h>
-#include <sys/time.h>
 #include <setjmp.h>
-#include <ctype.h>
+#include <signal.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
 #include <kadm.h>
 #include <kadm_err.h>
 #include <krb.h>
-#include <des.h>
-#include <errno.h>
-#include "userreg.h"
-#include "ureg_err.h"
 
-/* 7.2 release compatibility */
-#ifndef KADM_INSECURE_PW
-#define KADM_INSECURE_PW       (-1783126240L)
-#endif
+RCSID("$Header$");
+
+void fix_display(int sig);
+void reset(void);
+int dolook(void);
+int negotiate_login(void);
+int negotiate_passwd(void);
+void gfirst(void);
+void glast(void);
+void gpass(void);
+void glogin(void);
+void gmitid(void);
+void gmi(void);
+int qexit(void);
+int do_replace(void);
+int kinit(char *user, char *passwd);
+int lenient_strcmp(char *string1, char *string2);
+int strpasscmp(char *s1, char *s2);
+void restart(void);
+void canon_name(char *cp);
 
 #define EXIT -1
 
-
 struct user     user, db_user;
 struct alias    alias;
 char           realm[REALM_SZ];
 jmp_buf         redo;
-int             restart();
 
-extern int      errno;
 int             user_is_valid = 0;
 int            user_has_login = 0;
 int             already_registered = 0;
 int            enrollment = 0;
-extern char *disabled();
 char typed_mit_id[100];
 
-fix_display(sig)
+void fix_display(int sig)
 {
   struct sigaction act;
 
@@ -80,7 +90,7 @@ int main(int argc, char **argv)
       exit(1);
     }
 
-  if (when = disabled(&msg))
+  if ((when = disabled(&msg)))
     {
       printf("We're sorry, the registration service is unavailable right now\n");
       if (msg)
@@ -103,7 +113,7 @@ int main(int argc, char **argv)
 
   sigemptyset(&act.sa_mask);
   act.sa_flags = 0;
-  act.sa_handler = (void (*)()) fix_display;
+  act.sa_handler = fix_display;
   sigaction(SIGINT, &act, NULL);
   sigaction(SIGQUIT, &act, NULL);
   sigaction(SIGHUP, &act, NULL);
@@ -244,7 +254,7 @@ int main(int argc, char **argv)
   exit(0);
 }
 
-reset(void)
+void reset(void)
 {
   reset_display();
   memset(&user, 0, sizeof(user));
@@ -544,7 +554,7 @@ again:
          strcpy(lpassword, "moira");
        }
 
-      sprintf(tktstring, "/tmp/tkt_cpw_%d", getpid());
+      sprintf(tktstring, "/tmp/tkt_cpw_%ld", (long)getpid());
       krb_set_tkt_string(tktstring);
       des_string_to_key(passwd, key);
       inst[0] = 0;
@@ -564,7 +574,7 @@ again:
        }
       else if (result != KSUCCESS)
        {
-         display_text(NETWORK_DOWN);
+         display_text(NETWORK_DOWN, "");
          display_text_line(" ");
          sprintf(fullname, "%s while verifying password",
                  error_message(result));
@@ -602,7 +612,7 @@ again:
   return 0;
 }
 
-gfirst(void)
+void gfirst(void)
 {
   /* input the first name */
   char buf[FIRST_NAME_SIZE + 2];
@@ -610,7 +620,7 @@ gfirst(void)
 
   sigemptyset(&act.sa_mask);
   act.sa_flags = 0;
-  act.sa_handler = (void (*)()) fix_display;
+  act.sa_handler = fix_display;
   sigaction(SIGALRM, &act, NULL);
   input("Enter first Name:", buf, FIRST_NAME_SIZE + 1,
        FIRSTNAME_TIMEOUT, TRUE);
@@ -620,7 +630,7 @@ gfirst(void)
   redisp();
 }
 
-glast(void)
+void glast(void)
 {
   /* input the last name */
   char buf[LAST_NAME_SIZE + 2];
@@ -628,7 +638,7 @@ glast(void)
 
   sigemptyset(&act.sa_mask);
   act.sa_flags = 0;
-  act.sa_handler = (void (*)()) fix_display;
+  act.sa_handler = fix_display;
   sigaction(SIGALRM, &act, NULL);
   input("Enter family Name:", buf, LAST_NAME_SIZE + 1,
        LASTNAME_TIMEOUT, FALSE);
@@ -638,7 +648,7 @@ glast(void)
   redisp();
 }
 
-gpass(void)
+void gpass(void)
 {
   /* input password */
   char new_password[PASSWORD_SIZE + 1];
@@ -646,7 +656,7 @@ gpass(void)
 
   sigemptyset(&act.sa_mask);
   act.sa_flags = 0;
-  act.sa_handler = (void (*)()) fix_display;
+  act.sa_handler = fix_display;
   sigaction(SIGALRM, &act, NULL);
   input_no_echo("Enter password:", new_password,
                PASSWORD_SIZE, NEW_PASSWORD_TIMEOUT);
@@ -657,14 +667,14 @@ gpass(void)
 
 /* get login name */
 
-glogin(void)
+void glogin(void)
 {
   char buf[LOGIN_SIZE + 2];
   struct sigaction act;
 
   sigemptyset(&act.sa_mask);
   act.sa_flags = 0;
-  act.sa_handler = (void (*)()) fix_display;
+  act.sa_handler = fix_display;
   sigaction(SIGALRM, &act, NULL);
   user.u_login[0] = '\0';
   input("Enter username:", buf, LOGIN_SIZE, USERNAME_TIMEOUT, FALSE);
@@ -672,7 +682,7 @@ glogin(void)
   redisp();
 }
 
-gmitid(void)
+void gmitid(void)
 {
   /* get mid id */
   int i;
@@ -683,7 +693,7 @@ gmitid(void)
 input_mit_id:
   sigemptyset(&act.sa_mask);
   act.sa_flags = 0;
-  act.sa_handler = (void (*)()) fix_display;
+  act.sa_handler = fix_display;
   sigaction(SIGALRM, &act, NULL);
   input("Enter MIT Id:", buf, 14, MITID_TIMEOUT, FALSE);
   i = 0;
@@ -715,7 +725,7 @@ input_mit_id:
   EncryptID(user.u_mit_id, typed_mit_id, user.u_first, user.u_last);
 }
 
-gmi(void)
+void gmi(void)
 {
   /* get middle initial */
   char buf[MID_INIT_SIZE + 2];
@@ -723,7 +733,7 @@ gmi(void)
 
   sigemptyset(&act.sa_mask);
   act.sa_flags = 0;
-  act.sa_handler = (void (*)()) fix_display;
+  act.sa_handler = fix_display;
   sigaction(SIGALRM, &act, NULL);
   input("Enter Middle Initial:", buf, MID_INIT_SIZE + 1, MI_TIMEOUT, TRUE);
   strncpy(user.u_mid_init, buf, MID_INIT_SIZE);
@@ -770,7 +780,7 @@ int do_replace(void)
   timer_on();
   if (status)
     {
-      display_text(NETWORK_DOWN);
+      display_text(NETWORK_DOWN, "");
       display_text_line(" ");
       sprintf(buf, "The specific error was: %s", error_message(status));
       display_text_line(buf);
@@ -858,13 +868,13 @@ int strpasscmp(char *s1, char *s2)
  */
 
 /* Go to asking for first name. */
-restart(void)
+void restart(void)
 {
   qexit();
   longjmp(redo, 1);
 }
 
-canon_name(char *cp)
+void canon_name(char *cp)
 {
   char *p2 = cp;
 
index 1cf2d4b997295f0662ab5710e7c3f0d11bb8b6f5..6675300e2f2515274fffca43244fecfc8591647e 100644 (file)
@@ -6,7 +6,7 @@
  */
 
 #include <stdio.h>
-#include <ctype.h>
+#include "ureg_proto.h"
 #include "files.h"
 
 /*
@@ -58,16 +58,24 @@ struct alias {
 #define NO    0
 #define YES   1
 
-/* Externs from display.c */
-extern  setup_display ();
-extern  reset_display ();
-extern  restore_display ();
-extern  redisp ();
-extern  input ();
-extern  input_no_echo ();
-extern  display_text_line ();
-extern  display_text ();
-
 /* Global variables */
 extern struct user  user,
                     db_user;
+
+/* prototypes from disable.c */
+char *disabled(char **msg);
+
+/* prototypes from display.c */
+void setup_display(void);
+void reset_display(void);
+void redisp(void);
+void input(char *prompt, char *buf, int maxsize, int timeout, int emptyok);
+void input_no_echo(char *prompt, char *buf, int maxsize, int timeout);
+void wait_for_user(void);
+int askyn(char *prompt);
+void display_text_line(char *line);
+void display_text(char *filename, char *string);
+void restore_display(void);
+void timer_on(void);
+void timer_off(void);
+void wfeep(void);
index 4e39b7d7869902520ccbb73b9f0d84623a72ac18..3aa30f7a95e23a708e638c08f4250e522930b978 100644 (file)
@@ -8,13 +8,13 @@
 # Imakefile for server directory.
 #
 
-SRCS = dbck.h dbck.c fix.c phase1.c phase2.c phase3.c phase4.c nhash.c
-OBJS = dbck.o fix.o phase1.o phase2.o phase3.o phase4.o nhash.o
-CODE = dbck.h dbck.pc fix.pc phase1.pc phase2.pc phase3.pc phase4.pc nhash.c
+SRCS = dbck.h dbck.c fix.c phase1.c phase2.c phase3.c phase4.c
+OBJS = dbck.o fix.o phase1.o phase2.o phase3.o phase4.o
+CODE = dbck.h dbck.pc fix.pc phase1.pc phase2.pc phase3.pc phase4.pc
 SRCDIR=$(SRCTOP)/dbck
 sqlrule()
 
-program(dbck, ${OBJS},,../lib/libmoira.a ../server/libmrglue.a $(SQL_LIB), ${PROGDIR})
+program(dbck, ${OBJS},,../lib/libmoira.a $(SQL_LIB), ${PROGDIR})
 sqlfile(dbck)
 sqlfile(fix)
 sqlfile(phase1)
index aacebee2ab9623ffb630723e05fb4be91de588f4..873a45aec376185b58bbdc9d1066a6f78f9a2d0a 100644 (file)
@@ -7,8 +7,8 @@
  *  <mit-copyright.h>.
  */
 
-#include <moira_site.h>
 #include <mit-copyright.h>
+#include <moira_site.h>
 
 #define MODE_ASK 1
 #define MODE_NO 2
@@ -97,3 +97,31 @@ struct nfsphys {
   int allocated;
   int count;
 };
+
+void dbmserr(void);
+void out_of_mem(char *msg);
+void cleanup(void);
+
+void modified(char *table);
+
+void phase1(void);
+void phase2(void);
+void phase3(void);
+void phase4(void);
+void count_only_setup(void);
+
+/* prototypes from fix.pc */
+void generic_delete(struct save_queue *sq, int (*pfunc)(void *), char *table,
+                   char *idfield, int preen);
+void single_delete(char *table, char *idfield, int id);
+void zero_fix(char *tbl, char *zrfield, char *idfield, int id);
+int single_fix(char *msg, int preen);
+void generic_fix(struct save_queue *sq, int (*pfunc)(void *), char *msg,
+                void (*ffunc)(void *), int preen);
+int prompt(char *msg);
+int set_next_object_id(char *object, char *tablename);
+int generic_fix_id(char *tbl, char *idfield, char *txtfield,
+                  int oldid, char *name);
+
+/* prototypes from phase3.pc */
+struct string *string_check(int id);
index 6fd37b8ea614dd384c8e7b7e6946ef6867e40f1f..cef40d74a610b298d01529323f5b45de9fb82dcc 100644 (file)
@@ -1,22 +1,24 @@
-/* $Header$
+/* $Id$
  *
  * Moira database consistency checker
  *
- *  (c) Copyright 1988 by the Massachusetts Institute of Technology.
- *  For copying and distribution information, please see the file
- *  <mit-copyright.h>.
+ * (c) Copyright 1988-1998 by the Massachusetts Institute of Technology.
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
  */
 
 #include <mit-copyright.h>
-#include <stdio.h>
-#include <string.h>
-#include <signal.h>
+#include <moira.h>
 #include "dbck.h"
+
+#include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
+
 EXEC SQL INCLUDE sqlca;
 EXEC SQL INCLUDE sqlda;
 
-static char dbck_qc_rcsid[] = "$Header$";
-
+RCSID("$Header$");
 
 int debug = 0;
 int mode = MODE_ASK;
@@ -28,11 +30,12 @@ struct hash *strings, *members, *subnets, *string_dups;
 EXEC SQL BEGIN DECLARE SECTION;
 int dcmenable;
 EXEC SQL END DECLARE SECTION;
-struct save_queue *modtables, *sq_create();
-void interrupt();
+struct save_queue *modtables;
 SQLDA *mr_sqlda;
 
+void interrupt(void);
 extern SQLDA *sqlald(int, int, int);
+extern void sqlglm(char *, unsigned int *, unsigned int *);
 
 int main(int argc, char **argv)
 {
@@ -40,8 +43,8 @@ int main(int argc, char **argv)
   EXEC SQL BEGIN DECLARE SECTION;
   char *database;
   EXEC SQL END DECLARE SECTION;
-  int ingerr();
   int countonly = 0;
+  struct sigaction sa;
 
   database = "moira";
   setvbuf(stdout, NULL, _IOLBF, BUFSIZ);
@@ -98,9 +101,12 @@ int main(int argc, char **argv)
   if (debug)
     printf("Debug level is %d\n", debug);
 
-  signal(SIGHUP, interrupt);
-  signal(SIGQUIT, interrupt);
-  signal(SIGINT, interrupt);
+  sa.sa_handler = interrupt;
+  sa.sa_flags = 0;
+  sigemptyset(&sa.sa_mask);
+  sigaction(SIGHUP, &sa, NULL);
+  sigaction(SIGQUIT, &sa, NULL);
+  sigaction(SIGINT, &sa, NULL);
 
   modtables = sq_create();
   mr_sqlda = sqlald(1, 255, 0);
@@ -139,7 +145,7 @@ int main(int argc, char **argv)
   exit(0);
 }
 
-int dbmserr(void)
+void dbmserr(void)
 {
   EXEC SQL BEGIN DECLARE SECTION;
   char buf[512];
@@ -148,7 +154,7 @@ int dbmserr(void)
 
   if (sqlca.sqlcode == 1403)
     return;
-  printf("A DBMS error occurred, code %d\n", sqlca.sqlcode);
+  printf("A DBMS error occurred, code %ld\n", sqlca.sqlcode);
   sqlglm(buf, &bufsize, &msglength);
   buf[msglength] = '\0';
   printf("%s\n", buf);
@@ -185,12 +191,12 @@ void interrupt(void)
 }
 
 
-int modified(char *table)
+void modified(char *table)
 {
   sq_save_unique_string(modtables, table);
 }
 
-int cleanup(void)
+void cleanup(void)
 {
   EXEC SQL BEGIN DECLARE SECTION;
   char *tab;
@@ -206,7 +212,7 @@ int cleanup(void)
 }
 
 
-int out_of_mem(char *msg)
+void out_of_mem(char *msg)
 {
   fprintf(stderr, "Out of memory while %s\n", msg);
   if (prompt("Save database changes"))
index a23c50acf1dfbea94231797125a948432c58295b..86c1f5623071a16f8df58761d18ebd193795db45 100644 (file)
@@ -1,21 +1,22 @@
-/* $Header$
+/* $Id$
  *
  * User interface routines for dbck (Moira database consistency checker)
  *
- *  (c) Copyright 1988 by the Massachusetts Institute of Technology.
- *  For copying and distribution information, please see the file
- *  <mit-copyright.h>.
+ * (c) Copyright 1988-1998 by the Massachusetts Institute of Technology.
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
  */
 
 #include <mit-copyright.h>
 #include <moira.h>
-#include <stdio.h>
 #include "dbck.h"
 
+#include <stdio.h>
+
 EXEC SQL INCLUDE sqlca;  /* SQL Communications Area */
 EXEC SQL INCLUDE sqlda;  /* SQL Descriptor Area */
 
-static char fix_qc_rcsid[] = "$Header$";
+RCSID("$Header$");
 
 EXEC SQL BEGIN DECLARE SECTION;
 char *_table;
@@ -24,13 +25,14 @@ char stmt_buf[500];
 EXEC SQL END DECLARE SECTION;
 
 extern SQLDA *mr_sqlda;
+void generic_ffunc(void *id);
 
-int generic_ffunc(int id)
+void generic_ffunc(void *id)
 {
   int rowcount;
 
   sprintf(stmt_buf, "DELETE FROM %s WHERE %s.%s = %d",
-         _table, _table, _idfield, id);
+         _table, _table, _idfield, (int)id);
   EXEC SQL EXECUTE IMMEDIATE :stmt_buf;
   rowcount = sqlca.sqlerrd[2];
   if (rowcount > 0)
@@ -41,8 +43,8 @@ int generic_ffunc(int id)
 }
 
 
-int generic_delete(struct save_queue *sq, void (*pfunc)(), char *table,
-                  char *idfield, int preen)
+void generic_delete(struct save_queue *sq, int (*pfunc)(void *), char *table,
+                   char *idfield, int preen)
 {
   _table = table;
   _idfield = idfield;
@@ -50,15 +52,15 @@ int generic_delete(struct save_queue *sq, void (*pfunc)(), char *table,
 }
 
 
-int single_delete(char *table, char *idfield, int id)
+void single_delete(char *table, char *idfield, int id)
 {
   _table = table;
   _idfield = idfield;
-  generic_ffunc(id);
+  generic_ffunc((void *)id);
 }
 
 
-int zero_fix(char *tbl, char *zrfield, char *idfield, int id)
+void zero_fix(char *tbl, char *zrfield, char *idfield, int id)
 {
   int rowcount;
 
@@ -94,15 +96,15 @@ int single_fix(char *msg, int preen)
 }
 
 
-int generic_fix(struct save_queue *sq, int (*pfunc)(), char *msg,
-               int (*ffunc)(), int preen)
+void generic_fix(struct save_queue *sq, int (*pfunc)(void *), char *msg,
+                void (*ffunc)(void *), int preen)
 {
   int id;
 
   while (sq_get_data(sq, &id))
     {
-      if ((*pfunc)(id) == 0 && single_fix(msg, preen))
-       (*ffunc)(id);
+      if ((*pfunc)((void *)id) == 0 && single_fix(msg, preen))
+       (*ffunc)((void *)id);
     }
   sq_destroy(sq);
 }
diff --git a/dbck/nhash.c b/dbck/nhash.c
deleted file mode 100644 (file)
index d81dd08..0000000
+++ /dev/null
@@ -1,171 +0,0 @@
-/* $Header$
- *
- * Generic hash table routines.  Uses integer keys to store integer values.
- *
- *  (c) Copyright 1996 by the Massachusetts Institute of Technology.
- *  For copying and distribution information, please see the file
- *  <mit-copyright.h>.
- */
-
-#include <mit-copyright.h>
-#include <ctype.h>
-#include <stdlib.h>
-/* #include <moira.h> */
-
-struct int_bucket {
-  struct int_bucket *next;
-  int key;
-  int data;
-};
-struct int_hash {
-  int size;
-  struct int_bucket **data;
-};
-
-#define int_hash_func(h, key) (key >= 0 ? (key % h->size) : (-key % h->size))
-
-/* Create an int_hash table.  The size is just a hint, not a maximum. */
-
-struct int_hash *create_int_hash(int size)
-{
-  struct int_hash *h;
-
-  h = malloc(sizeof(struct int_hash));
-  if (!h)
-    return NULL;
-  h->size = size;
-  h->data = malloc(size * sizeof(struct int_bucket *));
-  if (!h->data)
-    {
-      free(h);
-      return NULL;
-    }
-  memset(h->data, 0, size * sizeof(char *));
-  return h;
-}
-
-/* Look up an object in the int_hash table.  Returns the value associated with
- * the key, or NULL (thus NULL is not a very good value to store...)
- */
-
-int int_hash_lookup(struct int_hash *h, int key)
-{
-  struct int_bucket *b;
-
-  b = h->data[int_hash_func(h, key)];
-  while (b && b->key != key)
-    b = b->next;
-  if (b && b->key == key)
-    return b->data;
-  else
-    return 0;
-}
-
-
-/* Update an existing object in the int_hash table.  Returns 1 if the object
- * existed, or 0 if not.
- */
-
-int int_hash_update(struct int_hash *h, int key, int value)
-{
-  struct int_bucket *b;
-
-  b = h->data[int_hash_func(h, key)];
-  while (b && b->key != key)
-    b = b->next;
-  if (b && b->key == key)
-    {
-      b->data = value;
-      return 1;
-    }
-  else
-    return 0;
-}
-
-
-/* Store an item in the int_hash table.  Returns 0 if the key was not
- * previously there, 1 if it was, or -1 if we ran out of memory.
- */
-
-int int_hash_store(struct int_hash *h, int key, int value)
-{
-  struct int_bucket *b, **p;
-
-  p = &(h->data[int_hash_func(h, key)]);
-  if (!*p)
-    {
-      b = *p = malloc(sizeof(struct int_bucket));
-      if (!b)
-       return -1;
-      b->next = NULL;
-      b->key = key;
-      b->data = value;
-      return 0;
-    }
-
-  for (b = *p; b && b->key != key; b = *p)
-    p = (struct int_bucket **) *p;
-  if (b && b->key == key)
-    {
-      b->data = value;
-      return 1;
-    }
-  b = *p = malloc(sizeof(struct int_bucket));
-  if (!b)
-    return -1;
-  b->next = NULL;
-  b->key = key;
-  b->data = value;
-  return 0;
-}
-
-
-/* Search through the int_hash table for a given value.  For each piece of
- * data with that value, call the callback proc with the corresponding key.
- */
-
-int int_hash_search(struct int_hash *h, int value, void (*callback)())
-{
-  struct int_bucket *b, **p;
-
-  for (p = &(h->data[h->size - 1]); p >= h->data; p--)
-    {
-      for (b = *p; b; b = b->next)
-       {
-         if (b->data == value)
-           (*callback)(b->key);
-       }
-    }
-}
-
-
-/* Step through the int_hash table, calling the callback proc with each key.
- */
-
-int int_hash_step(struct int_hash *h, void (*callback)(), char *hint)
-{
-  struct int_bucket *b, **p;
-
-  for (p = &(h->data[h->size - 1]); p >= h->data; p--)
-    {
-      for (b = *p; b; b = b->next)
-       (*callback)(b->key, b->data, hint);
-    }
-}
-
-
-/* Deallocate all of the memory associated with a table */
-
-int int_hash_destroy(struct int_hash *h)
-{
-  struct int_bucket *b, **p, *b1;
-
-  for (p = &(h->data[h->size - 1]); p >= h->data; p--)
-    {
-      for (b = *p; b; b = b1)
-       {
-         b1 = b->next;
-         free(b);
-       }
-    }
-}
index 52b06b758fbe060027accb9783f1916cc3fa48f4..0e99899d9182b8ae942404e87925a0465c2938b0 100644 (file)
@@ -1,29 +1,54 @@
-/* $Header$
+/* $Id$
  *
- *  (c) Copyright 1988 by the Massachusetts Institute of Technology.
- *  For copying and distribution information, please see the file
- *  <mit-copyright.h>.
+ * (c) Copyright 1988-1998 by the Massachusetts Institute of Technology.
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
  */
 
 #include <mit-copyright.h>
 #include <moira.h>
+#include "dbck.h"
+
 #include <stdio.h>
 #include <stdlib.h>
-#include "dbck.h"
+#include <string.h>
 EXEC SQL INCLUDE sqlca;
 
-static char phase1_qc_rcsid[] = "$Header$";
+RCSID("$Header$");
 
 EXEC SQL WHENEVER SQLERROR DO dbmserr();
-
-int show_user_id(struct user *u)
+int show_user_id(void *user);
+void handle_duplicate_logins(struct save_queue *sq);
+void fix_user_id(void *user);
+void cant_fix(void *id);
+int show_mach_id(void *machine);
+int show_mach_name(void *machine);
+void fix_mach_id(void *machine);
+int show_snet_name(void *subnet);
+int show_clu_id(void *cluster);
+int show_clu_name(void *cluster);
+void fix_clu_id(void *cluster);
+int show_list_id(void *list);
+int show_list_name(void *list);
+void fix_list_id(void *list);
+int show_fs_id(void *filesys);
+void fix_fs_id(void *filesys);
+int show_fs_name(void *fs);
+int show_np_id(void *nfsphys);
+void fix_np_id(void *nfsphys);
+int show_str_id(void *string);
+int print_str_id(void *id);
+void print_dup_map(int key, void *data, void *hint);
+
+int show_user_id(void *user)
 {
+  struct user *u = user;
   printf("User %s (%s, status %d) has duplicate ID\n",
         u->login, u->fullname, u->status);
   return 0;
 }
 
-handle_duplicate_logins(struct save_queue *sq)
+void handle_duplicate_logins(struct save_queue *sq)
 {
   struct user *u, *uu, *tmp;
 
@@ -45,9 +70,9 @@ handle_duplicate_logins(struct save_queue *sq)
              printf("User %s (%s, status %d) have duplicate logins\n",
                     uu->login, uu->fullname, uu->status);
              if (!strcmp(u->fullname, uu->fullname) &&
-                 single_fix("Delete the second one"))
+                 single_fix("Delete the second one", 0))
                single_delete("users", "users_id", uu->users_id);
-             else if (single_fix("Unregister the second one"))
+             else if (single_fix("Unregister the second one", 0))
                {
                  EXEC SQL BEGIN DECLARE SECTION;
                  int id = uu->users_id, rowcount;
@@ -73,126 +98,143 @@ handle_duplicate_logins(struct save_queue *sq)
     }
 }
 
-fix_user_id(struct user *u)
+void fix_user_id(void *user)
 {
+  struct user *u = user;
   u->users_id = generic_fix_id("users", "users_id", "login",
                               u->users_id, u->login);
 }
 
 
-cant_fix(int id)
+void cant_fix(void *id)
 {
   printf("Sorry, don't know how to fix that\n");
 }
 
-int show_mach_id(struct machine *m)
+int show_mach_id(void *machine)
 {
+  struct machine *m = machine;
   printf("Machine %s has duplicate ID %d\n", m->name, m->mach_id);
   return 0;
 }
 
-int show_mach_name(struct machine *m)
+int show_mach_name(void *machine)
 {
+  struct machine *m = machine;
   printf("Machine %s (%d) has duplicate name\n", m->name, m->mach_id);
   return 0;
 }
 
-fix_mach_id(struct machine *m)
+void fix_mach_id(void *machine)
 {
+  struct machine *m = machine;
   m->mach_id = generic_fix_id("machine", "mach_id", "name",
                              m->mach_id, m->name);
 }
 
-int show_snet_name(struct subnet *s)
+int show_snet_name(void *subnet)
 {
+  struct subnet *s = subnet;
   printf("Subnet %s (%d) has duplicate name\n", s->name, s->snet_id);
   return 0;
 }
 
-int show_clu_id(struct cluster *c)
+int show_clu_id(void *cluster)
 {
+  struct cluster *c = cluster;
   printf("Cluster %s has duplicate ID %d\n", c->name, c->clu_id);
   return 0;
 }
 
-int show_clu_name(struct cluster *c)
+int show_clu_name(void *cluster)
 {
+  struct cluster *c = cluster;
   printf("Cluster %s (%d) has duplicate name\n", c->name, c->clu_id);
   return 0;
 }
 
-fix_clu_id(struct cluster *c)
+void fix_clu_id(void *cluster)
 {
+  struct cluster *c = cluster;
   c->clu_id = generic_fix_id("cluster", "clu_id", "name", c->clu_id, c->name);
 }
 
-int show_list_id(struct list *l)
+int show_list_id(void *list)
 {
+  struct list *l = list;
   printf("List %s has duplicate ID %d\n", l->name, l->list_id);
   return 0;
 }
 
-int show_list_name(struct list *l)
+int show_list_name(void *list)
 {
+  struct list *l = list;
   printf("List %s (%d) has duplicate name\n", l->name, l->list_id);
   return 0;
 }
 
-fix_list_id(struct list *l)
+void fix_list_id(void *list)
 {
+  struct list *l = list;
   l->list_id = generic_fix_id("list", "list_id", "name", l->list_id, l->name);
 }
 
-int show_fs_id(struct filesys *f)
+int show_fs_id(void *filesys)
 {
+  struct filesys *f = filesys;
   printf("Filesys %s has duplicate ID %d\n", f->name, f->filsys_id);
   return 0;
 }
 
-fix_fs_id(struct filesys *f)
+void fix_fs_id(void *filesys)
 {
+  struct filesys *f = filesys;
   f->filsys_id = generic_fix_id("filesys", "filsys_id", "label",
                                f->filsys_id, f->name);
 }
 
-int show_fs_name(struct filesys *fs)
+int show_fs_name(void *filesys)
 {
+  struct filesys *fs = filesys;
   printf("Filesys %s (%d) has duplicate name\n", fs->name, fs->filsys_id);
   return 0;
 }
 
-int show_np_id(struct nfsphys *n)
+int show_np_id(void *nfsphys)
 {
+  struct nfsphys *n = nfsphys;
   printf("NfsPhys %s:%s has duplicate ID %d\n",
         ((struct machine *)hash_lookup(machines, n->mach_id))->name,
         n->dir, n->nfsphys_id);
   return 0;
 }
 
-fix_np_id(struct nfsphys *n)
+void fix_np_id(void *nfsphys)
 {
+  struct nfsphys *n = nfsphys;
   n->nfsphys_id = generic_fix_id("nfsphys", "nfsphys_id", "dir",
                                 n->nfsphys_id, n->dir);
 }
 
-int show_str_id(struct string *s)
+int show_str_id(void *string)
 {
+  struct string *s = string;
   printf("String %s has duplicate ID %d\n", s->name, s->string_id);
   return 0;
 }
 
-int print_str_id(int id)
+int print_str_id(void *id)
 {
-  printf("String %d is a duplicate\n", id);
+  printf("String %d is a duplicate\n", (int)id);
   return 0;
 }
 
-print_dup_map(int key, int data, char *hint)
+void print_dup_map(int key, void *data, void *hint)
 {
-  printf("String %d is a duplicate of string %d\n", key, data);
+  printf("String %d is a duplicate of string %d\n", key, (int)data);
 }
 
-phase1(void)
+void phase1(void)
 {
   EXEC SQL BEGIN DECLARE SECTION;
   char name[81], name1[81], last[17], first[17], buf[257];
@@ -238,18 +280,18 @@ phase1(void)
        break;
       q++;
       /*  If id2 is already stored, skip this row. */
-      i = int_hash_lookup(string_dups, id2);
+      i = (int)hash_lookup(string_dups, id2);
       if (i > 0)
        continue;
       /*  Follow the chain of id1 equivalent IDs back to the lowest one. */
       id = id1;
-      while ((tmp = int_hash_lookup(string_dups, id)) > 0)
+      while ((tmp = (int)hash_lookup(string_dups, id)) > 0)
        id = tmp;
-      int_hash_store(string_dups, id2, id);
+      hash_store(string_dups, id2, (void *)id);
     }
   EXEC SQL CLOSE csr116;
   dprintf("found %d duplicates\n", q);
-  int_hash_step(string_dups, print_dup_map, NULL);
+  hash_step(string_dups, print_dup_map, NULL);
   /* We don't want to delete the duplicates now because if the dbck
      is cancelled, a LOT of state will be lost. So, we'll just let
      them not get marked as used and then phase3 will clean them up */
@@ -273,7 +315,7 @@ phase1(void)
       s = malloc(sizeof(struct string));
       if (!s)
        out_of_mem("storing strings");
-      s->name = strsave(strtrim(buf));
+      s->name = strdup(strtrim(buf));
       s->string_id = id;
       s->refc = 0;
       retval = hash_store(strings, id, s);
@@ -315,7 +357,7 @@ phase1(void)
       strcpy(u->login, strtrim(name));
       u->potype = buf[0];
       sprintf(buf, "%s, %s", strtrim(last), strtrim(first));
-      u->fullname = strsave(buf);
+      u->fullname = strdup(buf);
       u->status = status;
       u->users_id = id;
       u->modby = sid;
index 4c92ccc7d5706d75a768a9d714db0b4d3e11439e..8dddbd229eac26f82ef43470ecd877077fa70cf4 100644 (file)
@@ -1,25 +1,85 @@
-/* $Header$
+/* $Id$
  *
- *  (c) Copyright 1988 by the Massachusetts Institute of Technology.
- *  For copying and distribution information, please see the file
- *  <mit-copyright.h>.
+ * (c) Copyright 1988-1998 by the Massachusetts Institute of Technology.
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
  */
 
 #include <mit-copyright.h>
-#include <stdio.h>
-#include <stdlib.h>
 #include <moira.h>
 #include "dbck.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
 EXEC SQL INCLUDE sqlca;
 
-static char phase2_qc_rcsid[] = "$Header$";
+RCSID("$Header$");
 
 EXEC SQL WHENEVER SQLERROR DO dbmserr();
 
-int show_mcm_mach(int id)
+int show_mcm_mach(void *id);
+int show_mcm_clu(void *id);
+int show_hostalias(void *id);
+int show_pcap_mach(void *id);
+int show_pcap_quota(void *id);
+void user_check(int id, void *user, void *hint);
+int maybe_fixup_unref_string(int sid, int oid, char *oname, char *table,
+                            char *field, char *idfield);
+int maybe_fixup_modby(int sid, int oid, char *oname, char *table,
+                     char *field, char *idfield);
+int maybe_fixup_unref_string2(char *table, char *field, char *cursor, int sid);
+int maybe_fixup_modby2(char *table, char *field, char *cursor, int id);
+void pobox_check(int id, struct user *u);
+void remove_pobox(int id);
+void fix_smtp_pobox(int id, int sid);
+void mach_check(int id, void *machine, void *hint);
+void subnet_check(int id, void *subnet, void *hint);
+void clear_subnet_owner(struct subnet *s);
+void clear_mach_owner(struct machine *m);
+void cluster_check(int id, void *cluster, void *hint);
+int show_svc(void *id);
+void list_check(int id, void *list, void *hint);
+void fix_list_acl(int id);
+int show_member_list(void *id);
+int show_mem_user(void *id);
+int show_mem_list(void *id);
+int show_mem_str(void *id);
+int show_mem_krb(void *id);
+void del_mem_user(void *id);
+void del_mem_list(void *id);
+void del_mem_str(void *id);
+void del_mem_krb(void *id);
+int show_sh(void *id);
+void del_sh_mach(void *id);
+void fsmatch(int id, void *nfsphys, void *filesys);
+void check_fs(int id, void *filesys, void *hint);
+void check_nfsphys(int id, void *nfsphys, void *hint);
+int show_fsg_missing(void *id);
+int show_fsg_type(void *filesys);
+void fix_fsg_type(void *filesys);
+int show_fsg_nomember(void *id);
+int show_quota_nouser(void *id);
+int show_quota_nolist(void *id);
+void fix_quota_nouser(void *id);
+void fix_quota_nolist(void *id);
+int show_quota_nofs(void *id);
+void fix_quota_nofs(void *id);
+int show_quota_wrongpid(void *id);
+void fix_quota_physid(void *id);
+int show_srv_user(void *id);
+int show_srv_list(void *id);
+void zero_srv_user(void *id);
+void zero_srv_list(void *id);
+int show_krb_usr(void *id);
+int show_krb_str(void *id);
+int show_pdm_mach(void *id);
+
+int show_mcm_mach(void *id)
 {
   EXEC SQL BEGIN DECLARE SECTION;
-  int iid = id, found = 1;
+  int iid = (int)id, found = 1;
   char name[33];
   EXEC SQL END DECLARE SECTION;
 
@@ -35,16 +95,17 @@ int show_mcm_mach(int id)
 
       strtrim(name);
       found = 0;
-      printf("Cluster %s, non-existant machine %d in cluster map\n", name, id);
+      printf("Cluster %s, non-existant machine %d in cluster map\n",
+            name, iid);
     }
   EXEC SQL CLOSE csr201;
   return found;
 }
 
-int show_mcm_clu(int id)
+int show_mcm_clu(void *id)
 {
   EXEC SQL BEGIN DECLARE SECTION;
-  int iid = id, found = 1;
+  int iid = (int)id, found = 1;
   char name[33];
   EXEC SQL END DECLARE SECTION;
 
@@ -61,16 +122,17 @@ int show_mcm_clu(int id)
       strtrim(name);
 
       found = 0;
-      printf("Machine %s, non-existant cluster %d in cluster map\n", name, id);
+      printf("Machine %s, non-existant cluster %d in cluster map\n",
+            name, iid);
     }
   EXEC SQL CLOSE csr202;
   return found;
 }
 
-int show_hostalias(int id)
+int show_hostalias(void *id)
 {
   EXEC SQL BEGIN DECLARE SECTION;
-  int iid = id, found = 1;
+  int iid = (int)id, found = 1;
   char name[33];
   EXEC SQL END DECLARE SECTION;
 
@@ -86,16 +148,17 @@ int show_hostalias(int id)
       strtrim(name);
 
       found = 0;
-      printf("Alias %s, non-existant machine %d in hostalias map\n", name, id);
+      printf("Alias %s, non-existant machine %d in hostalias map\n",
+            name, iid);
     }
   EXEC SQL CLOSE csr234;
   return found;
 }
 
-int show_pcap_mach(int id)
+int show_pcap_mach(void *id)
 {
   EXEC SQL BEGIN DECLARE SECTION;
-  int iid = id, found = 1;
+  int iid = (int)id, found = 1;
   char name[33];
   EXEC SQL END DECLARE SECTION;
 
@@ -112,16 +175,16 @@ int show_pcap_mach(int id)
 
       found = 0;
       printf("Printer %s, non-existant spool machine %d in printcap table\n",
-            name, id);
+            name, iid);
     }
   EXEC SQL CLOSE csr235;
   return found;
 }
 
-int show_pcap_quota(int id)
+int show_pcap_quota(void *id)
 {
   EXEC SQL BEGIN DECLARE SECTION;
-  int iid = id, found = 1;
+  int iid = (int)id, found = 1;
   char name[33];
   EXEC SQL END DECLARE SECTION;
 
@@ -138,14 +201,16 @@ int show_pcap_quota(int id)
 
       found = 0;
       printf("Printer %s, non-existant quota server %d in printcap table\n",
-            name, id);
+            name, iid);
     }
   EXEC SQL CLOSE csr236;
   return found;
 }
 
-user_check(int id, struct user *u, int hint)
+void user_check(int id, void *user, void *hint)
 {
+  struct user *u = user;
+
   u->comment = maybe_fixup_unref_string(u->comment, id, u->login, "users",
                                        "comments", "users_id");
 
@@ -161,7 +226,7 @@ user_check(int id, struct user *u, int hint)
   u->sigwho = maybe_fixup_unref_string(u->sigwho, id, u->login, "users",
                                       "sigwho", "users_id");
 
-  pobox_check(id, u, hint);
+  pobox_check(id, u);
 }
 
 int maybe_fixup_unref_string(int sid, int oid, char *oname, char *table,
@@ -173,7 +238,7 @@ int maybe_fixup_unref_string(int sid, int oid, char *oname, char *table,
   char stmt_buf[500];
   EXEC SQL END DECLARE SECTION;
 
-  if (newid = int_hash_lookup(string_dups, ret))
+  if ((newid = (int)hash_lookup(string_dups, ret)))
     {
       printf("%s entry %s(%d) has a %s with duplicate string %d\n",
             table, oname, oid, field, ret);
@@ -253,7 +318,7 @@ int maybe_fixup_unref_string2(char *table, char *field, char *cursor, int sid)
   char stmt_buf[500];
   EXEC SQL END DECLARE SECTION;
 
-  if ((newid = int_hash_lookup(string_dups, ret)))
+  if ((newid = (int)hash_lookup(string_dups, ret)))
     {
       printf("%s entry has a %s with duplicate string %d\n",
             table, field, ret);
@@ -323,7 +388,7 @@ int maybe_fixup_modby2(char *table, char *field, char *cursor, int id)
   return 1;
 }
 
-pobox_check(int id, struct user *u, int hint)
+void pobox_check(int id, struct user *u)
 {
   switch (u->potype)
     {
@@ -340,7 +405,7 @@ pobox_check(int id, struct user *u, int hint)
        }
       break;
     case 'S':
-      if (int_hash_lookup(string_dups, u->pobox_id))
+      if (hash_lookup(string_dups, u->pobox_id))
        {
          printf("User %s(%s) has P.O.Box with duplicate string %d\n",
                 u->login, u->fullname, u->pobox_id);
@@ -348,8 +413,8 @@ pobox_check(int id, struct user *u, int hint)
            {
              printf("Replacing box_id dup string ID %d with %d\n",
                     u->pobox_id,
-                    int_hash_lookup(string_dups, u->pobox_id));
-             u->pobox_id = int_hash_lookup(string_dups, u->pobox_id);
+                    (int)hash_lookup(string_dups, u->pobox_id));
+             u->pobox_id = (int)hash_lookup(string_dups, u->pobox_id);
              fix_smtp_pobox(u->users_id, u->pobox_id);
              string_check(u->pobox_id);
            }
@@ -371,10 +436,10 @@ pobox_check(int id, struct user *u, int hint)
 }
 
 
-remove_pobox(int id)
+void remove_pobox(int id)
 {
   EXEC SQL BEGIN DECLARE SECTION;
-  int rowcount, iid = id;
+  int rowcount, iid = (int)id;
   EXEC SQL END DECLARE SECTION;
 
   EXEC SQL UPDATE users SET potype = 'NONE' WHERE users.users_id = :iid;
@@ -386,7 +451,7 @@ remove_pobox(int id)
   modified("users");
 }
 
-fix_smtp_pobox(int id, int sid)
+void fix_smtp_pobox(int id, int sid)
 {
   EXEC SQL BEGIN DECLARE SECTION;
   int rowcount, iid = id, isid = sid;
@@ -401,8 +466,10 @@ fix_smtp_pobox(int id, int sid)
   modified("users");
 }
 
-mach_check(int id, struct machine *m, int hint)
+void mach_check(int id, void *machine, void *hint)
 {
+  struct machine *m = machine;
+
   if (!hash_lookup(subnets, m->snet_id))
     {
       printf("Machine %s is on a non-existant subnet %d\n",
@@ -466,8 +533,10 @@ mach_check(int id, struct machine *m, int hint)
                               "modby", "mach_id");
 }
 
-subnet_check(int id, struct subnet *s, int hint)
+void subnet_check(int id, void *subnet, void *hint)
 {
+  struct subnet *s = subnet;
+
   switch (s->owner_type)
     {
     case 'U':
@@ -502,7 +571,7 @@ subnet_check(int id, struct subnet *s, int hint)
                               "modby", "snet_id");
 }
 
-clear_subnet_owner(struct subnet *s)
+void clear_subnet_owner(struct subnet *s)
 {
   EXEC SQL BEGIN DECLARE SECTION;
   int rowcount, id = s->snet_id;
@@ -518,7 +587,7 @@ clear_subnet_owner(struct subnet *s)
   modified("subnet");
 }
 
-clear_mach_owner(struct machine *m)
+void clear_mach_owner(struct machine *m)
 {
   EXEC SQL BEGIN DECLARE SECTION;
   int rowcount, id = m->mach_id;
@@ -534,16 +603,18 @@ clear_mach_owner(struct machine *m)
   modified("machine");
 }
 
-cluster_check(int id, struct cluster *c, int hint)
+void cluster_check(int id, void *cluster, void *hint)
 {
+  struct cluster *c = cluster;
+
   c->modby = maybe_fixup_modby(c->modby, id, c->name, "clusters",
                               "modby", "clu_id");
 }
 
-int show_svc(int id)
+int show_svc(void *id)
 {
   EXEC SQL BEGIN DECLARE SECTION;
-  int iid = id, found = 1;
+  int iid = (int)id, found = 1;
   char label[17], data[33];
   EXEC SQL END DECLARE SECTION;
 
@@ -561,14 +632,16 @@ int show_svc(int id)
       strtrim(data);
       found = 0;
       printf("Cluster data [%s] %s for non-existant cluster %d\n",
-            label, data, id);
+            label, data, iid);
     }
   EXEC SQL CLOSE csr203;
   return found;
 }
 
-list_check(int id, struct list *l, int hint)
+void list_check(int id, void *list, void *hint)
 {
+  struct list *l = list;
+
   switch (l->acl_type)
     {
     case 'L':
@@ -600,10 +673,10 @@ list_check(int id, struct list *l, int hint)
     }
 }
 
-fix_list_acl(int id)
+void fix_list_acl(int id)
 {
   EXEC SQL BEGIN DECLARE SECTION;
-  int rowcount, iid = id;
+  int rowcount, iid = (int)id;
   EXEC SQL END DECLARE SECTION;
 
   EXEC SQL UPDATE list SET acl_id = :iid, acl_type = 'LIST'
@@ -616,10 +689,10 @@ fix_list_acl(int id)
   modified("list");
 }
 
-int show_member_list(int id)
+int show_member_list(void *id)
 {
   EXEC SQL BEGIN DECLARE SECTION;
-  int mid, iid = id, found = 1;
+  int mid, iid = (int)id, found = 1;
   char mtype[9], *name = "";
   EXEC SQL END DECLARE SECTION;
 
@@ -647,11 +720,10 @@ int show_member_list(int id)
   return found;
 }
 
-int show_mem_user(int id)
+int show_mem_user(void *id)
 {
   EXEC SQL BEGIN DECLARE SECTION;
-  int lid, iid = id, found = 1;
-  char name[33];
+  int lid, iid = (int)id, found = 1;
   EXEC SQL END DECLARE SECTION;
 
   EXEC SQL DECLARE csr205 CURSOR FOR
@@ -672,11 +744,10 @@ int show_mem_user(int id)
   return found;
 }
 
-int show_mem_list(int id)
+int show_mem_list(void *id)
 {
   EXEC SQL BEGIN DECLARE SECTION;
-  int lid, iid = id, found = 1;
-  char name[33];
+  int lid, iid = (int)id, found = 1;
   EXEC SQL END DECLARE SECTION;
 
   EXEC SQL DECLARE csr206 CURSOR FOR
@@ -697,11 +768,10 @@ int show_mem_list(int id)
   return found;
 }
 
-int show_mem_str(int id)
+int show_mem_str(void *id)
 {
   EXEC SQL BEGIN DECLARE SECTION;
-  int lid, iid = id, found = 1;
-  char name[33];
+  int lid, iid = (int)id, found = 1;
   EXEC SQL END DECLARE SECTION;
 
   EXEC SQL DECLARE csr207 CURSOR FOR
@@ -723,11 +793,10 @@ int show_mem_str(int id)
 }
 
 
-int show_mem_krb(int id)
+int show_mem_krb(void *id)
 {
   EXEC SQL BEGIN DECLARE SECTION;
-  int lid, iid = id, found = 1;
-  char name[33];
+  int lid, iid = (int)id, found = 1;
   EXEC SQL END DECLARE SECTION;
 
   EXEC SQL DECLARE csr208 CURSOR FOR
@@ -749,10 +818,10 @@ int show_mem_krb(int id)
 }
 
 
-del_mem_user(int id)
+void del_mem_user(void *id)
 {
   EXEC SQL BEGIN DECLARE SECTION;
-  int iid = id, rowcount;
+  int iid = (int)id, rowcount;
   EXEC SQL END DECLARE SECTION;
 
   EXEC SQL DELETE FROM imembers WHERE member_type = 'USER' AND
@@ -765,10 +834,10 @@ del_mem_user(int id)
   modified("imembers");
 }
 
-del_mem_list(int id)
+void del_mem_list(void *id)
 {
   EXEC SQL BEGIN DECLARE SECTION;
-  int iid = id, rowcount;
+  int iid = (int)id, rowcount;
   EXEC SQL END DECLARE SECTION;
 
   EXEC SQL DELETE FROM imembers WHERE member_type = 'LIST' AND
@@ -781,10 +850,10 @@ del_mem_list(int id)
   modified("imembers");
 }
 
-del_mem_str(int id)
+void del_mem_str(void *id)
 {
   EXEC SQL BEGIN DECLARE SECTION;
-  int iid = id, rowcount;
+  int iid = (int)id, rowcount;
   EXEC SQL END DECLARE SECTION;
 
   EXEC SQL DELETE FROM imembers WHERE member_type = 'STRING' AND
@@ -798,10 +867,10 @@ del_mem_str(int id)
 }
 
 
-del_mem_krb(int id)
+void del_mem_krb(void *id)
 {
   EXEC SQL BEGIN DECLARE SECTION;
-  int iid = id, rowcount;
+  int iid = (int)id, rowcount;
   EXEC SQL END DECLARE SECTION;
 
   EXEC SQL DELETE FROM imembers WHERE member_type = 'KERBEROS' AND
@@ -815,11 +884,11 @@ del_mem_krb(int id)
 }
 
 
-int show_sh(int id)
+int show_sh(void *id)
 {
   EXEC SQL BEGIN DECLARE SECTION;
   char name[33];
-  int iid = id;
+  int iid = (int)id;
   EXEC SQL END DECLARE SECTION;
   int found = 1;
 
@@ -835,16 +904,16 @@ int show_sh(int id)
 
       found = 0;
       printf("ServerHost entry for service %s non-existant host %d\n",
-            name, id);
+            name, iid);
     }
   EXEC SQL CLOSE csr209;
   return found;
 }
 
-del_sh_mach(int id)
+void del_sh_mach(void *id)
 {
   EXEC SQL BEGIN DECLARE SECTION;
-  int iid = id, rowcount;
+  int iid = (int)id, rowcount;
   EXEC SQL END DECLARE SECTION;
 
   EXEC SQL DELETE FROM serverhosts WHERE mach_id = :iid;
@@ -859,8 +928,11 @@ del_sh_mach(int id)
 
 static int fnchecklen;
 
-fsmatch(int id, struct nfsphys *n, struct filesys *f)
+void fsmatch(int id, void *nfsphys, void *filesys)
 {
+  struct nfsphys *n = nfsphys;
+  struct filesys *f = filesys;
+
   if (n->mach_id == f->mach_id &&
       !strncmp(f->dir, n->dir, strlen(n->dir)) &&
       strlen(n->dir) > fnchecklen)
@@ -871,12 +943,13 @@ fsmatch(int id, struct nfsphys *n, struct filesys *f)
 }
 
 
-check_fs(int id, struct filesys *f, int hint)
+void check_fs(int id, void *filesys, void *hint)
 {
   EXEC SQL BEGIN DECLARE SECTION;
   int iid = id, id1, id2, id3, rowcount;
   char *dir;
   EXEC SQL END DECLARE SECTION;
+  struct filesys *f = filesys;
   struct nfsphys *n;
   struct machine *m;
 
@@ -919,7 +992,7 @@ check_fs(int id, struct filesys *f, int hint)
     {
       if (!hash_lookup(nfsphys, f->phys_id))
        {
-         m = (struct machine *)hash_lookup(machines, f->mach_id);
+         m = hash_lookup(machines, f->mach_id);
          printf("Filesys %s with bad phys_id %d\n", f->name, f->phys_id);
          if (single_fix("Fix", 1))
            {
@@ -1004,8 +1077,10 @@ check_fs(int id, struct filesys *f, int hint)
     }
 }
 
-check_nfsphys(int id, struct nfsphys *n, int hint)
+void check_nfsphys(int id, void *nfsphys, void *hint)
 {
+  struct nfsphys *n = nfsphys;
+
   if (!hash_lookup(machines, n->mach_id))
     {
       printf("NFSphys %d(%s) on non-existant machine %d\n",
@@ -1015,10 +1090,10 @@ check_nfsphys(int id, struct nfsphys *n, int hint)
     }
 }
 
-int show_fsg_missing(int id)
+int show_fsg_missing(void *id)
 {
   EXEC SQL BEGIN DECLARE SECTION;
-  int iid = id, id1, found = 1;
+  int iid = (int)id, id1, found = 1;
   EXEC SQL END DECLARE SECTION;
   struct filesys *f;
 
@@ -1033,17 +1108,18 @@ int show_fsg_missing(int id)
        break;
 
       found = 0;
-      if (f = (struct filesys *) hash_lookup(filesys, id1))
-       printf("Missing fsgroup %d has member filesystem %s\n", id, f->name);
+      if ((f = hash_lookup(filesys, id1)))
+       printf("Missing fsgroup %d has member filesystem %s\n", iid, f->name);
       else
-       printf("Missing fsgroup %d has member filesystem %d\n", id, id1);
+       printf("Missing fsgroup %d has member filesystem %d\n", iid, id1);
     }
   EXEC SQL CLOSE csr210;
   return found;
 }
 
-int show_fsg_type(struct filesys *f)
+int show_fsg_type(void *filesys)
 {
+  struct filesys *f = filesys;
   char *t;
 
   switch (f->type)
@@ -1073,8 +1149,9 @@ int show_fsg_type(struct filesys *f)
   return 0;
 }
 
-fix_fsg_type(struct filesys *f)
+void fix_fsg_type(void *filesys)
 {
+  struct filesys *f = filesys;
   EXEC SQL BEGIN DECLARE SECTION;
   int rowcount, id = f->filsys_id;
   EXEC SQL END DECLARE SECTION;
@@ -1088,10 +1165,10 @@ fix_fsg_type(struct filesys *f)
   modified("filesys");
 }
 
-int show_fsg_nomember(int id)
+int show_fsg_nomember(void *id)
 {
   EXEC SQL BEGIN DECLARE SECTION;
-  int iid = id, id1, found = 1;
+  int iid = (int)id, id1, found = 1;
   EXEC SQL END DECLARE SECTION;
   struct filesys *f;
 
@@ -1106,19 +1183,19 @@ int show_fsg_nomember(int id)
        break;
 
       found = 0;
-      if (f = (struct filesys *) hash_lookup(filesys, id1))
-       printf("FSGroup %s has missing member %d\n", f->name, id);
+      if ((f = hash_lookup(filesys, id1)))
+       printf("FSGroup %s has missing member %d\n", f->name, iid);
       else
-       printf("FSGroup %d has missing member %d\n", id1, id);
+       printf("FSGroup %d has missing member %d\n", id1, iid);
     }
   EXEC SQL CLOSE csr211;
   return found;
 }
 
-int show_quota_nouser(int id)
+int show_quota_nouser(void *id)
 {
   EXEC SQL BEGIN DECLARE SECTION;
-  int iid = id, id1, found = 1;
+  int iid = (int)id, id1, found = 1;
   EXEC SQL END DECLARE SECTION;
 
   EXEC SQL DECLARE csr212 CURSOR FOR
@@ -1132,16 +1209,16 @@ int show_quota_nouser(int id)
        break;
 
       found = 0;
-      printf("Quota on fs %d for non-existant user %d\n", id1, id);
+      printf("Quota on fs %d for non-existant user %d\n", id1, iid);
     }
   EXEC SQL CLOSE csr212;
   return found;
 }
 
-int show_quota_nolist(int id)
+int show_quota_nolist(void *id)
 {
   EXEC SQL BEGIN DECLARE SECTION;
-  int iid = id, id1, found = 1;
+  int iid = (int)id, id1, found = 1;
   EXEC SQL END DECLARE SECTION;
 
   EXEC SQL DECLARE csr213 CURSOR FOR
@@ -1155,19 +1232,19 @@ int show_quota_nolist(int id)
        break;
 
       found = 0;
-      printf("Quota on fs %d for non-existant list %d\n", id1, id);
+      printf("Quota on fs %d for non-existant list %d\n", id1, iid);
     }
   EXEC SQL CLOSE csr213;
   return found;
 }
 
-fix_quota_nouser(int id)
+void fix_quota_nouser(void *id)
 {
   EXEC SQL BEGIN DECLARE SECTION;
-  int iid = id, rowcount, id1;
+  int iid = (int)id, rowcount, id1;
   EXEC SQL END DECLARE SECTION;
 
-  id1 = ((struct filesys *)hash_lookup(filesys, id))->phys_id;
+  id1 = ((struct filesys *)hash_lookup(filesys, iid))->phys_id;
   EXEC SQL DELETE FROM quota
     WHERE entity_id = :iid AND type = 'USER';
   rowcount = sqlca.sqlerrd[2];
@@ -1178,13 +1255,13 @@ fix_quota_nouser(int id)
   modified("quota");
 }
 
-fix_quota_nolist(int id)
+void fix_quota_nolist(void *id)
 {
   EXEC SQL BEGIN DECLARE SECTION;
-  int iid = id, rowcount, id1;
+  int iid = (int)id, rowcount, id1;
   EXEC SQL END DECLARE SECTION;
 
-  id1 = ((struct filesys *)hash_lookup(filesys, id))->phys_id;
+  id1 = ((struct filesys *)hash_lookup(filesys, iid))->phys_id;
   EXEC SQL DELETE FROM quota WHERE entity_id = :iid AND type = 'GROUP';
   rowcount = sqlca.sqlerrd[2];
   if (rowcount > 0)
@@ -1194,10 +1271,10 @@ fix_quota_nolist(int id)
   modified("quota");
 }
 
-int show_quota_nofs(int id)
+int show_quota_nofs(void *id)
 {
   EXEC SQL BEGIN DECLARE SECTION;
-  int iid = id, id1, found = 1;
+  int iid = (int)id, id1, found = 1;
   char type[9];
   EXEC SQL END DECLARE SECTION;
 
@@ -1212,27 +1289,26 @@ int show_quota_nofs(int id)
        break;
 
       found = 0;
-      printf("Quota for %s %d on non-existant filesys %d\n", type, id1, id);
+      printf("Quota for %s %d on non-existant filesys %d\n", type, id1, iid);
     }
   EXEC SQL CLOSE csr214;
   return found;
 }
 
-fix_quota_nofs(int id)
+void fix_quota_nofs(void *id)
 {
-  single_delete("quota", "filsys_id", id);
+  single_delete("quota", "filsys_id", (int)id);
 }
 
-int show_quota_wrongpid(int id)
+int show_quota_wrongpid(void *id)
 {
   EXEC SQL BEGIN DECLARE SECTION;
-  int iid = id, id1, found = 1;
+  int iid = (int)id, id1, found = 1;
   char type[9];
   EXEC SQL END DECLARE SECTION;
-  struct user *u;
   struct filesys *f;
 
-  f = (struct filesys *)hash_lookup(filesys, id);
+  f = hash_lookup(filesys, iid);
   EXEC SQL DECLARE csr215 CURSOR FOR
     SELECT entity_id, type FROM quota
     WHERE filsys_id = :iid;
@@ -1245,19 +1321,19 @@ int show_quota_wrongpid(int id)
 
       found = 0;
       printf("Quota for %s %d on filesys %s has wrong phys_id %d\n",
-            type, id1, f->name, id);
+            type, id1, f->name, iid);
     }
   EXEC SQL CLOSE csr215;
   return found;
 }
 
-fix_quota_physid(int id)
+void fix_quota_physid(void *id)
 {
   EXEC SQL BEGIN DECLARE SECTION;
-  int iid = id, rowcount, id1;
+  int iid = (int)id, rowcount, id1;
   EXEC SQL END DECLARE SECTION;
 
-  id1 = ((struct filesys *)hash_lookup(filesys, id))->phys_id;
+  id1 = ((struct filesys *)hash_lookup(filesys, iid))->phys_id;
   EXEC SQL UPDATE quota SET phys_id = :id1
     WHERE filsys_id = :iid AND phys_id != :id1;
   rowcount = sqlca.sqlerrd[2];
@@ -1268,11 +1344,11 @@ fix_quota_physid(int id)
   modified("quota");
 }
 
-int show_srv_user(int id)
+int show_srv_user(void *id)
 {
   EXEC SQL BEGIN DECLARE SECTION;
   char name[33];
-  int iid = id;
+  int iid = (int)id;
   EXEC SQL END DECLARE SECTION;
   int found = 1;
 
@@ -1287,18 +1363,18 @@ int show_srv_user(int id)
        break;
 
       strtrim(name);
-      printf("Service %s has acl non-existant user %d\n", name, id);
+      printf("Service %s has acl non-existant user %d\n", name, iid);
       found = 0;
     }
   EXEC SQL CLOSE csr216;
   return found;
 }
 
-int show_srv_list(int id)
+int show_srv_list(void *id)
 {
   EXEC SQL BEGIN DECLARE SECTION;
   char name[33];
-  int iid = id;
+  int iid = (int)id;
   EXEC SQL END DECLARE SECTION;
   int found = 1;
 
@@ -1313,17 +1389,17 @@ int show_srv_list(int id)
        break;
 
       strtrim(name);
-      printf("Service %s has acl non-existant list %d\n", name, id);
+      printf("Service %s has acl non-existant list %d\n", name, iid);
       found = 0;
     }
   EXEC SQL CLOSE csr217;
   return found;
 }
 
-zero_srv_user(int id)
+void zero_srv_user(void *id)
 {
   EXEC SQL BEGIN DECLARE SECTION;
-  int iid = id, rowcount;
+  int iid = (int)id, rowcount;
   EXEC SQL END DECLARE SECTION;
 
   EXEC SQL UPDATE servers SET acl_id = 0 WHERE acl_id = :iid AND
@@ -1336,10 +1412,10 @@ zero_srv_user(int id)
   modified("servers");
 }
 
-zero_srv_list(int id)
+void zero_srv_list(void *id)
 {
   EXEC SQL BEGIN DECLARE SECTION;
-  int iid = id, rowcount;
+  int iid = (int)id, rowcount;
   EXEC SQL END DECLARE SECTION;
 
   EXEC SQL UPDATE servers SET acl_id = 0 WHERE acl_id = :iid AND
@@ -1352,10 +1428,10 @@ zero_srv_list(int id)
   modified("servers");
 }
 
-int show_krb_usr(int id)
+int show_krb_usr(void *id)
 {
   EXEC SQL BEGIN DECLARE SECTION;
-  int iid = id, found = 1, id1;
+  int iid = (int)id, found = 1, id1;
   EXEC SQL END DECLARE SECTION;
   struct string *s;
   char *ss;
@@ -1370,22 +1446,22 @@ int show_krb_usr(int id)
       if (sqlca.sqlcode)
        break;
 
-      if ((s = ((struct string *)hash_lookup(strings, id1))))
+      if ((s = hash_lookup(strings, id1)))
        ss = s->name;
       else
        ss = "[unknown]";
       found = 0;
       printf("Kerberos map for non-existant user %d to principal %s\n",
-            id, s);
+            iid, ss);
     }
   EXEC SQL CLOSE csr218;
   return found;
 }
 
-int show_krb_str(int id)
+int show_krb_str(void *id)
 {
   EXEC SQL BEGIN DECLARE SECTION;
-  int iid = id, found = 1, id1;
+  int iid = (int)id, found = 1, id1;
   EXEC SQL END DECLARE SECTION;
   struct user *u;
   char *s;
@@ -1400,23 +1476,23 @@ int show_krb_str(int id)
       if (sqlca.sqlcode)
        break;
 
-      if ((u = ((struct user *)hash_lookup(users, id1))))
+      if ((u = hash_lookup(users, id1)))
        s = u->login;
       else
        s = "[\?\?\?]";
       found = 0;
       printf("Kerberos map for user %s (%d) to non-existant string %d\n",
-            s, id1, id);
+            s, id1, iid);
     }
   EXEC SQL CLOSE csr219;
   return found;
 }
 
-int show_pdm_mach(int id)
+int show_pdm_mach(void *id)
 {
   EXEC SQL BEGIN DECLARE SECTION;
   char name[33];
-  int iid = id;
+  int iid = (int)id;
   EXEC SQL END DECLARE SECTION;
   int found = 1;
 
@@ -1432,7 +1508,7 @@ int show_pdm_mach(int id)
 
       strtrim(name);
       printf("Palladium server/supervisor %s is on non-existant machine %d\n",
-            name, id);
+            name, iid);
       found = 0;
     }
   EXEC SQL CLOSE csr220;
@@ -1440,7 +1516,7 @@ int show_pdm_mach(int id)
 }
 
 
-phase2(void)
+void phase2(void)
 {
   EXEC SQL BEGIN DECLARE SECTION;
   int id1, id2, id3, id4, id5;
@@ -1478,10 +1554,10 @@ phase2(void)
       if (sqlca.sqlcode)
        break;
 
-      if (!(m = (struct machine *)hash_lookup(machines, id1)))
-       sq_save_unique_data(sq1, id1);
+      if (!(m = hash_lookup(machines, id1)))
+       sq_save_unique_data(sq1, (void *)id1);
       else if (!hash_lookup(clusters, id2))
-       sq_save_unique_data(sq2, id2);
+       sq_save_unique_data(sq2, (void *)id2);
       if (m)
        m->clucount++;
     }
@@ -1501,7 +1577,7 @@ phase2(void)
        break;
 
       if (!hash_lookup(clusters, id1))
-       sq_save_unique_data(sq1, id1);
+       sq_save_unique_data(sq1, (void *)id1);
     }
   EXEC SQL CLOSE csr222;
   generic_delete(sq1, show_svc, "svc", "clu_id", 1);
@@ -1526,16 +1602,16 @@ phase2(void)
       if (sqlca.sqlcode)
        break;
 
-      if (!(l = (struct list *) hash_lookup(lists, id1)))
-       sq_save_unique_data(sq1, id1);
+      if (!(l = hash_lookup(lists, id1)))
+       sq_save_unique_data(sq1, (void *)id1);
       else if (type[0] == 'U' && !hash_lookup(users, id2))
-       sq_save_unique_data(sq2, id2);
+       sq_save_unique_data(sq2, (void *)id2);
       else if (type[0] == 'L' && !hash_lookup(lists, id2))
-       sq_save_unique_data(sq3, id2);
+       sq_save_unique_data(sq3, (void *)id2);
       else if (type[0] == 'S' && !maybe_fixup_unref_string2("imembers", "member_id", "csr223", id2))
-       sq_save_unique_data(sq4, id2);
+       sq_save_unique_data(sq4, (void *)id2);
       else if (type[0] == 'K' && !maybe_fixup_unref_string2("imembers", "member_id", "csr223", id2))
-       sq_save_unique_data(sq5, id2);
+       sq_save_unique_data(sq5, (void *)id2);
       else
        l->members++;
     }
@@ -1562,9 +1638,9 @@ phase2(void)
       maybe_fixup_modby2("servers", "modby", "csr224", id2);
       strtrim(type);
       if (!strcmp(type, "USER") && !hash_lookup(users, id1))
-       sq_save_data(sq1, id1);
+       sq_save_data(sq1, (void *)id1);
       else if (!strcmp(type, "LIST") && !hash_lookup(lists, id1))
-       sq_save_data(sq2, id1);
+       sq_save_data(sq2, (void *)id1);
     }
   EXEC SQL CLOSE csr224;
   generic_fix(sq1, show_srv_user, "Fix", zero_srv_user, 1);
@@ -1584,7 +1660,7 @@ phase2(void)
 
       maybe_fixup_modby2("serverhosts", "modby", "csr225", id2);
       if (!hash_lookup(machines, id1))
-       sq_save_data(sq, id1);
+       sq_save_data(sq, (void *)id1);
     }
   EXEC SQL CLOSE csr225;
   generic_fix(sq, show_sh, "Delete", del_sh_mach, 0);
@@ -1608,10 +1684,10 @@ phase2(void)
       if (sqlca.sqlcode)
        break;
 
-      if (!(f = (struct filesys *) hash_lookup(filesys, id1)))
-       sq_save_data(sq1, id1);
+      if (!(f = hash_lookup(filesys, id1)))
+       sq_save_data(sq1, (void *)id1);
       if (!hash_lookup(filesys, id2))
-       sq_save_data(sq3, id2);
+       sq_save_data(sq3, (void *)id2);
     }
   EXEC SQL CLOSE csr226;
   generic_delete(sq1, show_fsg_missing, "fsgroup", "group_id", 0);
@@ -1634,14 +1710,13 @@ phase2(void)
 
       maybe_fixup_modby2("quota", "modby", "csr227", id5);
       if (type[0] == 'U' && id1 != 0 && !hash_lookup(users, id1))
-       sq_save_data(sq1, id1);
+       sq_save_data(sq1, (void *)id1);
       else if (type[0] == 'G' && !hash_lookup(lists, id1))
-       sq_save_data(sq4, id1);
-      else if (!(f = (struct filesys *) hash_lookup(filesys, id2)))
-       sq_save_data(sq2, id2);
-      else if (id3 != f->phys_id ||
-              !(n = (struct nfsphys *) hash_lookup(nfsphys, id3)))
-       sq_save_data(sq3, id2);
+       sq_save_data(sq4, (void *)id1);
+      else if (!(f = hash_lookup(filesys, id2)))
+       sq_save_data(sq2, (void *)id2);
+      else if (id3 != f->phys_id || !(n = hash_lookup(nfsphys, id3)))
+       sq_save_data(sq3, (void *)id2);
       else
        n->count += id4;
     }
@@ -1698,7 +1773,7 @@ phase2(void)
 
       maybe_fixup_modby2("palladium", "modby", "csr229", id2);
       if (!hash_lookup(machines, id1))
-       sq_save_unique_data(sq1, id1);
+       sq_save_unique_data(sq1, (void *)id1);
     }
   EXEC SQL CLOSE csr229;
   generic_delete(sq1, show_pdm_mach, "palladium", "mach_id", 1);
@@ -1717,9 +1792,9 @@ phase2(void)
        break;
 
       if (!hash_lookup(users, id1))
-       sq_save_unique_data(sq1, id1);
+       sq_save_unique_data(sq1, (void *)id1);
       else if (!maybe_fixup_unref_string2("krbmap", "string_id", "csr230", id2))
-       sq_save_unique_data(sq2, id2);
+       sq_save_unique_data(sq2, (void *)id2);
     }
   EXEC SQL CLOSE csr230;
   generic_delete(sq1, show_krb_usr, "krbmap", "users_id", 1);
@@ -1755,7 +1830,7 @@ phase2(void)
        break;
 
       if (!hash_lookup(machines, id1))
-       sq_save_unique_data(sq1, id1);
+       sq_save_unique_data(sq1, (void *)id1);
     }
   EXEC SQL CLOSE csr232;
   generic_delete(sq1, show_hostalias, "hostalias", "mach_id", 1);
@@ -1774,9 +1849,9 @@ phase2(void)
 
       maybe_fixup_modby2("printcap", "modby", "csr233", id3);
       if (!hash_lookup(machines, id1))
-       sq_save_unique_data(sq1, id1);
+       sq_save_unique_data(sq1, (void *)id1);
       else if (!hash_lookup(machines, id2))
-       sq_save_unique_data(sq2, id2);
+       sq_save_unique_data(sq2, (void *)id2);
     }
   EXEC SQL CLOSE csr233;
   generic_delete(sq1, show_pcap_mach, "printcap", "mach_id", 1);
index e78421bd0f16f21cd1b323f500a36e255fab739e..312dd8577cea2951dae4309909358ac11dc44fb0 100644 (file)
@@ -1,19 +1,25 @@
-/* $Header$
+/* $Id$
  *
- *  (c) Copyright 1988 by the Massachusetts Institute of Technology.
- *  For copying and distribution information, please see the file
- *  <mit-copyright.h>.
+ * (c) Copyright 1988-1998 by the Massachusetts Institute of Technology.
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
  */
 
 #include <mit-copyright.h>
-#include <stdio.h>
+#include <moira.h>
 #include "dbck.h"
 
-static char phase3_qc_rcsid[] = "$Header$";
+#include <stdio.h>
+
+RCSID("$Header$");
 
+void empty_list_check(int id, void *list, void *hint);
+void unref_string_check(int id, void *string, void *hint);
+void noclu_mach_check(int id, void *machine, void *hint);
 
-empty_list_check(int id, struct list *l, int hint)
+void empty_list_check(int id, void *list, void *hint)
 {
+  struct list *l = list;
   if (l->members == 0 && l->list_id != 0)
     printf("Warning: List %s is empty\n", l->name);
 }
@@ -36,8 +42,10 @@ struct string *string_check(int id)
 }
 
 
-unref_string_check(int id, struct string *s, int hint)
+void unref_string_check(int id, void *string, void *hint)
 {
+  struct string *s = string;
+
   if (s->refc == 0)
     {
       printf("Unreferenced string %s id %d\n", s->name, id);
@@ -51,15 +59,15 @@ unref_string_check(int id, struct string *s, int hint)
  *  servers in the Athena Computing Environment, has been extended to
  *  manage all hosts in the MIT.EDU domain (but not subdomains).
  */
-#ifndef ATHENA
-noclu_mach_check(int id, struct machine *m, int hint)
+void noclu_mach_check(int id, void *machine, void *hint)
 {
+  struct machine *m = machine;
+
   if (m->clucount == 0 && m->mach_id != 0)
     printf("Warning: machine %s is not in any clusters\n", m->name);
 }
-#endif
 
-phase3(void)
+void phase3(void)
 {
   printf("Phase 3 - Finding unused objects\n");
 
index a6ee75f487565590771d11ca6e1063b32352a670..9aba12e09a2eb208eb82c4e340afadb99c972dba 100644 (file)
@@ -1,29 +1,38 @@
-/* $Header$
+/* $Id$
  *
- *  (c) Copyright 1988 by the Massachusetts Institute of Technology.
- *  For copying and distribution information, please see the file
- *  <mit-copyright.h>.
+ * (c) Copyright 1988-1998 by the Massachusetts Institute of Technology.
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
  */
 
 #include <mit-copyright.h>
-#include <stdlib.h>
 #include <moira.h>
 #include "dbck.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
 EXEC SQL INCLUDE sqlca;
 
-static char phase4_qc_rcsid[] = "$Header$";
+RCSID("$Header$");
 
 EXEC SQL WHENEVER SQLERROR DO dbmserr();
 
-count_boxes(int id, struct user *u, struct hash *boxes)
+void count_boxes(int id, void *user, void *boxes);
+void check_box_counts(int id, void *cnt, void *counts);
+void check_nfs_counts(int id, void *nfsphys, void *hint);
+
+void count_boxes(int id, void *user, void *boxes)
 {
+  struct user *u = user;
   int i;
 
   if (u->potype == 'P')
     {
       if ((i = (int) hash_lookup(boxes, u->pobox_id)))
        {
-         if (hash_store(boxes, u->pobox_id, i + 1) == -1)
+         if (hash_store(boxes, u->pobox_id, (void *)(i + 1)) == -1)
            out_of_mem("storing poboxes in hash table");
        }
       else
@@ -36,19 +45,19 @@ count_boxes(int id, struct user *u, struct hash *boxes)
 }
 
 
-check_box_counts(int id, int cnt, struct hash *counts)
+void check_box_counts(int id, void *cnt, void *counts)
 {
   EXEC SQL BEGIN DECLARE SECTION;
-  int oldval, rowcount, iid = id, icnt = cnt;
+  int oldval, rowcount, iid = id, icnt = (int)cnt;
   EXEC SQL END DECLARE SECTION;
 
   oldval = (int) hash_lookup(counts, id);
-  cnt--;
-  if (oldval != cnt)
+  icnt--;
+  if (oldval != icnt)
     {
       printf("Count wrong on POBox machine %s; is %d in db, counted %d\n",
             ((struct machine *) hash_lookup(machines, id))->name,
-            oldval, cnt);
+            oldval, icnt);
       if (single_fix("Update", 1))
        {
          EXEC SQL UPDATE serverhosts SET value1 = :icnt
@@ -64,8 +73,9 @@ check_box_counts(int id, int cnt, struct hash *counts)
 }
 
 
-check_nfs_counts(int id, struct nfsphys *n, int hint)
+void check_nfs_counts(int id, void *nfsphys, void *hint)
 {
+  struct nfsphys *n = nfsphys;
   EXEC SQL BEGIN DECLARE SECTION;
   int iid = id, val, rowcount;
   EXEC SQL END DECLARE SECTION;
@@ -91,7 +101,7 @@ check_nfs_counts(int id, struct nfsphys *n, int hint)
 }
 
 
-phase4(void)
+void phase4(void)
 {
   struct hash *boxes, *counts;
   int id, cnt;
@@ -111,9 +121,9 @@ phase4(void)
       if (sqlca.sqlcode)
        break;
 
-      if (hash_store(boxes, id, 1) == -1)
+      if (hash_store(boxes, id, (void *)1) == -1)
        out_of_mem("storing poboxes");
-      if (hash_store(counts, id, cnt) == -1)
+      if (hash_store(counts, id, (void *)cnt) == -1)
        out_of_mem("storing pobox counts in hash table");
     }
   EXEC SQL CLOSE csr401;
@@ -125,13 +135,12 @@ phase4(void)
 }
 
 
-count_only_setup(void)
+void count_only_setup(void)
 {
   EXEC SQL BEGIN DECLARE SECTION;
   int id, status, id2, id3;
   char name[33], last[17], first[17], buf[257];
   EXEC SQL END DECLARE SECTION;
-  struct save_queue *sq;
   struct user *u;
   struct nfsphys *n;
   struct machine *m;
@@ -156,7 +165,7 @@ count_only_setup(void)
       strcpy(u->login, strtrim(name));
       u->potype = buf[0];
       sprintf(buf, "%s, %s", strtrim(last), strtrim(first));
-      u->fullname = strsave(buf);
+      u->fullname = strdup(buf);
       u->status = status;
       u->users_id = id;
       switch (u->potype)
@@ -230,7 +239,7 @@ count_only_setup(void)
       if (sqlca.sqlcode)
        break;
 
-      if (n = (struct nfsphys  *) hash_lookup(nfsphys, id))
+      if ((n = hash_lookup(nfsphys, id)))
        n->count += id2;
     }
   EXEC SQL CLOSE csr405;
index e02103560b0683409bf196f22d3abbae73a9e54d..62fcdb0346963194a20c49cbc4cb374a083d669b 100644 (file)
@@ -1,33 +1,40 @@
-/*
- * The Data Control Manager for MOIRA.
+/* $Id$
  *
- * Copyright 1987, 1988 by the Massachusetts Institute of Technology.
- * For copying and distribution information, see the file
- * "mit-copyright.h".
+ * The Data Control Manager for Moira.
  *
- * $Source$
- * $Author$
- * $Header$
+ * Copyright (C) 1987-1998 by the Massachusetts Institute of Technology.
+ * For copying and distribution information, see the file
+ * <mit-copyright.h>.
  */
 
-#ifndef lint
-static char rcsid_dcm_c[] = "$Header$";
-#endif lint
+#include <mit-copyright.h>
+#include <moira.h>
+#include <moira_site.h>
+#include "update.h"
+
+#include <sys/param.h>
+#include <sys/stat.h>
+#include <sys/wait.h>
 
 #include <signal.h>
 #include <stdio.h>
+#include <stdlib.h>
 #include <string.h>
-#include <time.h>
 #include <unistd.h>
-#include <sys/param.h>
-#include <sys/wait.h>
 
-#include <com_err.h>
 #include <gdb.h>
-#include <moira.h>
-#include <moira_site.h>
 
 EXEC SQL INCLUDE sqlca;
+void sqlglm(char *, unsigned int *, unsigned int *);
+
+RCSID("$Header$");
+
+int generate_service(char *name, int force);
+void do_hosts(char *service);
+int dcm_send_file(char *service, char *host, char *target);
+int dcm_execute(char *service, char *host, char *script);
+void dbmserr(void);
+
 EXEC SQL WHENEVER SQLERROR DO dbmserr();
 
 #define SQL_NO_MATCH 1403
@@ -128,6 +135,7 @@ int main(int argc, char **argv)
   while (waitpid(0, &status, 0) > 0)
     ;
   com_err(whoami, 0, "exiting");
+  exit(0);
 }
 
 int generate_service(char *name, int force)
@@ -135,7 +143,7 @@ int generate_service(char *name, int force)
   EXEC SQL BEGIN DECLARE SECTION;
   int interval, dfcheck, status;
   time_t now;
-  char *errmsg;
+  const char *errmsg;
   EXEC SQL END DECLARE SECTION;
   char dfgen_prog[64], dfgen_cmd[128];
   struct sigaction action, prevaction;
@@ -225,8 +233,9 @@ int generate_service(char *name, int force)
 void do_hosts(char *service)
 {
   EXEC SQL BEGIN DECLARE SECTION;
-  char type[16], host[73], target[64], script[128], *errmsg;
-  int status = 0, mid, dfgen, replicated;
+  char type[16], host[73], target[64], script[128];
+  const char *errmsg;
+  int status = 0, dfgen, replicated;
   time_t now;
   EXEC SQL END DECLARE SECTION;
 
index c1f493fbe062cc3f71aa84d327dfe1cddd714682..a5403bdf0fcb3fe8646a03339ceb01f55be81714 100644 (file)
@@ -1,38 +1,34 @@
-/*
- *     $Source$
- *     $Author$
- *     $Header$
+/* $Id$
  *
- *     Copyright (C) 1987, 1988 by the Massachusetts Institute of Technology
- *     For copying and distribution information, please see the file
- *     <mit-copyright.h>.
+ * This program starts the DCM in a "clean" environment.
+ * and then waits for it to exit.
  *
- *     This program starts the DCM in a "clean" environment.
- *     and then waits for it to exit.
+ * Copyright (C) 1987-1998 by the Massachusetts Institute of Technology
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
  */
 
-#ifndef lint
-static char *rcsid_mr_starter_c = "$Header$";
-#endif lint
-
 #include <mit-copyright.h>
+#include <moira.h>
+#include <moira_site.h>
+
+#include <sys/resource.h>
+#include <sys/wait.h>
+
 #include <errno.h>
+#include <fcntl.h>
+#include <signal.h>
 #include <stdio.h>
 #include <string.h>
-#include <sys/types.h>
-#include <sys/file.h>
-#include <sys/wait.h>
-#include <sys/signal.h>
-#include <sys/ioctl.h>
-#include <fcntl.h>
-#include <sys/resource.h>
-#include <moira_site.h>
-#include <time.h>
+#include <unistd.h>
+
+RCSID("$Header$");
 
 #define PROG   "dcm"
 
 int rdpipe[2];
-extern int errno;
+
+void cleanup(void);
 
 void cleanup(void)
 {
@@ -63,12 +59,9 @@ int main(int argc, char *argv)
 {
   char buf[BUFSIZ];
   FILE *log, *prog;
-  int logf, inf, i, done, pid, tty;
+  int logf, inf, i, done, pid;
   struct rlimit rl;
 
-  extern int errno;
-  extern char *sys_errlist[];
-
   struct sigaction action;
   int nfds;
 
@@ -139,7 +132,7 @@ int main(int argc, char *argv)
          if (errno && errno != EINTR)
            {
              strcpy(buf, "Unable to read from program: ");
-             strcat(buf, sys_errlist[errno]);
+             strcat(buf, strerror(errno));
              strcat(buf, "\n");
            }
          else
index 910c8072352e292a1898561dd91e3335bfa901ae..b34623c00b53954f29dbb361563fdaffd183b1bb 100644 (file)
@@ -1,22 +1,25 @@
-/* $Header$
+/* $Id$
  *
  * This generates a master /etc/passwd containing all active (status != 0)
  * accounts.
  *
- *  (c) Copyright 1988, 1990 by the Massachusetts Institute of Technology.
- *  For copying and distribution information, please see the file
- *  <mit-copyright.h>.
+ * Copyright (C) 1998 by the Massachusetts Institute of Technology.
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
  */
 
 #include <mit-copyright.h>
-#include <stdio.h>
 #include <moira.h>
-#include <sys/types.h>
+
 #include <sys/stat.h>
-#include <sys/time.h>
+
+#include <stdio.h>
+#include <time.h>
+
 EXEC SQL INCLUDE sqlca;
 
-extern int errno;
+RCSID("$Header$");
+
 char *whoami = "directory.gen";
 char *db = "moira/moira";
 
index 7a71639db045e3927cc07fa0d9b7d24f9e40c5c8..f4f624ed8ef2e1567896c27835c8936f87312b57 100644 (file)
@@ -1,26 +1,29 @@
-/* $Header$
+/* $Id$
  *
  * This generates the zone files necessary to load a hesiod server.
  * The following zones are generated: passwd, uid, pobox, group,
  * grplist, gid, filsys, cluster, pcap, sloc, service.
  *
- *  (c) Copyright 1988, 1990 by the Massachusetts Institute of Technology.
- *  For copying and distribution information, please see the file
- *  <mit-copyright.h>.
+ * (c) Copyright 1988-1998 by the Massachusetts Institute of Technology.
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
  */
 
 #include <mit-copyright.h>
-#include <stdio.h>
-#include <stdlib.h>
 #include <moira.h>
 #include <moira_site.h>
-#include <sys/types.h>
+
 #include <sys/stat.h>
-#include <sys/time.h>
-#include <ctype.h>
+
+#include <stdio.h>
+#include <stdlib.h>
 #include <string.h>
+
+#include "util.h"
+
 EXEC SQL INCLUDE sqlca;
 
+RCSID("$Header$");
 
 #ifndef HTYPE
 #define HTYPE "TXT"
@@ -55,6 +58,36 @@ struct user {
   struct grp *lists;
 };
 
+/*
+ * Modified from sys/types.h:
+ */
+int setsize;   /* = howmany(setbits, NSETBITS) */
+
+typedef long   set_mask;
+#define NSETBITS       (sizeof(set_mask) * NBBY)       /* bits per mask */
+#ifndef howmany
+#define        howmany(x, y)   (((x) + ((y) - 1)) / (y))
+#endif
+
+#define        SET_SET(n, p)   ((p)[(n)/NSETBITS] |=  (1 << ((n) % NSETBITS)))
+#define        SET_CLR(n, p)   ((p)[(n)/NSETBITS] &= ~(1 << ((n) % NSETBITS)))
+#define        SET_ISSET(n, p) ((p)[(n)/NSETBITS] &   (1 << ((n) % NSETBITS)))
+#define SET_CREATE()   (malloc(setsize * sizeof(set_mask)))
+#define SET_ZERO(p)    memset(p, 0, setsize * sizeof(set_mask))
+#define SET_CMP(p1, p2) (memcmp(p1, p2, setsize * sizeof(set_mask)))
+
+
+void get_mach(void);
+int nbitsset(set_mask *set);
+
+int do_passwd(void);
+int do_groups(void);
+int do_filsys(void);
+int do_cluster(void);
+int do_printcap(void);
+int do_palladium(void);
+int do_sloc(void);
+int do_service(void);
 
 int main(int argc, char **argv)
 {
@@ -101,7 +134,7 @@ int main(int argc, char **argv)
 }
 
 
-get_mach(void)
+void get_mach(void)
 {
   EXEC SQL BEGIN DECLARE SECTION;
   int id;
@@ -123,7 +156,7 @@ get_mach(void)
       EXEC SQL FETCH m_cursor INTO :name, :id;
       if (sqlca.sqlcode)
        break;
-      hash_store(machines, id, strsave(strtrim(name)));
+      hash_store(machines, id, strdup(strtrim(name)));
     }
   if (sqlca.sqlcode < 0)
     db_error(sqlca.sqlcode);
@@ -326,7 +359,7 @@ int do_groups(void)
        break;
       strtrim(name);
       sprintf(buf, "%s:%d", name, gid);
-      hash_store(groups, lid, strsave(buf));
+      hash_store(groups, lid, strdup(buf));
       fprintf(iout, "%d.gid\t%s CNAME %s.group\n", gid, HCLASS, name);
       fprintf(gout, "%s.group\t%s %s \"%s:*:%d:\"\n",
              name, HCLASS, HTYPE, name, gid);
@@ -370,8 +403,7 @@ int do_groups(void)
       EXEC SQL FETCH i_cursor INTO :lid, :id;
       if (sqlca.sqlcode)
        break;
-      if ((l = hash_lookup(groups, lid)) &&
-         (u = (struct user *) hash_lookup(users, id)))
+      if ((l = hash_lookup(groups, lid)) && (u = hash_lookup(users, id)))
        {
          g = malloc(sizeof(struct grp));
          g->next = u->lists;
@@ -431,10 +463,9 @@ int do_filsys(void)
 {
   FILE *out;
   char outf[64], outft[64], *mach, *group;
-  char *p;
   struct stat sb;
   time_t ftime;
-  struct save_queue *sq, *sq2, *sq_create();
+  struct save_queue *sq, *sq2;
   EXEC SQL BEGIN DECLARE SECTION;
   char name[33], type[9], loc[81], access[2], mount[33], trans[257];
   char comments[65];
@@ -490,7 +521,7 @@ int do_filsys(void)
       strtrim(type);
       if (!strcmp(type, "NFS") || !strcmp(type, "RVD"))
        {
-         if (mach = hash_lookup(machines, id))
+         if ((mach = hash_lookup(machines, id)))
            {
              fprintf(out, "%s.filsys\t%s %s \"%s %s %s %s %s\"\n",
                      strtrim(name), HCLASS, HTYPE, type, strtrim(loc),
@@ -511,12 +542,12 @@ int do_filsys(void)
       else if (!strcmp(type, "FSGROUP"))
        {
          sprintf(trans, "%s:%d", strtrim(name), fid);
-         sq_save_data(sq, strsave(trans));
+         sq_save_data(sq, strdup(trans));
        }
       else if (!strcmp(type, "MUL"))
        {
          sprintf(trans, "%s:%d", strtrim(name), fid);
-         sq_save_data(sq2, strsave(trans));
+         sq_save_data(sq2, strdup(trans));
        }
     }
   EXEC SQL CLOSE f_cursor;
@@ -542,7 +573,7 @@ int do_filsys(void)
          strtrim(type);
          if (!strcmp(type, "NFS") || !strcmp(type, "RVD"))
            {
-             if (mach = hash_lookup(machines, id))
+             if ((mach = hash_lookup(machines, id)))
                {
                  fprintf(out, "%s.filsys\t%s %s \"%s %s %s %s %s %d\"\n",
                          group, HCLASS, HTYPE, type, strtrim(loc), mach,
@@ -619,26 +650,7 @@ sqlerr:
   return 0;
 }
 
-
-/*
- * Modified from sys/types.h:
- */
-int setsize;   /* = howmany(setbits, NSETBITS) */
-
-typedef long   set_mask;
-#define NSETBITS       (sizeof(set_mask) * NBBY)       /* bits per mask */
-#ifndef howmany
-#define        howmany(x, y)   (((x) + ((y) - 1)) / (y))
-#endif
-
-#define        SET_SET(n, p)   ((p)[(n)/NSETBITS] |=  (1 << ((n) % NSETBITS)))
-#define        SET_CLR(n, p)   ((p)[(n)/NSETBITS] &= ~(1 << ((n) % NSETBITS)))
-#define        SET_ISSET(n, p) ((p)[(n)/NSETBITS] &   (1 << ((n) % NSETBITS)))
-#define SET_CREATE()   (malloc(setsize * sizeof(set_mask)))
-#define SET_ZERO(p)    memset(p, 0, setsize * sizeof(set_mask))
-#define SET_CMP(p1, p2) (memcmp(p1, p2, setsize * sizeof(set_mask)))
-
-int nbitsset(set_mask *set)
+ int nbitsset(set_mask *set)
 {
   int i, ret;
   ret = 0;
@@ -891,10 +903,10 @@ int do_printcap(void)
       strtrim(rp);
       strtrim(sd);
       fprintf(out, "%s.pcap\t%s %s \"%s:rp=%s:rm=%s:sd=%s:ka#%d:pc#%d",
-             name, HCLASS, HTYPE, name, rp, hash_lookup(machines, rm),
+             name, HCLASS, HTYPE, name, rp, (char *)hash_lookup(machines, rm),
              sd, ka, pc);
       if (rq && hash_lookup(machines, rq))
-       fprintf(out, ":rq=%s\"\n", hash_lookup(machines, rq));
+       fprintf(out, ":rq=%s\"\n", (char *)hash_lookup(machines, rq));
       else
        fputs("\"\n", out);
     }
@@ -965,8 +977,8 @@ int do_palladium(void)
        break;
       strtrim(name);
       fprintf(out, "%s.palladium\t%s %s \"%s %d %s interface directory\"\n",
-             name, HCLASS, HTYPE, hash_lookup(machines, rm), identifier,
-             name);
+             name, HCLASS, HTYPE, (char *)hash_lookup(machines, rm),
+             identifier, name);
     }
   EXEC SQL CLOSE p_cursor3;
 
@@ -1049,7 +1061,7 @@ int do_sloc(void)
       if (sqlca.sqlcode)
        break;
       strtrim(service);
-      if (mach = hash_lookup(machines, id))
+      if ((mach = hash_lookup(machines, id)))
        fprintf(out, "%s.sloc\t%s %s %s\n", service, HCLASS, HTYPE, mach);
     }
   EXEC SQL CLOSE s_cursor;
index ecd35adc4cbbd8515e077e03d489e06a8f74a072..d3f66b903d534c24ae29a9e0ffab07c26b4618a9 100644 (file)
@@ -1,21 +1,31 @@
-/* $Header$
+/* $Id$
  *
  * This generates the hstath.txt hosttable.
  *
- *  (c) Copyright 1993 by the Massachusetts Institute of Technology.
- *  For copying and distribution information, please see the file
- *  <mit-copyright.h>.
+ * (c) Copyright 1993-1998 by the Massachusetts Institute of Technology.
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
  */
 
 #include <mit-copyright.h>
-#include <stdio.h>
 #include <moira.h>
-#include <sys/types.h>
+
 #include <sys/stat.h>
-#include <sys/time.h>
+
+#include <netinet/in.h>
+#include <arpa/inet.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <time.h>
+
+#include "util.h"
+
 EXEC SQL INCLUDE sqlca;
 
-extern int errno;
+RCSID("$Header$");
+
 char *whoami = "hosts.gen";
 char *db = "moira/moira";
 
@@ -94,14 +104,14 @@ int main(int argc, char **argv)
        }
       else
        name[i - 8] = 0;
-      if (p = hash_lookup(aliases, id))
+      if ((p = hash_lookup(aliases, id)))
        {
          sprintf(buf, "%s,%s", p, name);
-         hash_update(aliases, id, strsave(buf));
+         hash_update(aliases, id, strdup(buf));
          free(p);
        }
       else
-       hash_store(aliases, id, strsave(name));
+       hash_store(aliases, id, strdup(name));
     }
 
   EXEC SQL DECLARE x CURSOR FOR SELECT
index 79948146d283568fb3c7fc04f313c7132069232d..615f5a4db366402d1052666caea1de72063686b6 100644 (file)
@@ -1,30 +1,31 @@
-
-/* $Header$
+/* $Id$
  *
  * This generates the /usr/lib/aliases file for the mailhub.
  *
- *  (c) Copyright 1988, 1990 by the Massachusetts Institute of Technology.
- *  For copying and distribution information, please see the file
- *  <mit-copyright.h>.
+ * (c) Copyright 1988-1998 by the Massachusetts Institute of Technology.
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
  */
 
 #include <mit-copyright.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <ctype.h>
-#include <errno.h>
 #include <moira.h>
 #include <moira_site.h>
-#include <sys/types.h>
+
 #include <sys/stat.h>
-#include <sys/time.h>
+
+#include <ctype.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "util.h"
+
 EXEC SQL INCLUDE sqlca;
 
+RCSID("$Header$");
+
 char *whoami = "mailhub.gen";
 char *db = "moira/moira";
-char *perm_malloc();
-char *pstrsave();
 char *divide = "##############################################################";
 
 #define ML_WID 72
@@ -35,6 +36,47 @@ char *divide = "##############################################################";
 
 FILE *out = stdout;
 
+struct hash *users, *machines, *strings, *lists, *names;
+struct user {
+  char *login;
+  char *first;
+  char *last;
+  char mi;
+  char *pobox;
+};
+struct member {
+  struct member *next;
+  char *name;
+  int list_id;
+};
+struct list {
+  char *name;
+  char maillist;
+  char *description;
+  char acl_t;
+  int acl_id;
+  struct member *m;
+};
+struct names {
+  char *name;
+  struct names *next;
+  int keep;
+  int id;
+};
+
+void get_info(void);
+void save_mlist(int id, void *list, void *force);
+void insert_login(int id, void *user, void *hint);
+void insert_names(int id, void *user, void *hint);
+void insert_name(char *s, int id, int nodups, int copy);
+int hashstr(char *s);
+void sort_info(void);
+void output_data(int dummy, void *names, void *out);
+void output_mlist(int id, struct list *l);
+void do_member(FILE *out, char *s);
+void put_fill(FILE *aliases, char *string);
+void do_people(void);
+
 int main(int argc, char **argv)
 {
   long tm = time(NULL);
@@ -100,38 +142,7 @@ int main(int argc, char **argv)
   exit(MR_SUCCESS);
 }
 
-
-
-struct hash *users, *machines, *strings, *lists, *names;
-struct user {
-  char *login;
-  char *first;
-  char *last;
-  char mi;
-  char *pobox;
-};
-struct member {
-  struct member *next;
-  char *name;
-  int list_id;
-};
-struct list {
-  char *name;
-  char maillist;
-  char *description;
-  char acl_t;
-  int acl_id;
-  struct member *m;
-};
-struct names {
-  char *name;
-  struct names *next;
-  int keep;
-  int id;
-};
-
-
-get_info(void)
+void get_info(void)
 {
   EXEC SQL BEGIN DECLARE SECTION;
   int id, pid, bid, cnt, maillistp, acl, mid;
@@ -162,14 +173,14 @@ get_info(void)
       EXEC SQL FETCH m_cursor INTO :id, :name;
       if (sqlca.sqlcode)
        break;
-      if (s = strchr(name, '.'))
+      if ((s = strchr(name, '.')))
        *s = '\0';
       else
        strtrim(name);
 #ifdef ATHENA
       strcat(name, ".LOCAL");
 #endif
-      if (hash_store(machines, id, pstrsave(name)) < 0)
+      if (hash_store(machines, id, strdup(name)) < 0)
        {
          fprintf(stderr, "Out of memory!\n");
          exit(MR_NO_MEM);
@@ -193,7 +204,7 @@ get_info(void)
       EXEC SQL FETCH s_cursor INTO :id, :name;
       if (sqlca.sqlcode)
        break;
-      if (hash_store(strings, id, pstrsave(strtrim(name))) < 0)
+      if (hash_store(strings, id, strdup(strtrim(name))) < 0)
        {
          fprintf(stderr, "Out of memory!\n");
          exit(MR_NO_MEM);
@@ -219,10 +230,10 @@ get_info(void)
        :type, :pid, :bid;
       if (sqlca.sqlcode)
        break;
-      u = (struct user *) perm_malloc(sizeof(struct user));
-      u->login = pstrsave(strtrim(name));
-      u->first = pstrsave(strtrim(fname));
-      u->last  = pstrsave(strtrim(lname));
+      u = malloc(sizeof(struct user));
+      u->login = strdup(strtrim(name));
+      u->first = strdup(strtrim(fname));
+      u->last  = strdup(strtrim(lname));
       if (mname[0] != ' ')
        u->mi = mname[0];
       else
@@ -231,7 +242,7 @@ get_info(void)
       if (type[0] == 'P' && (s = hash_lookup(machines, pid)))
        {
          sprintf(buf, "%s@%s", u->login, s);
-         u->pobox = pstrsave(buf);
+         u->pobox = strdup(buf);
        }
       else if (type[0] ==  'S')
        u->pobox = hash_lookup(strings, bid);
@@ -261,10 +272,10 @@ get_info(void)
       EXEC SQL FETCH l_cursor INTO :id, :name, :maillistp, :buf, :type, :acl;
       if (sqlca.sqlcode)
        break;
-      l = (struct list *) perm_malloc(sizeof(struct list));
-      l->name = pstrsave(strtrim(name));
+      l = malloc(sizeof(struct list));
+      l->name = strdup(strtrim(name));
       l->maillist = maillistp;
-      l->description = pstrsave(strtrim(buf));
+      l->description = strdup(strtrim(buf));
       l->acl_t = type[0];
       l->acl_id = acl;
       l->m = NULL;
@@ -292,18 +303,17 @@ get_info(void)
       if (sqlca.sqlcode)
        break;
       cnt++;
-      if ((l = (struct list *) hash_lookup(lists, id)))
+      if ((l = hash_lookup(lists, id)))
        {
-         m = (struct member *) perm_malloc(sizeof(struct member));
-         if (type[0] == 'U' && (u = (struct user *) hash_lookup(users, mid)))
+         m = malloc(sizeof(struct member));
+         if (type[0] == 'U' && (u = hash_lookup(users, mid)))
            {
              m->list_id = 0;
              m->name = u->login;
              m->next = l->m;
              l->m = m;
            }
-         else if (type[0] == 'L' &&
-                  (memberlist = (struct list *) hash_lookup(lists, mid)))
+         else if (type[0] == 'L' && (memberlist = hash_lookup(lists, mid)))
            {
              m->list_id = mid;
              m->name = memberlist->name;
@@ -330,10 +340,10 @@ sqlerr:
 }
 
 
-save_mlist(int id, struct list *l, int force)
+void save_mlist(int id, void *list, void *force)
 {
   struct member *m;
-  struct list *l1;
+  struct list *l = list, *l1;
 
   if (l->maillist > 1 || (l->maillist == 0 && !force))
     return;
@@ -347,26 +357,28 @@ save_mlist(int id, struct list *l, int force)
   insert_name(l->name, -1, TRUE, FALSE);
   output_mlist(id, l);
 
-  if (l->acl_t == 'L' && (l1 = (struct list *)hash_lookup(lists, l->acl_id)))
-    save_mlist(0, l1, TRUE);
+  if (l->acl_t == 'L' && (l1 = hash_lookup(lists, l->acl_id)))
+    save_mlist(0, l1, (void *)TRUE);
 
   for (m = l->m; m; m = m->next)
     {
-      if (m->list_id && (l1 = (struct list *)hash_lookup(lists, m->list_id)))
-       save_mlist(0, l1, TRUE);
+      if (m->list_id && (l1 = hash_lookup(lists, m->list_id)))
+       save_mlist(0, l1, (void *)TRUE);
     }
 }
 
 
-insert_login(int id, struct user *u, int dummy)
+void insert_login(int id, void *user, void *hint)
 {
+  struct user *u = user;
   if (u->pobox && u->login[0] != '#')
     insert_name(u->login, id, TRUE, FALSE);
 }
 
-void insert_names(int id, struct user *u, int dummy)
+void insert_names(int id, void *user, void *hint)
 {
   char buffer[256];
+  struct user *u = user;
 
   insert_name(u->last, id, FALSE, FALSE);
   sprintf(buffer, "%s_%s", u->first, u->last);
@@ -384,23 +396,23 @@ void insert_names(int id, struct user *u, int dummy)
 
 int incount = 0;
 
-insert_name(char *s, int id, int nodups, int copy)
+void insert_name(char *s, int id, int nodups, int copy)
 {
   int code;
   struct names *ns;
 
   incount++;
   code = hashstr(s);
-  ns = (struct names *) hash_lookup(names, code);
+  ns = hash_lookup(names, code);
   if (!ns)
     {
-      if (!(ns = (struct names *) perm_malloc(sizeof(struct names))))
+      if (!(ns = malloc(sizeof(struct names))))
        {
          fprintf(stderr, "ran out of memory inserting name (sorting)\n");
          exit(MR_NO_MEM);
        }
       if (copy)
-       ns->name = pstrsave(s);
+       ns->name = strdup(s);
       else
        ns->name = s;
       ns->keep = nodups;
@@ -421,14 +433,14 @@ insert_name(char *s, int id, int nodups, int copy)
          if (!strcasecmp(ns->name, s))
            goto foundns;
        }
-      if (!(ns->next = (struct names *) perm_malloc(sizeof(struct names))))
+      if (!(ns->next = malloc(sizeof(struct names))))
        {
          fprintf(stderr, "ran out of memory insterting name (sorting)\n");
          exit(MR_NO_MEM);
        }
       ns = ns->next;
       if (copy)
-       ns->name = pstrsave(s);
+       ns->name = strdup(s);
       else
        ns->name = s;
       ns->keep = nodups;
@@ -476,7 +488,7 @@ int hashstr(char *s)
   int result;
   int c;
 
-  for (result = 0; c = *s; s++)
+  for (result = 0; (c = *s); s++)
     {
       if (illegalchars[c])
        {
@@ -493,7 +505,7 @@ int hashstr(char *s)
 }
 
 
-sort_info(void)
+void sort_info(void)
 {
   names = create_hash(20001);
   hash_step(users, insert_login, NULL);
@@ -508,9 +520,9 @@ sort_info(void)
 }
 
 
-output_data(int dummy, struct names *nms, FILE *out)
+void output_data(int dummy, void *names, void *out)
 {
-  struct names *ns;
+  struct names *ns, *nms = names;
   struct user *u;
 
   incount++;
@@ -523,7 +535,7 @@ output_data(int dummy, struct names *nms, FILE *out)
        }
       if (ns->id > 0)
        {
-         u = (struct user *) hash_lookup(users, ns->id);
+         u = hash_lookup(users, ns->id);
          if (u->pobox)
            fprintf(out, "%s: %s\n", ns->name, u->pobox);
 #ifdef NAME_ALIASES
@@ -541,17 +553,16 @@ output_data(int dummy, struct names *nms, FILE *out)
 
 int lwid, bol, awid;
 
-output_mlist(int id, struct list *l)
+void output_mlist(int id, struct list *l)
 {
   struct list *l1;
   struct member *m;
   struct user *u;
 
   put_fill(out, l->description);
-  if (l->acl_t ==  'L' && (l1 = (struct list *) hash_lookup(lists, l->acl_id)))
+  if (l->acl_t ==  'L' && (l1 = hash_lookup(lists, l->acl_id)))
     fprintf(out, "owner-%s: %s\n%s: ", l->name, l1->name, l->name);
-  else if (l->acl_t ==  'U' &&
-            (u = (struct user *) hash_lookup(users, l->acl_id)))
+  else if (l->acl_t ==  'U' && (u = hash_lookup(users, l->acl_id)))
     fprintf(out, "owner-%s: %s\n%s: ", l->name, u->login, l->name);
   else
     fprintf(out, "%s: ", l->name);
@@ -569,9 +580,9 @@ output_mlist(int id, struct list *l)
 
 /* print out strings separated by commas, doing line breaks as appropriate */
 
-do_member(FILE *out, char *s)
+void do_member(FILE *out, char *s)
 {
-  wwid;
+  int wwid;
   static int cont = 1;
   char str[8];
 
@@ -610,7 +621,7 @@ do_member(FILE *out, char *s)
 }
 
 
-put_fill(FILE *aliases, char *string)
+void put_fill(FILE *aliases, char *string)
 {
   char *c;
   int lwid;
@@ -662,182 +673,10 @@ put_fill(FILE *aliases, char *string)
 }
 
 
-do_people(void)
+void do_people(void)
 {
   incount = 0;
   fprintf(out, "\n%s\n# People\n%s\n", divide, divide);
   hash_step(names, output_data, out);
   fprintf(stderr, "Output %d entries\n", incount);
 }
-
-
-#define chunk_size     102400
-
-char *perm_malloc(unsigned size)
-{
-  static char *pool = NULL;
-  static unsigned pool_size = 0;
-  char *ret;
-
-  if (size > pool_size)
-    {
-      pool = malloc(chunk_size);
-      pool_size = chunk_size;
-    }
-  ret = pool;
-  pool += size;
-  pool = (char *)(((unsigned) (pool + 3)) & ~3);
-  pool_size -= (pool - ret);
-  return ret;
-}
-
-
-/*
- * Make a (permenant) copy of a string.
- */
-char *pstrsave(char *s)
-{
-  int len;
-  char *p;
-  /* Kludge for sloppy string semantics */
-  if (!s)
-    {
-      printf("NULL != \"\" !!!!\r\n");
-      p = perm_malloc(1);
-      *p = '\0';
-      return p;
-    }
-  len = strlen(s) + 1;
-  p = perm_malloc((u_int)len);
-  if (p)
-    memcpy(p, s, len);
-  return p;
-}
-
-#define hash_func(h, key) (key >= 0 ? (key % h->size) : (-key % h->size))
-
-/* Create a hash table.  The size is just a hint, not a maximum. */
-
-struct hash *create_hash(int size)
-{
-  struct hash *h;
-
-  h = (struct hash *) perm_malloc(sizeof(struct hash));
-  if (!h)
-    return NULL;
-  h->size = size;
-  h->data = (struct bucket **) perm_malloc(size * sizeof(char *));
-  if (!h->data)
-    return NULL;
-  memset(h->data, 0, size * sizeof(char *));
-  return h;
-}
-
-/* Lookup an object in the hash table.  Returns the value associated with
- * the key, or NULL (thus NULL is not a very good value to store...)
- */
-
-char *hash_lookup(struct hash *h, int key)
-{
-  struct bucket *b;
-
-  b = h->data[hash_func(h, key)];
-  while (b && b->key != key)
-    b = b->next;
-  if (b && b->key == key)
-    return b->data;
-  else
-    return NULL;
-}
-
-
-/* Update an existing object in the hash table.  Returns 1 if the object
- * existed, or 0 if not.
- */
-
-int hash_update(struct hash *h, int key, char *value)
-{
-  struct bucket *b;
-
-  b = h->data[hash_func(h, key)];
-  while (b && b->key != key)
-    b = b->next;
-  if (b && b->key == key)
-    {
-      b->data = value;
-      return 1;
-    }
-  else
-    return 0;
-}
-
-
-/* Store an item in the hash table.  Returns 0 if the key was not previously
- * there, 1 if it was, or -1 if we ran out of memory.
- */
-
-int hash_store(struct hash *h, int key, char *value)
-{
-  struct bucket *b, **p;
-
-  p = &(h->data[hash_func(h, key)]);
-  if (!*p)
-    {
-      b = *p = (struct bucket *) perm_malloc(sizeof(struct bucket));
-      if (!b)
-       return -1;
-      b->next = NULL;
-      b->key = key;
-      b->data = value;
-      return 0;
-    }
-
-  for (b = *p; b && b->key != key; b = *p)
-    p = (struct bucket **) *p;
-  if (b && b->key == key)
-    {
-      b->data = value;
-      return 1;
-    }
-  b = *p = (struct bucket *) perm_malloc(sizeof(struct bucket));
-  if (!b)
-    return -1;
-  b->next = NULL;
-  b->key = key;
-  b->data = value;
-  return 0;
-}
-
-
-/* Search through the hash table for a given value.  For each piece of
- * data with that value, call the callback proc with the corresponding key.
- */
-
-hash_search(struct hash *h, char *value, void (*callback)())
-{
-  struct bucket *b, **p;
-
-  for (p = &(h->data[h->size - 1]); p >= h->data; p--)
-    {
-      for (b = *p; b; b = b->next)
-       {
-         if (b->data == value)
-           (*callback)(b->key);
-       }
-    }
-}
-
-
-/* Step through the hash table, calling the callback proc with each key.
- */
-
-hash_step(struct hash *h, void (*callback)(), char *hint)
-{
-  struct bucket *b, **p;
-
-  for (p = &(h->data[h->size - 1]); p >= h->data; p--)
-    {
-      for (b = *p; b; b = b->next)
-       (*callback)(b->key, b->data, hint);
-    }
-}
index d04bd09492b36b138e915a82f012d28070334efe..44d0ce640381b876b95139d262eb1a8e0c33a6e3 100644 (file)
@@ -1,26 +1,24 @@
-/* $Header$
+/* $Id$
  *
- *  (c) Copyright 1990 by the Massachusetts Institute of Technology.
- *  For copying and distribution information, please see the file
- *  <mit-copyright.h>.
+ * Copyright (C) 1990-1998 by the Massachusetts Institute of Technology.
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
  */
 
 #include <mit-copyright.h>
+#include <moira.h>
+
+#include <sys/types.h>
+
 #include <stdio.h>
 #include <stdlib.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <sys/time.h>
-#include <moira.h>
-#include <moira_site.h>
-EXEC SQL INCLUDE sqlca;
 
-static char *MONTHNAMES[] = {"january", "february", "march", "april", "may",
-                            "june", "july", "august", "september",
-                            "october", "november", "december"};
+#include "util.h"
 
-static int MONTHDAYS[] = {0,0,31,59,90,120,151,181,212,243,273,304,334};
+EXEC SQL INCLUDE sqlca;
 
+/* Julian day of the UNIX epoch (January 1, 1970) */
+#define UNIX_EPOCH 2440588
 
 /****************************************************************/
 /**  Return the difference between the modtime & table modtime **/
@@ -31,205 +29,26 @@ int ModDiff(int *flag, char *tbl, time_t ModTime)
 {
   time_t filetimeno;
   EXEC SQL BEGIN DECLARE SECTION;
-  char filetime[48], *tbl_name;
+  char filetime[48], *ft = filetime, *tbl_name;
   EXEC SQL END DECLARE SECTION;
 
   *flag = 0;
   tbl_name = tbl;
-  EXEC SQL SELECT TO_CHAR(modtime, 'DD-mon-YYYY HH24:MI:SS')
+  /* Get modtime as seconds, minutes, hours, and Julian day */
+  EXEC SQL SELECT TO_CHAR(modtime, 'SS MI HH24 J')
     INTO :filetime FROM tblstats
     WHERE table_name = :tbl_name;
   if (sqlca.sqlcode)
     {
-      fprintf(stderr, "Moddiff Query failed: %d\n", sqlca.sqlcode);
+      fprintf(stderr, "Moddiff Query failed: %ld\n", sqlca.sqlcode);
       return MR_DATE;
     }
-  if (Date2Sec (filetime, &filetimeno))
-    {
-      fprintf(stderr, "Unable to parse mod. date for file %s\n", tbl);
-      return MR_DATE;
-    }
-  *flag = (int) (filetimeno - ModTime);
-  return 0;
-}
-
-
-/***************************************************/
-/**  convert Unix-time (# of seconds since 1970)  **/
-/**  from a date-time string                      **/
-/**  Return 1 if failure, 0 if success            **/
-/***************************************************/
-
-int Date2Sec(char *DS, time_t *UTime)
-{
-  static int defzone = -1;
-  int Day, Month, Year, Hour, Minute, Sec, Err, TotalDays, Iter;
-  struct timeval tv;
-  struct timezone tz;
-
-  if (defzone == -1)
-    {
-      if (gettimeofday(&tv, &tz))
-       defzone = 0;
-      else
-       defzone = tz.tz_minuteswest;
-    }
-
-  Err = ParseDateString (DS, &Day, &Month, &Year, &Hour, &Minute, &Sec);
-  if (Err)
-    return Err;
-
-  if (Year < 1970)
-    {
-      for (TotalDays = 0, Iter = 1969; Iter > Year; Iter--)
-       TotalDays += NumdaysY(Iter);
-      TotalDays += (NumdaysY(Year) - NumdaysM(Month, Year) - Day);
-      *UTime = -((((24 * TotalDays) + 24 - Hour) * 60 - Minute) * 60 -
-                Sec) + defzone;
-      return 0;
-    }
-  else
-    {
-      for (TotalDays = 0, Iter = 1970; Iter < Year; Iter++)
-       TotalDays += NumdaysY(Iter);
-      TotalDays += NumdaysM(Month, Year);
-      TotalDays += (Day - 1);
-      *UTime = (((24 * TotalDays) + Hour) * 60 + Minute) * 60 +
-       Sec + defzone;
-      return 0;
-    }
-}
-
-
-/*****************************************/
-/**  Return the # of days in the Year   **/
-/*****************************************/
-
-int NumdaysY(int Year)
-{
-  return 365 + Leapyear(Year);
-}
-
-
-/*****************************************/
-/**  Return the # of days in the Month  **/
-/*****************************************/
-
-int NumdaysM(int Month, int Year)
-{
-  if ((Month > 2) && (Leapyear (Year)))
-    return MONTHDAYS[Month] + 1;
-  else
-    return MONTHDAYS[Month];
-}
-
-
-/*****************************************/
-/**  Return 1 if a leapyear, else 0     **/
-/*****************************************/
-
-int Leapyear(int Year)
-{
-  if ((Year % 4) && (!(Year % 100) || (Year % 1000)))
-    return 0;
-  else
-    return 1;
-}
-
-
-/************************************************/
-/**  Compute numeric breakdown of date string  **/
-/**  Return 0 if success, 1 if failure         **/
-/************************************************/
-
-int ParseDateString(char *DS, int *Day, int *Month, int *Year, int *Hour,
-                   int *Minute, int *Sec)
-{
-  int Gotten;
-  char *M, *D, *Temp;
-  int Y = 0, H = 0, Min = 0, S = 0, DayNum = 0, MonthNum = 0;
-
-  M = malloc(strlen(DS) + 2);
-  D = malloc(strlen(DS) + 2);
-  if (!(M && D))
-    return 1;
-  Gotten = sscanf (DS, "%[^-]-%[^-]-%d %d:%d:%d", D, M, &Y, &H, &Min, &S);
-  if (Gotten < 3)
-    Gotten = sscanf (DS, "%[^/]/%[^/]/%d %d:%d:%d", D, M, &Y, &H, &Min, &S);
-  if (Gotten < 3)
-    Gotten = sscanf (DS, "%s %[^,], %d %d:%d:%d", M, D, &Y, &H, &Min, &S);
-  if ((Gotten < 3) || !(D && M && Y))
-    {
-      free(M);
-      free(D);
-      return 1;               /* Couldn't scan in a date */
-    }
-  if (atoi(M))
-    {               /* Month not text, so M/D/Y not D/M/Y */
-      Temp = M;
-      M = D;
-      D = Temp;
-    }
-  DayNum = atoi(D);
-  MonthNum = MonthNo(M);
-  free(M);
-  free(D);
-  if ((DayNum < 1) || (DayNum > 31))
-    return 1;                /* Bad Day */
-  if (!MonthNum)
-    return 1;                /* Bad Month */
-  if ((Y < 1) || (Y > 10000))
-    return 1;                /* Bad Year */
-  if (Gotten == 4)
-    return 1;                 /* Bad Time (Hour only) */
-  if ((Gotten > 4) && (H < 0) || (H > 24))
-    return 1;                 /* Bad Hour */
-  if ((Gotten > 4) && ((Min < 0) || (Min > 59)))
-    return 1;                 /* Bad Minute */
-  if ((Gotten > 5) && ((S < 0) || (S > 59)))
-    return 1;                 /* Bad Second */
-  *Day = DayNum;
-  *Month = MonthNum;
-  if (Y < 100)                   /* For abreviations like 90 for 1990    */
-    Y += 1900;                   /* (Yes, it will be wrong in 2000) */
-  *Year = Y;
-  if (Gotten > 4)
-    {
-      *Hour = H;
-      *Minute = Min;
-    }
-  else
-    {
-      *Hour = 0;
-      *Minute = 0;
-    }
-  if (Gotten > 5)
-    *Sec = S;
-  else
-    *Sec = 0;
-  return 0;
-}
-
 
-/***********************************************************/
-/**  Return the Month number of a Month number or string  **/
-/***********************************************************/
+  filetimeno = strtol(ft, &ft, 10);
+  filetimeno = filetimeno * 60 + strtol(ft, &ft, 10);
+  filetimeno = filetimeno * 60 + strtol(ft, &ft, 10);
+  filetimeno = filetimeno * 24 + (strtol(ft, NULL, 10) - UNIX_EPOCH);
 
-int MonthNo(char *M)
-{
-  int Count;
-  if (atoi(M))
-    {
-      if ((atoi(M) > 0) && (atoi(M) < 13))
-       return atoi(M);
-      else
-       return 0;
-    }
-  for (Count = 0; Count < 12; Count++)
-    {
-      if (!strcasecmp (M, MONTHNAMES[Count])
-         || !strncasecmp(M, MONTHNAMES[Count], 3))
-       return Count + 1;
-    }
+  *flag = (int) (filetimeno - ModTime);
   return 0;
 }
index b7bbddbc933650086d379caec4706776b6bb96b1..e1ffc8d55dfb15cb7d2aab7dfbad9d475b029cbe 100644 (file)
@@ -1,21 +1,26 @@
-/* $Header$
+/* $Id$
  *
  * This generates the msql database for the network tables.
  *
- *  (c) Copyright 1988, 1990 by the Massachusetts Institute of Technology.
- *  For copying and distribution information, please see the file
- *  <mit-copyright.h>.
+ * Copyright 1998 by the Massachusetts Institute of Technology.
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
  */
 
 #include <mit-copyright.h>
-#include <stdio.h>
 #include <moira.h>
-#include <sys/types.h>
+
 #include <sys/stat.h>
-#include <sys/time.h>
+
+#include <stdio.h>
+#include <time.h>
+
+#include "util.h"
+
 EXEC SQL INCLUDE sqlca;
 
-extern int errno;
+RCSID("$Header$");
+
 char *whoami = "ndb.gen";
 char *db = "moira/moira";
 
index 3bbc8bbb666c2c0c27e8813e1434ecdd975a0617..1c347b2c985f70f9df112f23f8698c9f1f344804 100644 (file)
@@ -1,34 +1,40 @@
-/* $Header$
+/* $Id$
  *
  * This generates the network table.
  *
- *  (c) Copyright 1994 by the Massachusetts Institute of Technology.
- *  For copying and distribution information, please see the file
- *  <mit-copyright.h>.
+ * Copyright (C) 1994-1998 by the Massachusetts Institute of Technology.
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
  */
 
 #include <mit-copyright.h>
-#include <errno.h>
-#include <stdio.h>
 #include <moira.h>
-#include <sys/types.h>
+
 #include <sys/stat.h>
-#include <sys/time.h>
+
 #include <netinet/in.h>
+#include <arpa/inet.h>
+
+#include <stdio.h>
+#include <time.h>
+
+#include "util.h"
 
 EXEC SQL INCLUDE sqlca;
 
+RCSID("$Header$");
+
 char *whoami = "network.gen";
 char *db = "moira/moira";
 
 int main(int argc, char **argv)
 {
   FILE *out = stdout;
-  char *outf = NULL, outft[64], *p, buf[256];
+  char *outf = NULL, outft[64];
   struct stat sb;
   struct timeval now;
   struct in_addr addr;
-  int flag1, i;
+  int flag1;
   EXEC SQL BEGIN DECLARE SECTION;
   int id, saddr;
   char name[65], description[65];
index b76cdb8375dab0be2eeef2caf7522cf16329d7b7..762534a642219ae9db884d55bc49dc99f39007b5 100644 (file)
@@ -1,32 +1,41 @@
-/* $Header$
+/* $Id$
  *
  * This generates the files necessary to load an nfs server.
  *
- *  (c) Copyright 1988, 1990 by the Massachusetts Institute of Technology.
- *  For copying and distribution information, please see the file
- *  <mit-copyright.h>.
+ * Copyright (C) 1988-1998 by the Massachusetts Institute of Technology.
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
  */
 
 #include <mit-copyright.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
 #include <moira.h>
 #include <moira_site.h>
-#include <sys/types.h>
+
 #include <sys/stat.h>
-#include <sys/time.h>
+#include <sys/types.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+#include "util.h"
+
 EXEC SQL INCLUDE sqlca;
 
+RCSID("$Header$");
 
 #define min(x, y)      ((x) < (y) ? (x) : (y))
 
 char *whoami = "nfs.gen";
 char *db = "moira/moira";
-char *strsave();
 char nfs_dir[64];
 struct hash *users, *groups;
 
+int do_nfs(void);
+int do_lists(struct save_queue *lists);
+void do_everyone(void);
+int do_machs(struct save_queue *machs);
 
 int main(int argc, char **argv)
 {
@@ -97,8 +106,8 @@ int do_nfs(void)
       EXEC SQL FETCH s_cursor INTO :machname, :listname;
       if (sqlca.sqlcode)
        break;
-      sq_save_unique_string(machs, strsave(strtrim(machname)));
-      sq_save_unique_string(lists, strsave(strtrim(listname)));
+      sq_save_unique_string(machs, strdup(strtrim(machname)));
+      sq_save_unique_string(lists, strdup(strtrim(listname)));
     }
   EXEC SQL CLOSE s_cursor;
 
@@ -119,11 +128,10 @@ sqlerr:
 int do_lists(struct save_queue *lists)
 {
   char file[64], *u;
-  struct stat sb;
   FILE *fd;
   EXEC SQL BEGIN DECLARE SECTION;
-  char *listname, *lsname, lname[33], uname[9];
-  int uid, id, flag1, flag2, flag3, flag4;
+  char *listname;
+  int id;
   EXEC SQL END DECLARE SECTION;
 
   sprintf(file, "%s/list-", nfs_dir);
@@ -207,7 +215,7 @@ struct user {
 };
 
 
-do_everyone(void)
+void do_everyone(void)
 {
   char buf[BUFSIZ], *l;
   struct user *u;
@@ -215,11 +223,9 @@ do_everyone(void)
   struct bucket *b, **p;
   EXEC SQL BEGIN DECLARE SECTION;
   char name[33];
-  int gid, id, lid, maxid, uid;
+  int gid, id, lid, uid;
   EXEC SQL END DECLARE SECTION;
   FILE *fd;
-  int i;
-  struct save_queue *sq;
 
   fprintf(stderr, "Building the list of everybody\n");
   sprintf(buf, "%s/list-", nfs_dir);
@@ -246,7 +252,7 @@ do_everyone(void)
       if (sqlca.sqlcode)
        break;
       sprintf(buf, ":%d", gid);
-      hash_store(groups, lid, strsave(buf));
+      hash_store(groups, lid, strdup(buf));
     }
   EXEC SQL CLOSE l_cursor;
 
@@ -282,8 +288,7 @@ do_everyone(void)
       EXEC SQL FETCH m_cursor2 INTO :lid, :id;
       if (sqlca.sqlcode)
        break;
-      if ((u = (struct user *) hash_lookup(users, id)) &&
-         (l = hash_lookup(groups, lid)))
+      if ((u = hash_lookup(users, id)) && (l = hash_lookup(groups, lid)))
        {
          g = malloc(sizeof(struct grp));
          g->next = u->lists;
@@ -301,13 +306,12 @@ do_everyone(void)
          sprintf(buf, "%s:%d", u->name, u->uid);
          for (g = u->lists; g; g = g->next)
            strcat(buf, g->lid);
-         b->data = strsave(buf);
+         b->data = strdup(buf);
          fprintf(fd, "%s\n", buf);
        }
     }
 
   fclose(fd);
-  return 1;
 sqlerr:
   db_error(sqlca.sqlcode);
   exit(MR_DBMS_ERR);
@@ -322,7 +326,7 @@ int do_machs(struct save_queue *machs)
 {
   EXEC SQL BEGIN DECLARE SECTION;
   char *machname, listname[33], dev[33], dir[81], fstype[9];
-  int uid, quota, id, gid, flag1, flag2, flag3, flag4;
+  int uid, quota, id, gid, flag1, flag2, flag3;
   EXEC SQL END DECLARE SECTION;
   char file[64], f1[64], f2[64], *cp;
   int prevuid, quotasum, olddev, oldmach;
@@ -376,10 +380,10 @@ int do_machs(struct save_queue *machs)
            fclose(fd);
          olddev = flag1;
          oldmach = flag2;
-         while (cp = strchr(dev, '/'))
+         while ((cp = strchr(dev, '/')))
            *cp = '@';
          sprintf(file, "%s/%s.%s.quotas", nfs_dir,
-                 hash_lookup(machines, flag2), strtrim(dev));
+                 (char *)hash_lookup(machines, flag2), strtrim(dev));
          fd = fopen(file, "w");
          if (!fd)
            {
@@ -440,10 +444,10 @@ int do_machs(struct save_queue *machs)
            fclose(fd);
          olddev = flag1;
          oldmach = flag2;
-         while (cp = strchr(dev, '/'))
+         while ((cp = strchr(dev, '/')))
            *cp = '@';
          sprintf(file, "%s/%s.%s.quotas", nfs_dir,
-                 hash_lookup(machines, flag2), strtrim(dev));
+                 (char *)hash_lookup(machines, flag2), strtrim(dev));
          fd = fopen(file, "w");
          if (!fd)
            {
@@ -455,7 +459,7 @@ int do_machs(struct save_queue *machs)
        }
       if (gid != prevuid)
        {
-         if (cp = hash_lookup(groups, prevuid))
+         if ((cp = hash_lookup(groups, prevuid)))
            prevuid = atoi(cp + 1);
          if (quotasum)
            fprintf(fd, "%d %d\n", prevuid, quotasum);
@@ -501,10 +505,10 @@ int do_machs(struct save_queue *machs)
            fclose(fd);
          olddev = flag1;
          oldmach = flag2;
-         while (cp = strchr(dev, '/'))
+         while ((cp = strchr(dev, '/')))
            *cp = '@';
          sprintf(file, "%s/%s.%s.dirs", nfs_dir,
-                 hash_lookup(machines, flag2), strtrim(dev));
+                 (char *)hash_lookup(machines, flag2), strtrim(dev));
          fd = fopen(file, "w");
          if (!fd)
            {
index 618a00ca6867785433cb11d9f98a2d516403d19c..1070526b9abd60f64cef2f2d5241a550eaf96a08 100644 (file)
@@ -1,22 +1,27 @@
-/* $Header$
+/* $Id$
  *
  * This generates a master /etc/passwd containing all active (status != 0)
  * accounts.
  *
- *  (c) Copyright 1988, 1990 by the Massachusetts Institute of Technology.
- *  For copying and distribution information, please see the file
- *  <mit-copyright.h>.
+ * Copyright (C) 1988-1998 by the Massachusetts Institute of Technology.
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
  */
 
 #include <mit-copyright.h>
-#include <errno.h>
-#include <stdio.h>
 #include <moira.h>
-#include <sys/types.h>
+
 #include <sys/stat.h>
-#include <sys/time.h>
+#include <sys/types.h>
+
+#include <stdio.h>
+
+#include "util.h"
+
 EXEC SQL INCLUDE sqlca;
 
+RCSID("$Header$");
+
 char *whoami = "passwd.gen";
 char *db = "moira/moira";
 
index c164080c7e2c7b984c0d134fc6f0ff2b264aa046..6e066f6a85ecbbec4121858297392ff800ccee69 100644 (file)
@@ -1,22 +1,28 @@
-/* $Header$
+/* $Id $
  *
  * This generates a list of everyone's poboxes for the mitdir.
  *
- *  (c) Copyright 1992 by the Massachusetts Institute of Technology.
- *  For copying and distribution information, please see the file
- *  <mit-copyright.h>.
+ * Copyright (C) 1992-1998 by the Massachusetts Institute of Technology.
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
  */
 
 #include <mit-copyright.h>
-#include <errno.h>
-#include <stdio.h>
 #include <moira.h>
-#include <sys/types.h>
+
 #include <sys/stat.h>
-#include <sys/time.h>
+#include <sys/types.h>
+
 #include <ctype.h>
+#include <stdio.h>
+#include <string.h>
+
+#include "util.h"
+
 EXEC SQL INCLUDE sqlca;
 
+RCSID("$Header$");
+
 char *whoami = "pobox.gen";
 char *db = "moira/moira";
 
index 320ccef6361bb9d4791bf1963dac8638b1463a4c..9e8f2a91e0d496e0a9b2d133d21e17298f020f0a 100644 (file)
@@ -1,22 +1,26 @@
-/* $Header$
+/* $Id$
  *
  * Utility routines used by the MOIRA extraction programs.
  *
- *  (c) Copyright 1988 by the Massachusetts Institute of Technology.
- *  For copying and distribution information, please see the file
- *  <mit-copyright.h>.
+ * Copyright (C) 1988-1998 by the Massachusetts Institute of Technology.
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
  */
 
-
 #include <mit-copyright.h>
-#include <stdio.h>
-#include <sys/time.h>
 #include <moira.h>
 #include <moira_site.h>
 
+#include <stdio.h>
+#include <unistd.h>
+
+#include "util.h"
+
+RCSID("$Header$");
+
 extern void sqlglm(char buf[], int *, int *);
 
-fix_file(char *targetfile)
+void fix_file(char *targetfile)
 {
   char oldfile[64], filename[64];
 
@@ -65,7 +69,7 @@ char *dequote(char *s)
 }
 
 
-db_error(int code)
+void db_error(int code)
 {
   extern char *whoami;
   char buf[256];
diff --git a/gen/util.h b/gen/util.h
new file mode 100644 (file)
index 0000000..3b4c3bc
--- /dev/null
@@ -0,0 +1,5 @@
+void fix_file(char *targetfile);
+char *dequote(char *s);
+void db_error(int code);
+
+int ModDiff(int *flag, char *tbl, time_t ModTime);
index cccb6b8e0fe6330d2bc2b9989d4173c0795b552c..3e18bdb0affc3a7307cb74e1645018789f8d8d13 100644 (file)
@@ -1,31 +1,36 @@
-/* $Header$
+/* $Id$
  *
  * This generates a database extract from the users table for the MIT
  * Warehouse.
  *
- *  (c) Copyright 1992 by the Massachusetts Institute of Technology.
- *  For copying and distribution information, please see the file
- *  <mit-copyright.h>.
+ * Copyright (C) 1996-1998 by the Massachusetts Institute of Technology.
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
  */
 
 #include <mit-copyright.h>
-#include <errno.h>
-#include <stdio.h>
 #include <moira.h>
 #include <moira_site.h>
-#include <des.h>
-#include <krb.h>
-#include <gdss.h>
-#include <sys/types.h>
+
 #include <sys/stat.h>
-#include <sys/time.h>
-#include <sys/file.h>
-#include <string.h>
-#include <ctype.h>
+#include <sys/types.h>
+
 #include <fcntl.h>
+#include <ctype.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
 #include <unistd.h>
+
+#include <krb.h>
+#include <gdss.h>
+
+#include "util.h"
+
 EXEC SQL INCLUDE sqlca;
 
+RCSID("$Header$");
+
 char *whoami = "warehouse.gen";
 char *db = "moira/moira";
 
@@ -44,7 +49,6 @@ int main(int argc, char **argv)
   struct stat sb;
   int flag1;
   SigInfo si;
-  struct timeval now;
   int records = 0;
   EXEC SQL BEGIN DECLARE SECTION;
   char login[9], sig[257], id[17], kname[257];
index 9bd76aa21e8633c10a68804cb3b592107d916fd7..60a612c2696f3ab5fa14a9e4ef3687805cac6aab 100644 (file)
@@ -20,6 +20,8 @@
 #include <sys/types.h>
 #include <sys/time.h>
 
+#include <stdio.h>
+
 #ifndef TRUE
 #define TRUE 1
 #endif
index b8b3fb5c7054314c6da554e134292da706ca519a..aae80bfca923ae9a3a64040e5b0b6ccf6956321e 100644 (file)
@@ -1,7 +1,6 @@
-/* $Header$ */
-/*
+/* $Id$
 
-Copyright 1987, 1988 by the Massachusetts Institute of Technology
+Copyright (C) 1987-1998 by the Massachusetts Institute of Technology
 
 Permission to use, copy, modify, and distribute this
 software and its documentation for any purpose and without
index c88f914a4146dd9b6c4a09d92c3b7533d3ad56c5..0f6b5266c937aaf3583bef8f9173d6e1a2d40f19 100644 (file)
@@ -1,9 +1,6 @@
-/*
- *     $Source$
- *     $Author$
- *     $Header$
+/* $Id$
  *
- *     Copyright (C) 1987 by the Massachusetts Institute of Technology
+ * Copyright (C) 1987-1998 by the Massachusetts Institute of Technology
  *
  */
 
@@ -12,7 +9,11 @@
 
 /* return values from queries (and error codes) */
 
+#include <com_err.h>
 #include "mr_et.h"
+#include "krb_et.h"
+#include "gdss_et.h"
+#include "ureg_err.h"
 #define MR_SUCCESS 0           /* Query was successful */
 
 #define MR_VERSION_1 1         /* Version in use from 7/87 to 4/88 */
 /* Structure used by Save Queue routines (for temporary storage of data) */
 struct save_queue
 {
-    struct save_queue *q_next;
-    struct save_queue *q_prev;
-    struct save_queue *q_lastget;
-    char *q_data;
+  struct save_queue *q_next;
+  struct save_queue *q_prev;
+  struct save_queue *q_lastget;
+  void *q_data;
 };
 
 /* Hash table declarations */
 struct bucket {
-    struct bucket *next;
-    int        key;
-    char *data;
+  struct bucket *next;
+  int key;
+  void *data;
 };
 struct hash {
-    int        size;
-    struct bucket **data;
+  int size;
+  struct bucket **data;
 };
 
-#ifdef __STDC__
+/* prototypes from critical.c */
+void critical_alert(char *instance, char *msg, ...);
+void send_zgram(char *inst, char *msg);
+
+/* prototypes from fixhost.c */
+char *canonicalize_hostname(char *s);
+
+/* prototypes from fixname.c */
+void FixName(char *ilnm, char *ifnm, char *last, char *first, char *middle);
+void FixCase(char *p);
+void LookForJrAndIII(char *nm, int *pends_jr, int *pends_sr,
+                    int *pends_ii, int *pends_iii,
+                    int *pends_iv, int *pends_v);
+void LookForSt(char *nm);
+void LookForO(char *nm);
+void TrimTrailingSpace(char *ip);
+void GetMidInit(char *nm, char *mi);
+
+/* prototypes from gdss_convert.c */
+int gdss2et(int code);
+
+/* prototypes from hash.c */
+struct hash *create_hash(int size);
+void *hash_lookup(struct hash *h, int key);
+int hash_update(struct hash *h, int key, void *value);
+int hash_store(struct hash *h, int key, void *value);
+void hash_search(struct hash *h, void *value, void (*callback)(int));
+void hash_step(struct hash *h, void (*callback)(int, void *, void *),
+              void *hint);
+void hash_destroy(struct hash *h);
+
+/* prototypes from idno.c */
+void RemoveHyphens(char *str);
+void EncryptID(char *sbuf, char *idnumber, char *first, char *last);
+
+/* prototypes from kname_unparse.c */
+char *kname_unparse(char *p, char *i, char *r);
+
+/* prototypes from nfsparttype.c */
+char *parse_filesys_type(char *fs_type_name);
+char *format_filesys_type(char *fs_status);
+
+/* prototypes from sq.c */
+struct save_queue *sq_create(void);
+int sq_save_data(struct save_queue *sq, void *data);
+int sq_save_args(int argc, char *argv[], struct save_queue *sq);
+int sq_save_unique_data(struct save_queue *sq, void *data);
+int sq_save_unique_string(struct save_queue *sq, char *data);
+/* in sq_get_data and sq_remove_data, the `data' arg should be a
+   pointer to a pointer */
+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);
+
+/* prototypes from strs.c */
+char *strtrim(char *s);
+char *uppercase(char *s);
+char *lowercase(char *s);
+
+/* mr_ functions */
+int mr_access(char *handle, int argc, char **argv);
+int mr_auth(char *prog);
 int mr_connect(char *server);
-int mr_disconnect();
+int mr_disconnect(void);
+int mr_do_update(void);
 int mr_host(char *host, int size);
 int mr_motd(char **motd);
-int mr_auth(char *prog);
-int mr_access(char *handle, int argc, char **argv);
-int mr_access_internal(int argc, char **argv);
+int mr_noop(void);
 int mr_query(char *handle, int argc, char **argv,
-             int (*callback)(), char *callarg);
-int mr_query_internal(int argc, char **argv,
-                      int (*callback)(), char *callarg);
-int mr_noop();
-struct save_queue *sq_create();
-struct hash *create_hash(int size);
-char *hash_lookup(struct hash *h, int key);
-char *strsave(char *s);
-char *strtrim(char *s);
-char *canonicalize_hostname(char *s);
-#else /* !__STDC__ */
-int mr_connect();
-int mr_disconnect();
-int mr_host();
-int mr_motd();
-int mr_auth();
-int mr_access();
-int mr_query();
-int mr_noop();
-struct save_queue *sq_create();
-struct hash *create_hash();
-char *hash_lookup();
-char *strsave();
-char *strtrim();
-char *canonicalize_hostname();
-#endif  /* __STDC__ */
+            int (*callback)(int, char **, void *), void *callarg);
 
 /* error-name backward compatibility */
 #define MR_INGRES_ERR          MR_DBMS_ERR
 #define MR_INGRES_SOFTFAIL     MR_DBMS_SOFTFAIL
 
+
+#ifndef __GNUC__
+#define __attribute__(x)
+#endif
+
+#define RCSID(id) static char *rcsid __attribute__ ((__unused__)) = id
+
 #endif /* _moira_h_ */         /* Do Not Add Anything after this line. */
index a6c13e05e53965dd45ab248e106dd157f3739d5d..767593d166c5cb5411ff96dc3ae29dae21b49f86 100644 (file)
@@ -1,4 +1,5 @@
-/*
+/* $Id$
+ *
  * This file contains all definitions that allow easy access to
  * elements returned by most of the @i[Moira] queries.  It also defines
  * the default server location and the directories used on the server.
  *                                 Chris D. Peterson - kit@athena
  *                                   7/27/88
  *
- *      $Source$
- *      $Author$
- *      $Header$
- *
- *     Copyright 1988 by the Massachusetts Institute of Technology.
- *
- *     For further information on copyright and distribution
- *     see the file mit-copyright.h
+ * Copyright (C) 1988-1998 by the Massachusetts Institute of Technology.
+ * For further information on copyright and distribution
+ * see the file <mit-copyright.h>.
  */
 
 #ifndef _moira_site_
index f4176befcec6a0721d2c1dade744ab427c4fd1df..565c385d5649c3a39b125fc6c6131305dffc69b7 100644 (file)
@@ -1,9 +1,6 @@
-/*
- *     $Source$
- *     $Author$
- *     $Header$
+/* $Id$
  *
- *     Copyright (C) 1987, 1990 by the Massachusetts Institute of Technology
+ * Copyright (C) 1987-1998 by the Massachusetts Institute of Technology
  *
  */
 
@@ -27,4 +24,6 @@ typedef struct mr_params {
        int mr_state;
 } mr_params;
 
-extern int mr_start_recv(), mr_start_send();
+int mr_start_send(OPERATION op, HALF_CONNECTION hcon, struct mr_params *arg);
+int mr_start_recv(OPERATION op, HALF_CONNECTION hcon, struct mr_params **argp);
+void mr_destroy_reply(mr_params *reply);
index 7a7690f5a4795f37684bd481be8e952c2ae6848b..1f07c136de2eba85d5b982e7038a230fda45e282 100644 (file)
@@ -1,18 +1,3 @@
-/*
- * Update mechanism description structure.
- */
-struct update_desc {
-     int last_time;            /* when did we try last? */
-     int success;              /* did it succeed? */
-     int interval;             /* interval in minutes between updates */
-     char *service_name;
-     char *host_name;
-     char *target_path;                /* where to put the file */
-     int override;             /* override interval */
-     int enable;               /* can we update at all? */
-     char *instructions;       /* script pathname */
-};
-
 #define log_DEBUG 0
 #define log_INFO  1
 #define log_WARNING 2
@@ -20,3 +5,11 @@ struct update_desc {
 
 #define SERVICE_NAME "moira_update"
 #define        UPDATE_BUFSIZ   BUFSIZ
+
+int send_file(char *pathname, char *target_path, int encrypt);
+int send_auth(char *hostname);
+int execute(char *path);
+void send_quit(void);
+
+#include <krb.h>
+int get_mr_update_ticket(char *host, KTEXT ticket);
index 92a4dc3cbb525642661905b4a6bc58c310b4a70f..1122c203275472d63ddba82c2610289b594647dc 100644 (file)
@@ -1,9 +1,6 @@
-/*
- *     $Source$
- *     $Author$
- *     $Header$
+/* $Id$
  *
- *     Copyright (C) 1987 by the Massachusetts Institute of Technology
+ * Copyright (C) 1987-1998 by the Massachusetts Institute of Technology
  *
  */
 
 #define UREG_GET_SECURE 5
 #define UREG_SET_SECURE 6
 
-typedef u_long U_32BIT;
+typedef unsigned long U_32BIT;
+
+#ifndef REG_SVR
+/* (client) prototypes from reg_stubs.c */
+int ureg_init(void);
+int verify_user(char *first, char *last, char *idnumber,
+               char *hashidnumber, char *login);
+int grab_login(char *first, char *last, char *idnumber, char *hashidnumber,
+              char *login);
+int enroll_login(char *first, char *last, char *idnumber, char *hashidnumber,
+                char *login);
+int set_password(char *first, char *last, char *idnumber, char *hashidnumber,
+                char *password);
+int get_krb(char *first, char *last, char *idnumber, char *hashidnumber,
+           char *password);
+#endif
index 23941deceeb8d90f79d9957ecba6fff00e8f6bc3..140357220f6aa4b2a5dc2b27b200fc1b56bc6e47 100644 (file)
@@ -9,11 +9,14 @@
 
 #include <stdio.h>
 #include <stdlib.h>
+#include <sys/resource.h>
 #include <sys/types.h>
+#include <sys/utsname.h>
 #include <sys/file.h>
 #include <string.h>
 #include <unistd.h>
 
+#include <com_err.h>
 #include <krb.h>
 #include <moira.h>
 #include <moira_site.h>
 char *whoami;
 
 /* Main stub routines */
-int do_user();
-int do_list();
-int do_member();
-int do_filesys();
-int do_quota();
+void do_user(char **before, int beforec, char **after, int afterc);
+void do_list(char **before, int beforec, char **after, int afterc);
+void do_member(char **before, int beforec, char **after, int afterc);
+void do_filesys(char **before, int beforec, char **after, int afterc);
+void do_quota(char **before, int beforec, char **after, int afterc);
 
 /* Support stub routines */
-int run_cmd();
-int add_user_lists();
-int add_list_members();
-int check_user();
-int edit_group();
+void run_cmd(char *cmd);
+int add_user_lists(int ac, char **av, void *user);
+int add_list_members(int ac, char **av, void  *group);
+int check_user(int ac, char **av, void *ustate);
+void edit_group(int op, char *group, char *type, char *member);
 long pr_try();
-int check_afs();
+void check_afs(void);
+int moira_connect(void);
+int moira_disconnect(void);
 
 /* libprot.a routines */
 extern long pr_Initialize();
@@ -71,8 +76,10 @@ int main(int argc, char **argv)
 {
   int beforec, afterc, i;
   char *table, **before, **after;
+  struct rlimit rl;
 
-  for (i = getdtablesize() - 1; i > 2; i--)
+  getrlimit(RLIMIT_NOFILE, &rl);
+  for (i = rl.rlim_cur; i > 2; i--)
     close(i);
 
   whoami = ((whoami = strrchr(argv[0], '/')) ? whoami+1 : argv[0]);
@@ -120,7 +127,7 @@ int main(int argc, char **argv)
 }
 
 
-do_user(char **before, int beforec, char **after, int afterc)
+void do_user(char **before, int beforec, char **after, int afterc)
 {
   int astate, bstate, auid, buid, code;
   char *av[2];
@@ -231,7 +238,7 @@ do_user(char **before, int beforec, char **after, int afterc)
 }
 
 
-do_list(char **before, int beforec, char **after, int afterc)
+void do_list(char **before, int beforec, char **after, int afterc)
 {
   int agid, bgid;
   int ahide, bhide;
@@ -374,11 +381,8 @@ do_list(char **before, int beforec, char **after, int afterc)
 #define LM_EXTRA_GID      (LM_END+5)
 #define LM_EXTRA_END      (LM_END+6)
 
-do_member(char **before, int beforec, char **after, int afterc)
+void do_member(char **before, int beforec, char **after, int afterc)
 {
-  int code;
-  char *p;
-
   if (afterc)
     {
       if (afterc < LM_EXTRA_END)
@@ -405,7 +409,7 @@ do_member(char **before, int beforec, char **after, int afterc)
 }
 
 
-do_filesys(char **before, int beforec, char **after, int afterc)
+void do_filesys(char **before, int beforec, char **after, int afterc)
 {
   char cmd[1024];
   int acreate, atype, bcreate, btype;
@@ -479,7 +483,7 @@ do_filesys(char **before, int beforec, char **after, int afterc)
 }
 
 
-do_quota(char **before, int beforec, char **after, int afterc)
+void do_quota(char **before, int beforec, char **after, int afterc)
 {
   char cmd[1024];
 
@@ -495,7 +499,7 @@ do_quota(char **before, int beforec, char **after, int afterc)
 }
 
 
-run_cmd(char *cmd)
+void run_cmd(char *cmd)
 {
   int success=0, tries=0;
 
@@ -514,7 +518,7 @@ run_cmd(char *cmd)
 }
 
 
-int add_user_lists(int ac, char *av[], char *user)
+int add_user_lists(int ac, char **av, void *user)
 {
   if (atoi(av[L_ACTIVE]) && atoi(av[L_GROUP])) /* active group ? */
     edit_group(1, av[L_NAME], "USER", user);
@@ -522,20 +526,20 @@ int add_user_lists(int ac, char *av[], char *user)
 }
 
 
-int add_list_members(int ac, char *av[], char *group)
+int add_list_members(int ac, char **av, void *group)
 {
   edit_group(1, group, av[0], av[1]);
   return 0;
 }
 
-int check_user(int ac, char *av[], int *ustate)
+int check_user(int ac, char **av, void *ustate)
 {
-  *ustate = atoi(av[U_STATE]);
+  *(int *)ustate = atoi(av[U_STATE]);
   return 0;
 }
 
 
-edit_group(int op, char *group, char *type, char *member)
+void edit_group(int op, char *group, char *type, char *member)
 {
   char *p = 0;
   char buf[PR_MAXNAMELEN];
@@ -650,12 +654,12 @@ long pr_try(long (*fn)(), char *a1, char *a2, char *a3, char *a4, char *a5,
     {
       critical_alert("incremental", "Couldn't initialize libprot: %s",
                     error_message(code));
-      return;
+      return code;
     }
 
   sleep(1);                                    /* give ptserver room */
 
-  while (code = (*fn)(a1, a2, a3, a4, a5, a6, a7, a8))
+  while ((code = (*fn)(a1, a2, a3, a4, a5, a6, a7, a8)))
     {
       if (++tries > 2)
        break;          /* 3 tries */
@@ -681,7 +685,7 @@ long pr_try(long (*fn)(), char *a1, char *a2, char *a3, char *a4, char *a5,
 }
 
 
-check_afs(void)
+void check_afs(void)
 {
   int i;
 
@@ -701,13 +705,13 @@ check_afs(void)
 
 int moira_connect(void)
 {
-  static char hostname[64];
   long code;
 
   if (!mr_connections++)
     {
-      gethostname(hostname, sizeof(hostname));
-      code = mr_connect(hostname);
+      struct utsname uts;
+      uname(&uts);
+      code = mr_connect(uts.nodename);
       if (!code)
        code = mr_auth("afs.incr");
       return code;
@@ -722,7 +726,7 @@ int moira_disconnect(void)
   if (!--mr_connections)
     {
       mr_disconnect();
-      while (m = member_head)
+      while ((m = member_head))
        {
          edit_group(m->op, m->list, m->type, m->member);
          member_head = m->next;
index 1be6e3e21424cbebc00e7a953a0c56ccdef2fc35..57ff923724890379cf0c802819b65ab664941c99 100644 (file)
@@ -14,6 +14,8 @@
  */
 
 #include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
 #include <sys/param.h>
 #include <krb.h>
 /*#include <conf.h>*/
 char rcsid[] =
     "$Header$";
 
-
-void usage(char **argv)
-{
-  fprintf(stderr,
-         "Usage: %s name instance [-r realm] [-s srvtab] [-l lifetime]\n",
-         argv[0]);
-  exit(1);
-}
-
+void usage(char **argv);
 
 int main(int argc, char **argv)
 {
@@ -92,3 +86,10 @@ int main(int argc, char **argv)
   exit(code);
 }
 
+void usage(char **argv)
+{
+  fprintf(stderr,
+         "Usage: %s name instance [-r realm] [-s srvtab] [-l lifetime]\n",
+         argv[0]);
+  exit(1);
+}
index 69960c20e4f50680afadb70dd4f50f894298a905..01c90baa1f055300b122169f894764872cfc4036 100644 (file)
@@ -1,50 +1,52 @@
-/* $Header$
+/* $Id $
  *
  * Log and send a zephyrgram about any critical errors.
  *
- *  (c) Copyright 1988 by the Massachusetts Institute of Technology.
- *  For copying and distribution information, please see the file
- *  <mit-copyright.h>.
+ * (c) Copyright 1988-1998 by the Massachusetts Institute of Technology.
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
  */
 
-#include <mit-copyright.h>
-#include <stdio.h>
-#include <sys/types.h>
-#include <sys/file.h>
-#include <moira_site.h>
+
 #ifdef ZEPHYR
+/* need to include before moira.h, which includes krb_et.h, because
+   zephyr.h is broken */
 #include <zephyr/zephyr.h>
+/* zephyr.h doesn't prototype this */
+extern Code_t ZSendNotice(ZNotice_t *notice, Z_AuthProc cert_routine);
 #endif
+
+#include <mit-copyright.h>
+#include <moira.h>
+#include <moira_site.h>
+
+#include <string.h>
 #ifdef SYSLOG
 #include <syslog.h>
 #endif
-#include <string.h>
-#include <time.h>
-#include <com_err.h>
+
+RCSID("$Header$");
 
 /* mode to create the file with */
 #define LOGFILEMODE    0644
 
 extern char *whoami;
 
-
 /* This routine sends a class MOIRA zephyrgram of specified instance
  * and logs to a special logfile the message passed to it via msg
  * and args in printf format.  *** It expects the global variable
  * whoami to be defined and contain the name of the calling program.
- * It's a kludge that it takes a max of 8 arguments in a way that
- * isn't necessarily portable, but varargs doesn't work here and we
- * don't necessarily have vsprintf().
  */
 
-void critical_alert(char *instance, char *msg, char *arg1, char *arg2,
-                   char *arg3, char *arg4, char *arg5, char *arg6,
-                   char *arg7, char *arg8)
+void critical_alert(char *instance, char *msg, ...)
 {
   FILE *crit;                  /* FILE for critical log file */
   char buf[BUFSIZ];            /* Holds the formatted message */
+  va_list ap;
 
-  sprintf(buf, msg, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8);
+  va_start(ap, msg);
+  vsprintf(buf, msg, ap);
+  va_end(ap);
 
   /* Send zephyr notice */
   send_zgram(instance, buf);
@@ -59,7 +61,7 @@ void critical_alert(char *instance, char *msg, char *arg1, char *arg2,
       time_s = ctime(&t) + 4;
       time_s[strlen(time_s) - 6] = '\0';
 
-      fprintf(crit, "%s <%d> %s\n", time_s, getpid(), buf);
+      fprintf(crit, "%s <%ld> %s\n", time_s, (long)getpid(), buf);
       fclose(crit);
     }
 
@@ -72,7 +74,7 @@ void critical_alert(char *instance, char *msg, char *arg1, char *arg2,
  * errors while sending message.
  */
 
-send_zgram(char *inst, char *msg)
+void send_zgram(char *inst, char *msg)
 {
 #ifdef ZEPHYR
   ZNotice_t znotice;
index 11e087d5a0ee5d6c20a3ef557ceb4ffd3c610ee4..9a529736462adeee56c43f5941c156bf270d8cf8 100644 (file)
@@ -1,28 +1,28 @@
-/*
- *     $Source$
- *     $Author$
- *     $Header$
+/* $Id $
+ *
+ * Canonicalize a hostname
  *
- *     Copyright (C) 1987 by the Massachusetts Institute of Technology
- *     For copying and distribution information, please see the file
- *     <mit-copyright.h>.
+ * Copyright (C) 1987-1998 by the Massachusetts Institute of Technology
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
  */
 
-#ifndef lint
-static char *rcsid_fixhost_c = "$Header$";
-#endif
-
 #include <mit-copyright.h>
+#include <moira.h>
+
 #include <sys/types.h>
 #include <sys/socket.h>
-#include <netinet/in.h>
+#include <sys/utsname.h>
+
 #include <netdb.h>
+#include <netinet/in.h>
+
+#include <ctype.h>
 #include <stdio.h>
 #include <stdlib.h>
-#include <sys/utsname.h>
 #include <string.h>
-#include <ctype.h>
-#include <moira.h>
+
+RCSID("$Header$");
 
 /*
  * Canonicalize hostname:
@@ -49,7 +49,7 @@ char *canonicalize_hostname(char *host)
       strcpy(tbuf, host + 1);
       free(host);
       tbuf[strlen(tbuf) - 1] = '\0';
-      return strsave(tbuf);
+      return strdup(tbuf);
     }
 
   if (strchr(host, '*') || strchr(host, '?') || strchr(host, '['))
@@ -85,13 +85,13 @@ char *canonicalize_hostname(char *host)
              hp = gethostbyname(name.nodename);
              cp = strchr(hp->h_name, '.');
              if (cp)
-               domain = strsave(++cp);
+               domain = strdup(++cp);
              else
                domain = "";
            }
          sprintf(tbuf, "%s.%s", host, domain);
          free(host);
-         host = strsave(tbuf);
+         host = strdup(tbuf);
        }
       return host;
     }
index 02e9d254146ff2b33012956fad567c7ac09377df..8b0912d5bfc9c7e47ffe0520e7b91b10a180a608 100644 (file)
@@ -1,27 +1,27 @@
-/*
- *     $Source$
- *     $Author$
- *     $Header$
+/* $Id $
  *
- *     Copyright (C) 1987 by the Massachusetts Institute of Technology
- *     For copying and distribution information, please see the file
- *     <mit-copyright.h>.
+ * Put a name into Moira-canonical form
+ *
+ * Copyright (C) 1987-1998 by the Massachusetts Institute of Technology
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
  */
 
-#ifndef lint
-static char *rcsid_fixname_c = "$Header$";
-#endif
-
 #include <mit-copyright.h>
-#include <string.h>
+#include <moira.h>
+
 #include <ctype.h>
+#include <string.h>
+
+RCSID("$Header$");
 
 #define LAST_LEN               100
 #define FIRST_LEN              100
 
 void FixName(char *ilnm, char *ifnm, char *last, char *first, char *middle)
 {
-  int ends_jr = 0, ends_iii = 0, ends_iv = 0, ends_ii = 0, ends_v = 0;
+  int ends_jr = 0, ends_sr = 0;
+  int ends_iii = 0, ends_iv = 0, ends_ii = 0, ends_v = 0;
 
   uppercase(ilnm);
   uppercase(ifnm);
@@ -29,7 +29,8 @@ void FixName(char *ilnm, char *ifnm, char *last, char *first, char *middle)
   /* Last name ... */
 
   TrimTrailingSpace(ilnm);
-  LookForJrAndIII(ilnm, &ends_jr, &ends_ii, &ends_iii, &ends_iv, &ends_v);
+  LookForJrAndIII(ilnm, &ends_jr, &ends_sr,
+                 &ends_ii, &ends_iii, &ends_iv, &ends_v);
   LookForSt(ilnm);
   LookForO(ilnm);
   FixCase(ilnm);
@@ -38,19 +39,16 @@ void FixName(char *ilnm, char *ifnm, char *last, char *first, char *middle)
   /* First name  & middle initial ... */
 
   TrimTrailingSpace(ifnm);
-  LookForJrAndIII(ifnm, &ends_jr, &ends_ii, &ends_iii, &ends_iv, &ends_v);
+  LookForJrAndIII(ifnm, &ends_jr, &ends_sr,
+                 &ends_ii, &ends_iii, &ends_iv, &ends_v);
 
   GetMidInit(ifnm, middle);
 
   FixCase(ifnm);
-#ifdef notdef
-  /* okay, finish up first name */
-  AppendJrOrIII(ifnm, &ends_jr, &ends_ii, &ends_iii, &ends_iv, &ends_v);
-#endif
   strncpy(first, ifnm, FIRST_LEN);
 }
 
-FixCase(char *p)
+void FixCase(char *p)
 {
   int cflag;   /* convert to lcase, unless at start or following */
                /* a space or punctuation mark (e.g., '-') */
@@ -68,8 +66,8 @@ FixCase(char *p)
     }
 }
 
-LookForJrAndIII(char *nm, int *pends_jr, int *pends_ii, int *pends_iii,
-               int *pends_iv, int *pends_v)
+void LookForJrAndIII(char *nm, int *pends_jr, int *pends_sr, int *pends_ii,
+                    int *pends_iii, int *pends_iv, int *pends_v)
 {
   int len = strlen(nm);
 
@@ -78,6 +76,11 @@ LookForJrAndIII(char *nm, int *pends_jr, int *pends_ii, int *pends_iii,
       *pends_jr = 1;
       nm[len - 3] = '\0';
     }
+  else if (len >= 4 && !strcmp(nm + len - 3, " SR"))
+    {
+      *pends_sr = 1;
+      nm[len - 3] = '\0';
+    }
   else if (len >= 4 && !strcmp(nm + len - 3, " IV"))
     {
       *pends_iv = 1;
@@ -105,7 +108,7 @@ LookForJrAndIII(char *nm, int *pends_jr, int *pends_ii, int *pends_iii,
     }
 }
 
-LookForSt(char *nm)            /* ST PIERRE, etc. */
+void LookForSt(char *nm)               /* ST PIERRE, etc. */
 {
   char temp[256];
 
@@ -117,20 +120,20 @@ LookForSt(char *nm)               /* ST PIERRE, etc. */
     }
 }
 
-LookForO(char *nm)             /* O BRIEN, etc. */
+void LookForO(char *nm)                /* O BRIEN, etc. */
 {
   if (!strcmp(nm, "O ") && isalpha(nm[2]))
     nm[1] = '\'';
 }
 
-TrimTrailingSpace(char *ip)
+void TrimTrailingSpace(char *ip)
 {
   char *p;
   for (p = ip + strlen(ip) - 1; p >= ip && isspace(*p); p--)
     *p = '\0';
 }
 
-GetMidInit(char *nm, char *mi)
+void GetMidInit(char *nm, char *mi)
 {
   while (*nm && !isspace(*nm))
     nm++;
index 40c421d24e4a62d8ac24b5b85de684e66808c18f..bdb008af704039be1fb05a698e7ce01efd067910 100644 (file)
@@ -1,10 +1,19 @@
-/* $Header$
+/* $Id $
  *
  * Convert from GDSS error codes to com_err error codes
+ *
+ * Copyright (C) 1987-1998 by the Massachusetts Institute of Technology
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
  */
 
+#include <mit-copyright.h>
+#include <moira.h>
+
 #include <gdss_et.h>
 
+RCSID("$Header$");
+
 int gdss2et(int code)
 {
   if (code == 0)
index e00be3149711fce1fba4aea3f934a5491d84d1a4..facec15aeced776c398f3dd6f33e1b3f08598a34 100644 (file)
@@ -1,21 +1,20 @@
-/* $Header$
+/* $Id $
  *
  * Generic hash table routines.  Uses integer keys to store char * values.
  *
- *  (c) Copyright 1988 by the Massachusetts Institute of Technology.
- *  For copying and distribution information, please see the file
- *  <mit-copyright.h>.
+ * Copyright (C) 1988-1998 by the Massachusetts Institute of Technology.
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
  */
 
 #include <mit-copyright.h>
-#include <ctype.h>
 #include <moira.h>
-#include <string.h>
+
 #include <stdlib.h>
+#include <string.h>
+
+RCSID("$Header$");
 
-#ifndef NULL
-#define NULL 0
-#endif
 #define hash_func(h, key) (key >= 0 ? (key % h->size) : (-key % h->size))
 
 /* Create a hash table.  The size is just a hint, not a maximum. */
@@ -28,13 +27,13 @@ struct hash *create_hash(int size)
   if (!h)
     return NULL;
   h->size = size;
-  h->data = malloc(size * sizeof(char *));
+  h->data = malloc(size * sizeof(void *));
   if (!h->data)
     {
       free(h);
       return NULL;
     }
-  memset(h->data, 0, size * sizeof(char *));
+  memset(h->data, 0, size * sizeof(void *));
   return h;
 }
 
@@ -42,7 +41,7 @@ struct hash *create_hash(int size)
  * the key, or NULL (thus NULL is not a very good value to store...)
  */
 
-char *hash_lookup(struct hash *h, int key)
+void *hash_lookup(struct hash *h, int key)
 {
   struct bucket *b;
 
@@ -60,7 +59,7 @@ char *hash_lookup(struct hash *h, int key)
  * existed, or 0 if not.
  */
 
-int hash_update(struct hash *h, int key, char *value)
+int hash_update(struct hash *h, int key, void *value)
 {
   struct bucket *b;
 
@@ -81,7 +80,7 @@ int hash_update(struct hash *h, int key, char *value)
  * there, 1 if it was, or -1 if we ran out of memory.
  */
 
-int hash_store(struct hash *h, int key, char *value)
+int hash_store(struct hash *h, int key, void *value)
 {
   struct bucket *b, **p;
 
@@ -118,7 +117,7 @@ int hash_store(struct hash *h, int key, char *value)
  * data with that value, call the callback proc with the corresponding key.
  */
 
-hash_search(struct hash *h, char *value, void (*callback)())
+void hash_search(struct hash *h, void *value, void (*callback)(int))
 {
   struct bucket *b, **p;
 
@@ -136,7 +135,8 @@ hash_search(struct hash *h, char *value, void (*callback)())
 /* Step through the hash table, calling the callback proc with each key.
  */
 
-hash_step(struct hash *h, void (*callback)(), char *hint)
+void hash_step(struct hash *h, void (*callback)(int, void *, void *),
+              void *hint)
 {
   struct bucket *b, **p;
 
@@ -150,7 +150,7 @@ hash_step(struct hash *h, void (*callback)(), char *hint)
 
 /* Deallocate all of the memory associated with a table */
 
-hash_destroy(struct hash *h)
+void hash_destroy(struct hash *h)
 {
   struct bucket *b, **p, *b1;
 
index 49883998695215bf63ebb6d50678e2cb8bc2acc0..53f9f96ee67d2b66bdc5a3e2d47181d2c4e446fd 100644 (file)
@@ -1,18 +1,22 @@
-/* $Header$
+/* $Id $
  *
- * Routines to encrypt ID's
+ * Routines to deal with MIT IDs
  *
- *  (c) Copyright 1988 by the Massachusetts Institute of Technology.
- *  For copying and distribution information, please see the file
- *  <mit-copyright.h>.
+ * Copyright (C) 1988-1998 by the Massachusetts Institute of Technology.
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
  */
 
 #include <mit-copyright.h>
-#include <string.h>
+#include <moira.h>
+
 #include <ctype.h>
-#include <unistd.h>
+#include <string.h>
+
 #ifdef USE_CRYPT_H
 #include <crypt.h>
+#else
+#include <unistd.h>
 #endif
 
 /*     Function Name: RemoveHyphens
index a694b20da8b5994c466b9b5a71c7352b8f93823f..71c3c2a71326994778fdc4e82e9fa7cfe43460aa 100644 (file)
@@ -1,13 +1,23 @@
-/* $Header$
+/* $Id $
  *
  * Don't know why this function is not in libkrb.a.  It's the inverse
  * of kname_parse() which is there.
+ *
+ * Copyright (C) 1993-1998 by the Massachusetts Institute of Technology
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
  */
 
+#include <mit-copyright.h>
+#include <moira.h>
+
 #include <stdio.h>
+
 #include <des.h>
 #include <krb.h>
 
+RCSID("$Header$");
+
 /* 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.
index e2fc6df84cd2cd6a47a47e608caa767d92864331..c45b37632e28e24f4bf6d5942cda8d3c9ed69849 100644 (file)
@@ -1,21 +1,22 @@
-/*
- *     $Source$
- *     $Author$
- *     $Header$
+/* $Id $
+ *
+ * Check access to a Moira query
  *
- *     Copyright (C) 1987, 1990 by the Massachusetts Institute of Technology
- *     For copying and distribution information, please see the file
- *     <mit-copyright.h>.
+ * Copyright (C) 1987-1998 by the Massachusetts Institute of Technology
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
  */
 
-#ifndef lint
-static char *rcsid_mr_access_c = "$Header$";
-#endif
-
 #include <mit-copyright.h>
+#include <moira.h>
 #include "mr_private.h"
-#include <string.h>
+
 #include <stdlib.h>
+#include <string.h>
+
+RCSID("$Header$");
+
+int mr_access_internal(int argc, char **argv);
 
 /*
  * Check access to a named query.
index d196e5cd3f172994031328ac91f9b89cb27fd28b..b6273e07e55b82666260698633b51e3ac9cd1352 100644 (file)
@@ -1,27 +1,25 @@
-/*
- *     $Source$
- *     $Author$
- *     $Header$
+/* $Id $
  *
- *     Copyright (C) 1987, 1990 by the Massachusetts Institute of Technology
- *     For copying and distribution information, please see the file
- *     <mit-copyright.h>.
+ * Handles the client side of the sending of authenticators to the moira server
  *
- *     Handles the client side of the sending of authenticators to
- * the mr server.
+ * Copyright (C) 1987-1998 by the Massachusetts Institute of Technology
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
  */
 
-#ifndef lint
-static char *rcsid_mr_auth_c = "$Header$";
-#endif
-
 #include <mit-copyright.h>
+#include <moira.h>
 #include "mr_private.h"
+
 #include <ctype.h>
-#include <krb.h>
-#include <krb_et.h>
 #include <string.h>
 
+#include <krb.h>
+extern char *krb_realmofhost(char *);
+extern int krb_mk_req(KTEXT, char *, char *, char *, int);
+
+RCSID("$Header$");
+
 /* Authenticate this client with the Moira server.  prog is the name of the
  * client program, and will be recorded in the database.
  */
@@ -33,7 +31,6 @@ int mr_auth(char *prog)
   char *args[2];
   int argl[2];
   char realm[REALM_SZ], host[BUFSIZ], *p;
-
   mr_params *params = &params_st;
   mr_params *reply = NULL;
   KTEXT_ST auth;
@@ -46,7 +43,7 @@ int mr_auth(char *prog)
   if ((status = mr_host(host, sizeof(host) - 1)))
     return status;
 
-  strcpy(realm, (char *)krb_realmofhost(host));
+  strcpy(realm, krb_realmofhost(host));
   for (p = host; *p && *p != '.'; p++)
     {
       if (isupper(*p))
index a6b543465f78cd054a2360f87992e31937c82d9c..63e576ad6e2a1e17c30d5e87175fd1bd27a19541 100644 (file)
@@ -1,20 +1,18 @@
-/*
- *     $Source$
- *     $Author$
- *     $Header$
+/* $Id $
  *
- *     Copyright (C) 1987 by the Massachusetts Institute of Technology
- *     For copying and distribution information, please see the file
- *     <mit-copyright.h>.
+ * Pass an mr_params off to the Moira server and get a reply
+ *
+ * Copyright (C) 1987-1998 by the Massachusetts Institute of Technology
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
  */
 
-#ifndef lint
-static char *rcsid_mr_call_c = "$Header$";
-#endif
-
 #include <mit-copyright.h>
+#include <moira.h>
 #include "mr_private.h"
 
+RCSID("$Header$");
+
 int mr_do_call(struct mr_params *params, struct mr_params **reply)
 {
   CHECK_CONNECTED;
@@ -32,8 +30,8 @@ int mr_do_call(struct mr_params *params, struct mr_params **reply)
   queue_operation(_mr_conn, CON_INPUT, _mr_recv_op);
 
   /* Block until operation done. */
-  mr_complete_operation(_mr_send_op);
-  mr_complete_operation(_mr_recv_op);
+  complete_operation(_mr_send_op);
+  complete_operation(_mr_recv_op);
   /* Look at results */
   if ((OP_STATUS(_mr_send_op) != OP_COMPLETE) ||
       (OP_STATUS(_mr_recv_op) != OP_COMPLETE))
index e18c10b8ba234a8371f158c034ccc969a23446ea..091b1d06c959ba8edb354f3a69453f031838f64e 100644 (file)
@@ -1,27 +1,26 @@
-/*
- *     $Source$
- *     $Author$
- *     $Header$
+/* $Id $
  *
- *     Copyright (C) 1987, 1990 by the Massachusetts Institute of Technology
- *     For copying and distribution information, please see the file
- *     <mit-copyright.h>.
+ * This routine is part of the client library.  It handles
+ * creating a connection to the moira server.
  *
- *     This routine is part of the client library.  It handles
- *     creating a connection to the mr server.
+ * Copyright (C) 1987-1998 by the Massachusetts Institute of Technology
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
  */
 
-#ifndef lint
-static char *rcsid_mr_connect_c = "$Header$";
-#endif
-
 #include <mit-copyright.h>
-#include "mr_private.h"
+#include <moira.h>
 #include <moira_site.h>
-#include <string.h>
+#include "mr_private.h"
+
+#include <errno.h>
 #include <stdlib.h>
+#include <string.h>
+
 #include <hesiod.h>
 
+RCSID("$Header$");
+
 static char *mr_server_host = 0;
 
 /*
@@ -32,7 +31,6 @@ static char *mr_server_host = 0;
 
 int mr_connect(char *server)
 {
-  extern int errno;
   char *p, **pp, sbuf[256];
 
   if (!mr_inited)
@@ -80,7 +78,7 @@ int mr_connect(char *server)
    * stash hostname for later use
    */
 
-  mr_server_host = strsave(server);
+  mr_server_host = strdup(server);
   if ((p = strchr(mr_server_host, ':')))
     *p = '\0';
   mr_server_host = canonicalize_hostname(mr_server_host);
index 253fb8978d7bc9867deb02534854ae2c2f4bbc40..05893f54058fbc96425267c9e69c0e9bc33ca144 100644 (file)
@@ -1,21 +1,18 @@
-/*
- *     $Source$
- *     $Author$
- *     $Header$
+/* $Id $
  *
- *     Copyright (C) 1987 by the Massachusetts Institute of Technology
- *     For copying and distribution information, please see the file
- *     <mit-copyright.h>.
+ * A few variables
  *
+ * Copyright (C) 1987-1998 by the Massachusetts Institute of Technology
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
  */
 
-#ifndef lint
-static char *rcsid_mr_data_c = "$Header$";
-#endif
-
 #include <mit-copyright.h>
+#include <moira.h>
 #include "mr_private.h"
 
+RCSID("$Header$");
+
 CONNECTION _mr_conn;
 
 OPERATION _mr_send_op, _mr_recv_op;
index c77473847a135ad240e0ad36a3b4cb5549c231f6..abb2933c9025a694a6629fbf40fe35ef4bfd41b0 100644 (file)
@@ -1,26 +1,24 @@
-/*
- *     $Source$
- *     $Author$
- *     $Header$
+/* $Id $
  *
- *     Copyright (C) 1987, 1990 by the Massachusetts Institute of Technology
- *     For copying and distribution information, please see the file
- *     <mit-copyright.h>.
+ * Initialize libmoira
+ *
+ * Copyright (C) 1987-1990 by the Massachusetts Institute of Technology
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
  */
 
-#ifndef lint
-static char *rcsid_mr_init_c = "$Header$";
-#endif
-
 #include <mit-copyright.h>
+#include <moira.h>
 #include "mr_private.h"
 
+RCSID("$Header$");
+
 int mr_inited = 0;
 
 /* the reference to link_against_the_moira_version_of_gdb is to make
  * sure that this is built with the proper libraries.
  */
-mr_init(void)
+void mr_init(void)
 {
   extern int link_against_the_moira_version_of_gdb;
   if (mr_inited)
index b981c9f3599c79e4a4146b4037873349d7779049..4c2519c8f51b1f4ac923663b6bf0bbdc2edf67f9 100644 (file)
@@ -1,26 +1,21 @@
-/*
- *     $Source$
- *     $Author$
- *     $Header$
+/* $Id $
  *
- *     Copyright (C) 1987, 1989, 1990 by the Massachusetts Institute of
- *     Technology
- *     For copying and distribution information, please see the file
- *     <mit-copyright.h>.
+ * This routine is part of the client library.  It handles
+ * the protocol operations: invoking an update and getting the
+ * Moira message of the day.
  *
- *     This routine is part of the client library.  It handles
- *     the protocol operations: invoking an update and getting the
- *     Moira message of the day.
+ * Copyright (C) 1987-1998 by the Massachusetts Institute of Technology
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
  */
 
-#ifndef lint
-static char *rcsid_mr_do_update_c = "$Header$";
-#endif
-
 #include <mit-copyright.h>
-#include <string.h>
+#include <moira.h>
 #include "mr_private.h"
 
+#include <string.h>
+
+RCSID("$Header$");
 
 /* Invoke a DCM update. */
 
@@ -85,7 +80,7 @@ int mr_motd(char **motd)
       initialize_operation(_mr_recv_op, mr_start_recv, &reply, NULL);
       queue_operation(_mr_conn, CON_INPUT, _mr_recv_op);
 
-      mr_complete_operation(_mr_recv_op);
+      complete_operation(_mr_recv_op);
       if (OP_STATUS(_mr_recv_op) != OP_COMPLETE)
        {
          mr_disconnect();
@@ -101,61 +96,3 @@ punt:
   else
     return status;
 }
-
-
-/* Tell the library to take care of another input source while it is
- * processing a query.  For instance, an X toolkit application would
- * do something like
- *    mr_set_alternate_input(ConnectionNumber(XtDisplay(widget)), doxinput);
- * where doxinput is defined as:
- *    doxinput() {
- *     extern Widget toplevel;
- *     XEvent event;
- *     while (XPending(XtDisplay(toplevel))) {
- *         XNextEvent(XtDisplay(toplevel), &event);
- *         XtDispatchEvent(&event);
- *      }
- *      XFlush(XtDisplay(toplevel));
- *    }
- */
-
-static int mr_alternate_input = 0;
-static int (*mr_alternate_handler)();
-
-int mr_set_alternate_input(int fd, int (*proc)())
-{
-  if (mr_alternate_input != 0)
-    return MR_ALREADY_CONNECTED;
-  mr_alternate_input = fd;
-  mr_alternate_handler = proc;
-  return MR_SUCCESS;
-}
-
-
-/* This is used by the parts of the library that must wait for GDB.  It
- * handles alternate input streams (such as X) as well.
- */
-
-int mr_complete_operation(OPERATION op)
-{
-  long infd, outfd, exfd;
-  int rc;
-
-  gdb_progress();              /* try for an immediate completion */
-
-  if (mr_alternate_input == 0)
-    return complete_operation(op);
-
-  infd = 1 << mr_alternate_input;
-  outfd = exfd = 0;
-
-  while (op->status != OP_COMPLETE && op->status != OP_CANCELLED)
-    {
-      rc = con_select(mr_alternate_input, (fd_set *)&infd, (fd_set *)&outfd,
-                     (fd_set *)&exfd, NULL);
-      if (rc > 0 && mr_alternate_handler)
-       (*mr_alternate_handler)();
-    }
-  return op->status;
-}
-
index bdf0302e313d4fcae7b05dc1ed5869707598db79..55b0309a90347d40af965c2d3737214b108635ae 100644 (file)
@@ -1,24 +1,24 @@
-/*
- *     $Source$
- *     $Author$
- *     $Header$
+/* $Id $
+ *
+ * Deal with mrgdb (bleah!)
  *
- *     Copyright (C) 1987, 1990 by the Massachusetts Institute of Technology
- *     For copying and distribution information, please see the file
- *     <mit-copyright.h>.
+ * Copyright (C) 1987-1998 by the Massachusetts Institute of Technology
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
  *
  */
 
-#ifndef lint
-static char *rcsid_mr_param_c = "$Header$";
-#endif
-
 #include <mit-copyright.h>
+#include <moira.h>
+#include "mr_private.h"
+
 #include <sys/types.h>
 #include <netinet/in.h>
-#include "mr_private.h"
-#include <string.h>
+
 #include <stdlib.h>
+#include <string.h>
+
+RCSID("$Header$");
 
 /*
  * GDB operations to send and recieve RPC requests and replies.
@@ -213,7 +213,7 @@ int mr_start_recv(OPERATION op, HALF_CONNECTION hcon, struct mr_params **argp)
   return mr_cont_recv(op, hcon, argp);
 }
 
-mr_destroy_reply(mr_params *reply)
+void mr_destroy_reply(mr_params *reply)
 {
   int i;
   if (reply)
index 14e62c717cc6c4f3f071601ff4d636b1d5d5a9ef..906a233e512bdfaf698d377fbffac8e770fd5b0b 100644 (file)
@@ -1,11 +1,10 @@
-/*
- *     $Source$
- *     $Author$
- *     $Header$
+/* $Id $
  *
- *     Copyright (C) 1987 by the Massachusetts Institute of Technology
+ * Private declarations of the Moira library.
  *
- *     Private declarations of the Moira library.
+ * Copyright (C) 1987-1998 by the Massachusetts Institute of Technology
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
  */
 
 #include "mr_proto.h"
@@ -27,3 +26,16 @@ extern int sending_version_no;
 #define EVER (;;)
 
 #define CHECK_CONNECTED {if (!_mr_conn) return MR_NOT_CONNECTED;}
+
+/* prototypes from mr_call.h */
+int mr_do_call(struct mr_params *params, struct mr_params **reply);
+
+/* prototypes from mr_init.c */
+void mr_init(void);
+
+/* prototypes from mr_ops.c */
+int mr_complete_operation(OPERATION op);
+
+/* prototypes from mr_params.c */
+int mr_cont_send(OPERATION op, HALF_CONNECTION hcon, struct mr_params *arg);
+int mr_cont_recv(OPERATION op, HALF_CONNECTION hcon, mr_params **argp);
index d7c5711bd55a1ac0202c63c42a9a95080f303cc0..f9374d014064350cb2a52f6ca6f12209daee4ce9 100644 (file)
@@ -1,22 +1,24 @@
-/*
- *     $Source$
- *     $Author$
- *     $Header$
+/* $Id $
+ *
+ * Perform a Moira query
  *
- *     Copyright (C) 1987 by the Massachusetts Institute of Technology
- *     For copying and distribution information, please see the file
- *     <mit-copyright.h>.
+ * Copyright (C) 1987-1998 by the Massachusetts Institute of Technology
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
  *
  */
 
-#ifndef lint
-static char *rcsid_mr_query_c = "$Header$";
-#endif
-
 #include <mit-copyright.h>
+#include <moira.h>
 #include "mr_private.h"
-#include <string.h>
+
 #include <stdlib.h>
+#include <string.h>
+
+RCSID("$Header$");
+
+int mr_query_internal(int argc, char **argv,
+                     int (*callback)(int, char **, void *), void *callarg);
 
 /*
  * This routine is the primary external interface to the mr library.
@@ -27,7 +29,7 @@ static char *rcsid_mr_query_c = "$Header$";
 static int level = 0;
 
 int mr_query(char *name, int argc, char **argv,
-            int (*callproc)(), char *callarg)
+            int (*callproc)(int, char **, void *), void *callarg)
 {
   char **nargv = malloc(sizeof(char *) * (argc + 1));
   int status = 0;
@@ -52,7 +54,8 @@ int mr_query(char *name, int argc, char **argv,
  * way to send it a quench..)
  */
 
-int mr_query_internal(int argc, char **argv, int (*callproc)(), char *callarg)
+int mr_query_internal(int argc, char **argv,
+                     int (*callproc)(int, char **, void *), void *callarg)
 {
   int status;
   mr_params params_st;
@@ -78,7 +81,7 @@ int mr_query_internal(int argc, char **argv, int (*callproc)(), char *callarg)
 
   while ((status = reply->mr_status) == MR_MORE_DATA)
     {
-      if (!stopcallbacks)
+      if (!stopcallbacks && callproc)
        stopcallbacks = (*callproc)(reply->mr_argc, reply->mr_argv, callarg);
       mr_destroy_reply(reply);
       reply = NULL;
@@ -86,7 +89,7 @@ int mr_query_internal(int argc, char **argv, int (*callproc)(), char *callarg)
       initialize_operation(_mr_recv_op, mr_start_recv, &reply, NULL);
       queue_operation(_mr_conn, CON_INPUT, _mr_recv_op);
 
-      mr_complete_operation(_mr_recv_op);
+      complete_operation(_mr_recv_op);
       if (OP_STATUS(_mr_recv_op) != OP_COMPLETE)
        {
          mr_disconnect();
index 2aec68f2a21bcb6a65699206fc00e622e4f37e33..b814008652a9a0b0edbed913dce68092edf470bc 100644 (file)
@@ -1,27 +1,21 @@
-/*
- *     $Source$
- *     $Author$
- *     $Header$
+/* $Id $
+ *
+ * Deal with NFS partition types
  *
- *     Copyright (C) 1987 by the Massachusetts Institute of Technology
- *     For copying and distribution information, please see the file
- *     <mit-copyright.h>.
+ * Copyright (C) 1987-1998 by the Massachusetts Institute of Technology
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
  *
  */
 
-#ifndef lint
-static char *rcsid_nfsparttype_c = "$Header$";
-#endif
-
 #include <mit-copyright.h>
 #include <moira.h>
+
 #include <stdio.h>
-#include <string.h>
-#include <ctype.h>
 #include <stdlib.h>
+#include <string.h>
 
-extern char *strsave();
-extern char *strtrim();
+RCSID("$Header$");
 
 struct pair {
   int type;
@@ -78,7 +72,7 @@ char *format_filesys_type(char *fs_status)
     }
   if (!n_names)
     strcpy(buf, "none");
-  return strsave(buf);
+  return strdup(buf);
 }
 
 /*
@@ -121,5 +115,5 @@ char *parse_filesys_type(char *fs_type_name)
     }
   while (cp);
   sprintf(temp, "%d", flags);
-  return strsave(temp);
+  return strdup(temp);
 }
index 68f0d207698aa45cc7699aeba6f151c81e3c6fef..d3c3b5b020083bf28be728f3ef042531437c287f 100644 (file)
--- a/lib/sq.c
+++ b/lib/sq.c
@@ -1,16 +1,19 @@
-/* $Header$
+/* $Id $
  *
  * Generic Queue Routines
  *
- *  (c) Copyright 1988 by the Massachusetts Institute of Technology.
- *  For copying and distribution information, please see the file
- *  <mit-copyright.h>.
+ * Copyright (C) 1988-1998 by the Massachusetts Institute of Technology.
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
  */
 
 #include <mit-copyright.h>
 #include <moira.h>
-#include <string.h>
+
 #include <stdlib.h>
+#include <string.h>
+
+RCSID("$Header$");
 
 struct save_queue *sq_create(void)
 {
@@ -25,7 +28,7 @@ struct save_queue *sq_create(void)
   return sq;
 }
 
-int sq_save_data(struct save_queue *sq, char *data)
+int sq_save_data(struct save_queue *sq, void *data)
 {
   struct save_queue *q;
 
@@ -62,10 +65,10 @@ int sq_save_args(int argc, char *argv[], struct save_queue *sq)
       memcpy(argv_copy[i], argv[i], n);
     }
 
-  return sq_save_data(sq, (char *)argv_copy);
+  return sq_save_data(sq, argv_copy);
 }
 
-int sq_save_unique_data(struct save_queue *sq, char *data)
+int sq_save_unique_data(struct save_queue *sq, void *data)
 {
   struct save_queue *q;
 
@@ -91,24 +94,31 @@ int sq_save_unique_string(struct save_queue *sq, char *data)
   return sq_save_data(sq, data);
 }
 
-int sq_get_data(struct save_queue *sq, char **data)
+/* in sq_get_data and sq_remove_data, `data' is actually a pointer to the
+   variable to put the data in to. */
+
+int sq_get_data(struct save_queue *sq, void *data)
 {
-  if (sq->q_lastget == (struct save_queue *)0)
+  void **dptr = data;
+
+  if (sq->q_lastget == NULL)
     sq->q_lastget = sq->q_next;
   else
     sq->q_lastget = sq->q_lastget->q_next;
 
   if (sq->q_lastget == sq)
     return 0;
-  *data = sq->q_lastget->q_data;
+  *dptr = sq->q_lastget->q_data;
   return 1;
 }
 
-int sq_remove_data(struct save_queue *sq, char **data)
+int sq_remove_data(struct save_queue *sq, void *data)
 {
+  void **dptr = data;
+
   if (sq->q_next != sq)
     {
-      *data = sq->q_next->q_data;
+      *dptr = sq->q_next->q_data;
       sq->q_next = sq->q_next->q_next;
       free(sq->q_next->q_prev);
       sq->q_next->q_prev = sq;
@@ -125,7 +135,7 @@ int sq_empty(struct save_queue *sq)
     return 0;
 }
 
-sq_destroy(struct save_queue *sq)
+void sq_destroy(struct save_queue *sq)
 {
   struct save_queue *q;
 
index 1dc4def69778f3efc6579c3911d70539d68feb5f..2980e9b38f9df2ba00d2cd907ed3605fef6b4d0a 100644 (file)
@@ -1,49 +1,18 @@
-/*
- *     $Source$
- *     $Author$
- *     $Header$
+/* $Id $
  *
- *     Copyright (C) 1987 by the Massachusetts Institute of Technology
- *     For copying and distribution information, please see the file
- *     <mit-copyright.h>.
+ * Miscellaneous string functions.
  *
- *     Miscellaneous string functions.
+ * Copyright (C) 1987-1998 by the Massachusetts Institute of Technology
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
  */
 
-#ifndef lint
-static char *rcsid_strs_c = "$Header$";
-#endif
-
 #include <mit-copyright.h>
-#include <sys/types.h>
-#include <stdlib.h>
-#include <string.h>
-#include <ctype.h>
+#include <moira.h>
 
-/*
- * Random string functions which should be in the C library..
- */
+#include <ctype.h>
 
-/*
- * Make a copy of a string.
- */
-char *strsave(char *s)
-{
-  int len;
-  char *p;
-  /* Kludge for sloppy string semantics */
-  if (!s)
-    {
-      p = malloc(1);
-      *p = '\0';
-      return p;
-    }
-  len = strlen(s) + 1;
-  p = malloc(len);
-  if (p)
-    memcpy(p, s, len);
-  return p;
-}
+RCSID("$Header$");
 
 /*
  * Trim whitespace off both ends of a string.
index 64d392864bd234671d20da29e090def84670aa1e..b1341b24e9521363bd89ad64a1ad5f778dd9948e 100644 (file)
@@ -1,46 +1,55 @@
-/*
- *      $Source$
- *      $Author$
- *      $Header$
+/* $Id$
  *
- *      Copyright (C) 1987, 1988 by the Massachusetts Institute of Technology
- *     For copying and distribution information, please see the file
- *     <mit-copyright.h>.
+ * Server for user registration with Moira and Kerberos.
  *
- *      Server for user registration with Moira and Kerberos.
+ * This program is a client of the Kerberos admin_server and a
+ * server for the userreg program.  It is not a client of the
+ * Moira server as it is linked with libmoiraglue which bypasses
+ * the network protocol.
  *
- *      This program is a client of the Kerberos admin_server and a
- *      server for the userreg program.  It is not a client of the
- *      Moira server as it is linked with libmoiraglue which bypasses
- *      the network protocol.
+ * Copyright (C) 1987-1998 by the Massachusetts Institute of Technology
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
  */
 
-#ifndef lint
-static char *rcsid_reg_svr_c = "$Header$";
-#endif lint
-
 #include <mit-copyright.h>
+#include <moira.h>
+#include <moira_site.h>
+
+#include <sys/utsname.h>
+
+#include <errno.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-#include <ctype.h>
-#include <sys/time.h>
-#include <sys/types.h>
-#include <sys/file.h>
-#include <krb.h>
+#include <time.h>
+
 #include <des.h>
 #include <kadm.h>
 #include <kadm_err.h>
-#include <krb_err.h>
-#include <errno.h>
-#include <com_err.h>
-#include "moira.h"
-#include "moira_site.h"
+#include <krb.h>
+
 #include "reg_svr.h"
 
+RCSID("$Header$");
+
 extern char admin_errmsg[];
 
-void reg_com_err_hook();
+int parse_encrypted(struct msg *message, struct db_data *data);
+int parse_encrypted(struct msg *message, struct db_data *data);
+int db_callproc(int argc, char **argv, void *queue);
+int find_user(struct msg *message);
+int verify_user(struct msg *message, char *retval);
+int ureg_kadm_init(void);
+int reserve_krb(char *login);
+int setpass_krb(char *login, char *password);
+int reserve_user(struct msg *message, char *retval);
+int set_final_status(struct msg *message);
+int set_password(struct msg *message, char *retval);
+int getuserinfo(int argc, char **argv, void *qa);
+int set_identity(struct msg *message, char *retval);
+int get_secure(struct msg *message, char *retval);
+int set_secure(struct msg *message, char *retval);
 
 int main(int argc, char *argv[])
 {
@@ -48,17 +57,12 @@ int main(int argc, char *argv[])
   int status = SUCCESS;                /* Error status */
   char retval[BUFSIZ];         /* Buffer to hold return message for client */
 
-  void req_initialize();       /* Initialize request layer */
-  void get_request();          /* Get a request */
-  void report();               /* Respond to a request */
-
   /* Initialize */
   whoami = argv[0];
 
   /* Error messages sent one line at a time */
   setvbuf(stderr, NULL, _IOLBF, BUFSIZ);
   setvbuf(stdout, NULL, _IOLBF, BUFSIZ);
-  set_com_err_hook(reg_com_err_hook);
 
   /* Initialize com_err error tables */
   init_ureg_err_tbl();
@@ -159,7 +163,6 @@ int parse_encrypted(struct msg *message, struct db_data *data)
   des_key_schedule sched;      /* En/decryption schedule */
   static char decrypt[BUFSIZ]; /* Buffer to hold decrypted information */
   long decrypt_len;            /* Length of decypted ID information */
-  char recrypt[14];            /* Buffer to hold re-encrypted information */
   static char hashid[14];      /* Buffer to hold one-way encrypted ID */
   char idnumber[BUFSIZ];       /* Buffer to hold plain-text ID */
   char *temp;                  /* A temporary string pointer */
@@ -241,7 +244,7 @@ int parse_encrypted(struct msg *message, struct db_data *data)
 
 /* This function is called by mr_query after each tuple found.  It is
    used by find_user to cache information about each user found.  */
-int db_callproc(int argc, char **argv, struct save_queue *queue)
+int db_callproc(int argc, char **argv, void*queue)
 {
   struct db_data *data;        /* Structure to store the information in */
   int status = SUCCESS;        /* Error status */
@@ -272,7 +275,7 @@ int db_callproc(int argc, char **argv, struct save_queue *queue)
 int find_user(struct msg *message)
 {
 #define GUBN_ARGS 2            /* Arguements needed by get_user_by_name */
-  char *q_name;                        /* Name of query */
+  char *q_name;                        /* Name of Moira query */
   int q_argc;                  /* Number of arguments for query */
   char *q_argv[GUBN_ARGS];     /* Arguments to query */
   int status = SUCCESS;                /* Query return status */
@@ -297,7 +300,7 @@ int find_user(struct msg *message)
       queue = sq_create();
 
       /* Do it */
-      status = mr_query(q_name, q_argc, q_argv, db_callproc, (char *)queue);
+      status = mr_query(q_name, q_argc, q_argv, db_callproc, queue);
 
       if (status == MR_SUCCESS)
        {
@@ -399,23 +402,24 @@ int ureg_kadm_init(void)
 {
   unsigned int status = SUCCESS;        /* Return status */
   static char krbrealm[REALM_SZ];       /* kerberos realm name */
-  static char hostbuf[BUFSIZ], *host;   /* local hostname in principal fmt */
+  static char *host;                    /* local hostname in principal fmt */
   static int inited = 0;
   char *p;
+  struct utsname uts;
 
   if (!inited)
     {
       inited++;
       memset(krbrealm, 0, sizeof(krbrealm));
-      if (status = krb_get_lrealm(krbrealm, 1))
+      if ((status = krb_get_lrealm(krbrealm, 1)))
        {
          status += krb_err_base;
          com_err(whoami, status, " fetching kerberos realm");
          exit(1);
        }
-      if (gethostname(hostbuf, sizeof(hostbuf)) < 0)
+      if (uname(&uts) < 0)
        com_err(whoami, errno, "getting local hostname");
-      host = canonicalize_hostname(strsave(hostbuf));
+      host = canonicalize_hostname(strdup(uts.nodename));
       for (p = host; *p && *p != '.'; p++)
        {
          if (isupper(*p))
@@ -426,8 +430,8 @@ int ureg_kadm_init(void)
 
   /* Get keys for interacting with Kerberos admin server. */
   /* principal, instance, realm, service, service instance, life, file */
-  if (status = krb_get_svc_in_tkt(MOIRA_SNAME, host, krbrealm, PWSERV_NAME,
-                                 KADM_SINST, 1, KEYFILE))
+  if ((status = krb_get_svc_in_tkt(MOIRA_SNAME, host, krbrealm, PWSERV_NAME,
+                                  KADM_SINST, 1, KEYFILE)))
     status += krb_err_base;
 
   if (status != SUCCESS)
@@ -442,14 +446,6 @@ int ureg_kadm_init(void)
   return status;
 }
 
-/* This routine is a null callback that should be used for queries that
-   do not return tuples.  If it ever gets called, something is wrong. */
-int null_callproc(int argc, char *argv[], char *message)
-{
-  critical_alert(FAIL_INST, "Something returned from an update query.");
-  return FAILURE;
-}
-
 /*
  * This routine reserves a principal in kerberos by setting up a
  * principal with a random initial key.
@@ -579,7 +575,7 @@ int reserve_user(struct msg *message, char *retval)
       q_argv[1] = login;
       q_argv[2] = fstype_buf;
       q_argc = 3;
-      status = mr_query(q_name, q_argc, q_argv, null_callproc, NULL);
+      status = mr_query(q_name, q_argc, q_argv, NULL, NULL);
       switch (status)
        {
        case MR_SUCCESS:
@@ -645,7 +641,7 @@ int set_final_status(struct msg *message)
   q_argc = 2;
   q_argv[0] = login;
   q_argv[1] = state;
-  if ((status = mr_query(q_name, q_argc, q_argv, null_callproc, NULL))
+  if ((status = mr_query(q_name, q_argc, q_argv, NULL, NULL))
       != MR_SUCCESS)
     {
       if (status == MR_DEADLOCK)
@@ -703,8 +699,9 @@ int set_password(struct msg *message, char *retval)
 }
 
 
-int getuserinfo(int argc, char **argv, char **qargv)
+int getuserinfo(int argc, char **argv, void *qa)
 {
+  char **qargv = qa;
   int status = SUCCESS;
   int  i;
 
@@ -716,9 +713,9 @@ int getuserinfo(int argc, char **argv, char **qargv)
     }
   else
     {
-      qargv[U_NAME] = strsave(argv[U_NAME]);
+      qargv[U_NAME] = strdup(argv[U_NAME]);
       for (i = 1; i < U_MODTIME; i++)
-       qargv[i + 1] = strsave(argv[i]);
+       qargv[i + 1] = strdup(argv[i]);
       qargv[U_MODTIME + 1] = NULL;
     }
   return status;
@@ -727,11 +724,8 @@ int getuserinfo(int argc, char **argv, char **qargv)
 
 int set_identity(struct msg *message, char *retval)
 {
-  int q_argc;                  /* Number of arguments to query */
   char *q_argv[U_END];         /* Arguments to Moira query */
-  char *q_name;                        /* Name of Moira query */
   int status = SUCCESS;                /* General purpose error status */
-  char fstype_buf[7];          /* Buffer to hold fs_type, a 16 bit number */
   char *login;                 /* The login name the user wants */
   int i;                       /* A counter */
 
@@ -777,7 +771,7 @@ int set_identity(struct msg *message, char *retval)
 
       q_argv[0] = message->db.uid;
       status = mr_query("get_user_account_by_uid", 1, q_argv,
-                       getuserinfo, (char *)q_argv);
+                       getuserinfo, q_argv);
       if (status != SUCCESS)
        {
          com_err(whoami, status, " while getting user info");
@@ -787,7 +781,7 @@ int set_identity(struct msg *message, char *retval)
       q_argv[U_STATE + 1] = "7";
       q_argv[U_SIGNATURE + 1] = "";
       status = mr_query("update_user_account", U_MODTIME + 1, q_argv,
-                       null_callproc, NULL);
+                       NULL, NULL);
       switch (status)
        {
        case MR_SUCCESS:
@@ -826,22 +820,6 @@ int set_identity(struct msg *message, char *retval)
 }
 
 
-void reg_com_err_hook(char *whoami, int code, char *fmt, caddr_t pvar)
-{
-  if (whoami)
-    {
-      fputs(whoami, stderr);
-      fputs(": ", stderr);
-    }
-  if (code)
-    fputs(error_message(code), stderr);
-  if (fmt)
-    _doprnt(fmt, pvar, stderr);
-  putc('\n', stderr);
-  fflush(stderr);
-}
-
-
 /* Find out if someone's secure instance password is set.
  * Returns UREG_ALREADY_REGISTERED if set, SUCCESS (0) if not.
  */
@@ -854,8 +832,7 @@ int get_secure(struct msg *message, char *retval)
   com_err(whoami, 0, "checking status of secure password for %s",
          message->first);
   argv[0] = message->first;
-  status = mr_query("get_user_account_by_login", 1, argv, getuserinfo,
-                   (char *)argv);
+  status = mr_query("get_user_account_by_login", 1, argv, getuserinfo, argv);
   if (status != SUCCESS)
     {
       com_err(whoami, status, " while getting user info");
@@ -871,8 +848,8 @@ int get_secure(struct msg *message, char *retval)
 
 int set_secure(struct msg *message, char *retval)
 {
-  int status, i;
-  char *argv[U_END], hostbuf[256], *bp, *p, buf[512], *passwd, *id;
+  int status;
+  char *argv[U_END], *bp, buf[512], *passwd, *id;
   KTEXT_ST creds;
   AUTH_DAT auth;
   C_Block key;
@@ -882,20 +859,19 @@ int set_secure(struct msg *message, char *retval)
   struct timeval now;
   static int inited = 0;
   static char *host;
-  extern char *krb_get_phost(char *);
+  struct utsname uts;
 
   if (!inited)
     {
       inited++;
-      if (gethostname(hostbuf, sizeof(hostbuf)) < 0)
+      if (uname(&uts) < 0)
        com_err(whoami, errno, "getting local hostname");
-      host = strsave(krb_get_phost(hostbuf));
+      host = strdup(krb_get_phost(uts.nodename));
     }
 
   com_err(whoami, 0, "setting secure passwd for %s", message->first);
   argv[0] = message->first;
-  status = mr_query("get_user_account_by_login", 1, argv, getuserinfo,
-                   (char *)argv);
+  status = mr_query("get_user_account_by_login", 1, argv, getuserinfo, argv);
   if (status != SUCCESS)
     {
       com_err(whoami, status, " while getting user info");
@@ -978,9 +954,8 @@ int set_secure(struct msg *message, char *retval)
   argv[0] = message->first;
   argv[1] = buf;
   gettimeofday(&now, NULL);
-  sprintf(buf, "%d", now.tv_sec);
-  status = mr_query("update_user_security_status", 2, argv, getuserinfo,
-                   (char *)argv);
+  sprintf(buf, "%ld", now.tv_sec);
+  status = mr_query("update_user_security_status", 2, argv, getuserinfo, argv);
   if (status != SUCCESS)
     {
       com_err(whoami, status, " while updating user status");
index 91e48b4a40ff6f2d302effe8b2ad9d62d8c943c8..a5f0d54e949dab08677e78bfafcfb61f5f23c742 100644 (file)
@@ -14,6 +14,7 @@
 #include <sys/types.h>
 #include <ctype.h>
 #include "ureg_err.h"
+#define REG_SVR
 #include "ureg_proto.h"
 
 #ifndef TRUE
@@ -37,7 +38,6 @@
 #define UID_LEN 7              /* Allow room for a 16 bit number */
 
 extern char *whoami;           /* Name of program - used by libraries */
-extern int errno;              /* Unix error number */
 
 /* This structure holds information from the Moira database that will be
    worth holding on to.  An instance of it appears in the formatted
@@ -67,14 +67,11 @@ struct msg
   struct db_data db;           /* Information from the Moira database */
 };
 
-void failure_alert();          /* Log an unexplainable failure */
-int parse_pkt();               /* Parse a packet from the client */
-int format_pkt();              /* Prepare a packet to send to client*/
-int verify_user();             /* Make sure user is allowed to register */
-int reserve_user();            /* Reserve a login for this user */
-int set_password();            /* Set this user's password */
-
-
 /* For logging successful database transactions */
 extern FILE *journal;
 
+/* prototypes from requests.c */
+void req_initialize(void);
+void get_request(struct msg *message);
+void report(int status, char *message);
+u_long cur_req_sender(void);
index c07624fef7ff64c3d1811fb4339bb607daaf8e3f..56d26140b66795ab07749c03f26eb9fe70df75ae 100644 (file)
@@ -1,43 +1,34 @@
-/*
- *      $Source$
- *      $Author$
- *      $Header$
+/* $Id$
  *
- *      Copyright (C) 1987, 1988 by the Massachusetts Institute of Technology
- *     For copying and distribution information, please see the file
- *     <mit-copyright.h>.
+ * Server for user registration with Moira and Kerberos.
  *
- *      Server for user registration with Moira and Kerberos.
+ * This file handles the processing of requests for the register
+ * server.
  *
- *      This file handles the processing of requests for the register
- *      server.
- */
-
-#ifndef lint
-static char *rcsid_requests_c = "$Header$";
-#endif lint
-
-/*
- * Before you add anything to the list of things that are #included and
- * #defined, make sure that it is not already done in reg_svr.h
+ * Copyright (C) 1987-1998 by the Massachusetts Institute of Technology
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
  */
 
 #include <mit-copyright.h>
-#include <stdio.h>
-#include <strings.h>
-#include <ctype.h>
+#include <moira.h>
+#include <moira_site.h>
+
 #include <sys/types.h>
-#include <sys/file.h>
-#include <krb.h>
-#include <des.h>
-#include <errno.h>
 #include <sys/socket.h>
+
 #include <netinet/in.h>
+#include <arpa/inet.h>
 #include <netdb.h>
-#include "moira.h"
-#include "moira_site.h"
+
+#include <errno.h>
+#include <stdio.h>
+#include <string.h>
+
 #include "reg_svr.h"
 
+RCSID("$Header$");
+
 #define NUM_REQUESTS_SAVED 100 /* Number of transactions to save */
 #define CUR_REQ (requests[cur_request_index]) /* The current request */
 #define NEXT_INDEX(x)  (x == NUM_REQUESTS_SAVED - 1) ? 0 : (x + 1)
@@ -62,6 +53,18 @@ struct request_save {
 static struct request_save requests[NUM_REQUESTS_SAVED]; /* Saved packets */
 static int cur_request_index = 0;      /* Index to the current request */
 
+void clear_req(struct request_save *req);
+void req_initialize(void);
+int handle_retransmitted(void);
+void respond(int status, char *text);
+void get_request(struct msg *message);
+void report(int status, char *message);
+int format_pkt(char *packet, int *pktlenp, U_32BIT seqno,
+              int cl_status, char *message);
+int ureg_validate_char(char *s);
+int parse_pkt(char *packet, int pktlen, struct msg *message);
+u_long cur_req_sender(void);
+
 void clear_req(struct request_save *req)
 {
   req->seqno = 0;
@@ -261,7 +264,7 @@ int ureg_validate_char(char *s)
 {
   while (*s)
     {
-      if (illegalchars[*s++])
+      if (illegalchars[(int)*s++])
        return FAILURE;
     }
   return SUCCESS;
index 4cad0af161df39074d0feaa2f6f6183d99124db5..0afe73dc47483c0f4423943170c125be575971d8 100644 (file)
@@ -1,38 +1,34 @@
-/*
- *     $Source$
- *     $Author$
- *     $Header$
+/* $Id$
  *
- *     Copyright (C) 1987 by the Massachusetts Institute of Technology
- *     For copying and distribution information, please see the file
- *     <mit-copyright.h>.
+ * This program starts the user registration server
+ * in a "clean" environment, and then waits for it to exit.
  *
- *     This program starts the user registration server
- *     in a "clean" environment, and then waits for it to exit.
+ * Copyright (C) 1987-1998 by the Massachusetts Institute of Technology
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
  */
 
-#ifndef lint
-static char *rcsid_mr_starter_c = "$Header$";
-#endif lint
-
 #include <mit-copyright.h>
+#include <moira.h>
+#include <moira_site.h>
+
+#include <sys/resource.h>
+#include <sys/wait.h>
+
 #include <errno.h>
+#include <fcntl.h>
+#include <signal.h>
 #include <stdio.h>
 #include <string.h>
-#include <sys/types.h>
-#include <sys/file.h>
-#include <sys/wait.h>
-#include <sys/signal.h>
-#include <sys/ioctl.h>
-#include <time.h>
-#include <fcntl.h>
-#include <sys/resource.h>
-#include <moira_site.h>
+#include <unistd.h>
+
+RCSID("$Header$");
 
 #define PROG   "reg_svr"
 
 int rdpipe[2];
-extern int errno;
+
+void cleanup(void);
 
 void cleanup(void)
 {
@@ -63,12 +59,9 @@ int main(int argc, char **argv)
 {
   char buf[BUFSIZ];
   FILE *log, *prog;
-  int logf, inf, i, done, pid, tty;
+  int logf, inf, i, done, pid;
   struct rlimit rl;
 
-  extern int errno;
-  extern char *sys_errlist[];
-
   struct sigaction action;
   int nfds;
 
@@ -139,7 +132,7 @@ int main(int argc, char **argv)
          if (errno && errno != EINTR)
            {
              strcpy(buf, "Unable to read from program: ");
-             strcat(buf, sys_errlist[errno]);
+             strcat(buf, strerror(errno));
              strcat(buf, "\n");
            }
          else
index 1bbdb5e09f61d8a95de426286a8959bb4059f3b6..71cfde4c53411695e36dd7a3aa0d5429dc7d73a2 100644 (file)
@@ -7,21 +7,20 @@
 #
 # Imakefile for moira regtape programs.
 
-SRCS= students.c employee.c sign.c verify.c vote.c rafnu.c
-CODE= students.pc employee.pc sign.pc verify.pc vote.pc rafnu.c
+SRCS= students.c employee.c sign.c verify.c vote.c
+CODE= students.pc employee.pc sign.pc verify.pc vote.pc
 SRCDIR = $(SRCTOP)/regtape
 #ifdef USE_CRYPT_H
-DEFINES = $(GDSSINC) -DUSE_CRYPT_H
-#else
-DEFINES = $(GDSSINC)
+DEFINES = -DUSE_CRYPT_H
 #endif
+GDSS_INC = $(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,,$(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))
+program(students, students.o,,$(CLIBS) $(SQL_LIB), $(PROGDIR))
+program(employee, employee.o,,$(CLIBS) $(SQL_LIB), $(PROGDIR))
+program(verify, verify.o,,$(LIBGDSS) $(CLIBS) $(SQL_LIB), $(PROGDIR))
+program(sign, sign.o,,$(LIBGDSS) $(CLIBS) $(SQL_LIB), $(PROGDIR))
+program(vote, vote.o,,$(CLIBS) $(SQL_LIB), $(PROGDIR))
 
 sqlfile(students)
 sqlfile(employee)
index c793b0df511f94655d597c5bfbf96b509ba8b457..b4bf328b3057aa77f0c020c277e1a2a5c68fef11 100644 (file)
@@ -1,14 +1,24 @@
-/* $Header$
+/* $Id$
+ *
+ * Load data into Moira from Personnel Office data file
+ *
+ * Copyright (C) 1990-1998 by the Massachusetts Institute of Technology
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
  */
 
-#include <stdio.h>
-#include <string.h>
-#include <ctype.h>
-#include <sys/time.h>
+#include <mit-copyright.h>
 #include <moira.h>
 #include <moira_site.h>
+
+#include <ctype.h>
+#include <stdio.h>
+#include <string.h>
+
 EXEC SQL INCLUDE sqlca;
+extern void sqlglm(char *, unsigned int *, unsigned int *);
 
+RCSID("$Header$");
 
 #define WHO 11859              /* root */
 #define PROG "emp-tape"
@@ -67,6 +77,13 @@ struct entry {
   int highid;
 };
 
+struct entry *get_next_entry(FILE *in);
+void process_entry(struct entry *e);
+void newuser(struct entry *e);
+int set_next_users_id(int limit);
+int set_next_uid(int high);
+void sqlexit(void);
+void dbmserr(char *where, int what);
 
 char *whoami;
 int newfinger = 0;
@@ -78,7 +95,7 @@ int newfinger = 0;
 int main(int argc, char **argv)
 {
   FILE *in;
-  struct entry *e, *get_next_entry();
+  struct entry *e;
   int i, wait = 0;
   char buf[BUFSIZ], *file = NULL;
   EXEC SQL BEGIN DECLARE SECTION;
@@ -98,8 +115,6 @@ int main(int argc, char **argv)
     {
       if (!strcmp(argv[i], "-w"))
        wait++;
-      else if (!strcmp(argv[i], "-D"))
-       setenv("ING_SET", "set printqry");
       else if (!strcmp(argv[i], "-n"))
        newfinger++;
       else if (file)
@@ -126,7 +141,6 @@ int main(int argc, char **argv)
 
   while ((e = get_next_entry(in)))
     {
-    again:
       process_entry(e);
       EXEC SQL COMMIT WORK;
       if (sqlca.sqlcode)
@@ -145,24 +159,10 @@ int main(int argc, char **argv)
   exit(0);
 }
 
-
-char *substr(char *buf, char *key)
-{
-  int l;
-
-  for (l = strlen(key); *buf; buf++)
-    {
-      if (!strncmp(buf, key, l))
-       return buf;
-    }
-  return NULL;
-}
-
-
 struct entry *get_next_entry(FILE *in)
 {
   static struct entry e;
-  static char buf[BUFSIZ], mid[16], eid[16];
+  static char buf[BUFSIZ], eid[16];
   static char name[LEN_NAME + 1], sname[LEN_NAME + 1], id[LEN_ID + 1];
   static char office[LEN_OFFICE + 1], phone[LEN_PHONE + 1];
   static char phone2[LEN_PHONE2 + 1], dept[LEN_DEPT + 1], title[LEN_TITLE + 1];
@@ -204,7 +204,7 @@ struct entry *get_next_entry(FILE *in)
       while (isspace(*p))
        p++;
       e.first = p;
-      if (p = strchr(e.first, ' '))
+      if ((p = strchr(e.first, ' ')))
        {
          *p = '\0';
          e.first = strtrim(e.first);
@@ -224,10 +224,10 @@ struct entry *get_next_entry(FILE *in)
   ends_sr = ends_jr = ends_iii = ends_iv = ends_ii = ends_v = 0;
   LookForSt(e.last);
   LookForO(e.last);
-  LookForJrAndIII(e.last, &ends_sr, &ends_jr, &ends_iii, &ends_iv,
-                 &ends_ii, &ends_v);
-  LookForJrAndIII(e.first, &ends_sr, &ends_jr, &ends_iii, &ends_iv,
-                 &ends_ii, &ends_v);
+  LookForJrAndIII(e.last, &ends_jr, &ends_sr, &ends_ii, &ends_iii,
+                 &ends_iv, &ends_v);
+  LookForJrAndIII(e.first, &ends_jr, &ends_sr, &ends_ii, &ends_iii,
+                 &ends_iv, &ends_v);
   FixCase(e.last);
   FixCase(e.first);
   FixCase(e.middle);
@@ -244,7 +244,7 @@ struct entry *get_next_entry(FILE *in)
 
   e.class = "MITS";
   e.highid = 0;
-  if (substr(e.title, "PROF") || substr(e.title, "LECTURE"))
+  if (strstr(e.title, "PROF") || strstr(e.title, "LECTURE"))
     e.class = "FACULTY";
   if (!strcmp(e.dept, "LINCOLN LAB"))
     {
@@ -255,13 +255,12 @@ struct entry *get_next_entry(FILE *in)
   return &e;
 }
 
-
-process_entry(struct entry *e)
+void process_entry(struct entry *e)
 {
   int changed, nochange, encrypted;
   char buf[BUFSIZ], *from, *to;
   EXEC SQL BEGIN DECLARE SECTION;
-  char *first, *last, *middle, *eid, *sid, *name, *title, *phone2, *rdept;
+  char *first, *last, *middle, *eid, *sid, *name, *rdept;
   char *rtitle, *raddr, *rhphone, *rophone, *prog;
   char class[9], oaddr[25], ophone[17], dept[128];
   char dfirst[17], dlast[17], dmiddle[17];
@@ -472,13 +471,13 @@ process_entry(struct entry *e)
 }
 
 
-newuser(struct entry *e)
+void newuser(struct entry *e)
 {
   char *from, *to;
   EXEC SQL BEGIN DECLARE SECTION;
   int id, uid, st, who;
   char *last, *first, *class, *middle, login[9], *sid, fullname[65], *prog;
-  char oaddr[81], ophone[17], dept[128], *name, *title, phone2[17];
+  char oaddr[81], ophone[17], dept[128], *name, *title;
   char *rdept, *rhphone, *rophone;
   EXEC SQL END DECLARE SECTION;
 
@@ -546,10 +545,10 @@ newuser(struct entry *e)
 }
 
 
-set_next_users_id(int limit)
+int set_next_users_id(int limit)
 {
   EXEC SQL BEGIN DECLARE SECTION;
-  int rowcount, flag, value, retval;
+  int flag, value, retval;
   EXEC SQL END DECLARE SECTION;
 
   EXEC SQL SELECT value INTO :value FROM numvalues
@@ -597,10 +596,10 @@ set_next_users_id(int limit)
   return retval;
 }
 
-set_next_uid(int high)
+int set_next_uid(int high)
 {
   EXEC SQL BEGIN DECLARE SECTION;
-  int rowcount, flag, value, retval;
+  int flag, value, retval;
   char *name;
   EXEC SQL END DECLARE SECTION;
 
@@ -652,14 +651,14 @@ set_next_uid(int high)
 }
 
 
-sqlexit(void)
+void sqlexit(void)
 {
   dbmserr(NULL, sqlca.sqlcode);
   EXEC SQL ROLLBACK WORK;
   exit(1);
 }
 
-dbmserr(char *where, int what)
+void dbmserr(char *where, int what)
 {
   char err_msg[256];
   int bufsize = 256, msglength = 0;
diff --git a/regtape/rafnu.c b/regtape/rafnu.c
deleted file mode 100644 (file)
index 4f9cbc4..0000000
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- *     $Source$
- *     $Author$
- *     $Header$
- */
-
-#ifndef lint
-static char *rcsid_rafnu_c = "$Header$";
-
-#endif lint
-
-
-#include <stdio.h>
-#include <ctype.h>
-
-FixCase(char *p)
-{
-  int cflag;
-
-  for (cflag = 0; *p; p++)
-    {
-      if (cflag && isupper(*p))
-       *p = tolower(*p);
-      else if (isspace(*p) || ispunct(*p))
-       cflag = 0;
-      else
-       cflag = 1;
-    }
-}
-
-LookForJrAndIII(char *nm, int *pends_sr, int *pends_jr, int *pends_iii,
-               int *pends_iv)
-{
-  int len = strlen(nm);
-
-  if (len >= 4 && !strcmp(nm + len - 3, " SR"))
-    {
-      *pends_sr = 1;
-      nm[len - 3] = '\0';
-    }
-  else if (len >= 4 && !strcmp(nm + len - 3, " JR"))
-    {
-      *pends_jr = 1;
-      nm[len - 3] = '\0';
-    }
-  else if (len >= 4 && !strcmp(nm + len - 3, " IV"))
-    {
-      *pends_iv = 1;
-      nm[len - 3] = '\0';
-    }
-  else if (len >= 5 && !strcmp(nm + len - 4, " SR."))
-    {
-      *pends_sr = 1;
-      nm[len - 4] = '\0';
-    }
-  else if (len >= 5 && !strcmp(nm + len - 4, " JR."))
-    {
-      *pends_jr = 1;
-      nm[len - 4] = '\0';
-    }
-  else if (len >= 5 && !strcmp(nm + len - 4, " III"))
-    {
-      *pends_iii = 1;
-      nm[len - 4] = '\0';
-    }
-}
-
-LookForSt(char *nm)                    /* ST PIERRE, etc. */
-{
-  char temp[256];
-
-  if (!strcmp(nm, "ST "))
-    {
-      strcpy(temp, nm + 3);
-      strcpy(nm, "ST. ");
-      strcat(nm, temp);
-    }
-}
-
-LookForO(char *nm)                     /* O BRIEN, etc. */
-{
-  if (!strcmp(nm, "O ") && isalpha(nm[2]))
-    nm[1] = '\'';
-}
index a3afd7be7c1906460d5fe9b3a4122c8cf5dbd665..669bd067726455a647b1c5eb5e58205f40a1af60 100644 (file)
@@ -1,20 +1,28 @@
-/* $Header$
+/* $Id$
  *
  * This program will bulk sign user records in the database.
+ *
+ * Copyright (C) 1992-1998 by the Massachusetts Institute of Technology
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
  */
 
-#include <stdio.h>
-#include <string.h>
-#include <ctype.h>
-#include <sys/time.h>
+#include <mit-copyright.h>
 #include <moira.h>
 #include <moira_site.h>
-#include <des.h>
+
+#include <ctype.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
 #include <krb.h>
-#include <krb_err.h>
 #include <gdss.h>
+
 EXEC SQL INCLUDE sqlca;
 
+RCSID("$Header$");
 
 char *program;
 
@@ -38,8 +46,6 @@ int main(int argc, char **argv)
     {
       if (!strcmp(argv[i], "-w"))
        wait++;
-      else if (!strcmp(argv[i], "-D"))
-       setenv("ING_SET", "set printqry");
       else
        fprintf(stderr, "Usage: %s [-w] [-D]\n", argv[0]);
     }
@@ -100,7 +106,7 @@ int main(int argc, char **argv)
       if (login[0] == '#' || !isdigit(mid[0]))
        continue;
       sprintf(buf, "%d:%s:%s", id, strtrim(login), strtrim(mid));
-      sq_save_data(sq, strsave(buf));
+      sq_save_data(sq, strdup(buf));
       found++;
     }
   EXEC SQL CLOSE c;
index 16b32a18cebadaee985cd4251cb6799a2e08e8a7..43d57f40ad87b91258f57165cf851e62dc1794e9 100644 (file)
@@ -1,14 +1,26 @@
-/* $Header$
+/* $Id$
+ *
+ * Load data into Moira from Registrar's Office data file
+ *
+ * Copyright (C) 1990-1998 by the Massachusetts Institute of Technology
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
  */
 
-#include <stdio.h>
-#include <string.h>
-#include <ctype.h>
-#include <sys/time.h>
+#include <mit-copyright.h>
 #include <moira.h>
 #include <moira_site.h>
+
+#include <ctype.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <time.h>
+
 EXEC SQL INCLUDE sqlca;
+extern void sqlglm(char *, unsigned int *, unsigned int *);
 
+RCSID("$Header$");
 
 #define WHO 11859              /* root */
 #define PROG "stu-tape"
@@ -73,17 +85,24 @@ struct entry {
   char *class;
 };
 
-
 char *whoami;
 int newfinger = 0;
 
+struct entry *get_next_entry(FILE *in);
+void process_entry(struct entry *e);
+void newuser(struct entry *e);
+int set_next_users_id(int limit);
+int set_next_uid(int limit);
+void sqlexit(void);
+void dbmserr(char *where, int what);
+
 #define SQL_DUPLICATE -2112
 #define sqlfail() (sqlca.sqlcode && sqlca.sqlcode != 1403)
 
 int main(int argc, char **argv)
 {
   FILE *in;
-  struct entry *e, *get_next_entry();
+  struct entry *e;
   int i, wait = 0;
   char buf[BUFSIZ], *file = NULL;
   EXEC SQL BEGIN DECLARE SECTION;
@@ -103,8 +122,6 @@ int main(int argc, char **argv)
     {
       if (!strcmp(argv[i], "-w"))
        wait++;
-      else if (!strcmp(argv[i], "-D"))
-       setenv("ING_SET", "set printqry");
       else if (!strcmp(argv[i], "-n"))
        newfinger++;
       else if (file)
@@ -131,7 +148,6 @@ int main(int argc, char **argv)
 
   while ((e = get_next_entry(in)))
     {
-    again:
       process_entry(e);
       EXEC SQL COMMIT WORK;
       if (sqlca.sqlcode)
@@ -154,7 +170,7 @@ int main(int argc, char **argv)
 struct entry *get_next_entry(FILE *in)
 {
   static struct entry e;
-  static char buf[BUFSIZ], eid[16], classbuf[10], titlebuf[12];
+  static char buf[BUFSIZ], eid[16], classbuf[10];
   static char name[LEN_NAME + 1], id[LEN_ID + 1], course[LEN_COURSE + 1];
   static char year[LEN_YEAR + 1], address[LEN_ADDRESS + 1];
   static char dorm_room[LEN_DORM_ROOM + 1], city[LEN_CITY + 1];
@@ -212,7 +228,7 @@ struct entry *get_next_entry(FILE *in)
       while (isspace(*p))
        p++;
       e.first = p;
-      if (p = strchr(e.first, ' '))
+      if ((p = strchr(e.first, ' ')))
        {
          *p = '\0';
          e.first = strtrim(e.first);
@@ -270,12 +286,12 @@ struct entry *get_next_entry(FILE *in)
 }
 
 
-process_entry(struct entry *e)
+void process_entry(struct entry *e)
 {
   int changed, nochange, encrypted;
   char buf[BUFSIZ], *from, *to;
   EXEC SQL BEGIN DECLARE SECTION;
-  char *first, *last, *middle, *eid, *title, *sid, *name, *rname, *rdept;
+  char *first, *last, *middle, *eid, *sid, *name, *rdept;
   char *rtitle, *rophone, *rhphone, *prog;
   char class[9], haddr[128], hphone[33], ophone[33], dept[33], raddr[128];
   char dfirst[17], dlast[17], dmiddle[17];
@@ -562,8 +578,7 @@ process_entry(struct entry *e)
     }
 }
 
-
-newuser(struct entry *e)
+void newuser(struct entry *e)
 {
   char buf[512], *from, *to;
   EXEC SQL BEGIN DECLARE SECTION;
@@ -685,7 +700,7 @@ newuser(struct entry *e)
 int set_next_users_id(int limit)
 {
   EXEC SQL BEGIN DECLARE SECTION;
-  int rowcount, flag, value, retval;
+  int flag, value, retval;
   EXEC SQL END DECLARE SECTION;
 
   EXEC SQL SELECT value INTO :value FROM numvalues
@@ -736,7 +751,7 @@ int set_next_users_id(int limit)
 int set_next_uid(int limit)
 {
   EXEC SQL BEGIN DECLARE SECTION;
-  int rowcount, flag, value, retval;
+  int flag, value, retval;
   EXEC SQL END DECLARE SECTION;
 
   EXEC SQL SELECT value INTO :value FROM numvalues
@@ -782,14 +797,14 @@ int set_next_uid(int limit)
 }
 
 
-sqlexit(void)
+void sqlexit(void)
 {
   dbmserr(NULL, sqlca.sqlcode);
   EXEC SQL ROLLBACK WORK;
   exit(1);
 }
 
-dbmserr(char *where, int what)
+void dbmserr(char *where, int what)
 {
   char err_msg[256];
   int bufsize = 256, msglength = 0;
index d5d2808941318d44a4545a84c188b42848ca1f82..99593eb318ebb8ae0b16caa767c619764cd4bfdd 100644 (file)
@@ -1,20 +1,29 @@
-/* $Header$
+/* $Id$
  *
  * This program will verify signatures on user records in the database.
+ *
+ * Copyright (C) 1993-1998 by the Massachusetts Institute of Technology
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
  */
 
-#include <stdio.h>
-#include <string.h>
-#include <ctype.h>
-#include <sys/time.h>
+#include <mit-copyright.h>
 #include <moira.h>
 #include <moira_site.h>
-#include <des.h>
+
+#include <ctype.h>
+#include <stdio.h>
+#include <string.h>
+#include <unistd.h>
+
 #include <krb.h>
-#include <krb_err.h>
 #include <gdss.h>
+
 EXEC SQL INCLUDE sqlca;
 
+RCSID("$Header$");
+
+void hex_dump(unsigned char *p);
 
 char *program;
 
@@ -27,7 +36,7 @@ int main(int argc, char **argv)
   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;
+  int timestamp, sms;
   EXEC SQL END DECLARE SECTION;
 
   initialize_sms_error_table();
@@ -43,8 +52,6 @@ int main(int argc, char **argv)
        wait++;
       else if (!strcmp(argv[i], "-d"))
        debug++;
-      else if (!strcmp(argv[i], "-D"))
-       setenv("ING_SET", "set printqry");
       else if (!strcmp(argv[i], "-fix"))
        fix++;
       else if (argv[i][0] == '-')
@@ -113,7 +120,7 @@ int main(int argc, char **argv)
          if (status)
            com_err(program, gdss2et(status), "verifying user %s", login);
          if (fix && status == GDSS_E_BADSIG)
-           sq_save_data(sq, strsave(buf));
+           sq_save_data(sq, strdup(buf));
          if (wait)
            {
              printf("Next");
@@ -130,7 +137,7 @@ int main(int argc, char **argv)
                *strchr(login, ':') = '\0';
            again:
              com_err(program, 0, "fixing sig for %s", login);
-             status = GDSS_Sign(data, strlen(data), sigbuf, &si);
+             status = GDSS_Sign(data, strlen(data), sigbuf);
              if (status)
                {
                  com_err(program, gdss2et(status), "signing data");
@@ -253,7 +260,7 @@ int main(int argc, char **argv)
 }
 
 
-hex_dump(unsigned  char *p)
+void hex_dump(unsigned  char *p)
 {
   printf("Size: %d\n", strlen(p));
   while (strlen(p) >= 8)
index 8593800a1cf7a2eb8bfdbd95aad788bc64b6ecbc..a66b983ec872fad54455e63a25da0ae0828d5d4f 100644 (file)
@@ -1,14 +1,21 @@
-/* $Header$
+/* $Id$
+ *
+ * Copyright (C) 1993-1998 by the Massachusetts Institute of Technology
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
  */
 
-#include <stdio.h>
-#include <string.h>
-#include <ctype.h>
-#include <sys/time.h>
+#include <mit-copyright.h>
 #include <moira.h>
 #include <moira_site.h>
+
+#include <ctype.h>
+#include <stdio.h>
+#include <string.h>
+
 EXEC SQL INCLUDE sqlca;
 
+RCSID("$Header$");
 
 struct entry {
   char *line;
@@ -19,11 +26,13 @@ struct entry {
 char *whoami;
 int debug;
 
+struct entry *get_next_entry(FILE *in);
+int process_entry(struct entry *e);
 
 int main(int argc, char **argv)
 {
   FILE *in;
-  struct entry *e, *get_next_entry();
+  struct entry *e;
   int i, wait = 0;
   char buf[BUFSIZ], *file = NULL, *p, *p1, *db = "moira";
 
@@ -41,8 +50,6 @@ int main(int argc, char **argv)
     {
       if (!strcmp(argv[i], "-w"))
        wait++;
-      else if (!strcmp(argv[i], "-D"))
-       setenv("ING_SET", "set printqry");
       else if (!strcmp(argv[i], "-d"))
        debug = 1;
       else if (file)
@@ -89,8 +96,6 @@ int main(int argc, char **argv)
   exit(0);
 }
 
-
-
 struct entry *get_next_entry(FILE *in)
 {
   static struct entry e;
@@ -106,7 +111,6 @@ struct entry *get_next_entry(FILE *in)
   return &e;
 }
 
-
 int process_entry(struct entry *e)
 {
   EXEC SQL BEGIN DECLARE SECTION;
@@ -119,7 +123,7 @@ int process_entry(struct entry *e)
   EXEC SQL SELECT login INTO :login FROM users WHERE clearid = :id;
   if (sqlca.sqlcode)
     {
-      fprintf(stderr, "Error %d on %s\n", sqlca.sqlcode, e->line);
+      fprintf(stderr, "Error %ld on %s\n", sqlca.sqlcode, e->line);
       return -1;
     }
   strncpy(e->login, login, 8);
index a2c5b80decb24778fd02d94ae673dcf50b7e2f02..c14272e4e291286cd4a7b050db84acd63e7e8f24 100644 (file)
@@ -8,7 +8,7 @@
 # Imakefile for server directory.
 #
 
-DEFINES= -I. $(GDSSINC)
+GDSS_INC=$(GDSSINC)
 
 SRCS = startmoira.c mr_main.c mr_sauth.c mr_scall.c \
        mr_srvdata.c mr_shutdown.c mr_util.c \
index eb49781f8b6e15534e81569112f4c750f2d86cca..352b1a697ab70131597910c2af648afc32523857 100644 (file)
@@ -1,21 +1,23 @@
-/*
- *     $Header$
+/* $Id$
  *
- *     Copyright (C) 1989, 1990 by the Massachusetts Institute of Technology
- *     For copying and distribution information, please see the file
- *     <mit-copyright.h>.
+ * Keep a cache of name/id mappings
+ *
+ * Copyright (C) 1989-1998 by the Massachusetts Institute of Technology
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
  */
 
-#ifndef lint
-static char *rcsid_cache_dc = "$Header$";
-#endif lint
-
 #include <mit-copyright.h>
-#include <string.h>
 #include "mr_server.h"
 #include "query.h"
+
+#include <stdlib.h>
+#include <string.h>
+
 EXEC SQL INCLUDE sqlca;
 
+RCSID("$Header$");
+
 EXEC SQL WHENEVER SQLERROR DO dbmserr();
 
 extern char *whoami;
@@ -40,6 +42,7 @@ static int cachesize;
 /* statistics counters */
 int cachehits = 0, cachemisses = 0;
 
+int hashname(char *name, enum tables type);
 
 /* Name hash function. */
 
@@ -205,7 +208,7 @@ int id_to_name(int id, enum tables type, char **name)
       if (i->id != id || type != i->type)
        continue;
       free(*name);
-      *name = strsave(i->name);
+      *name = strdup(i->name);
       cachehits++;
       i->next->prev = i->prev;
       i->prev->next = i->next;
@@ -249,7 +252,7 @@ int id_to_name(int id, enum tables type, char **name)
     {
       free(*name);
       sprintf(iname, "#%d", j);
-      *name = strsave(iname);
+      *name = strdup(iname);
       return MR_NO_MATCH;
     }
   if (sqlca.sqlerrd[2] > 1)
@@ -257,7 +260,7 @@ int id_to_name(int id, enum tables type, char **name)
   if (sqlca.sqlcode)
     return MR_DBMS_ERR;
   free(*name);
-  *name = strsave(strtrim(iname));
+  *name = strdup(strtrim(iname));
   if (**name == '#' && type != USERS_TABLE)
     return MR_SUCCESS;
   if (cachesize < CACHESIZE)
index 8808061203ecaed14a026c98e3b666996a2df91f..5b86c29b06776214f2c454b2895cc775344e6c2a 100644 (file)
@@ -1,28 +1,26 @@
-/*
- *     $Source$
- *     $Author$
- *     $Header$
+/* $Id$
  *
- *     Copyright (C) 1989 by the Massachusetts Institute of Technology
- *     For copying and distribution information, please see the file
- *     <mit-copyright.h>.
+ * Deal with incremental updates
  *
+ * Copyright (C) 1989-1998 by the Massachusetts Institute of Technology
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
  */
 
-#ifndef lint
-static char *rcsid_increment_dc = "$Header$";
-#endif lint
-
 #include <mit-copyright.h>
-#include <moira.h>
-#include <fcntl.h>
-#include <unistd.h>
-#include <signal.h>
 #include "mr_server.h"
 #include "query.h"
 #include "qrtn.h"
+
+#include <signal.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
 EXEC SQL INCLUDE sqlca;
 
+RCSID("$Header$");
+
 extern char *whoami;
 extern char *table_name[];
 extern int num_tables;
@@ -362,8 +360,8 @@ void incremental_update(void)
            break;
          c = malloc(sizeof(struct inc_cache));
          c->next = cache;
-         c->table = strsave(strtrim(tab));
-         c->service = strsave(strtrim(serv));
+         c->table = strdup(strtrim(tab));
+         c->service = strdup(strtrim(serv));
          cache = c;
        }
       EXEC SQL CLOSE inc;
@@ -465,7 +463,7 @@ char **copy_argv(char **argv, int argc)
 {
   char **ret = malloc(sizeof(char *) * argc);
   while (--argc >= 0)
-    ret[argc] = strsave(strtrim(argv[argc]));
+    ret[argc] = strdup(strtrim(argv[argc]));
   return ret;
 }
 
index 55a1324727830a01e8416e03c3736069b36a5956..80c9ccc230458b1f8a5672e7635d0db05fcabaed 100644 (file)
@@ -1,38 +1,40 @@
-/*
- *     $Source$
- *     $Author$
- *     $Header$
+/* $Id$
  *
- *     Copyright (C) 1987 by the Massachusetts Institute of Technology
- *     For copying and distribution information, please see the file
- *     <mit-copyright.h>.
+ * Glue routines to allow the database stuff to be linked in to
+ * a program expecting a library level interface.
  *
- *     Glue routines to allow the database stuff to be linked in to
- *     a program expecting a library level interface.
+ * Copyright (C) 1987-1998 by the Massachusetts Institute of Technology
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
  */
 
-#ifndef lint
-static char *rcsid_mr_glue_c = "$Header$";
-#endif lint
-
 #include <mit-copyright.h>
-#include <sys/types.h>
-#include <sys/signal.h>
-#include <sys/wait.h>
-#include <krb_et.h>
-#include <pwd.h>
 #include "mr_server.h"
 #include "query.h"
 
+#include <sys/wait.h>
+
+#include <errno.h>
+#include <pwd.h>
+#include <signal.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+extern char *krb_get_lrealm(char *, int);
+
+RCSID("$Header$");
+
 static int already_connected = 0;
 
 #define CHECK_CONNECTED { if (!already_connected) return MR_NOT_CONNECTED; }
 
 static client pseudo_client;
-extern int errno;
 extern char *whoami;
 extern time_t now;
-void reapchild();
+
+void reapchild(void);
+int callback(int argc, char **argv, void *arg);
 
 int mr_connect(char *server)
 {
@@ -85,7 +87,7 @@ int mr_auth(char *prog)
 {
   struct passwd *pw;
   extern char *krb_realm;
-  char buf[1024], *strsave();
+  char buf[1024];
 
   CHECK_CONNECTED;
   pw = getpwuid(getuid());
@@ -109,19 +111,21 @@ int mr_auth(char *prog)
 }
 
 struct hint {
-  int (*proc)();
+  int (*proc)(int, char **, void *);
   char *hint;
 };
 
-callback(int argc, char **argv, struct hint *arg)
+int callback(int argc, char **argv, void *arg)
 {
+  struct hint *hint = arg;
   if (mr_trim_args(argc, argv) == MR_NO_MEM)
     com_err(whoami, MR_NO_MEM, "while trimmming args");
-  (*arg->proc)(argc, argv, arg->hint);
+  return (*hint->proc)(argc, argv, hint->hint);
 }
 
 
-int mr_query(char *name, int argc, char **argv, int (*callproc)(), char *callarg)
+int mr_query(char *name, int argc, char **argv,
+            int (*callproc)(int, char **, void *), void *callarg)
 {
   struct hint hints;
 
@@ -141,32 +145,6 @@ int mr_access(char *name, int argc, char **argv)
                         mr_copy_args(argv, argc));
 }
 
-int mr_query_internal(int argc, char **argv, int (*callproc)(), char *callarg)
-{
-  struct hint hints;
-
-  time(&now);
-  hints.proc = callproc;
-  hints.hint = callarg;
-  next_incremental();
-  return mr_process_query(&pseudo_client, argv[0], argc - 1,
-                         mr_copy_args(argv + 1, argc - 1), callback,
-                         (char *)&hints);
-}
-
-int mr_access_internal(int argc, char **argv)
-{
-  time(&now);
-  return mr_check_access(&pseudo_client, argv[0], argc - 1,
-                        mr_copy_args(argv + 1, argc - 1));
-}
-
-mr_shutdown(char *why)
-{
-  fprintf(stderr, "Sorry, not implemented\n");
-}
-
-
 /* trigger_dcm is also used as a followup routine to the
  * set_server_host_override query, hence the two dummy arguments.
  */
@@ -176,7 +154,7 @@ struct query pseudo_query = {
   "tdcm",
 };
 
-int trigger_dcm(int dummy0, int dummy1, client *cl)
+int trigger_dcm(struct query *q, char *argv[], client *cl)
 {
   int pid, status;
   char prog[128];
index 118b3f2f390aba2d9d351f48ef3bc531aab92b81..aaa4896a11cf5e330ca121a55d828884cf57577f 100644 (file)
@@ -1,38 +1,37 @@
-/*
- *     $Source$
- *     $Author$
- *     $Header$
- *
- *     Copyright (C) 1987 by the Massachusetts Institute of Technology
- *     For copying and distribution information, please see the file
- *     <mit-copyright.h>.
- *
- *     Moira server process.
+/* $Id$
  *
- *     Most of this is stolen from ../gdb/tsr.c
+ * Moira server process.
  *
- *     You are in a maze of twisty little finite automata, all different.
- *     Let the reader beware.
+ * Copyright (C) 1987-1998 by the Massachusetts Institute of Technology
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
  *
  */
 
-static char *rcsid_mr_main_c = "$Header$";
-
 #include <mit-copyright.h>
-#include <string.h>
-#include <stdio.h>
+#include "mr_server.h"
+
+#include <sys/socket.h>
+#include <sys/stat.h>
 #include <sys/types.h>
-#include <sys/errno.h>
-#include <sys/signal.h>
+#include <sys/utsname.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 <netinet/in.h>
 #include <arpa/inet.h>
 
+#include <ctype.h>
+#include <errno.h>
+#include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+RCSID("$Header$");
+
+extern char *krb_get_lrealm(char *, int);
+
 extern CONNECTION newconn, listencon;
 
 extern int nclients;
@@ -48,13 +47,15 @@ extern TUPLE client_tuple;
 extern char *whoami;
 extern char buf1[BUFSIZ];
 extern char *takedown;
-extern int errno;
 extern FILE *journal;
 
 extern time_t now;
 
-char hostbuf[BUFSIZ], *host;
+char *host;
 
+void reapchild(int x);
+void godormant(int x);
+void gowakeup(int x);
 int do_listen(char *port);
 void do_reset_listen(void);
 void clist_append(client *cp);
@@ -77,6 +78,7 @@ int main(int argc, char **argv)
   char *port, *p;
   extern char *database;
   struct stat stbuf;
+  struct utsname uts;
 
   whoami = argv[0];
   /*
@@ -146,12 +148,12 @@ int main(int argc, char **argv)
   /*
    * Get moira server hostname for authentication
    */
-  if (gethostname(hostbuf, sizeof(hostbuf)) < 0)
+  if (uname(&uts) < 0)
     {
       com_err(whoami, errno, "Unable to get local hostname");
       exit(1);
     }
-  host = canonicalize_hostname(strsave(hostbuf));
+  host = canonicalize_hostname(strdup(uts.nodename));
   for (p = host; *p && *p != '.'; p++)
     {
       if (isupper(*p))
@@ -186,7 +188,7 @@ int main(int argc, char **argv)
   op_list = create_list_of_operations(1, listenop);
 
   com_err(whoami, 0, "started (pid %d)", getpid());
-  com_err(whoami, 0, rcsid_mr_main_c);
+  com_err(whoami, 0, rcsid);
   if (dormant != ASLEEP)
     send_zgram("MOIRA", "server started");
   else
@@ -369,7 +371,7 @@ int new_connection(void)
   cp->con = newconn;
   cp->id = counter++;
   cp->args = NULL;
-  cp->clname[0] = NULL;
+  cp->clname[0] = '\0';
   cp->reply.mr_argv = NULL;
   cp->first = NULL;
   cp->last = NULL;
index bb35f2113423c544e24243e7815a66fc46b017f9..d2c61e248af2be16cf0a2610e9a77359e3af07cd 100644 (file)
@@ -1,30 +1,27 @@
-/*
- *     $Source$
- *     $Author$
- *     $Header$
+/* $Id$
+ *
+ * Handle server side of authentication
  *
- *     Copyright (C) 1987 by the Massachusetts Institute of Technology
- *     For copying and distribution information, please see the file
- *     <mit-copyright.h>.
+ * Copyright (C) 1987-1998 by the Massachusetts Institute of Technology
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
  *
  */
 
-#ifndef lint
-static char *rcsid_mr_sauth_c = "$Header$";
-#endif lint
-
 #include <mit-copyright.h>
-#include <string.h>
 #include "mr_server.h"
-#include <ctype.h>
-#include <krb_et.h>
-#include <moira.h>
-#include <time.h>
 
-extern char *whoami, *host;
+#include <sys/types.h>
 
-/* from libmoira */
-char *kname_unparse(char *, char *, char *);
+#include <arpa/inet.h>
+#include <netinet/in.h>
+
+#include <stdlib.h>
+#include <string.h>
+
+RCSID("$Header$");
+
+extern char *whoami, *host;
 
 typedef struct _replay_cache {
   KTEXT_ST auth;
@@ -47,7 +44,6 @@ void do_auth(client *cl)
   KTEXT_ST auth;
   AUTH_DAT ad;
   int status, ok;
-  extern int errno;
   replay_cache *rc, *rcnew;
   time_t now;
 
index 2b4a7c4dc583e5c493b53be9619b39c3436b7c70..acf17e470e61c75924971074fecf6c1eebfd48b0 100644 (file)
@@ -1,40 +1,46 @@
-/*
- *     $Source$
- *     $Author$
- *     $Header$
+/* $Id$
+ *
+ * Do RPC
  *
- *     Copyright (C) 1987 by the Massachusetts Institute of Technology
- *     For copying and distribution information, please see the file
- *     <mit-copyright.h>.
+ * Copyright (C) 1987-1998 by the Massachusetts Institute of Technology
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
  *
  */
 
-#ifndef lint
-static char *rcsid_mr_scall_c = "$Header$";
-#endif lint
-
 #include <mit-copyright.h>
-#include <sys/types.h>
+#include "mr_server.h"
+#include "query.h"
+
 #include <sys/stat.h>
-#include <sys/file.h>
-#include <fcntl.h>
-#include <string.h>
-#include <netinet/in.h>
+#include <sys/types.h>
+
 #include <arpa/inet.h>
-#include <krb.h>
+#include <netinet/in.h>
+
 #include <errno.h>
-#include "mr_server.h"
-#include "query.h"
+#include <fcntl.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+RCSID("$Header$");
+
 extern char buf1[];
 extern int nclients;
 extern char *whoami;
-extern int errno;
 
-extern void clist_delete(), do_auth(), do_shutdown();
-void do_call();
 extern int dbms_errno, mr_errcode;
 static int row_count;
 
+void do_call(client *cl);
+void free_rtn_tuples(client *cp);
+int retr_callback(int argc, char **argv, void *p_cp);
+int list_users(int (*callbk)(int, char **, void *), char *callarg);
+void do_retr(client *cl);
+void do_access(client *cl);
+void get_motd(client *cl);
+
 /* Put this in a variable so that we can patch it if necessary */
 int max_row_count = 4096;
 
@@ -152,7 +158,7 @@ void do_call(client *cl)
       return;
 
     case MR_DO_UPDATE:
-      trigger_dcm(0, 0, cl);
+      trigger_dcm(NULL, NULL, cl);
       return;
 
     case MR_MOTD:
@@ -161,7 +167,7 @@ void do_call(client *cl)
     }
 }
 
-free_rtn_tuples(client *cp)
+void free_rtn_tuples(client *cp)
 {
   returned_tuples *temp;
   for (temp = cp->first; temp && OP_DONE(temp->op); )
@@ -178,9 +184,9 @@ free_rtn_tuples(client *cp)
   cp->first = temp;
 }
 
-retr_callback(int argc, char **argv, char *p_cp)
+int retr_callback(int argc, char **argv, void *p_cp)
 {
-  client *cp = (client *)p_cp;
+  client *cp = p_cp;
   mr_params *arg_tmp;
   returned_tuples *tp;
   OPERATION op_tmp;
@@ -190,15 +196,15 @@ retr_callback(int argc, char **argv, char *p_cp)
   if (row_count++ >= max_row_count)
     {
       dbms_errno = mr_errcode = MR_NO_MEM;
-      return;
+      return MR_ABORT;
     }
 
   /*
    * This takes too much advantage of the fact that
    * serialization of the data happens during the queue operation.
    */
-  arg_tmp = db_alloc(sizeof(mr_params));
-  tp = db_alloc(sizeof(returned_tuples));
+  arg_tmp = malloc(sizeof(mr_params));
+  tp = malloc(sizeof(returned_tuples));
   nargv = malloc(argc * sizeof(char *));
 
   op_tmp = create_operation();
@@ -235,9 +241,10 @@ retr_callback(int argc, char **argv, char *p_cp)
   reset_operation(op_tmp);
   initialize_operation(op_tmp, mr_start_send, (char *)arg_tmp, NULL);
   queue_operation(cp->con, CON_OUTPUT, op_tmp);
+  return MR_CONT;
 }
 
-int list_users(int (*callbk)(), char *callarg)
+int list_users(int (*callbk)(int, char **, void *), char *callarg)
 {
   char *argv[6];
   char buf[30];
@@ -245,7 +252,6 @@ int list_users(int (*callbk)(), char *callarg)
   int i;
   extern client **clients;
   char *cp;
-  char *ctime();
 
   for (i = 0; i < nclients; i++)
     {
@@ -268,7 +274,7 @@ int list_users(int (*callbk)(), char *callarg)
   return 0;
 }
 
-do_retr(client *cl)
+void do_retr(client *cl)
 {
   char *queryname;
 
@@ -296,7 +302,7 @@ do_retr(client *cl)
       cl->reply.mr_status = mr_process_query(cl, queryname,
                                             cl->args->mr_argc - 1,
                                             cl->args->mr_argv + 1,
-                                            retr_callback, (char *)cl);
+                                            retr_callback, cl);
     }
   if (row_count >= max_row_count)
     {
@@ -308,7 +314,7 @@ do_retr(client *cl)
     com_err(whoami, 0, "Query complete.");
 }
 
-do_access(client *cl)
+void do_access(client *cl)
 {
   if (cl->args->mr_argc < 1)
     {
@@ -335,7 +341,7 @@ struct query pseudo_query = {
   "tdcm",
 };
 
-int trigger_dcm(int dummy0, int dummy1, client *cl)
+int trigger_dcm(struct query *q, char *argv[], client *cl)
 {
   int pid;
   char prog[128];
@@ -363,7 +369,7 @@ int trigger_dcm(int dummy0, int dummy1, client *cl)
 }
 
 
-get_motd(client *cl)
+void get_motd(client *cl)
 {
   int motd, len;
   char buffer[1024];
index ebb96b9dc8a223587c01e0bc098838b82698d087..80306cb3cf5819d17d98b20d2609503795178d36 100644 (file)
@@ -1,23 +1,20 @@
-/*
- *     $Source$
- *     $Author$
- *     $Header$
- *
- *     Copyright (C) 1987 by the Massachusetts Institute of Technology
+/* $Id$
  *
+ * Copyright (C) 1987-1998 by the Massachusetts Institute of Technology
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
  */
 
-#include <sys/types.h>
-#include <sys/uio.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include "mr_proto.h"
+#include <moira.h>
+#include <mr_proto.h>
 #include <moira_site.h>
-#include <krb.h>
-#include <com_err.h>
-#include <stdlib.h>
+
+#include <netinet/in.h>
+
 #include <stdarg.h>
 
+#include <krb.h>
+
 typedef struct returned_tuples {
   struct returned_tuples *next;
   OPERATION op;
@@ -115,34 +112,24 @@ extern time_t inc_started, now;
 
 #define SQL_NO_MATCH 1403 /* oracle, not ingres (= 100) */
 
+/* types needed for prototypes */
+struct query;
+struct validate;
+struct valobj;
+
 /* 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 initialize_operation(OPERATION, int (*init_function)(OPERATION, HALF_CONNECTION, void *),
+                        char *, int (*cancel_function)(HALF_CONNECTION, void *));
 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);
-int sq_save_data(struct save_queue *sq, void *data);
-int sq_save_unique_data(struct save_queue *sq, void *data);
-int 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);
@@ -155,13 +142,14 @@ 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 (*action)(int, char *[], void *), void *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 find_member(char *list_type, int list_id, client *cl);
-int do_for_all_rows(char *query, int count, int (*action)(), int actarg);
-int build_qual(char *fmt, int argc, char *argv[], char *qual);
+int do_for_all_rows(char *query, int count,
+                   int (*action)(int, char *[], void *), void *actarg);
+void build_qual(char *fmt, int argc, char *argv[], char *qual);
 
 
 /* prototyoes from qsupport.dc */
@@ -180,7 +168,7 @@ void do_auth(client *cl);
 
 /* prototypes from mr_scall.c */
 void do_client(client *cp);
-int trigger_dcm(int dummy0, int dummy1, client *cl);
+int trigger_dcm(struct query *q, char *argv[], client *cl);
 
 /* prototypes from mr_shutdown.c */
 void sigshut(int);
@@ -192,3 +180,123 @@ void log_args(char *tag, int version, int argc, char **argv);
 void mr_com_err(const char *whoami, long code, const char *fmt, va_list pvar);
 int mr_trim_args(int argc, char **argv);
 char **mr_copy_args(char **argv, int argc);
+
+/* prototypes from qaccess.pc */
+int access_user(struct query *q, char *argv[], client *cl);
+int access_login(struct query *q, char *argv[], client *cl);
+int access_list(struct query *q, char *argv[], client *cl);
+int access_visible_list(struct query *q, char *argv[], client *cl);
+int access_vis_list_by_name(struct query *q, char *argv[], client *cl);
+int access_member(struct query *q, char *argv[], client *cl);
+int access_qgli(struct query *q, char *argv[], client *cl);
+int access_service(struct query *q, char *argv[], client *cl);
+int access_filesys(struct query *q, char *argv[], client *cl);
+int access_host(struct query *q, char *argv[], client *cl);
+int access_ahal(struct query *q, char *argv[], client *cl);
+int access_snt(struct query *q, char *argv[], client *cl);
+
+/* prototypes from qfollow.pc */
+int followup_fix_modby(struct query *q, struct save_queue *sq,
+                      struct validate *v, int (*action)(int, char **, void *),
+                      void *actarg, client *cl);
+int followup_gpob(struct query *q, struct save_queue *sq, struct validate *v,
+                 int (*action)(int, char **, void *), void *actarg,
+                 client *cl);
+int followup_glin(struct query *q, struct save_queue *sq, struct validate *v,
+                 int (*action)(int, char **, void *), void *actarg,
+                 client *cl);
+int followup_gzcl(struct query *q, struct save_queue *sq, struct validate *v,
+                 int (*action)(int, char **, void *), void *actarg,
+                 client *cl);
+int followup_gsha(struct query *q, struct save_queue *sq, struct validate *v,
+                 int (*action)(int, char **, void *), void *actarg,
+                 client *cl);
+int followup_gqot(struct query *q, struct save_queue *sq, struct validate *v,
+                 int (*action)(int, char **, void *), void *actarg,
+                 client *cl);
+int followup_gpce(struct query *q, struct save_queue *sq, struct validate *v,
+                 int (*action)(int, char **, void *), void *actarg,
+                 client *cl);
+int followup_guax(struct query *q, struct save_queue *sq, struct validate *v,
+                 int (*action)(int, char **, void *), void *actarg,
+                 client *cl);
+int followup_gsnt(struct query *q, struct save_queue *sq, struct validate *v,
+                 int (*action)(int, char **, void *), void *actarg,
+                 client *cl);
+int followup_ghst(struct query *q, struct save_queue *sq, struct validate *v,
+                 int (*action)(int, char **, void *), void *actarg,
+                 client *cl);
+
+int followup_ausr(struct query *q, char *argv[], client *cl);
+int followup_aqot(struct query *q, char *argv[], client *cl);
+int followup_dqot(struct query *q, char *argv[], client *cl);
+int followup_uuac(struct query *q, char *argv[], client *cl);
+
+int set_modtime(struct query *q, char *argv[], client *cl);
+int set_modtime_by_id(struct query *q, char *argv[], client *cl);
+int set_finger_modtime(struct query *q, char *argv[], client *cl);
+int set_pobox_modtime(struct query *q, char *argv[], client *cl);
+int set_uppercase_modtime(struct query *q, char *argv[], client *cl);
+int set_mach_modtime_by_id(struct query *q, char *argv[], client *cl);
+int set_cluster_modtime_by_id(struct query *q, char *argv[], client *cl);
+int set_serverhost_modtime(struct query *q, char *argv[], client *cl);
+int set_nfsphys_modtime(struct query *q, char *argv[], client *cl);
+int set_filesys_modtime(struct query *q, char *argv[], client *cl);
+int set_zephyr_modtime(struct query *q, char *argv[], client *cl);
+int _sdl_followup(struct query *q, char *argv[], client *cl);
+
+/* prototypes from qsetup.pc */
+int prefetch_value(struct query *q, char *argv[], client *cl);
+int prefetch_filesys(struct query *q, char *argv[], client *cl);
+int setup_ausr(struct query *q, char *argv[], client *cl);
+int setup_dusr(struct query *q, char *argv[], client *cl);
+int setup_spop(struct query *q, char *argv[], client *cl);
+int setup_dpob(struct query *q, char *argv[], client *cl);
+int setup_dmac(struct query *q, char *argv[], client *cl);
+int setup_dclu(struct query *q, char *argv[], client *cl);
+int setup_alis(struct query *q, char *argv[], client *cl);
+int setup_dlis(struct query *q, char *argv[], client *cl);
+int setup_dsin(struct query *q, char *argv[], client *cl);
+int setup_dshi(struct query *q, char *argv[], client *cl);
+int setup_afil(struct query *q, char *argv[], client *cl);
+int setup_ufil(struct query *q, char *argv[], client *cl);
+int setup_dfil(struct query *q, char *argv[], client *cl);
+int setup_aftg(struct query *q, char *argv[], client *cl);
+int setup_dnfp(struct query *q, char *argv[], client *cl);
+int setup_dqot(struct query *q, char *argv[], client *cl);
+int setup_akum(struct query *q, char *argv[], client *cl);
+int setup_dsnt(struct query *q, char *argv[], client *cl);
+int setup_ahst(struct query *q, char *argv[], client *cl);
+int setup_ahal(struct query *q, char *argv[], client *cl);
+
+/* prototypes from qsupport.pc */
+int set_pobox(struct query *q, char *argv[], client *cl);
+int add_member_to_list(struct query *q, char *argv[], client *cl);
+int delete_member_from_list(struct query *q, char *argv[], client *cl);
+int register_user(struct query *q, char *argv[], client *cl);
+
+int get_list_info(struct query *q, char **argv, client *cl,
+                 int (*action)(int, char *[], void *), void *actarg);
+int get_ace_use(struct query *q, char **argv, client *cl,
+               int (*action)(int, char *[], void *), void *actarg);
+int qualified_get_lists(struct query *q, char **argv, client *cl,
+                       int (*action)(int, char *[], void *), void *actarg);
+int get_members_of_list(struct query *q, char **argv, client *cl,
+                       int (*action)(int, char *[], void *), void *actarg);
+int get_end_members_of_list(struct query *q, char **argv, client *cl,
+                           int (*action)(int, char *[], void *),
+                           void *actarg);
+int qualified_get_server(struct query *q, char **argv, client *cl,
+                        int (*action)(int, char *[], void *), void *actarg);
+int qualified_get_serverhost(struct query *q, char **argv, client *cl,
+                            int (*action)(int, char *[], void *),
+                            void *actarg);
+int count_members_of_list(struct query *q, char **argv, client *cl,
+                         int (*action)(int, char *[], void *), void *actarg);
+int get_lists_of_member(struct query *q, char **argv, client *cl,
+                       int (*action)(int, char *[], void *), void *actarg);
+
+/* prototypes from qvalidate.pc */
+/* 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);
index e884495c4c477bef40ca2fadf37a0a0e40e4d321..5f3e3caf0c2a97df086398ca82496b7b5863bf68 100644 (file)
@@ -1,22 +1,17 @@
-/*
- *     $Source$
- *     $Author$
- *     $Header$
- *
- *     Copyright (C) 1987 by the Massachusetts Institute of Technology
- *     For copying and distribution information, please see the file
- *     <mit-copyright.h>.
+/* $Id$
  *
+ * Copyright (C) 1987-1998 by the Massachusetts Institute of Technology
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
  */
 
-#ifndef lint
-static char *rcsid_mr_shutdown_c = "$Header$";
-#endif lint
-
 #include <mit-copyright.h>
-#include <sys/errno.h>
 #include "mr_server.h"
 
+#include <errno.h>
+
+RCSID("$Header$");
+
 extern char *takedown;
 extern char *whoami;
 
index e71f551367e9e310d18cb42f86f0da7351f2221b..dcca3c8f83923e1c9c1c29b7ce1b4d1c4f95e71e 100644 (file)
@@ -1,22 +1,17 @@
-/*
- *     $Source$
- *     $Author$
- *     $Header$
+/* $Id$
  *
- *     Copyright (C) 1987 by the Massachusetts Institute of Technology
- *     For copying and distribution information, please see the file
- *     <mit-copyright.h>.
+ * Global variables inside the Moira server.
  *
- *     Global variables inside the Moira server.
+ * Copyright (C) 1987-1998 by the Massachusetts Institute of Technology
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
  */
 
-#ifndef lint
-static char *rcsid_mr_srvdata_c = "$Header$";
-#endif lint
-
 #include <mit-copyright.h>
 #include "mr_server.h"
 
+RCSID("$Header$");
+
 /*
  * Connections & clients:
  *
index 5c5894385766b8d3d0cb136d42ef50605bf0c4a0..04b528b62ffeea11a1f6aa5cb7dd58e5e3fa34a9 100644 (file)
@@ -1,24 +1,19 @@
-/*
- *     $Source$
- *     $Author$
- *     $Header$
+/* $Id$
  *
- *     Copyright (C) 1987 by the Massachusetts Institute of Technology
- *     For copying and distribution information, please see the file
- *     <mit-copyright.h>.
+ * Copyright (C) 1987-1998 by the Massachusetts Institute of Technology
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
  */
 
-#ifndef lint
-static char *rcsid_mr_util_c = "$Header$";
-#endif lint
-
 #include <mit-copyright.h>
 #include "mr_server.h"
-#include <com_err.h>
+
 #include <ctype.h>
-#include <sys/types.h>
+#include <stdlib.h>
 #include <string.h>
 
+RCSID("$Header$");
+
 extern char *whoami;
 
 char *requote(char *buf, char *cp, int len)
@@ -91,7 +86,7 @@ void mr_com_err(const char *whoami, long code, const char *fmt, va_list pvar)
   if (code)
     fputs(error_message(code), stderr);
   if (fmt)
-    _doprnt(fmt, pvar, stderr);
+    vfprintf(stderr, fmt, pvar);
   putc('\n', stderr);
 }
 
@@ -147,6 +142,6 @@ char **mr_copy_args(char **argv, int argc)
   if (!a)
     return a;
   for (i = 0; i < argc; i++)
-    a[i] = strsave(argv[i]);
+    a[i] = strdup(argv[i]);
   return a;
 }
index a1cc322f1075bb895edcc9ecced5e994acb053bc..fc273ae2a228649076c4b36321675c34c6f732af 100644 (file)
@@ -1,24 +1,23 @@
-/*
- *     $Source$
- *     $Author$
- *     $Header$
+/* $Id$
  *
- *     Copyright (C) 1987 by the Massachusetts Institute of Technology
- *     For copying and distribution information, please see the file
- *     <mit-copyright.h>.
+ * Check access to queries
  *
+ * Copyright (C) 1987-1998 by the Massachusetts Institute of Technology
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
  */
 
-#ifndef lint
-static char *rcsid_qsupport_dc = "$Header$";
-#endif lint
-
 #include <mit-copyright.h>
 #include "mr_server.h"
+#include "qrtn.h"
 #include "query.h"
+
 #include <ctype.h>
+#include <stdlib.h>
+
 EXEC SQL INCLUDE sqlca;
-#include "qrtn.h"
+
+RCSID("$Header$");
 
 extern char *whoami;
 extern int dbms_errno, mr_errcode;
index 66451711b74811666cfead588dcabbe0d3b357aa..50d5b4cb09071c1c57686f6bd011784c146d8820 100644 (file)
@@ -1,28 +1,28 @@
-/*
- *     $Source$
- *     $Author$
- *     $Header$
+/* $Id$
  *
- *     Copyright (C) 1987 by the Massachusetts Institute of Technology
- *     For copying and distribution information, please see the file
- *     <mit-copyright.h>.
+ * Query followup routines
+ *
+ * Copyright (C) 1987-1998 by the Massachusetts Institute of Technology
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
  *
  */
 
-#ifndef lint
-static char *rcsid_qsupport_dc = "$Header$";
-#endif lint
-
 #include <mit-copyright.h>
 #include "mr_server.h"
 #include "query.h"
+#include "qrtn.h"
+
 #include <ctype.h>
+#include <stdlib.h>
 #include <string.h>
 #ifdef GDSS
 #include "gdss.h"
 #endif /* GDSS */
+
 EXEC SQL INCLUDE sqlca;
-#include "qrtn.h"
+
+RCSID("$Header$");
 
 extern char *whoami, *table_name[];
 extern int dbms_errno, mr_errcode;
@@ -291,8 +291,8 @@ int set_zephyr_modtime(struct query *q, char *argv[], client *cl)
  * username, or # + the users_id.
  */
 int followup_fix_modby(struct query *q, struct save_queue *sq,
-                      struct validate *v, int (*action)(), int actarg,
-                      client *cl)
+                      struct validate *v, int (*action)(int, char *[], void *),
+                      void *actarg, client *cl)
 {
   int i, j;
   char **argv;
@@ -327,7 +327,8 @@ int followup_fix_modby(struct query *q, struct save_queue *sq,
  * routine but don't have a signature.
  */
 int followup_guax(struct query *q, struct save_queue *sq, struct validate *v,
-                 int (*action)(), int actarg, client *cl)
+                 int (*action)(int, char *[], void *), void *actarg,
+                 client *cl)
 {
   int i, j;
   char **argv;
@@ -336,7 +337,7 @@ int followup_guax(struct query *q, struct save_queue *sq, struct validate *v,
   char *kname;
   SigInfo  si;
   EXEC SQL BEGIN DECLARE SECTION;
-  int timestamp, who, siglen;
+  int timestamp, who;
   char *login;
   char rsig[256];
   EXEC SQL VAR rsig IS STRING(256);
@@ -369,14 +370,14 @@ int followup_guax(struct query *q, struct save_queue *sq, struct validate *v,
          si.SigInfoVersion = 0; /* XXXXX this isn't used */
          kname_parse(si.pname, si.pinst, si.prealm, kname);
          free(kname);
-         si.rawsig = (unsigned char *)strsave(rsig);
+         si.rawsig = (unsigned char *)strdup(rsig);
          if (log_flags & LOG_GDSS)
            com_err(whoami, 0, "rawsig length = %d, sig=\"%s\"",
                    strlen(si.rawsig), si.rawsig);
          GDSS_Recompose(&si, sigbuf);
          free(si.rawsig);
          free(argv[U_SIGNATURE]);
-         argv[U_SIGNATURE] = strsave(sigbuf);
+         argv[U_SIGNATURE] = strdup(sigbuf);
          if (log_flags & LOG_GDSS)
            com_err(whoami, 0, "generated signature length %d",
                    strlen(sigbuf));
@@ -411,7 +412,7 @@ int followup_ausr(struct query *q, char *argv[], client *cl)
   char fullname[129];
   EXEC SQL END DECLARE SECTION;
 #ifdef GDSS
-  char databuf[32], *kname_unparse();
+  char databuf[32];
   EXEC SQL BEGIN DECLARE SECTION;
   char rawsig[128];
   int sigwho, timestamp;
@@ -507,7 +508,7 @@ int followup_uuac(struct query *q, char *argv[], client *cl)
   char *entity, *name;
   EXEC SQL END DECLARE SECTION;
 #ifdef GDSS
-  char databuf[32], *kname_unparse();
+  char databuf[32];
   EXEC SQL BEGIN DECLARE SECTION;
   char rawsig[128];
   char *login;
@@ -584,7 +585,8 @@ int followup_uuac(struct query *q, char *argv[], client *cl)
  */
 
 int followup_gpob(struct query *q, struct save_queue *sq, struct validate *v,
-                 int (*action)(), int actarg, client *cl)
+                 int (*action)(int, char *[], void *), void *actarg,
+                 client *cl)
 {
   char **argv;
   char *ptype, *p;
@@ -648,7 +650,8 @@ int followup_gpob(struct query *q, struct save_queue *sq, struct validate *v,
  */
 
 int followup_gsnt(struct query *q, struct save_queue *sq, struct validate *v,
-                 int (*action)(), int actarg, client *cl)
+                 int (*action)(int, char *[], void *), void *actarg,
+                 client *cl)
 {
   char **argv, *type;
   int id, i, idx, status;
@@ -680,13 +683,13 @@ int followup_gsnt(struct query *q, struct save_queue *sq, struct validate *v,
        {
          status = 0;
          free(argv[idx]);
-         argv[idx] = strsave("NONE");
+         argv[idx] = strdup("NONE");
        }
       else
        {
          status = 0;
          free(argv[idx]);
-         argv[idx] = strsave("???");
+         argv[idx] = strdup("???");
        }
       if (status && status != MR_NO_MATCH)
        return status;
@@ -712,7 +715,8 @@ int followup_gsnt(struct query *q, struct save_queue *sq, struct validate *v,
  */
 
 int followup_ghst(struct query *q, struct save_queue *sq, struct validate *v,
-                 int (*action)(), int actarg, client *cl)
+                 int (*action)(int, char *[], void *), void *actarg,
+                 client *cl)
 {
   char **argv, *type;
   int id, i, idx, status;
@@ -759,13 +763,13 @@ int followup_ghst(struct query *q, struct save_queue *sq, struct validate *v,
        {
          status = 0;
          free(argv[idx]);
-         argv[idx] = strsave("NONE");
+         argv[idx] = strdup("NONE");
        }
       else
        {
          status = 0;
          free(argv[idx]);
-         argv[idx] = strsave("???");
+         argv[idx] = strdup("???");
        }
       if (status && status != MR_NO_MATCH)
        return status;
@@ -791,7 +795,8 @@ int followup_ghst(struct query *q, struct save_queue *sq, struct validate *v,
  */
 
 int followup_glin(struct query *q, struct save_queue *sq, struct validate *v,
-                 int (*action)(), int actarg, client *cl)
+                 int (*action)(int, char *[], void *), void *actarg,
+                 client *cl)
 {
   char **argv, *type;
   int id, i, idx, status;
@@ -825,13 +830,13 @@ int followup_glin(struct query *q, struct save_queue *sq, struct validate *v,
        {
          status = 0;
          free(argv[idx]);
-         argv[idx] = strsave("NONE");
+         argv[idx] = strdup("NONE");
        }
       else
        {
          status = 0;
          free(argv[idx]);
-         argv[idx] = strsave("???");
+         argv[idx] = strdup("???");
        }
       if (status && status != MR_NO_MATCH)
        return status;
@@ -864,7 +869,8 @@ int followup_glin(struct query *q, struct save_queue *sq, struct validate *v,
  */
 
 int followup_gqot(struct query *q, struct save_queue *sq, struct validate *v,
-                 int (*action)(), int actarg, client *cl)
+                 int (*action)(int, char *[], void *), void *actarg,
+                 client *cl)
 {
   int j;
   char **argv;
@@ -894,7 +900,7 @@ int followup_gqot(struct query *q, struct save_queue *sq, struct validate *v,
              break;
            case 'A':
              free(argv[2]);
-             argv[2] = strsave("system:anyuser");
+             argv[2] = strdup("system:anyuser");
              break;
            default:
              id = atoi(argv[2]);
@@ -1078,7 +1084,8 @@ int followup_dqot(struct query *q, char **argv, client *cl)
 
 
 int followup_gpce(struct query *q, struct save_queue *sq, struct validate *v,
-                 int (*action)(), int actarg, client *cl)
+                 int (*action)(int, char *[], void *), void *actarg,
+                 client *cl)
 {
   int i, j;
   char **argv;
@@ -1112,7 +1119,8 @@ int followup_gpce(struct query *q, struct save_queue *sq, struct validate *v,
  */
 
 int followup_gzcl(struct query *q, struct save_queue *sq, struct validate *v,
-                 int (*action)(), int actarg, client *cl)
+                 int (*action)(int, char *[], void *), void *actarg,
+                 client *cl)
 {
   int id, i, status;
   char **argv;
@@ -1142,13 +1150,13 @@ int followup_gzcl(struct query *q, struct save_queue *sq, struct validate *v,
            {
              status = 0;
              free(argv[i + 1]);
-             argv[i + 1] = strsave("NONE");
+             argv[i + 1] = strdup("NONE");
            }
          else
            {
              status = 0;
              free(argv[i + 1]);
-             argv[i + 1] = strsave("???");
+             argv[i + 1] = strdup("???");
            }
          if (status && status != MR_NO_MATCH)
            return status;
@@ -1171,7 +1179,8 @@ int followup_gzcl(struct query *q, struct save_queue *sq, struct validate *v,
  */
 
 int followup_gsha(struct query *q, struct save_queue *sq, struct validate *v,
-                 int (*action)(), int actarg, client *cl)
+                 int (*action)(int, char *[], void *), void *actarg,
+                 client *cl)
 {
   char **argv;
   int i, id, status;
@@ -1199,13 +1208,13 @@ int followup_gsha(struct query *q, struct save_queue *sq, struct validate *v,
        {
          status = 0;
          free(argv[2]);
-         argv[2] = strsave("NONE");
+         argv[2] = strdup("NONE");
        }
       else
        {
          status = 0;
          free(argv[2]);
-         argv[2] = strsave("???");
+         argv[2] = strdup("???");
        }
       if (status && status != MR_NO_MATCH)
        return status;
index 6a97dc35764a66baabd6670b8be2b0ccfae516ac..d848ad63aeeac00b697e1a16e0729922162f3e26 100644 (file)
@@ -9,6 +9,6 @@
 extern int mr_sig_length;
 extern char stmt_buf[MR_STMTBUF_LEN];
 
-extern void dbmserr();
+void dbmserr(void);
 
 /* eof:qtrn.h */
index c1b7297fb03710dc75427a119100644fb0e0e8bf..4f0f9fecb47dc242a7e220729bba49c8ee0a81f0 100644 (file)
@@ -1,25 +1,25 @@
-/*
- *     $Source$
- *     $Author$
- *     $Header$
+/* $Id$
+ *
+ * Query-processing routines
  *
- *     Copyright (C) 1987, 1988 by the Massachusetts Institute of Technology
- *     For copying and distribution information, please see the file
- *     <mit-copyright.h>.
+ * Copyright (C) 1987-1998 by the Massachusetts Institute of Technology
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
  *
  */
 
-#ifndef lint
-static char *rcsid_qrtn_dc = "$Header$";
-#endif lint
-
 #include <mit-copyright.h>
-#include <string.h>
 #include "mr_server.h"
+#include "qrtn.h"
 #include "query.h"
+
+#include <stdlib.h>
+#include <string.h>
+
 EXEC SQL INCLUDE sqlca;  /* SQL Communications Area */
 EXEC SQL INCLUDE sqlda;  /* SQL Descriptor Area */
-#include "qrtn.h"
+
+RCSID("$Header$");
 
 SQLDA *mr_sqlda;
 EXEC SQL BEGIN DECLARE SECTION;
@@ -44,21 +44,21 @@ extern FILE *journal;
 
 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 (*action)(int, char *[], void *), void *actarg);
 int do_update(struct query *q, char *argv[], char *qual,
-             int (*action)(), char *actarg);
+             int (*action)(int, char *[], void *), void *actarg);
 int do_append(struct query *q, char *argv[], char *pqual,
-             int (*action)(), char *actarg);
+             int (*action)(int, char *[], void *), void *actarg);
 int do_delete(struct query *q, char *qual,
-             int (*action)(), char *actarg);
+             int (*action)(int, char *[], void *), void *actarg);
 void build_sql_stmt(char *result_buf, char *cmd, char *targetlist,
                    char *argv[], char *qual);
 char *build_sort(struct validate *v, char *sort);
+char *sqlstrstr(char *str, char *pat);
+void optimize_sql_stmt(char *buf);
 
-/* 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);
-
+SQLDA *mr_alloc_sqlda(void);
+void sqlglm(char *, int *, int *);
 
 /*
  * dbmserr: Called when the DBMS indicates an error.
@@ -87,7 +87,6 @@ EXEC SQL WHENEVER SQLERROR DO dbmserr();
 int mr_open_database(void)
 {
   int i;
-  SQLDA *mr_alloc_sqlda();
   static first_open = 1;
 
   if (first_open)
@@ -143,7 +142,7 @@ int mr_check_access(client *cl, char *name, int argc, char *argv_ro[])
 }
 
 int mr_process_query(client *cl, char *name, int argc, char *argv_ro[],
-                    int (*action)(), char *actarg)
+                    int (*action)(int, char *[], void *), void *actarg)
 {
   struct query *q;
   int status;
@@ -192,7 +191,7 @@ int mr_process_query(client *cl, char *name, int argc, char *argv_ro[],
   /* perform any special query pre-processing */
   if (v && v->pre_rtn)
     {
-      status = (*v->pre_rtn)(q, Argv, cl, 0);
+      status = (*v->pre_rtn)(q, Argv, cl);
       if (status != MR_SUCCESS)
        goto out;
     }
@@ -232,7 +231,7 @@ int mr_process_query(client *cl, char *name, int argc, char *argv_ro[],
          if (v && v->post_rtn)
            {
              sq = sq_create();
-             status = do_retrieve(q, pqual, psort, sq_save_args, (char *)sq);
+             status = do_retrieve(q, pqual, psort, sq_save_args, sq);
              if (status != MR_SUCCESS)
                {
                  sq_destroy(sq);
@@ -364,6 +363,9 @@ int mr_process_query(client *cl, char *name, int argc, char *argv_ro[],
       if (v->post_rtn)
        status = (*v->post_rtn)(q, Argv, cl);
       break;
+
+    case SPECIAL:
+      break;
     }
 
 out:
@@ -389,7 +391,7 @@ out:
 
              fprintf(journal, "%% %s %s %s",
                      cl->clname, cl->entity, ctime(&now));
-             fprintf(journal, "%s[%d] ", q->name, cl->args->mr_version_no);
+             fprintf(journal, "%s[%ld] ", q->name, cl->args->mr_version_no);
              for (i = 0; i < argc; i++)
                {
                  if (i != 0)
@@ -416,7 +418,7 @@ out:
   return status;
 }
 
-int build_qual(char *fmt_buf, int argc, char *argv[], char *qual)
+void build_qual(char *fmt_buf, int argc, char *argv[], char *qual)
 {
   char *res, *fmt;
 
@@ -626,7 +628,7 @@ int find_member(char *list_type, int list_id, client *cl)
 
 
 int do_retrieve(struct query *q, char *pqual, char *psort,
-               int (*action)(), char *actarg)
+               int (*action)(int, char *[], void *), void *actarg)
 {
   build_sql_stmt(stmt_buf, "SELECT", q->tlist, NULL, pqual);
   if (psort)
@@ -635,7 +637,7 @@ int do_retrieve(struct query *q, char *pqual, char *psort,
       strcat(stmt_buf, psort);
     }
 
-  return do_for_all_rows(stmt_buf, q->vcnt, action, (int)actarg);
+  return do_for_all_rows(stmt_buf, q->vcnt, action, actarg);
 }
 
 char *sqlstrstr(char *str, char *pat)
@@ -671,7 +673,7 @@ void optimize_sql_stmt(char *buf)
 {
   char *point = buf, *pat, *eopat, *esc1, *esc2, *csr;
 
-  for (point = buf; point = sqlstrstr(point, "LIKE"); point++)
+  for (point = buf; (point = sqlstrstr(point, "LIKE")); point++)
     {
       /* Now pointing to string "LIKE" */
 
@@ -797,7 +799,7 @@ void build_sql_stmt(char *result_buf, char *cmd, char *targetlist,
 }
 
 int do_update(struct query *q, char *argv[], char *qual,
-             int (*action)(), char *actarg)
+             int (*action)(int, char *[], void *), void *actarg)
 {
   build_sql_stmt(stmt_buf, "UPDATE", q->tlist, argv, qual);
   EXEC SQL EXECUTE IMMEDIATE :stmt_buf;
@@ -807,7 +809,7 @@ int do_update(struct query *q, char *argv[], char *qual,
 }
 
 int do_append(struct query *q, char *argv[], char *pqual,
-             int (*action)(), char *actarg)
+             int (*action)(int, char *[], void *), void *actarg)
 {
   build_sql_stmt(stmt_buf, "INSERT", q->tlist, argv, pqual);
   EXEC SQL EXECUTE IMMEDIATE :stmt_buf;
@@ -816,7 +818,8 @@ int do_append(struct query *q, char *argv[], char *pqual,
   return MR_SUCCESS;
 }
 
-int do_delete(struct query *q, char *qual, int (*action)(), char *actarg)
+int do_delete(struct query *q, char *qual,
+             int (*action)(int, char *[], void *), void *actarg)
 {
   sprintf(stmt_buf, "DELETE FROM %s WHERE %s", table_name[q->rtable], qual);
   EXEC SQL EXECUTE IMMEDIATE :stmt_buf;
@@ -993,7 +996,8 @@ void dosql(char *buffers[])
     }
 }
 
-int do_for_all_rows(char *query, int count, int (*action)(), int actarg)
+int do_for_all_rows(char *query, int count,
+                   int (*action)(int, char *[], void *), void *actarg)
 {
   int i, rowcount = 0;
   EXEC SQL BEGIN DECLARE SECTION;
@@ -1002,7 +1006,7 @@ int do_for_all_rows(char *query, int count, int (*action)(), int actarg)
 
   EXEC SQL PREPARE stmt FROM :q;
   if (sqlca.sqlcode)
-    return;
+    return MR_INTERNAL;
   EXEC SQL DECLARE curs CURSOR FOR stmt;
   EXEC SQL OPEN curs;
   mr_sqlda->N = count;
index a59d253bed603adb7ca10066490ba7a827331728..b4f8c50eb03790a61673c8b9d739f00d9f305a35 100644 (file)
@@ -1,27 +1,29 @@
-/*
- *     $Source$
- *     $Author$
- *     $Header$
+/* $Id$
  *
- *     Copyright (C) 1987 by the Massachusetts Institute of Technology
- *     For copying and distribution information, please see the file
- *     <mit-copyright.h>.
+ * Query setup routines
  *
+ * Copyright (C) 1987-1998 by the Massachusetts Institute of Technology
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
  */
 
-#ifndef lint
-static char *rcsid_qsupport_dc = "$Header$";
-#endif lint
-
 #include <mit-copyright.h>
 #include "mr_server.h"
 #include "query.h"
-#include <ctype.h>
+#include "qrtn.h"
+
 #include <arpa/inet.h>
+#include <netinet/in.h>
+
+#include <ctype.h>
+#include <stdlib.h>
+#include <string.h>
+
 EXEC SQL INCLUDE sqlca;
-#include "qrtn.h"
 
-extern char *whoami, *strsave();
+RCSID("$Header$");
+
+extern char *whoami;
 extern int dbms_errno, mr_errcode;
 
 EXEC SQL BEGIN DECLARE SECTION;
@@ -82,7 +84,7 @@ int setup_ausr(struct query *q, char *argv[], client *cl)
  * and may safely be deleted.
  */
 
-int setup_dusr(struct query *q, char **argv)
+int setup_dusr(struct query *q, char *argv[], client *cl)
 {
   EXEC SQL BEGIN DECLARE SECTION;
   int flag, id, cnt;
@@ -126,7 +128,7 @@ int setup_dusr(struct query *q, char **argv)
 /* setup_spop: verify that there is already a valid POP machine_id in the
  * pop_id field.  Also take care of keeping track of the post office usage.
  */
-int setup_spop(struct query *q, char **argv)
+int setup_spop(struct query *q, char *argv[], client *cl)
 {
   EXEC SQL BEGIN DECLARE SECTION;
   int id, mid;
@@ -136,11 +138,11 @@ int setup_spop(struct query *q, char **argv)
   id = *(int *)argv[0];
   EXEC SQL SELECT potype, pop_id INTO :type, :mid FROM users
     WHERE users_id = :id;
-  if (sqlca.sqlerrd[2] = 0)
+  if (sqlca.sqlerrd[2] == 0)
     return MR_MACHINE;
   EXEC SQL SELECT mach_id INTO :mid FROM machine
     WHERE mach_id = :mid;
-  if (sqlca.sqlerrd[2] = 0)
+  if (sqlca.sqlerrd[2] == 0)
     return MR_MACHINE;
   if (strcmp(strtrim(type), "POP"))
     set_pop_usage(mid, 1);
@@ -150,7 +152,7 @@ int setup_spop(struct query *q, char **argv)
 
 /* setup_dpob:  Take care of keeping track of the post office usage.
  */
-int setup_dpob(struct query *q, char **argv)
+int setup_dpob(struct query *q, char *argv[], client *cl)
 {
   EXEC SQL BEGIN DECLARE SECTION;
   int id, user;
@@ -173,7 +175,7 @@ int setup_dpob(struct query *q, char **argv)
  * and may safely be deleted.
  */
 
-int setup_dmac(struct query *q, char **argv)
+int setup_dmac(struct query *q, char *argv[], client *cl)
 {
   EXEC SQL BEGIN DECLARE SECTION;
   int flag, id, cnt;
@@ -229,7 +231,7 @@ int setup_dmac(struct query *q, char **argv)
  * and may safely be deleted.
  */
 
-int setup_dsnt(struct query *q, char **argv)
+int setup_dsnt(struct query *q, char *argv[], client *cl)
 {
   EXEC SQL BEGIN DECLARE SECTION;
   int id, cnt = 0;
@@ -248,7 +250,7 @@ int setup_dsnt(struct query *q, char **argv)
  * and may safely be deleted.
  */
 
-int setup_dclu(struct query *q, char **argv)
+int setup_dclu(struct query *q, char *argv[], client *cl)
 {
   EXEC SQL BEGIN DECLARE SECTION;
   int id, cnt;
@@ -342,7 +344,7 @@ int setup_alis(struct query *q, char *argv[], client *cl)
  * and may safely be deleted.
  */
 
-int setup_dlis(struct query *q, char **argv)
+int setup_dlis(struct query *q, char *argv[], client *cl)
 {
   int id;
   EXEC SQL BEGIN DECLARE SECTION;
@@ -410,7 +412,7 @@ int setup_dlis(struct query *q, char **argv)
  * and may safely be deleted.
  */
 
-int setup_dsin(struct query *q, char **argv)
+int setup_dsin(struct query *q, char *argv[], client *cl)
 {
   EXEC SQL BEGIN DECLARE SECTION;
   int ec, cnt;
@@ -438,7 +440,7 @@ int setup_dsin(struct query *q, char **argv)
  * and may safely be deleted.
  */
 
-int setup_dshi(struct query *q, char **argv)
+int setup_dshi(struct query *q, char *argv[], client *cl)
 {
   EXEC SQL BEGIN DECLARE SECTION;
   int id, ec;
@@ -999,7 +1001,7 @@ int setup_ahst(struct query *q, char **argv, client *cl)
               * make IP address is unique. If this a modify request
               * (row == 1), then we expect one record to exist.
               */
-             if (row == 0 || row == 1 && cnt > 1)
+             if (row == 0 || (row == 1 && cnt > 1))
                return MR_ADDRESS;
              if (row == 1 && cnt == 1)
                {
@@ -1022,7 +1024,7 @@ int setup_ahst(struct query *q, char **argv, client *cl)
              if (((id & 0xff) == 0) || ((id & 0xff) == 255))
                continue;
              addr.s_addr = htonl(id);
-             name = (char *)inet_ntoa(addr);
+             name = inet_ntoa(addr);
              EXEC SQL SELECT count(mach_id) INTO :cnt FROM machine
                WHERE address = :name;
              if (dbms_errno)
index 08e69d21877b0ddc413225a70f8e49d00d1abc9f..3933041bfa9f6c9c6d4fe04dc83614b890297e13 100644 (file)
@@ -1,26 +1,23 @@
-/*
- *     $Source$
- *     $Author$
- *     $Header$
- *
- *     Copyright (C) 1987 by the Massachusetts Institute of Technology
- *     For copying and distribution information, please see the file
- *     <mit-copyright.h>.
+/* $Id$
  *
+ * Copyright (C) 1987-1998 by the Massachusetts Institute of Technology
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
  */
 
-#ifndef lint
-static char *rcsid_qsubs_c = "$Header$";
-#endif lint
-
 #include <mit-copyright.h>
-#include <moira.h>
 #include "mr_server.h"
 #include "query.h"
 
+#include <stdlib.h>
+
+RCSID("$Header$");
+
 extern struct query Queries2[];
 extern int QueryCount2;
 
+int qcmp(const void *q1, const void *q2);
+
 struct query *get_query_by_name(char *name, int version)
 {
   struct query *q;
@@ -51,7 +48,8 @@ struct query *get_query_by_name(char *name, int version)
   return NULL;
 }
 
-void list_queries(int version, int (*action)(), char *actarg)
+void list_queries(int version, int (*action)(int, char *[], void *),
+                 void *actarg)
 {
   struct query *q;
   int i;
@@ -60,7 +58,6 @@ void list_queries(int version, int (*action)(), char *actarg)
   char qnames[80];
   char *qnp;
   int count;
-  int qcmp();
 
   count = QueryCount2;
   if (!squeries2)
@@ -88,7 +85,8 @@ void list_queries(int version, int (*action)(), char *actarg)
   (*action)(1, &qnp, actarg);
 }
 
-void help_query(struct query *q, int (*action)(), char *actarg)
+void help_query(struct query *q, int (*action)(int, char *[], void *),
+               void *actarg)
 {
   int argcount;
   int i;
@@ -146,7 +144,7 @@ void help_query(struct query *q, int (*action)(), char *actarg)
   (*action)(argcount, argv, actarg);
 }
 
-int qcmp(struct query **q1, struct query **q2)
+int qcmp(const void *q1, const void *q2)
 {
-  return strcmp((*q1)->name, (*q2)->name);
+  return strcmp((*(struct query **)q1)->name, (*(struct query **)q2)->name);
 }
index 81efe55f03972be48a5400b24c17538cedbded85..42ca9afbf29cf5cecd09720eae2b3b51869b4b3b 100644 (file)
@@ -1,25 +1,24 @@
-/*
- *     $Source$
- *     $Author$
- *     $Header$
+/* $Id$
  *
- *     Copyright (C) 1987 by the Massachusetts Institute of Technology
- *     For copying and distribution information, please see the file
- *     <mit-copyright.h>.
+ * Special query routines
  *
+ * Copyright (C) 1987-1998 by the Massachusetts Institute of Technology
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
  */
 
-#ifndef lint
-static char *rcsid_qsupport_dc = "$Header$";
-#endif lint
-
 #include <mit-copyright.h>
 #include "mr_server.h"
 #include "query.h"
+#include "qrtn.h"
+
 #include <ctype.h>
+#include <stdlib.h>
 #include <string.h>
+
 EXEC SQL INCLUDE sqlca;
-#include "qrtn.h"
+
+RCSID("$Header$");
 
 extern char *whoami, *table_name[];
 extern int dbms_errno, mr_errcode;
@@ -30,15 +29,16 @@ EXEC SQL END DECLARE SECTION;
 
 EXEC SQL WHENEVER SQLERROR DO dbmserr();
 
-int get_ace_internal(char *atypex, int aid, int (*action)(), int actarg);
+int get_ace_internal(char *atypex, int aid,
+                    int (*action)(int, char *[], void *), void *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,
+                 int (*action)(int, char *[], void *), void *actarg,
+                 int flag);
+int qualified_get(struct query *q, char *argv[],
+                 int (*action)(int, char *[], void *), void *actarg,
                  char *start, char *range, char *field, char *flags[]);
 
 
-/* Special query routines */
-
 /* set_pobox - this does all of the real work.
  *      argv = user_id, type, box
  * if type is POP, then box should be a machine, and its ID should be put in
@@ -109,7 +109,7 @@ int set_pobox(struct query *q, char **argv, client *cl)
  */
 
 int get_list_info(struct query *q, char **aargv, client *cl,
-                 int (*action)(), int actarg)
+                 int (*action)(int, char *[], void *), void *actarg)
 {
   char *argv[13];
   EXEC SQL BEGIN DECLARE SECTION;
@@ -119,7 +119,7 @@ int get_list_info(struct query *q, char **aargv, client *cl,
   int id, rowcount, acl_id, hid, modby_id;
   EXEC SQL END DECLARE SECTION;
   int returned, status;
-  struct save_queue *sq, *sq_create();
+  struct save_queue *sq;
 
   returned = rowcount = 0;
   name = aargv[0];
@@ -138,7 +138,7 @@ int get_list_info(struct query *q, char **aargv, client *cl,
       EXEC SQL FETCH csr102 INTO :id;
       if (sqlca.sqlcode)
        break;
-      sq_save_data(sq, (char *)id);
+      sq_save_data(sq, (void *)id);
       rowcount++;
     }
   EXEC SQL CLOSE csr102;
@@ -184,13 +184,13 @@ int get_list_info(struct query *q, char **aargv, client *cl,
        {
          status = 0;
          free(argv[8]);
-         argv[8] = strsave("NONE");
+         argv[8] = strdup("NONE");
        }
       else
        {
          status = 0;
          free(argv[8]);
-         argv[8] = strsave("???");
+         argv[8] = strdup("???");
        }
       if (status && status != MR_NO_MATCH)
        return status;
@@ -561,14 +561,14 @@ int delete_member_from_list(struct query *q, char **argv, client *cl)
  */
 
 int get_ace_use(struct query *q, char *argv[], client *cl,
-               int (*action)(), int actarg)
+               int (*action)(int, char *[], void *), void *actarg)
 {
   int found = 0;
   EXEC SQL BEGIN DECLARE SECTION;
   char *atype;
   int aid, listid, id;
   EXEC SQL END DECLARE SECTION;
-  struct save_queue *sq, *sq_create();
+  struct save_queue *sq;
 
   atype = argv[0];
   aid = *(int *)argv[1];
@@ -579,7 +579,7 @@ int get_ace_use(struct query *q, char *argv[], client *cl,
   sq = sq_create();
   if (!strcmp(atype, "RLIST"))
     {
-      sq_save_data(sq, (char *)aid);
+      sq_save_data(sq, (void *)aid);
       /* get all the list_id's of containing lists */
       EXEC SQL DECLARE csr107 CURSOR FOR
        SELECT list_id FROM imembers
@@ -594,7 +594,7 @@ int get_ace_use(struct query *q, char *argv[], client *cl,
          EXEC SQL FETCH csr107 INTO :listid;
          if (sqlca.sqlcode)
            break;
-         sq_save_unique_data(sq, (char *)listid);
+         sq_save_unique_data(sq, (void *)listid);
        }
       EXEC SQL CLOSE csr107;
       /* now process each one */
@@ -620,7 +620,7 @@ int get_ace_use(struct query *q, char *argv[], client *cl,
          EXEC SQL FETCH csr108 INTO :listid;
          if (sqlca.sqlcode)
            break;
-         sq_save_data(sq, (char *)listid);
+         sq_save_data(sq, (void *)listid);
        }
       EXEC SQL CLOSE csr108;
       /* now process each one */
@@ -648,7 +648,7 @@ int get_ace_use(struct query *q, char *argv[], client *cl,
          EXEC SQL FETCH csr109 INTO :listid;
          if (sqlca.sqlcode)
            break;
-         sq_save_data(sq, (char *)listid);
+         sq_save_data(sq, (void *)listid);
        }
       EXEC SQL CLOSE csr109;
       /* now process each one */
@@ -675,7 +675,8 @@ int get_ace_use(struct query *q, char *argv[], client *cl,
  * by get_ace_use above.
  */
 
-int get_ace_internal(char *atype, int aid, int (*action)(), int actarg)
+int get_ace_internal(char *atype, int aid,
+                    int (*action)(int, char *[], void *), void *actarg)
 {
   char *rargv[2];
   int found = 0;
@@ -842,7 +843,7 @@ int get_ace_internal(char *atype, int aid, int (*action)(), int actarg)
  */
 
 int get_lists_of_member(struct query *q, char *argv[], client *cl,
-                       int (*action)(), int actarg)
+                       int (*action)(int, char *[], void *), void *actarg)
 {
   int found = 0, direct = 1;
   char *rargv[6];
@@ -945,7 +946,7 @@ int get_lists_of_member(struct query *q, char *argv[], client *cl,
 static char *lflags[5] = { "active", "publicflg", "hidden", "maillist", "grouplist" };
 
 int qualified_get_lists(struct query *q, char *argv[], client *cl,
-                       int (*action)(), int actarg)
+                       int (*action)(int, char *[], void *), void *actarg)
 {
   return qualified_get(q, argv, action, actarg, "l.list_id != 0",
                       "l", "name", lflags);
@@ -955,7 +956,7 @@ int qualified_get_lists(struct query *q, char *argv[], client *cl,
 /* get_members_of_list - this gets only direct members */
 
 int get_members_of_list(struct query *q, char *argv[], client *cl,
-                       int (*action)(), int actarg)
+                       int (*action)(int, char *[], void *), void *actarg)
 {
   return gmol_internal(q, argv, cl, action, actarg, 1);
 }
@@ -963,7 +964,7 @@ int get_members_of_list(struct query *q, char *argv[], client *cl,
 /* get_end_members_of_list - this gets direct or indirect members */
 
 int get_end_members_of_list(struct query *q, char *argv[], client *cl,
-                           int (*action)(), int actarg)
+                           int (*action)(int, char *[], void *), void *actarg)
 {
   return gmol_internal(q, argv, cl, action, actarg, 0);
 }
@@ -979,14 +980,13 @@ int get_end_members_of_list(struct query *q, char *argv[], client *cl,
  **/
 
 int gmol_internal(struct query *q, char *argv[], client *cl,
-                 int (*action)(), int actarg, int flag)
+                 int (*action)(int, char *[], void *), void *actarg, int flag)
 {
   EXEC SQL BEGIN DECLARE SECTION;
-  int list_id, member_id, direct;
-  char member_name[129], member_type[9];
+  int list_id, direct;
+  char member_name[129];
   EXEC SQL END DECLARE SECTION;
   char *targv[2];
-  int members;
 
   /* true/false flag indicates whether to display only direct members. */
   if (flag)
@@ -1095,7 +1095,7 @@ int gmol_internal(struct query *q, char *argv[], client *cl,
  */
 
 int count_members_of_list(struct query *q, char *argv[], client *cl,
-                         int (*action)(), int actarg)
+                         int (*action)(int, char *[], void *), void *actarg)
 {
   EXEC SQL BEGIN DECLARE SECTION;
   int  list, ct = 0;
@@ -1123,7 +1123,7 @@ int count_members_of_list(struct query *q, char *argv[], client *cl,
 static char *sflags[3] = { "enable", "inprogress", "harderror" };
 
 int qualified_get_server(struct query *q, char *argv[], client *cl,
-                        int (*action)(), int actarg)
+                        int (*action)(int, char *[], void *), void *actarg)
 {
   return qualified_get(q, argv, action, actarg, "s.name is not null",
                       "s", "name", sflags);
@@ -1141,7 +1141,8 @@ int qualified_get_server(struct query *q, char *argv[], client *cl,
  *     flags - an array of strings, names of the flag variables
  */
 
-int qualified_get(struct query *q, char *argv[], int (*action)(), int actarg,
+int qualified_get(struct query *q, char *argv[],
+                 int (*action)(int, char *[], void *), void *actarg,
                  char *start, char *range, char *field, char *flags[])
 {
   char qual[256];
@@ -1179,7 +1180,8 @@ static char *shflags[6] = { "service", "enable", "override", "success",
                            "inprogress", "hosterror" };
 
 int qualified_get_serverhost(struct query *q, char *argv[], client *cl,
-                            int (*action)(), int actarg)
+                            int (*action)(int, char *[], void *),
+                            void *actarg)
 {
   char qual[256], buf[32];
   int i;
@@ -1218,7 +1220,7 @@ int register_user(struct query *q, char **argv, client *cl)
   EXEC SQL BEGIN DECLARE SECTION;
   char *login, *entity, directory[129], machname[33];
   int who, rowcount, mid, uid, users_id, utype, list_id;
-  int ostatus, nstatus, gidval, fsidval;
+  int ostatus, nstatus, fsidval;
   static int m_id = 0, def_quota = 0;
   EXEC SQL END DECLARE SECTION;
   char buffer[256], *aargv[3];
index 0adf14964dddb3076da13219299bd77ea00d26ee..797cc2e91b9746d564db0233ff49b06673bf818b 100644 (file)
@@ -1,8 +1,8 @@
-/* This file defines the query dispatch table for version 2 of the protocol
+/* $Id$
  *
- * $Header$
+ * This file defines the query dispatch table for version 2 of the protocol
  *
- * Copyright 1987, 1988 by the Massachusetts Institute of Technology.
+ * Copyright (C) 1987-1998 by the Massachusetts Institute of Technology.
  * For copying and distribution information, please see the file
  * <mit-copyright.h>.
  */
 #undef ACE_NAME
 #undef NAME
 #include "query.h"
-#include "mr_et.h"
-
-/* Specialized Support Query Routines */
-
-/* Special Access Check Routines */
-int access_user();
-int access_login();
-int access_list();
-int access_visible_list();
-int access_vis_list_by_name();
-int access_member();
-int access_qgli();
-int access_service();
-int access_filesys();
-int access_host();
-int access_ahal();
-int access_snt();
-
-/* Query Setup Routines */
-int prefetch_value();
-int prefetch_filesys();
-int setup_ausr();
-int setup_dusr();
-int setup_spop();
-int setup_dpob();
-int setup_dmac();
-int setup_dsnet();
-int setup_dclu();
-int setup_alis();
-int setup_dlis();
-int setup_dsin();
-int setup_dshi();
-int setup_afil();
-int setup_ufil();
-int setup_dfil();
-int setup_aftg();
-int setup_dnfp();
-int setup_dqot();
-int setup_akum();
-int setup_dsnt();
-int setup_ahst();
-int setup_ahal();
-
-/* Query Followup Routines */
-int followup_fix_modby();
-int followup_ausr();
-int followup_gpob();
-int followup_glin();
-int followup_aqot();
-int followup_dqot();
-int followup_gzcl();
-int followup_gsha();
-int followup_gqot();
-int followup_gpce();
-int followup_guax();
-int followup_uuac();
-int followup_gsnt();
-int followup_ghst();
-
-int set_modtime();
-int set_modtime_by_id();
-int set_finger_modtime();
-int set_pobox_modtime();
-int set_uppercase_modtime();
-int set_mach_modtime_by_id();
-int set_cluster_modtime_by_id();
-int set_serverhost_modtime();
-int set_nfsphys_modtime();
-int set_filesys_modtime();
-int set_zephyr_modtime();
-
-/* Special Queries */
-int set_pobox();
-int get_list_info();
-int add_member_to_list();
-int delete_member_from_list();
-int get_ace_use();
-int qualified_get_lists();
-int get_members_of_list();
-int get_end_members_of_list();
-int qualified_get_server();
-int qualified_get_serverhost();
-int trigger_dcm();
-int count_members_of_list();
-int get_lists_of_member();
-int register_user();
-int _sdl_followup();
 
+#include "mr_et.h"
 
-\f
 /* String compression
  * These are commonly used strings in the table, defined here so that
  * they can be shared.
@@ -2683,8 +2596,8 @@ static struct validate _sdl_validate =
 {
   0,
   0,
-  (char *)0,
-  (char *)0,
+  NULL,
+  NULL,
   0,
   0,
   0,
@@ -2906,7 +2819,7 @@ struct query Queries2[] = {
     "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,
+    NULL,
     0,
     &auac_validate,
   },
@@ -3038,7 +2951,7 @@ struct query Queries2[] = {
     DELETE,
     "u",
     USERS_TABLE,
-    (char *)0,
+    NULL,
     dusr_fields,
     0,
     "users_id = %d",
@@ -3053,7 +2966,7 @@ struct query Queries2[] = {
     DELETE,
     "u",
     USERS_TABLE,
-    (char *)0,
+    NULL,
     dubu_fields,
     0,
     "users_id = %d",
@@ -3206,7 +3119,7 @@ struct query Queries2[] = {
     0,
     spob_fields,
     3,
-    (char *)0,
+    NULL,
     0,
     &spob_validate,
   },
@@ -3293,7 +3206,7 @@ struct query Queries2[] = {
     DELETE,
     "m",
     MACHINE_TABLE,
-    (char *)0,
+    NULL,
     dhst_fields,
     0,
     "mach_id = %d",
@@ -3353,7 +3266,7 @@ struct query Queries2[] = {
     DELETE,
     "a",
     HOSTALIAS_TABLE,
-    (char *)0,
+    NULL,
     ghal_fields,
     0,
     "name = UPPER('%s') AND mach_id = %d",
@@ -3413,7 +3326,7 @@ struct query Queries2[] = {
     DELETE,
     "s",
     SUBNET_TABLE,
-    (char *)0,
+    NULL,
     dsnt_fields,
     0,
     "snet_id = %d",
@@ -3473,7 +3386,7 @@ struct query Queries2[] = {
     DELETE,
     "c",
     CLUSTER_TABLE,
-    (char *)0,
+    NULL,
     dclu_fields,
     0,
     "clu_id = %d",
@@ -3551,7 +3464,7 @@ struct query Queries2[] = {
     "INTO svc (clu_id, serv_label, serv_cluster) VALUES (%d, '%s', '%s')",
     acld_fields,
     3,
-    (char *)0,
+    NULL,
     0,
     &acld_validate,
   },
@@ -3563,7 +3476,7 @@ struct query Queries2[] = {
     DELETE,
     "svc",
     SVC_TABLE,
-    (char *)0,
+    NULL,
     acld_fields,
     0,
     "clu_id = %d AND serv_label = '%s' AND serv_cluster = '%s'",
@@ -3638,7 +3551,7 @@ struct query Queries2[] = {
     DELETE,
     "l",
     LIST_TABLE,
-    (char *)0,
+    NULL,
     dlis_fields,
     0,
     "list_id = %d",
@@ -3656,7 +3569,7 @@ struct query Queries2[] = {
     0,
     amtl_fields,
     3,
-    (char *)0,
+    NULL,
     0,
     &amtl_validate,
   },
@@ -3668,7 +3581,7 @@ struct query Queries2[] = {
     DELETE,
     0,
     IMEMBERS_TABLE,
-    (char *)0,
+    NULL,
     amtl_fields,
     0,
     0,
@@ -3711,12 +3624,12 @@ struct query Queries2[] = {
     "get_members_of_list",
     "gmol",
     RETRIEVE,
-    (char *)0,
+    NULL,
     IMEMBERS_TABLE,
-    (char *)0,
+    NULL,
     gmol_fields,
     2,
-    (char *)0,
+    NULL,
     1,
     &gmol_validate,
   },
@@ -3726,12 +3639,12 @@ struct query Queries2[] = {
     "get_end_members_of_list",
     "geml",
     RETRIEVE,
-    (char *)0,
+    NULL,
     IMEMBERS_TABLE,
-    (char *)0,
+    NULL,
     gmol_fields,
     2,
-    (char *)0,
+    NULL,
     1,
     &geml_validate,
   },
@@ -3806,7 +3719,7 @@ struct query Queries2[] = {
     "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,
+    NULL,
     0,
     &asin_validate,
   },
@@ -3863,7 +3776,7 @@ struct query Queries2[] = {
     DELETE,
     "s",
     SERVERS_TABLE,
-    (char *)0,
+    NULL,
     dsin_fields,
     0,
     "name = UPPER('%s')",
@@ -3911,7 +3824,7 @@ struct query Queries2[] = {
     "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,
+    NULL,
     0,
     &ashi_validate,
   },
@@ -3983,7 +3896,7 @@ struct query Queries2[] = {
     DELETE,
     "sh",
     SERVERHOSTS_TABLE,
-    (char *)0,
+    NULL,
     dshi_fields,
     0,
     "service = UPPER('%s') AND mach_id = %d",
@@ -4118,7 +4031,7 @@ struct query Queries2[] = {
     DELETE,
     "fs",
     FILESYS_TABLE,
-    (char *)0,
+    NULL,
     dfil_fields,
     0,
     "filsys_id = %d",
@@ -4151,7 +4064,7 @@ struct query Queries2[] = {
     "INTO fsgroup (group_id, filsys_id, key) VALUES (%d, %d, '%s')",
     gfgm_fields,
     3,
-    (char *)0,
+    NULL,
     0,
     &aftg_validate,
   },
@@ -4163,7 +4076,7 @@ struct query Queries2[] = {
     DELETE,
     "fg",
     FSGROUP_TABLE,
-    (char *)0,
+    NULL,
     gfgm_fields,
     0,
     "group_id = %d AND filsys_id = %d",
@@ -4253,7 +4166,7 @@ struct query Queries2[] = {
     DELETE,
     "np",
     NFSPHYS_TABLE,
-    (char *)0,
+    NULL,
     dnfp_fields,
     0,
     "mach_id = %d AND dir = '%s'",
@@ -4301,7 +4214,7 @@ struct query Queries2[] = {
     "INTO quota (filsys_id, type, entity_id, quota, phys_id) VALUES ('%s', %d, %d, %s, %s)",
     aqot_fields,
     4,
-    (char *)0,
+    NULL,
     0,
     &aqot_validate,
   },
@@ -4328,7 +4241,7 @@ struct query Queries2[] = {
     DELETE,
     0,
     QUOTA_TABLE,
-    (char *)0,
+    NULL,
     aqot_fields,
     0,
     0,
@@ -4376,7 +4289,7 @@ struct query Queries2[] = {
     "INTO quota (type, filsys_id, entity_id, quota, phys_id ) VALUES ('USER', %d, %d, %s, %s)",
     anfq_fields,
     3,
-    (char *)0,
+    NULL,
     0,
     &anfq_validate,
   },
@@ -4403,7 +4316,7 @@ struct query Queries2[] = {
     DELETE,
     0,
     QUOTA_TABLE,
-    (char *)0,
+    NULL,
     anfq_fields,
     0,
     0,
@@ -4556,7 +4469,7 @@ struct query Queries2[] = {
     "INTO services (name, protocol, port, description) VALUES ('%s', '%s', %s, NVL('%s', CHR(0)))",
     asvc_fields,
     4,
-    (char *)0,
+    NULL,
     0,
     &asvc_validate,
   },
@@ -4721,7 +4634,7 @@ struct query Queries2[] = {
     "INTO alias (name, type, trans) VALUES ('%s', '%s', '%s')",
     aali_fields,
     3,
-    (char *)0,
+    NULL,
     0,
     &aali_validate,
   },
@@ -4733,7 +4646,7 @@ struct query Queries2[] = {
     DELETE,
     "a",
     ALIAS_TABLE,
-    (char *)0,
+    NULL,
     aali_fields,
     0,
     "name = '%s' AND type = '%s' AND  trans = '%s'",
@@ -4766,7 +4679,7 @@ struct query Queries2[] = {
     "INTO numvalues (name, value) VALUES ('%s', %s)",
     aval_fields,
     2,
-    (char *)0,
+    NULL,
     0,
     &aval_validate,
   },
@@ -4793,7 +4706,7 @@ struct query Queries2[] = {
     DELETE,
     "val",
     NUMVALUES_TABLE,
-    (char *)0,
+    NULL,
     dval_fields,
     0,
     "name = '%s'",
@@ -4811,7 +4724,7 @@ struct query Queries2[] = {
     "table_name, appends, updates, deletes, TO_CHAR(modtime, 'DD-mon-YYYY HH24:MI:SS') FROM tblstats",
     gats_fields,
     5,
-    (char *)0,
+    NULL,
     0,
     0,
   },
@@ -4821,12 +4734,12 @@ struct query Queries2[] = {
     "_set_debug_level",
     "_sdl",
     UPDATE,
-    (char *)0,
+    NULL,
     0,
-    (char *)0,
+    NULL,
     _sdl_fields,
     1,
-    (char *)0,
+    NULL,
     0,
     &_sdl_validate,
   },
index ffb3af810c725eeb5160a9864c83464c697f5f5a..8cb6b777cbc2ed084bf4d88d9b71be4403a55bc2 100644 (file)
@@ -1,6 +1,10 @@
-/* $Header$
+/* $Id$
  *
  * Structures and constants used in the query dispatch table
+ *
+ * Copyright (C) 1987-1998 by the Massachusetts Institute of Technology.
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
  */
 
 /* Query Types */
@@ -46,15 +50,15 @@ struct validate
   /* values field containing current max object id */
   char *object_id;
   /* routine to verify access permission on objects */
-  int (*acs_rtn)();
+  int (*acs_rtn)(struct query *q, char *Argv[], client *cl);
   /* pre-processing routine (var setup only) */
-  int (*pre_rtn)();
+  int (*pre_rtn)(struct query *q, char *Argv[], client *cl);
   /* post-processing routine */
   int (*post_rtn)();
 };
 
 /* Validated Object Types */
-enum vo_type {V_NAME, V_ID, V_TYPE, V_TYPEDATA, V_DATE,
+enum vo_type {V_NAME, V_ID, V_TYPE, V_TYPEDATA,
              V_SORT, V_RENAME, V_CHAR, V_LOCK, V_WILD, V_UPWILD,
               V_RLOCK, V_LEN};
 
@@ -93,6 +97,8 @@ 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)(), char *actarg);
-void help_query(struct query *q, int (*action)(), char *actarg);
+void list_queries(int version, int (*action)(int, char *[], void *),
+                 void *actarg);
+void help_query(struct query *q, int (*action)(int, char *[], void *),
+               void *actarg);
 struct query *get_query_by_name(char *name, int version);
index fa25f891bd29018260c1811db9082dbd8c1064ef..a70a73800a791859c282ef0274942d515b5f5673 100644 (file)
@@ -1,27 +1,26 @@
-/*
- *     $Source$
- *     $Author$
- *     $Header$
+/* $Id$
  *
- *     Copyright (C) 1987 by the Massachusetts Institute of Technology
- *     For copying and distribution information, please see the file
- *     <mit-copyright.h>.
+ * Argument validation routines
  *
+ * Copyright (C) 1987-1998 by the Massachusetts Institute of Technology
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
  */
 
-#ifndef lint
-static char *rcsid_qsupport_dc = "$Header$";
-#endif lint
-
 #include <mit-copyright.h>
-#include <unistd.h>
 #include "mr_server.h"
 #include "query.h"
+#include "qrtn.h"
+
 #include <ctype.h>
+#include <stdlib.h>
 #include <string.h>
+#include <unistd.h>
+
 EXEC SQL INCLUDE sqlca;
 EXEC SQL INCLUDE sqlda;
-#include "qrtn.h"
+
+RCSID("$Header$");
 
 extern char *whoami, *table_name[], *sqlbuffer[QMAXARGS];
 extern int dbms_errno, mr_errcode;
@@ -42,6 +41,7 @@ int readlock_table(struct valobj *vo);
 int convert_wildcards_uppercase(char *arg);
 
 extern SQLDA *sqlald(int, int, int);
+SQLDA *mr_alloc_sqlda(void);
 
 EXEC SQL WHENEVER SQLERROR DO dbmserr();
 
@@ -200,7 +200,6 @@ static int illegalchars[] = {
 int validate_chars(char *argv[], struct valobj *vo)
 {
   char *s = argv[vo->index];
-  int arg;
   EXEC SQL BEGIN DECLARE SECTION;
   int len;
   char *tname, *cname;
@@ -209,7 +208,7 @@ int validate_chars(char *argv[], struct valobj *vo)
   /* check for bad characters */
   while (*s)
     {
-      if (illegalchars[*s++])
+      if (illegalchars[(int)*s++])
        return MR_BAD_CHAR;
     }
 
@@ -373,7 +372,7 @@ int validate_type(char *argv[], struct valobj *vo)
   c = val = argv[vo->index];
   while (*c)
     {
-      if (illegalchars[*c++])
+      if (illegalchars[(int)*c++])
        return MR_BAD_CHAR;
     }
 
@@ -586,7 +585,7 @@ void sanity_check_database(void)
 char *sqlbuffer[QMAXARGS];
 
 /* Dynamic SQL support routines */
-SQLDA *mr_alloc_sqlda()
+SQLDA *mr_alloc_sqlda(void)
 {
   SQLDA *it;
   int j;
@@ -698,7 +697,7 @@ int convert_wildcards_uppercase(char *arg)
 int add_string(char *nm)
 {
   EXEC SQL BEGIN DECLARE SECTION;
-  char buf[256], *name = nm;
+  char *name = nm;
   int id;
   EXEC SQL END DECLARE SECTION;
 
@@ -706,7 +705,7 @@ int add_string(char *nm)
   id++;
   EXEC SQL UPDATE numvalues SET value = :id WHERE name = 'strings_id';
 
-  EXEC SQL INSERT INTO strings (string_id, string) VALUES (:id, :nm);
+  EXEC SQL INSERT INTO strings (string_id, string) VALUES (:id, :name);
 
   return id;
 }
index adacf8ad413114fcbd53389323e4ca67f718eff2..a85bc6800760bca76fd1094fb8444ce50069ce2d 100644 (file)
@@ -1,41 +1,34 @@
-/*
- *     $Source$
- *     $Author$
- *     $Header$
+/* $Id$
  *
- *     Copyright (C) 1987 by the Massachusetts Institute of Technology
- *     For copying and distribution information, please see the file
- *     <mit-copyright.h>.
- *
- *     This program starts the moira server in a "clean" environment.
- *     and then waits for it to exit.
+ * This program starts the moira server in a "clean" environment.
+ * and then waits for it to exit.
  *
+ * Copyright (C) 1987-1998 by the Massachusetts Institute of Technology
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
  */
 
-#ifndef lint
-static char *rcsid_mr_starter_c = "$Header$";
-#endif lint
-
 #include <mit-copyright.h>
+#include <moira.h>
+#include <moira_site.h>
+
+#include <sys/resource.h>
+#include <sys/wait.h>
+
 #include <errno.h>
+#include <fcntl.h>
+#include <signal.h>
 #include <stdio.h>
 #include <string.h>
-#include <sys/types.h>
-#include <sys/file.h>
-#include <sys/wait.h>
-#include <sys/signal.h>
-#include <sys/ioctl.h>
-#include <time.h>
-#include <fcntl.h>
-#include <sys/resource.h>
-#include <moira_site.h>
+#include <unistd.h>
 
+RCSID("$Header$");
 
 #define PROG   "moirad"
 
 int rdpipe[2];
-extern int errno;
 char *whoami;
+void cleanup(void);
 
 void cleanup(void)
 {
@@ -71,12 +64,9 @@ int main(int argc, char *argv[])
 {
   char buf[BUFSIZ];
   FILE *log, *prog;
-  int logf, inf, i, done, pid, tty;
+  int logf, inf, i, done, pid;
   struct rlimit rl;
 
-  extern int errno;
-  extern char *sys_errlist[];
-
   struct sigaction action;
   int nfds;
 
@@ -149,7 +139,7 @@ int main(int argc, char *argv[])
          if (errno && errno != EINTR)
            {
              strcpy(buf, "Unable to read from program: ");
-             strcat(buf, sys_errlist[errno]);
+             strcat(buf, strerror(errno));
              strcat(buf, "\n");
            }
          else
index cac267da83cadb3c719ead32e47ea20701bb178a..1521bf11c6f4cfe75fedcff15cb63431027f890d 100644 (file)
@@ -9,7 +9,7 @@
 #
 
 SRCS=  auth_002.c checksum.c client.c config.c exec_002.c \
-       get_file.c hostname.c log.c send_file.c ticket.c \
+       get_file.c log.c send_file.c ticket.c \
        update_server.c update_test.c xfer_002.c xfer_003.c
 SRCDIR=${SRCTOP}/update
 CODE=${SRCS} Imakefile
index fa9a31e12d6770d72050467ac60197ddc178913c..28c11dc297bc6a3bc6b8e83d6cade5c0e73f22ff 100644 (file)
@@ -1,33 +1,28 @@
-/*
- *     $Source$
- *     $Header$
+/* $Id$
+ *
+ * Copyright (C) 1988-1998 by the Massachusetts Institute of Technology.
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
  */
-/*  (c) Copyright 1988 by the Massachusetts Institute of Technology. */
-/*  For copying and distribution information, please see the file */
-/*  <mit-copyright.h>. */
-
-#ifndef lint
-static char *rcsid_auth_002_c = "$Header$";
-#endif
 
 #include <mit-copyright.h>
+#include <moira.h>
+#include "update_server.h"
+
+#include <sys/utsname.h>
+
+#include <errno.h>
 #include <stdio.h>
-#include <string.h>
+
 #include <gdb.h>
 #include <krb.h>
-#include <krb_et.h>
-#include <netinet/in.h>
-#include <errno.h>
-#ifdef POSIX
-#include <sys/utsname.h>
-#endif
+
+RCSID("$Header$");
 
 extern char buf[BUFSIZ];
 extern int have_authorization;
-extern struct sockaddr_in *client_address();
 extern CONNECTION conn;
 extern int code;
-extern char *PrincipalHostname();
 static char service[] = "rcmd";
 static char master[] = "sms";
 static char qmark[] = "???";
@@ -49,10 +44,9 @@ extern C_Block session;
 int auth_002(char *str)
 {
   STRING data;
-  char realm[REALM_SZ];
   char aname[ANAME_SZ], ainst[INST_SZ], arealm[REALM_SZ];
   AUTH_DAT ad;
-  char *p, *first, *config_lookup();
+  char *p, *first;
   KTEXT_ST ticket_st;
   struct utsname name;
   des_key_schedule sched;
@@ -85,7 +79,7 @@ int auth_002(char *str)
    * authenticator we received, then accept it.  If there's no
    * auth record, assume [master]@[local realm].
    */
-  if (first = p = config_lookup("auth"))
+  if ((first = p = config_lookup("auth")))
     {
       do
        {
index fdb47266e337eed916f73ae2c15145474c915e77..5a2323dcc9c584921a337506529d7595a3ba737f 100644 (file)
@@ -1,19 +1,17 @@
-/*
- *     $Source$
- *     $Header$
+/* $Id$
+ *
+ * Copyright (C) 1988-1998 by the Massachusetts Institute of Technology.
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
  */
-/*  (c) Copyright 1988 by the Massachusetts Institute of Technology. */
-/*  For copying and distribution information, please see the file */
-/*  <mit-copyright.h>. */
-
-#ifndef lint
-static char *rcsid_checksum_c = "$Header$";
-#endif
 
 #include <mit-copyright.h>
+#include <moira.h>
+#include "update_server.h"
+
 #include <stdio.h>
-#include <sys/types.h>
-#include <sys/file.h>
+
+RCSID("$Header$");
 
 /*
  * checksum_fd(fd)
index f72746efca863d671e83ffe47917a6203f10d082..f982fdf3fa1e11ca02368b1b51698211d89b42c8 100644 (file)
@@ -1,78 +1,30 @@
-/*
- *     $Source$
- *     $Header$
- */
-
-#ifndef lint
-static char *rcsid_client2_c = "$Header$";
-#endif lint
-
-/*
- * MODULE IDENTIFICATION:
- *     $Header$
- *     Copyright 1987, 1988 by the Massachusetts Institute of Technology.
- *     For copying and distribution information, please see the file
- *     <mit-copyright.h>.
- * DESCRIPTION:
- *     This code handles the actual distribution of data files
- *     to servers in the Moira server-update program.
- * AUTHOR:
- *     Ken Raeburn (spook@athena.MIT.EDU),
- *             MIT Project Athena/MIT Information Systems.
- * DEFINED VALUES:
- *     conn
- *     mr_update_server
+/* $Id$
+ *
+ * This code handles the actual distribution of data files
+ * to servers in the Moira server-update program.
+ *
+ * Copyright (C) 1987-1998 by the Massachusetts Institute of Technology.
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
  */
 
 #include <mit-copyright.h>
+#include <moira.h>
+#include "update.h"
+
 #include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
+
+#include <des.h>
 #include <gdb.h>
-#include <sys/param.h>
-#include <sys/wait.h>
-#include <sys/socket.h>
-#include <update.h>
-#include <errno.h>
-#include <moira.h>
-#include <moira_site.h>
 #include <krb.h>
 
-extern int errno, dbg;
-extern C_Block session;
+RCSID("$Header$");
 
-static char buf[BUFSIZ];
-static int code;
+extern int dbg;
+extern C_Block session;
 
 CONNECTION conn;
 
-
-/*
- * FUNCTION:
- *     initialize()
- * DESCRIPTION:
- *     Insures that various libraries have a chance to get
- *     initialized.
- * INPUT:
- * OUTPUT:
- * RETURN VALUE:
- *     void
- * SIDE EFFECTS:
- *     Initializes GDB library.
- * PROBLEMS:
- *
- */
-static void initialize()
-{
-  static int initialized = 0;
-
-  if (!initialized)
-    {
-      gdb_init();
-      initialized++;
-    }
-}
-
 int send_auth(char *host_name)
 {
   KTEXT_ST ticket_st;
@@ -161,7 +113,7 @@ int execute(char *path)
   return MR_SUCCESS;
 }
 
-send_quit(void)
+void send_quit(void)
 {
   STRING str;
   if (!conn)
index c76592c33c7d4d7abf3c54ebccf6d77c6b7ee2cf..0f7b35c18474c19d526a07f3237ac2abb3bd3728 100644 (file)
@@ -1,26 +1,29 @@
-/* $Header$
+/* $Id$
  *
  * Routines to handle configuration file for Moira's update_server.
  * These routines must load the file into memory rather than parse
  * it each time as one of the things the server may do is chroot()
  * itself.
  *
- * (c) Copyright 1992 by the Massachusetts Institute of Technology.
+ * Copyright (C) 1992-1998 by the Massachusetts Institute of Technology.
  * For copying and distribution information, please see the file
  * <mit-copyright.h>.
  */
 
 #include <mit-copyright.h>
+#include <moira.h>
+#include "update_server.h"
+
+#include <sys/stat.h>
+
+#include <ctype.h>
+#include <fcntl.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-#include <ctype.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <sys/file.h>
-#include <fcntl.h>
-#include <moira.h>
+#include <unistd.h>
 
+RCSID("$Header$");
 
 #define CONFIG_FILE    "/etc/athena/moira.conf"
 
@@ -38,11 +41,11 @@ static char *config_buf = NULL;
 static char **config_keys, **config_values;
 
 
-static init()
+static int init(void)
 {
   int fd, count = 0;
   struct stat st;
-  char *p, *start;
+  char *p;
 
   /* Only execute once */
   if (config_buf)
index 50f817392d5789c585222dc8962a941b7f225be5..aeec495c18d5634077fa16aadbbfa05b38c6fcce 100644 (file)
@@ -1,27 +1,28 @@
-/*
- *     $Source$
- *     $Header$
+/* $Id$
+ *
+ * Copyright (C) 1988-1998 by the Massachusetts Institute of Technology.
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
  */
-/*  (c) Copyright 1988 by the Massachusetts Institute of Technology. */
-/*  For copying and distribution information, please see the file */
-/*  <mit-copyright.h>. */
-
-#ifndef lint
-static char *rcsid_exec_002_c = "$Header$";
-#endif
 
 #include <mit-copyright.h>
-#include <stdio.h>
-#include <errno.h>
-#include <sys/types.h>
+#include <moira.h>
+#include "update_server.h"
+#include "update.h"
+
 #include <sys/wait.h>
+
+#include <errno.h>
 #include <signal.h>
+#include <stdio.h>
+#include <unistd.h>
+
 #include <gdb.h>
-#include <moira.h>
-#include "update.h"
+
+RCSID("$Header$");
 
 extern CONNECTION conn;
-extern int code, errno, uid, log_priority, have_authorization;
+extern int code, uid, log_priority, have_authorization;
 extern char *whoami;
 
 int exec_002(char *str)
@@ -106,4 +107,5 @@ int exec_002(char *str)
            exit(1);
        }
     }
+  return 0;
 }
index 8ce07b3c7f6d7eb4b4a4fffdc1aac63e5b99e2fd..04053504d60b0cfe52308a68869fea9911bd3fb8 100644 (file)
@@ -1,28 +1,25 @@
-/*
- *     $Source$
- *     $Header$
+/* $Id$
+ *
+ * Copyright (C) 1988-1998 by the Massachusetts Institute of Technology.
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
  */
-/*  (c) Copyright 1988 by the Massachusetts Institute of Technology. */
-/*  For copying and distribution information, please see the file */
-/*  <mit-copyright.h>. */
-
-#ifndef lint
-static char *rcsid_get_file_c = "$Header$";
-#endif
 
 #include <mit-copyright.h>
-#include <stdio.h>
-#include <gdb.h>
-#include <ctype.h>
-#include <string.h>
-#include <sys/param.h>
-#include <sys/file.h>
-#include <fcntl.h>
-#include <des.h>
-#include <krb.h>
 #include <moira.h>
+#include "update_server.h"
 #include "update.h"
 
+#include <errno.h>
+#include <fcntl.h>
+#include <stdio.h>
+#include <unistd.h>
+
+#include <des.h>
+#include <gdb.h>
+
+RCSID("$Header$");
+
 #ifndef MIN
 #define MIN(a, b)    (((a) < (b)) ? (a) : (b))
 #endif /* MIN */
@@ -30,7 +27,7 @@ static char *rcsid_get_file_c = "$Header$";
 extern CONNECTION conn;
 extern char buf[BUFSIZ];
 
-extern int code, errno, uid;
+extern int code, uid;
 extern char *whoami;
 
 extern int have_authorization, have_file, done;
@@ -38,7 +35,7 @@ extern C_Block session;
 static des_key_schedule sched;
 static des_cblock ivec;
 
-static int get_block();
+static int get_block(int fd, int max_size, int encrypt);
 
 /*
  * get_file()
@@ -135,7 +132,7 @@ int get_file(char *pathname, int file_size, int checksum,
        }
       n_written += n_wrote;
     }
-  lseek(fd, 0, L_SET);
+  lseek(fd, 0, SEEK_SET);
   if (send_ok())
     lose("sending okay for file transfer (get_file)");
   if (encrypt)
diff --git a/update/hostname.c b/update/hostname.c
deleted file mode 100644 (file)
index 081d731..0000000
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- *     $Source$
- *     $Header$
- */
-/*  (c) Copyright 1988 by the Massachusetts Institute of Technology. */
-/*  For copying and distribution information, please see the file */
-/*  <mit-copyright.h>. */
-
-#ifndef lint
-static char *rcsid_hostname_c = "$Header$";
-#endif lint
-
-/* PrincipalHostname, borrowed from rcmd.c in Kerberos code */
-#include <mit-copyright.h>
-#include <stdio.h>
-#include <sys/types.h>
-#include <netinet/in.h>
-#include <netdb.h>
-#include <ctype.h>
-#include <string.h>
-
-char *PrincipalHostname(char *alias)
-{
-  struct hostent *h;
-  char *phost = alias;
-  if ((h = gethostbyname(alias)))
-    {
-      char *p = strchr(h->h_name, '.');
-      if (p)
-       *p = NULL;
-      p = phost = h->h_name;
-      do
-       {
-         if (isupper(*p))
-           *p = tolower(*p);
-       }
-      while (*p++);
-    }
-  return phost;
-}
index c4cf6319cf26ccc4633694ea77a59e20ac519d9e..b4e921dd5628975b3da5bc2018ae5dca88474189 100644 (file)
@@ -1,32 +1,20 @@
-/*
- *     $Source$
- *     $Header$
- */
-/*  (c) Copyright 1988 by the Massachusetts Institute of Technology. */
-/*  For copying and distribution information, please see the file */
-/*  <mit-copyright.h>. */
-
-#ifndef lint
-static char *rcsid_log_c = "$Header$";
-#endif
-
-/*
+/* $Id$
+ *
  * handle logging for dcm and update server
  *
- * this should eventually use zephyr
- */
-
-/*
- * define syslog for using syslog,
- * default to tty
+ * Copyright (C) 1988-1998 by the Massachusetts Institute of Technology.
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
  */
 
 #include <mit-copyright.h>
+#include <moira.h>
+#include "update_server.h"
+
 #include <stdio.h>
-#include "com_err.h"
 #include <stdarg.h>
+
 #include "update.h"
-#include <krb.h>
 
 #ifdef use_syslog
 #include <syslog.h>
@@ -34,6 +22,11 @@ static char *rcsid_log_c = "$Header$";
 #define use_tty
 #endif
 
+RCSID("$Header$");
+
+void mr_update_com_err_hook(const char *whoami, long code,
+                           const char *fmt, va_list args);
+
 #ifdef use_syslog
 int syslog_prio[] = {
   LOG_DEBUG,
@@ -49,7 +42,6 @@ void mr_update_com_err_hook(const char *whoami, long code,
                            const char *fmt, va_list args)
 {
   char buf[BUFSIZ], *cp;
-  FILE _strbuf;
 
 #ifndef use_syslog
   strcpy(buf, whoami);
@@ -76,7 +68,7 @@ void mr_update_com_err_hook(const char *whoami, long code,
 #endif
 }
 
-mr_update_initialize(void)
+void mr_update_initialize(void)
 {
   static int initialized = 0;
   if (initialized)
@@ -93,7 +85,7 @@ mr_update_initialize(void)
 static char fmt[] = "[%s] %s";
 
 #define        def(name, level, prio) \
-name(char *msg)\
+void name(char *msg)\
 {\
    int old_prio; \
    old_prio = log_priority; \
index b5ff17fcf0f10dca2e9fdfa3411903c34ff356fa..5e12ef81d6e42fbd7638ec8c6bae924ccfe0b5e3 100644 (file)
@@ -1,29 +1,29 @@
-/*
- *     $Source$
- *     $Header$
+/* $Id$
+ *
+ * Copyright (C) 1988-1998 by the Massachusetts Institute of Technology.
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
  */
-/*  (c) Copyright 1988 by the Massachusetts Institute of Technology. */
-/*  For copying and distribution information, please see the file */
-/*  <mit-copyright.h>. */
-
-#ifndef lint
-static char *rcsid_send_file_c = "$Header$";
-#endif
 
 #include <mit-copyright.h>
-#include <stdio.h>
-#include <com_err.h>
-#include <gdb.h>
 #include <moira.h>
-#include <sys/file.h>
+#include "update_server.h"
+
 #include <sys/stat.h>
+
+#include <errno.h>
+#include <fcntl.h>
+#include <stdio.h>
+#include <string.h>
+#include <unistd.h>
+
 #include <des.h>
-#include <krb.h>
+#include <gdb.h>
 #include <update.h>
-#include <fcntl.h>
+
+RCSID("$Header$");
 
 extern CONNECTION conn;
-extern int errno;
 char buf[BUFSIZ];
 extern C_Block session;
 extern char *whoami;
index c2d6f09674e54c9160289af6990290e5982a28fc..f482c597d4c841034b33de1de2e70ced7993e931 100644 (file)
@@ -1,15 +1,22 @@
-/* $Header$ */
-
-/*  (c) Copyright 1988 by the Massachusetts Institute of Technology. */
-/*  For copying and distribution information, please see the file */
-/*  <mit-copyright.h>. */
-
+/* $Id$
+ *
+ * Copyright (C) 1988-1998 by the Massachusetts Institute of Technology.
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
+ */
 
 #include <mit-copyright.h>
-#include <stdio.h>
-#include <sys/file.h>
+#include <moira.h>
+
 #include <fcntl.h>
+#include <stdio.h>
+#include <string.h>
+#include <unistd.h>
+
 #include <des.h>
+
+RCSID("$Header$");
+
 int debug = 0;                 /* goddamn des library breakage */
 char string[] = "sms\0\0Athena\0\1";
 char srvtab[] = "/etc/srvtab";
@@ -20,7 +27,7 @@ int main(int argc, char **argv)
 {
   int fd;
   C_Block key;
-  char *tty, *ttyname();
+  char *tty;
   tty = ttyname(0);
   if (!tty || strcmp(tty, "/dev/console"))
     {
@@ -45,4 +52,5 @@ int main(int argc, char **argv)
     perror(srvtab);
   close(fd);
   printf("\nKey written.\n");
+  exit(0);
 }
index 3b081f8d4cd0da0b07c1f42464fc36045284b7b0..155fa9de4ad257b2c5d01863f6d9fd387dbfb547 100644 (file)
@@ -1,24 +1,22 @@
-/*
- *     $Source$
- *     $Header$
+/* $Id$
+ *
+ * Copyright (C) 1988-1998 by the Massachusetts Institute of Technology.
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
  */
-/*  (c) Copyright 1988 by the Massachusetts Institute of Technology. */
-/*  For copying and distribution information, please see the file */
-/*  <mit-copyright.h>. */
-
-#ifndef lint
-static char *rcsid_ticket_c = "$Header$";
-#endif
 
 #include <mit-copyright.h>
-#include <stdio.h>
-#include <krb.h>
-#include <sys/types.h>
+#include <moira.h>
+
 #include <sys/stat.h>
+
+#include <stdio.h>
 #include <string.h>
+
+#include <krb.h>
 #include <update.h>
-#include <com_err.h>
-#include <krb_et.h>
+
+RCSID("$Header$");
 
 extern char *whoami;
 
@@ -29,8 +27,9 @@ static char master[INST_SZ] = "sms";
 static char service[ANAME_SZ] = "rcmd";
 C_Block session;
 
+int get_mr_tgt(void);
 
-static init(void)
+static void init(void)
 {
   static int initialized = 0;
 
index 65b8a8da8b78d23b60d33b9906334b14eac7b4b2..a739a3f8d6e8186b6ca822651365b29e91f6ac62 100644 (file)
@@ -1,38 +1,28 @@
-/*
- *     $Source$
- *     $Header$
+/* $Id$
+ *
+ * Copyright 1988-1998 by the Massachusetts Institute of Technology.
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
  */
-/*  (c) Copyright 1988 by the Massachusetts Institute of Technology. */
-/*  For copying and distribution information, please see the file */
-/*  <mit-copyright.h>. */
-
-#ifndef lint
-static char *rcsid_dispatch_c = "$Header$";
-#endif
 
 #include <mit-copyright.h>
+#include <moira.h>
+#include "update_server.h"
+
+#include <sys/stat.h>
+
+#include <pwd.h>
 #include <stdio.h>
 #include <stdlib.h>
-#include <gdb.h>
-#include <errno.h>
 #include <string.h>
-#include <pwd.h>
-#include <moira.h>
-#include <sys/file.h>
-#include <fcntl.h>
-#include <sys/ioctl.h>
-#ifdef POSIX
-#include <termios.h>
-#endif
-#include "update.h"
-#include "des.h"
+#include <unistd.h>
 
-extern int auth_002(), xfer_002(), xfer_003(), exec_002();
+#include <des.h>
+#include <gdb.h>
+#include "update.h"
 
-extern int sync_proc(), quit();
-extern char *config_lookup();
+RCSID("$Header$");
 
-extern void gdb_debug();
 extern int errno;
 
 CONNECTION conn;
@@ -51,14 +41,14 @@ int _send_int;
 
 struct _dt {
   char *str;
-  int (*proc)();
+  int (*proc)(char *);
 } dispatch_table[] = {
   { "AUTH_002", auth_002 },
   { "XFER_002", xfer_002 },
   { "XFER_003", xfer_003 },
   { "EXEC_002", exec_002 },
   { "quit", quit },
-  { NULL, (int (*)())abort }
+  { NULL, (int (*)(char *))abort }
 };
 
 /* general scratch space -- useful for building error messages et al... */
@@ -69,7 +59,6 @@ int main(int argc, char **argv)
   STRING str;
   struct _dt *d;
   char *p;
-  int n;
 
   whoami = strrchr(argv[0], '/');
   if (whoami)
@@ -187,7 +176,7 @@ int send_ok(void)
 }
 
 
-initialize(void)
+void initialize(void)
 {
   /* keep have_authorization around */
   have_file = 0;
@@ -221,7 +210,7 @@ int quit(char *str)
  * put <msg> to log as error, break connection, and exit
  */
 
-lose(char *msg)
+void lose(char *msg)
 {
   com_err(whoami, code, msg);
   if (conn)
@@ -235,7 +224,7 @@ lose(char *msg)
  * send back (external) <code>; if error, punt big with <lose(msg)>
  */
 
-report_error(char *msg)
+void report_error(char *msg)
 {
   code = send_object(conn, (char *)&code, INTEGER_T);
   if (code)
@@ -251,7 +240,7 @@ report_error(char *msg)
  * set (external) <code> to <c> and call <report_error>
  */
 
-reject_call(int c)
+void reject_call(int c)
 {
   code = c;
   report_error("call rejected");
diff --git a/update/update_server.h b/update/update_server.h
new file mode 100644 (file)
index 0000000..0ed98dc
--- /dev/null
@@ -0,0 +1,31 @@
+/* prototypes for the update_server */
+
+int auth_002(char *str);
+int exec_002(char *str);
+int xfer_002(char *str);
+int xfer_003(char *str);
+
+/* from checksum.c */
+int checksum_file(char *path);
+
+/* from config.c */
+char *config_lookup(char *key);
+
+/* from get_file.c */
+int get_file(char *pathname, int file_size, int checksum,
+            int mode, int encrypt);
+
+/* from log.c */
+void mr_update_initialize(void);
+void mr_log_error(char *msg);
+void mr_log_warning(char *msg);
+void mr_log_info(char *msg);
+void mr_debug(char *msg);
+
+/* from update_server.c */
+void initialize(void);
+int send_ok(void);
+int quit(char *str);
+void lose(char *msg);
+void report_error(char *msg);
+void reject_call(int c);
index e3fefcb5b6bdd763c83a3ac7daebae0bb50c279b..1e10dd1aa794c9b52143e608694b86aab31ceae4 100644 (file)
@@ -1,28 +1,22 @@
-/* $Header$
+/* $Id$
  *
  * Test client for update_server protocol.
  *
- * Reads commands from the command line:
- * test host [commands...]
- *     -s file file    sends file to host
- *     -S file file    sends encrypted file to host
- *     -i file         sends instruction file to host
- *     -x file         executes instructions
- *     -n              nop
+ * Copyright 1992-1998 by the Massachusetts Institute of Technology.
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
  */
 
 #include <mit-copyright.h>
+#include <moira.h>
+#include <update.h>
+
 #include <stdio.h>
-#include <string.h>
+#include <stdlib.h>
+
 #include <gdb.h>
-#include <sys/param.h>
-#include <sys/wait.h>
-#include <sys/socket.h>
-#include <update.h>
-#include <errno.h>
-#include <moira.h>
-#include <moira_site.h>
-#include <krb.h>
+
+void usage(void);
 
 CONNECTION conn;
 char *whoami;
@@ -30,7 +24,7 @@ char *whoami;
 int main(int argc, char **argv)
 {
   char *host, service_address[256], *file, *rfile, buf[256];
-  int code, i, count = 0;
+  int code, i;
 
   whoami = argv[0];
   initialize_sms_error_table();
@@ -122,7 +116,7 @@ int main(int argc, char **argv)
   exit(code);
 }
 
-usage(void)
+void usage(void)
 {
   fprintf(stderr, "Usage: test host [commands...]\n");
   fprintf(stderr, "  Commands are:\n");
index 3b87970ce261783a8da9edec631570a684fb7844..32562c03d4eaf599a5d441d19cf83fda1ed61f23 100644 (file)
@@ -1,28 +1,27 @@
-/*
- *     $Source$
- *     $Header$
+/* $Id$
+ *
+ * Copyright (C) 1988-1998 by the Massachusetts Institute of Technology.
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
  */
-/*  (c) Copyright 1988 by the Massachusetts Institute of Technology. */
-/*  For copying and distribution information, please see the file */
-/*  <mit-copyright.h>. */
-
-#ifndef lint
-static char *rcsid_xfer_002_c = "$Header$";
-#endif
 
 #include <mit-copyright.h>
-#include <stdio.h>
-#include <gdb.h>
+#include <moira.h>
+#include "update_server.h"
+
 #include <ctype.h>
-#include <sys/param.h>
-#include <sys/file.h>
+#include <stdio.h>
+#include <stdlib.h>
 #include <string.h>
-#include <moira.h>
+
+#include <gdb.h>
+
+RCSID("$Header$");
 
 extern CONNECTION conn;
 extern char buf[BUFSIZ];
 
-extern int code, errno;
+extern int code;
 
 extern int have_authorization, have_file, done;
 
index 78069983f2d9f2c9ffc4d23b90de766498ae75e8..2138128633f3c6135d787fa2ad9a898b95a47350 100644 (file)
@@ -1,29 +1,27 @@
-/*
- *     $Source$
- *     $Header$
- */
-/*  (c) Copyright 1988, 1992 by the Massachusetts Institute of Technology.
- *  For copying and distribution information, please see the file
- *  <mit-copyright.h>.
+/* $Id$
+ *
+ * Copyright (C) 1988-1998 by the Massachusetts Institute of Technology.
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
  */
 
-#ifndef lint
-static char *rcsid_xfer_002_c = "$Header$";
-#endif
-
 #include <mit-copyright.h>
-#include <stdio.h>
-#include <gdb.h>
+#include <moira.h>
+#include "update_server.h"
+
 #include <ctype.h>
-#include <sys/param.h>
-#include <sys/file.h>
+#include <stdio.h>
+#include <stdlib.h>
 #include <string.h>
-#include <moira.h>
+
+#include <gdb.h>
+
+RCSID("$Header$");
 
 extern CONNECTION conn;
 extern char buf[BUFSIZ];
 
-extern int code, errno;
+extern int code;
 
 extern int have_authorization, have_file, done;
 
This page took 1.041919 seconds and 5 git commands to generate.