1 /* zoneinfo_db.h -- zoneinfo DB routines 2 * 3 * Copyright (c) 1994-2013 Carnegie Mellon University. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 9 * 1. Redistributions of source code must retain the above copyright 10 * notice, this list of conditions and the following disclaimer. 11 * 12 * 2. Redistributions in binary form must reproduce the above copyright 13 * notice, this list of conditions and the following disclaimer in 14 * the documentation and/or other materials provided with the 15 * distribution. 16 * 17 * 3. The name "Carnegie Mellon University" must not be used to 18 * endorse or promote products derived from this software without 19 * prior written permission. For permission or any legal 20 * details, please contact 21 * Carnegie Mellon University 22 * Center for Technology Transfer and Enterprise Creation 23 * 4615 Forbes Avenue 24 * Suite 302 25 * Pittsburgh, PA 15213 26 * (412) 268-7393, fax: (412) 268-7395 27 * innovation@andrew.cmu.edu 28 * 29 * 4. Redistributions of any form whatsoever must retain the following 30 * acknowledgment: 31 * "This product includes software developed by Computing Services 32 * at Carnegie Mellon University (http://www.cmu.edu/computing/)." 33 * 34 * CARNEGIE MELLON UNIVERSITY DISCLAIMS ALL WARRANTIES WITH REGARD TO 35 * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY 36 * AND FITNESS, IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY BE LIABLE 37 * FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 38 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN 39 * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING 40 * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 41 * 42 */ 43 44 #ifndef ZONEINFO_DB_H 45 #define ZONEINFO_DB_H 46 47 #include <time.h> 48 49 #include "annotate.h" /* for strlist functionality */ 50 51 /* name of the zoneinfo directory */ 52 #define FNAME_ZONEINFODIR "/zoneinfo" 53 54 /* name of the NIST leap seconds file (provided with IANA tzdata) */ 55 #define FNAME_LEAPSECFILE "/leap-seconds.list" 56 57 /* name of the world shape file (http://efele.net/maps/tz/world/) */ 58 #define FNAME_WORLD_SHAPEFILE "/tz_world.shp" 59 60 /* name of the antarctica shape file (http://efele.net/maps/tz/world/) */ 61 #define FNAME_AQ_SHAPEFILE "/tz_antarctica.shp" 62 63 /* offset between NIST and UNIX epochs (in seconds) */ 64 #define NIST_EPOCH_OFFSET 2208988800U 65 66 /* name of the zoneinfo database */ 67 #define FNAME_ZONEINFODB "/zoneinfo.db" 68 #define ZONEINFO_VERSION 1 69 70 #define INFO_TZID ".info" 71 #define zoneinfo_lookup_info(zi) zoneinfo_lookup(INFO_TZID, zi) 72 73 #define LEAP_TZID ".leap" 74 #define zoneinfo_lookup_leap(zi) zoneinfo_lookup(LEAP_TZID, zi) 75 76 struct zoneinfo { 77 unsigned type; 78 time_t dtstamp; 79 struct strlist *data; 80 }; 81 82 /* zoneinfo record types */ 83 enum { 84 ZI_ZONE = 0, 85 ZI_LINK, 86 ZI_INFO, 87 ZI_LEAP 88 }; 89 90 /* open the zoneinfo db */ 91 extern int zoneinfo_open(const char *name); 92 93 /* lookup a single zoneinfo entry and return result, or error if it 94 doesn't exist or doesn't have the fields we need */ 95 extern int zoneinfo_lookup(const char *tzid, struct zoneinfo *zi); 96 97 /* store a zoneinfo entry */ 98 extern int zoneinfo_store(const char *tzid, struct zoneinfo *zi, 99 struct txn **tid); 100 101 /* process all zoneinfo entries (optionally matching 'find') */ 102 extern int zoneinfo_find(const char *find, int tzid_only, time_t changedsince, 103 int (*proc)(const char *tzid, int tzidlen, 104 struct zoneinfo *zi, void *rock), 105 void *rock); 106 107 /* close the database (optionally committing txn) */ 108 extern void zoneinfo_close(struct txn *tid); 109 110 /* done with database stuff */ 111 extern void zoneinfo_done(void); 112 113 #endif /* ZONEINFO_DB_H */ 114