1 /*
2 * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
3 * Use is subject to license terms.
4 */
5
6 #pragma ident "%Z%%M% %I% %E% SMI"
7
8 /*
9 * zdump 7.24
10 * Taken from elsie.nci.nih.gov to replace the existing Solaris zdump,
11 * which was based on an earlier version of the elsie code.
12 *
13 * For zdump 7.24, the following changes were made to the elsie code:
14 * locale/textdomain/messages to match existing Solaris style.
15 * Solaris verbose mode is documented to display the current time first.
16 * cstyle cleaned code.
17 * removed old locale/textdomain code.
18 */
19
20 static char elsieid[] = "@(#)zdump.c 7.74";
21
22 /*
23 * This code has been made independent of the rest of the time
24 * conversion package to increase confidence in the verification it provides.
25 * You can use this code to help in verifying other implementations.
26 */
27
125 (void) fprintf(stderr, "\n%s: ", progname);
126 (void) fprintf(stderr, tformat(), *tp);
127 (void) fprintf(stderr, " ->");
128 (void) fprintf(stderr, " year=%d", tmp->tm_year);
129 (void) fprintf(stderr, " mon=%d", tmp->tm_mon);
130 (void) fprintf(stderr, " mday=%d", tmp->tm_mday);
131 (void) fprintf(stderr, " hour=%d", tmp->tm_hour);
132 (void) fprintf(stderr, " min=%d", tmp->tm_min);
133 (void) fprintf(stderr, " sec=%d", tmp->tm_sec);
134 (void) fprintf(stderr, " isdst=%d", tmp->tm_isdst);
135 (void) fprintf(stderr, " -> ");
136 (void) fprintf(stderr, tformat(), t);
137 (void) fprintf(stderr, "\n");
138 }
139 }
140 return (tmp);
141 }
142 #endif /* !defined TYPECHECK */
143
144 static void
145 abbrok(abbrp, zone)
146 const char * const abbrp;
147 const char * const zone;
148 {
149 register const char *cp;
150 int error = 0;
151
152 if (warned)
153 return;
154 cp = abbrp;
155 while (isascii(*cp) && isalpha((unsigned char)*cp))
156 ++cp;
157 (void) fflush(stdout);
158 if (cp - abbrp == 0) {
159 /*
160 * TRANSLATION_NOTE
161 * The first %s prints for the program name (zdump),
162 * the second %s prints the timezone name, the third
163 * %s prints the timezone abbreviation (tzname[0] or
164 * tzname[1]).
165 */
166 (void) fprintf(stderr, gettext("%s: warning: zone \"%s\" "
167 "abbreviation \"%s\" lacks alphabetic at start\n"),
168 progname, zone, abbrp);
169 error = 1;
170 } else if (cp - abbrp < 3) {
171 (void) fprintf(stderr, gettext("%s: warning: zone \"%s\" "
172 "abbreviation \"%s\" has fewer than 3 alphabetics\n"),
173 progname, zone, abbrp);
174 error = 1;
175 } else if (cp - abbrp > 6) {
176 (void) fprintf(stderr, gettext("%s: warning: zone \"%s\" "
177 "abbreviation \"%s\" has more than 6 alphabetics\n"),
178 progname, zone, abbrp);
179 error = 1;
180 }
181 if (error == 0 && (*cp == '+' || *cp == '-')) {
182 ++cp;
183 if (isascii(*cp) && isdigit((unsigned char)*cp))
184 if (*cp++ == '1' && *cp >= '0' && *cp <= '4')
185 ++cp;
186 if (*cp != '\0') {
187 (void) fprintf(stderr, gettext("%s: warning: "
188 "zone \"%s\" abbreviation \"%s\" differs from "
189 "POSIX standard\n"), progname, zone, abbrp);
190 error = 1;
191 }
192 }
193 if (error)
194 warned = TRUE;
195 }
196
197 int
198 main(argc, argv)
199 int argc;
200 char *argv[];
201 {
202 register int i;
203 register int c;
204 register int vflag;
205 register char *cutarg;
206 register long cutloyear = ZDUMP_LO_YEAR;
207 register long cuthiyear = ZDUMP_HI_YEAR;
208 register time_t cutlotime;
209 register time_t cuthitime;
210 time_t now;
211 time_t t;
212 time_t newt;
|
1 /*
2 * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
3 * Use is subject to license terms.
4 */
5
6 /*
7 * zdump 7.24
8 * Taken from elsie.nci.nih.gov to replace the existing Solaris zdump,
9 * which was based on an earlier version of the elsie code.
10 *
11 * For zdump 7.24, the following changes were made to the elsie code:
12 * locale/textdomain/messages to match existing Solaris style.
13 * Solaris verbose mode is documented to display the current time first.
14 * cstyle cleaned code.
15 * removed old locale/textdomain code.
16 */
17
18 static char elsieid[] = "@(#)zdump.c 7.74";
19
20 /*
21 * This code has been made independent of the rest of the time
22 * conversion package to increase confidence in the verification it provides.
23 * You can use this code to help in verifying other implementations.
24 */
25
123 (void) fprintf(stderr, "\n%s: ", progname);
124 (void) fprintf(stderr, tformat(), *tp);
125 (void) fprintf(stderr, " ->");
126 (void) fprintf(stderr, " year=%d", tmp->tm_year);
127 (void) fprintf(stderr, " mon=%d", tmp->tm_mon);
128 (void) fprintf(stderr, " mday=%d", tmp->tm_mday);
129 (void) fprintf(stderr, " hour=%d", tmp->tm_hour);
130 (void) fprintf(stderr, " min=%d", tmp->tm_min);
131 (void) fprintf(stderr, " sec=%d", tmp->tm_sec);
132 (void) fprintf(stderr, " isdst=%d", tmp->tm_isdst);
133 (void) fprintf(stderr, " -> ");
134 (void) fprintf(stderr, tformat(), t);
135 (void) fprintf(stderr, "\n");
136 }
137 }
138 return (tmp);
139 }
140 #endif /* !defined TYPECHECK */
141
142 static void
143 abbrok(const char * const abbrp, const char * const zone)
144 {
145 register const char *cp;
146 int error = 0;
147
148 if (warned)
149 return;
150 cp = abbrp;
151 while (isalpha(*cp) || isdigit(*cp) || *cp == '-' || *cp == '+')
152 ++cp;
153 (void) fflush(stdout);
154 if (cp - abbrp < 3) {
155 (void) fprintf(stderr, gettext("%s: warning: zone \"%s\" "
156 "abbreviation \"%s\" has fewer than 3 alphabetics\n"),
157 progname, zone, abbrp);
158 error = 1;
159 } else if (cp - abbrp > 6) {
160 (void) fprintf(stderr, gettext("%s: warning: zone \"%s\" "
161 "abbreviation \"%s\" has more than 6 characters\n"),
162 progname, zone, abbrp);
163 error = 1;
164 } else if (*cp != '\0') {
165 (void) fprintf(stderr, gettext("%s: warning: zone \"%s\" "
166 "abbreviation \"%s\" has characters other than "
167 "alphanumerics\n"), progname, zone, abbrp);
168 error = 1;
169 }
170 if (error)
171 warned = TRUE;
172 }
173
174 int
175 main(argc, argv)
176 int argc;
177 char *argv[];
178 {
179 register int i;
180 register int c;
181 register int vflag;
182 register char *cutarg;
183 register long cutloyear = ZDUMP_LO_YEAR;
184 register long cuthiyear = ZDUMP_HI_YEAR;
185 register time_t cutlotime;
186 register time_t cuthitime;
187 time_t now;
188 time_t t;
189 time_t newt;
|