mirror of
https://frontier.innolan.net/rainlance/amiga-tz.git
synced 2025-11-21 18:20:59 +00:00
created
SCCS-file: zdump.c SCCS-SID: 1.1
This commit is contained in:
committed by
Paul Eggert
parent
60afb5f98b
commit
264aa0f702
67
zdump.c
Normal file
67
zdump.c
Normal file
@ -0,0 +1,67 @@
|
||||
#
|
||||
|
||||
#include "stdio.h"
|
||||
|
||||
#ifdef OBJECTID
|
||||
static char sccsid[] = "%W%";
|
||||
#endif
|
||||
|
||||
#include "timezone.h"
|
||||
|
||||
extern char * newctime();
|
||||
extern int optind;
|
||||
extern char * sprintf();
|
||||
extern long time();
|
||||
|
||||
main(argc, argv)
|
||||
int argc;
|
||||
char * argv[];
|
||||
{
|
||||
register FILE * fp;
|
||||
register int i, j, c;
|
||||
int vflag;
|
||||
long now;
|
||||
struct tzinfo t;
|
||||
char buf[BUFSIZ];
|
||||
|
||||
vflag = 0;
|
||||
while ((c = getopt(argc, argv, "v")) == 'v')
|
||||
vflag = 1;
|
||||
if (c != EOF || optind == argc - 1 && strcmp(argv[optind], "=") == 0) {
|
||||
(void) fprintf(stderr, "%s: usage is %s zonename ...\n",
|
||||
argv[0], argv[0]);
|
||||
exit(1);
|
||||
}
|
||||
(void) time(&now);
|
||||
for (i = optind; i < argc; ++i) {
|
||||
if (settz(argv[i]) != 0) {
|
||||
(void) fprintf(stderr, "%s: wild result from settz(\"%s\")\n",
|
||||
argv[0], argv[i]);
|
||||
exit(1);
|
||||
}
|
||||
(void) printf("%s: %s", argv[i], newctime(&now));
|
||||
if (!vflag)
|
||||
continue;
|
||||
(void) sprintf(buf, "%s/%s", TZDIR, argv[i]);
|
||||
if ((fp = fopen(buf, "r")) == NULL &&
|
||||
(fp = fopen(argv[i], "r")) == NULL) {
|
||||
(void) fprintf(stderr, "%s: wild result opening %s file\n",
|
||||
argv[0], argv[i]);
|
||||
exit(1);
|
||||
}
|
||||
if (fread((char *) &t, sizeof t, 1, fp) != 1) {
|
||||
(void) fprintf(stderr, "%s: wild result reading %s file\n",
|
||||
argv[0], argv[i]);
|
||||
exit(1);
|
||||
}
|
||||
if (fclose(fp)) {
|
||||
(void) fprintf(stderr, "%s: wild result closing %s file\n",
|
||||
argv[0], argv[i]);
|
||||
exit(1);
|
||||
}
|
||||
for (j = 0; j < t.tz_rulecnt; ++j)
|
||||
(void) printf("%s: %s", argv[i],
|
||||
newctime(&t.tz_times[j]));
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user