2007-10-07 17:14:02 +05:30
|
|
|
/*
|
2021-12-05 21:05:27 +05:30
|
|
|
* SPDX-FileCopyrightText: 1991 - 1994, Julianne Frances Haugh
|
|
|
|
* SPDX-FileCopyrightText: 1991 - 1994, Chip Rosenthal
|
|
|
|
* SPDX-FileCopyrightText: 1996 - 1998, Marek Michałkiewicz
|
|
|
|
* SPDX-FileCopyrightText: 2003 - 2005, Tomasz Kłoczko
|
|
|
|
* SPDX-FileCopyrightText: 2007 - 2010, Nicolas François
|
2007-10-07 17:14:02 +05:30
|
|
|
*
|
2021-12-05 21:05:27 +05:30
|
|
|
* SPDX-License-Identifier: BSD-3-Clause
|
2007-10-07 17:14:02 +05:30
|
|
|
*/
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
2008-09-06 22:12:41 +05:30
|
|
|
#ifndef USE_PAM
|
|
|
|
|
2007-11-11 05:16:11 +05:30
|
|
|
#ident "$Id$"
|
2007-10-07 17:17:01 +05:30
|
|
|
|
2007-10-07 17:14:02 +05:30
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include "defines.h"
|
2008-01-05 18:53:22 +05:30
|
|
|
#include "prototypes.h"
|
2007-10-07 17:14:02 +05:30
|
|
|
#include "getdef.h"
|
2008-09-06 22:12:41 +05:30
|
|
|
|
2007-10-07 17:14:02 +05:30
|
|
|
/*
|
|
|
|
* tz - return local timezone name
|
|
|
|
*
|
|
|
|
* tz() determines the name of the local timezone by reading the
|
|
|
|
* contents of the file named by ``fname''.
|
|
|
|
*/
|
2010-08-22 18:19:07 +05:30
|
|
|
/*@observer@*/const char *tz (const char *fname)
|
2007-10-07 17:14:02 +05:30
|
|
|
{
|
2010-08-22 18:19:07 +05:30
|
|
|
FILE *fp = NULL;
|
2007-10-07 17:14:02 +05:30
|
|
|
static char tzbuf[BUFSIZ];
|
2007-11-20 01:55:36 +05:30
|
|
|
const char *def_tz = "TZ=CST6CDT";
|
2007-10-07 17:14:02 +05:30
|
|
|
|
2010-08-22 18:19:07 +05:30
|
|
|
fp = fopen (fname, "r");
|
|
|
|
if ( (NULL == fp)
|
|
|
|
|| (fgets (tzbuf, (int) sizeof (tzbuf), fp) == NULL)) {
|
|
|
|
def_tz = getdef_str ("ENV_TZ");
|
|
|
|
if ((NULL == def_tz) || ('/' == def_tz[0])) {
|
2007-10-07 17:14:02 +05:30
|
|
|
def_tz = "TZ=CST6CDT";
|
2010-08-22 18:19:07 +05:30
|
|
|
}
|
2007-10-07 17:14:02 +05:30
|
|
|
|
|
|
|
strcpy (tzbuf, def_tz);
|
2010-08-22 18:19:07 +05:30
|
|
|
} else {
|
2023-01-27 17:27:51 +05:30
|
|
|
/* Remove optional trailing '\n'. */
|
|
|
|
tzbuf[strcspn (tzbuf, "\n")] = '\0';
|
2010-08-22 18:19:07 +05:30
|
|
|
}
|
2007-10-07 17:14:02 +05:30
|
|
|
|
2010-08-22 18:19:07 +05:30
|
|
|
if (NULL != fp) {
|
2007-10-07 17:15:23 +05:30
|
|
|
(void) fclose (fp);
|
2010-08-22 18:19:07 +05:30
|
|
|
}
|
2007-10-07 17:14:02 +05:30
|
|
|
|
|
|
|
return tzbuf;
|
|
|
|
}
|
2008-09-06 22:12:41 +05:30
|
|
|
#else /* !USE_PAM */
|
2022-12-21 23:32:25 +05:30
|
|
|
extern int ISO_C_forbids_an_empty_translation_unit;
|
2008-09-06 22:12:41 +05:30
|
|
|
#endif /* !USE_PAM */
|
|
|
|
|