[Asterisk-cvs] asterisk/stdtime localtime.c,1.1,1.2

markster at lists.digium.com markster at lists.digium.com
Thu Sep 18 08:32:57 CDT 2003


Update of /usr/cvsroot/asterisk/stdtime
In directory mongoose.digium.com:/tmp/cvs-serv22928/stdtime

Modified Files:
	localtime.c 
Log Message:
Grab timezone from system config


Index: localtime.c
===================================================================
RCS file: /usr/cvsroot/asterisk/stdtime/localtime.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- localtime.c	13 Sep 2003 20:51:48 -0000	1.1
+++ localtime.c	18 Sep 2003 13:34:06 -0000	1.2
@@ -650,6 +650,9 @@
 	register int			load_result;
 
 	stdname = name;
+#ifdef DEBUG
+	fprintf(stderr, "tzparse(): loading default rules\n");
+#endif
 	load_result = tzload(TZDEFRULES, sp);
 	if (load_result != 0)
 		sp->leapcnt = 0;		/* so, we're off a little */
@@ -858,7 +861,14 @@
 	}
 	memset(cur_state,0,sizeof(struct state));
 	if (tzload((char *) NULL, cur_state) != 0)
+#ifdef DEBUG
+	{
+		fprintf(stderr, "ast_tzsetwall: calling gmtload()\n");
+#endif
 		gmtload(cur_state);
+#ifdef DEBUG
+	}
+#endif
 
 	if (last_lclptr)
 		last_lclptr->next = cur_state;
@@ -920,8 +930,14 @@
 		cur_state->ttis[0].tt_abbrind = 0;
 		(void) strcpy(cur_state->chars, gmt);
 	} else if (tzload(name, cur_state) != 0)
-		if (name[0] == ':' || tzparse(name, cur_state, FALSE) != 0)
+		if (name[0] == ':') {
 			(void) gmtload(cur_state);
+		} else if (tzparse(name, cur_state, FALSE) != 0) {
+			/* If not found, load localtime */
+			if (tzload("/etc/localtime", cur_state) != 0)
+				/* Last ditch, get GMT */
+				(void) gmtload(cur_state);
+		}
 	strncpy(cur_state->name,name,sizeof(cur_state->name));
 	if (last_lclptr)
 		last_lclptr->next = cur_state;
@@ -971,6 +987,18 @@
 		sp = sp->next;
 	}
 
+	if (sp == NULL) {
+		ast_tzsetwall();
+		sp = lclptr;
+		/* Find the default zone record */
+		while (sp != NULL) {
+			if (sp->name[0] == '\0')
+				break;
+			sp = sp->next;
+		}
+	}
+
+	/* Last ditch effort, use GMT */
 	if (sp == NULL) {
 		gmtsub(timep, offset, tmp, zone);
 		return;




More information about the svn-commits mailing list