changeset 555:7f54d0c0edbc

2004-9-17 Brian Masney <masneyb@gftp.org> * lib/misc.c lib/cache.c lib/config_file.c lib/gftp.h lib/protocols.c lib/rfc2068.c lib/sshv2.c src/gtk/bookmarks.c src/gtk/dnd.c src/gtk/gftp-gtk.c src/gtk/gtkui.c src/gtk/menu-items.c src/gtk/misc-gtk.c src/gtk/transfer.c src/uicommon/gftpui.c - added gftp_request argument to gftp_build_path() and expand_path(). Renamed expand_path() to gftp_expand_path() * lib/gftp.h - fixed compile error in gftp_need_username macro
author masneyb
date Fri, 17 Sep 2004 23:37:47 +0000
parents a8ca3e349d4a
children 017b1108305b
files ChangeLog lib/cache.c lib/config_file.c lib/gftp.h lib/misc.c lib/protocols.c lib/rfc2068.c lib/sshv2.c src/gtk/bookmarks.c src/gtk/dnd.c src/gtk/gftp-gtk.c src/gtk/gtkui.c src/gtk/menu-items.c src/gtk/misc-gtk.c src/gtk/transfer.c src/uicommon/gftpui.c
diffstat 16 files changed, 73 insertions(+), 48 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Tue Sep 14 10:24:01 2004 +0000
+++ b/ChangeLog	Fri Sep 17 23:37:47 2004 +0000
@@ -1,3 +1,13 @@
+2004-9-17 Brian Masney <masneyb@gftp.org>
+	* lib/misc.c lib/cache.c lib/config_file.c lib/gftp.h lib/protocols.c
+	lib/rfc2068.c lib/sshv2.c src/gtk/bookmarks.c src/gtk/dnd.c
+	src/gtk/gftp-gtk.c src/gtk/gtkui.c src/gtk/menu-items.c
+	src/gtk/misc-gtk.c src/gtk/transfer.c src/uicommon/gftpui.c - added
+	gftp_request argument to gftp_build_path() and expand_path(). Renamed
+	expand_path() to gftp_expand_path()
+
+	* lib/gftp.h - fixed compile error in gftp_need_username macro
+
 2004-9-14 Brian Masney <masneyb@gftp.org>
 	* docs/gftp-faq.sgml - updated SSH section
 
@@ -2819,7 +2829,7 @@
 
 	* cvsclean - added this script
 
