3 * Copyright (C) 1990-1998 by the Massachusetts Institute of Technology.
4 * For copying and distribution information, please see the file
8 #include <mit-copyright.h>
11 #include <sys/types.h>
18 EXEC SQL INCLUDE sqlca;
20 /* Julian day of the UNIX epoch (January 1, 1970) */
21 #define UNIX_EPOCH 2440588
23 /****************************************************************/
24 /** Return the difference between the modtime & table modtime **/
25 /** in flag variable. Return 0 if success, else errno. **/
26 /****************************************************************/
28 int ModDiff(int *flag, char *tbl, time_t ModTime)
31 EXEC SQL BEGIN DECLARE SECTION;
32 char filetime[48], *ft = filetime, *tbl_name;
33 EXEC SQL END DECLARE SECTION;
37 /* Get modtime as Julian day, hours, minutes, and seconds */
38 EXEC SQL SELECT TO_CHAR(modtime, 'J HH24 MI SS')
39 INTO :filetime FROM tblstats
40 WHERE table_name = :tbl_name;
43 fprintf(stderr, "Moddiff Query failed: %ld\n", sqlca.sqlcode);
47 filetimeno = strtol(ft, &ft, 10) - UNIX_EPOCH;
48 filetimeno = filetimeno * 24 + strtol(ft, &ft, 10);
49 filetimeno = filetimeno * 60 + strtol(ft, &ft, 10);
50 filetimeno = filetimeno * 60 + strtol(ft, &ft, 10);
52 *flag = (int) (filetimeno - ModTime);