diff lib/protocols.c @ 186:13ca1defdc75

2003-6-16 Brian Masney <masneyb@gftp.org> * lib/gftp.h src/text/gftp-text.c src/gtk/misc-gtk.c - changed 2nd parameter of logging function to be a request structure, instead of request->user_data. In the logging functions, if the string isn't in UTF-8, convert it with gftp_string_to_utf8() * lib/bookmark.c lib/cache.c lib/gftp.h lib/https.c lib/local.c lib/protocols.c lib/rfc2068.c lib/rfc959.c lib/sshv2.c lib/sslcommon.c src/gtk/chmod_dialog.c src/gtk/delete_dialog.c src/gtk/gftp-gtk.h src/gtk/menu-items.c src/gtk/misc-gtk.c src/gtk/mkdir_dialog.c src/gtk/rename_dialog.c src/gtk/transfer.c src/text/gftp-text.c src/gtk/gftp-gtk.h src/text/gftp-text.h - pass request structure to logging function instead of request->user_data
author masneyb
date Tue, 17 Jun 2003 10:49:16 +0000
parents cc94bd62d290
children a8ec69e39112
line wrap: on
line diff
--- a/lib/protocols.c	Tue Jun 17 10:13:26 2003 +0000
+++ b/lib/protocols.c	Tue Jun 17 10:49:16 2003 +0000
@@ -155,7 +155,7 @@
   gftp_lookup_request_option (request, "maxkbs", &maxkbs);
   if (maxkbs > 0)
     {
-      request->logging_function (gftp_logging_misc, request->user_data,
+      request->logging_function (gftp_logging_misc, request,
                     _("File transfer will be throttled to %.2f KB/s\n"),
                     maxkbs);
     }
@@ -179,7 +179,7 @@
 
   if (maxkbs > 0)
     {
-      request->logging_function (gftp_logging_misc, request->user_data,
+      request->logging_function (gftp_logging_misc, request,
                     _("File transfer will be throttled to %.2f KB/s\n"), 
                     maxkbs);
     }
@@ -314,7 +314,7 @@
   request->cached = 0;
   if (request->use_cache && (fd = gftp_find_cache_entry (request)) > 0)
     {
-      request->logging_function (gftp_logging_misc, request->user_data,
+      request->logging_function (gftp_logging_misc, request,
                                  _("Loading directory listing %s from cache\n"),
                                  request->directory);
 
@@ -359,7 +359,7 @@
 }
 
 
-static char *
+char *
 gftp_string_to_utf8 (gftp_request * request, char *str)
 {
   char *ret, *remote_charsets, *stpos, *cur_charset;
@@ -442,7 +442,7 @@
           if (gftp_fd_write (request, request->last_dir_entry,
                           request->last_dir_entry_len, request->cachefd) < 0)
             {
-              request->logging_function (gftp_logging_error, request->user_data,
+              request->logging_function (gftp_logging_error, request,
                                         _("Error: Cannot write to cache: %s\n"),
                                         g_strerror (errno));
               close (request->cachefd);
@@ -473,14 +473,14 @@
   if ((tempentry = g_hash_table_lookup (gftp_bookmarks_htable, 
                                         bookmark)) == NULL)
     {
-      request->logging_function (gftp_logging_error, request->user_data,
+      request->logging_function (gftp_logging_error, request,
                                  _("Error: Could not find bookmark %s\n"), 
                                  bookmark);
       return (GFTP_EFATAL);
     }
   else if (tempentry->hostname == NULL || *tempentry->hostname == '\0')
     {
-      request->logging_function (gftp_logging_error, request->user_data,
+      request->logging_function (gftp_logging_error, request,
                                  _("Bookmarks Error: The bookmark entry %s does not have a hostname\n"), bookmark);
       return (GFTP_EFATAL);
     }
@@ -890,13 +890,13 @@
   else
     snprintf (serv, sizeof (serv), "%d", port);
 
-  request->logging_function (gftp_logging_misc, request->user_data,
+  request->logging_function (gftp_logging_misc, request,
                              _("Looking up %s\n"), request->hostname);
 
   if ((errnum = getaddrinfo (request->hostname, serv, &hints, 
                              &request->hostp)) != 0)
     {
-      request->logging_function (gftp_logging_error, request->user_data,
+      request->logging_function (gftp_logging_error, request,
                                  _("Cannot look up hostname %s: %s\n"),
                                  request->hostname, gai_strerror (errnum));
       return (GFTP_ERETRYABLE);
@@ -905,13 +905,13 @@
   addr = request->hostp->ai_addr;
 
 #else /* !HAVE_GETADDRINFO */
-  request->logging_function (gftp_logging_misc, request->user_data,
+  request->logging_function (gftp_logging_misc, request,
                              _("Looking up %s\n"), request->hostname);
 
   if (!(request->hostp = r_gethostbyname (request->hostname, &request->host,
                                           NULL)))
     {
-      request->logging_function (gftp_logging_error, request->user_data,
+      request->logging_function (gftp_logging_error, request,
                                  _("Cannot look up hostname %s: %s\n"),
                                  request->hostname, g_strerror (errno));
       return (GFTP_ERETRYABLE);
@@ -1705,12 +1705,12 @@
       else
         snprintf (serv, sizeof (serv), "%d", port);
 
-      request->logging_function (gftp_logging_misc, request->user_data,
+      request->logging_function (gftp_logging_misc, request,
                                  _("Looking up %s\n"), connect_host);
       if ((errnum = getaddrinfo (connect_host, serv, &hints, 
                                  &request->hostp)) != 0)
         {
-          request->logging_function (gftp_logging_error, request->user_data,
+          request->logging_function (gftp_logging_error, request,
                                      _("Cannot look up hostname %s: %s\n"),
                                      connect_host, gai_strerror (errnum));
           return (GFTP_ERETRYABLE);
@@ -1728,18 +1728,18 @@
       if ((sock = socket (res->ai_family, res->ai_socktype, 
                           res->ai_protocol)) < 0)
         {
-          request->logging_function (gftp_logging_error, request->user_data,
+          request->logging_function (gftp_logging_error, request,
                                      _("Failed to create a socket: %s\n"),
                                      g_strerror (errno));
           continue; 
         } 
 
-      request->logging_function (gftp_logging_misc, request->user_data,
+      request->logging_function (gftp_logging_misc, request,
                                  _("Trying %s:%d\n"), disphost, port);
 
       if (connect (sock, res->ai_addr, res->ai_addrlen) == -1)
         {
-          request->logging_function (gftp_logging_error, request->user_data,
+          request->logging_function (gftp_logging_error, request,
                                      _("Cannot connect to %s: %s\n"),
                                      disphost, g_strerror (errno));
           close (sock);
@@ -1771,7 +1771,7 @@
 
   if ((sock = socket (AF_INET, SOCK_STREAM, IPPROTO_TCP)) < 0)
     {
-      request->logging_function (gftp_logging_error, request->user_data,
+      request->logging_function (gftp_logging_error, request,
                                  _("Failed to create a socket: %s\n"),
                                  g_strerror (errno));
       return (GFTP_ERETRYABLE);
@@ -1795,7 +1795,7 @@
     {
       if (!r_getservbyname (service, "tcp", &serv_struct, NULL))
         {
-          request->logging_function (gftp_logging_error, request->user_data,
+          request->logging_function (gftp_logging_error, request,
                                      _("Cannot look up service name %s/tcp. Please check your services file\n"),
                                      service);
           close (sock);
@@ -1814,12 +1814,12 @@
 
   if (request->hostp == NULL)
     {
-      request->logging_function (gftp_logging_misc, request->user_data,
+      request->logging_function (gftp_logging_misc, request,
                                  _("Looking up %s\n"), connect_host);
       if (!(request->hostp = r_gethostbyname (connect_host, &request->host,
                                               NULL)))
         {
-          request->logging_function (gftp_logging_error, request->user_data,
+          request->logging_function (gftp_logging_error, request,
                                      _("Cannot look up hostname %s: %s\n"),
                                      connect_host, g_strerror (errno));
           close (sock);
@@ -1833,14 +1833,14 @@
       disphost = request->host.h_name;
       memcpy (&remote_address.sin_addr, request->host.h_addr_list[curhost],
               request->host.h_length);
-      request->logging_function (gftp_logging_misc, request->user_data,
+      request->logging_function (gftp_logging_misc, request,
                                  _("Trying %s:%d\n"),
                                  request->host.h_name, ntohs (port));
 
       if (connect (sock, (struct sockaddr *) &remote_address,
                    sizeof (remote_address)) == -1)
         {
-          request->logging_function (gftp_logging_error, request->user_data,
+          request->logging_function (gftp_logging_error, request,
                                      _("Cannot connect to %s: %s\n"),
                                      connect_host, g_strerror (errno));
         }
@@ -1857,14 +1857,14 @@
 
   if (fcntl (sock, F_SETFD, 1) == -1)
     {
-      request->logging_function (gftp_logging_error, request->user_data,
+      request->logging_function (gftp_logging_error, request,
                                  _("Error: Cannot set close on exec flag: %s\n"),
                                  g_strerror (errno));
 
       return (GFTP_ERETRYABLE);
     }
 
-  request->logging_function (gftp_logging_misc, request->user_data,
+  request->logging_function (gftp_logging_misc, request,
                              _("Connected to %s:%d\n"), connect_host, port);
 
   if (gftp_fd_set_sockblocking (request, sock, 1) < 0)
@@ -2079,7 +2079,7 @@
         {
           if (request != NULL)
             {
-              request->logging_function (gftp_logging_error, request->user_data,
+              request->logging_function (gftp_logging_error, request,
                                          _("Connection to %s timed out\n"),
                                          request->hostname);
               gftp_disconnect (request);
@@ -2099,7 +2099,7 @@
  
           if (request != NULL)
             {
-              request->logging_function (gftp_logging_error, request->user_data,
+              request->logging_function (gftp_logging_error, request,
                                    _("Error: Could not read from socket: %s\n"),
                                     g_strerror (errno));
               gftp_disconnect (request);
@@ -2149,7 +2149,7 @@
         {
           if (request != NULL)
             {
-              request->logging_function (gftp_logging_error, request->user_data,
+              request->logging_function (gftp_logging_error, request,
                                          _("Connection to %s timed out\n"),
                                          request->hostname);
               gftp_disconnect (request);
@@ -2169,7 +2169,7 @@
  
           if (request != NULL)
             {
-              request->logging_function (gftp_logging_error, request->user_data,
+              request->logging_function (gftp_logging_error, request,
                                     _("Error: Could not write to socket: %s\n"),
                                     g_strerror (errno));
               gftp_disconnect (request);
@@ -2217,7 +2217,7 @@
 
   if ((flags = fcntl (fd, F_GETFL, 0)) < 0)
     {
-      request->logging_function (gftp_logging_error, request->user_data,
+      request->logging_function (gftp_logging_error, request,
                                  _("Cannot get socket flags: %s\n"),
                                  g_strerror (errno));
       gftp_disconnect (request);
@@ -2231,7 +2231,7 @@
 
   if (fcntl (fd, F_SETFL, flags) < 0)
     {
-      request->logging_function (gftp_logging_error, request->user_data,
+      request->logging_function (gftp_logging_error, request,
                                  _("Cannot set socket to non-blocking: %s\n"),
                                  g_strerror (errno));
       gftp_disconnect (request);
@@ -2462,7 +2462,7 @@
   if ((fd = open (pathname, flags, mode)) < 0)
     {
       if (request != NULL)
-        request->logging_function (gftp_logging_error, request->user_data,
+        request->logging_function (gftp_logging_error, request,
                                    _("Error: Cannot open local file %s: %s\n"),
                                    pathname, g_strerror (errno));
       return (GFTP_ERETRYABLE);
@@ -2471,7 +2471,7 @@
   if (fcntl (fd, F_SETFD, 1) == -1)
     {
       if (request != NULL)
-        request->logging_function (gftp_logging_error, request->user_data,
+        request->logging_function (gftp_logging_error, request,
                                    _("Error: Cannot set close on exec flag: %s\n"),
                                    g_strerror (errno));