gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r559 - in GNUnet/src: applications/fs/fsui applications/fs/


From: grothoff
Subject: [GNUnet-SVN] r559 - in GNUnet/src: applications/fs/fsui applications/fs/tools include
Date: Fri, 1 Apr 2005 20:19:58 -0800 (PST)

Author: grothoff
Date: 2005-04-01 20:19:54 -0800 (Fri, 01 Apr 2005)
New Revision: 559

Modified:
   GNUnet/src/applications/fs/fsui/helper.c
   GNUnet/src/applications/fs/fsui/upload.c
   GNUnet/src/applications/fs/tools/gnunet-insert.c
   GNUnet/src/include/gnunet_fsui_lib.h
Log:
bugfix for multiple keywords with gnunet-insert and minor API change

Modified: GNUnet/src/applications/fs/fsui/helper.c
===================================================================
--- GNUnet/src/applications/fs/fsui/helper.c    2005-04-02 00:52:48 UTC (rev 
558)
+++ GNUnet/src/applications/fs/fsui/helper.c    2005-04-02 04:19:54 UTC (rev 
559)
@@ -140,5 +140,50 @@
   return uri;
 }
 
+/**
+ * Create an ECRS URI from a user-supplied list of keywords.
+ * The keywords are NOT separated by AND but already
+ * given individually.
+ *
+ * @return an ECRS URI for the given keywords, NULL
+ *  if keywords is not legal (i.e. empty).
+ */
+struct ECRS_URI * FSUI_parseListKeywordURI(unsigned int num_keywords,
+                                          const char ** keywords) {
+  unsigned int i;
+  unsigned int uriLen;
+  char * uriString;
+  unsigned int uriSize;
+  struct ECRS_URI * uri;
 
+  uriString = NULL;
+  uriSize = 0;
+  GROW(uriString,
+       uriSize,
+       4096);
+  strcpy(uriString, ECRS_URI_PREFIX);
+  strcat(uriString, ECRS_SEARCH_INFIX);
+  uriLen = 1 + strlen(ECRS_URI_PREFIX) + strlen(ECRS_SEARCH_INFIX);
+
+
+  for (i=0;i<num_keywords;i++) {
+    if (uriSize < uriLen + 1 + strlen(keywords[i]))
+      GROW(uriString,
+          uriSize,
+          uriSize + 4096 + strlen(keywords[i]));
+    if (i > 0) {
+      strcat(uriString, "+");
+      uriLen++;
+    }
+    strcat(uriString, keywords[i]);
+    uriLen += strlen(keywords[i]);    
+  }
+  uri = ECRS_stringToUri(uriString);
+  GROW(uriString,
+       uriSize,
+       0);
+  return uri;
+}
+
+
 /* end of helper.c */

Modified: GNUnet/src/applications/fs/fsui/upload.c
===================================================================
--- GNUnet/src/applications/fs/fsui/upload.c    2005-04-02 00:52:48 UTC (rev 
558)
+++ GNUnet/src/applications/fs/fsui/upload.c    2005-04-02 04:19:54 UTC (rev 
559)
@@ -446,8 +446,7 @@
                unsigned int anonymityLevel,
                int doIndex,
                const struct ECRS_MetaData * md,
-               unsigned int keywordCount,
-               const char ** keywords) {
+               const struct ECRS_URI * keyUri) {
   FSUI_ThreadList * tl;
   UploadThreadClosure * utc;
 
@@ -462,8 +461,7 @@
   utc->globalUri = NULL;
   utc->filename = NULL;
   utc->main_filename = STRDUP(filename);
-  utc->uri = FSUI_parseArgvKeywordURI(keywordCount,
-                                     keywords);
+  utc->uri = ECRS_dupUri(keyUri);
   utc->meta = ECRS_dupMetaData(md);
   utc->doIndex = doIndex;
   tl = MALLOC(sizeof(FSUI_ThreadList));
@@ -499,8 +497,6 @@
  * and the specified directoryMetaData.
  *
  * @param extractorPluginNames list of LE plugins to use
- * @param keywordCount number of keywords
- * @param keywords keywords to use ONLY for the top-level directory
  * @return OK on success (at least we started with it),
  *  SYSERR if the file does not exist
 */
@@ -510,10 +506,8 @@
                   int doIndex,
                   const struct ECRS_MetaData * directoryMetaData,
                   const char * extractorPluginNames,
-                  unsigned int globalKeywordCount,
-                  const char ** globalKeywords,
-                  unsigned int keywordCount,
-                  const char ** keywords) {
+                  const struct ECRS_URI * globalURI,
+                  const struct ECRS_URI * topURI) {
   FSUI_ThreadList * tl;
   UploadThreadClosure * utc;
 
@@ -525,12 +519,10 @@
                                      "INSERT-PRIORITY");
   utc->expiration = cronTime(NULL) + 120 * cronYEARS;
   utc->extractors = EXTRACTOR_loadConfigLibraries(NULL, extractorPluginNames);
