]> andersk Git - moira.git/blobdiff - gen/pobox.pc
allow for simple service monitoring via tagged members
[moira.git] / gen / pobox.pc
index c164080c7e2c7b984c0d134fc6f0ff2b264aa046..a1ee2ab015f2f6376cd3442f0f63369b0b25536d 100644 (file)
@@ -1,50 +1,45 @@
-/* $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";
 
 int main(int argc, char **argv)
 {
   FILE *out = stdout;
-  char *outf = NULL, outft[64];
-  struct stat sb;
-  int flag, i;
+  char *outf = NULL, outft[MAXPATHLEN];
+  int i;
   EXEC SQL BEGIN DECLARE SECTION;
-  char login[9], id[18], string[257];
+  char login[USERS_LOGIN_SIZE], id[USERS_CLEARID_SIZE];
+  char string[STRINGS_STRING_SIZE];
   EXEC SQL END DECLARE SECTION;
 
   EXEC SQL CONNECT :db;
 
   if (argc == 2)
     {
-      if (stat(argv[1], &sb) == 0)
-       {
-         if (ModDiff(&flag, "users", sb.st_mtime))
-           exit(MR_DATE);
-         if (flag < 0)
-           {
-             fprintf(stderr, "File %s does not need to be rebuilt.\n",
-                     argv[1]);
-             exit(MR_NO_CHANGE);
-           }
-       }
       outf = argv[1];
       sprintf(outft, "%s~", outf);
       if (!(out = fopen(outft, "w")))
@@ -69,7 +64,7 @@ int main(int argc, char **argv)
 
   EXEC SQL DECLARE x CURSOR FOR SELECT
     clearid, login
-    FROM users WHERE status != 3 and potype = 'POP';
+    FROM users WHERE status != 3 AND potype != 'NONE';
   EXEC SQL OPEN x;
   while (1)
     {
@@ -84,35 +79,6 @@ int main(int argc, char **argv)
 
   EXEC SQL CLOSE x;
 
-  EXEC SQL DECLARE y CURSOR FOR SELECT
-    u.clearid, s.string
-    FROM users u, strings s
-    WHERE u.status != 3 and u.potype = 'SMTP' and u.box_id = s.string_id;
-  EXEC SQL OPEN y;
-  while (1)
-    {
-      EXEC SQL FETCH y INTO :id, :string;
-      if (sqlca.sqlcode)
-       break;
-      strtrim(string);
-      strtrim(id);
-      if (isdigit(id[0]))
-       {
-         if ((i = strlen(string)) > 7 &&
-             !strcasecmp(".local", string + i - 6))
-           {
-             string[i - 6] = '\0';
-             fprintf(out, "%s %s.mit.edu\n", id, string);
-           }
-         else if (!strchr(string, '@'))
-           fprintf(out, "%s %s@mit.edu\n", id, string);
-         else
-           fprintf(out, "%s %s\n", id, string);
-       }
-    }
-
-  EXEC SQL CLOSE y;
-
   EXEC SQL COMMIT;
 
   if (fclose(out))
This page took 0.033779 seconds and 4 git commands to generate.