gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r1771 - in GNUnet/src: conf include util


From: grothoff
Subject: [GNUnet-SVN] r1771 - in GNUnet/src: conf include util
Date: Fri, 19 Aug 2005 22:57:12 -0700 (PDT)

Author: grothoff
Date: 2005-08-19 22:57:10 -0700 (Fri, 19 Aug 2005)
New Revision: 1771

Modified:
   GNUnet/src/conf/gconf.c
   GNUnet/src/conf/recreate.c
   GNUnet/src/conf/wizard.c
   GNUnet/src/conf/wizard_curs.c
   GNUnet/src/include/gnunet_util.h
   GNUnet/src/include/winproc.h
   GNUnet/src/util/osconfig.c
Log:
fixing Mantis 869

Modified: GNUnet/src/conf/gconf.c
===================================================================
--- GNUnet/src/conf/gconf.c     2005-08-20 05:38:27 UTC (rev 1770)
+++ GNUnet/src/conf/gconf.c     2005-08-20 05:57:10 UTC (rev 1771)
@@ -63,7 +63,7 @@
 static gboolean config_changed = FALSE;
 
 static char nohelp_text[] =
-    "Sorry, no help available for this option yet.\n";
+  gettext_noop("Sorry, no help is available for this option.\n");
 
 GtkWidget *main_wnd = NULL;
 GtkWidget *tree1_w = NULL;  /* left  frame */

Modified: GNUnet/src/conf/recreate.c
===================================================================
--- GNUnet/src/conf/recreate.c  2005-08-20 05:38:27 UTC (rev 1770)
+++ GNUnet/src/conf/recreate.c  2005-08-20 05:57:10 UTC (rev 1771)
@@ -69,7 +69,40 @@
     }
 }
 
+static void insert_nic(const char * name,
+                      int defaultNIC,
+                      void * cls) {
+  struct symbol * sym = cls;
+  if ( (NULL == sym_get_string_value(sym)) ||
+       (defaultNIC) )
+    sym_set_string_value(sym, name);
+}
 
