/* $Id$ * * Copyright (C) 1990-1998 by the Massachusetts Institute of Technology. * For copying and distribution information, please see the file * . */ #include #include #include #include #include #include "util.h" EXEC SQL INCLUDE sqlca; /* Julian day of the UNIX epoch (January 1, 1970) */ #define UNIX_EPOCH 2440588 /****************************************************************/ /** Return the difference between the modtime & table modtime **/ /** in flag variable. Return 0 if success, else errno. **/ /****************************************************************/ int ModDiff(int *flag, char *tbl, time_t ModTime) { time_t filetimeno; EXEC SQL BEGIN DECLARE SECTION; char filetime[48], *ft = filetime, *tbl_name; EXEC SQL END DECLARE SECTION; *flag = 0; tbl_name = tbl; /* Get modtime as Julian day, hours, minutes, and seconds */ EXEC SQL SELECT TO_CHAR(modtime, 'J HH24 MI SS') INTO :filetime FROM tblstats WHERE table_name = :tbl_name; if (sqlca.sqlcode) { fprintf(stderr, "Moddiff Query failed: %ld\n", sqlca.sqlcode); return MR_DATE; } filetimeno = strtol(ft, &ft, 10) - UNIX_EPOCH; filetimeno = filetimeno * 24 + strtol(ft, &ft, 10); filetimeno = filetimeno * 60 + strtol(ft, &ft, 10); filetimeno = filetimeno * 60 + strtol(ft, &ft, 10); *flag = (int) (filetimeno - ModTime); return 0; }