diff options
-rw-r--r-- | src/fs/Makefile.am | 3 | ||||
-rw-r--r-- | src/fs/fs.h | 75 | ||||
-rw-r--r-- | src/fs/fs_download.c | 75 | ||||
-rw-r--r-- | src/fs/fs_publish.c | 89 | ||||
-rw-r--r-- | src/fs/fs_search.c | 69 | ||||
-rw-r--r-- | src/fs/fs_unindex.c | 61 | ||||
-rw-r--r-- | src/fs/test_fs.c (renamed from src/fs/fs_test.c) | 0 | ||||
-rw-r--r-- | src/include/gnunet_fs_service.h | 10 |
8 files changed, 348 insertions, 34 deletions
diff --git a/src/fs/Makefile.am b/src/fs/Makefile.am index db9567fb1..5aca42ac2 100644 --- a/src/fs/Makefile.am +++ b/src/fs/Makefile.am | |||
@@ -16,10 +16,13 @@ libgnunetfs_la_SOURCES = \ | |||
16 | fs.c \ | 16 | fs.c \ |
17 | fs_collection.c \ | 17 | fs_collection.c \ |
18 | fs_directory.c \ | 18 | fs_directory.c \ |
19 | fs_download.c \ | ||
19 | fs_file_information.c \ | 20 | fs_file_information.c \ |
20 | fs_getopt.c \ | 21 | fs_getopt.c \ |
21 | fs_publish.c \ | 22 | fs_publish.c \ |
22 | fs_namespace.c \ | 23 | fs_namespace.c \ |
24 | fs_search.c \ | ||
25 | fs_unindex.c \ | ||
23 | fs_uri.c | 26 | fs_uri.c |
24 | 27 | ||
25 | libgnunetfs_la_LIBADD = \ | 28 | libgnunetfs_la_LIBADD = \ |
diff --git a/src/fs/fs.h b/src/fs/fs.h index 1a8a6b0f7..4743a594b 100644 --- a/src/fs/fs.h +++ b/src/fs/fs.h | |||
@@ -318,4 +318,79 @@ struct GNUNET_FS_Handle | |||
318 | }; | 318 | }; |
319 | 319 | ||
320 | 320 | ||
321 | /** | ||
322 | * Handle for controlling an upload. | ||
323 | */ | ||
324 | struct GNUNET_FS_PublishContext | ||
325 | { | ||
326 | /** | ||
327 | * Handle to the global fs context. | ||
328 | */ | ||
329 | struct GNUNET_FS_Handle *h; | ||
330 | |||
331 | /** | ||
332 | * Argument to pass to the client in callbacks. | ||
333 | */ | ||
334 | void *client_ctx; | ||
335 | |||
336 | /** | ||
337 | * File-structure that is being shared. | ||
338 | */ | ||
339 | struct GNUNET_FS_FileInformation *fi; | ||
340 | |||
341 | /** | ||
342 | * Namespace that we are publishing in, NULL if we have no namespace. | ||
343 | */ | ||
344 | struct GNUNET_FS_Namespace *namespace; | ||
345 | |||
346 | /** | ||
347 | * ID of the content in the namespace, NULL if we have no namespace. | ||
348 | */ | ||
349 | char *nid; | ||
350 | |||
351 | /** | ||
352 | * ID for future updates, NULL if we have no namespace or no updates. | ||
353 | */ | ||
354 | char *nuid; | ||
355 | |||
356 | /** | ||
357 | * ID of the task performing the upload. NO_TASK | ||
358 | * if the upload has completed. | ||
359 | */ | ||
360 | GNUNET_SCHEDULER_TaskIdentifier upload_task; | ||
361 | }; | ||
362 | |||
363 | |||
364 | /** | ||
365 | * Handle for controlling an unindexing operation. | ||
366 | */ | ||
367 | struct GNUNET_FS_UnindexContext | ||
368 | { | ||
369 | }; | ||
370 | |||
371 | |||
372 | /** | ||
373 | * Handle for controlling a search. | ||
374 | */ | ||
375 | struct GNUNET_FS_SearchContext | ||
376 | { | ||
377 | }; | ||
378 | |||
379 | |||
380 | /** | ||
381 | * Context for controlling a download. | ||
382 | */ | ||
383 | struct GNUNET_FS_DownloadContext | ||
384 | { | ||
385 | }; | ||
386 | |||
387 | struct GNUNET_FS_Namespace | ||
388 | { | ||
389 | /** | ||
390 | * Reference counter. | ||
391 | */ | ||
392 | unsigned int rc; | ||
393 | }; | ||
394 | |||
395 | |||
321 | #endif | 396 | #endif |
diff --git a/src/fs/fs_download.c b/src/fs/fs_download.c index cb3b39995..f1954ea89 100644 --- a/src/fs/fs_download.c +++ b/src/fs/fs_download.c | |||
@@ -18,22 +18,75 @@ | |||
18 | Boston, MA 02111-1307, USA. | 18 | Boston, MA 02111-1307, USA. |
19 | */ | 19 | */ |
20 | /** | 20 | /** |
21 | * @file applications/fs/ecrs/download.c | 21 | * @file fs/fs_download.c |
22 | * @brief DOWNLOAD helper methods (which do the real work). | 22 | * @brief DOWNLOAD helper methods (which do the real work). |
23 | * @author Christian Grothoff | 23 | * @author Christian Grothoff |
24 | */ | 24 | */ |
25 | 25 | ||
26 | #include "platform.h" | 26 | #include "platform.h" |
27 | #include "gnunet_protocols.h" | 27 | #include "gnunet_fs_service.h" |
28 | #include "gnunet_ecrs_lib.h" | ||
29 | #include "gnunet_fs_lib.h" | ||
30 | #include "gnunet_identity_lib.h" | ||
31 | #include "ecrs_core.h" | ||
32 | #include "ecrs.h" | ||
33 | #include "fs.h" | 28 | #include "fs.h" |
34 | #include "tree.h" | ||
35 | 29 | ||
36 | #define DEBUG_DOWNLOAD GNUNET_NO | 30 | #define DEBUG_DOWNLOAD GNUNET_YES |
31 | |||
32 | |||
33 | |||
34 | /** | ||
35 | * Download parts of a file. Note that this will store | ||
36 | * the blocks at the respective offset in the given file. Also, the | ||
37 | * download is still using the blocking of the underlying FS | ||
38 | * encoding. As a result, the download may *write* outside of the | ||
39 | * given boundaries (if offset and length do not match the 32k FS | ||
40 | * block boundaries). <p> | ||
41 | * | ||
42 | * This function should be used to focus a download towards a | ||
43 | * particular portion of the file (optimization), not to strictly | ||
44 | * limit the download to exactly those bytes. | ||
45 | * | ||
46 | * @param h handle to the file sharing subsystem | ||
47 | * @param uri the URI of the file (determines what to download); CHK or LOC URI | ||
48 | * @param filename where to store the file, maybe NULL (then no file is | ||
49 | * created on disk and data must be grabbed from the callbacks) | ||
50 | * @param offset at what offset should we start the download (typically 0) | ||
51 | * @param length how many bytes should be downloaded starting at offset | ||
52 | * @param anonymity anonymity level to use for the download | ||
53 | * @param no_temporaries set to GNUNET_YES to disallow generation of temporary files | ||
54 | * @param recursive should this be a recursive download (useful for directories | ||
55 | * to automatically trigger download of files in the directories) | ||
56 | * @param parent parent download to associate this download with (use NULL | ||
57 | * for top-level downloads; useful for manually-triggered recursive downloads) | ||
58 | * @return context that can be used to control this download | ||
59 | */ | ||
60 | struct GNUNET_FS_DownloadContext * | ||
61 | GNUNET_FS_file_download_start (struct GNUNET_FS_Handle *h, | ||
62 | const struct GNUNET_FS_Uri *uri, | ||
63 | const char *filename, | ||
64 | unsigned long long offset, | ||
65 | unsigned long long length, | ||
66 | unsigned int anonymity, | ||
67 | int no_temporaries, | ||
68 | int recursive, | ||
69 | struct GNUNET_FS_DownloadContext *parent) | ||
70 | { | ||
71 | return NULL; | ||
72 | } | ||
73 | |||
74 | /** | ||
75 | * Stop a download (aborts if download is incomplete). | ||
76 | * | ||
77 | * @param rm handle for the download | ||
78 | * @param do_delete delete files of incomplete downloads | ||
79 | */ | ||
80 | void | ||
81 | GNUNET_FS_file_download_stop (struct GNUNET_FS_DownloadContext *rm, | ||
82 | int do_delete) | ||
83 | { | ||
84 | } | ||
85 | |||
86 | |||
87 | |||
88 | |||
89 | #if 0 | ||
37 | 90 | ||
38 | /** | 91 | /** |
39 | * Node-specific data (not shared, keep small!). 152 bytes. | 92 | * Node-specific data (not shared, keep small!). 152 bytes. |
@@ -920,4 +973,6 @@ GNUNET_ECRS_file_download (struct GNUNET_GE_Context *ectx, | |||
920 | dpcb, dpcbClosure, tt, ttClosure); | 973 | dpcb, dpcbClosure, tt, ttClosure); |
921 | } | 974 | } |
922 | 975 | ||
923 | /* end of download.c */ | 976 | #endif |
977 | |||
978 | /* end of fs_download.c */ | ||
diff --git a/src/fs/fs_publish.c b/src/fs/fs_publish.c index ac71c8f21..7696dd940 100644 --- a/src/fs/fs_publish.c +++ b/src/fs/fs_publish.c | |||
@@ -34,6 +34,95 @@ | |||
34 | #define DEBUG_PUBLISH GNUNET_YES | 34 | #define DEBUG_PUBLISH GNUNET_YES |
35 | 35 | ||
36 | 36 | ||
37 | /** | ||
38 | * Main function that performs the upload. | ||
39 | * @param cls "struct GNUNET_FS_PublishContext" identifies the upload | ||
40 | * @param tc task context | ||
41 | */ | ||
42 | static void | ||
43 | do_upload (void *cls, | ||
44 | const struct GNUNET_SCHEDULER_TaskContext *tc) | ||
45 | { | ||
46 | struct GNUNET_FS_PublishContext *sc = cls; | ||
47 | |||
48 | sc->upload_task = GNUNET_SCHEDULER_NO_TASK; | ||
49 | |||
50 | // FIXME: find next block, process, schedule | ||
51 | // transmission to FS service | ||
52 | } | ||
53 | |||
54 | |||
55 | /** | ||
56 | * Publish a file or directory. | ||
57 | * | ||
58 | * @param h handle to the file sharing subsystem | ||
59 | * @param ctx initial value to use for the '*ctx' | ||
60 | * in the callback (for the GNUNET_FS_STATUS_PUBLISH_START event). | ||
61 | * @param fi information about the file or directory structure to publish | ||
62 | * @param namespace namespace to publish the file in, NULL for no namespace | ||
63 | * @param nid identifier to use for the publishd content in the namespace | ||
64 | * (can be NULL, must be NULL if namespace is NULL) | ||
65 | * @param nuid update-identifier that will be used for future updates | ||
66 | * (can be NULL, must be NULL if namespace or nid is NULL) | ||
67 | * @return context that can be used to control the publish operation | ||
68 | */ | ||
69 | struct GNUNET_FS_PublishContext * | ||
70 | GNUNET_FS_publish_start (struct GNUNET_FS_Handle *h, | ||
71 | void *ctx, | ||
72 | struct GNUNET_FS_FileInformation *fi, | ||
73 | struct GNUNET_FS_Namespace *namespace, | ||
74 | const char *nid, | ||
75 | const char *nuid) | ||
76 | { | ||
77 | struct GNUNET_FS_PublishContext *ret; | ||
78 | |||
79 | ret = GNUNET_malloc (sizeof (struct GNUNET_FS_PublishContext)); | ||
80 | ret->h = h; | ||
81 | ret->client_ctx = ctx; | ||
82 | ret->fi = fi; | ||
83 | ret->namespace = namespace; | ||
84 | if (namespace != NULL) | ||
85 | { | ||
86 | namespace->rc++; | ||
87 | GNUNET_assert (NULL != nid); | ||
88 | ret->nid = GNUNET_strdup (nid); | ||
89 | if (NULL != nuid) | ||
90 | ret->nuid = GNUNET_strdup (nuid); | ||
91 | } | ||
92 | // FIXME: make upload persistent! | ||
93 | ret->upload_task | ||
94 | = GNUNET_SCHEDULER_add_delayed (h->sched, | ||
95 | GNUNET_NO, | ||
96 | GNUNET_SCHEDULER_PRIORITY_BACKGROUND, | ||
97 | GNUNET_SCHEDULER_NO_TASK, | ||
98 | GNUNET_TIME_UNIT_ZERO, | ||
99 | &do_upload, | ||
100 | ret); | ||
101 | return ret; | ||
102 | } | ||
103 | |||
104 | |||
105 | /** | ||
106 | * Stop an upload. Will abort incomplete uploads (but | ||
107 | * not remove blocks that have already been publishd) or | ||
108 | * simply clean up the state for completed uploads. | ||
109 | * | ||
110 | * @param sc context for the upload to stop | ||
111 | */ | ||
112 | void | ||
113 | GNUNET_FS_publish_stop (struct GNUNET_FS_PublishContext *sc) | ||
114 | { | ||
115 | if (GNUNET_SCHEDULER_NO_TASK != sc->upload_task) | ||
116 | GNUNET_SCHEDULER_cancel (sc->h->sched, sc->upload_task); | ||
117 | // FIXME: remove from persistence DB (?) --- think more about | ||
118 | // shutdown / persistent-resume APIs!!! | ||
119 | GNUNET_FS_file_information_destroy (sc->fi, NULL, NULL); | ||
120 | GNUNET_FS_namespace_delete (sc->namespace, GNUNET_NO); | ||
121 | GNUNET_free_non_null (sc->nid); | ||
122 | GNUNET_free_non_null (sc->nuid); | ||
123 | GNUNET_free (sc); | ||
124 | } | ||
125 | |||
37 | 126 | ||
38 | #if 0 | 127 | #if 0 |
39 | 128 | ||
diff --git a/src/fs/fs_search.c b/src/fs/fs_search.c index 56240af69..51d1fbc1f 100644 --- a/src/fs/fs_search.c +++ b/src/fs/fs_search.c | |||
@@ -19,19 +19,71 @@ | |||
19 | */ | 19 | */ |
20 | 20 | ||
21 | /** | 21 | /** |
22 | * @file applications/fs/ecrs/search.c | 22 | * @file fs/fs_search.c |
23 | * @brief Helper functions for searching. | 23 | * @brief Helper functions for searching. |
24 | * @author Christian Grothoff | 24 | * @author Christian Grothoff |
25 | */ | 25 | */ |
26 | 26 | ||
27 | #include "platform.h" | 27 | #include "platform.h" |
28 | #include "gnunet_protocols.h" | 28 | #include "gnunet_fs_service.h" |
29 | #include "gnunet_fs_lib.h" | 29 | #include "fs.h" |
30 | #include "gnunet_ecrs_lib.h" | 30 | |
31 | #include "ecrs_core.h" | 31 | #define DEBUG_SEARCH GNUNET_YES |
32 | #include "ecrs.h" | 32 | |
33 | |||
34 | /** | ||
35 | * Start search for content. | ||
36 | * | ||
37 | * @param h handle to the file sharing subsystem | ||
38 | * @param uri specifies the search parameters; can be | ||
39 | * a KSK URI or an SKS URI. | ||
40 | * @param anonymity desired level of anonymity | ||
41 | * @return context that can be used to control the search | ||
42 | */ | ||
43 | struct GNUNET_FS_SearchContext * | ||
44 | GNUNET_FS_search_start (struct GNUNET_FS_Handle *h, | ||
45 | const struct GNUNET_FS_Uri *uri, | ||
46 | unsigned int anonymity) | ||
47 | { | ||
48 | return NULL; | ||
49 | } | ||
50 | |||
51 | |||
52 | /** | ||
53 | * Pause search. | ||
54 | * | ||
55 | * @param sc context for the search that should be paused | ||
56 | */ | ||
57 | void | ||
58 | GNUNET_FS_search_pause (struct GNUNET_FS_SearchContext *sc) | ||
59 | { | ||
60 | } | ||
61 | |||
62 | /** | ||
63 | * Continue paused search. | ||
64 | * | ||
65 | * @param sc context for the search that should be resumed | ||
66 | */ | ||
67 | void | ||
68 | GNUNET_FS_search_continue (struct GNUNET_FS_SearchContext *sc) | ||
69 | { | ||
70 | } | ||
33 | 71 | ||
34 | #define DEBUG_SEARCH GNUNET_NO | 72 | |
73 | /** | ||
74 | * Stop search for content. | ||
75 | * | ||
76 | * @param sc context for the search that should be stopped | ||
77 | */ | ||
78 | void | ||
79 | GNUNET_FS_search_stop (struct GNUNET_FS_SearchContext *sc) | ||
80 | { | ||
81 | } | ||
82 | |||
83 | |||
84 | |||
85 | |||
86 | #if 0 | ||
35 | 87 | ||
36 | /** | 88 | /** |
37 | * Context for an individual search. Followed | 89 | * Context for an individual search. Followed |
@@ -568,5 +620,6 @@ GNUNET_ECRS_search (struct GNUNET_GE_Context *ectx, | |||
568 | return GNUNET_OK; | 620 | return GNUNET_OK; |
569 | } | 621 | } |
570 | 622 | ||
623 | #endif | ||
571 | 624 | ||
572 | /* end of search.c */ | 625 | /* end of fs_search.c */ |
diff --git a/src/fs/fs_unindex.c b/src/fs/fs_unindex.c index ef63e798e..8fb13a644 100644 --- a/src/fs/fs_unindex.c +++ b/src/fs/fs_unindex.c | |||
@@ -19,25 +19,62 @@ | |||
19 | */ | 19 | */ |
20 | 20 | ||
21 | /** | 21 | /** |
22 | * @file applications/fs/ecrs/unindex.c | 22 | * @file fs/fs_unindex.c |
23 | * @author Krista Bennett | 23 | * @author Krista Bennett |
24 | * @author Christian Grothoff | 24 | * @author Christian Grothoff |
25 | * | 25 | * @brief Unindex file. |
26 | * Unindex file. | ||
27 | * | 26 | * |
28 | * TODO: | 27 | * TODO: |
29 | * - code cleanup (share more with upload.c) | 28 | * - code cleanup (share more with upload.c) |
30 | */ | 29 | */ |
31 | 30 | ||
32 | #include "platform.h" | 31 | #include "platform.h" |
33 | #include "gnunet_protocols.h" | 32 | #include "gnunet_fs_service.h" |
34 | #include "gnunet_ecrs_lib.h" | ||
35 | #include "gnunet_fs_lib.h" | ||
36 | #include "gnunet_getoption_lib.h" | ||
37 | #include "ecrs_core.h" | ||
38 | #include "ecrs.h" | ||
39 | #include "fs.h" | 33 | #include "fs.h" |
40 | #include "tree.h" | 34 | |
35 | /** | ||
36 | * Iterate over all indexed files. | ||
37 | * | ||
38 | * @param h handle to the file sharing subsystem | ||
39 | * @param iterator function to call on each indexed file | ||
40 | * @param iterator_cls closure for iterator | ||
41 | */ | ||
42 | void | ||
43 | GNUNET_FS_get_indexed_files (struct GNUNET_FS_Handle *h, | ||
44 | GNUNET_FS_IndexedFileProcessor iterator, | ||
45 | void *iterator_cls) | ||
46 | { | ||
47 | } | ||
48 | |||
49 | |||
50 | /** | ||
51 | * Unindex a file. | ||
52 | * | ||
53 | * @param h handle to the file sharing subsystem | ||
54 | * @param filename file to unindex | ||
55 | * @return NULL on error, otherwise handle | ||
56 | */ | ||
57 | struct GNUNET_FS_UnindexContext * | ||
58 | GNUNET_FS_unindex (struct GNUNET_FS_Handle *h, | ||
59 | const char *filename) | ||
60 | { | ||
61 | return NULL; | ||
62 | } | ||
63 | |||
64 | |||
65 | /** | ||
66 | * Clean up after completion of an unindex operation. | ||
67 | * | ||
68 | * @param uc handle | ||
69 | */ | ||
70 | void | ||
71 | GNUNET_FS_unindex_stop (struct GNUNET_FS_UnindexContext *uc) | ||
72 | { | ||
73 | } | ||
74 | |||
75 | |||
76 | |||
77 | #if 0 | ||
41 | 78 | ||
42 | #define STRICT_CHECKS GNUNET_NO | 79 | #define STRICT_CHECKS GNUNET_NO |
43 | 80 | ||
@@ -391,4 +428,6 @@ FAILURE: | |||
391 | return GNUNET_SYSERR; | 428 | return GNUNET_SYSERR; |
392 | } | 429 | } |
393 | 430 | ||
394 | /* end of unindex.c */ | 431 | #endif |
432 | |||
433 | /* end of fs_unindex.c */ | ||
diff --git a/src/fs/fs_test.c b/src/fs/test_fs.c index 5eedda982..5eedda982 100644 --- a/src/fs/fs_test.c +++ b/src/fs/test_fs.c | |||
diff --git a/src/include/gnunet_fs_service.h b/src/include/gnunet_fs_service.h index 7c6fc0549..4664c4cee 100644 --- a/src/include/gnunet_fs_service.h +++ b/src/include/gnunet_fs_service.h | |||
@@ -1763,11 +1763,11 @@ GNUNET_FS_file_information_destroy (struct GNUNET_FS_FileInformation *fi, | |||
1763 | */ | 1763 | */ |
1764 | struct GNUNET_FS_PublishContext * | 1764 | struct GNUNET_FS_PublishContext * |
1765 | GNUNET_FS_publish_start (struct GNUNET_FS_Handle *h, | 1765 | GNUNET_FS_publish_start (struct GNUNET_FS_Handle *h, |
1766 | void *ctx, | 1766 | void *ctx, |
1767 | const struct GNUNET_FS_FileInformation *fi, | 1767 | struct GNUNET_FS_FileInformation *fi, |
1768 | struct GNUNET_FS_Namespace *namespace, | 1768 | struct GNUNET_FS_Namespace *namespace, |
1769 | const char *nid, | 1769 | const char *nid, |
1770 | const char *nuid); | 1770 | const char *nuid); |
1771 | 1771 | ||
1772 | 1772 | ||
1773 | /** | 1773 | /** |