gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r2341 - GNUnet/src/conf


From: durner
Subject: [GNUnet-SVN] r2341 - GNUnet/src/conf
Date: Sun, 18 Dec 2005 09:31:03 -0800 (PST)

Author: durner
Date: 2005-12-18 09:30:12 -0800 (Sun, 18 Dec 2005)
New Revision: 2341

Modified:
   GNUnet/src/conf/Makefile.am
   GNUnet/src/conf/gconf.c
   GNUnet/src/conf/gconf.h
   GNUnet/src/conf/gnunet-setup.c
   GNUnet/src/conf/mconf.c
   GNUnet/src/conf/mconf.h
   GNUnet/src/conf/wizard.c
   GNUnet/src/conf/wizard.h
   GNUnet/src/conf/wizard_curs.c
   GNUnet/src/conf/wizard_curs.h
Log:
Make dependency on GTK and Curses optional (Mantis #995, Debian #342108)

Modified: GNUnet/src/conf/Makefile.am
===================================================================
--- GNUnet/src/conf/Makefile.am 2005-12-17 22:00:11 UTC (rev 2340)
+++ GNUnet/src/conf/Makefile.am 2005-12-18 17:30:12 UTC (rev 2341)
@@ -2,6 +2,8 @@
 
 AM_CFLAGS = $(GTK_CFLAGS)
 
+plugindir = $(libdir)/GNUnet
+
 # GNU Gettext support
 LIBS = @LIBINTL@ @LIBS@
 
@@ -13,6 +15,21 @@
  gnunet-setup \
  $(WINTOOL)
 
+if HAVE_CURSES
+ curses_libs = \
+       libgnunetsetup_curses.la
+endif
+
+if HAVE_GTK
+ gtk_libs = \
+       libgnunetsetup_gtk.la
+endif
+
+plugin_LTLIBRARIES = \
+ libgnunetsetup.la \
+ $(curses_libs) \
+ $(gtk_libs)
+
 BUILT_SOURCES = \
  lkc_defs.h
 
@@ -33,44 +50,7 @@
 lkc_defs.h: $(srcdir)/lkc_proto.h
        sed < $(srcdir)/lkc_proto.h > $@ 's/P(\([^,]*\),.*/#define \1 (\*\1_p)/'
 
-if HAVE_CURSES
-mconf_src = \
-  mconf.c mconf.h \
-  mconf_checklist.c \
-  mconf_colors.h \
-  mconf_dialog.h \
-  mconf_inputbox.c \
-  mconf_menubox.c \
-  mconf_msgbox.c \
-  mconf_textbox.c \
-  mconf_util.c \
-  mconf_yesno.c \
-  wizard_curs.c wizard_curs.h
-endif
-
-if HAVE_GTK
- gconf_libs = $(GTK_LIBS) @EXT_LIB_PATH@ $(LDADD) @EXT_LIBS@ -lgthread-2.0
-
- gconf_src = \
-   gconf_callbacks.h \
-   gconf_interface.h \
-   gconf_support.h \
-   gconf_interface.c \
-   gconf_support.c \
-   gconf.c gconf.h \
-   images.c 
-
- gbasic_src = \
-   wizard_callbacks.h \
-   wizard_interface.h \
-   wizard_support.h \
-   wizard_callbacks.c \
-   wizard_interface.c \
-   wizard.c wizard.h
-endif
-
-
-gnunet_setup_SOURCES = \
+libgnunetsetup_la_SOURCES = \
  conf.c conf.h \
  confdata.c confdata.h \
  expr.c \
@@ -81,18 +61,66 @@
  symbol.c \
  zconf.tab.h \
  zconf_tab.c zconf_tab.h \
- $(mconf_src) \
- $(gconf_src) \
- $(gbasic_src) \
- $(wizard_util_src) \
- wizard_util.c wizard_util.h \
- gnunet-setup.c
+ wizard_util.c \
+ wizard_util.h
+ 
+libgnunetsetup_la_LIBADD = \
+ $(top_builddir)/src/util/libgnunetutil.la
 
-gnunet_setup_LDFLAGS = \
- $(curses_lib) $(pdcurses_lib) $(gconf_libs)
+libgnunetsetup_la_LDFLAGS = \
+ -export-dynamic -avoid-version
 
+libgnunetsetup_curses_la_SOURCES = \
+ mconf.c mconf.h \
+ mconf_checklist.c \
+ mconf_colors.h \
+ mconf_dialog.h \
+ mconf_inputbox.c \
+ mconf_menubox.c \
+ mconf_msgbox.c \
+ mconf_textbox.c \
+ mconf_util.c \
+ mconf_yesno.c \
+ wizard_curs.c \
+ wizard_curs.h
+ 
+libgnunetsetup_curses_la_LDFLAGS = \
+ $(curses_lib) $(pdcurses_lib) \
+ -export-dynamic -avoid-version -module
+ 
+libgnunetsetup_curses_la_LIBADD = \
+ $(top_builddir)/src/util/libgnunetutil.la \
+ libgnunetsetup.la
+
+libgnunetsetup_gtk_la_SOURCES = \
+ gconf_callbacks.h \
+ gconf_interface.h \
+ gconf_support.h \
+ gconf_interface.c \
+ gconf_support.c \
+ gconf.c gconf.h \
+ images.c  \
+ wizard_callbacks.h \
+ wizard_interface.h \
+ wizard_support.h \
+ wizard_callbacks.c \
+ wizard_interface.c \
+ wizard.c wizard.h
+
+libgnunetsetup_gtk_la_LDFLAGS = \
+ $(GTK_LIBS) @EXT_LIB_PATH@ $(LDADD) @EXT_LIBS@ -lgthread-2.0 \
+ -export-dynamic -avoid-version -module
+ 
+libgnunetsetup_gtk_la_LIBADD = \
+ $(top_builddir)/src/util/libgnunetutil.la \
+ libgnunetsetup.la
+
+gnunet_setup_SOURCES = \
+ gnunet-setup.c
+ 
 gnunet_setup_LDADD = \
- $(top_builddir)/src/util/libgnunetutil.la
+ $(top_builddir)/src/util/libgnunetutil.la \
+ libgnunetsetup.la
 
 gnunet_win_tool_SOURCE = \
  gnunet-win-tool.c

Modified: GNUnet/src/conf/gconf.c
===================================================================
--- GNUnet/src/conf/gconf.c     2005-12-17 22:00:11 UTC (rev 2340)
+++ GNUnet/src/conf/gconf.c     2005-12-18 17:30:12 UTC (rev 2341)
@@ -1671,11 +1671,12 @@
 /* Main */
 
 
-int gconf_main()
+int gconf_main(int argc, char **argv)
 {
   char * filename;
 
   /* GTK stuffs */
+  gtk_init(&argc, &argv);
   bind_textdomain_codeset(PACKAGE, "UTF-8");
   gtk_set_locale();
 

Modified: GNUnet/src/conf/gconf.h
===================================================================
--- GNUnet/src/conf/gconf.h     2005-12-17 22:00:11 UTC (rev 2340)
+++ GNUnet/src/conf/gconf.h     2005-12-18 17:30:12 UTC (rev 2341)
@@ -28,6 +28,6 @@
 #ifndef GNUNET_SETUP_GCONF_H
 #define GNUNET_SETUP_GCONF_H
 
-int gconf_main(void);
+int gconf_main(int argc, char **argv);
 
 #endif

Modified: GNUnet/src/conf/gnunet-setup.c
===================================================================
--- GNUnet/src/conf/gnunet-setup.c      2005-12-17 22:00:11 UTC (rev 2340)
+++ GNUnet/src/conf/gnunet-setup.c      2005-12-18 17:30:12 UTC (rev 2341)
@@ -200,65 +200,91 @@
   return cont;
 }
 
+int dyn_config(const char *module, const char *mainfunc, int argc, char 
**argv) {
+  void (*mptr)(int, char **);
+  void *library;
 
+  library = loadDynamicLibrary("libgnunet", module);
+  if (!library)    
+    return SYSERR;
+  
+  mptr = bindDynamicMethod(library, mainfunc, "");
+  if (! mptr)
+    return SYSERR;
+  
+  mptr(argc, argv);
+  
+  unloadDynamicLibrary(library);
+  
+  return YES;
+}
+
 int main(int argc, char *argv[])
 {
   char *operation;
+  int def;
 
   if(OK != initUtil(argc, argv, &parser))
     return -1;
   operation = getConfigurationString("GNUNET-SETUP", "OPERATION");
   if (operation == NULL) {
-#if HAVE_GTK
-    operation = STRDUP("gconfig");
-#elif HAVE_CURSES
-    operation = STRDUP("menuconfig");
-#else
-    operation = STRDUP("config");
-#endif
+    operation = STRDUP("");
     LOG(LOG_WARNING,
-       "No interface specified, defaulting to `%s'\n",
-       operation);
+      _("No interface specified, using default\n"));
+    def = YES;
   }
-  if(strcmp(operation, "config") == 0)
+  else
+    def = NO;
+  
+  if(strcmp(operation, "gconfig") == 0 || def) {
+    if (dyn_config("setup_gtk", "gconf_main",
+          argc, argv) != YES) {
+      if (!def) {
+        FREE(operation);
+        errexit(_("`%s' is not available."), "gconfig");
+      }
+    }
+    else
+      def = NO;
+  }
+  
+  if(strcmp(operation, "menuconfig") == 0 || def) {
+    if (dyn_config("setup_curses", "mconf_main",
+          argc, argv) != YES) {
+      if (!def) {
+        FREE(operation);
+        errexit(_("`%s' is not available."), "menuconfig");
+      }
+    }
+    else
+      def = NO;
+  }
+  
+  if(strcmp(operation, "config") == 0 || def)
     conf_main();
-  else if(strcmp(operation, "menuconfig") == 0) {
-#if HAVE_CURSES
-    mconf_main();
-#else
-    printf(_("menuconfig is not available\n"));
-#endif
-  }
   else if(strcmp(operation, "wizard-curses") == 0) {
     if(!testConfigurationString("GNUNETD", "_MAGIC_", "YES"))
       errexit(_("Can only run wizard to configure gnunetd.\n"
                 "Did you forget the `%s' option?\n"), "-d");
-#if HAVE_CURSES
-    wizard_curs_main();
-#else
-    printf(_("wizard-curses is not available\n"));
-#endif
+                
+    if (dyn_config("setup_curses", "wizard_curs_main",
+          argc, argv) != YES) {
+      FREE(operation);
+      errexit(_("`%s' is not available."), "wizard-curses");
+    }
   }
   else if(strcmp(operation, "wizard-gtk") == 0) {
     if(!testConfigurationString("GNUNETD", "_MAGIC_", "YES"))
       errexit(_("Can only run wizard to configure gnunetd.\n"
                 "Did you forget the `%s' option?\n"), "-d");
-#if HAVE_GTK
-    gtk_init(&argc, &argv);
-    wizard_main();
-#else
-    printf(_("wizard-gtk is not available\n"));
-#endif
+
+    if (dyn_config("setup_gtk", "wizard_main",
+          argc, argv) != YES) {
+      FREE(operation);
+      errexit(_("`%s' is not available."), "wizard-gtk");
+    }
   }
-  else if(strcmp(operation, "gconfig") == 0) {
-#if HAVE_GTK
-    gtk_init(&argc, &argv);
-    gconf_main();
-#else
-    printf(_("gconfig is not available\n"));
-#endif
-  }
-  else {
+  else if (strcmp(operation, "") != 0) {
     printf(_("Unknown operation `%s'\n"), operation);
     printf(_("Use --help to get a list of options.\n"));
     FREE(operation);

Modified: GNUnet/src/conf/mconf.c
===================================================================
--- GNUnet/src/conf/mconf.c     2005-12-17 22:00:11 UTC (rev 2340)
+++ GNUnet/src/conf/mconf.c     2005-12-18 17:30:12 UTC (rev 2341)
@@ -779,7 +779,7 @@
        UNLINK("lxdialog.scrltmp");
 }
 
-int mconf_main()
+int mconf_main(int argc, char **argv)
 {
        char *mode;
        int stat;

Modified: GNUnet/src/conf/mconf.h
===================================================================
--- GNUnet/src/conf/mconf.h     2005-12-17 22:00:11 UTC (rev 2340)
+++ GNUnet/src/conf/mconf.h     2005-12-18 17:30:12 UTC (rev 2341)
@@ -28,6 +28,6 @@
 #ifndef MCONF_H
 #define MCONF_H
 
-int mconf_main(void);
+int mconf_main(int argc, char **argv);
 
 #endif

Modified: GNUnet/src/conf/wizard.c
===================================================================
--- GNUnet/src/conf/wizard.c    2005-12-17 22:00:11 UTC (rev 2340)
+++ GNUnet/src/conf/wizard.c    2005-12-18 17:30:12 UTC (rev 2341)
@@ -349,12 +349,13 @@
                gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(chkEnh), 1);     
        
 }
 
-int
-wizard_main ()
+int wizard_main (int argc, char **argv)
 {
   struct symbol *sym;
   char * filename;
        
+  gtk_init(&argc, &argv);
+  
 #ifdef ENABLE_NLS
   /* GTK uses UTF-8 encoding */
   bind_textdomain_codeset(PACKAGE, "UTF-8");
@@ -384,7 +385,7 @@
   gtk_main ();
 
   if (doOpenEnhConfigurator)
-    gconf_main();
+    gconf_main(argc, argv);
 
   return 0;
 }

Modified: GNUnet/src/conf/wizard.h
===================================================================
--- GNUnet/src/conf/wizard.h    2005-12-17 22:00:11 UTC (rev 2340)
+++ GNUnet/src/conf/wizard.h    2005-12-18 17:30:12 UTC (rev 2341)
@@ -28,6 +28,6 @@
 #ifndef WIZARD_H
 #define WIZARD_H
 
-int wizard_main(void);
+int wizard_main(int argc, char **argv);
 
 #endif

Modified: GNUnet/src/conf/wizard_curs.c
===================================================================
--- GNUnet/src/conf/wizard_curs.c       2005-12-17 22:00:11 UTC (rev 2340)
+++ GNUnet/src/conf/wizard_curs.c       2005-12-18 17:30:12 UTC (rev 2341)
@@ -82,7 +82,7 @@
   item->selected = wiz_is_nic_default(name, defaultNIC);
 }
 
-int wizard_curs_main()
+int wizard_curs_main(int argc, char **argv)
 {
   void *active_ptr = NULL;
   int idx, ret, autostart = 0, adv = 0;
@@ -656,7 +656,7 @@
   FREENONNULL(group_name);
 
   if (adv) {
-    mconf_main();
+    mconf_main(argc, argv);
   }
 
   return 0;

Modified: GNUnet/src/conf/wizard_curs.h
===================================================================
--- GNUnet/src/conf/wizard_curs.h       2005-12-17 22:00:11 UTC (rev 2340)
+++ GNUnet/src/conf/wizard_curs.h       2005-12-18 17:30:12 UTC (rev 2341)
@@ -28,6 +28,6 @@
 #ifndef GCONF_H
 #define GCONF_H
 
-int wizard_curs_main(void);
+int wizard_curs_main(int argc, char **argv);
 
 #endif





reply via email to

[Prev in Thread] Current Thread [Next in Thread]