2 * Copyright (c) 1991 - 1994, Julianne Frances Haugh
3 * Copyright (c) 1991 - 1994, Chip Rosenthal
4 * Copyright (c) 1996 - 1998, Marek Michałkiewicz
5 * Copyright (c) 2003 - 2005, Tomasz Kłoczko
6 * Copyright (c) 2007 - 2010, Nicolas François
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the distribution.
17 * 3. The name of the copyright holders or contributors may not be used to
18 * endorse or promote products derived from this software without
19 * specific prior written permission.
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
24 * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
43 #include "prototypes.h"
47 * tz - return local timezone name
49 * tz() determines the name of the local timezone by reading the
50 * contents of the file named by ``fname''.
52 /*@observer@*/const char *tz (const char *fname)
55 static char tzbuf[BUFSIZ];
56 const char *def_tz = "TZ=CST6CDT";
58 fp = fopen (fname, "r");
60 || (fgets (tzbuf, (int) sizeof (tzbuf), fp) == NULL)) {
61 def_tz = getdef_str ("ENV_TZ");
62 if ((NULL == def_tz) || ('/' == def_tz[0])) {
63 def_tz = "TZ=CST6CDT";
66 strcpy (tzbuf, def_tz);
68 tzbuf[strlen (tzbuf) - 1] = '\0';
78 extern int errno; /* warning: ANSI C forbids an empty source file */