aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2009-09-05 21:54:42 +0000
committerChristian Grothoff <christian@grothoff.org>2009-09-05 21:54:42 +0000
commit593ccab46356928ca9a4538b5ccf7d9fd1704b85 (patch)
treed9fd8ae7fb2fcb4dcf87a0526db756f5a7f59084 /src
parent40b39eeabe0f8301cc7410c9b54f82dd46c48cbb (diff)
downloadgnunet-593ccab46356928ca9a4538b5ccf7d9fd1704b85.tar.gz
gnunet-593ccab46356928ca9a4538b5ccf7d9fd1704b85.zip
work on fs binaries
Diffstat (limited to 'src')
-rw-r--r--src/fs/Makefile.am30
-rw-r--r--src/fs/gnunet-download.c134
-rw-r--r--src/fs/gnunet-search.c134
-rw-r--r--src/fs/gnunet-unindex.c138
4 files changed, 432 insertions, 4 deletions
diff --git a/src/fs/Makefile.am b/src/fs/Makefile.am
index d4da86e6d..0948b349f 100644
--- a/src/fs/Makefile.am
+++ b/src/fs/Makefile.am
@@ -39,12 +39,12 @@ libgnunetfs_la_LDFLAGS = \
39 39
40 40
41bin_PROGRAMS = \ 41bin_PROGRAMS = \
42 gnunet-publish 42 gnunet-download \
43 gnunet-publish \
44 gnunet-search \
45 gnunet-unindex
43# gnunet-directory 46# gnunet-directory
44# gnunet-download
45# gnunet-pseudonym 47# gnunet-pseudonym
46# gnunet-search
47# gnunet-unindex
48 48
49#gnunet_directory_SOURCES = 49#gnunet_directory_SOURCES =
50# gnunet-directory.c 50# gnunet-directory.c
@@ -53,6 +53,12 @@ bin_PROGRAMS = \
53# $(top_builddir)/src/util/libgnunetutil.la 53# $(top_builddir)/src/util/libgnunetutil.la
54# $(GN_LIBINTL) 54# $(GN_LIBINTL)
55 55
56gnunet_download_SOURCES = \
57 gnunet-download.c
58gnunet_download_LDADD = \
59 $(top_builddir)/src/fs/libgnunetfs.la \
60 $(top_builddir)/src/util/libgnunetutil.la \
61 $(GN_LIBINTL)
56 62
57gnunet_publish_SOURCES = \ 63gnunet_publish_SOURCES = \
58 gnunet-publish.c 64 gnunet-publish.c
@@ -61,6 +67,22 @@ gnunet_publish_LDADD = \
61 $(top_builddir)/src/util/libgnunetutil.la \ 67 $(top_builddir)/src/util/libgnunetutil.la \
62 $(GN_LIBINTL) 68 $(GN_LIBINTL)
63 69
70gnunet_search_SOURCES = \
71 gnunet-search.c
72gnunet_search_LDADD = \
73 $(top_builddir)/src/fs/libgnunetfs.la \
74 $(top_builddir)/src/util/libgnunetutil.la \
75 $(GN_LIBINTL)
76
77gnunet_unindex_SOURCES = \
78 gnunet-unindex.c
79gnunet_unindex_LDADD = \
80 $(top_builddir)/src/fs/libgnunetfs.la \
81 $(top_builddir)/src/util/libgnunetutil.la \
82 $(GN_LIBINTL)
83
84
85
64 86
65check_PROGRAMS = \ 87check_PROGRAMS = \
66 test_fs_collection \ 88 test_fs_collection \
diff --git a/src/fs/gnunet-download.c b/src/fs/gnunet-download.c
new file mode 100644
index 000000000..c6bb7c115
--- /dev/null
+++ b/src/fs/gnunet-download.c
@@ -0,0 +1,134 @@
1/*
2 This file is part of GNUnet.
3 (C) 2001, 2002, 2004, 2005, 2006, 2007, 2009 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 2, 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-download.c
22 * @brief downloading for files on GNUnet
23 * @author Christian Grothoff
24 * @author Krista Bennett
25 * @author James Blackwell
26 * @author Igor Wronsky
27 *
28 * TODO:
29 * - all
30 */
31#include "platform.h"
32#include "gnunet_fs_service.h"
33
34static int ret;
35
36static const struct GNUNET_CONFIGURATION_Handle *cfg;
37
38static struct GNUNET_FS_Handle *ctx;
39
40static struct GNUNET_TIME_Absolute start_time;
41
42static unsigned int anonymity = 1;
43
44
45/**
46 * Called by FS client to give information about the progress of an
47 * operation.
48 *
49 * @param cls closure
50 * @param info details about the event, specifying the event type
51 * and various bits about the event
52 * @return client-context (for the next progress call
53 * for this operation; should be set to NULL for
54 * SUSPEND and STOPPED events). The value returned
55 * will be passed to future callbacks in the respective
56 * field in the GNUNET_FS_ProgressInfo struct.
57 */
58static void *
59progress_cb (void *cls,
60 const struct GNUNET_FS_ProgressInfo *info)
61{
62 return NULL;
63}
64
65
66/**
67 * Main function that will be run by the scheduler.
68 *
69 * @param cls closure
70 * @param sched the scheduler to use
71 * @param args remaining command-line arguments
72 * @param cfgfile name of the configuration file used (for saving, can be NULL!)
73 * @param cfg configuration
74 */
75static void
76run (void *cls,
77 struct GNUNET_SCHEDULER_Handle *sched,
78 char *const *args,
79 const char *cfgfile,
80 const struct GNUNET_CONFIGURATION_Handle *c)
81{
82 /* FIXME: check arguments */
83 cfg = c;
84 ctx = GNUNET_FS_start (sched,
85 cfg,
86 "gnunet-download",
87 &progress_cb,
88 NULL);
89 if (NULL == ctx)
90 {
91 fprintf (stderr,
92 _("Could not initialize `%s' subsystem.\n"),
93 "FS");
94 ret = 1;
95 return;
96 }
97 start_time = GNUNET_TIME_absolute_get ();
98 // FIXME: start download
99}
100
101
102/**
103 * gnunet-download command line options
104 */
105static struct GNUNET_GETOPT_CommandLineOption options[] = {
106 {'a', "anonymity", "LEVEL",
107 gettext_noop ("set the desired LEVEL of receiver-anonymity"),
108 1, &GNUNET_GETOPT_set_uint, &anonymity},
109 // FIXME: options!
110 GNUNET_GETOPT_OPTION_END
111};
112
113
114/**
115 * The main function to download GNUnet.
116 *
117 * @param argc number of arguments from the command line
118 * @param argv command line arguments
119 * @return 0 ok, 1 on error
120 */
121int
122main (int argc, char *const *argv)
123{
124 return (GNUNET_OK ==
125 GNUNET_PROGRAM_run (argc,
126 argv,
127 "gnunet-download",
128 gettext_noop
129 ("Download files from GNUnet."),
130 options, &run, NULL)) ? ret : 1;
131}
132
133/* end of gnunet-download.c */
134
diff --git a/src/fs/gnunet-search.c b/src/fs/gnunet-search.c
new file mode 100644
index 000000000..10a3c82fd
--- /dev/null
+++ b/src/fs/gnunet-search.c
@@ -0,0 +1,134 @@
1/*
2 This file is part of GNUnet.
3 (C) 2001, 2002, 2004, 2005, 2006, 2007, 2009 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 2, 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-search.c
22 * @brief searching for files on GNUnet
23 * @author Christian Grothoff
24 * @author Krista Bennett
25 * @author James Blackwell
26 * @author Igor Wronsky
27 *
28 * TODO:
29 * - all
30 */
31#include "platform.h"
32#include "gnunet_fs_service.h"
33
34static int ret;
35
36static const struct GNUNET_CONFIGURATION_Handle *cfg;
37
38static struct GNUNET_FS_Handle *ctx;
39
40static struct GNUNET_TIME_Absolute start_time;
41
42static unsigned int anonymity = 1;
43
44
45/**
46 * Called by FS client to give information about the progress of an
47 * operation.
48 *
49 * @param cls closure
50 * @param info details about the event, specifying the event type
51 * and various bits about the event
52 * @return client-context (for the next progress call
53 * for this operation; should be set to NULL for
54 * SUSPEND and STOPPED events). The value returned
55 * will be passed to future callbacks in the respective
56 * field in the GNUNET_FS_ProgressInfo struct.
57 */
58static void *
59progress_cb (void *cls,
60 const struct GNUNET_FS_ProgressInfo *info)
61{
62 return NULL;
63}
64
65
66/**
67 * Main function that will be run by the scheduler.
68 *
69 * @param cls closure
70 * @param sched the scheduler to use
71 * @param args remaining command-line arguments
72 * @param cfgfile name of the configuration file used (for saving, can be NULL!)
73 * @param cfg configuration
74 */
75static void
76run (void *cls,
77 struct GNUNET_SCHEDULER_Handle *sched,
78 char *const *args,
79 const char *cfgfile,
80 const struct GNUNET_CONFIGURATION_Handle *c)
81{
82 /* FIXME: check arguments */
83 cfg = c;
84 ctx = GNUNET_FS_start (sched,
85 cfg,
86 "gnunet-search",
87 &progress_cb,
88 NULL);
89 if (NULL == ctx)
90 {
91 fprintf (stderr,
92 _("Could not initialize `%s' subsystem.\n"),
93 "FS");
94 ret = 1;
95 return;
96 }
97 start_time = GNUNET_TIME_absolute_get ();
98 // FIXME: start search
99}
100
101
102/**
103 * gnunet-search command line options
104 */
105static struct GNUNET_GETOPT_CommandLineOption options[] = {
106 {'a', "anonymity", "LEVEL",
107 gettext_noop ("set the desired LEVEL of receiver-anonymity"),
108 1, &GNUNET_GETOPT_set_uint, &anonymity},
109 // FIXME: options!
110 GNUNET_GETOPT_OPTION_END
111};
112
113
114/**
115 * The main function to search GNUnet.
116 *
117 * @param argc number of arguments from the command line
118 * @param argv command line arguments
119 * @return 0 ok, 1 on error
120 */
121int
122main (int argc, char *const *argv)
123{
124 return (GNUNET_OK ==
125 GNUNET_PROGRAM_run (argc,
126 argv,
127 "gnunet-search",
128 gettext_noop
129 ("Search GNUnet."),
130 options, &run, NULL)) ? ret : 1;
131}
132
133/* end of gnunet-search.c */
134
diff --git a/src/fs/gnunet-unindex.c b/src/fs/gnunet-unindex.c
new file mode 100644
index 000000000..2dfef9432
--- /dev/null
+++ b/src/fs/gnunet-unindex.c
@@ -0,0 +1,138 @@
1/*
2 This file is part of GNUnet.
3 (C) 2001, 2002, 2004, 2005, 2006, 2007, 2009 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 2, 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-unindex.c
22 * @brief unindex files published on GNUnet
23 * @author Christian Grothoff
24 * @author Krista Bennett
25 * @author James Blackwell
26 * @author Igor Wronsky
27 *
28 * TODO:
29 * - progress callback
30 * - error checking
31 */
32#include "platform.h"
33#include "gnunet_fs_service.h"
34
35static int ret;
36
37static const struct GNUNET_CONFIGURATION_Handle *cfg;
38
39static struct GNUNET_FS_Handle *ctx;
40
41static struct GNUNET_FS_UnindexContext *uc;
42
43static struct GNUNET_TIME_Absolute start_time;
44
45
46/**
47 * Called by FS client to give information about the progress of an
48 * operation.
49 *
50 * @param cls closure
51 * @param info details about the event, specifying the event type
52 * and various bits about the event
53 * @return client-context (for the next progress call
54 * for this operation; should be set to NULL for
55 * SUSPEND and STOPPED events). The value returned
56 * will be passed to future callbacks in the respective
57 * field in the GNUNET_FS_ProgressInfo struct.
58 */
59static void *
60progress_cb (void *cls,
61 const struct GNUNET_FS_ProgressInfo *info)
62{
63 return NULL;
64}
65
66
67/**
68 * Main function that will be run by the scheduler.
69 *
70 * @param cls closure
71 * @param sched the scheduler to use
72 * @param args remaining command-line arguments
73 * @param cfgfile name of the configuration file used (for saving, can be NULL!)
74 * @param cfg configuration
75 */
76static void
77run (void *cls,
78 struct GNUNET_SCHEDULER_Handle *sched,
79 char *const *args,
80 const char *cfgfile,
81 const struct GNUNET_CONFIGURATION_Handle *c)
82{
83 /* check arguments */
84 if ( (args[0] == NULL) || (args[1] != NULL) )
85 {
86 printf (_
87 ("You must specify one and only one filename for unindexing.\n"));
88 ret = -1;
89 return;
90 }
91 cfg = c;
92 ctx = GNUNET_FS_start (sched,
93 cfg,
94 "gnunet-unindex",
95 &progress_cb,
96 NULL);
97 if (NULL == ctx)
98 {
99 fprintf (stderr,
100 _("Could not initialize `%s' subsystem.\n"),
101 "FS");
102 ret = 1;
103 return;
104 }
105 start_time = GNUNET_TIME_absolute_get ();
106 uc = GNUNET_FS_unindex (ctx,
107 args[0]);
108}
109
110
111/**
112 * gnunet-unindex command line options
113 */
114static struct GNUNET_GETOPT_CommandLineOption options[] = {
115 GNUNET_GETOPT_OPTION_END
116};
117
118
119/**
120 * The main function to unindex content.
121 *
122 * @param argc number of arguments from the command line
123 * @param argv command line arguments
124 * @return 0 ok, 1 on error
125 */
126int
127main (int argc, char *const *argv)
128{
129 return (GNUNET_OK ==
130 GNUNET_PROGRAM_run (argc,
131 argv,
132 "gnunet-unindex",
133 gettext_noop
134 ("Unindex files."),
135 options, &run, NULL)) ? ret : 1;
136}
137
138/* end of gnunet-unindex.c */