From 3cade53dad8d40c94338bba3510c142d21ab4190 Mon Sep 17 00:00:00 2001 From: C-o-r-E Date: Fri, 27 Jul 2012 17:12:15 -0400 Subject: [PATCH 1/9] added some debug output --- libfreerdp-locale/timezone.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/libfreerdp-locale/timezone.c b/libfreerdp-locale/timezone.c index a788855d7..11cd0bc45 100644 --- a/libfreerdp-locale/timezone.c +++ b/libfreerdp-locale/timezone.c @@ -1481,6 +1481,7 @@ const WINDOWS_TZID_ENTRY WindowsTimeZoneIdTable[] = char* freerdp_get_unix_timezone_identifier() { + printf("Called freerdp_get_unix_timezone_identifier\n"); FILE* fp; char* tz_env; size_t length; @@ -1491,6 +1492,7 @@ char* freerdp_get_unix_timezone_identifier() if (tz_env != NULL) { tzid = xstrdup(tz_env); + printf("tzid = [%s]\n", tzid); return tzid; } @@ -1518,6 +1520,14 @@ char* freerdp_get_unix_timezone_identifier() fclose(fp) ; } + if(tzid == NULL) + { + printf("Unable to detect time zone\n"); + } + else + { + printf("tzid = [%s]\n", tzid); + } return tzid; } @@ -1601,6 +1611,7 @@ TIME_ZONE_RULE_ENTRY* freerdp_get_current_time_zone_rule(TIME_ZONE_RULE_ENTRY* r void freerdp_time_zone_detect(TIME_ZONE_INFO* clientTimeZone) { + printf("Called time_zone_detect\n"); time_t t; struct tm* local_time; TIME_ZONE_ENTRY* tz; From 37874db0e92f290b315ebac96bc555fe75f71e4b Mon Sep 17 00:00:00 2001 From: C-o-r-E Date: Fri, 27 Jul 2012 17:38:45 -0400 Subject: [PATCH 2/9] added some debug output --- libfreerdp-locale/timezone.c | 1 + 1 file changed, 1 insertion(+) diff --git a/libfreerdp-locale/timezone.c b/libfreerdp-locale/timezone.c index 11cd0bc45..c4d7354bf 100644 --- a/libfreerdp-locale/timezone.c +++ b/libfreerdp-locale/timezone.c @@ -1578,6 +1578,7 @@ TIME_ZONE_ENTRY* freerdp_detect_windows_time_zone(uint32 bias) if (freerdp_match_unix_timezone_identifier_with_list(tzid, WindowsTimeZoneIdTable[j].tzid)) { + printf("we have a match: %s\n", tzid); timezone = (TIME_ZONE_ENTRY*) xmalloc(sizeof(TIME_ZONE_ENTRY)); memcpy((void*) timezone, (void*) &TimeZoneTable[i], sizeof(TIME_ZONE_ENTRY)); xfree(tzid); From 55232b3ead353dc38cc72a1c679c4a4e5097ef2a Mon Sep 17 00:00:00 2001 From: C-o-r-E Date: Fri, 27 Jul 2012 18:15:18 -0400 Subject: [PATCH 3/9] added more debug output --- libfreerdp-locale/timezone.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libfreerdp-locale/timezone.c b/libfreerdp-locale/timezone.c index c4d7354bf..387011771 100644 --- a/libfreerdp-locale/timezone.c +++ b/libfreerdp-locale/timezone.c @@ -1496,7 +1496,7 @@ char* freerdp_get_unix_timezone_identifier() return tzid; } - fp = fopen("/etc/timezone", "r"); + fp = fopen("TZ -> /etc/timezone", "r"); if (fp != NULL) { @@ -1526,7 +1526,7 @@ char* freerdp_get_unix_timezone_identifier() } else { - printf("tzid = [%s]\n", tzid); + printf("/etc/timezone -> tzid = [%s]\n", tzid); } return tzid; } @@ -1587,7 +1587,7 @@ TIME_ZONE_ENTRY* freerdp_detect_windows_time_zone(uint32 bias) } } } - + printf("Unable to find a match for unix timezone: %s\n", tzid); xfree(tzid); return NULL; } From b15f47c54b6cb545b76593475c7fbb6e43da5eb1 Mon Sep 17 00:00:00 2001 From: C-o-r-E Date: Fri, 27 Jul 2012 22:58:56 -0400 Subject: [PATCH 4/9] timezone stuff --- libfreerdp-locale/timezone.c | 43 +++++++++++++++++++++++++++++++----- 1 file changed, 37 insertions(+), 6 deletions(-) diff --git a/libfreerdp-locale/timezone.c b/libfreerdp-locale/timezone.c index 387011771..69272b1d3 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) ; + + printf("/etc/timezone -> tzid = [%s]\n", tzid); + return tzid; } - if(tzid == NULL) + /* 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("Unable to detect time zone\n"); - } - else - { - 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; } From 65c18d3924174f9968737ff6b4070b796b94392d Mon Sep 17 00:00:00 2001 From: C-o-r-E Date: Fri, 27 Jul 2012 23:53:35 -0400 Subject: [PATCH 5/9] Added support for timezone detection on redhad style systems using /etc/localtime --- libfreerdp-locale/timezone.c | 38 +++++++++++++++++++----------------- 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/libfreerdp-locale/timezone.c b/libfreerdp-locale/timezone.c index 69272b1d3..59d437e40 100644 --- a/libfreerdp-locale/timezone.c +++ b/libfreerdp-locale/timezone.c @@ -1529,34 +1529,36 @@ char* freerdp_get_unix_timezone_identifier() */ char buf[1024]; - char tz[256]; ssize_t len; - if ((len = readlink("/etc/localtime", buf, sizeof(buf)-1)) != -1) - buf[len] = '\0'; + { + buf[len] = '\0'; - printf("%d localtime = [%s]\n", len, buf); + printf("%d localtime = [%s]\n", len, buf); - //find the position of the 2nd to last "/" - int num = 0; - int pos = len; - while(num < 2) - { - if(pos == 0) - break; + //find the position of the 2nd to last "/" + int num = 0; + int pos = len; + while(num < 2) + { + if(pos == 0) + break; - pos -= 1; + pos -= 1; - if(buf[pos] == '/') - num++; - } + if(buf[pos] == '/') + num++; + } - printf("looks like we want to cut at position %d\n", pos); + printf("looks like we want to cut at position %d\n", pos); - strncpy(tz, buf+pos+1, len - pos); + tzid = (char*) xmalloc(len - pos + 1); + strncpy(tzid, buf+pos+1, len - pos); - printf("timezone: [%s]\n", tz); + printf("timezone: [%s]\n", tzid); + return tzid; + } printf("Unable to detect time zone\n"); return tzid; From a5c96251a11a95e4814478233e6c2a49bfda4e67 Mon Sep 17 00:00:00 2001 From: C-o-r-E Date: Sat, 28 Jul 2012 00:07:37 -0400 Subject: [PATCH 6/9] fixed warning and added some more debug output --- libfreerdp-locale/timezone.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/libfreerdp-locale/timezone.c b/libfreerdp-locale/timezone.c index 59d437e40..52d063a4d 100644 --- a/libfreerdp-locale/timezone.c +++ b/libfreerdp-locale/timezone.c @@ -1489,6 +1489,7 @@ char* freerdp_get_unix_timezone_identifier() tz_env = getenv("TZ"); + printf("Trying to get timezone from the env variables..."); if (tz_env != NULL) { tzid = xstrdup(tz_env); @@ -1496,6 +1497,7 @@ char* freerdp_get_unix_timezone_identifier() return tzid; } + printf("failed\nTrying to get timezone from /etc/timezone..."); fp = fopen("TZ -> /etc/timezone", "r"); if (fp != NULL) @@ -1528,6 +1530,8 @@ char* freerdp_get_unix_timezone_identifier() * America/Montreal for example. */ + printf("failed\nTrying to get timezone from /etc/localtime...\n"); + char buf[1024]; ssize_t len; @@ -1535,7 +1539,7 @@ char* freerdp_get_unix_timezone_identifier() { buf[len] = '\0'; - printf("%d localtime = [%s]\n", len, buf); + printf("localtime = [%s]\n", buf); //find the position of the 2nd to last "/" int num = 0; @@ -1551,8 +1555,6 @@ char* freerdp_get_unix_timezone_identifier() num++; } - printf("looks like we want to cut at position %d\n", pos); - tzid = (char*) xmalloc(len - pos + 1); strncpy(tzid, buf+pos+1, len - pos); From 1fe8a1d161150e049dc74ffedff94e9b5a18fa80 Mon Sep 17 00:00:00 2001 From: C-o-r-E Date: Sat, 28 Jul 2012 00:11:09 -0400 Subject: [PATCH 7/9] fixed erroneous string modification --- libfreerdp-locale/timezone.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libfreerdp-locale/timezone.c b/libfreerdp-locale/timezone.c index 52d063a4d..36dcd8534 100644 --- a/libfreerdp-locale/timezone.c +++ b/libfreerdp-locale/timezone.c @@ -1498,7 +1498,7 @@ char* freerdp_get_unix_timezone_identifier() } printf("failed\nTrying to get timezone from /etc/timezone..."); - fp = fopen("TZ -> /etc/timezone", "r"); + fp = fopen("/etc/timezone", "r"); if (fp != NULL) { From e9d7c05bf594639ab1f823a8be282132bdabb205 Mon Sep 17 00:00:00 2001 From: C-o-r-E Date: Sat, 28 Jul 2012 00:43:54 -0400 Subject: [PATCH 8/9] client now successfuly sets the server's timezone --- libfreerdp-locale/timezone.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/libfreerdp-locale/timezone.c b/libfreerdp-locale/timezone.c index 36dcd8534..6965cffdc 100644 --- a/libfreerdp-locale/timezone.c +++ b/libfreerdp-locale/timezone.c @@ -1602,15 +1602,25 @@ TIME_ZONE_ENTRY* freerdp_detect_windows_time_zone(uint32 bias) if (tzid == NULL) return NULL; + /*printf("TimeZoneTable has %lu elements\n", ARRAY_SIZE(TimeZoneTable)); for (i = 0; i < ARRAY_SIZE(TimeZoneTable); i++) { - if (bias == TimeZoneTable[i].Bias) + printf("[%s]\n", TimeZoneTable[i].Id); + }*/ + + for (i = 0; i < ARRAY_SIZE(TimeZoneTable); i++) + { + if (1)//(bias == TimeZoneTable[i].Bias) { + printf("i = %d\n", i); for (j = 0; j < ARRAY_SIZE(WindowsTimeZoneIdTable); j++) { + if(i == 14) + printf("[%s] == [%s]\n", TimeZoneTable[i].Id, WindowsTimeZoneIdTable[j].windows); if (strcmp(TimeZoneTable[i].Id, WindowsTimeZoneIdTable[j].windows) != 0) continue; + printf("[%s] == [%s]\n", tzid, WindowsTimeZoneIdTable[j].tzid); if (freerdp_match_unix_timezone_identifier_with_list(tzid, WindowsTimeZoneIdTable[j].tzid)) { printf("we have a match: %s\n", tzid); From 1e48dc38ecb5406babe498c63402dfe5e30228ba Mon Sep 17 00:00:00 2001 From: C-o-r-E Date: Sat, 28 Jul 2012 15:04:07 -0400 Subject: [PATCH 9/9] Removed debug output --- libfreerdp-locale/timezone.c | 45 ++++++++---------------------------- 1 file changed, 10 insertions(+), 35 deletions(-) diff --git a/libfreerdp-locale/timezone.c b/libfreerdp-locale/timezone.c index 6965cffdc..3127eede4 100644 --- a/libfreerdp-locale/timezone.c +++ b/libfreerdp-locale/timezone.c @@ -1481,7 +1481,6 @@ const WINDOWS_TZID_ENTRY WindowsTimeZoneIdTable[] = char* freerdp_get_unix_timezone_identifier() { - printf("Called freerdp_get_unix_timezone_identifier\n"); FILE* fp; char* tz_env; size_t length; @@ -1489,15 +1488,12 @@ char* freerdp_get_unix_timezone_identifier() tz_env = getenv("TZ"); - printf("Trying to get timezone from the env variables..."); if (tz_env != NULL) { tzid = xstrdup(tz_env); - printf("tzid = [%s]\n", tzid); return tzid; } - printf("failed\nTrying to get timezone from /etc/timezone..."); fp = fopen("/etc/timezone", "r"); if (fp != NULL) @@ -1521,7 +1517,6 @@ char* freerdp_get_unix_timezone_identifier() fclose(fp) ; - printf("/etc/timezone -> tzid = [%s]\n", tzid); return tzid; } @@ -1530,8 +1525,6 @@ char* freerdp_get_unix_timezone_identifier() * America/Montreal for example. */ - printf("failed\nTrying to get timezone from /etc/localtime...\n"); - char buf[1024]; ssize_t len; @@ -1539,8 +1532,6 @@ char* freerdp_get_unix_timezone_identifier() { buf[len] = '\0'; - printf("localtime = [%s]\n", buf); - //find the position of the 2nd to last "/" int num = 0; int pos = len; @@ -1558,7 +1549,6 @@ char* freerdp_get_unix_timezone_identifier() tzid = (char*) xmalloc(len - pos + 1); strncpy(tzid, buf+pos+1, len - pos); - printf("timezone: [%s]\n", tzid); return tzid; } @@ -1602,33 +1592,19 @@ TIME_ZONE_ENTRY* freerdp_detect_windows_time_zone(uint32 bias) if (tzid == NULL) return NULL; - /*printf("TimeZoneTable has %lu elements\n", ARRAY_SIZE(TimeZoneTable)); for (i = 0; i < ARRAY_SIZE(TimeZoneTable); i++) - { - printf("[%s]\n", TimeZoneTable[i].Id); - }*/ - - for (i = 0; i < ARRAY_SIZE(TimeZoneTable); i++) - { - if (1)//(bias == TimeZoneTable[i].Bias) + { + for (j = 0; j < ARRAY_SIZE(WindowsTimeZoneIdTable); j++) { - printf("i = %d\n", i); - for (j = 0; j < ARRAY_SIZE(WindowsTimeZoneIdTable); j++) - { - if(i == 14) - printf("[%s] == [%s]\n", TimeZoneTable[i].Id, WindowsTimeZoneIdTable[j].windows); - if (strcmp(TimeZoneTable[i].Id, WindowsTimeZoneIdTable[j].windows) != 0) - continue; + if (strcmp(TimeZoneTable[i].Id, WindowsTimeZoneIdTable[j].windows) != 0) + continue; - printf("[%s] == [%s]\n", tzid, WindowsTimeZoneIdTable[j].tzid); - if (freerdp_match_unix_timezone_identifier_with_list(tzid, WindowsTimeZoneIdTable[j].tzid)) - { - printf("we have a match: %s\n", tzid); - timezone = (TIME_ZONE_ENTRY*) xmalloc(sizeof(TIME_ZONE_ENTRY)); - memcpy((void*) timezone, (void*) &TimeZoneTable[i], sizeof(TIME_ZONE_ENTRY)); - xfree(tzid); - return timezone; - } + if (freerdp_match_unix_timezone_identifier_with_list(tzid, WindowsTimeZoneIdTable[j].tzid)) + { + timezone = (TIME_ZONE_ENTRY*) xmalloc(sizeof(TIME_ZONE_ENTRY)); + memcpy((void*) timezone, (void*) &TimeZoneTable[i], sizeof(TIME_ZONE_ENTRY)); + xfree(tzid); + return timezone; } } } @@ -1657,7 +1633,6 @@ TIME_ZONE_RULE_ENTRY* freerdp_get_current_time_zone_rule(TIME_ZONE_RULE_ENTRY* r void freerdp_time_zone_detect(TIME_ZONE_INFO* clientTimeZone) { - printf("Called time_zone_detect\n"); time_t t; struct tm* local_time; TIME_ZONE_ENTRY* tz;