Proposed magic number patch
John Cowan
cowan at drv.cbc.com
Tue Oct 7 20:39:36 UTC 1997
The following patch adds a "magic number" to compiled zoneinfo
files. The affected files are zic.c and tzfile.h. In essence,
the first four bytes of zoneinfo files are set to
"\0x14\0x1a\0x54\0x5a", which in ASCII is "^T^ZTZ".
This patch is trivial, but will assist in the automatic
recognition of zoneinfo files by the Unix "file" command.
*** tzfile.h Sat Jul 19 13:14:50 1997
--- tzfile.new.h Tue Oct 7 16:36:24 1997
***************
*** 46,52 ****
*/
struct tzhead {
! char tzh_reserved[20]; /* reserved for future use */
char tzh_ttisgmtcnt[4]; /* coded number of trans. time flags */
char tzh_ttisstdcnt[4]; /* coded number of trans. time flags */
char tzh_leapcnt[4]; /* coded number of leap seconds */
--- 46,53 ----
*/
struct tzhead {
! char tzh_magic[4]; /* magic string: "^T^ZTZ" */
! char tzh_reserved[16]; /* reserved for future use */
char tzh_ttisgmtcnt[4]; /* coded number of trans. time flags */
char tzh_ttisstdcnt[4]; /* coded number of trans. time flags */
char tzh_leapcnt[4]; /* coded number of leap seconds */
*** zic.c Tue Sep 23 16:37:14 1997
--- zic.new.c Tue Oct 7 16:34:30 1997
***************
*** 1468,1473 ****
--- 1468,1475 ----
convert(eitol(typecnt), tzh.tzh_typecnt);
convert(eitol(charcnt), tzh.tzh_charcnt);
#define DO(field) (void) fwrite((void *) tzh.field, (size_t) sizeof tzh.field, (size_t) 1, fp)
+ strncpy(tzh.tzh_magic, "\0x14\0x1a\0x54\0x5a", 4);
+ DO(tzh_magic);
DO(tzh_reserved);
DO(tzh_ttisgmtcnt);
DO(tzh_ttisstdcnt);
--
John Cowan http://www.ccil.org/~cowan cowan at ccil.org
e'osai ko sarji la lojban
More information about the tz
mailing list