98f39b821b7b3e7dac408d93d382f35c6c079f0b
[oweals/gnunet.git] / src / fs / gnunet-publish.c
1 /*
2      This file is part of GNUnet.
3      (C) 2001, 2002, 2004, 2005, 2006, 2007, 2009, 2010, 2011 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 3, 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-publish.c
22  * @brief publishing files on GNUnet
23  * @author Christian Grothoff
24  * @author Krista Bennett
25  * @author James Blackwell
26  * @author Igor Wronsky
27  */
28 #include "platform.h"
29 #include "gnunet_fs_service.h"
30
31 static int ret;
32
33 static int verbose;
34
35 static const struct GNUNET_CONFIGURATION_Handle *cfg;
36
37 static struct GNUNET_FS_Handle *ctx;
38
39 static struct GNUNET_FS_PublishContext *pc;
40
41 static struct GNUNET_CONTAINER_MetaData *meta;
42
43 static struct GNUNET_FS_Uri *topKeywords;
44
45 static struct GNUNET_FS_Uri *uri;
46
47 static struct GNUNET_FS_BlockOptions bo = { {0LL}, 1, 365, 1 };
48
49 static char *uri_string;
50
51 static char *next_id;
52
53 static char *this_id;
54
55 static char *pseudonym;
56
57 static int do_insert;
58
59 static int disable_extractor;
60
61 static int do_simulate;
62
63 static int extract_only;
64
65 static int do_disable_creation_time;
66
67 static GNUNET_SCHEDULER_TaskIdentifier kill_task;
68
69 static struct GNUNET_FS_DirScanner *ds;
70
71 static struct GNUNET_FS_ShareTreeItem * directory_scan_intermediary_result;
72
73 static struct GNUNET_FS_ShareTreeItem * directory_scan_result;
74
75 static struct GNUNET_FS_ProcessMetadataContext *pmc;
76
77 static struct GNUNET_FS_Namespace *namespace;
78
79 /**
80  * FIXME: docu
81  */
82 static void
83 do_stop_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
84 {
85   struct GNUNET_FS_PublishContext *p;
86
87   kill_task = GNUNET_SCHEDULER_NO_TASK;
88   if (pc != NULL)
89   {
90     p = pc;
91     pc = NULL;
92     GNUNET_FS_publish_stop (p);
93   }
94   if (NULL != meta)
95   {
96     GNUNET_CONTAINER_meta_data_destroy (meta);
97     meta = NULL;
98   }  
99 }
100
101
102 /**
103  * Called by FS client to give information about the progress of an
104  * operation.
105  *
106  * @param cls closure
107  * @param info details about the event, specifying the event type
108  *        and various bits about the event
109  * @return client-context (for the next progress call
110  *         for this operation; should be set to NULL for
111  *         SUSPEND and STOPPED events).  The value returned
112  *         will be passed to future callbacks in the respective
113  *         field in the GNUNET_FS_ProgressInfo struct.
114  */
115 static void *
116 progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *info)
117 {
118   char *s;
119
120   switch (info->status)
121   {
122   case GNUNET_FS_STATUS_PUBLISH_START:
123     break;
124   case GNUNET_FS_STATUS_PUBLISH_PROGRESS:
125     if (verbose)
126     {
127       s = GNUNET_STRINGS_relative_time_to_string (info->value.publish.eta);
128       FPRINTF (stdout, _("Publishing `%s' at %llu/%llu (%s remaining)\n"),
129                info->value.publish.filename,
130                (unsigned long long) info->value.publish.completed,
131                (unsigned long long) info->value.publish.size, s);
132       GNUNET_free (s);
133     }
134     break;
135   case GNUNET_FS_STATUS_PUBLISH_ERROR:
136     FPRINTF (stderr, _("Error publishing: %s.\n"),
137              info->value.publish.specifics.error.message);
138     if (kill_task != GNUNET_SCHEDULER_NO_TASK)
139     {
140       GNUNET_SCHEDULER_cancel (kill_task);
141       kill_task = GNUNET_SCHEDULER_NO_TASK;
142     }
143     kill_task = GNUNET_SCHEDULER_add_now (&do_stop_task, NULL);
144     break;
145   case GNUNET_FS_STATUS_PUBLISH_COMPLETED:
146     FPRINTF (stdout, _("Publishing `%s' done.\n"),
147              info->value.publish.filename);
148     s = GNUNET_FS_uri_to_string (info->value.publish.specifics.
149                                  completed.chk_uri);
150     FPRINTF (stdout, _("URI is `%s'.\n"), s);
151     GNUNET_free (s);
152     if (info->value.publish.pctx == NULL)
153     {
154       if (kill_task != GNUNET_SCHEDULER_NO_TASK)
155       {
156         GNUNET_SCHEDULER_cancel (kill_task);
157         kill_task = GNUNET_SCHEDULER_NO_TASK;
158       }
159       kill_task = GNUNET_SCHEDULER_add_now (&do_stop_task, NULL);
160     }
161     break;
162   case GNUNET_FS_STATUS_PUBLISH_STOPPED:
163     GNUNET_break (NULL == pc);
164     return NULL;
165   case GNUNET_FS_STATUS_UNINDEX_PROGRESS:
166     return NULL;
167   case GNUNET_FS_STATUS_UNINDEX_COMPLETED:
168     FPRINTF (stderr, "%s",  _("Cleanup after abort complete.\n"));
169     return NULL;
170   default:
171     FPRINTF (stderr, _("Unexpected status: %d\n"), info->status);
172     return NULL;
173   }
174   return "";                    /* non-null */
175 }
176
177
178 /**
179  * Print metadata entries (except binary
180  * metadata and the filename).
181  *
182  * @param cls closure
183  * @param plugin_name name of the plugin that generated the meta data
184  * @param type type of the meta data
185  * @param format format of data
186  * @param data_mime_type mime type of data
187  * @param data value of the meta data
188  * @param data_size number of bytes in data
189  * @return always 0
190  */
191 static int
192 meta_printer (void *cls, const char *plugin_name, enum EXTRACTOR_MetaType type,
193               enum EXTRACTOR_MetaFormat format, const char *data_mime_type,
194               const char *data, size_t data_size)
195 {
196   if ((format != EXTRACTOR_METAFORMAT_UTF8) &&
197       (format != EXTRACTOR_METAFORMAT_C_STRING))
198     return 0;
199   if (type == EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME)
200     return 0;
201   FPRINTF (stdout, "\t%s - %s\n", EXTRACTOR_metatype_to_string (type), data);
202   return 0;
203 }
204
205
206 /**
207  * Iterator printing keywords
208  *
209  * @param cls closure
210  * @param keyword the keyword
211  * @param is_mandatory is the keyword mandatory (in a search)
212  * @return GNUNET_OK to continue to iterate, GNUNET_SYSERR to abort
213  */
214 static int
215 keyword_printer (void *cls, const char *keyword, int is_mandatory)
216 {
217   FPRINTF (stdout, "\t%s\n", keyword);
218   return GNUNET_OK;
219 }
220
221
222 /**
223  * Function called on all entries before the publication.  This is
224  * where we perform modifications to the default based on command-line
225  * options.
226  *
227  * @param cls closure
228  * @param fi the entry in the publish-structure
229  * @param length length of the file or directory
230  * @param m metadata for the file or directory (can be modified)
231  * @param uri pointer to the keywords that will be used for this entry (can be modified)
232  * @param bo block options
233  * @param do_index should we index?
234  * @param client_info pointer to client context set upon creation (can be modified)
235  * @return GNUNET_OK to continue, GNUNET_NO to remove
236  *         this entry from the directory, GNUNET_SYSERR
237  *         to abort the iteration
238  */
239 static int
240 publish_inspector (void *cls, struct GNUNET_FS_FileInformation *fi,
241                    uint64_t length, struct GNUNET_CONTAINER_MetaData *m,
242                    struct GNUNET_FS_Uri **uri,
243                    struct GNUNET_FS_BlockOptions *bo, int *do_index,
244                    void **client_info)
245 {
246   char *fn;
247   char *fs;
248   struct GNUNET_FS_Uri *new_uri;
249
250   if (cls == fi)
251     return GNUNET_OK;
252   if (NULL != topKeywords)
253   {
254     if (*uri != NULL)
255     {
256       new_uri = GNUNET_FS_uri_ksk_merge (topKeywords, *uri);
257       GNUNET_FS_uri_destroy (*uri);
258       *uri = new_uri;
259       GNUNET_FS_uri_destroy (topKeywords);
260     }
261     else
262     {
263       *uri = topKeywords;
264     }
265     topKeywords = NULL;
266   }
267   if (NULL != meta)
268   {
269     GNUNET_CONTAINER_meta_data_merge (m, meta);
270     GNUNET_CONTAINER_meta_data_destroy (meta);
271     meta = NULL;
272   }
273   if (!do_disable_creation_time)
274     GNUNET_CONTAINER_meta_data_add_publication_date (m);
275   if (extract_only)
276   {
277     fn = GNUNET_CONTAINER_meta_data_get_by_type (m,
278                                                  EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME);
279     fs = GNUNET_STRINGS_byte_size_fancy (length);
280     FPRINTF (stdout, _("Meta data for file `%s' (%s)\n"), fn, fs);
281     GNUNET_CONTAINER_meta_data_iterate (m, &meta_printer, NULL);
282     FPRINTF (stdout, _("Keywords for file `%s' (%s)\n"), fn, fs);
283     GNUNET_free (fn);
284     GNUNET_free (fs);
285     if (NULL != *uri)
286       GNUNET_FS_uri_ksk_get_keywords (*uri, &keyword_printer, NULL);
287     FPRINTF (stdout, "%s",  "\n");
288   }
289   if (GNUNET_YES == GNUNET_FS_meta_data_test_for_directory (m))
290     GNUNET_FS_file_information_inspect (fi, &publish_inspector, fi);
291   return GNUNET_OK;
292 }
293
294
295 /**
296  * FIXME: docu
297  */
298 static void
299 uri_sks_continuation (void *cls, const struct GNUNET_FS_Uri *ksk_uri,
300                       const char *emsg)
301 {
302   if (emsg != NULL)
303   {
304     FPRINTF (stderr, "%s\n", emsg);
305     ret = 1;
306   }
307   GNUNET_FS_uri_destroy (uri);
308   uri = NULL;
309   GNUNET_FS_stop (ctx);
310   ctx = NULL;
311 }
312
313
314 /**
315  * FIXME: docu
316  */
317 static void
318 uri_ksk_continuation (void *cls, const struct GNUNET_FS_Uri *ksk_uri,
319                       const char *emsg)
320 {
321   struct GNUNET_FS_Namespace *ns;
322
323   if (emsg != NULL)
324   {
325     FPRINTF (stderr, "%s\n", emsg);
326     ret = 1;
327   }
328   if (pseudonym != NULL)
329   {
330     ns = GNUNET_FS_namespace_create (ctx, pseudonym);
331     if (ns == NULL)
332     {
333       FPRINTF (stderr, _("Failed to create namespace `%s'\n"), pseudonym);
334       ret = 1;
335     }
336     else
337     {
338       GNUNET_FS_publish_sks (ctx, ns, this_id, next_id, meta, uri, &bo,
339                              GNUNET_FS_PUBLISH_OPTION_NONE,
340                              uri_sks_continuation, NULL);
341       GNUNET_assert (GNUNET_OK == GNUNET_FS_namespace_delete (ns, GNUNET_NO));
342       return;
343     }
344   }
345   GNUNET_FS_uri_destroy (uri);
346   uri = NULL;
347   GNUNET_FS_stop (ctx);
348   ctx = NULL;
349 }
350
351 static struct GNUNET_FS_FileInformation *
352 get_file_information (struct GNUNET_FS_ShareTreeItem *item)
353 {
354   struct GNUNET_FS_FileInformation *fi;
355   struct GNUNET_FS_FileInformation *fic;
356   struct GNUNET_FS_ShareTreeItem *child;
357
358   if (item->is_directory)
359   {
360     GNUNET_CONTAINER_meta_data_delete (item->meta,
361         EXTRACTOR_METATYPE_MIMETYPE, NULL, 0);
362     GNUNET_FS_meta_data_make_directory (item->meta);
363     GNUNET_FS_uri_ksk_add_keyword (item->ksk_uri, GNUNET_FS_DIRECTORY_MIME,
364         GNUNET_NO);
365     fi = GNUNET_FS_file_information_create_empty_directory (
366         ctx, NULL, item->ksk_uri,
367         item->meta, &bo, item->filename);
368     for (child = item->children_head; child; child = child->next)
369     {
370       fic = get_file_information (child);
371       GNUNET_break (GNUNET_OK == GNUNET_FS_file_information_add (fi, fic));
372     }
373   }
374   else
375   {
376     fi = GNUNET_FS_file_information_create_from_file (
377         ctx, NULL, item->filename,
378         item->ksk_uri, item->meta, !do_insert,
379         &bo);
380   }
381   GNUNET_CONTAINER_meta_data_destroy (item->meta);
382   GNUNET_FS_uri_destroy (item->ksk_uri);
383   GNUNET_free (item->short_filename);
384   GNUNET_free (item->filename);
385   GNUNET_free (item);
386   return fi;
387 }
388
389 static void
390 directory_trim_complete (void *cls,
391     const struct GNUNET_SCHEDULER_TaskContext *tc)
392 {
393   struct GNUNET_FS_FileInformation *fi;
394   directory_scan_result = directory_scan_intermediary_result;
395   fi = get_file_information (directory_scan_result);
396   directory_scan_result = NULL;
397   if (fi == NULL)
398   {
399     FPRINTF (stderr, "%s", _("Could not publish\n"));
400     if (namespace != NULL)
401       GNUNET_FS_namespace_delete (namespace, GNUNET_NO);
402     GNUNET_FS_stop (ctx);
403     ret = 1;
404     return;
405   }
406   GNUNET_FS_file_information_inspect (fi, &publish_inspector, NULL);
407   if (extract_only)
408   {
409     if (namespace != NULL)
410       GNUNET_FS_namespace_delete (namespace, GNUNET_NO);
411     GNUNET_FS_file_information_destroy (fi, NULL, NULL);
412     GNUNET_FS_stop (ctx);
413     return;
414   }
415   pc = GNUNET_FS_publish_start (ctx, fi, namespace, this_id, next_id,
416                                 (do_simulate) ?
417                                 GNUNET_FS_PUBLISH_OPTION_SIMULATE_ONLY :
418                                 GNUNET_FS_PUBLISH_OPTION_NONE);
419   if (NULL == pc)
420   {
421     FPRINTF (stderr, "%s",  _("Could not start publishing.\n"));
422     GNUNET_FS_stop (ctx);
423     ret = 1;
424     return;
425   }
426 }
427
428 static int
429 directory_scan_cb (void *cls, struct GNUNET_FS_DirScanner *ds,
430                    const char *filename, 
431                    int is_directory,
432                    enum GNUNET_FS_DirScannerProgressUpdateReason reason)
433 {
434   switch (reason)
435   {
436     case GNUNET_FS_DIRSCANNER_NEW_FILE:
437       if (filename != NULL)
438       {
439         if (is_directory)
440           FPRINTF (stdout, _("Scanning directory `%s'.\n"), filename);
441         else
442           FPRINTF (stdout, _("Scanning file `%s'.\n"), filename);
443       }
444       break;
445     case GNUNET_FS_DIRSCANNER_DOES_NOT_EXIST:
446       if (filename != NULL)
447       {
448         FPRINTF (stdout, 
449             _("Failed to scan `%s', because it does not exist.\n"),
450             filename);
451       }
452       break;
453     case GNUNET_FS_DIRSCANNER_ASKED_TO_STOP:
454       if (filename != NULL)
455       {
456         FPRINTF (stdout, 
457             _("Scanner was about to scan `%s', but is now stopping.\n"),
458             filename);
459       }
460       else
461         FPRINTF (stdout, "%s", _("Scanner is stopping.\n"));
462       break;
463     case GNUNET_FS_DIRSCANNER_SHUTDOWN:
464       FPRINTF (stdout, "%s", _("Client is shutting down.\n"));
465       break;
466     case GNUNET_FS_DIRSCANNER_FINISHED:
467       FPRINTF (stdout, "%s", _("Scanner has finished.\n"));
468       break;
469     case GNUNET_FS_DIRSCANNER_PROTOCOL_ERROR:
470       FPRINTF (stdout, "%s", 
471           _("There was a failure communicating with the scanner.\n"));
472       break;
473     default:
474       FPRINTF (stdout, _("Got unknown scanner update with filename `%s'.\n"),
475           filename);
476       break;
477   }
478   if ((filename == NULL && GNUNET_FS_DIRSCANNER_FINISHED)
479       || reason == GNUNET_FS_DIRSCANNER_PROTOCOL_ERROR
480       || reason == GNUNET_FS_DIRSCANNER_SHUTDOWN)
481   {
482     /* Any of this causes us to try to clean up the scanner */
483     directory_scan_intermediary_result = GNUNET_FS_directory_scan_cleanup (ds);
484     pmc = GNUNET_FS_trim_share_tree (directory_scan_intermediary_result,
485       &directory_trim_complete, NULL);
486
487     ds = NULL;
488     /* FIXME: change the tree processor to be able to free untrimmed trees
489      * right here instead of waiting for trimming to complete, if we need to
490      * cancel everything.
491      */
492   }
493   return 0;
494 }
495
496
497 /**
498  * Main function that will be run by the scheduler.
499  *
500  * @param cls closure
501  * @param args remaining command-line arguments
502  * @param cfgfile name of the configuration file used (for saving, can be NULL!)
503  * @param c configuration
504  */
505 static void
506 run (void *cls, char *const *args, const char *cfgfile,
507      const struct GNUNET_CONFIGURATION_Handle *c)
508 {
509   char *ex;
510   char *emsg;
511
512   /* check arguments */
513   if ((uri_string != NULL) && (extract_only))
514   {
515     printf (_("Cannot extract metadata from a URI!\n"));
516     ret = -1;
517     return;
518   }
519   if (((uri_string == NULL) || (extract_only)) &&
520       ((args[0] == NULL) || (args[1] != NULL)))
521   {
522     printf (_("You must specify one and only one filename for insertion.\n"));
523     ret = -1;
524     return;
525   }
526   if ((uri_string != NULL) && (args[0] != NULL))
527   {
528     printf (_("You must NOT specify an URI and a filename.\n"));
529     ret = -1;
530     return;
531   }
532   if (pseudonym != NULL)
533   {
534     if (NULL == this_id)
535     {
536       FPRINTF (stderr, _("Option `%s' is required when using option `%s'.\n"),
537                "-t", "-P");
538       ret = -1;
539       return;
540     }
541   }
542   else
543   {                             /* ordinary insertion checks */
544     if (NULL != next_id)
545     {
546       FPRINTF (stderr, _("Option `%s' makes no sense without option `%s'.\n"),
547                "-N", "-P");
548       ret = -1;
549       return;
550     }
551     if (NULL != this_id)
552     {
553       FPRINTF (stderr, _("Option `%s' makes no sense without option `%s'.\n"),
554                "-t", "-P");
555       ret = -1;
556       return;
557     }
558   }
559   cfg = c;
560   ctx =
561       GNUNET_FS_start (cfg, "gnunet-publish", &progress_cb, NULL,
562                        GNUNET_FS_FLAGS_NONE, GNUNET_FS_OPTIONS_END);
563   if (NULL == ctx)
564   {
565     FPRINTF (stderr, _("Could not initialize `%s' subsystem.\n"), "FS");
566     ret = 1;
567     return;
568   }
569   namespace = NULL;
570   if (NULL != pseudonym)
571   {
572     namespace = GNUNET_FS_namespace_create (ctx, pseudonym);
573     if (NULL == namespace)
574     {
575       FPRINTF (stderr, _("Could not create namespace `%s'\n"), pseudonym);
576       GNUNET_FS_stop (ctx);
577       ret = 1;
578       return;
579     }
580   }
581   if (NULL != uri_string)
582   {
583     emsg = NULL;
584     uri = GNUNET_FS_uri_parse (uri_string, &emsg);
585     if (uri == NULL)
586     {
587       FPRINTF (stderr, _("Failed to parse URI: %s\n"), emsg);
588       GNUNET_free (emsg);
589       if (namespace != NULL)
590         GNUNET_FS_namespace_delete (namespace, GNUNET_NO);
591       GNUNET_FS_stop (ctx);
592       ret = 1;
593       return;
594     }
595     GNUNET_FS_publish_ksk (ctx, topKeywords, meta, uri, &bo,
596                            GNUNET_FS_PUBLISH_OPTION_NONE, &uri_ksk_continuation,
597                            NULL);
598     if (namespace != NULL)
599       GNUNET_FS_namespace_delete (namespace, GNUNET_NO);
600     return;
601   }
602   if (GNUNET_OK !=
603       GNUNET_CONFIGURATION_get_value_string (cfg, "FS", "EXTRACTORS", &ex))
604     ex = NULL;
605
606   ds = GNUNET_FS_directory_scan_start (args[0],
607                                        disable_extractor, 
608                                        ex, 
609                                        &directory_scan_cb, NULL);
610   kill_task =
611       GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &do_stop_task,
612                                     NULL);
613 }
614
615
616 /**
617  * The main function to publish content to GNUnet.
618  *
619  * @param argc number of arguments from the command line
620  * @param argv command line arguments
621  * @return 0 ok, 1 on error
622  */
623 int
624 main (int argc, char *const *argv)
625 {
626   static const struct GNUNET_GETOPT_CommandLineOption options[] = {
627     {'a', "anonymity", "LEVEL",
628      gettext_noop ("set the desired LEVEL of sender-anonymity"),
629      1, &GNUNET_GETOPT_set_uint, &bo.anonymity_level},
630     {'d', "disable-creation-time", NULL,
631      gettext_noop
632      ("disable adding the creation time to the metadata of the uploaded file"),
633      0, &GNUNET_GETOPT_set_one, &do_disable_creation_time},
634     {'D', "disable-extractor", NULL,
635      gettext_noop ("do not use libextractor to add keywords or metadata"),
636      0, &GNUNET_GETOPT_set_one, &disable_extractor},
637     {'e', "extract", NULL,
638      gettext_noop
639      ("print list of extracted keywords that would be used, but do not perform upload"),
640      0, &GNUNET_GETOPT_set_one, &extract_only},
641     {'k', "key", "KEYWORD",
642      gettext_noop
643      ("add an additional keyword for the top-level file or directory"
644       " (this option can be specified multiple times)"),
645      1, &GNUNET_FS_getopt_set_keywords, &topKeywords},
646     {'m', "meta", "TYPE:VALUE",
647      gettext_noop ("set the meta-data for the given TYPE to the given VALUE"),
648      1, &GNUNET_FS_getopt_set_metadata, &meta},
649     {'n', "noindex", NULL,
650      gettext_noop ("do not index, perform full insertion (stores entire "
651                    "file in encrypted form in GNUnet database)"),
652      0, &GNUNET_GETOPT_set_one, &do_insert},
653     {'N', "next", "ID",
654      gettext_noop
655      ("specify ID of an updated version to be published in the future"
656       " (for namespace insertions only)"),
657      1, &GNUNET_GETOPT_set_string, &next_id},
658     {'p', "priority", "PRIORITY",
659      gettext_noop ("specify the priority of the content"),
660      1, &GNUNET_GETOPT_set_uint, &bo.content_priority},
661     {'P', "pseudonym", "NAME",
662      gettext_noop
663      ("publish the files under the pseudonym NAME (place file into namespace)"),
664      1, &GNUNET_GETOPT_set_string, &pseudonym},
665     {'r', "replication", "LEVEL",
666      gettext_noop ("set the desired replication LEVEL"),
667      1, &GNUNET_GETOPT_set_uint, &bo.replication_level},
668     {'s', "simulate-only", NULL,
669      gettext_noop ("only simulate the process but do not do any "
670                    "actual publishing (useful to compute URIs)"),
671      0, &GNUNET_GETOPT_set_one, &do_simulate},
672     {'t', "this", "ID",
673      gettext_noop ("set the ID of this version of the publication"
674                    " (for namespace insertions only)"),
675      1, &GNUNET_GETOPT_set_string, &this_id},
676     {'u', "uri", "URI",
677      gettext_noop ("URI to be published (can be used instead of passing a "
678                    "file to add keywords to the file with the respective URI)"),
679      1, &GNUNET_GETOPT_set_string, &uri_string},
680     {'V', "verbose", NULL,
681      gettext_noop ("be verbose (print progress information)"),
682      0, &GNUNET_GETOPT_set_one, &verbose},
683     GNUNET_GETOPT_OPTION_END
684   };
685   GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
686               "GNUnet publish starts\n");
687   bo.expiration_time =
688       GNUNET_FS_year_to_time (GNUNET_FS_get_current_year () + 2);
689   return (GNUNET_OK ==
690           GNUNET_PROGRAM_run (argc, argv, "gnunet-publish [OPTIONS] FILENAME",
691                               gettext_noop
692                               ("Publish a file or directory on GNUnet"),
693                               options, &run, NULL)) ? ret : 1;
694 }
695
696 /* end of gnunet-publish.c */