70964590d69bc38eb8db016c3269ee3099f73e27
[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 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  * @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 #define DEFAULT_EXPIRATION GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_YEARS, 2)
32
33 static int ret;
34
35 static int verbose;
36
37 static const struct GNUNET_CONFIGURATION_Handle *cfg;
38
39 static struct GNUNET_FS_Handle *ctx;
40
41 static struct GNUNET_SCHEDULER_Handle *sched;
42
43 static struct GNUNET_FS_PublishContext *pc;
44
45 static struct GNUNET_CONTAINER_MetaData *meta;
46
47 static struct GNUNET_FS_Uri *topKeywords;
48
49 static unsigned int anonymity = 1;
50
51 static unsigned int priority = 365;
52
53 static char *uri_string;
54
55 static char *next_id;
56
57 static char *this_id;
58
59 static char *pseudonym;
60
61 static int do_insert;
62
63 static int disable_extractor;
64
65 static int do_simulate;
66
67 static int extract_only;
68
69 static int do_disable_creation_time;
70
71 static GNUNET_SCHEDULER_TaskIdentifier kill_task;
72
73
74 static void 
75 do_stop_task (void *cls,
76               const struct GNUNET_SCHEDULER_TaskContext *tc)
77 {
78   struct GNUNET_FS_PublishContext *p;
79
80   if (pc != NULL)
81     {
82       p = pc;
83       pc = NULL;
84       GNUNET_FS_publish_stop (p);
85     }
86 }
87
88
89 /**
90  * Called by FS client to give information about the progress of an 
91  * operation.
92  *
93  * @param cls closure
94  * @param info details about the event, specifying the event type
95  *        and various bits about the event
96  * @return client-context (for the next progress call
97  *         for this operation; should be set to NULL for
98  *         SUSPEND and STOPPED events).  The value returned
99  *         will be passed to future callbacks in the respective
100  *         field in the GNUNET_FS_ProgressInfo struct.
101  */
102 static void *
103 progress_cb (void *cls,
104              const struct GNUNET_FS_ProgressInfo *info)
105 {
106   char *s;
107
108   switch (info->status)
109     {
110     case GNUNET_FS_STATUS_PUBLISH_START:
111       break;
112     case GNUNET_FS_STATUS_PUBLISH_PROGRESS:
113       if (verbose)
114         {
115           s = GNUNET_STRINGS_relative_time_to_string(info->value.publish.eta);
116           fprintf (stdout,
117                    _("Publishing `%s' at %llu/%llu (%s remaining)\n"),
118                    info->value.publish.filename,
119                    (unsigned long long) info->value.publish.completed,
120                    (unsigned long long) info->value.publish.size,
121                    s);
122           GNUNET_free (s);
123         }
124       break;
125     case GNUNET_FS_STATUS_PUBLISH_ERROR:
126       fprintf (stderr,
127                _("Error publishing: %s.\n"),
128                info->value.publish.specifics.error.message);
129       if (kill_task != GNUNET_SCHEDULER_NO_TASK)
130         {
131           GNUNET_SCHEDULER_cancel (sched,
132                                    kill_task);
133           kill_task = GNUNET_SCHEDULER_NO_TASK;
134         }
135       GNUNET_SCHEDULER_add_continuation (sched,
136                                          &do_stop_task,
137                                          NULL,
138                                          GNUNET_SCHEDULER_REASON_PREREQ_DONE);
139       break;
140     case GNUNET_FS_STATUS_PUBLISH_COMPLETED:
141       fprintf (stdout,
142                _("Publishing `%s' done.\n"),
143                info->value.publish.filename);
144       s = GNUNET_FS_uri_to_string (info->value.publish.specifics.completed.chk_uri);
145       fprintf (stdout,
146                _("URI is `%s'.\n"),
147                s);
148       GNUNET_free (s);
149       if (info->value.publish.pctx == NULL)
150         {
151           if (kill_task != GNUNET_SCHEDULER_NO_TASK)
152             {
153               GNUNET_SCHEDULER_cancel (sched,
154                                        kill_task);
155               kill_task = GNUNET_SCHEDULER_NO_TASK;
156             }
157           GNUNET_SCHEDULER_add_continuation (sched,
158                                              &do_stop_task,
159                                              NULL,
160                                              GNUNET_SCHEDULER_REASON_PREREQ_DONE);
161         }
162       break;
163     case GNUNET_FS_STATUS_PUBLISH_STOPPED: 
164       GNUNET_break (NULL == pc);
165       return NULL;      
166     default:
167       fprintf (stderr,
168                _("Unexpected status: %d\n"),
169                info->status);
170       return NULL;
171     }
172   return ""; /* non-null */
173 }
174
175
176 /**
177  * Print metadata entries (except binary
178  * metadata and the filename).
179  *
180  * @param cls closure
181  * @param plugin_name name of the plugin that generated the meta data
182  * @param type type of the meta data
183  * @param format format of data
184  * @param data_mime_type mime type of data
185  * @param data value of the meta data
186  * @param data_size number of bytes in data
187  * @return always 0
188  */
189 static int
190 meta_printer (void *cls,
191               const char *plugin_name,
192               enum EXTRACTOR_MetaType type, 
193               enum EXTRACTOR_MetaFormat format,
194               const char *data_mime_type,
195               const char *data,
196               size_t data_size)
197 {
198   if ( (format != EXTRACTOR_METAFORMAT_UTF8) &&
199        (format != EXTRACTOR_METAFORMAT_C_STRING) )
200     return 0;
201   if (type == EXTRACTOR_METATYPE_FILENAME) 
202     return 0;
203   fprintf (stdout, 
204            "%s - %s",
205            EXTRACTOR_metatype_to_string (type),
206            data);
207   return 0;
208 }
209
210
211 /**
212  * Merge metadata entries.
213  *
214  * @param cls closure, target metadata structure
215  * @param plugin_name name of the plugin that generated the meta data
216  * @param type type of the meta data
217  * @param format format of data
218  * @param data_mime_type mime type of data
219  * @param data value of the meta data
220  * @param data_size number of bytes in data
221  * @return always 0
222  */
223 static int
224 meta_merger (void *cls,
225               const char *plugin_name,
226               enum EXTRACTOR_MetaType type, 
227               enum EXTRACTOR_MetaFormat format,
228               const char *data_mime_type,
229               const char *data,
230               size_t data_size)
231 {
232   struct GNUNET_CONTAINER_MetaData *m = cls;
233
234   GNUNET_CONTAINER_meta_data_insert (m,
235                                      plugin_name,
236                                      type, 
237                                      format,
238                                      data_mime_type,
239                                      data,
240                                      data_size);
241   return 0;
242 }
243
244
245 /**
246  * Function called on all entries before the publication.  This is
247  * where we perform modifications to the default based on command-line
248  * options.
249  *
250  * @param cls closure
251  * @param fi the entry in the publish-structure
252  * @param length length of the file or directory
253  * @param m metadata for the file or directory (can be modified)
254  * @param uri pointer to the keywords that will be used for this entry (can be modified)
255  * @param anonymity pointer to selected anonymity level (can be modified)
256  * @param priority pointer to selected priority (can be modified)
257  * @param expirationTime pointer to selected expiration time (can be modified)
258  * @param client_info pointer to client context set upon creation (can be modified)
259  * @return GNUNET_OK to continue, GNUNET_NO to remove
260  *         this entry from the directory, GNUNET_SYSERR
261  *         to abort the iteration
262  */
263 static int
264 publish_inspector (void *cls,
265                    struct GNUNET_FS_FileInformation *fi,
266                    uint64_t length,
267                    struct GNUNET_CONTAINER_MetaData *m,
268                    struct GNUNET_FS_Uri **uri,
269                    unsigned int *anonymity,
270                    unsigned int *priority,
271                    struct GNUNET_TIME_Absolute *expirationTime,
272                    void **client_info)
273 {
274   char *fn;
275   char *fs;
276   struct GNUNET_FS_Uri *new_uri;
277
278   if (NULL != topKeywords)
279     {
280       if (*uri != NULL)
281         {
282           new_uri = GNUNET_FS_uri_ksk_merge (topKeywords,
283                                              *uri);
284           GNUNET_FS_uri_destroy (*uri); 
285           *uri = new_uri;
286           GNUNET_FS_uri_destroy (topKeywords);
287         }
288       else
289         {
290           *uri = topKeywords;
291         }
292       topKeywords = NULL;
293     }
294   if (NULL != meta) 
295     {
296       GNUNET_CONTAINER_meta_data_iterate (meta,
297                                           &meta_merger,
298                                           m);
299       GNUNET_CONTAINER_meta_data_destroy (meta);
300       meta = NULL;
301     }
302   if (! do_disable_creation_time)
303     GNUNET_CONTAINER_meta_data_add_publication_date (m);
304   if (extract_only)
305     {
306       fn = GNUNET_CONTAINER_meta_data_get_by_type (m,
307                                                    EXTRACTOR_METATYPE_FILENAME);
308       fs = GNUNET_STRINGS_byte_size_fancy (length);
309       fprintf (stdout,
310                _("Keywords for file `%s' (%s)\n"),
311                fn,
312                fs);
313       GNUNET_free (fn);
314       GNUNET_free (fs);
315       GNUNET_CONTAINER_meta_data_iterate (m,
316                                           &meta_printer,
317                                           NULL);
318       fprintf (stdout, "\n");
319     }
320   if (GNUNET_YES == GNUNET_FS_meta_data_test_for_directory (m))
321     GNUNET_FS_file_information_inspect (fi,
322                                         &publish_inspector,
323                                         NULL);
324   return GNUNET_OK;
325 }
326
327
328 static void 
329 uri_ksk_continuation (void *cls,
330                       const struct GNUNET_FS_Uri *uri,
331                       const char *emsg)
332 {
333   if (emsg != NULL)
334     {
335       fprintf (stderr,
336                "%s\n",
337                emsg);
338       ret = 1;
339     }
340   GNUNET_FS_stop (ctx);
341 }
342
343
344 /**
345  * Main function that will be run by the scheduler.
346  *
347  * @param cls closure
348  * @param s the scheduler to use
349  * @param args remaining command-line arguments
350  * @param cfgfile name of the configuration file used (for saving, can be NULL!)
351  * @param c configuration
352  */
353 static void
354 run (void *cls,
355      struct GNUNET_SCHEDULER_Handle *s,
356      char *const *args,
357      const char *cfgfile,
358      const struct GNUNET_CONFIGURATION_Handle *c)
359 {
360   struct GNUNET_FS_FileInformation *fi;
361   struct GNUNET_FS_Namespace *namespace;
362   struct EXTRACTOR_PluginList *l;
363   struct stat sbuf;
364   char *ex;
365   char *emsg;
366   struct GNUNET_FS_Uri *uri;
367   
368   sched = s;
369   /* check arguments */
370   if ( ( (uri_string == NULL) || (extract_only) ) 
371        && ( (args[0] == NULL) || (args[1] != NULL) ) )
372     {
373       printf (_
374               ("You must specify one and only one filename for insertion.\n"));
375       ret = -1;
376       return;
377     }
378   if ((uri_string != NULL) && (args[0] != NULL))
379     {
380       printf (_("You must NOT specify an URI and a filename.\n"));
381       ret = -1;
382       return;
383     }
384   if ((uri_string != NULL) && (extract_only))
385     {
386       printf (_("Cannot extract metadata from a URI!\n"));
387       ret = -1;
388       return;
389     }
390   if (pseudonym != NULL)
391     {
392       if (NULL == this_id)
393         {
394           fprintf (stderr,
395                    _("Option `%s' is required when using option `%s'.\n"),
396                    "-t", "-P");
397           ret = -1;
398           return;
399         }
400     }
401   else
402     {                           /* ordinary insertion checks */
403       if (NULL != next_id)
404         {
405           fprintf (stderr,
406                    _("Option `%s' makes no sense without option `%s'.\n"),
407                    "-N", "-P");
408           ret = -1;
409           return;
410         }
411       if (NULL != this_id)
412         {
413           fprintf (stderr,
414                    _("Option `%s' makes no sense without option `%s'.\n"),
415                    "-t", "-P");
416           ret = -1;
417           return;
418         }
419     }
420   if (args[0] == NULL)
421     {
422       fprintf (stderr,
423                _("Need the name of a file to publish!\n"));
424       ret = 1;
425       return;
426     }
427   cfg = c;
428   ctx = GNUNET_FS_start (sched,
429                          cfg,
430                          "gnunet-publish",
431                          &progress_cb,
432                          NULL,
433                          GNUNET_FS_FLAGS_NONE,
434                          GNUNET_FS_OPTIONS_END);
435   if (NULL == ctx)
436     {
437       fprintf (stderr,
438                _("Could not initialize `%s' subsystem.\n"),
439                "FS");
440       ret = 1;
441       return;
442     }
443   namespace = NULL;
444   if (NULL != pseudonym)
445     {
446       namespace = GNUNET_FS_namespace_create (ctx,
447                                               pseudonym);
448       if (NULL == namespace)
449         {
450           fprintf (stderr,
451                    _("Could not create namespace `%s'\n"),
452                    pseudonym);
453           GNUNET_FS_stop (ctx);
454           ret = 1;
455           return;
456         }
457     }
458   if (NULL != uri_string)
459     {      
460       emsg = NULL;
461       uri = GNUNET_FS_uri_parse (uri_string,
462                                  &emsg);
463       if (uri == NULL)
464         {
465           fprintf (stderr, 
466                    _("Failed to parse URI: %s\n"),
467                    emsg);
468           GNUNET_free (emsg);
469           GNUNET_FS_stop (ctx);
470           ret = 1;
471           return;         
472         }
473       GNUNET_FS_publish_ksk (ctx,
474                              topKeywords,
475                              meta,
476                              uri,
477                              GNUNET_TIME_relative_to_absolute (DEFAULT_EXPIRATION),
478                              anonymity,
479                              priority,
480                              GNUNET_FS_PUBLISH_OPTION_NONE,
481                              &uri_ksk_continuation,
482                              NULL);
483       return;
484     }
485   l = NULL;
486   if (! disable_extractor)
487     {
488       l = EXTRACTOR_plugin_add_defaults (EXTRACTOR_OPTION_DEFAULT_POLICY);
489       if (GNUNET_OK ==
490           GNUNET_CONFIGURATION_get_value_string (cfg, "FS", "EXTRACTORS",
491                                                  &ex))
492         {
493           if (strlen (ex) > 0)
494             l = EXTRACTOR_plugin_add_config (l, ex, EXTRACTOR_OPTION_DEFAULT_POLICY);
495           GNUNET_free (ex);
496         }
497     }
498   emsg = NULL;
499   if (0 != STAT (args[0], &sbuf))
500     {
501       GNUNET_asprintf (&emsg,
502                        _("Could not access file: %s\n"),
503                        STRERROR (errno));
504       fi = NULL;
505     }
506   else if (S_ISDIR (sbuf.st_mode))
507     {
508       fi = GNUNET_FS_file_information_create_from_directory (NULL,
509                                                              args[0],
510                                                              &GNUNET_FS_directory_scanner_default,
511                                                              l,
512                                                              !do_insert,
513                                                              anonymity,
514                                                              priority,
515                                                              GNUNET_TIME_relative_to_absolute (DEFAULT_EXPIRATION),
516                                                              &emsg);
517     }
518   else
519     {
520       fi = GNUNET_FS_file_information_create_from_file (NULL,
521                                                         args[0],
522                                                         NULL,
523                                                         NULL,
524                                                         !do_insert,
525                                                         anonymity,
526                                                         priority,
527                                                         GNUNET_TIME_relative_to_absolute (DEFAULT_EXPIRATION));
528       GNUNET_break (fi != NULL);
529     }
530   EXTRACTOR_plugin_remove_all (l);  
531   if (fi == NULL)
532     {
533       fprintf (stderr,
534                _("Could not publish `%s': %s\n"),
535                args[0],
536                emsg);
537       GNUNET_free (emsg);
538       if (namespace != NULL)
539         GNUNET_FS_namespace_delete (namespace, GNUNET_NO);
540       GNUNET_FS_stop (ctx);
541       ret = 1;
542       return;
543     }
544   GNUNET_FS_file_information_inspect (fi,
545                                       &publish_inspector,
546                                       NULL);
547   if (extract_only)
548     {
549       if (namespace != NULL)
550         GNUNET_FS_namespace_delete (namespace, GNUNET_NO);
551       GNUNET_FS_file_information_destroy (fi, NULL, NULL);
552       GNUNET_FS_stop (ctx);
553       return;
554     }
555   pc = GNUNET_FS_publish_start (ctx,
556                                 fi,
557                                 namespace,
558                                 this_id,
559                                 next_id,
560                                 (do_simulate) 
561                                 ? GNUNET_FS_PUBLISH_OPTION_SIMULATE_ONLY
562                                 : GNUNET_FS_PUBLISH_OPTION_NONE);
563   if (NULL == pc)
564     {
565       fprintf (stderr,
566                _("Could not start publishing.\n"));
567       GNUNET_FS_stop (ctx);
568       ret = 1;
569       return;
570     }
571   kill_task = GNUNET_SCHEDULER_add_delayed (sched,
572                                             GNUNET_TIME_UNIT_FOREVER_REL,
573                                             &do_stop_task,
574                                             NULL);
575 }
576
577
578 /**
579  * gnunet-publish command line options
580  */
581 static struct GNUNET_GETOPT_CommandLineOption options[] = {
582   {'a', "anonymity", "LEVEL",
583    gettext_noop ("set the desired LEVEL of sender-anonymity"),
584    1, &GNUNET_GETOPT_set_uint, &anonymity},
585   {'d', "disable-creation-time", NULL,
586    gettext_noop
587    ("disable adding the creation time to the metadata of the uploaded file"),
588    0, &GNUNET_GETOPT_set_one, &do_disable_creation_time},
589   {'D', "disable-extractor", NULL,
590    gettext_noop
591    ("do not use libextractor to add keywords or metadata"),
592    0, &GNUNET_GETOPT_set_one, &disable_extractor},
593   {'e', "extract", NULL,
594    gettext_noop
595    ("print list of extracted keywords that would be used, but do not perform upload"),
596    0, &GNUNET_GETOPT_set_one, &extract_only},
597   {'k', "key", "KEYWORD",
598    gettext_noop
599    ("add an additional keyword for the top-level file or directory"
600     " (this option can be specified multiple times)"),
601    1, &GNUNET_FS_getopt_set_keywords, &topKeywords},
602   // *: option not yet used... (can handle in a pass over FI)
603   {'m', "meta", "TYPE:VALUE",
604    gettext_noop ("set the meta-data for the given TYPE to the given VALUE"),
605    1, &GNUNET_FS_getopt_set_metadata, &meta},
606   {'n', "noindex", NULL,
607    gettext_noop ("do not index, perform full insertion (stores entire "
608                  "file in encrypted form in GNUnet database)"),
609    0, &GNUNET_GETOPT_set_one, &do_insert},
610   {'N', "next", "ID",
611    gettext_noop
612    ("specify ID of an updated version to be published in the future"
613     " (for namespace insertions only)"),
614    1, &GNUNET_GETOPT_set_string, &next_id},
615   {'p', "priority", "PRIORITY",
616    gettext_noop ("specify the priority of the content"),
617    1, &GNUNET_GETOPT_set_uint, &priority},
618   {'P', "pseudonym", "NAME",
619    gettext_noop
620    ("publish the files under the pseudonym NAME (place file into namespace)"),
621    1, &GNUNET_GETOPT_set_string, &pseudonym},
622   // *: option not yet used... (need FS API support!)
623   {'s', "simulate-only", NULL,
624    gettext_noop ("only simulate the process but do not do any "
625                  "actual publishing (useful to compute URIs)"),
626    0, &GNUNET_GETOPT_set_one, &do_simulate},
627   {'t', "this", "ID",
628    gettext_noop ("set the ID of this version of the publication"
629                  " (for namespace insertions only)"),
630    1, &GNUNET_GETOPT_set_string, &this_id},
631   // *: option not yet used... (need FS API support!)
632   {'u', "uri", "URI",
633    gettext_noop ("URI to be published (can be used instead of passing a "
634                  "file to add keywords to the file with the respective URI)"),
635    1, &GNUNET_GETOPT_set_string, &uri_string}, 
636   {'V', "verbose", NULL,
637    gettext_noop ("be verbose (print progress information)"),
638    0, &GNUNET_GETOPT_set_one, &verbose},
639   GNUNET_GETOPT_OPTION_END
640 };
641
642
643 /**
644  * The main function to publish content to GNUnet.
645  *
646  * @param argc number of arguments from the command line
647  * @param argv command line arguments
648  * @return 0 ok, 1 on error
649  */
650 int
651 main (int argc, char *const *argv)
652 {
653   return (GNUNET_OK ==
654           GNUNET_PROGRAM_run (argc,
655                               argv,
656                               "gnunet-publish",
657                               gettext_noop
658                               ("Publish files on GNUnet."),
659                               options, &run, NULL)) ? ret : 1;
660 }
661
662 /* end of gnunet-publish.c */
663
664 ////////////////////////////////////////////////////////////////
665
666 #if 0
667 /**
668  * Print progess message.
669  */
670 static void *
671 printstatus (void *ctx, const GNUNET_FSUI_Event * event)
672 {
673   unsigned long long delta;
674   char *fstring;
675
676   switch (event->type)
677     {
678     case GNUNET_FSUI_upload_progress:
679       if (*verboselevel)
680         {
681           char *ret;
682           GNUNET_CronTime now;
683
684           now = GNUNET_get_time ();
685           delta = event->data.UploadProgress.eta - now;
686           if (event->data.UploadProgress.eta < now)
687             delta = 0;
688           ret = GNUNET_get_time_interval_as_fancy_string (delta);
689           PRINTF (_("%16llu of %16llu bytes inserted "
690                     "(estimating %6s to completion) - %s\n"),
691                   event->data.UploadProgress.completed,
692                   event->data.UploadProgress.total,
693                   ret, event->data.UploadProgress.filename);
694           GNUNET_free (ret);
695         }
696       break;
697     case GNUNET_FSUI_upload_completed:
698       if (*verboselevel)
699         {
700           delta = GNUNET_get_time () - start_time;
701           PRINTF (_("Upload of `%s' complete, "
702                     "%llu bytes took %llu seconds (%8.3f KiB/s).\n"),
703                   event->data.UploadCompleted.filename,
704                   event->data.UploadCompleted.total,
705                   delta / GNUNET_CRON_SECONDS,
706                   (delta == 0)
707                   ? (double) (-1.0)
708                   : (double) (event->data.UploadCompleted.total
709                               / 1024.0 * GNUNET_CRON_SECONDS / delta));
710         }
711       fstring = GNUNET_ECRS_uri_to_string (event->data.UploadCompleted.uri);
712       printf (_("File `%s' has URI: %s\n"),
713               event->data.UploadCompleted.filename, fstring);
714       GNUNET_free (fstring);
715       if (ul == event->data.UploadCompleted.uc.pos)
716         {
717           postProcess (event->data.UploadCompleted.uri);
718           errorCode = 0;
719           GNUNET_shutdown_initiate ();
720         }
721       break;
722     case GNUNET_FSUI_upload_aborted:
723       printf (_("\nUpload aborted.\n"));
724       errorCode = 2;
725       GNUNET_shutdown_initiate ();
726       break;
727     case GNUNET_FSUI_upload_error:
728       printf (_("\nError uploading file: %s"),
729               event->data.UploadError.message);
730       errorCode = 3;
731       GNUNET_shutdown_initiate ();
732       break;
733     case GNUNET_FSUI_upload_started:
734     case GNUNET_FSUI_upload_stopped:
735       break;
736     default:
737       printf (_("\nUnexpected event: %d\n"), event->type);
738       GNUNET_GE_BREAK (ectx, 0);
739       break;
740     }
741   return NULL;
742 }
743 #endif
744
745 /* end of gnunet-publish.c */