-	* *.[ch] - added $Id: ChangeLog,v 1.321 2004/09/14 10:24:01 masneyb Exp $ tags
+	* *.[ch] - added $Id: ChangeLog,v 1.322 2004/09/17 23:37:46 masneyb Exp $ tags
 
 	* debian/* - updated files from Debian maintainer
 
--- a/lib/cache.c	Tue Sep 14 10:24:01 2004 +0000
+++ b/lib/cache.c	Fri Sep 17 23:37:47 2004 +0000
@@ -127,7 +127,7 @@
   time (&t);
   t += cache_ttl;
 
-  cachedir = expand_path (BASE_CONF_DIR "/cache");
+  cachedir = gftp_expand_path (NULL, BASE_CONF_DIR "/cache");
   if (access (cachedir, F_OK) == -1)
     {
       if (mkdir (cachedir, S_IRUSR | S_IWUSR | S_IXUSR) < 0)
@@ -205,7 +205,7 @@
   gftp_generate_cache_description (request, description, sizeof (description),
                                    0);
 
-  indexfile = expand_path (BASE_CONF_DIR "/cache/index.db");
+  indexfile = gftp_expand_path (NULL, BASE_CONF_DIR "/cache/index.db");
   if ((indexfd = gftp_fd_open (NULL, indexfile, O_RDONLY, 0)) == -1)
     {
       g_free (indexfile);
@@ -269,7 +269,7 @@
   gftp_cache_entry centry;
   int indexfd;
 
-  indexfile = expand_path (BASE_CONF_DIR "/cache/index.db");
+  indexfile = gftp_expand_path (NULL, BASE_CONF_DIR "/cache/index.db");
   if ((indexfd = gftp_fd_open (NULL, indexfile, O_RDONLY, 0)) == -1)
     {
       g_free (indexfile);
@@ -318,14 +318,14 @@
   else
     return;
 
-  oldindexfile = expand_path (BASE_CONF_DIR "/cache/index.db");
+  oldindexfile = gftp_expand_path (NULL, BASE_CONF_DIR "/cache/index.db");
   if ((indexfd = gftp_fd_open (NULL, oldindexfile, O_RDONLY, 0)) == -1)
     {
       g_free (oldindexfile);
       return;
     }
 
-  newindexfile = expand_path (BASE_CONF_DIR "/cache/index.db.new");
+  newindexfile = gftp_expand_path (NULL, BASE_CONF_DIR "/cache/index.db.new");
   if ((newfd = gftp_fd_open (request, newindexfile, O_WRONLY | O_CREAT, 
                              S_IRUSR | S_IWUSR)) == -1)
     {
--- a/lib/config_file.c	Tue Sep 14 10:24:01 2004 +0000
+++ b/lib/config_file.c	Fri Sep 17 23:37:47 2004 +0000
@@ -169,7 +169,7 @@
   size_t len;
   int line;
 
-  if ((tempstr = expand_path (BOOKMARKS_FILE)) == NULL)
+  if ((tempstr = gftp_expand_path (NULL, BOOKMARKS_FILE)) == NULL)
     {
       printf (_("gFTP Error: Bad bookmarks file name %s\n"), BOOKMARKS_FILE);
       exit (1);
@@ -572,7 +572,7 @@
                            &gftp_config_list[i]);
     }
 
-  if ((tempstr = expand_path (CONFIG_FILE)) == NULL)
+  if ((tempstr = gftp_expand_path (NULL, CONFIG_FILE)) == NULL)
     {
       printf (_("gFTP Error: Bad config file name %s\n"), CONFIG_FILE);
       exit (1);
@@ -580,7 +580,7 @@
 
   if (access (tempstr, F_OK) == -1)
     {
-      temp1str = expand_path (BASE_CONF_DIR);
+      temp1str = gftp_expand_path (NULL, BASE_CONF_DIR);
       if (access (temp1str, F_OK) == -1)
 	{
 	  if (mkdir (temp1str, S_IRUSR | S_IWUSR | S_IXUSR) != 0)
@@ -656,7 +656,7 @@
 	}
     }
 
-  if ((tempstr = expand_path (LOG_FILE)) == NULL)
+  if ((tempstr = gftp_expand_path (NULL, LOG_FILE)) == NULL)
     {
       printf (_("gFTP Error: Bad log file name %s\n"), LOG_FILE);
       exit (1);
@@ -722,7 +722,7 @@
   bmhdr = N_("Bookmarks file for gFTP. Copyright (C) 1998-2003 Brian Masney <masneyb@gftp.org>. Warning: Any comments that you add to this file WILL be overwritten");
   pwhdr = N_("Note: The passwords contained inside this file are scrambled. This algorithm is not secure. This is to avoid your password being easily remembered by someone standing over your shoulder while you're editing this file. Prior to this, all passwords were stored in plaintext.");
 
-  if ((tempstr = expand_path (BOOKMARKS_FILE)) == NULL)
+  if ((tempstr = gftp_expand_path (NULL, BOOKMARKS_FILE)) == NULL)
     {
       printf (_("gFTP Error: Bad bookmarks file name %s\n"), CONFIG_FILE);
       exit (1);
@@ -811,7 +811,7 @@
   FILE *conffile;
   int i;
 
-  if ((tempstr = expand_path (CONFIG_FILE)) == NULL)
+  if ((tempstr = gftp_expand_path (NULL, CONFIG_FILE)) == NULL)
     {
       printf (_("gFTP Error: Bad config file name %s\n"), CONFIG_FILE);
       exit (1);
--- a/lib/gftp.h	Tue Sep 14 10:24:01 2004 +0000
+++ b/lib/gftp.h	Fri Sep 17 23:37:47 2004 +0000
@@ -354,7 +354,7 @@
 						  gftp_request * request, 
 						  const char *string, ... );
 
-#define gftp_need_username(request)		((request)->need_username && ((request)->username == NULL || *(request)->username == '\0')
+#define gftp_need_username(request)		((request)->need_username && ((request)->username == NULL || *(request)->username == '\0'))
 #define gftp_need_password(request)		((request)->need_password && (request)->username != NULL && *(request)->username != '\0' && strcmp ((request)->username, "anonymous") != 0 && ((request)->password == NULL || *(request)->password == '\0'))
 
 struct gftp_request_tag 
@@ -727,7 +727,8 @@
 
 char *alltrim 				( char *str );
 
-char *expand_path 			( const char *src );
+char *gftp_expand_path 			( gftp_request * request,
+					  const char *src );
 
 void make_nonnull 			( char **str );
 
@@ -778,7 +779,8 @@
 					  GList ** list, 
 					  int *curnum );
 
-char * gftp_build_path 			( const char *first_element,
+char * gftp_build_path 			( gftp_request * request,
+					  const char *first_element,
 					  ... );
 
 void gftp_locale_init 			( void );
--- a/lib/misc.c	Tue Sep 14 10:24:01 2004 +0000
+++ b/lib/misc.c	Fri Sep 17 23:37:47 2004 +0000
@@ -135,7 +135,7 @@
 
 
 char *
-expand_path (const char *src)
+gftp_expand_path (gftp_request * request, const char *src)
 {
   char *str, *pos, *endpos, *prevpos, *newstr, *tempstr, *ntoken,
        tempchar;
@@ -228,7 +228,7 @@
       if ((pos = strchr (newstr, '/')) == NULL)
 	str = g_strdup (pw->pw_dir);
       else
-	str = gftp_build_path (pw->pw_dir, pos, NULL);
+	str = gftp_build_path (request, pw->pw_dir, pos, NULL);
 
       g_free (newstr);
       newstr = str;
@@ -1127,7 +1127,7 @@
 
 
 char *
-gftp_build_path (const char *first_element, ...) 
+gftp_build_path (gftp_request * request, const char *first_element, ...) 
 {
   const char *element;
   size_t len, retlen;
@@ -1161,7 +1161,9 @@
       retlen += len;
       ret = g_realloc (ret, retlen + 1);
 
-      if (add_separator)
+      /* Don't append a / for VMS servers... */
+      if (add_separator &&
+          (request == NULL || request->server_type != GFTP_DIRTYPE_VMS))
         strncat (ret, "/", retlen);
 
       strncat (ret, element, retlen);
