changeset 483:4376ffeab64e

2004-6-13 Brian Masney <masneyb@gftp.org> * lib/gftp.h lib/misc.c src/gtk/Makefile.am src/gtk/menu-items.c src/gtk/misc-gtk.c src/text/Makefile.am src/uicommon/Makefile.am src/uicommon/gftpui.c - added support to override the value of SHARE_DIR during runtime with the GFTP_SHARE_DIR environment variable
author masneyb
date Sun, 13 Jun 2004 14:25:18 +0000
parents 18773e9af7f0
children 632036c6e4a4
files ChangeLog lib/gftp.h lib/misc.c src/gtk/Makefile.am src/gtk/menu-items.c src/gtk/misc-gtk.c src/text/Makefile.am src/uicommon/Makefile.am src/uicommon/gftpui.c
diffstat 9 files changed, 49 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Sun Jun 13 14:13:28 2004 +0000
+++ b/ChangeLog	Sun Jun 13 14:25:18 2004 +0000
@@ -1,3 +1,10 @@
+2004-6-13 Brian Masney <masneyb@gftp.org>
+	* lib/gftp.h lib/misc.c src/gtk/Makefile.am src/gtk/menu-items.c
+	src/gtk/misc-gtk.c src/text/Makefile.am src/uicommon/Makefile.am
+	src/uicommon/gftpui.c - added support to override the value of
+	SHARE_DIR during runtime with the GFTP_SHARE_DIR environment
+	variable
+
 2004-6-6 Brian Masney <masneyb@gftp.org>
 	* lib/protocols.c (gftp_set_username) - allow a NULL username
 
@@ -2492,7 +2499,7 @@
 
 	* cvsclean - added this script
 
-	* *.[ch] - added $Id: ChangeLog,v 1.268 2004/06/07 02:02:49 masneyb Exp $ tags
+	* *.[ch] - added $Id: ChangeLog,v 1.269 2004/06/13 14:25:18 masneyb Exp $ tags
 
 	* debian/* - updated files from Debian maintainer
 
--- a/lib/gftp.h	Sun Jun 13 14:13:28 2004 +0000
+++ b/lib/gftp.h	Sun Jun 13 14:25:18 2004 +0000
@@ -764,6 +764,8 @@
 int gftp_get_transfer_action 		( gftp_request * request,
 					  gftp_file * fle );
 
+char * gftp_get_share_dir 		( void );
+
 /* mkstemps.c */
 int mkstemps 				( char *template,
 					  int suffix_len );
--- a/lib/misc.c	Sun Jun 13 14:13:28 2004 +0000
+++ b/lib/misc.c	Sun Jun 13 14:25:18 2004 +0000
@@ -1349,3 +1349,23 @@
   return (fle->transfer_action);
 }
 
+
+char *
+gftp_get_share_dir (void)
+{
+  static char *gftp_share_dir = NULL;
+  char *envval;
+
+  if (gftp_share_dir == NULL)
+    {
+      envval = getenv ("GFTP_SHARE_DIR");
+
+      if (envval != NULL && *envval != '\0')
+        gftp_share_dir = g_strdup (envval);
+      else
+        gftp_share_dir = SHARE_DIR;
+    }
+
+  return (gftp_share_dir);
+}
+
--- a/src/gtk/Makefile.am	Sun Jun 13 14:13:28 2004 +0000
+++ b/src/gtk/Makefile.am	Sun Jun 13 14:25:18 2004 +0000
@@ -5,6 +5,6 @@
 gftp_gtk_SOURCES = bookmarks.c chmod_dialog.c delete_dialog.c dnd.c \
                      gftp-gtk.c gtkui.c gtkui_transfer.c menu-items.c \
                      misc-gtk.c options_dialog.c transfer.c view_dialog.c
-INCLUDES = @GTK_CFLAGS@ @PTHREAD_CFLAGS@ -DSHARE_DIR=\"$(datadir)/gftp\" -I../../intl
+INCLUDES = @GTK_CFLAGS@ @PTHREAD_CFLAGS@ -I../../intl
 LDADD = ../../lib/libgftp.a ../uicommon/libgftpui.a @GTK_LIBS@ @PTHREAD_LIBS@ @EXTRA_LIBS@ @GTHREAD_LIBS@ @SSL_LIBS@ @LIBINTL@
 noinst_HEADERS = gftp-gtk.h
