]> andersk Git - moira.git/blobdiff - gen/util.c
Command line printer manipulation client, and build goo.
[moira.git] / gen / util.c
index 320ccef6361bb9d4791bf1963dac8638b1463a4c..607bf8546e5673ce78c5a2cb733fabd19545193c 100644 (file)
@@ -1,22 +1,29 @@
-/* $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$");
+
+/* Julian day of the UNIX epoch (January 1, 1970) */
+#define UNIX_EPOCH 2440588
+
 extern void sqlglm(char buf[], int *, int *);
 
-fix_file(char *targetfile)
+void fix_file(char *targetfile)
 {
   char oldfile[64], filename[64];
 
@@ -64,8 +71,19 @@ char *dequote(char *s)
   return s;
 }
 
+time_t unixtime(char *timestring)
+{
+  time_t t;
+
+  t = strtol(timestring, &timestring, 10) - UNIX_EPOCH;
+  t = t * 24 + strtol(timestring, &timestring, 10);
+  t = t * 60 + strtol(timestring, &timestring, 10);
+  t = t * 60 + strtol(timestring, &timestring, 10);
+
+  return t;
+}
 
-db_error(int code)
+void db_error(int code)
 {
   extern char *whoami;
   char buf[256];
@@ -81,7 +99,7 @@ db_error(int 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",
+  critical_alert(whoami, "DCM", "%s build encountered DATABASE ERROR %d\n%s",
                 whoami, code, buf);
   exit(MR_DBMS_ERR);
 }
This page took 0.047927 seconds and 4 git commands to generate.