gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r8963 - in gnunet: . src/fs src/hostlist src/include


From: gnunet
Subject: [GNUnet-SVN] r8963 - in gnunet: . src/fs src/hostlist src/include
Date: Mon, 7 Sep 2009 14:00:19 -0600

Author: grothoff
Date: 2009-09-07 14:00:18 -0600 (Mon, 07 Sep 2009)
New Revision: 8963

Added:
   gnunet/src/fs/gnunet-directory.c
   gnunet/src/fs/gnunet-pseudonym.c
   gnunet/src/fs/gnunet-service-fs.c
Modified:
   gnunet/TODO
   gnunet/src/fs/
   gnunet/src/fs/Makefile.am
   gnunet/src/hostlist/
   gnunet/src/include/gnunet_fs_service.h
Log:
prep work

Modified: gnunet/TODO
===================================================================
--- gnunet/TODO 2009-09-07 14:23:23 UTC (rev 8962)
+++ gnunet/TODO 2009-09-07 20:00:18 UTC (rev 8963)
@@ -78,7 +78,9 @@
     + gnunet-publish (URI args)
     + gnunet-download (directory)
     + gnunet-search (options, incl. namespace search)
-    - gnunet-download (many options)
+    + gnunet-download (many options)
+    + gnunet-directory (man page, options)
+    + gnunet-pseudonym (all of it)
   - implement adv. FS testcases 
     + insert: sblocks, loc uris
     + download: loc uris


Property changes on: gnunet/src/fs
___________________________________________________________________
Modified: svn:ignore
   - gnunet-unindex
gnunet-search
gnunet-download
gnunet-publish
Makefile.in
Makefile
.deps

   + gnunet-service-fs
gnunet-pseudonym
gnunet-directory
gnunet-unindex
gnunet-search
gnunet-download
gnunet-publish
Makefile.in
Makefile
.deps


Modified: gnunet/src/fs/Makefile.am
===================================================================
--- gnunet/src/fs/Makefile.am   2009-09-07 14:23:23 UTC (rev 8962)
+++ gnunet/src/fs/Makefile.am   2009-09-07 20:00:18 UTC (rev 8963)
@@ -39,19 +39,20 @@
 
 
 bin_PROGRAMS = \
+  gnunet-directory \
   gnunet-download \
   gnunet-publish \
+  gnunet-pseudonym \
   gnunet-search \
+  gnunet-service-fs \
   gnunet-unindex 
-# gnunet-directory 
-# gnunet-pseudonym 
 
-#gnunet_directory_SOURCES = 
-# gnunet-directory.c         
-#gnunet_directory_LDADD = 
-#  $(top_builddir)/src/fs/libgnunetfs.la 
-#  $(top_builddir)/src/util/libgnunetutil.la 
-#  $(GN_LIBINTL)
+gnunet_directory_SOURCES = \
+ gnunet-directory.c
+gnunet_directory_LDADD = \
+  $(top_builddir)/src/fs/libgnunetfs.la \
+  $(top_builddir)/src/util/libgnunetutil.la \
+  $(GN_LIBINTL)
 
 gnunet_download_SOURCES =  \
  gnunet-download.c         
@@ -67,6 +68,13 @@
  $(top_builddir)/src/util/libgnunetutil.la \
  $(GN_LIBINTL)
 
+gnunet_pseudonym_SOURCES = \
+ gnunet-pseudonym.c
+gnunet_pseudonym_LDADD = \
+  $(top_builddir)/src/fs/libgnunetfs.la \
+  $(top_builddir)/src/util/libgnunetutil.la \
+  $(GN_LIBINTL)
+
 gnunet_search_SOURCES = \
  gnunet-search.c         
 gnunet_search_LDADD = \
@@ -74,6 +82,15 @@
   $(top_builddir)/src/util/libgnunetutil.la \
   $(GN_LIBINTL)
 
+gnunet_service_fs_SOURCES =  \
+ gnunet-service-fs.c         
+gnunet_service_fs_LDADD =  \
+ $(top_builddir)/src/fs/libgnunetfs.la \
+ $(top_builddir)/src/datastore/libgnunetdatastore.la \
+ $(top_builddir)/src/core/libgnunetcore.la \
+ $(top_builddir)/src/util/libgnunetutil.la \
+ $(GN_LIBINTL)
+
 gnunet_unindex_SOURCES = \
  gnunet-unindex.c         
 gnunet_unindex_LDADD = \

