]> andersk Git - moira.git/blobdiff - gen/mitdir.qc
Used /bin/sh format instead of /bin/csh format, by accident.
[moira.git] / gen / mitdir.qc
index 584a9e5f32a6ee5f2d6521e3a7f9d7f4179ce175..f05453a321c37b1d27d699484f496c8bb0180ea8 100644 (file)
@@ -12,8 +12,8 @@
 #include <mit-copyright.h>
 #include <stdio.h>
 #include <string.h>
-#include <sms.h>
-#include <sms_app.h>
+#include <moira.h>
+#include <moira_site.h>
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <sys/time.h>
@@ -49,18 +49,18 @@ char **argv;
            if (flag1 < 0) {
                fprintf(stderr, "File %s does not need to be rebuilt.\n",
                        argv[1]);
-               exit(SMS_NO_CHANGE);
+               exit(MR_NO_CHANGE);
            }
        }
        targetfile = argv[1];
        sprintf(filename, "%s~", targetfile);
        if ((out = fopen(filename, "w")) == NULL) {
            fprintf(stderr, "unable to open %s for output\n", filename);
-           exit(SMS_OCONFIG);
+           exit(MR_OCONFIG);
        }
     } else if (argc != 1) {
        fprintf(stderr, "usage: %s [outfile]\n", argv[0]);
-       exit(SMS_ARGS);
+       exit(MR_ARGS);
     }
 
 ##  begin transaction
@@ -70,12 +70,12 @@ char **argv;
 
     if (fclose(out)) {
        perror("close failed");
-       exit(SMS_CCONFIG);
+       exit(MR_CCONFIG);
     }
 
     if (argc == 2)
       fix_file(targetfile);
-    exit(SMS_SUCCESS);
+    exit(MR_SUCCESS);
 }
 
 
@@ -94,12 +94,12 @@ static int ingerr(num)
 
     switch (*num) {
     case INGRES_DEADLOCK:
-       ingres_errno = SMS_DEADLOCK;
+       ingres_errno = MR_DEADLOCK;
        break;
     default:
-       ingres_errno = SMS_INGRES_ERR;
+       ingres_errno = MR_INGRES_ERR;
     }
-    com_err(whoami, SMS_INGRES_ERR, " code %d\n", *num);
+    com_err(whoami, MR_INGRES_ERR, " code %d\n", *num);
     critical_alert("DCM", "Alias build encountered INGRES ERROR %d", *num);
     exit(ingres_errno);
 }
@@ -111,7 +111,9 @@ FILE *out;
 ##  int id, pid, bid, mid;
 ##  char name[129], type[9], buf[257], fname[17], mname[17], lname[17];
 ##  char year[9], dept[13], oaddr[17], ophone[13], haddr[81], hphone[17];
-    char stuemp, *mhost, *uname, *pob;
+##  char affil[5];
+    int mitroom, mitphone;
+    char stuemp, *mhost, *uname, *pob, *tmp;
     struct hash *strings;
 
     /* get locks */
@@ -161,13 +163,35 @@ FILE *out;
            uname = strtrim(name);
        }
 
-       fprintf(out, "%c:%s:%s:%s:%s:",
-               stuemp, "", strtrim(lname), strtrim(fname), strtrim(mname));
-       fprintf(out, "%s:%s:%s:%s:%s:%s:%s:%s:",
-               strtrim(oaddr), "", strtrim(ophone), "",
-               "", "", uname, mhost);
-       fprintf(out, "%s:%s:%s:%s:%s:%s:%s:%s:%s:%s:%s:%d\n",
-               strtrim(haddr), "", "", "", strtrim(hphone),
-               "", "", "", "", year, "", id);
+       strtrim(oaddr);
+       if (oaddr[0] != ' ') {
+           tmp = &oaddr[strlen(oaddr) - 1];
+           if (*tmp == 'm' || *tmp == 'M') {
+               *tmp = 0;
+           }
+       }
+
+       if (tmp = index(ophone, '-')) {
+           bcopy(tmp+1, tmp, strlen(tmp)-1);
+       }
+       if (tmp = index(hphone, '-')) {
+           bcopy(tmp+1, tmp, strlen(tmp)-1);
+       }
+
+       fprintf(out, "%c:%s, %s %s:",
+               stuemp, strtrim(lname), strtrim(fname), strtrim(mname));
+       fprintf(out, "%s:%s:%s:%s::", lname, fname, mname, oaddr);
+       if (ophone[0] != ' ')
+         fprintf(out, "%010d:::%s:%s:%s:",
+                 atoi(ophone), strtrim(dept), uname, mhost);
+       else
+         fprintf(out, ":::%s:%s:%s:",
+                 strtrim(dept), uname, mhost);
+       if (hphone[0] != ' ')
+         fprintf(out, "%s:::::%010d::::%s::0\n",
+                 strtrim(haddr), atoi(hphone), year);
+       else
+         fprintf(out, "%s:::::::::%s::0\n",
+                 strtrim(haddr), year);
 ##  }
 ##}
This page took 0.040601 seconds and 4 git commands to generate.