aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/fs/Makefile.am10
-rw-r--r--src/fs/gnunet-auto-share.c129
-rw-r--r--src/fs/gnunet-publish.c2
3 files changed, 140 insertions, 1 deletions
diff --git a/src/fs/Makefile.am b/src/fs/Makefile.am
index efe126a2c..dc8698696 100644
--- a/src/fs/Makefile.am
+++ b/src/fs/Makefile.am
@@ -60,6 +60,7 @@ libgnunetfstest_a_LIBADD = \
60 $(top_builddir)/src/testing_old/libgnunettesting_old.la 60 $(top_builddir)/src/testing_old/libgnunettesting_old.la
61 61
62bin_PROGRAMS = \ 62bin_PROGRAMS = \
63 gnunet-auto-share \
63 gnunet-directory \ 64 gnunet-directory \
64 gnunet-download \ 65 gnunet-download \
65 gnunet-publish \ 66 gnunet-publish \
@@ -112,6 +113,15 @@ gnunet_publish_LDADD = \
112gnunet_publish_DEPENDENCIES = \ 113gnunet_publish_DEPENDENCIES = \
113 libgnunetfs.la 114 libgnunetfs.la
114 115
116gnunet_auto_share_SOURCES = \
117 gnunet-auto-share.c
118gnunet_auto_share_LDADD = \
119 $(top_builddir)/src/util/libgnunetutil.la \
120 -lextractor \
121 $(GN_LIBINTL)
122gnunet_auto_share_DEPENDENCIES = \
123 libgnunetfs.la
124
115gnunet_helper_fs_publish_SOURCES = \ 125gnunet_helper_fs_publish_SOURCES = \
116 gnunet-helper-fs-publish.c 126 gnunet-helper-fs-publish.c
117gnunet_helper_fs_publish_LDADD = \ 127gnunet_helper_fs_publish_LDADD = \
diff --git a/src/fs/gnunet-auto-share.c b/src/fs/gnunet-auto-share.c
new file mode 100644
index 000000000..e076d8b31
--- /dev/null
+++ b/src/fs/gnunet-auto-share.c
@@ -0,0 +1,129 @@
1/*
2 This file is part of GNUnet.
3 (C) 2001--2012 Christian Grothoff (and other contributing authors)
4
5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published
7 by the Free Software Foundation; either version 3, or (at your
8 option) any later version.
9
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with GNUnet; see the file COPYING. If not, write to the
17 Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA.
19*/
20/**
21 * @file fs/gnunet-auto-share.c
22 * @brief automatically publish files on GNUnet
23 * @author Christian Grothoff
24 */
25#include "platform.h"
26#include "gnunet_util_lib.h"
27
28
29static int ret;
30
31static int verbose;
32
33static const struct GNUNET_CONFIGURATION_Handle *cfg;
34
35static int disable_extractor;
36
37static int do_disable_creation_time;
38
39static GNUNET_SCHEDULER_TaskIdentifier kill_task;
40
41static unsigned int anonymity_level = 1;
42
43static unsigned int content_priority = 365;
44
45static unsigned int replication_level = 1;
46
47
48/**
49 * FIXME: docu
50 */
51static void
52do_stop_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
53{
54 kill_task = GNUNET_SCHEDULER_NO_TASK;
55}
56
57
58
59
60/**
61 * Main function that will be run by the scheduler.
62 *
63 * @param cls closure
64 * @param args remaining command-line arguments
65 * @param cfgfile name of the configuration file used (for saving, can be NULL!)
66 * @param c configuration
67 */
68static void
69run (void *cls, char *const *args, const char *cfgfile,
70 const struct GNUNET_CONFIGURATION_Handle *c)
71{
72 /* check arguments */
73 if ((args[0] == NULL) || (args[1] != NULL) ||
74 (GNUNET_YES != GNUNET_DISK_directory_test (args[0])))
75 {
76 printf (_("You must specify one and only one directory name for automatic publication.\n"));
77 ret = -1;
78 return;
79 }
80 cfg = c;
81 // FIXME...
82 kill_task =
83 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &do_stop_task,
84 NULL);
85}
86
87
88/**
89 * The main function to automatically publish content to GNUnet.
90 *
91 * @param argc number of arguments from the command line
92 * @param argv command line arguments
93 * @return 0 ok, 1 on error
94 */
95int
96main (int argc, char *const *argv)
97{
98 static const struct GNUNET_GETOPT_CommandLineOption options[] = {
99 {'a', "anonymity", "LEVEL",
100 gettext_noop ("set the desired LEVEL of sender-anonymity"),
101 1, &GNUNET_GETOPT_set_uint, &anonymity_level},
102 {'d', "disable-creation-time", NULL,
103 gettext_noop
104 ("disable adding the creation time to the metadata of the uploaded file"),
105 0, &GNUNET_GETOPT_set_one, &do_disable_creation_time},
106 {'D', "disable-extractor", NULL,
107 gettext_noop ("do not use libextractor to add keywords or metadata"),
108 0, &GNUNET_GETOPT_set_one, &disable_extractor},
109 {'p', "priority", "PRIORITY",
110 gettext_noop ("specify the priority of the content"),
111 1, &GNUNET_GETOPT_set_uint, &content_priority},
112 {'r', "replication", "LEVEL",
113 gettext_noop ("set the desired replication LEVEL"),
114 1, &GNUNET_GETOPT_set_uint, &replication_level},
115 {'V', "verbose", NULL,
116 gettext_noop ("be verbose (print progress information)"),
117 0, &GNUNET_GETOPT_set_one, &verbose},
118 GNUNET_GETOPT_OPTION_END
119 };
120 if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv))
121 return 2;
122 return (GNUNET_OK ==
123 GNUNET_PROGRAM_run (argc, argv, "gnunet-auto-share [OPTIONS] FILENAME",
124 gettext_noop
125 ("Automatically publish files from a directory on GNUnet"),
126 options, &run, NULL)) ? ret : 1;
127}
128
129/* end of gnunet-auto-share.c */
diff --git a/src/fs/gnunet-publish.c b/src/fs/gnunet-publish.c
index 4b13a16bd..ef48f2d92 100644
--- a/src/fs/gnunet-publish.c
+++ b/src/fs/gnunet-publish.c
@@ -732,7 +732,7 @@ main (int argc, char *const *argv)
732 0, &GNUNET_GETOPT_set_one, &verbose}, 732 0, &GNUNET_GETOPT_set_one, &verbose},
733 GNUNET_GETOPT_OPTION_END 733 GNUNET_GETOPT_OPTION_END
734 }; 734 };
735 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 735 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
736 "GNUnet publish starts\n"); 736 "GNUnet publish starts\n");
737 bo.expiration_time = 737 bo.expiration_time =
738 GNUNET_FS_year_to_time (GNUNET_FS_get_current_year () + 2); 738 GNUNET_FS_year_to_time (GNUNET_FS_get_current_year () + 2);