Added: gnunet/src/fs/gnunet-directory.c
===================================================================
--- gnunet/src/fs/gnunet-directory.c                            (rev 0)
+++ gnunet/src/fs/gnunet-directory.c    2009-09-07 20:00:18 UTC (rev 8963)
@@ -0,0 +1,167 @@
+/*
+     This file is part of GNUnet.
+     (C) 2001, 2002, 2004, 2005, 2006, 2007, 2009 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
+     by the Free Software Foundation; either version 2, or (at your
+     option) any later version.
+
+     GNUnet is distributed in the hope that it will be useful, but
+     WITHOUT ANY WARRANTY; without even the implied warranty of
+     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+     General Public License for more details.
+
+     You should have received a copy of the GNU General Public License
+     along with GNUnet; see the file COPYING.  If not, write to the
+     Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+     Boston, MA 02111-1307, USA.
+*/
+/**
+ * @file fs/gnunet-directory.c
+ * @brief display content of GNUnet directories
+ * @author Christian Grothoff
+ */
+#include "platform.h"
+#include "gnunet_fs_service.h"
+
+static int ret;
+
+/**
+ * Print a meta data entry.
+ */
+static int
+item_printer (void *cls,
+             EXTRACTOR_KeywordType type, 
+             const char *data)
+{
+  printf ("\t%20s: %s\n",
+          dgettext (LIBEXTRACTOR_GETTEXT_DOMAIN,
+                    EXTRACTOR_getKeywordTypeAsString (type)), data);
+  return GNUNET_OK;
+}
+
+
+
+/**
+ * Print an entry in a directory.
+ *
+ * @param cls closure (not used)
+ * @param filename name of the file in the directory
+ * @param uri URI of the file
+ * @param metadata metadata for the file; metadata for
+ *        the directory if everything else is NULL/zero
+ * @param length length of the available data for the file
+ *           (of type size_t since data must certainly fit
+ *            into memory; if files are larger than size_t
+ *            permits, then they will certainly not be
+ *            embedded with the directory itself).
+ * @param data data available for the file (length bytes)
+ */
+static void
+print_entry (void *cls,
+            const char *filename,
+            const struct GNUNET_FS_Uri *uri,
+            const struct GNUNET_CONTAINER_MetaData *meta,
+            size_t length,
+            const void *data)
+{
+  char *string;
+
+  string = GNUNET_FS_uri_to_string (uri);
+  printf ("%s:\n", string);
+  GNUNET_free (string);
+  GNUNET_CONTAINER_meta_data_get_contents (meta,
+                                          &item_printer,
+                                          NULL);
+}
+
+
+/**
+ * Main function that will be run by the scheduler.
+ *
+ * @param cls closure
+ * @param sched the scheduler to use
+ * @param args remaining command-line arguments
+ * @param cfgfile name of the configuration file used (for saving, can be 
NULL!)
+ * @param cfg configuration
+ */
+static void
+run (void *cls,
+     struct GNUNET_SCHEDULER_Handle *sched,
+     char *const *args,
+     const char *cfgfile,
+     const struct GNUNET_CONFIGURATION_Handle *cfg)
+{
+  struct GNUNET_DISK_MapHandle *map;
+  struct GNUNET_DISK_FileHandle *h;
+  void *data;
+  size_t len;
+  uint64_t size;
+  const char *filename = args[0];
+
+  if (NULL == filename)
+    {
+      fprintf (stderr,
+              _("You must specify a filename to inspect."));
+      ret = 1;
+      return;
+    }
+  if ( (GNUNET_OK !=
+       GNUNET_DISK_file_size (filename,
+                              &size,
+                              GNUNET_YES)) ||
+       (NULL == (h = GNUNET_DISK_file_open (filename,
+                                           GNUNET_DISK_OPEN_READ))) )
+    {
+      GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+                 _("Failed to read directory `%s'\n"),
+                 filename);
+      ret = 1;
+      return;
+    }
+  len = (size_t) size;
+  data = GNUNET_DISK_file_map (h,
+                              &map,
+                              GNUNET_DISK_MAP_READ,
+                              len);
+  GNUNET_assert (NULL != data);
+  GNUNET_FS_directory_list_contents (len,
+                                    data,
+                                    0, 
+                                    &print_entry,
+                                    NULL);
+  GNUNET_DISK_file_unmap (map);
+  GNUNET_DISK_file_close (h);
+}
+
+
+/**
+ * gnunet-directory command line options
+ */
+static struct GNUNET_GETOPT_CommandLineOption options[] = {
+  // FIXME: options!
+  GNUNET_GETOPT_OPTION_END
+};
+
+
+/**
+ * The main function to inspect GNUnet directories.
+ *
+ * @param argc number of arguments from the command line
+ * @param argv command line arguments
+ * @return 0 ok, 1 on error
+ */
+int
+main (int argc, char *const *argv)
+{
+  return (GNUNET_OK ==
+          GNUNET_PROGRAM_run (argc,
+                              argv,
+                              "gnunet-directory",
+                              gettext_noop
+                              ("Display GNUnet directories."),
+                              options, &run, NULL)) ? ret : 1;
+}
+
+/* end of gnunet-directory.c */