--- a/lib/protocols.c	Tue Sep 14 10:24:01 2004 +0000
+++ b/lib/protocols.c	Fri Sep 17 23:37:47 2004 +0000
@@ -1856,14 +1856,16 @@
         fle->startsize = *newsize;
 
       if (transfer->toreq && fle->destfile == NULL)
-        fle->destfile = gftp_build_path (transfer->toreq->directory, 
+        fle->destfile = gftp_build_path (transfer->toreq,
+                                         transfer->toreq->directory, 
                                          fle->file, NULL);
 
       if (transfer->fromreq->directory != NULL &&
           *transfer->fromreq->directory != '\0' &&
           *fle->file != '/')
         {
-          newname = gftp_build_path (transfer->fromreq->directory,
+          newname = gftp_build_path (transfer->fromreq,
+                                     transfer->fromreq->directory,
                                      fle->file, NULL);
 
           g_free (fle->file);
@@ -1933,13 +1935,15 @@
         }
 
       if (transfer->toreq && curfle->destfile == NULL)
-        curfle->destfile = gftp_build_path (transfer->toreq->directory, 
+        curfle->destfile = gftp_build_path (transfer->toreq,
+                                            transfer->toreq->directory, 
                                             curfle->file, NULL);
 
       if (transfer->fromreq->directory != NULL &&
           *transfer->fromreq->directory != '\0' && *curfle->file != '/')
         {
-          newname = gftp_build_path (transfer->fromreq->directory,
+          newname = gftp_build_path (transfer->fromreq,
+                                     transfer->fromreq->directory,
                                      curfle->file, NULL);
           g_free (curfle->file);
           curfle->file = newname;
@@ -2932,7 +2936,7 @@
   gftp_lookup_request_option (request, "startup_directory", &startup_directory);
 
   if (*startup_directory != '\0' &&
-      (tempstr = expand_path (startup_directory)) != NULL)
+      (tempstr = gftp_expand_path (request, startup_directory)) != NULL)
     {
       gftp_set_directory (request, tempstr);
       g_free (tempstr);
--- a/lib/rfc2068.c	Tue Sep 14 10:24:01 2004 +0000
+++ b/lib/rfc2068.c	Fri Sep 17 23:37:47 2004 +0000
@@ -285,7 +285,7 @@
   if (fd > 0)
     request->datafd = fd;
 
-  hf = gftp_build_path (request->hostname, filename, NULL);
+  hf = gftp_build_path (request, request->hostname, filename, NULL);
 
   if (request->username == NULL || *request->username == '\0')
     tempstr = g_strconcat ("GET ", request->url_prefix, "://", hf,
@@ -398,7 +398,7 @@
   if (strncmp (request->directory, "/", strlen (request->directory)) == 0)
     hd = g_strdup (request->hostname);
   else
-    hd = gftp_build_path (request->hostname, request->directory, NULL);
+    hd = gftp_build_path (request, request->hostname, request->directory, NULL);
 
   if (request->username == NULL || *request->username == '\0')
     tempstr = g_strconcat ("GET ", request->url_prefix, "://", hd,
@@ -442,7 +442,7 @@
 
   gftp_lookup_request_option (request, "use_http11", &use_http11);
 
-  hf = gftp_build_path (request->hostname, filename, NULL);
+  hf = gftp_build_path (request, request->hostname, filename, NULL);
 
   if (request->username == NULL || *request->username == '\0')
     tempstr = g_strconcat ("HEAD ", request->url_prefix, "://", hf,
@@ -651,11 +651,11 @@
       if (*directory != '/' && request->directory != NULL)
         {
           tempstr = g_strconcat (request->directory, "/", directory, NULL);
-          request->directory = expand_path (tempstr);
+          request->directory = gftp_expand_path (request, tempstr);
           g_free (tempstr);
         }
       else
-        request->directory = expand_path (directory);
+        request->directory = gftp_expand_path (request, directory);
 
       if (olddir != NULL)
         g_free (olddir);
--- a/lib/sshv2.c	Tue Sep 14 10:24:01 2004 +0000
+++ b/lib/sshv2.c	Fri Sep 17 23:37:47 2004 +0000
@@ -183,7 +183,7 @@
     }
   else
     {
-      tempstr = gftp_build_path (request->directory, path, NULL);
+      tempstr = gftp_build_path (request, request->directory, path, NULL);
       pathlen = strlen (tempstr);
       *len += pathlen + 8;
       ret = sshv2_initialize_string (request, *len);
@@ -1586,12 +1586,12 @@
   if (*oldname == '/')
     oldstr = g_strdup (oldname);
   else
-    oldstr = gftp_build_path (request->directory, oldname, NULL);
+    oldstr = gftp_build_path (request, request->directory, oldname, NULL);
 
   if (*newname == '/')
     newstr = g_strdup (newname);
   else
-    newstr = gftp_build_path (request->directory, newname, NULL);
+    newstr = gftp_build_path (request, request->directory, newname, NULL);
 
   oldlen = strlen (oldstr); 
   newlen = strlen (newname); 
--- a/src/gtk/bookmarks.c	Tue Sep 14 10:24:01 2004 +0000
+++ b/src/gtk/bookmarks.c	Fri Sep 17 23:37:47 2004 +0000
@@ -691,7 +691,7 @@
       *pos = '\0';
     }
 
-  origpath = newpath = gftp_build_path (entry->path, gtk_entry_get_text (GTK_ENTRY (bm_pathedit)), NULL);
+  origpath = newpath = gftp_build_path (NULL, entry->path,gtk_entry_get_text (GTK_ENTRY (bm_pathedit)), NULL);
   *pos = tempchar;
 
   str = gtk_entry_get_text (GTK_ENTRY (bm_hostedit));
@@ -757,7 +757,8 @@
           if (*(tempentry->path + oldpathlen) == '\0')
 	    tempstr = g_strdup (newpath);
           else
-	    tempstr = gftp_build_path (newpath, tempentry->path + oldpathlen, NULL);
+	    tempstr = gftp_build_path (NULL, newpath,
+                                       tempentry->path + oldpathlen, NULL);
 
 	  g_free (tempentry->path);
 	  tempentry->path = tempstr;
--- a/src/gtk/dnd.c	Tue Sep 14 10:24:01 2004 +0000
+++ b/src/gtk/dnd.c	Fri Sep 17 23:37:47 2004 +0000
@@ -79,7 +79,8 @@
   newfle->file = g_strdup (current_ftpdata->directory);
   *(pos - 1) = '\0';
   
-  newfle->destfile = gftp_build_path (wdata->request->directory, pos, NULL);
+  newfle->destfile = gftp_build_path (wdata->request,
+                                      wdata->request->directory, pos, NULL);
 
   tdata = NULL;
   for (templist = *trans_list; templist != NULL; templist = templist->next)
@@ -162,7 +163,8 @@
         continue;
 
       oldlen = totlen;
-      df = gftp_build_path (wdata->request->directory, tempfle->file, NULL);
+      df = gftp_build_path (wdata->request, wdata->request->directory,
+                            tempfle->file, NULL);
 
       if (wdata->request->hostname == NULL || 
           wdata->request->protonum == GFTP_LOCAL_NUM)
--- a/src/gtk/gftp-gtk.c	Tue Sep 14 10:24:01 2004 +0000
+++ b/src/gtk/gftp-gtk.c	Fri Sep 17 23:37:47 2004 +0000
@@ -610,7 +610,8 @@
 
   if (S_ISLNK (tempfle->st_mode) || S_ISDIR (tempfle->st_mode))
     {
-      directory = gftp_build_path (wdata->request->directory, tempfle->file, NULL);
+      directory = gftp_build_path (wdata->request, wdata->request->directory,
+                                   tempfle->file, NULL);
       success = gftpui_run_chdir (wdata, directory);
       g_free (directory);
     }
--- a/src/gtk/gtkui.c	Tue Sep 14 10:24:01 2004 +0000
+++ b/src/gtk/gtkui.c	Fri Sep 17 23:37:47 2004 +0000
@@ -385,7 +385,7 @@
   char *tempstr;
   int ret;
 
-  if ((tempstr = expand_path (directory)) == NULL)
+  if ((tempstr = gftp_expand_path (wdata->request, directory)) == NULL)
     return (FALSE);	  
   
   wdata = uidata;
@@ -424,7 +424,8 @@
   templist = get_next_selection (templist, &filelist, &num);
   curfle = filelist->data;
 
-  tempstr = gftp_build_path (wdata->request->directory, curfle->file, NULL);
+  tempstr = gftp_build_path (wdata->request, wdata->request->directory,
+                             curfle->file, NULL);
   gftpui_run_chdir (wdata, tempstr);
   g_free (tempstr);
 }
--- a/src/gtk/menu-items.c	Tue Sep 14 10:24:01 2004 +0000
+++ b/src/gtk/menu-items.c	Fri Sep 17 23:37:47 2004 +0000
@@ -262,7 +262,7 @@
       return (0);
     }
 
-  if ((tempstr = expand_path (edttxt)) == NULL)
+  if ((tempstr = gftp_expand_path (wdata->request, edttxt)) == NULL)
     return (FALSE);
 
   if (gftpui_run_chdir (wdata, tempstr))
@@ -580,12 +580,12 @@
     {
       g_free (tempstr);
       temp1str = g_strconcat (share_dir, "/COPYING", NULL);
-      tempstr = expand_path (temp1str);
+      tempstr = gftp_expand_path (NULL, temp1str);
       g_free (temp1str);
       if (access (tempstr, F_OK) != 0)
 	{
 	  g_free (tempstr);
-          tempstr = expand_path (BASE_CONF_DIR "/COPYING");
+          tempstr = gftp_expand_path (NULL, BASE_CONF_DIR "/COPYING");
 	  if (access (tempstr, F_OK) != 0)
 	    {
 #if GTK_MAJOR_VERSION == 1
--- a/src/gtk/misc-gtk.c	Tue Sep 14 10:24:01 2004 +0000
+++ b/src/gtk/misc-gtk.c	Fri Sep 17 23:37:47 2004 +0000
@@ -1234,7 +1234,7 @@
   char *tempstr, *exfile, *share_dir;
 
   tempstr = g_strconcat (BASE_CONF_DIR, "/", filename, NULL);
-  exfile = expand_path (tempstr);
+  exfile = gftp_expand_path (NULL, tempstr);
   g_free (tempstr);
   if (access (exfile, F_OK) != 0)
     {
@@ -1242,7 +1242,7 @@
       share_dir = gftp_get_share_dir ();
 
       tempstr = g_strconcat (share_dir, "/", filename, NULL);
-      exfile = expand_path (tempstr);
+      exfile = gftp_expand_path (NULL, tempstr);
       g_free (tempstr);
       if (access (exfile, F_OK) != 0)
 	{
--- a/src/gtk/transfer.c	Tue Sep 14 10:24:01 2004 +0000
+++ b/src/gtk/transfer.c	Fri Sep 17 23:37:47 2004 +0000
@@ -300,7 +300,8 @@
   GList * newfile;
 
   tempfle = g_malloc0 (sizeof (*tempfle));
-  tempfle->destfile = gftp_build_path (ve_proc->torequest->directory,
+  tempfle->destfile = gftp_build_path (ve_proc->torequest,
+                                       ve_proc->torequest->directory,
                                        ve_proc->remote_filename, NULL);
   ve_proc->remote_filename = NULL;
   tempfle->file = ve_proc->filename;
--- a/src/uicommon/gftpui.c	Tue Sep 14 10:24:01 2004 +0000
+++ b/src/uicommon/gftpui.c	Fri Sep 17 23:37:47 2004 +0000
@@ -473,12 +473,13 @@
     {
       if (*command != '/' && request->directory != NULL)
         {
-          tempstr = gftp_build_path (request->directory, command, NULL);
-          newdir = expand_path (tempstr);
+          tempstr = gftp_build_path (request, request->directory, command,
+                                     NULL);
+          newdir = gftp_expand_path (request, tempstr);
           g_free (tempstr);
         }
       else
-        newdir = expand_path (command);
+        newdir = gftp_expand_path (request, command);
 
       if (newdir == NULL)
         {