]> andersk Git - moira.git/blobdiff - gen/util.c
Make a half-hearted attempt at returning a useful exit status, instead
[moira.git] / gen / util.c
index f51f05579cd61d36e9ba4abd4461c64c23884504..b3d1aa70bc70e98c1c7d885f9b312387cd81ec69 100644 (file)
 #include <moira.h>
 #include <moira_site.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);
-       }
-}
-
+extern void sqlglm(char buf[], int *, int *);
 
 fix_file(targetfile)
 char *targetfile;
@@ -124,4 +57,23 @@ register char *s;
       *last = '\0';
     else
       *(++last) = '\0';
+    return(s);
+}
+
+
+
+db_error(code)
+int code;
+{
+    extern char *whoami;
+    char buf[256];
+    int bufsize=256, len=0;
+
+    com_err(whoami, MR_DBMS_ERR, " code %d\n", code);
+    sqlglm(buf, &bufsize, &len);
+    buf[len]=0;
+    com_err(whoami, 0, "SQL error text = %s", buf);
+    critical_alert("DCM", "%s build encountered DATABASE ERROR %d\n%s",
+                  whoami, code, buf);
+    exit(MR_DBMS_ERR);
 }
This page took 0.038064 seconds and 4 git commands to generate.