#include #include #include #define BOOL unsigned char #define TRUE 1 #define FALSE 0 #define KEY_USER_WILDCARD 1 #define KEY_HOST_WILDCARD 2 #define KEY_DOMAIN_WILDCARD 4 #define EPOCH (((unsigned long int)2<<31) - 1) int main(int, char**); unsigned long int now(void); char *long2hex(long int, BOOL); int main(int argc, char **argv) { printf("%lX -- %ld -- %s\n", EPOCH, now(), long2hex(now(), FALSE)); return(0); } /* main() */ unsigned long int now(void) { struct tm *tm_epoch; time_t epoch, recent; epoch = 0; tm_epoch = gmtime(&epoch); tm_epoch->tm_sec = tm_epoch->tm_min = tm_epoch->tm_hour = 0; tm_epoch->tm_mday = 31; tm_epoch->tm_mon = 0; tm_epoch->tm_year = 99; epoch = mktime(tm_epoch) - timezone; recent = time((time_t *)NULL); return((unsigned long int)recent - epoch); } /* now() */ char *long2hex(long int i, BOOL reverse) { char *hex; if((hex = (char *)malloc(9)) == NULL) { return((char *)NULL); } /* if */ sprintf(hex, "%08lX", (unsigned long int)(reverse ? EPOCH - i : i)); return(hex); } /* long2hex() */