diff options
author | Christian Grothoff <christian@grothoff.org> | 2012-06-17 11:07:33 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2012-06-17 11:07:33 +0000 |
commit | 685d9d7c3791b897cf7b0ec1366a062b26f05a21 (patch) | |
tree | 616c089b1dbf26bbe62da36df0f9706c14b125e8 /src/fs/gnunet-auto-share.c | |
parent | c9f35cfcad1112803a3b09ce5530a2d7752115ee (diff) | |
download | gnunet-685d9d7c3791b897cf7b0ec1366a062b26f05a21.tar.gz gnunet-685d9d7c3791b897cf7b0ec1366a062b26f05a21.zip |
-starting harness for gnunet-auto-share:
Diffstat (limited to 'src/fs/gnunet-auto-share.c')
-rw-r--r-- | src/fs/gnunet-auto-share.c | 129 |
1 files changed, 129 insertions, 0 deletions
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 | |||
29 | static int ret; | ||
30 | |||
31 | static int verbose; | ||
32 | |||
33 | static const struct GNUNET_CONFIGURATION_Handle *cfg; | ||
34 | |||
35 | static int disable_extractor; | ||
36 | |||
37 | static int do_disable_creation_time; | ||
38 | |||
39 | static GNUNET_SCHEDULER_TaskIdentifier kill_task; | ||
40 | |||
41 | static unsigned int anonymity_level = 1; | ||
42 | |||
43 | static unsigned int content_priority = 365; | ||
44 | |||
45 | static unsigned int replication_level = 1; | ||
46 | |||
47 | |||
48 | /** | ||
49 | * FIXME: docu | ||
50 | */ | ||
51 | static void | ||
52 | do_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 | */ | ||
68 | static void | ||
69 | run (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 | */ | ||
95 | int | ||
96 | main (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 */ | ||