]> andersk Git - moira.git/blobdiff - gen/moddiff.dc
applied the patch from [887] in moira, to fix addresses that appeared
[moira.git] / gen / moddiff.dc
index 483a97daa7f40a04bbe053c8910bea9e5692bee3..8ab2f463d43657630bca8d44f304eeef04923d53 100644 (file)
@@ -31,23 +31,33 @@ int *flag;
 char *tbl;
 time_t ModTime;
 {
-    int filetimeno;
+    time_t filetimeno;
     EXEC SQL BEGIN DECLARE SECTION;
-    char filetime[29], *tbl_name;
+    char filetime[48], *tbl_name;
     EXEC SQL END DECLARE SECTION;
 
     *flag = 0;
     tbl_name = tbl;
-    EXEC SQL SELECT modtime INTO :filetime FROM tblstats WHERE tbl = :tbl_name;
+    EXEC SQL SELECT modtime INTO :filetime FROM tblstats 
+      WHERE table_name = :tbl_name;
     if (sqlca.sqlcode != 0) {
-       fprintf(stderr, "Query failed: %d\n", sqlca.sqlcode);
+       if (sqlca.sqlcode == -37000 ||
+           sqlca.sqlcode == 17700)
+         exit(MR_DEADLOCK);
+       fprintf(stderr, "Moddiff Query failed: %d\n", sqlca.sqlcode);
        return(MR_DATE);
     }
+#ifdef DEBUG
+    printf("about to call Date2Sec, flag = 0x%x\n", flag);
+#endif
     if (Date2Sec (filetime, &filetimeno)) {
        fprintf(stderr,"Unable to parse mod. date for file %s\n", tbl);
        return(MR_DATE);
     }
-    *flag = (filetimeno - ModTime);
+#ifdef DEBUG
+    printf("got time, flag = 0x%x\n", flag);
+#endif
+    *flag = (int) (filetimeno - ModTime);
     return(0);
 }
 
@@ -60,23 +70,22 @@ time_t ModTime;
 
 Date2Sec(DS, UTime)
 char *DS;
-struct timeval *UTime;
+time_t *UTime;
 {
     static int defzone = -1;
     int Day, Month, Year, Hour, Minute, Sec, Err, TotalDays, Iter;
+    struct timeval tv;
+    struct timezone tz;
 
     if (defzone == -1) {
-       struct timeval tv;
-       struct tzp tz;
-
-       if (gettimeofday(&tv, &tzp))
+       if (gettimeofday(&tv, &tz))
          defzone = 0;
        else
-         defzone = tzp->tz_minuteswest;
+         defzone = tz.tz_minuteswest;
     }
 
 #ifdef DEBUG
-    printf("Date2Sec(\"%s\", %d.%d)\n", DS, UTime->tv_sec, UTime->tv_usec);
+    printf("Date2Sec(\"%s\", %d)\n", DS, *UTime);
 #endif
     Err = ParseDateString (DS, &Day, &Month, &Year, &Hour, &Minute,&Sec);
 #ifdef DEBUG
@@ -95,9 +104,8 @@ struct timeval *UTime;
 #ifdef DEBUG
        printf("Days after months & days: %d\n", TotalDays);
 #endif
-       UTime->tv_sec = -((((24 * TotalDays) + 24 - Hour) * 60 - Minute) * 60 -
+       *UTime = -((((24 * TotalDays) + 24 - Hour) * 60 - Minute) * 60 -
                          Sec) + defzone;
-       UTime->tv_usec = 0;
        return (0);
     } else {
        for (TotalDays = 0, Iter = 1970; Iter < Year; Iter++) {
@@ -112,10 +120,13 @@ struct timeval *UTime;
        TotalDays += (Day - 1);
 #ifdef DEBUG
        printf("Days after Days  : %d\n", TotalDays);
+       printf("Calculating seconds...(UTime = 0x%x)\n", *UTime);
 #endif
-       UTime->tv_sec = (((24 * TotalDays) + Hour) * 60 + Minute) * 60 +
+       *UTime = (((24 * TotalDays) + Hour) * 60 + Minute) * 60 +
                        Sec + defzone;
-       UTime->tv_usec = 0;
+#ifdef DEBUG
+       printf("Calculated value of %d\n", *UTime);
+#endif
        return (0);
     }
 }
@@ -173,8 +184,8 @@ int *Day, *Month, *Year, *Hour, *Minute, *Sec;
     char *M, *D, *Temp;
     int Y=0, H=0, Min=0, S=0, DayNum=0, MonthNum=0;
 
-    M = (char *)malloc(strlen(DS));
-    D = (char *)malloc(strlen(DS));
+    M = (char *)malloc(strlen(DS) + 2);
+    D = (char *)malloc(strlen(DS) + 2);
     if (!(M && D)) return (1);
     Gotten = sscanf (DS, "%[^-]-%[^-]-%d %d:%d:%d", D, M, &Y, &H, &Min, &S);
     if (Gotten < 3) 
This page took 0.036758 seconds and 4 git commands to generate.