Added: gnunet/src/fs/gnunet-pseudonym.c
===================================================================
--- gnunet/src/fs/gnunet-pseudonym.c                            (rev 0)
+++ gnunet/src/fs/gnunet-pseudonym.c    2009-09-07 20:00:18 UTC (rev 8963)
@@ -0,0 +1,78 @@
+/*
+     This file is part of GNUnet.
+     (C) 2001, 2002, 2004, 2005, 2006, 2007, 2009 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
+     by the Free Software Foundation; either version 2, or (at your
+     option) any later version.
+
+     GNUnet is distributed in the hope that it will be useful, but
+     WITHOUT ANY WARRANTY; without even the implied warranty of
+     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+     General Public License for more details.
+
+     You should have received a copy of the GNU General Public License
+     along with GNUnet; see the file COPYING.  If not, write to the
+     Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+     Boston, MA 02111-1307, USA.
+*/
+/**
+ * @file fs/gnunet-pseudonym.c
+ * @brief manage GNUnet namespaces / pseudonyms
+ * @author Christian Grothoff
+ */
+#include "platform.h"
+#include "gnunet_fs_service.h"
+
+static int ret;
+
+/**
+ * Main function that will be run by the scheduler.
+ *
+ * @param cls closure
+ * @param sched the scheduler to use
+ * @param args remaining command-line arguments
+ * @param cfgfile name of the configuration file used (for saving, can be 
NULL!)
+ * @param cfg configuration
+ */
+static void
+run (void *cls,
+     struct GNUNET_SCHEDULER_Handle *sched,
+     char *const *args,
+     const char *cfgfile,
+     const struct GNUNET_CONFIGURATION_Handle *cfg)
+{
+  // FIXME
+}
+
+
+/**
+ * gnunet-pseudonym command line options
+ */
+static struct GNUNET_GETOPT_CommandLineOption options[] = {
+  // FIXME: options!
+  GNUNET_GETOPT_OPTION_END
+};
+
+
+/**
+ * The main function to inspect GNUnet directories.
+ *
+ * @param argc number of arguments from the command line
+ * @param argv command line arguments
+ * @return 0 ok, 1 on error
+ */
+int
+main (int argc, char *const *argv)
+{
+  return (GNUNET_OK ==
+          GNUNET_PROGRAM_run (argc,
+                              argv,
+                              "gnunet-pseudonym",
+                              gettext_noop
+                              ("Manage GNUnet pseudonyms."),
+                              options, &run, NULL)) ? ret : 1;
+}
+
+/* end of gnunet-pseudonym.c */

