work on fs binaries
[oweals/gnunet.git] / src / fs / gnunet-search.c
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
34 static int ret;
35
36 static const struct GNUNET_CONFIGURATION_Handle *cfg;
37
38 static struct GNUNET_FS_Handle *ctx;
39
40 static struct GNUNET_TIME_Absolute start_time;
41
42 static 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  */
58 static void *
59 progress_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  */
75 static void
76 run (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  */
105 static 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  */
121 int
122 main (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