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