--- a/src/gtk/menu-items.c	Sun Jun 13 14:13:28 2004 +0000
+++ b/src/gtk/menu-items.c	Sun Jun 13 14:25:18 2004 +0000
@@ -442,9 +442,8 @@
 void 
 about_dialog (gpointer data)
 {
-  GtkWidget * tempwid, * notebook, * box, * label, * view, * vscroll,
-            * dialog;
-  char *tempstr, *no_license_agreement, *str, buf[255];
+  GtkWidget * tempwid, * notebook, * box, * label, * view, * vscroll, * dialog;
+  char *tempstr, *temp1str, *no_license_agreement, *str, buf[255], *share_dir;
   size_t len;
   FILE * fd;
 #if GTK_MAJOR_VERSION > 1
@@ -453,7 +452,8 @@
   guint textlen;
 #endif
 
-  no_license_agreement = g_strdup_printf (_("Cannot find the license agreement file COPYING. Please make sure it is in either %s or in %s"), BASE_CONF_DIR, SHARE_DIR);
+  share_dir = gftp_get_share_dir ();
+  no_license_agreement = g_strdup_printf (_("Cannot find the license agreement file COPYING. Please make sure it is in either %s or in %s"), BASE_CONF_DIR, share_dir);
 
 #if GTK_MAJOR_VERSION == 1
   dialog = gtk_dialog_new ();
@@ -579,7 +579,9 @@
   if (access (tempstr, F_OK) != 0)
     {
       g_free (tempstr);
-      tempstr = expand_path (SHARE_DIR "/COPYING");
+      temp1str = g_strconcat (share_dir, "/COPYING", NULL);
+      tempstr = expand_path (temp1str);
+      g_free (temp1str);
       if (access (tempstr, F_OK) != 0)
 	{
 	  g_free (tempstr);
--- a/src/gtk/misc-gtk.c	Sun Jun 13 14:13:28 2004 +0000
+++ b/src/gtk/misc-gtk.c	Sun Jun 13 14:25:18 2004 +0000
@@ -1219,7 +1219,7 @@
 char *
 get_xpm_path (char *filename, int quit_on_err)
 {
-  char *tempstr, *exfile;
+  char *tempstr, *exfile, *share_dir;
 
   tempstr = g_strconcat (BASE_CONF_DIR, "/", filename, NULL);
   exfile = expand_path (tempstr);
@@ -1227,7 +1227,9 @@
   if (access (exfile, F_OK) != 0)
     {
       g_free (exfile);
-      tempstr = g_strconcat (SHARE_DIR, "/", filename, NULL);
+      share_dir = gftp_get_share_dir ();
+
+      tempstr = g_strconcat (share_dir, "/", filename, NULL);
       exfile = expand_path (tempstr);
       g_free (tempstr);
       if (access (exfile, F_OK) != 0)
@@ -1241,7 +1243,7 @@
 		return (NULL);
 
 	      printf (_("gFTP Error: Cannot find file %s in %s or %s\n"),
-		      filename, SHARE_DIR, BASE_CONF_DIR);
+		      filename, share_dir, BASE_CONF_DIR);
 	      exit (1);
 	    }
 	}
--- a/src/text/Makefile.am	Sun Jun 13 14:13:28 2004 +0000
+++ b/src/text/Makefile.am	Sun Jun 13 14:25:18 2004 +0000
@@ -3,7 +3,7 @@
 bin_PROGRAMS = @GFTP_TEXT@
 EXTRA_PROGRAMS = gftp-text
 gftp_text_SOURCES=gftp-text.c textui.c
-INCLUDES=@GLIB_CFLAGS@ -DSHARE_DIR=\"$(datadir)/gftp\" -I../../intl
+INCLUDES=@GLIB_CFLAGS@ -I../../intl
 LDADD = ../../lib/libgftp.a ../uicommon/libgftpui.a @GLIB_LIBS@ @EXTRA_LIBS@ @READLINE_LIBS@ @SSL_LIBS@ @LIBINTL@
 noinst_HEADERS=gftp-text.h
 localedir=$(datadir)/locale
--- a/src/uicommon/Makefile.am	Sun Jun 13 14:13:28 2004 +0000
+++ b/src/uicommon/Makefile.am	Sun Jun 13 14:25:18 2004 +0000
@@ -2,6 +2,6 @@
 
 noinst_LIBRARIES = libgftpui.a
 libgftpui_a_SOURCES = gftpui.c gftpuicallbacks.c
-INCLUDES = @GLIB_CFLAGS@ @PTHREAD_CFLAGS@ -I../intl -DSHARE_DIR=\"$(datadir)/gftp\"
+INCLUDES = @GLIB_CFLAGS@ @PTHREAD_CFLAGS@ -I../intl
 noinst_HEADERS = gftpui.h
 
--- a/src/uicommon/gftpui.c	Sun Jun 13 14:13:28 2004 +0000
+++ b/src/uicommon/gftpui.c	Sun Jun 13 14:25:18 2004 +0000
@@ -129,6 +129,8 @@
 void
 gftpui_common_init (int *argc, char ***argv, gftp_logging_func logfunc)
 {
+  char *share_dir;
+
   gftp_locale_init ();
 
   signal (SIGCHLD, gftpui_common_sig_child);
@@ -136,7 +138,8 @@
   signal (SIGALRM, gftpui_common_signal_handler);
   signal (SIGINT, gftpui_common_signal_handler);
 
-  gftp_read_config_file (SHARE_DIR);
+  share_dir = gftp_get_share_dir ();
+  gftp_read_config_file (share_dir);
   if (gftp_parse_command_line (argc, argv) != 0)
     exit (0);