Added: gnunet/src/fs/gnunet-service-fs.c
===================================================================
--- gnunet/src/fs/gnunet-service-fs.c                           (rev 0)
+++ gnunet/src/fs/gnunet-service-fs.c   2009-09-07 20:00:18 UTC (rev 8963)
@@ -0,0 +1,100 @@
+/*
+     This file is part of GNUnet.
+     (C) 2009 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
+     by the Free Software Foundation; either version 2, or (at your
+     option) any later version.
+
+     GNUnet is distributed in the hope that it will be useful, but
+     WITHOUT ANY WARRANTY; without even the implied warranty of
+     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+     General Public License for more details.
+
+     You should have received a copy of the GNU General Public License
+     along with GNUnet; see the file COPYING.  If not, write to the
+     Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+     Boston, MA 02111-1307, USA.
+*/
+
+/**
+ * @file statistics/gnunet-service-fs.c
+ * @brief program that provides the file-sharing service
+ * @author Christian Grothoff
+ */
+#include "platform.h"
+#include "gnunet_protocols.h"
+#include "gnunet_core_service.h"
+#include "gnunet_datastore_service.h"
+#include "gnunet_util_lib.h"
+#include "fs.h"
+
+
+
+/**
+ * Handle GET-message.
+ *
+ * @param cls closure
+ * @param client identification of the client
+ * @param message the actual message
+ * @return GNUNET_OK to keep the connection open,
+ *         GNUNET_SYSERR to close it (signal serious error)
+ */
+static void
+handle_xxx (void *cls,
+            struct GNUNET_SERVER_Client *client,
+            const struct GNUNET_MessageHeader *message)
+{
+}
+
+
+/**
+ * List of handlers for the messages understood by this
+ * service.
+ */
+static struct GNUNET_SERVER_MessageHandler handlers[] = {
+  {&handle_xxx, NULL, GNUNET_MESSAGE_TYPE_FS_INDEX_START, 0},
+  {&handle_xxx, NULL, GNUNET_MESSAGE_TYPE_FS_INDEX_LIST_GET, 0},
+  {&handle_xxx, NULL, GNUNET_MESSAGE_TYPE_FS_UNINDEX, 0},
+  {&handle_xxx, NULL, GNUNET_MESSAGE_TYPE_FS_START_SEARCH, 0},
+  {NULL, NULL, 0, 0}
+};
+
+
+/**
+ * Process fs requests.
+ *
+ * @param cls closure
+ * @param sched scheduler to use
+ * @param server the initialized server
+ * @param cfg configuration to use
+ */
+static void
+run (void *cls,
+     struct GNUNET_SCHEDULER_Handle *sched,
+     struct GNUNET_SERVER_Handle *server,
+     const struct GNUNET_CONFIGURATION_Handle *cfg)
+{
+  GNUNET_SERVER_add_handlers (server, handlers);
+  // FIXME: also handle P2P messages!
+}
+
+
+/**
+ * The main function for the fs service.
+ *
+ * @param argc number of arguments from the command line
+ * @param argv command line arguments
+ * @return 0 ok, 1 on error
+ */
+int
+main (int argc, char *const *argv)
+{
+  return (GNUNET_OK ==
+          GNUNET_SERVICE_run (argc,
+                              argv,
+                              "fs", &run, NULL, NULL, NULL)) ? 0 : 1;
+}
+
+/* end of gnunet-service-fs.c */


Property changes on: gnunet/src/hostlist
___________________________________________________________________
Modified: svn:ignore
   - test_gnunet_daemon_hostlist.gcno
gnunet_daemon_hostlist-hostlist-server.gcno
gnunet_daemon_hostlist-hostlist-client.gcno
gnunet_daemon_hostlist-gnunet-daemon-hostlist.gcno
gnunet-daemon-hostlist
Makefile.in
Makefile
.deps

   + test_gnunet_daemon_hostlist
test_gnunet_daemon_hostlist.gcno
gnunet_daemon_hostlist-hostlist-server.gcno
gnunet_daemon_hostlist-hostlist-client.gcno
gnunet_daemon_hostlist-gnunet-daemon-hostlist.gcno
gnunet-daemon-hostlist
Makefile.in
Makefile
.deps


Modified: gnunet/src/include/gnunet_fs_service.h
===================================================================
--- gnunet/src/include/gnunet_fs_service.h      2009-09-07 14:23:23 UTC (rev 
8962)
+++ gnunet/src/include/gnunet_fs_service.h      2009-09-07 20:00:18 UTC (rev 
8963)
@@ -117,6 +117,7 @@
 char *
 GNUNET_FS_uri_ksk_to_string_fancy (const struct GNUNET_FS_Uri *uri);
 
+
 /**
  * Convert a UTF-8 String to a URI.
  *





reply via email to

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