]> andersk Git - moira.git/blobdiff - gen/util.c
cleaned up outputs in host table
[moira.git] / gen / util.c
index d241de8da1e01a9de87bd9390a96e6f602303f7f..8bbe23900bb0e24bd17a78bbbb96a3527ec88257 100644 (file)
@@ -1,81 +1,18 @@
 /* $Header$
  *
- * Utility routines used by the SMS extraction programs.
+ * 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>.
  */
 
 
+#include <mit-copyright.h>
 #include <stdio.h>
 #include <sys/time.h>
-#include <sms.h>
-#include <sms_app.h>
-
-
-/* ingres_date_and_time: passed a unix time_t, returns a string that ingres
- * can parse to obtain that time.
- */
-
-static char *month_name[] = {
-    "jan", "feb", "mar", "apr", "may", "jun", "jul", "aug", "sep", "oct",
-    "nov", "dec"
-  };
-
-
-char *ingres_date(), *ingres_time();
-
-char *ingres_date_and_time(l)
-long l;
-{
-       char *ans = NULL, *date, *time;
-      
-       if ((date = ingres_date(l)) && (time = ingres_time(l))) {
-               char buf[BUFSIZ];
-               sprintf(buf, "%s %s", date, time);
-               ans = strsave(buf);
-       }
-       if (date)
-               free(date);
-       if (time)
-               free(time);
-       return ans;
-}
-
-char *ingres_time(t)
-       long t;
-{
-       struct tm *tm;
-
-       if (t == (long) 0)
-               (void) time(&t);
-
-       if ((tm = localtime(&t)) == (struct tm *) NULL) {
-               return NULL;
-       } else {
-               char buf[BUFSIZ];
-
-               sprintf(buf, "%02d:%02d:%02d", tm->tm_hour, tm->tm_min,
-                       tm->tm_sec);
-               return strsave(buf);
-       }
-}
-
-char *ingres_date(t)
-       long t;
-{
-       struct tm *tm;
-
-       if (t == (long) 0)
-               (void) time(&t);
-
-       if ((tm = localtime(&t)) == (struct tm *) NULL) {
-               return NULL;
-       } else {
-               char buf[BUFSIZ];
-
-               sprintf(buf, "%02d-%3.3s-%04d", tm->tm_mday,
-                       month_name[tm->tm_mon], 1900 + tm->tm_year);
-               return strsave(buf);
-       }
-}
+#include <moira.h>
+#include <moira_site.h>
 
 
 fix_file(targetfile)
@@ -90,13 +27,13 @@ char *targetfile;
            rename(oldfile, targetfile);
            perror("Unable to install new file (rename failed)\n");
            fprintf(stderr, "Filename = %s\n", targetfile);
-           exit(SMS_CCONFIG);
+           exit(MR_CCONFIG);
        }
     } else {
        if (rename(filename, targetfile) < 0) {
            perror("Unable to rename old file\n");
            fprintf(stderr, "Filename = %s\n", targetfile);
-           exit(SMS_CCONFIG);
+           exit(MR_CCONFIG);
        }
     }
     unlink(oldfile);
@@ -115,5 +52,24 @@ register char *s;
          last = s;
        s++;
     }
-    *(++last) = '\0';
+    if (*last == ' ')
+      *last = '\0';
+    else
+      *(++last) = '\0';
+    return(s);
+}
+
+
+
+db_error(code)
+int code;
+{
+    extern char *whoami;
+
+    com_err(whoami, MR_INGRES_ERR, " code %d\n", code);
+    if (code == -49900 || code == -37000 || code == 17700)
+      exit(MR_DEADLOCK);
+    critical_alert("DCM", "%s build encountered DATABASE ERROR %d",
+                  whoami, code);
+    exit(MR_INGRES_ERR);
 }
This page took 0.322421 seconds and 4 git commands to generate.