]> andersk Git - moira.git/blobdiff - gen/util.c
DCM for TSM.
[moira.git] / gen / util.c
index 2640b2ca58bbcbd06c55aeb3512c38803021c35e..d56ea3b23663c3a1a15af743d32907e7e5fcecef 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];
 
@@ -45,7 +52,7 @@ fix_file(char *targetfile)
 }
 
 
-char *dequote(register char *s)
+char *dequote(char *s)
 {
   char *last = s;
 
@@ -64,8 +71,19 @@ char *dequote(register 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];
This page took 0.048834 seconds and 4 git commands to generate.