changeset 473:45fb9dc47a2e

2004-5-26 Brian Masney <masneyb@gftp.org> * lib/protocols.c lib/options.h - added remote_lc_time option. The value of LC_TIME can now be overridden on a per site basis. This will fix problems parsing the dates in the remote directory listings
author masneyb
date Thu, 27 May 2004 10:11:56 +0000
parents 5100b89c44e1
children 71382528fce4
files ChangeLog lib/options.h lib/protocols.c
diffstat 3 files changed, 31 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Thu May 27 09:54:57 2004 +0000
+++ b/ChangeLog	Thu May 27 10:11:56 2004 +0000
@@ -1,4 +1,8 @@
 2004-5-26 Brian Masney <masneyb@gftp.org>
+	* lib/protocols.c lib/options.h - added remote_lc_time option. The
+	value of LC_TIME can now be overridden on a per site basis. This will
+	fix problems parsing the dates in the remote directory listings
+
 	* src/gtk/dnd.c - when a URL is dropped on the connect button, log the
 	URL that is received
 
@@ -2469,7 +2473,7 @@
 
 	* cvsclean - added this script
 
-	* *.[ch] - added $Id: ChangeLog,v 1.263 2004/05/27 09:54:57 masneyb Exp $ tags
+	* *.[ch] - added $Id: ChangeLog,v 1.264 2004/05/27 10:11:56 masneyb Exp $ tags
 
 	* debian/* - updated files from Debian maintainer
 
--- a/lib/options.h	Thu May 27 09:54:57 2004 +0000
+++ b/lib/options.h	Thu May 27 10:11:56 2004 +0000
@@ -50,6 +50,10 @@
    gftp_option_type_text, "", NULL, GFTP_CVARS_FLAGS_SHOW_BOOKMARK,
    N_("This is a comma separated list of charsets to try to convert the remote messages to the current locale"), 
    GFTP_PORT_ALL, NULL},
+  {"remote_lc_time", N_("Remote LC_TIME:"), 
+   gftp_option_type_text, "", NULL, GFTP_CVARS_FLAGS_SHOW_BOOKMARK,
+   N_("This is the value of LC_TIME for the remote site. This is so that dates can be parsed properly in the directory listings."), 
+   GFTP_PORT_ALL, NULL},
   {"cache_ttl", N_("Cache TTL:"), 
    gftp_option_type_int, GINT_TO_POINTER(3600), NULL, 
    GFTP_CVARS_FLAGS_SHOW_BOOKMARK,
--- a/lib/protocols.c	Thu May 27 09:54:57 2004 +0000
+++ b/lib/protocols.c	Thu May 27 10:11:56 2004 +0000
@@ -344,16 +344,31 @@
 int
 gftp_list_files (gftp_request * request)
 {
+  char *remote_lc_time, *locret;
   int fd;
 
   g_return_val_if_fail (request != NULL, GFTP_EFATAL);
 
+  gftp_lookup_request_option (request, "remote_lc_time", &remote_lc_time);
+  if (remote_lc_time != NULL && *remote_lc_time != '\0')
+    locret = setlocale (LC_TIME, remote_lc_time);
+  else
+    locret = setlocale (LC_TIME, NULL);
+
+  if (locret == NULL)
+    {
+      locret = setlocale (LC_TIME, NULL);
+      request->logging_function (gftp_logging_misc, request,
+                                 _("Error setting LC_TIME to '%s'. Falling back to '%s'\n"),
+                                 remote_lc_time, locret);
+    }
+
   request->cached = 0;
   if (request->use_cache && (fd = gftp_find_cache_entry (request)) > 0)
     {
       request->logging_function (gftp_logging_misc, request,
-                                 _("Loading directory listing %s from cache\n"),
-                                 request->directory);
+                                 _("Loading directory listing %s from cache (LC_TIME=%s)\n"),
+                                 request->directory, locret);
 
       request->cachefd = fd;
       request->cached = 1;
@@ -361,12 +376,17 @@
     }
   else if (request->use_cache)
     {
+      request->logging_function (gftp_logging_misc, request,
+                                 _("Loading directory listing %s from server (LC_TIME=%s)\n"),
+                                 request->directory, locret);
+
       request->cachefd = gftp_new_cache_entry (request);
       request->cached = 0; 
     }
 
   if (request->list_files == NULL)
     return (GFTP_EFATAL);
+
   return (request->list_files (request));
 }