[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r805 - in GNUnet: . doc m4 src/applications/fs/ecrs src/app
From: |
grothoff |
Subject: |
[GNUnet-SVN] r805 - in GNUnet: . doc m4 src/applications/fs/ecrs src/applications/fs/fsui src/applications/fs/tools src/include |
Date: |
Tue, 24 May 2005 04:17:02 -0700 (PDT) |
Author: grothoff
Date: 2005-05-24 04:16:42 -0700 (Tue, 24 May 2005)
New Revision: 805
Modified:
GNUnet/README
GNUnet/configure.ac
GNUnet/doc/README.mysql
GNUnet/m4/Makefile.in
GNUnet/src/applications/fs/ecrs/directory.c
GNUnet/src/applications/fs/ecrs/download.c
GNUnet/src/applications/fs/ecrs/keyspace.c
GNUnet/src/applications/fs/ecrs/namespace.c
GNUnet/src/applications/fs/ecrs/uri.c
GNUnet/src/applications/fs/ecrs/uritest.c
GNUnet/src/applications/fs/fsui/collection.c
GNUnet/src/applications/fs/fsui/download.c
GNUnet/src/applications/fs/fsui/fsui.c
GNUnet/src/applications/fs/fsui/fsui.h
GNUnet/src/applications/fs/fsui/namespace_info.c
GNUnet/src/applications/fs/tools/gnunet-download.c
GNUnet/src/include/gnunet_ecrs_lib.h
GNUnet/todo
Log:
coding
Modified: GNUnet/README
===================================================================
--- GNUnet/README 2005-05-22 13:46:59 UTC (rev 804)
+++ GNUnet/README 2005-05-24 11:16:42 UTC (rev 805)
@@ -48,7 +48,8 @@
GNUnet requires the GNU MP library (http://www.gnu.org/software/gmp/)
and libgcrypt. You can specify the path to libgcrypt by passing
-"--with-gcrypt=PATH" to configure.
+"--with-gcrypt=PATH" to configure. You will also need either sqlite
+(version 3 or higher) or MySQL (version 4.1 or higher).
If you are compiling the code from subversion, you have to run
". bootstrap" before ./configure. If you receive an error during the
@@ -56,7 +57,7 @@
found in library", you may need to run aclocal by hand with the -I
option, pointing to your aclocal m4 macros, i.e.
-# aclocal -I /usr/local/share/aclocal
+$ aclocal -I /usr/local/share/aclocal
In order to start a "permanent" node, you should create a new user
"gnunet" and start "gnunetd" as that user whenever the system boots.
@@ -79,8 +80,8 @@
The defaults are usually ok, you may want to adjust the limitations
(space consumption, bandwidth, etc.) though. If you want to
-configure, edit "/etc/gnunet.conf" and "~/.gnunet/gnunet.conf"
-(whichever applies).
+configure, edit "/etc/gnunetd.conf" (or /var/lib/GNUnet/gnunetd.conf)
+and "~/.gnunet/gnunet.conf" (whichever applies).
If you want to use a different configuration file, pass the name of
the configuration file as an argument with the option -c to any GNUnet
@@ -100,20 +101,20 @@
First, you must obtain an initial list of GNUnet hosts. Knowing a
single peer is sufficient since after that GNUnet propagates
-information about other peers. Note that the default "gnunet.conf"
+information about other peers. Note that the default "gnunetd.conf"
contains a URL from where gnunetd downloads an initial hostlist
whenever it is started. If you want to create an alternative URL for
others to use, the file can be generated on any machine running
gnunetd by periodically executing
-# cat $GNUNETD-HOME/.gnunet/data/hosts/* > the_file
+$ cat $GNUNETD_HOME/data/hosts/* > the_file
If the solution with the URL is not feasible for your situation, you
can also add hosts manually. The GNUnet webpage has a public
directory of hostkeys under http://gnunet.org/hosts/. You
can of course use any other source for these files. Copy the hostkeys
-to "$GNUNETD-HOME/.gnunet/data/hosts/" (where $GNUNETD_HOME is the
-directory specified in the /etc/gnunet.conf configuration file).
+to "$GNUNETD_HOME/data/hosts/" (where $GNUNETD_HOME is the
+directory specified in the /etc/gnunetd.conf configuration file).
Now start the local node using "gnunetd". gnunetd should run 24/7 if
you want to maximize your anonymity. You may start it as a service
@@ -142,7 +143,7 @@
==============
Contributions are welcome, please submit bugs to
-http://gnunet.org/mantis/. Please make sure to run contrib/report.sh
+https://gnunet.org/mantis/. Please make sure to run contrib/report.sh
and include the output with your bug reports. More about how to
report bugs can be found in the GNUnet FAQ on the webpage. Submit
patches via E-Mail to address@hidden
@@ -158,3 +159,4 @@
* http://mail.gnu.org/mailman/listinfo/gnunet-developers
* http://mail.gnu.org/mailman/listinfo/help-gnunet
* http://mail.gnu.org/mailman/listinfo/info-gnunet
+
Modified: GNUnet/configure.ac
===================================================================
--- GNUnet/configure.ac 2005-05-22 13:46:59 UTC (rev 804)
+++ GNUnet/configure.ac 2005-05-24 11:16:42 UTC (rev 805)
@@ -332,15 +332,6 @@
AM_CONDITIONAL(HAVE_CURSES, test x$curses = x1)
AM_CONDITIONAL(HAVE_PDCURSES, test x$pdcurses = x1)
-# check for gtk >= 2.4.0
-AC_MSG_CHECKING(for gtk)
-AM_PATH_GTK_2_0(2.4.0,without_gtk=false,without_gtk=true)
-AM_CONDITIONAL(HAVE_GTK, test x$without_gtk != xtrue)
-if test $without_gtk != true
-then
- AC_DEFINE_UNQUOTED([HAVE_GTK], 1, [We have GTK])
-fi
-
# check for gettext
AM_GNU_GETTEXT_VERSION(0.14)
AM_GNU_GETTEXT([external])
@@ -557,9 +548,4 @@
AC_MSG_NOTICE([NOTICE: IPv6 support will NOT be compiled.])
fi
-#if test "$without_gtk" = "true"
-#then
-# AC_MSG_NOTICE([NOTICE: gnunet-gtk user interface will NOT be compiled.])
-#fi
-
AC_MSG_NOTICE([NOTICE: Database support is set to MySQL: $mysql, SQLite:
$sqlite])
Modified: GNUnet/doc/README.mysql
===================================================================
--- GNUnet/doc/README.mysql 2005-05-22 13:46:59 UTC (rev 804)
+++ GNUnet/doc/README.mysql 2005-05-24 11:16:42 UTC (rev 805)
@@ -1,8 +1,7 @@
How to setup the MySQL database for GNUnet.
-NOTE: This db module does NOT work with mysql v3.23.49 due to a bug
-in mysql. All later versions should be fine, including the 4.0.x
-series. Current devel version is 4.0.22 on debian/unstable.
+NOTE: This db module does NOT work with mysql before 4.1 since
+we need prepared statements.
HIGHLIGHTS
@@ -21,11 +20,11 @@
MANUAL SETUP INSTRUCTIONS
- 1) in /etc/gnunet.conf, set
+ 1) in /etc/gnunetd.conf, set
sqstore = "sqstore_mysql"
2) Then access mysql as root,
- # mysql -u root -p
+ $ mysql -u root -p
and do the following. [You should replace $USER with the username
that will be running the gnunetd process].
@@ -52,7 +51,7 @@
4) Still, perhaps you should briefly try if the DB connection
works. First, login as $USER. Then use,
- # mysql -u $USER
+ $ mysql -u $USER
mysql> use gnunet;
If you get the message "Database changed" it probably works.
@@ -80,9 +79,9 @@
EFFICIENCY ISSUES
If you suffer from too slow index/insert speeds,
- you might try to define /etc/gnunet.conf option
+ you might try to define /etc/gnunetd.conf option
- [AFS]
+ [MYSQL]
MYSQL_DELAYED = YES
for small efficiency boost. The option will let MySQL bundle multiple
Modified: GNUnet/m4/Makefile.in
===================================================================
--- GNUnet/m4/Makefile.in 2005-05-22 13:46:59 UTC (rev 804)
+++ GNUnet/m4/Makefile.in 2005-05-24 11:16:42 UTC (rev 805)
@@ -38,13 +38,12 @@
DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in ChangeLog
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/m4/ac_define_dir.m4 \
- $(top_srcdir)/m4/gettext.m4 $(top_srcdir)/m4/gtk-2.0.m4 \
- $(top_srcdir)/m4/guile.m4 $(top_srcdir)/m4/iconv.m4 \
- $(top_srcdir)/m4/lib-ld.m4 $(top_srcdir)/m4/lib-link.m4 \
- $(top_srcdir)/m4/lib-prefix.m4 $(top_srcdir)/m4/libgcrypt.m4 \
- $(top_srcdir)/m4/nls.m4 $(top_srcdir)/m4/po.m4 \
- $(top_srcdir)/m4/progtest.m4 $(top_srcdir)/acinclude.m4 \
- $(top_srcdir)/configure.ac
+ $(top_srcdir)/m4/gettext.m4 $(top_srcdir)/m4/guile.m4 \
+ $(top_srcdir)/m4/iconv.m4 $(top_srcdir)/m4/lib-ld.m4 \
+ $(top_srcdir)/m4/lib-link.m4 $(top_srcdir)/m4/lib-prefix.m4 \
+ $(top_srcdir)/m4/libgcrypt.m4 $(top_srcdir)/m4/nls.m4 \
+ $(top_srcdir)/m4/po.m4 $(top_srcdir)/m4/progtest.m4 \
+ $(top_srcdir)/acinclude.m4 $(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
@@ -92,15 +91,11 @@
F77 = @F77@
FFLAGS = @FFLAGS@
GMSGFMT = @GMSGFMT@
-GTK_CFLAGS = @GTK_CFLAGS@
-GTK_LIBS = @GTK_LIBS@
GUILE = @GUILE@
GUILE_CONFIG = @GUILE_CONFIG@
GUILE_TOOLS = @GUILE_TOOLS@
HAVE_CURSES_FALSE = @HAVE_CURSES_FALSE@
HAVE_CURSES_TRUE = @HAVE_CURSES_TRUE@
-HAVE_GTK_FALSE = @HAVE_GTK_FALSE@
-HAVE_GTK_TRUE = @HAVE_GTK_TRUE@
HAVE_GUILE_FALSE = @HAVE_GUILE_FALSE@
HAVE_GUILE_TRUE = @HAVE_GUILE_TRUE@
HAVE_IPV6_FALSE = @HAVE_IPV6_FALSE@
@@ -154,7 +149,6 @@
PACKAGE_TARNAME = @PACKAGE_TARNAME@
PACKAGE_VERSION = @PACKAGE_VERSION@
PATH_SEPARATOR = @PATH_SEPARATOR@
-PKG_CONFIG = @PKG_CONFIG@
POSUB = @POSUB@
RANLIB = @RANLIB@
SET_MAKE = @SET_MAKE@
Modified: GNUnet/src/applications/fs/ecrs/directory.c
===================================================================
--- GNUnet/src/applications/fs/ecrs/directory.c 2005-05-22 13:46:59 UTC (rev
804)
+++ GNUnet/src/applications/fs/ecrs/directory.c 2005-05-24 11:16:42 UTC (rev
805)
@@ -99,7 +99,7 @@
pos = epos+1;
if (fi.uri == NULL)
return SYSERR; /* malformed! */
- if (ECRS_isKeywordURI(fi.uri)) {
+ if (ECRS_isKeywordUri(fi.uri)) {
ECRS_freeUri(fi.uri);
BREAK();
return SYSERR; /* illegal in directory! */
@@ -169,7 +169,7 @@
int ret;
for (i=0;i<count;i++) {
- if (ECRS_isKeywordURI(fis[i].uri)) {
+ if (ECRS_isKeywordUri(fis[i].uri)) {
BREAK();
return SYSERR; /* illegal in directory! */
}
Modified: GNUnet/src/applications/fs/ecrs/download.c
===================================================================
--- GNUnet/src/applications/fs/ecrs/download.c 2005-05-22 13:46:59 UTC (rev
804)
+++ GNUnet/src/applications/fs/ecrs/download.c 2005-05-24 11:16:42 UTC (rev
805)
@@ -1147,7 +1147,7 @@
FileIdentifier fid;
fid = uri->data.chk;
- if (! ECRS_isFileURI(uri))
+ if (! ECRS_isFileUri(uri))
return SYSERR;
if (OK != createIOContext(&ioc,
Modified: GNUnet/src/applications/fs/ecrs/keyspace.c
===================================================================
--- GNUnet/src/applications/fs/ecrs/keyspace.c 2005-05-22 13:46:59 UTC (rev
804)
+++ GNUnet/src/applications/fs/ecrs/keyspace.c 2005-05-24 11:16:42 UTC (rev
805)
@@ -137,7 +137,7 @@
char * cpy; /* copy of the encrypted portion */
struct ECRS_URI * xuri;
- if (! ECRS_isKeywordURI(uri)) {
+ if (! ECRS_isKeywordUri(uri)) {
BREAK();
return SYSERR;
}
Modified: GNUnet/src/applications/fs/ecrs/namespace.c
===================================================================
--- GNUnet/src/applications/fs/ecrs/namespace.c 2005-05-22 13:46:59 UTC (rev
804)
+++ GNUnet/src/applications/fs/ecrs/namespace.c 2005-05-24 11:16:42 UTC (rev
805)
@@ -123,7 +123,7 @@
char * cpy;
if ( (advertisementURI != NULL) &&
- (! ECRS_isKeywordURI(advertisementURI)) ) {
+ (! ECRS_isKeywordUri(advertisementURI)) ) {
BREAK();
return SYSERR;
}
Modified: GNUnet/src/applications/fs/ecrs/uri.c
===================================================================
--- GNUnet/src/applications/fs/ecrs/uri.c 2005-05-22 13:46:59 UTC (rev
804)
+++ GNUnet/src/applications/fs/ecrs/uri.c 2005-05-24 11:16:42 UTC (rev
805)
@@ -403,7 +403,7 @@
/**
* Is this a namespace URI?
*/
-int ECRS_isNamespaceURI(const struct ECRS_URI * uri) {
+int ECRS_isNamespaceUri(const struct ECRS_URI * uri) {
return uri->type == sks;
}
@@ -430,7 +430,7 @@
*/
int ECRS_getNamespaceId(const struct ECRS_URI * uri,
HashCode512 * id) {
- if (! ECRS_isNamespaceURI(uri)) {
+ if (! ECRS_isNamespaceUri(uri)) {
BREAK();
return SYSERR;
}
@@ -441,7 +441,7 @@
/**
* Is this a keyword URI?
*/
-int ECRS_isKeywordURI(const struct ECRS_URI * uri) {
+int ECRS_isKeywordUri(const struct ECRS_URI * uri) {
return uri->type == ksk;
}
@@ -460,14 +460,14 @@
/**
* Is this a file (or directory) URI?
*/
-int ECRS_isFileURI(const struct ECRS_URI * uri) {
+int ECRS_isFileUri(const struct ECRS_URI * uri) {
return uri->type == chk;
}
/**
* Is this a location URI? (DHT specific!)
*/
-int ECRS_isLocationURI(const struct ECRS_URI * uri) {
+int ECRS_isLocationUri(const struct ECRS_URI * uri) {
return uri->type == loc;
}
Modified: GNUnet/src/applications/fs/ecrs/uritest.c
===================================================================
--- GNUnet/src/applications/fs/ecrs/uritest.c 2005-05-22 13:46:59 UTC (rev
804)
+++ GNUnet/src/applications/fs/ecrs/uritest.c 2005-05-24 11:16:42 UTC (rev
805)
@@ -40,7 +40,7 @@
ret = ECRS_stringToUri("gnunet://ecrs/ksk/foo+bar");
if (ret == NULL)
ABORT();
- if (! ECRS_isKeywordURI(ret))
+ if (! ECRS_isKeywordUri(ret))
ABORT();
if ( (2 != ret->data.ksk.keywordCount) ||
(0 != strcmp("foo", ret->data.ksk.keywords[0])) ||
@@ -69,9 +69,9 @@
ret =
ECRS_stringToUri("gnunet://ecrs/sks/C282GG70GKK41O4551011DO413KFBVTVMQG1OG30I0K4045N0G41HAPB82G680A02JRVVFO8URVRU2F159011DO41000000022RG820/test");
if (ret == NULL)
ABORT();
- if (ECRS_isKeywordURI(ret))
+ if (ECRS_isKeywordUri(ret))
ABORT();
- if (! ECRS_isNamespaceURI(ret))
+ if (! ECRS_isNamespaceUri(ret))
ABORT();
uri = ECRS_uriToString(ret);
@@ -96,9 +96,9 @@
ret =
ECRS_stringToUri("gnunet://ecrs/chk/C282GG70GKK41O4551011DO413KFBVTVMQG1OG30I0K4045N0G41HAPB82G680A02JRVVFO8URVRU2F159011DO41000000022RG820.RNVVVVOOLCLK065B5D04HTNVNSIB2AI022RG8200HSLK1CO1000ATQ98824DMA2032LIMG50CG0K057NVUVG200000H000004400000.42");
if (ret == NULL)
ABORT();
- if (ECRS_isKeywordURI(ret))
+ if (ECRS_isKeywordUri(ret))
ABORT();
- if (ECRS_isNamespaceURI(ret))
+ if (ECRS_isNamespaceUri(ret))
ABORT();
if (ntohll(ret->data.chk.file_length) != 42)
ABORT();
Modified: GNUnet/src/applications/fs/fsui/collection.c
===================================================================
--- GNUnet/src/applications/fs/fsui/collection.c 2005-05-22 13:46:59 UTC
(rev 804)
+++ GNUnet/src/applications/fs/fsui/collection.c 2005-05-24 11:16:42 UTC
(rev 805)
@@ -340,7 +340,7 @@
if (ctx->collectionData == NULL)
return;
- if ((ECRS_isKeywordURI(fi->uri))) {
+ if ((ECRS_isKeywordUri(fi->uri))) {
BREAK();
return;
}
Modified: GNUnet/src/applications/fs/fsui/download.c
===================================================================
--- GNUnet/src/applications/fs/fsui/download.c 2005-05-22 13:46:59 UTC (rev
804)
+++ GNUnet/src/applications/fs/fsui/download.c 2005-05-24 11:16:42 UTC (rev
805)
@@ -294,8 +294,8 @@
FSUI_DownloadList * parent) {
FSUI_DownloadList * dl;
- if (! (ECRS_isFileURI(uri) ||
- ECRS_isLocationURI(uri)) ) {
+ if (! (ECRS_isFileUri(uri) ||
+ ECRS_isLocationUri(uri)) ) {
BREAK(); /* wrong type of URI! */
return SYSERR;
}
Modified: GNUnet/src/applications/fs/fsui/fsui.c
===================================================================
--- GNUnet/src/applications/fs/fsui/fsui.c 2005-05-22 13:46:59 UTC (rev
804)
+++ GNUnet/src/applications/fs/fsui/fsui.c 2005-05-24 11:16:42 UTC (rev
805)
@@ -1,6 +1,6 @@
/*
This file is part of GNUnet.
- (C) 2001, 2002, 2003, 2004 Christian Grothoff (and other contributing
authors)
+ (C) 2001, 2002, 2003, 2004, 2005 Christian Grothoff (and other
contributing authors)
GNUnet is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published
@@ -28,11 +28,239 @@
#include "gnunet_fsui_lib.h"
#include "fsui.h"
+#define READINT(a) \
+ if (sizeof(int) != READ(fd, &big, sizeof(int))) \
+ goto ERROR; \
+ else \
+ a = ntohl(big)
+#define READLONG(a) \
+ if (sizeof(long long) != READ(fd, &bigl, sizeof(long long))) \
+ goto ERROR; \
+ else \
+ a = ntohll(big)
+
+static struct ECRS_URI * readURI(int fd) {
+ char * buf;
+ unsigned int big;
+ struct ECRS_URI * ret;
+ unsigned int size;
+
+ READINT(size);
+ buf = MALLOC(size+1);
+ buf[size] = '\0';
+ if (size != READ(fd,
+ buf,
+ size)) {
+ FREE(buf);
+ return NULL;
+ }
+ ret = ECRS_stringToUri(buf);
+ FREE(buf);
+ return ret;
+ ERROR:
+ return NULL;
+}
+
/**
+ * (Recursively) read a download list from the
+ * given fd.
+ *
+ * @return NULL on error AND on read of empty
+ * list (these two cannot be distinguished)
+ */
+static FSUI_DownloadList * readDownloadList(int fd,
+ FSUI_Context * ctx) {
+ char zaro;
+ static FSUI_DownloadList * ret;
+ unsigned int big;
+ unsigned long long bigl;
+ int i;
+
+ if (1 != READ(fd, &zaro, sizeof(char)))
+ return NULL;
+ if (zaro == '\0')
+ return NULL;
+ ret = MALLOC(sizeof(FSUI_DownloadList));
+ ret->ctx = ctx;
+
+ ret->signalTerminate
+ = NO;
+ READINT(ret->is_recursive);
+ READINT(ret->is_directory);
+ READINT(ret->anonymityLevel);
+ READINT(ret->completedDownloadsCount);
+ READLONG(ret->total);
+ READLONG(ret->completed);
+ READLONG(ret->startTime);
+ ret->startTime = cronTime(NULL) - ret->startTime;
+ ret->uri
+ = readURI(fd);
+ if (ret->completedDownloadsCount > 0)
+ ret->completedDownloads
+ = MALLOC(sizeof(struct ECRS_URI *) *
+ ret->completedDownloadsCount);
+ else
+ ret->completedDownloads
+ = NULL;
+ for (i=0;i<ret->completedDownloadsCount;i++) {
+ ret->completedDownloads[i]
+ = readURI(fd);
+ }
+ /* FIXME: check if URIs were
+ all read successfully! */
+
+ ret->next = readDownloadList(fd,
+ ctx);
+ ret->next->parent = ret;
+ ret->subDownloads = readDownloadList(fd,
+ ctx);
+ ret->subDownloadsNext = readDownloadList(fd,
+ ctx);
+
+ /* FIXME: start download thread! */
+ // PTHREAD_CREATE(&ret->handle);
+ return ret;
+ ERROR:
+ FREE(ret);
+ return NULL;
+}
+
+static void WRITEINT(int fd,
+ int val) {
+ int big;
+ big = htonl(val);
+ WRITE(fd, &big, sizeof(int));
+}
+
+static void WRITELONG(int fd,
+ long long val) {
+ long long big;
+ big = htonll(val);
+ WRITE(fd, &big, sizeof(long long));
+}
+
+static void writeURI(int fd,
+ const struct ECRS_URI * uri) {
+ char * buf;
+ unsigned int size;
+
+ buf = ECRS_uriToString(uri);
+ size = strlen(buf);
+ WRITEINT(fd, size);
+ WRITE(fd,
+ buf,
+ size);
+ FREE(buf);
+}
+
+/**
+ * (recursively) write a download list.
+ */
+static void writeDownloadList(int fd,
+ const FSUI_DownloadList * list) {
+ static char zero = '\0';
+ static char nonzero = '+';
+ int i;
+
+ if (list == NULL) {
+ WRITE(fd, &zero, sizeof(char));
+ return;
+ }
+ WRITE(fd, &nonzero, sizeof(char));
+
+ /* FIXME: write rest of list */
+ WRITEINT(fd, list->is_recursive);
+ WRITEINT(fd, list->is_directory);
+ WRITEINT(fd, list->anonymityLevel);
+ WRITEINT(fd, list->completedDownloadsCount);
+ WRITELONG(fd, list->total);
+ WRITELONG(fd, list->completed);
+ WRITELONG(fd, cronTime(NULL) - list->startTime);
+ writeURI(fd, list->uri);
+ for (i=0;i<list->completedDownloadsCount;i++)
+ writeURI(fd, list->completedDownloads[i]);
+
+ writeDownloadList(fd,
+ list->next);
+ writeDownloadList(fd,
+ list->subDownloads);
+ writeDownloadList(fd,
+ list->subDownloadsNext);
+}
+
+/**
+ * Read file info from file.
+ *
+ * @return OK on success, SYSERR on error
+ */
+static int readFileInfo(int fd,
+ ECRS_FileInfo * fi) {
+ unsigned int size;
+ unsigned int big;
+ char * buf;
+
+ fi->meta = NULL;
+ fi->uri = NULL;
+ if (sizeof(unsigned int) !=
+ READ(fd,
+ &big,
+ sizeof(unsigned int)))
+ return SYSERR;
+ size = ntohl(big);
+ buf = MALLOC(size);
+ if (size != READ(fd,
+ buf,
+ size)) {
+ FREE(buf);
+ return SYSERR;
+ }
+ if (OK != ECRS_deserializeMetaData(&fi->meta,
+ buf,
+ size)) {
+ FREE(buf);
+ return SYSERR;
+ }
+ FREE(buf);
+
+ fi->uri
+ = readURI(fd);
+ if (fi->uri == NULL) {
+ ECRS_freeMetaData(fi->meta);
+ fi->meta = NULL;
+ return SYSERR;
+ }
+ return OK;
+}
+
+static void writeFileInfo(int fd,
+ const ECRS_FileInfo * fi) {
+ unsigned int size;
+ unsigned int big;
+ char * buf;
+
+ size = ECRS_sizeofMetaData(fi->meta);
+ buf = MALLOC(size);
+ ECRS_serializeMetaData(fi->meta,
+ buf,
+ size,
+ NO);
+ big = htonl(size);
+ WRITE(fd,
+ &big,
+ sizeof(unsigned int));
+ WRITE(fd,
+ buf,
+ size);
+ FREE(buf);
+ writeURI(fd, fi->uri);
+}
+
+/**
* Start FSUI manager. Use the given progress callback to notify the
* UI about events. Start processing pending activities that were
* running when FSUI_stop was called previously.
*
+ * @param name name of the context, must not be NULL
* @return NULL on error
*/
struct FSUI_Context * FSUI_start(const char * name,
@@ -42,28 +270,216 @@
FSUI_Context * ret;
char * fn;
char * gh;
+ int fd;
+ int i;
ret = MALLOC(sizeof(FSUI_Context));
memset(ret, 0, sizeof(FSUI_Context));
+ fn = getConfigurationString("",
+ "GNUNET_HOME");
+ gh = expandFileName(fn);
+ FREE(fn);
+ fn = MALLOC(strlen(gh) + strlen(name) + 2);
+ strcpy(fn, gh);
+ FREE(gh);
+ strcat(fn, DIR_SEPARATOR_STR);
+ strcat(fn, name);
+ ret->ipc = IPC_SEMAPHORE_NEW(fn,
+ 1);
+ ret->name = fn;
if (doResume) {
- fn = getConfigurationString("",
- "GNUNET_HOME");
- gh = expandFileName(fn);
- FREE(fn);
- fn = MALLOC(strlen(gh) + strlen(name) + 2);
- strcpy(fn, gh);
- FREE(gh);
- strcat(fn, DIR_SEPARATOR_STR);
- strcat(fn, "fsui-lock");
- ret->ipc = IPC_SEMAPHORE_NEW(fn,
- 1);
LOG(LOG_INFO,
"Getting IPC lock for FSUI (%s).\n",
fn);
- FREE(fn);
IPC_SEMAPHORE_DOWN(ret->ipc);
LOG(LOG_INFO,
"Aquired IPC lock.\n");
+ fd = fileopen(fn, O_RDONLY);
+ if (fd != -1) {
+ char magic[8];
+ unsigned int big;
+
+ /* ****** check magic ******* */
+ if (8 != READ(fd, magic, 8))
+ goto WARN;
+ if (0 != memcmp(magic,
+ "FSUI00\n\0",
+ 8))
+ goto WARN;
+ /* ******* deserialize state **** */
+
+ /* deserialize collection data */
+ if (sizeof(unsigned int) !=
+ READ(fd, &big, sizeof(unsigned int)))
+ goto WARN;
+ if (ntohl(big) > 16 * 1024 * 1024)
+ goto WARN;
+ ret->collectionData
+ = MALLOC(ntohl(big));
+ if (ntohl(big) - sizeof(unsigned int) !=
+ READ(fd,
+ &ret->collectionData[1],
+ ntohl(big) - sizeof(unsigned int))) {
+ FREE(ret->collectionData);
+ ret->collectionData = NULL;
+ goto WARN;
+ }
+
+ /* deserialize pending searches! */
+ while (1) {
+ FSUI_SearchList * list;
+ char * buf;
+
+ if (sizeof(unsigned int) !=
+ READ(fd, &big, sizeof(unsigned int)))
+ goto WARN;
+ if (ntohl(big) == 0)
+ break;
+ if (ntohl(big) > 1024 * 1024)
+ goto WARN;
+ buf
+ = MALLOC(ntohl(big)+1);
+ buf[ntohl(big)] = '\0';
+ if (ntohl(big) !=
+ READ(fd,
+ buf,
+ ntohl(big))) {
+ FREE(buf);
+ goto WARN;
+ }
+ list
+ = MALLOC(sizeof(FSUI_SearchList));
+ list->uri
+ = ECRS_stringToUri(buf);
+ FREE(buf);
+ if (list->uri == NULL) {
+ FREE(list);
+ goto WARN;
+ }
+ if (! ECRS_isKeywordUri(list->uri)) {
+ ECRS_freeUri(list->uri);
+ FREE(list);
+ goto WARN;
+ }
+ list->numberOfURIKeys
+ = ECRS_countKeywordsOfUri(list->uri);
+ if (sizeof(unsigned int) !=
+ READ(fd, &big, sizeof(unsigned int))) {
+ ECRS_freeUri(list->uri);
+ FREE(list);
+ goto WARN;
+ }
+ list->anonymityLevel
+ = ntohl(big);
+ if (sizeof(unsigned int) !=
+ READ(fd, &big, sizeof(unsigned int))) {
+ ECRS_freeUri(list->uri);
+ FREE(list);
+ goto WARN;
+ }
+ list->sizeResultsReceived
+ = ntohl(big);
+ if (sizeof(unsigned int) !=
+ READ(fd, &big, sizeof(unsigned int))) {
+ ECRS_freeUri(list->uri);
+ FREE(list);
+ goto WARN;
+ }
+ list->sizeUnmatchedResultsReceived
+ = ntohl(big);
+ if ( (list->sizeResultsReceived > 1024*1024) ||
+ (list->sizeUnmatchedResultsReceived > 1024*1024) ) {
+ ECRS_freeUri(list->uri);
+ FREE(list);
+ goto WARN;
+ }
+ if (list->sizeResultsReceived > 0)
+ list->resultsReceived
+ = MALLOC(list->sizeResultsReceived *
+ sizeof(ECRS_FileInfo));
+ else
+ list->resultsReceived
+ = NULL;
+ if (list->sizeUnmatchedResultsReceived > 0)
+ list->unmatchedResultsReceived
+ = MALLOC(list->sizeUnmatchedResultsReceived *
+ sizeof(ResultPending));
+ else
+ list->unmatchedResultsReceived
+ = NULL;
+ for (i=0;i<list->sizeResultsReceived;i++)
+ readFileInfo(fd,
+ &list->resultsReceived[i]);
+ for (i=0;i<list->sizeUnmatchedResultsReceived;i++) {
+ ResultPending * rp;
+
+ rp = &list->unmatchedResultsReceived[i];
+ readFileInfo(fd,
+ &rp->fi);
+
+ if (sizeof(unsigned int) !=
+ READ(fd,
+ &big,
+ sizeof(unsigned int))) {
+ /* FIXME: memory leak! */
+ goto WARN;
+ }
+ rp->matchingKeyCount
+ = ntohl(big);
+ if ( (rp->matchingKeyCount > 1024) ||
+ (rp->matchingKeyCount >
+ list->numberOfURIKeys) ) {
+ /* FIXME: memory leak! */
+ goto WARN;
+ }
+
+ if (rp->matchingKeyCount > 0)
+ rp->matchingKeys
+ = MALLOC(sizeof(HashCode512) *
+ rp->matchingKeyCount);
+ else
+ rp->matchingKeys
+ = NULL;
+ if (sizeof(HashCode512) *
+ rp->matchingKeyCount !=
+ READ(fd,
+ rp->matchingKeys,
+ sizeof(HashCode512) *
+ rp->matchingKeyCount)) {
+ /* FIXME: memory leak! */
+ goto WARN;
+ }
+ }
+
+
+ list->signalTerminate
+ = NO;
+ list->ctx
+ = ret;
+ /* FIXME: start search threads! */
+ // PTHREAD_CREATE(&list->handle);
+
+ /* finally: prepend to list */
+ list->next
+ = ret->activeSearches;
+ ret->activeSearches
+ = list;
+ }
+ ret->activeDownloads
+ = readDownloadList(fd,
+ ret);
+
+ /* success, read complete! */
+ goto END;
+ WARN:
+ LOG(LOG_WARNING,
+ _("FSUI state file '%s' had syntax error at offset %u.\n"),
+ fn,
+ lseek(fd, 0, SEEK_CUR));
+ END:
+ CLOSE(fd);
+ UNLINK(fn);
+ }
} else
ret->ipc = NULL;
MUTEX_CREATE_RECURSIVE(&ret->lock);
@@ -105,6 +521,8 @@
FSUI_SearchList * spos;
void * unused;
int i;
+ int fd;
+ int big;
LOG(LOG_INFO,
"FSUI shutdown. This may take a while.\n");
@@ -116,14 +534,85 @@
FREE(tpos);
}
+ if (ctx->ipc != NULL) {
+ fd = fileopen(ctx->name,
+ O_CREAT|O_TRUNC|O_WRONLY,
+ S_IRUSR|S_IWUSR);
+ WRITE(fd,
+ "FSUI00\n\0",
+ 8); /* magic */
+ if (fd == -1) {
+ LOG_FILE_STRERROR(LOG_ERROR,
+ "open",
+ ctx->name);
+ }
+ } else {
+ fd = -1;
+ }
+ if (fd != -1) {
+ /* serialize collection data */
+ WRITE(fd,
+ ctx->collectionData,
+ ntohl(ctx->collectionData->size));
+ }
while (ctx->activeSearches != NULL) {
spos = ctx->activeSearches;
ctx->activeSearches = spos->next;
spos->signalTerminate = YES;
PTHREAD_JOIN(&spos->handle, &unused);
- /* FIXME: serialize spos state! */
+ if (fd != -1) {
+ /* serialize pending searches */
+ char * tmp;
+ unsigned int big;
+ tmp = ECRS_uriToString(spos->uri);
+ GNUNET_ASSERT(tmp != NULL);
+ big = htonl(strlen(tmp));
+ WRITE(fd,
+ &big,
+ sizeof(unsigned int));
+ WRITE(fd,
+ tmp,
+ strlen(tmp));
+ FREE(tmp);
+ big = htonl(spos->anonymityLevel);
+ WRITE(fd,
+ &big,
+ sizeof(unsigned int));
+ big = htonl(spos->sizeResultsReceived);
+ WRITE(fd,
+ &big,
+ sizeof(unsigned int));
+ big = htonl(spos->sizeUnmatchedResultsReceived);
+ WRITE(fd,
+ &big,
+ sizeof(unsigned int));
+ for (i=0;i<spos->sizeResultsReceived;i++)
+ writeFileInfo(fd,
+ &spos->resultsReceived[i]);
+ for (i=0;i<spos->sizeUnmatchedResultsReceived;i++) {
+ ResultPending * rp;
+
+ rp = &spos->unmatchedResultsReceived[i];
+ writeFileInfo(fd,
+ &rp->fi);
+ big = htonl(rp->matchingKeyCount);
+ WRITE(fd,
+ &big,
+ sizeof(unsigned int));
+ WRITE(fd,
+ rp->matchingKeys,
+ sizeof(HashCode512) * rp->matchingKeyCount);
+ }
+ }
+ if (fd != -1) {
+ big = htonl(strlen(0));
+ WRITE(fd,
+ &big,
+ sizeof(unsigned int));
+ }
+
ECRS_freeUri(spos->uri);
for (i=spos->sizeResultsReceived-1;i>=0;i--) {
ECRS_FileInfo * fi;
@@ -135,7 +624,9 @@
spos->sizeResultsReceived,
0);
for (i=spos->sizeUnmatchedResultsReceived-1;i>=0;i--) {
- ResultPending * rp = &spos->unmatchedResultsReceived[i];
+ ResultPending * rp;
+
+ rp = &spos->unmatchedResultsReceived[i];
GROW(rp->matchingKeys,
rp->matchingKeyCount,
0);
@@ -148,14 +639,20 @@
FREE(spos);
}
- /* FIXME: serialize dpos state! */
+ if (fd != -1) {
+ writeDownloadList(fd,
+ ctx->activeDownloads);
+ }
freeDownloadList(ctx->activeDownloads);
ctx->activeDownloads = NULL;
+ if (fd != -1)
+ CLOSE(fd);
if (ctx->ipc != NULL) {
IPC_SEMAPHORE_UP(ctx->ipc);
IPC_SEMAPHORE_FREE(ctx->ipc);
}
MUTEX_DESTROY(&ctx->lock);
+ FREE(ctx->name);
FREE(ctx);
LOG(LOG_INFO,
"FSUI shutdown complete.\n");
Modified: GNUnet/src/applications/fs/fsui/fsui.h
===================================================================
--- GNUnet/src/applications/fs/fsui/fsui.h 2005-05-22 13:46:59 UTC (rev
804)
+++ GNUnet/src/applications/fs/fsui/fsui.h 2005-05-24 11:16:42 UTC (rev
805)
@@ -226,6 +226,8 @@
IPC_Semaphore * ipc;
+ char * name;
+
/**
* Lock to synchronize access to the FSUI Context.
*/
Modified: GNUnet/src/applications/fs/fsui/namespace_info.c
===================================================================
--- GNUnet/src/applications/fs/fsui/namespace_info.c 2005-05-22 13:46:59 UTC
(rev 804)
+++ GNUnet/src/applications/fs/fsui/namespace_info.c 2005-05-24 11:16:42 UTC
(rev 805)
@@ -711,7 +711,7 @@
struct ECRS_MetaData * old;
HashCode512 id;
- if (! ECRS_isNamespaceURI(uri)) {
+ if (! ECRS_isNamespaceUri(uri)) {
BREAK();
return;
}
Modified: GNUnet/src/applications/fs/tools/gnunet-download.c
===================================================================
--- GNUnet/src/applications/fs/tools/gnunet-download.c 2005-05-22 13:46:59 UTC
(rev 804)
+++ GNUnet/src/applications/fs/tools/gnunet-download.c 2005-05-24 11:16:42 UTC
(rev 805)
@@ -209,8 +209,8 @@
"URI");
uri = ECRS_stringToUri(fstring);
if ( (NULL == uri) ||
- (! (ECRS_isLocationURI(uri) ||
- ECRS_isFileURI(uri)) ) ) {
+ (! (ECRS_isLocationUri(uri) ||
+ ECRS_isFileUri(uri)) ) ) {
LOG(LOG_ERROR,
_("URI '%s' invalid for gnunet-download.\n"),
fstring);
Modified: GNUnet/src/include/gnunet_ecrs_lib.h
===================================================================
--- GNUnet/src/include/gnunet_ecrs_lib.h 2005-05-22 13:46:59 UTC (rev
804)
+++ GNUnet/src/include/gnunet_ecrs_lib.h 2005-05-24 11:16:42 UTC (rev
805)
@@ -266,7 +266,7 @@
/**
* Is this a namespace URI?
*/
-int ECRS_isNamespaceURI(const struct ECRS_URI * uri);
+int ECRS_isNamespaceUri(const struct ECRS_URI * uri);
/**
* Get the (globally unique) name for the given
@@ -287,12 +287,12 @@
/**
* Is this a keyword URI?
*/
-int ECRS_isKeywordURI(const struct ECRS_URI * uri);
+int ECRS_isKeywordUri(const struct ECRS_URI * uri);
/**
* Is this a file (or directory) URI?
*/
-int ECRS_isFileURI(const struct ECRS_URI * uri);
+int ECRS_isFileUri(const struct ECRS_URI * uri);
/**
* What is the size of the file that this URI
@@ -303,7 +303,7 @@
/**
* Is this a location URI? (DHT specific!)
*/
-int ECRS_isLocationURI(const struct ECRS_URI * uri);
+int ECRS_isLocationUri(const struct ECRS_URI * uri);
/**
* Construct a keyword-URI from meta-data (take all entries
Modified: GNUnet/todo
===================================================================
--- GNUnet/todo 2005-05-22 13:46:59 UTC (rev 804)
+++ GNUnet/todo 2005-05-24 11:16:42 UTC (rev 805)
@@ -1,10 +1,11 @@
0.7.0 [6'05?] (aka "compatibility? what's that?"):
-- Features removed but to be revived:
- * gnunet-gtk: glade II -- control!
- Missing Features:
* resolve "FIXME 0.7"
* fsui core (persistence) [ difficult ]
- * #593 (gnunet-setup): php-ification for i18n, curses wizard; template path
adjustment for non gconf setup
+ - some error handling
+ - actual starting of download/search threads
+ * #593 (gnunet-setup): php-ification for i18n, curses wizard;
+ template path adjustment for non gconf setup
* #770? (use freedback (LOG) in gnunet-gtk via show-messages)
- Additional (automated, make check-style) testing:
* gnunet-tracekit
@@ -45,44 +46,3 @@
- #603 (libgcrypt problem)
-
-
-
-gnunet-gtk wishlist (unallocated tasks unless mentioned
-otherwise, feel free to implement):
-
-- while (!) downloading directory, display already received results
- for download (now supported by libecrs!)
-- add option to list all indexed files and perhaps delete from them
- (ECRS now supports listing of indexed files!)
-- for potentially long clists, add option to specify a string
- pattern that must be matched for the lines to be displayed
- (to further prune search results, for example)
-- implement search bookmarking (e.g. user could add/edit/delete
- favourite namespace/key etc combinations)
-- in Assemble Directory's Files Available/Selected
- Add sortability
- Add multiselection
- Print filenames as well
-- add right button popup menu operations for
- Select by pattern
- in the search result list.
-- a completely new interactive namespace/directory building
- module that would allow importing files/directories from
- disk and edit various parameters, file descriptions and
- the dir tree structure before the insertion.
-- give user opportunity to change namespace rating after
- namespace download succeeded
-
---------------------------
-
-Igor's check-up list for a release version:
-a) works out of the box on a fresh setup
- connects to the network
-b) local search
- nonlocal search
- local download
- nonlocal download
- insert
- gnunet-update
- GUI search, insert, download
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r805 - in GNUnet: . doc m4 src/applications/fs/ecrs src/applications/fs/fsui src/applications/fs/tools src/include,
grothoff <=