aboutsummaryrefslogtreecommitdiff
path: root/src/fs/fs_file_information.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/fs/fs_file_information.c')
-rw-r--r--src/fs/fs_file_information.c131
1 files changed, 31 insertions, 100 deletions
diff --git a/src/fs/fs_file_information.c b/src/fs/fs_file_information.c
index 2ae708e59..b248fae44 100644
--- a/src/fs/fs_file_information.c
+++ b/src/fs/fs_file_information.c
@@ -1,6 +1,6 @@
1/* 1/*
2 This file is part of GNUnet. 2 This file is part of GNUnet.
3 (C) 2009 Christian Grothoff (and other contributing authors) 3 (C) 2009, 2011 Christian Grothoff (and other contributing authors)
4 4
5 GNUnet is free software; you can redistribute it and/or modify 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 6 it under the terms of the GNU General Public License as published
@@ -132,11 +132,7 @@ GNUNET_FS_file_information_get_id (struct GNUNET_FS_FileInformation *s)
132 * @param meta metadata for the file 132 * @param meta metadata for the file
133 * @param do_index GNUNET_YES for index, GNUNET_NO for insertion, 133 * @param do_index GNUNET_YES for index, GNUNET_NO for insertion,
134 * GNUNET_SYSERR for simulation 134 * GNUNET_SYSERR for simulation
135 * @param anonymity what is the desired anonymity level for sharing? 135 * @param bo block options
136 * @param priority what is the priority for OUR node to
137 * keep this file available? Use 0 for maximum anonymity and
138 * minimum reliability...
139 * @param expirationTime when should this content expire?
140 * @return publish structure entry for the file 136 * @return publish structure entry for the file
141 */ 137 */
142struct GNUNET_FS_FileInformation * 138struct GNUNET_FS_FileInformation *
@@ -146,9 +142,7 @@ GNUNET_FS_file_information_create_from_file (struct GNUNET_FS_Handle *h,
146 const struct GNUNET_FS_Uri *keywords, 142 const struct GNUNET_FS_Uri *keywords,
147 const struct GNUNET_CONTAINER_MetaData *meta, 143 const struct GNUNET_CONTAINER_MetaData *meta,
148 int do_index, 144 int do_index,
149 uint32_t anonymity, 145 const struct GNUNET_FS_BlockOptions *bo)
150 uint32_t priority,
151 struct GNUNET_TIME_Absolute expirationTime)
152{ 146{
153 struct FileInfo *fi; 147 struct FileInfo *fi;
154 struct stat sbuf; 148 struct stat sbuf;
@@ -177,9 +171,7 @@ GNUNET_FS_file_information_create_from_file (struct GNUNET_FS_Handle *h,
177 keywords, 171 keywords,
178 meta, 172 meta,
179 do_index, 173 do_index,
180 anonymity, 174 bo);
181 priority,
182 expirationTime);
183 if (ret == NULL) 175 if (ret == NULL)
184 return NULL; 176 return NULL;
185 ret->h = h; 177 ret->h = h;
@@ -212,11 +204,7 @@ GNUNET_FS_file_information_create_from_file (struct GNUNET_FS_Handle *h,
212 * @param meta metadata for the file 204 * @param meta metadata for the file
213 * @param do_index GNUNET_YES for index, GNUNET_NO for insertion, 205 * @param do_index GNUNET_YES for index, GNUNET_NO for insertion,
214 * GNUNET_SYSERR for simulation 206 * GNUNET_SYSERR for simulation
215 * @param anonymity what is the desired anonymity level for sharing? 207 * @param bo block options
216 * @param priority what is the priority for OUR node to
217 * keep this file available? Use 0 for maximum anonymity and
218 * minimum reliability...
219 * @param expirationTime when should this content expire?
220 * @return publish structure entry for the file 208 * @return publish structure entry for the file
221 */ 209 */
222struct GNUNET_FS_FileInformation * 210struct GNUNET_FS_FileInformation *
@@ -227,9 +215,7 @@ GNUNET_FS_file_information_create_from_data (struct GNUNET_FS_Handle *h,
227 const struct GNUNET_FS_Uri *keywords, 215 const struct GNUNET_FS_Uri *keywords,
228 const struct GNUNET_CONTAINER_MetaData *meta, 216 const struct GNUNET_CONTAINER_MetaData *meta,
229 int do_index, 217 int do_index,
230 uint32_t anonymity, 218 const struct GNUNET_FS_BlockOptions *bo)
231 uint32_t priority,
232 struct GNUNET_TIME_Absolute expirationTime)
233{ 219{
234 if (GNUNET_YES == do_index) 220 if (GNUNET_YES == do_index)
235 { 221 {
@@ -244,9 +230,7 @@ GNUNET_FS_file_information_create_from_data (struct GNUNET_FS_Handle *h,
244 keywords, 230 keywords,
245 meta, 231 meta,
246 do_index, 232 do_index,
247 anonymity, 233 bo);
248 priority,
249 expirationTime);
250} 234}
251 235
252 236
@@ -263,11 +247,7 @@ GNUNET_FS_file_information_create_from_data (struct GNUNET_FS_Handle *h,
263 * @param meta metadata for the file 247 * @param meta metadata for the file
264 * @param do_index GNUNET_YES for index, GNUNET_NO for insertion, 248 * @param do_index GNUNET_YES for index, GNUNET_NO for insertion,
265 * GNUNET_SYSERR for simulation 249 * GNUNET_SYSERR for simulation
266 * @param anonymity what is the desired anonymity level for sharing? 250 * @param bo block options
267 * @param priority what is the priority for OUR node to
268 * keep this file available? Use 0 for maximum anonymity and
269 * minimum reliability...
270 * @param expirationTime when should this content expire?
271 * @return publish structure entry for the file 251 * @return publish structure entry for the file
272 */ 252 */
273struct GNUNET_FS_FileInformation * 253struct GNUNET_FS_FileInformation *
@@ -279,9 +259,7 @@ GNUNET_FS_file_information_create_from_reader (struct GNUNET_FS_Handle *h,
279 const struct GNUNET_FS_Uri *keywords, 259 const struct GNUNET_FS_Uri *keywords,
280 const struct GNUNET_CONTAINER_MetaData *meta, 260 const struct GNUNET_CONTAINER_MetaData *meta,
281 int do_index, 261 int do_index,
282 uint32_t anonymity, 262 const struct GNUNET_FS_BlockOptions *bo)
283 uint32_t priority,
284 struct GNUNET_TIME_Absolute expirationTime)
285{ 263{
286 struct GNUNET_FS_FileInformation *ret; 264 struct GNUNET_FS_FileInformation *ret;
287 265
@@ -298,13 +276,11 @@ GNUNET_FS_file_information_create_from_reader (struct GNUNET_FS_Handle *h,
298 if (ret->meta == NULL) 276 if (ret->meta == NULL)
299 ret->meta = GNUNET_CONTAINER_meta_data_create (); 277 ret->meta = GNUNET_CONTAINER_meta_data_create ();
300 ret->keywords = (keywords == NULL) ? NULL : GNUNET_FS_uri_dup (keywords); 278 ret->keywords = (keywords == NULL) ? NULL : GNUNET_FS_uri_dup (keywords);
301 ret->expirationTime = expirationTime;
302 ret->data.file.reader = reader; 279 ret->data.file.reader = reader;
303 ret->data.file.reader_cls = reader_cls; 280 ret->data.file.reader_cls = reader_cls;
304 ret->data.file.do_index = do_index; 281 ret->data.file.do_index = do_index;
305 ret->data.file.file_size = length; 282 ret->data.file.file_size = length;
306 ret->anonymity = anonymity; 283 ret->bo = *bo;
307 ret->priority = priority;
308 return ret; 284 return ret;
309} 285}
310 286
@@ -350,24 +326,15 @@ struct DirScanCls
350 char *emsg; 326 char *emsg;
351 327
352 /** 328 /**
353 * Should files be indexed? 329 * Block options.
354 */
355 int do_index;
356
357 /**
358 * Desired anonymity level.
359 */ 330 */
360 uint32_t anonymity; 331 const struct GNUNET_FS_BlockOptions *bo;
361 332
362 /** 333 /**
363 * Desired publishing priority. 334 * Should files be indexed?
364 */ 335 */
365 uint32_t priority; 336 int do_index;
366 337
367 /**
368 * Expiration time for publication.
369 */
370 struct GNUNET_TIME_Absolute expiration;
371}; 338};
372 339
373 340
@@ -406,9 +373,7 @@ dir_scan_cb (void *cls,
406 dsc->scanner, 373 dsc->scanner,
407 dsc->scanner_cls, 374 dsc->scanner_cls,
408 dsc->do_index, 375 dsc->do_index,
409 dsc->anonymity, 376 dsc->bo,
410 dsc->priority,
411 dsc->expiration,
412 &dsc->emsg); 377 &dsc->emsg);
413 if (NULL == fi) 378 if (NULL == fi)
414 { 379 {
@@ -430,9 +395,7 @@ dir_scan_cb (void *cls,
430 ksk_uri, 395 ksk_uri,
431 meta, 396 meta,
432 dsc->do_index, 397 dsc->do_index,
433 dsc->anonymity, 398 dsc->bo);
434 dsc->priority,
435 dsc->expiration);
436 GNUNET_CONTAINER_meta_data_destroy (meta); 399 GNUNET_CONTAINER_meta_data_destroy (meta);
437 GNUNET_FS_uri_destroy (keywords); 400 GNUNET_FS_uri_destroy (keywords);
438 GNUNET_FS_uri_destroy (ksk_uri); 401 GNUNET_FS_uri_destroy (ksk_uri);
@@ -459,9 +422,7 @@ dir_scan_cb (void *cls,
459 * @param h handle to the file sharing subsystem 422 * @param h handle to the file sharing subsystem
460 * @param dirname name of the directory to scan 423 * @param dirname name of the directory to scan
461 * @param do_index should files be indexed or inserted 424 * @param do_index should files be indexed or inserted
462 * @param anonymity desired anonymity level 425 * @param bo block options
463 * @param priority priority for publishing
464 * @param expirationTime expiration for publication
465 * @param proc function called on each entry 426 * @param proc function called on each entry
466 * @param proc_cls closure for proc 427 * @param proc_cls closure for proc
467 * @param emsg where to store an error message (on errors) 428 * @param emsg where to store an error message (on errors)
@@ -472,9 +433,7 @@ GNUNET_FS_directory_scanner_default (void *cls,
472 struct GNUNET_FS_Handle *h, 433 struct GNUNET_FS_Handle *h,
473 const char *dirname, 434 const char *dirname,
474 int do_index, 435 int do_index,
475 uint32_t anonymity, 436 const struct GNUNET_FS_BlockOptions *bo,
476 uint32_t priority,
477 struct GNUNET_TIME_Absolute expirationTime,
478 GNUNET_FS_FileProcessor proc, 437 GNUNET_FS_FileProcessor proc,
479 void *proc_cls, 438 void *proc_cls,
480 char **emsg) 439 char **emsg)
@@ -489,9 +448,7 @@ GNUNET_FS_directory_scanner_default (void *cls,
489 dsc.scanner = &GNUNET_FS_directory_scanner_default; 448 dsc.scanner = &GNUNET_FS_directory_scanner_default;
490 dsc.scanner_cls = cls; 449 dsc.scanner_cls = cls;
491 dsc.do_index = do_index; 450 dsc.do_index = do_index;
492 dsc.anonymity = anonymity; 451 dsc.bo = bo;
493 dsc.priority = priority;
494 dsc.expiration = expirationTime;
495 if (-1 == GNUNET_DISK_directory_scan (dirname, 452 if (-1 == GNUNET_DISK_directory_scan (dirname,
496 &dir_scan_cb, 453 &dir_scan_cb,
497 &dsc)) 454 &dsc))
@@ -555,11 +512,7 @@ dirproc (void *cls,
555 * @param scanner function used to get a list of files in a directory 512 * @param scanner function used to get a list of files in a directory
556 * @param scanner_cls closure for scanner 513 * @param scanner_cls closure for scanner
557 * @param do_index should files in the hierarchy be indexed? 514 * @param do_index should files in the hierarchy be indexed?
558 * @param anonymity what is the desired anonymity level for sharing? 515 * @param bo block options
559 * @param priority what is the priority for OUR node to
560 * keep this file available? Use 0 for maximum anonymity and
561 * minimum reliability...
562 * @param expirationTime when should this content expire?
563 * @param emsg where to store an error message 516 * @param emsg where to store an error message
564 * @return publish structure entry for the directory, NULL on error 517 * @return publish structure entry for the directory, NULL on error
565 */ 518 */
@@ -570,9 +523,7 @@ GNUNET_FS_file_information_create_from_directory (struct GNUNET_FS_Handle *h,
570 GNUNET_FS_DirectoryScanner scanner, 523 GNUNET_FS_DirectoryScanner scanner,
571 void *scanner_cls, 524 void *scanner_cls,
572 int do_index, 525 int do_index,
573 uint32_t anonymity, 526 const struct GNUNET_FS_BlockOptions *bo,
574 uint32_t priority,
575 struct GNUNET_TIME_Absolute expirationTime,
576 char **emsg) 527 char **emsg)
577{ 528{
578 struct GNUNET_FS_FileInformation *ret; 529 struct GNUNET_FS_FileInformation *ret;
@@ -590,9 +541,7 @@ GNUNET_FS_file_information_create_from_directory (struct GNUNET_FS_Handle *h,
590 h, 541 h,
591 filename, 542 filename,
592 do_index, 543 do_index,
593 anonymity, 544 bo,
594 priority,
595 expirationTime,
596 &dirproc, 545 &dirproc,
597 &dc, 546 &dc,
598 emsg); 547 emsg);
@@ -602,9 +551,7 @@ GNUNET_FS_file_information_create_from_directory (struct GNUNET_FS_Handle *h,
602 client_info, 551 client_info,
603 ksk, 552 ksk,
604 meta, 553 meta,
605 anonymity, 554 bo);
606 priority,
607 expirationTime);
608 GNUNET_CONTAINER_meta_data_destroy (meta); 555 GNUNET_CONTAINER_meta_data_destroy (meta);
609 ret->data.dir.entries = dc.entries; 556 ret->data.dir.entries = dc.entries;
610 while (dc.entries != NULL) 557 while (dc.entries != NULL)
@@ -657,11 +604,7 @@ GNUNET_FS_file_information_is_directory (struct GNUNET_FS_FileInformation *ent)
657 * @param meta metadata for the directory 604 * @param meta metadata for the directory
658 * @param keywords under which keywords should this directory be available 605 * @param keywords under which keywords should this directory be available
659 * directly; can be NULL 606 * directly; can be NULL
660 * @param anonymity what is the desired anonymity level for sharing? 607 * @param bo block options
661 * @param priority what is the priority for OUR node to
662 * keep this file available? Use 0 for maximum anonymity and
663 * minimum reliability...
664 * @param expirationTime when should this content expire?
665 * @return publish structure entry for the directory , NULL on error 608 * @return publish structure entry for the directory , NULL on error
666 */ 609 */
667struct GNUNET_FS_FileInformation * 610struct GNUNET_FS_FileInformation *
@@ -669,9 +612,7 @@ GNUNET_FS_file_information_create_empty_directory (struct GNUNET_FS_Handle *h,
669 void *client_info, 612 void *client_info,
670 const struct GNUNET_FS_Uri *keywords, 613 const struct GNUNET_FS_Uri *keywords,
671 const struct GNUNET_CONTAINER_MetaData *meta, 614 const struct GNUNET_CONTAINER_MetaData *meta,
672 uint32_t anonymity, 615 const struct GNUNET_FS_BlockOptions *bo)
673 uint32_t priority,
674 struct GNUNET_TIME_Absolute expirationTime)
675{ 616{
676 struct GNUNET_FS_FileInformation *ret; 617 struct GNUNET_FS_FileInformation *ret;
677 618
@@ -680,10 +621,8 @@ GNUNET_FS_file_information_create_empty_directory (struct GNUNET_FS_Handle *h,
680 ret->client_info = client_info; 621 ret->client_info = client_info;
681 ret->meta = GNUNET_CONTAINER_meta_data_duplicate (meta); 622 ret->meta = GNUNET_CONTAINER_meta_data_duplicate (meta);
682 ret->keywords = GNUNET_FS_uri_dup (keywords); 623 ret->keywords = GNUNET_FS_uri_dup (keywords);
683 ret->expirationTime = expirationTime; 624 ret->bo = *bo;
684 ret->is_directory = GNUNET_YES; 625 ret->is_directory = GNUNET_YES;
685 ret->anonymity = anonymity;
686 ret->priority = priority;
687 return ret; 626 return ret;
688} 627}
689 628
@@ -747,10 +686,8 @@ GNUNET_FS_file_information_inspect (struct GNUNET_FS_FileInformation *dir,
747 (dir->is_directory) ? dir->data.dir.dir_size : dir->data.file.file_size, 686 (dir->is_directory) ? dir->data.dir.dir_size : dir->data.file.file_size,
748 dir->meta, 687 dir->meta,
749 &dir->keywords, 688 &dir->keywords,
750 &dir->anonymity, 689 &dir->bo,
751 &dir->priority,
752 (dir->is_directory) ? &no : &dir->data.file.do_index, 690 (dir->is_directory) ? &no : &dir->data.file.do_index,
753 &dir->expirationTime,
754 &dir->client_info)) 691 &dir->client_info))
755 return; 692 return;
756 if (! dir->is_directory) 693 if (! dir->is_directory)
@@ -765,10 +702,8 @@ GNUNET_FS_file_information_inspect (struct GNUNET_FS_FileInformation *dir,
765 (pos->is_directory) ? pos->data.dir.dir_size : pos->data.file.file_size, 702 (pos->is_directory) ? pos->data.dir.dir_size : pos->data.file.file_size,
766 pos->meta, 703 pos->meta,
767 &pos->keywords, 704 &pos->keywords,
768 &pos->anonymity, 705 &pos->bo,
769 &pos->priority,
770 (dir->is_directory) ? &no : &dir->data.file.do_index, 706 (dir->is_directory) ? &no : &dir->data.file.do_index,
771 &pos->expirationTime,
772 &pos->client_info)) 707 &pos->client_info))
773 break; 708 break;
774 pos = pos->next; 709 pos = pos->next;
@@ -810,10 +745,8 @@ GNUNET_FS_file_information_destroy (struct GNUNET_FS_FileInformation *fi,
810 fi->data.dir.dir_size, 745 fi->data.dir.dir_size,
811 fi->meta, 746 fi->meta,
812 &fi->keywords, 747 &fi->keywords,
813 &fi->anonymity, 748 &fi->bo,
814 &fi->priority,
815 &no, 749 &no,
816 &fi->expirationTime,
817 &fi->client_info); 750 &fi->client_info);
818 GNUNET_free_non_null (fi->data.dir.dir_data); 751 GNUNET_free_non_null (fi->data.dir.dir_data);
819 } 752 }
@@ -830,10 +763,8 @@ GNUNET_FS_file_information_destroy (struct GNUNET_FS_FileInformation *fi,
830 fi->data.file.file_size, 763 fi->data.file.file_size,
831 fi->meta, 764 fi->meta,
832 &fi->keywords, 765 &fi->keywords,
833 &fi->anonymity, 766 &fi->bo,
834 &fi->priority,
835 &fi->data.file.do_index, 767 &fi->data.file.do_index,
836 &fi->expirationTime,
837 &fi->client_info); 768 &fi->client_info);
838 } 769 }
839 GNUNET_free_non_null (fi->filename); 770 GNUNET_free_non_null (fi->filename);