gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r3226 - in GNUnet/src: applications/fs/namespace include ut


From: grothoff
Subject: [GNUnet-SVN] r3226 - in GNUnet/src: applications/fs/namespace include util/config util/config_impl
Date: Sun, 13 Aug 2006 13:08:35 -0700 (PDT)

Author: grothoff
Date: 2006-08-13 13:08:30 -0700 (Sun, 13 Aug 2006)
New Revision: 3226

Modified:
   GNUnet/src/applications/fs/namespace/namespace_info.c
   GNUnet/src/include/gnunet_util_config.h
   GNUnet/src/include/gnunet_util_config_impl.h
   GNUnet/src/util/config/config.c
   GNUnet/src/util/config_impl/impl.c
Log:
add get filename to cfg

Modified: GNUnet/src/applications/fs/namespace/namespace_info.c
===================================================================
--- GNUnet/src/applications/fs/namespace/namespace_info.c       2006-08-13 
19:32:25 UTC (rev 3225)
+++ GNUnet/src/applications/fs/namespace/namespace_info.c       2006-08-13 
20:08:30 UTC (rev 3226)
@@ -35,7 +35,9 @@
 #define NS_UPDATE_DIR "data" DIR_SEPARATOR_STR "namespace-updates" 
DIR_SEPARATOR_STR
 #define NS_ROOTS "data" DIR_SEPARATOR_STR "namespace-root" DIR_SEPARATOR_STR
 
-static void writeNamespaceInfo(const char * namespaceName,
+static void writeNamespaceInfo(struct GE_Context * ectx,
+                              struct GC_Configuration * cfg,
+                              const char * namespaceName,
                               const struct ECRS_MetaData * meta,
                               int ranking) {
   unsigned int size;
@@ -44,9 +46,12 @@
   char * fn;
   char * fnBase;
 
-  fn = getConfigurationString("GNUNET", "GNUNET_HOME");
-  fnBase = expandFileName(fn);
-  FREE(fn);
+
+  GC_get_configuration_value_string(cfg,
+                                   "GNUNET",
+                                   "GNUNET_HOME",
+                                   GNUNET_HOME_DIRECTORY,
+                                   &fnBase);
   fn = MALLOC(strlen(fnBase) +
              strlen(NS_DIR) +
              strlen(namespaceName) +
@@ -64,10 +69,11 @@
   tag = size + sizeof(int);
   buf = MALLOC(tag);
   ((int *) buf)[0] = htonl(ranking); /* ranking */
-  GE_ASSERT(ectx, size == ECRS_serializeMetaData(meta,
-                                              &buf[sizeof(int)],
-                                              size,
-                                              ECRS_SERIALIZE_FULL));
+  GE_ASSERT(ectx, size == ECRS_serializeMetaData(ectx,
+                                                meta,
+                                                &buf[sizeof(int)],
+                                                size,
+                                                ECRS_SERIALIZE_FULL));
   writeFile(fn,
            buf,
            tag,

Modified: GNUnet/src/include/gnunet_util_config.h
===================================================================
--- GNUnet/src/include/gnunet_util_config.h     2006-08-13 19:32:25 UTC (rev 
3225)
+++ GNUnet/src/include/gnunet_util_config.h     2006-08-13 20:08:30 UTC (rev 
3226)
@@ -111,6 +111,22 @@
                                      char ** value);
 
 /**
+ * Get a configuration value that should be the name of a file
+ * or directory.
+ *
+ * @param default default value (use indicated by return value;
+ *        will NOT be aliased, may NOT be NULL)
+ * @param value will be set to a freshly allocated configuration
+ *        value, or NULL if option is not specified and no default given
+ * @return 0 on success, -1 on error, 1 for default
+ */
+int GC_get_configuration_value_filename(struct GC_Configuration * cfg,
+                                       const char * section,
+                                       const char * option,
+                                       const char * def,
+                                       char ** value);
+
+/**
  * Get a configuration value that should be in a set of
  * predefined strings
  * @param choices NULL-terminated list of legal values

Modified: GNUnet/src/include/gnunet_util_config_impl.h
===================================================================
--- GNUnet/src/include/gnunet_util_config_impl.h        2006-08-13 19:32:25 UTC 
(rev 3225)
+++ GNUnet/src/include/gnunet_util_config_impl.h        2006-08-13 20:08:30 UTC 
(rev 3226)
@@ -115,6 +115,20 @@
                                        const char * option,
                                        const char * def,
                                        char ** value);
+
+  /**
+   * Get a configuration value that should be a file name.
+   * @param default default value (use indicated by return value;
+   *        will NOT be aliased, maybe NOT be NULL)
+   * @param value will be set to a freshly allocated configuration
+   *        value, or NULL if option is not specified and no default given
+   * @return 0 on success, -1 on error, 1 for default
+   */
+  int (*get_configuration_value_filename)(struct GC_Configuration * cfg,
+                                         const char * section,
+                                         const char * option,
+                                         const char * def,
+                                         char ** value);
   
   /**
    * Get a configuration value that should be in a set of

Modified: GNUnet/src/util/config/config.c
===================================================================
--- GNUnet/src/util/config/config.c     2006-08-13 19:32:25 UTC (rev 3225)
+++ GNUnet/src/util/config/config.c     2006-08-13 20:08:30 UTC (rev 3226)
@@ -142,6 +142,14 @@
   return cfg->get_configuration_value_string(cfg, section, option, def, value);
 }
 
+int GC_get_configuration_value_filename(struct GC_Configuration * cfg,
+                                       const char * section,
+                                       const char * option,
+                                       const char * def,
+                                       char ** value) {
+  return cfg->get_configuration_value_string(cfg, section, option, def, value);
+}
+
 /**
  * Get a configuration value that should be in a set of
  * predefined strings

Modified: GNUnet/src/util/config_impl/impl.c
===================================================================
--- GNUnet/src/util/config_impl/impl.c  2006-08-13 19:32:25 UTC (rev 3225)
+++ GNUnet/src/util/config_impl/impl.c  2006-08-13 20:08:30 UTC (rev 3226)
@@ -592,6 +592,31 @@
   return ret;
 }
 
+/**
+ * Get a configuration value that should be a string.
+ * @param def default value (use indicated by return value;
+ *        will NOT be aliased, maybe NULL)
+ * @param value will be set to a freshly allocated configuration
+ *        value, or NULL if option is not specified and no default given
+ * @return 0 on success, -1 on error, 1 for default
+ */
+int _get_configuration_value_filename(struct GC_Configuration * cfg,
+                                     const char * section,
+                                     const char * option,
+                                     const char * def,
+                                     char ** value) {
+  GC_ConfigurationData * data;
+  int ret;
+  char * tmp;
+  
+  data = cfg->data;
+  GE_ASSERT(data->ectx, def != NULL);
+  ret = _get_configuration_value_string(cfg, section, option, def, &tmp);
+  *value = string_expandFileName(data->ectx, tmp);
+  FREE(tmp);
+  return ret;
+}
+
 static int 
 _set_configuration_value_number(struct GC_Configuration * cfg,
                                struct GE_Context * ectx,
@@ -671,6 +696,7 @@
   ret->write_configuration = &_write_configuration;
   ret->get_configuration_value_number = &_get_configuration_value_number;
   ret->get_configuration_value_string = &_get_configuration_value_string;
+  ret->get_configuration_value_filename = &_get_configuration_value_filename;
   ret->get_configuration_value_choice = &_get_configuration_value_choice;
   ret->set_configuration_value_number = &_set_configuration_value_number;
   ret->set_configuration_value_string = &_set_configuration_value_string;





reply via email to

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