From: C-o-r-E Date: Sat, 28 Jul 2012 02:58:56 +0000 (-0400) Subject: timezone stuff X-Git-Tag: 1.1.0-beta1~253^2~5 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=b15f47c54b6cb545b76593475c7fbb6e43da5eb1;p=platform%2Fupstream%2Ffreerdp.git timezone stuff --- diff --git a/libfreerdp-locale/timezone.c b/libfreerdp-locale/timezone.c index 3870117..69272b1 100644 --- a/libfreerdp-locale/timezone.c +++ b/libfreerdp-locale/timezone.c @@ -1518,16 +1518,47 @@ char* freerdp_get_unix_timezone_identifier() tzid[length - 1] = '\0'; fclose(fp) ; - } - if(tzid == NULL) - { - printf("Unable to detect time zone\n"); + printf("/etc/timezone -> tzid = [%s]\n", tzid); + return tzid; } - else + + /* On linux distros such as Redhat or Archlinux, a symlink at /etc/localtime + * will point to /usr/share/zoneinfo/region/place where region/place could be + * America/Montreal for example. + */ + + char buf[1024]; + char tz[256]; + ssize_t len; + + + if ((len = readlink("/etc/localtime", buf, sizeof(buf)-1)) != -1) + buf[len] = '\0'; + + printf("%d localtime = [%s]\n", len, buf); + + //find the position of the 2nd to last "/" + int num = 0; + int pos = len; + while(num < 2) { - printf("/etc/timezone -> tzid = [%s]\n", tzid); + if(pos == 0) + break; + + pos -= 1; + + if(buf[pos] == '/') + num++; } + + printf("looks like we want to cut at position %d\n", pos); + + strncpy(tz, buf+pos+1, len - pos); + + printf("timezone: [%s]\n", tz); + + printf("Unable to detect time zone\n"); return tzid; }