[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r473 - in GNUnet: . src/applications/fs/ecrs src/applicatio
From: |
grothoff |
Subject: |
[GNUnet-SVN] r473 - in GNUnet: . src/applications/fs/ecrs src/applications/fs/tools src/include src/util |
Date: |
Mon, 21 Mar 2005 09:41:11 -0800 (PST) |
Author: grothoff
Date: 2005-03-21 09:41:09 -0800 (Mon, 21 Mar 2005)
New Revision: 473
Modified:
GNUnet/configure.ac
GNUnet/src/applications/fs/ecrs/keyspace.c
GNUnet/src/applications/fs/ecrs/meta.c
GNUnet/src/applications/fs/ecrs/uri.c
GNUnet/src/applications/fs/tools/gnunet-insert.c
GNUnet/src/include/gnunet_ecrs_lib.h
GNUnet/src/include/gnunet_util.h
GNUnet/src/util/timer.c
Log:
fixing mantis #789
Modified: GNUnet/configure.ac
===================================================================
--- GNUnet/configure.ac 2005-03-21 16:51:38 UTC (rev 472)
+++ GNUnet/configure.ac 2005-03-21 17:41:09 UTC (rev 473)
@@ -374,7 +374,7 @@
AC_HEADER_SYS_WAIT
AC_TYPE_OFF_T
AC_TYPE_UID_T
-AC_CHECK_FUNCS([floor gethostname memmove rmdir strncasecmp strrchr strtol
atoll dup2 fdatasync ftruncate gethostbyname gettimeofday memset mkdir mkfifo
select socket strcasecmp strchr strdup strerror strstr clock_gettime getrusage
rand uname setlocale getcwd mktime])
+AC_CHECK_FUNCS([floor gethostname memmove rmdir strncasecmp strrchr strtol
atoll dup2 fdatasync ftruncate gethostbyname gettimeofday memset mkdir mkfifo
select socket strcasecmp strchr strdup strerror strstr clock_gettime getrusage
rand uname setlocale getcwd mktime gmtime_r gmtime])
# restore LIBS
LIBS=$SAVE_LIBS
Modified: GNUnet/src/applications/fs/ecrs/keyspace.c
===================================================================
--- GNUnet/src/applications/fs/ecrs/keyspace.c 2005-03-21 16:51:38 UTC (rev
472)
+++ GNUnet/src/applications/fs/ecrs/keyspace.c 2005-03-21 17:41:09 UTC (rev
473)
@@ -135,6 +135,7 @@
EncName enc;
HashCode512 key;
char * cpy; /* copy of the encrypted portion */
+ struct ECRS_URI * xuri;
if (! ECRS_isKeywordURI(uri)) {
BREAK();
@@ -186,10 +187,18 @@
sock = getClientSocket();
ret = OK;
- keywords = uri->data.ksk.keywords;
- keywordCount = uri->data.ksk.keywordCount;
+ if (testConfigurationString("FS",
+ "DISABLE-CREATION-TIME",
+ "YES"))
+ xuri = ECRS_dupUri(uri);
+ else
+ xuri = ECRS_dateExpandKeywordUri(uri);
+ keywords = xuri->data.ksk.keywords;
+ keywordCount = xuri->data.ksk.keywordCount;
cpy = MALLOC(mdsize + strlen(dstURI) + 1);
- memcpy(cpy, &kb[1], mdsize + strlen(dstURI) + 1);
+ memcpy(cpy,
+ &kb[1],
+ mdsize + strlen(dstURI) + 1);
for (i=0;i<keywordCount;i++) {
memcpy(&kb[1], cpy, mdsize + strlen(dstURI) + 1);
hash(keywords[i],
@@ -224,6 +233,7 @@
GNUNET_ASSERT(OK == verifyKBlock(&key, value))
#endif
}
+ ECRS_freeUri(xuri);
FREE(cpy);
FREE(dstURI);
releaseClientSocket(sock);
Modified: GNUnet/src/applications/fs/ecrs/meta.c
===================================================================
--- GNUnet/src/applications/fs/ecrs/meta.c 2005-03-21 16:51:38 UTC (rev
472)
+++ GNUnet/src/applications/fs/ecrs/meta.c 2005-03-21 17:41:09 UTC (rev
473)
@@ -29,6 +29,11 @@
#include "gnunet_ecrs_lib.h"
#include <zlib.h>
+/* for pre LE 0.4.3 */
+#ifndef EXTRACTOR_PUBLICATION_DATE
+#define EXTRACTOR_PUBLICATION_DATE ((EXTRACTOR_KeywordType)71)
+#endif
+
/**
* Create a fresh MetaData token.
*/
@@ -54,6 +59,25 @@
}
/**
+ * Add the current time as the publication date
+ * to the meta-data.
+ */
+void ECRS_addPublicationDateToMetaData(MetaData * md) {
+ char * dat;
+ TIME_T t;
+
+ TIME(&t);
+ ECRS_delFromMetaData(md,
+ EXTRACTOR_PUBLICATION_DATE,
+ NULL);
+ dat = GN_CTIME(&t);
+ ECRS_addToMetaData(md,
+ EXTRACTOR_PUBLICATION_DATE,
+ dat);
+ FREE(dat);
+}
+
+/**
* Extend metadata.
* @return OK on success, SYSERR if this entry already exists
*/
@@ -119,7 +143,7 @@
sub = 0;
for (i=md->itemCount-1;i>=0;i--) {
- if (md->items[i].type != EXTRACTOR_THUMBNAIL_DATA) {
+ if (md->items[i].type != EXTRACTOR_THUMBNAIL_DATA) {
if ( (iterator != NULL) &&
(OK != iterator(md->items[i].type,
md->items[i].data,
Modified: GNUnet/src/applications/fs/ecrs/uri.c
===================================================================
--- GNUnet/src/applications/fs/ecrs/uri.c 2005-03-21 16:51:38 UTC (rev
472)
+++ GNUnet/src/applications/fs/ecrs/uri.c 2005-03-21 17:41:09 UTC (rev
473)
@@ -477,7 +477,7 @@
* Duplicate URI. FIXME: this is the QnD, costly
* implementation.
*/
-struct ECRS_URI * ECRS_dupUri(const struct ECRS_URI * uri) {
+URI * ECRS_dupUri(const URI * uri) {
char * tmp;
struct ECRS_URI * ret;
@@ -488,6 +488,49 @@
}
/**
+ * Expand a keyword-URI by duplicating all keywords,
+ * adding the current date (YYYY-MM-DD) after each
+ * keyword.
+ */
+URI * ECRS_dateExpandKeywordUri(const URI * uri) {
+ URI * ret;
+ int i;
+ char * key;
+ char * kd;
+ struct tm t;
+ time_t now;
+
+ GNUNET_ASSERT(uri->type == ksk);
+ time(&now);
+#ifdef HAVE_GMTIME_R
+ gmtime_r(&now, &t);
+#else
+ t = *gmtime(&now);
+#endif
+
+ ret = MALLOC(sizeof(URI));
+ ret->type = ksk;
+ ret->data.ksk.keywordCount = 2 * uri->data.ksk.keywordCount;
+ ret->data.ksk.keywords = MALLOC(sizeof(char*) * ret->data.ksk.keywordCount);
+ for (i=0;i<uri->data.ksk.keywordCount;i++) {
+ key = uri->data.ksk.keywords[2*i];
+ ret->data.ksk.keywords[2*i]
+ = STRDUP(key);
+ kd = MALLOC(strlen(key) + 13);
+ memset(kd, 0, strlen(key) + 13);
+ strcpy(kd, key);
+ strftime(kd[strlen(key)],
+ 13,
+ "-%Y-%m-%d",
+ &t);
+ ret->data.ksk.keywords[2*i+1]
+ = kd;
+ }
+ return ret;
+}
+
+
+/**
* Construct a keyword-URI from meta-data (take all entries
* in the meta-data and construct one large keyword URI
* that lists all keywords that can be found in the meta-data).
Modified: GNUnet/src/applications/fs/tools/gnunet-insert.c
===================================================================
--- GNUnet/src/applications/fs/tools/gnunet-insert.c 2005-03-21 16:51:38 UTC
(rev 472)
+++ GNUnet/src/applications/fs/tools/gnunet-insert.c 2005-03-21 17:41:09 UTC
(rev 473)
@@ -613,6 +613,10 @@
if (extractors == NULL)
extractors = STRDUP(EXTRACTOR_DEFAULT_LIBRARIES);
+ if (! testConfigurationString("FS",
+ "DISABLE-CREATION-TIME",
+ "YES"))
+ ECRS_addPublicationDateToMetaData(meta);
if (testConfigurationString("GNUNET-INSERT",
"RECURSIVE",
"YES")) {
Modified: GNUnet/src/include/gnunet_ecrs_lib.h
===================================================================
--- GNUnet/src/include/gnunet_ecrs_lib.h 2005-03-21 16:51:38 UTC (rev
472)
+++ GNUnet/src/include/gnunet_ecrs_lib.h 2005-03-21 17:41:09 UTC (rev
473)
@@ -120,6 +120,12 @@
const char * data);
/**
+ * Add the current time as the publication date
+ * to the meta-data.
+ */
+void ECRS_addPublicationDateToMetaData(struct ECRS_MetaData * md);
+
+/**
* Iterate over MD entries, excluding thumbnails.
*
* @return number of entries
@@ -237,12 +243,20 @@
struct ECRS_URI * ECRS_dupUri(const struct ECRS_URI * uri);
/**
+ * Expand a keyword-URI by duplicating all keywords,
+ * adding the current date (YYYY-MM-DD) after each
+ * keyword.
+ */
+struct ECRS_URI * ECRS_dateExpandKeywordUri(const struct ECRS_URI * uri);
+
+/**
* Test if two URIs are equal.
*/
int ECRS_equalsUri(const struct ECRS_URI * u1,
const struct ECRS_URI * u2);
-
+
+
/**
* Is this a namespace URI?
*/
Modified: GNUnet/src/include/gnunet_util.h
===================================================================
--- GNUnet/src/include/gnunet_util.h 2005-03-21 16:51:38 UTC (rev 472)
+++ GNUnet/src/include/gnunet_util.h 2005-03-21 17:41:09 UTC (rev 473)
@@ -1166,7 +1166,9 @@
TIME_T TIME(TIME_T * t);
/**
- * "man ctime".
+ * "man ctime_r".
+ * @return character sequence describing the time,
+ * must be freed by caller
*/
char * GN_CTIME(const TIME_T * t);
Modified: GNUnet/src/util/timer.c
===================================================================
--- GNUnet/src/util/timer.c 2005-03-21 16:51:38 UTC (rev 472)
+++ GNUnet/src/util/timer.c 2005-03-21 17:41:09 UTC (rev 473)
@@ -163,7 +163,7 @@
}
/**
- * "man ctime". Automagically expands the 32-bit
+ * "man ctime_r". Automagically expands the 32-bit
* GNUnet time value to a 64-bit value of the current
* epoc if needed.
*/
@@ -174,7 +174,11 @@
tnow = time(NULL);
now = (TIME_T) tnow;
tnow = tnow - now + *t;
- return ctime(&tnow);
+#ifdef ctime_r
+ return ctime_r(&tnow, MALLOC(32));
+#else
+ return STRDUP(ctime(&tnow));
+#endif
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r473 - in GNUnet: . src/applications/fs/ecrs src/applications/fs/tools src/include src/util,
grothoff <=