-  utc->globalUri = FSUI_parseArgvKeywordURI(globalKeywordCount,
-                                           globalKeywords);
+  utc->globalUri = ECRS_dupUri(globalURI);
   utc->filename = NULL;
   utc->main_filename = STRDUP(dirname);
-  utc->uri = FSUI_parseArgvKeywordURI(keywordCount,
-                                     keywords);
+  utc->uri = ECRS_dupUri(topURI);
   utc->meta = ECRS_dupMetaData(directoryMetaData);
   utc->doIndex = doIndex;
   tl = MALLOC(sizeof(FSUI_ThreadList));
@@ -544,6 +536,7 @@
     FREE(tl);
     FREE(utc->main_filename);
     ECRS_freeMetaData(utc->meta);
+    ECRS_freeUri(utc->globalUri);
     ECRS_freeUri(utc->uri);
     FREE(utc);
     return SYSERR;

Modified: GNUnet/src/applications/fs/tools/gnunet-insert.c
===================================================================
--- GNUnet/src/applications/fs/tools/gnunet-insert.c    2005-04-02 00:52:48 UTC 
(rev 558)
+++ GNUnet/src/applications/fs/tools/gnunet-insert.c    2005-04-02 04:19:54 UTC 
(rev 559)
@@ -620,6 +620,13 @@
   if (testConfigurationString("GNUNET-INSERT",
                              "RECURSIVE",
                              "YES")) {
+    struct ECRS_URI * topURI;
+    struct ECRS_URI * gloURI;
+
+    gloURI = FSUI_parseListKeywordURI(gloKeywordCnt,
+                                     (const char**) gloKeywords);
+    topURI = FSUI_parseListKeywordURI(topKeywordCnt,
+                                     (const char**) topKeywords);    
     ret = FSUI_uploadAll(ctx,
                         filename,
                         getConfigurationInt("FS",
@@ -627,19 +634,23 @@
                         doIndex,
                         meta,
                         extractors,
-                        gloKeywordCnt,
-                        (const char**) gloKeywords,
-                        topKeywordCnt,
-                        (const char**) topKeywords);
+                        gloURI,
+                        topURI);
+    ECRS_freeUri(gloURI);
+    ECRS_freeUri(topURI);
   } else {
+    struct ECRS_URI * topURI;
+
+    topURI = FSUI_parseListKeywordURI(topKeywordCnt,
+                                     (const char**) topKeywords);    
     ret = FSUI_upload(ctx,
                      filename,
                      getConfigurationInt("FS",
                                          "ANONYMITY-SEND"),
                      doIndex,
                      meta,
-                     topKeywordCnt,
-                     (const char**) topKeywords);
+                     topURI);
+    ECRS_freeUri(topURI);
   }
   FREE(extractors);
   /* wait for completion */

Modified: GNUnet/src/include/gnunet_fsui_lib.h
===================================================================
--- GNUnet/src/include/gnunet_fsui_lib.h        2005-04-02 00:52:48 UTC (rev 
558)
+++ GNUnet/src/include/gnunet_fsui_lib.h        2005-04-02 04:19:54 UTC (rev 
559)
@@ -401,6 +401,17 @@
                                           const char ** argv); /* helper.c */
 
 /**
+ * Create an ECRS URI from a user-supplied list of keywords.
+ * The keywords are NOT separated by AND but already
+ * given individually.
+ *
+ * @return an ECRS URI for the given keywords, NULL
+ *  if keywords is not legal (i.e. empty).
+ */
+struct ECRS_URI * FSUI_parseListKeywordURI(unsigned int num_keywords,
+                                          const char ** keywords);
+
+/**
  * Start a search.
  * @return SYSERR if such a search is already pending, OK on
  *  success
@@ -470,8 +481,7 @@
                unsigned int anonymityLevel,
                int doIndex,
                const struct ECRS_MetaData * md,
-               unsigned int keywordCount,
-               const char ** keywords);
+               const struct ECRS_URI * keyUri);
 
 /**
  * "delete" operation for uploaded files.  May fail
@@ -506,10 +516,8 @@
                   int doIndex,
                   const struct ECRS_MetaData * directoryMetaData,
                   const char * extractorPluginNames,
-                  unsigned int globalKeywordCount,
-                  const char ** globalKeywords,
-                  unsigned int keywordCount,
-                  const char ** keywords); /* upload.c */
+                  const struct ECRS_URI * globalURI,
+                  const struct ECRS_URI * topURI); /* upload.c */
 
 /**
  * Start to download a file or directory recursively.





reply via email to

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