#!/bin/sh # # This is a shell archive. To extract its contents, # execute this file with /bin/sh to create the file(s): # # long2time.README long2time.c # # This shell archive created: Tue Sep 17 10:15:55 EDT 2002 # echo "Extracting file long2time.README" sed -e 's/^X//' <<\SHAR_EOF > long2time.README Xlong2time.README X X Xlong2time.c Converts an ER timestamp into display format. X X XN.B. --- this is 'as is' only X X-- X--------------------------------------- XMadison Pruet XEnterprise Replication Product Development XIBM Informix Dynamic Server XDallas, Texas SHAR_EOF if [ `wc -c < long2time.README` -ne 253 ] then echo "Lengths do not match -- Bad Copy of long2time.README" fi echo "Extracting file long2time.c" sed -e 's/^X//' <<\SHAR_EOF > long2time.c X/* X * Little program to take a numeric argument from the command line, X * interpretted as a long and convert it to a date and time representation. X */ X X#include X#include X X/* X * This is the routine that actually formats the long into a time. X * It will print it out in MM/DD/YY HH:MM:SS format. X */ Xvoid XFmtTime (time_t* clock) X{ X struct tm* times; /* time format */ X X times = localtime(clock); X X fprintf (stdout, "%02d/%02d/%04d %02d:%02d:%02d\n", X times->tm_mon + 1, times->tm_mday, times->tm_year +1900, X times->tm_hour, times->tm_min, times->tm_sec); X} X X/* X * Print usage and exit if improper usage. X */ Xvoid XusageNexit(char *prog) X{ X fprintf (stderr, "Usage: %s val\n", prog); X fprintf (stderr, "\twhere val is a long representation of a time value\n"); X exit(-1); X} X Xvoid Xmain(argc, argv) Xint argc; Xchar *argv[]; X{ X long longTime; X /* Check if the correct number of args are passed in. */ X if (argc != 2) X usageNexit(argv[0]); X /* take the first argument and convert to a long. */ X if ((argv[1][0] == '0') && (argv[1][1] == 'x')) X sscanf(argv[1], "0x%x", &longTime); X else longTime = atol(argv[1]); X /* Pass that long into the formating routine. */ X FmtTime(&longTime); X} X X SHAR_EOF if [ `wc -c < long2time.c` -ne 1316 ] then echo "Lengths do not match -- Bad Copy of long2time.c" fi echo "Done." exit 0