3 * Utility routines used by the SMS extraction programs.
5 * (c) Copyright 1988 by the Massachusetts Institute of Technology.
6 * For copying and distribution information, please see the file
11 #include <mit-copyright.h>
18 /* ingres_date_and_time: passed a unix time_t, returns a string that ingres
19 * can parse to obtain that time.
22 static char *month_name[] = {
23 "jan", "feb", "mar", "apr", "may", "jun", "jul", "aug", "sep", "oct",
28 char *ingres_date(), *ingres_time();
30 char *ingres_date_and_time(l)
33 char *ans = NULL, *date, *time;
35 if ((date = ingres_date(l)) && (time = ingres_time(l))) {
37 sprintf(buf, "%s %s", date, time);
55 if ((tm = localtime(&t)) == (struct tm *) NULL) {
60 sprintf(buf, "%02d:%02d:%02d", tm->tm_hour, tm->tm_min,
74 if ((tm = localtime(&t)) == (struct tm *) NULL) {
79 sprintf(buf, "%02d-%3.3s-%04d", tm->tm_mday,
80 month_name[tm->tm_mon], 1900 + tm->tm_year);
89 char oldfile[64], filename[64];
91 sprintf(oldfile, "%s.old", targetfile);
92 sprintf(filename, "%s~", targetfile);
93 if (rename(targetfile, oldfile) == 0) {
94 if (rename(filename, targetfile) < 0) {
95 rename(oldfile, targetfile);
96 perror("Unable to install new file (rename failed)\n");
97 fprintf(stderr, "Filename = %s\n", targetfile);
101 if (rename(filename, targetfile) < 0) {
102 perror("Unable to rename old file\n");
103 fprintf(stderr, "Filename = %s\n", targetfile);