[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r6324 - in GNUnet: contrib src/applications/fs/tools
From: |
gnunet |
Subject: |
[GNUnet-SVN] r6324 - in GNUnet: contrib src/applications/fs/tools |
Date: |
Sat, 16 Feb 2008 13:21:13 -0700 (MST) |
Author: grothoff
Date: 2008-02-16 13:21:12 -0700 (Sat, 16 Feb 2008)
New Revision: 6324
Modified:
GNUnet/contrib/config-client.scm
GNUnet/src/applications/fs/tools/gnunet-auto-share.c
Log:
adding support for user-specified metadata to gnunet-auto-share
Modified: GNUnet/contrib/config-client.scm
===================================================================
--- GNUnet/contrib/config-client.scm 2008-02-16 20:02:36 UTC (rev 6323)
+++ GNUnet/contrib/config-client.scm 2008-02-16 20:21:12 UTC (rev 6324)
@@ -27,10 +27,6 @@
;; Second, a function "gnunet-config-change" which is notified whenever
;; configuration options are changed; the script can then
;; change the visibility of other options.
-;;
-;;
-;; TODO:
-;; - complete conversion of *.in to *.scm
@@ -262,6 +258,18 @@
(cons 1 1073741824)
'rare) )
+(define (gnunet-fs-metadata builder)
+ (builder
+ "FS"
+ "METADATA"
+ (_ "Location of the file specifying metadata for the auto-share directory")
+ (nohelp)
+ '()
+ #t
+ "$GNUNET_HOME/metadata.conf"
+ '()
+ 'fs-loaded) )
+
(define (fs builder)
(builder
"File-Sharing"
@@ -272,6 +280,7 @@
(fs-extractors builder)
(fs-disable-creation-time builder)
(fs-uri-db-size builder)
+ (gnunet-fs-metadata builder)
)
#t
#f
Modified: GNUnet/src/applications/fs/tools/gnunet-auto-share.c
===================================================================
--- GNUnet/src/applications/fs/tools/gnunet-auto-share.c 2008-02-16
20:02:36 UTC (rev 6323)
+++ GNUnet/src/applications/fs/tools/gnunet-auto-share.c 2008-02-16
20:21:12 UTC (rev 6324)
@@ -28,11 +28,14 @@
#include "gnunet_directories.h"
#include "gnunet_fsui_lib.h"
#include "gnunet_util.h"
+#include <extractor.h>
static int upload_done;
static struct GNUNET_GC_Configuration *cfg;
+static struct GNUNET_GC_Configuration *meta_cfg;
+
static struct GNUNET_GE_Context *ectx;
static struct GNUNET_FSUI_Context *ctx;
@@ -150,12 +153,66 @@
return GNUNET_OK;
}
+struct AddMetadataClosure {
+ const char * filename;
+ struct GNUNET_ECRS_MetaData * meta;
+};
+
+
static int
+add_meta_data(void * cls,
+ struct GNUNET_GC_Configuration * cfg,
+ struct GNUNET_GE_Context * ectx,
+ const char * section,
+ const char * option)
+{
+ struct AddMetadataClosure * amc = cls;
+ EXTRACTOR_KeywordType type;
+ EXTRACTOR_KeywordType max;
+ char * value;
+
+ if (0 != strcmp(amc->filename,
+ section) )
+ return GNUNET_OK;
+ max = EXTRACTOR_getHighestKeywordTypeNumber();
+ for (type=0;type<max;type++)
+ {
+ if (0 == strcasecmp(option,
+ EXTRACTOR_getKeywordTypeAsString(type)))
+ break;
+ }
+ if (type == max)
+ {
+ GNUNET_GE_LOG(ectx,
+ GNUNET_GE_USER | GNUNET_GE_WARNING | GNUNET_GE_BULK,
+ _("Unknown keyword type `%s' in metadata configuration\n"),
+ option);
+ return GNUNET_OK;
+ }
+ value = NULL;
+ GNUNET_GC_get_configuration_value_string(cfg,
+ section,
+ option,
+ NULL,
+ &value);
+ if (value != NULL)
+ {
+ GNUNET_ECRS_meta_data_insert(amc->meta,
+ type,
+ value);
+ GNUNET_free(value);
+ }
+ return GNUNET_OK;
+}
+
+
+static int
probe_directory (const char *filename, const char *dirName, void *cls)
{
time_t *last = cls;
time_t latest;
struct stat buf;
+ struct AddMetadataClosure amc;
char *fn;
if (filename[0] == '.')
@@ -184,6 +241,16 @@
GNUNET_free (fn);
return GNUNET_OK;
}
+ amc.meta = GNUNET_ECRS_meta_data_create();
+ amc.filename = filename;
+ /* attaching a listener will prompt iteration
+ over all config values! */
+ GNUNET_GC_attach_change_listener(meta_cfg,
+ &add_meta_data,
+ &amc);
+ GNUNET_GC_detach_change_listener(meta_cfg,
+ &add_meta_data,
+ &amc);
ul = GNUNET_FSUI_upload_start (ctx,
fn,
(GNUNET_FSUI_DirectoryScanCallback) &
@@ -191,7 +258,8 @@
priority, GNUNET_YES, GNUNET_YES,
!do_no_direct_references,
GNUNET_get_time () + 2 * GNUNET_CRON_YEARS,
- NULL, gloKeywords, NULL);
+ amc.meta, gloKeywords, NULL);
+ GNUNET_ECRS_meta_data_destroy(amc.meta);
GNUNET_free (fn);
return GNUNET_SYSERR;
}
@@ -213,6 +281,7 @@
time_t last;
time_t start;
GNUNET_CronTime delay;
+ char * metafn;
errorCode = 0;
i = GNUNET_init (argc,
@@ -235,6 +304,17 @@
GNUNET_GC_get_configuration_value_number (cfg,
"GNUNET",
"VERBOSE", 0, 9999, 0, &verbose);
+ metafn = NULL;
+ GNUNET_GC_get_configuration_value_filename(cfg,
+ "FS",
+ "METADATA",
+ GNUNET_DEFAULT_HOME_DIRECTORY
"/metadata.conf",
+ &metafn);
+ meta_cfg = GNUNET_GC_create();
+ if (GNUNET_YES ==
+ GNUNET_disk_file_test(NULL, metafn))
+ GNUNET_GC_parse_configuration(meta_cfg,
+ metafn);
/* fundamental init */
ctx = GNUNET_FSUI_start (ectx, cfg, "gnunet-auto-share", GNUNET_NO, 32,
&printstatus, &verbose);
@@ -269,6 +349,8 @@
GNUNET_ECRS_uri_destroy (gloKeywords);
GNUNET_free (dirname);
quit:
+ if (meta_cfg != NULL)
+ GNUNET_GC_free(meta_cfg);
GNUNET_fini (ectx, cfg);
return errorCode;
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r6324 - in GNUnet: contrib src/applications/fs/tools,
gnunet <=