make clang static analysis happy
[oweals/gnunet.git] / src / fs / fs.c
1 /*
2      This file is part of GNUnet.
3      (C) 2001, 2002, 2003, 2004, 2005, 2006, 2008, 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 /**
22  * @file fs/fs.c
23  * @brief main FS functions
24  * @author Christian Grothoff
25  */
26
27 #include "platform.h"
28 #include "gnunet_fs_service.h"
29 #include "fs.h"
30
31
32 /**
33  * Setup a connection to the file-sharing service.
34  *
35  * @param sched scheduler to use
36  * @param cfg configuration to use
37  * @param client_name unique identifier for this client 
38  * @param upcb function to call to notify about FS actions
39  * @param upcb_cls closure for upcb
40  * @param flags specific attributes for fs-operations
41  * @param ... list of optional options, terminated with GNUNET_FS_OPTIONS_END
42  * @return NULL on error
43  */
44 struct GNUNET_FS_Handle *
45 GNUNET_FS_start (struct GNUNET_SCHEDULER_Handle *sched,
46                  const struct GNUNET_CONFIGURATION_Handle *cfg,
47                  const char *client_name,
48                  GNUNET_FS_ProgressCallback upcb,
49                  void *upcb_cls,
50                  enum GNUNET_FS_Flags flags,
51                  ...)
52 {
53   struct GNUNET_FS_Handle *ret;
54   struct GNUNET_CLIENT_Connection *client;
55   
56   client = GNUNET_CLIENT_connect (sched,
57                                   "fs",
58                                   cfg);
59   if (NULL == client)
60     return NULL;
61   ret = GNUNET_malloc (sizeof (struct GNUNET_FS_Handle));
62   ret->sched = sched;
63   ret->cfg = cfg;
64   ret->client_name = GNUNET_strdup (client_name);
65   ret->upcb = upcb;
66   ret->upcb_cls = upcb_cls;
67   ret->client = client;
68   ret->flags = flags;
69   // FIXME: process varargs!
70   // FIXME: setup receive-loop with client
71
72   // FIXME: deserialize state; use client-name to find master-directory!
73   // Deserialize-Upload:
74   // * read FNs for upload FIs, deserialize each
75   // Deserialize Search:
76   // * read search queries
77   // * for each query, read file with search results
78   // * for each search result with active download, deserialize download
79   // * for each directory search result, check for active downloads of contents
80   // Deserialize Download:
81   // * always part of search???
82   // Deserialize Unindex:
83   // * read FNs for unindex with progress offset
84   return ret;
85 }
86
87
88 /**
89  * Close our connection with the file-sharing service.
90  * The callback given to GNUNET_FS_start will no longer be
91  * called after this function returns.
92  *
93  * @param h handle that was returned from GNUNET_FS_start
94  */                    
95 void 
96 GNUNET_FS_stop (struct GNUNET_FS_Handle *h)
97 {
98   // FIXME: serialize state!? (or is it always serialized???)
99   // FIXME: terminate receive-loop with client  
100   GNUNET_CLIENT_disconnect (h->client, GNUNET_NO);
101   GNUNET_free (h->client_name);
102   GNUNET_free (h);
103 }
104
105
106 /* end of fs.c */