+/**
+ * @brief Set reasonable default for GNUNETD_HOME if needed
+ */
+static void checkDefaultIFC(struct symbol *sym)
+{
+ 
+  if (strncmp(sym->name, 
+             "INTERFACE",
+             strlen("INTERFACE")) == 0) /* match also for INTERFACES ! */
+    {
+      const char *val;
+      
+      sym_calc_value_ext(sym, 1);
+      val = sym_get_string_value(sym);
+      
+      /* only empty if gnunet-setup is run for the first time */
+      if (!val || !strlen(val))
+       {
+         /* INTERFACE isn't set yet. Let's choose a sane default */
+         enumNetworkIfs(insert_nic, sym);
+       }
+    }
+}
+
+
 int recreate_main() {
   struct symbol *sym;
   int i = 0;
@@ -92,8 +125,10 @@
   if (testConfigurationString("GNUNETD",
                              "_MAGIC_",
                              "YES")) {
-    for_all_symbols(i, sym) 
+    for_all_symbols(i, sym) {
       checkGNUNETDHome(sym);
+      checkDefaultIFC(sym);
+    }
   }
   /* Write defaults */
   if (conf_write(filename)) {

Modified: GNUnet/src/conf/wizard.c
===================================================================
--- GNUnet/src/conf/wizard.c    2005-08-20 05:38:27 UTC (rev 1770)
+++ GNUnet/src/conf/wizard.c    2005-08-20 05:57:10 UTC (rev 1771)
@@ -55,7 +55,9 @@
 char * group_name = NULL;
 static int nic_item_count = 0;
 
-void insert_nic(char *name, int defaultNIC)
+void insert_nic(const char *name, 
+                int defaultNIC, 
+                void * cls)
 {
  gtk_combo_box_append_text(GTK_COMBO_BOX(cmbNIC), name);
   
@@ -103,7 +105,7 @@
        if (sym)
        {
                nic_item_count = 0;
-               enumNetworkIfs(insert_nic);
+               enumNetworkIfs(insert_nic, NULL);
 
                if (!nic_item_count)
                {

Modified: GNUnet/src/conf/wizard_curs.c
===================================================================
--- GNUnet/src/conf/wizard_curs.c       2005-08-20 05:38:27 UTC (rev 1770)
+++ GNUnet/src/conf/wizard_curs.c       2005-08-20 05:57:10 UTC (rev 1771)
@@ -63,7 +63,9 @@
   free(err);   
 }
 
-void insert_nic_curs(char *name, int defaultNIC)
+void insert_nic_curs(const char *name, 
+                    int defaultNIC,
+                    void * cls)
 {
        struct dialog_list_item *item;
 
@@ -121,7 +123,7 @@
   
   dialog_clear();
        
-  enumNetworkIfs(insert_nic_curs);
+  enumNetworkIfs(insert_nic_curs, NULL);
 
   /* Network interface */
   if (nic_item_count) {
@@ -610,7 +612,7 @@
   /* Save config */
   if ( (user_name != NULL) && 
        (strlen(user_name) > 0) )
-    if (!isOSUserAddCapable(group_name, user_name))
+    if (!isOSUserAddCapable())
       showCursErr(_("Unable to create user account:"), STRERROR(errno));
   
   if (!isOSAutostartCapable())

Modified: GNUnet/src/include/gnunet_util.h
===================================================================
--- GNUnet/src/include/gnunet_util.h    2005-08-20 05:38:27 UTC (rev 1770)
+++ GNUnet/src/include/gnunet_util.h    2005-08-20 05:57:10 UTC (rev 1771)
@@ -2334,7 +2334,7 @@
  * @brief Enumerate all network interfaces
  * @param callback the callback function
  */
-void enumNetworkIfs(void (*callback) (char *, int));
+void enumNetworkIfs(void (*callback) (const char *, int, void *), void * cls);
 
 /**
  * @brief Checks if we can start GNUnet automatically
@@ -2356,7 +2356,7 @@
  * @return 1 if yes, 0 otherwise
  * @todo support for useradd(8)
  */
-int isOSUserAddCapable();
+int isOSUserAddCapable(void);
 
 /**
  * @brief Checks if we can add a group for the GNUnet service

Modified: GNUnet/src/include/winproc.h
===================================================================
--- GNUnet/src/include/winproc.h        2005-08-20 05:38:27 UTC (rev 1770)
+++ GNUnet/src/include/winproc.h        2005-08-20 05:57:10 UTC (rev 1771)
@@ -160,7 +160,7 @@
 BOOL DereferenceShortcut(char *pszShortcut);
 long QueryRegistry(HKEY hMainKey, char *pszKey, char *pszSubKey,
               char *pszBuffer, long *pdLength);
-int ListNICs(void (*callback) (char *, int));
+int ListNICs(void (*callback) (const char *, int, void *), void * cls);
 BOOL AddPathAccessRights(char *lpszFileName, char *lpszAccountName,
       DWORD dwAccessMask);
 

Modified: GNUnet/src/util/osconfig.c
===================================================================
--- GNUnet/src/util/osconfig.c  2005-08-20 05:38:27 UTC (rev 1770)
+++ GNUnet/src/util/osconfig.c  2005-08-20 05:57:10 UTC (rev 1771)
@@ -31,57 +31,58 @@
  * @brief Enumerate all network interfaces
  * @param callback the callback function
  */
-void enumNetworkIfs(void (*callback) (char *, int)) {
+void enumNetworkIfs(void (*callback) (const char *, int, void *),
+                   void * cls) {
 #ifdef MINGW
-               ListNICs(callback);
+  ListNICs(callback, cls);
 #else
-               char entry[11], *dst;
-               FILE *f;
-               
-               if (system("ifconfig > /dev/null 2> /dev/null"))
-                       if (system("/sbin/ifconfig > /dev/null 2> /dev/null") 
== 0)
-                               f = popen("/sbin/ifconfig 2> /dev/null", "r");
-                       else
-                               f = NULL;
-               else
-                       f = popen("ifconfig 2> /dev/null", "r");
-               
-               if (!f)
-                       return;
-                       
-               while(1)
-               {
-                       int i = 0;
-                       int c = fgetc(f);
-                       
-                       if (c == EOF)
-                               break;
-
-                       dst = entry;
-                       
-                       /* Read interface name until the first space (or colon 
under OS X) */
-                       while (c != EOF && c != '\n' &&
+  char entry[11], *dst;
+  FILE *f;
+  
+  if (system("ifconfig > /dev/null 2> /dev/null"))
+    if (system("/sbin/ifconfig > /dev/null 2> /dev/null") == 0)
+      f = popen("/sbin/ifconfig 2> /dev/null", "r");
+    else
+      f = NULL;
+  else
+    f = popen("ifconfig 2> /dev/null", "r");
+  
+  if (!f)
+    return;
+  
+  while(1)
+    {
+      int i = 0;
+      int c = fgetc(f);
+      
+      if (c == EOF)
+       break;
+      
+      dst = entry;
+      
+      /* Read interface name until the first space (or colon under OS X) */
+      while (c != EOF && c != '\n' &&
 #ifdef OSX
-                               c != ':'
+            c != ':'
 #else
-                               c != ' '
+            c != ' '
 #endif
-                               && i < 10)
-                       {
-                               *dst++ = c;
-                               i++;
-                               c = fgetc(f);
-                       }
-                       *dst = 0;
-
-                       if (entry[0])
-                               callback(entry, strcmp(entry, "eth0") == 0);
-
-                       while(c != '\n' && c != EOF)
-                               c = fgetc(f);
-               }
-
-               pclose(f);
+            && i < 10)
+       {
+         *dst++ = c;
+         i++;
+         c = fgetc(f);
+       }
+      *dst = 0;
+      
+      if (entry[0])
+       callback(entry, strcmp(entry, "eth0") == 0, cls);
+      
+      while(c != '\n' && c != EOF)
+       c = fgetc(f);
+    }
+  
+  pclose(f);
 #endif
 }
 





reply via email to

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