⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gnunet-insert.c

📁 GNUnet是一个安全的点对点网络框架
💻 C
📖 第 1 页 / 共 2 页
字号:
   gettext_noop   ("disable adding the creation time to the metadata of the uploaded file"),   0, &GNUNET_getopt_configure_set_one, &do_disable_creation_time},  {'D', "disable-direct", NULL,   gettext_noop   ("do not use libextractor to add additional references to directory entries and/or the published file"),   0, &GNUNET_getopt_configure_set_one, &do_no_direct_references},  {'e', "extract", NULL,   gettext_noop   ("print list of extracted keywords that would be used, but do not perform upload"),   0, &GNUNET_getopt_configure_set_one, &extract_only},  GNUNET_COMMAND_LINE_OPTION_HELP (gettext_noop ("Make files available to GNUnet for sharing.")),       /* -h */  GNUNET_COMMAND_LINE_OPTION_HOSTNAME,  /* -H */  {'k', "key", "KEYWORD",   gettext_noop   ("add an additional keyword for the top-level file or directory"    " (this option can be specified multiple times)"),   1, &GNUNET_ECRS_getopt_configure_set_keywords, &topKeywords},  {'K', "global-key", "KEYWORD",   gettext_noop ("add an additional keyword for all files and directories"                 " (this option can be specified multiple times)"),   1, &GNUNET_ECRS_getopt_configure_set_keywords, &gloKeywords},  GNUNET_COMMAND_LINE_OPTION_LOGGING,   /* -L */  {'m', "meta", "TYPE:VALUE",   gettext_noop ("set the meta-data for the given TYPE to the given VALUE"),   1, &GNUNET_ECRS_getopt_configure_set_metadata, &meta},  {'n', "noindex", NULL,   gettext_noop ("do not index, perform full insertion (stores entire "                 "file in encrypted form in GNUnet database)"),   0, &GNUNET_getopt_configure_set_one, &do_insert},  {'N', "next", "ID",   gettext_noop   ("specify ID of an updated version to be published in the future"    " (for namespace insertions only)"),   1, &GNUNET_getopt_configure_set_string, &next_id},  {'p', "priority", "PRIORITY",   gettext_noop ("specify the priority of the content"),   1, &GNUNET_getopt_configure_set_uint, &priority},  {'P', "pseudonym", "NAME",   gettext_noop   ("publish the files under the pseudonym NAME (place file into namespace)"),   1, &GNUNET_getopt_configure_set_string, &pseudonym},  {'s', "simulate-only", NULL,   gettext_noop ("only simulte the process but do not do any "                 "actual publishing (useful to compute URIs)"),   0, &GNUNET_getopt_configure_set_one, &do_simulate},  {'t', "this", "ID",   gettext_noop ("set the ID of this version of the publication"                 " (for namespace insertions only)"),   1, &GNUNET_getopt_configure_set_string, &this_id},  {'u', "uri", "URI",   gettext_noop ("URI to be published (can be used instead of passing a "                 "file to add keywords to the file with the respective URI)"),   1, &GNUNET_getopt_configure_set_string, &uri_string},  GNUNET_COMMAND_LINE_OPTION_VERSION (PACKAGE_VERSION), /* -v */  GNUNET_COMMAND_LINE_OPTION_VERBOSE,  GNUNET_COMMAND_LINE_OPTION_END,};/** * The main function to insert files into GNUnet. * * @param argc number of arguments from the command line * @param argv command line arguments * @return return 0 for ok, -1 on error */intmain (int argc, char *const *argv){  const char *filename;  int i;  char *tmp;  unsigned long long verbose;  GNUNET_HashCode pid;  meta = GNUNET_meta_data_create ();  i = GNUNET_init (argc,                   argv,                   "gnunet-insert [OPTIONS] FILENAME",                   &cfgFilename, gnunetinsertOptions, &ectx, &cfg);  if (i == -1)    {      errorCode = -1;      goto quit;    }  if (((uri_string == NULL) || (extract_only)) && (i != argc - 1))    {      printf (_              ("You must specify one and only one filename for insertion.\n"));      errorCode = -1;      goto quit;    }  if ((uri_string != NULL) && (i != argc))    {      printf (_("You must NOT specify an URI and a filename.\n"));      errorCode = -1;      goto quit;    }  if ((uri_string != NULL) && (extract_only))    {      printf (_("Cannot extract metadata from a URI!\n"));      errorCode = -1;      goto quit;    }  if (uri_string == NULL)    filename = argv[i];  else    filename = NULL;  if (extract_only)    {      EXTRACTOR_ExtractorList *l;      char *ex;      char *dirname;      char *fname;      l = EXTRACTOR_loadDefaultLibraries ();      ex = NULL;      GNUNET_GC_get_configuration_value_string (cfg, "FS", "EXTRACTORS", "",                                                &ex);      if (strlen (ex) > 0)        l = EXTRACTOR_loadConfigLibraries (l, ex);      GNUNET_free (ex);      dirname = GNUNET_expand_file_name (ectx, filename);      GNUNET_GE_ASSERT (ectx, dirname != NULL);      while ((strlen (dirname) > 0) &&             (dirname[strlen (dirname) - 1] == DIR_SEPARATOR))        dirname[strlen (dirname) - 1] = '\0';      fname = dirname;      while (strstr (fname, DIR_SEPARATOR_STR) != NULL)        fname = strstr (fname, DIR_SEPARATOR_STR) + 1;      GNUNET_GE_ASSERT (ectx, fname != dirname);      fname[-1] = '\0';      listKeywords (fname, dirname, l);      GNUNET_free (dirname);      EXTRACTOR_removeAll (l);      GNUNET_meta_data_destroy (meta);      meta = NULL;      errorCode = 0;      goto quit;    }  GNUNET_GC_get_configuration_value_number (cfg,                                            "GNUNET",                                            "VERBOSE", 0, 9999, 0, &verbose);  /* check arguments */  if (pseudonym != NULL)    {      if ((GNUNET_OK !=           GNUNET_pseudonym_name_to_id (ectx, cfg,                                        pseudonym, &pid)) ||          (GNUNET_OK != GNUNET_ECRS_namespace_test_exists (ectx, cfg, &pid)))        {          printf (_("Could not access namespace `%s' (does not exist?).\n"),                  pseudonym);          errorCode = -1;          goto quit;        }      if (NULL == this_id)        {          fprintf (stderr,                   _("Option `%s' is required when using option `%s'.\n"),                   "-t", "-P");          errorCode = -1;          goto quit;        }    }  else    {                           /* ordinary insertion checks */      if (NULL != next_id)        {          fprintf (stderr,                   _("Option `%s' makes no sense without option `%s'.\n"),                   "-N", "-P");          errorCode = -1;          goto quit;        }      if (NULL != this_id)        {          fprintf (stderr,                   _("Option `%s' makes no sense without option `%s'.\n"),                   "-t", "-P");          errorCode = -1;          goto quit;        }    }  if (uri_string != NULL)    {      struct GNUNET_ECRS_URI *us        = GNUNET_ECRS_string_to_uri (ectx, uri_string);      if (us == NULL)        {          errorCode = -1;          goto quit;        }      postProcess (us);      if (gloKeywords != NULL)        GNUNET_ECRS_publish_under_keyword (ectx,                                           cfg,                                           gloKeywords,                                           anonymity,                                           priority,                                           start_time + expiration, us, meta);      if (topKeywords != NULL)        GNUNET_ECRS_publish_under_keyword (ectx,                                           cfg,                                           topKeywords,                                           anonymity,                                           priority,                                           start_time + expiration, us, meta);      GNUNET_ECRS_uri_destroy (us);      goto quit;    }  /* fundamental init */  ctx = GNUNET_FSUI_start (ectx, cfg, "gnunet-insert", GNUNET_NO, 32,   /* make configurable */                           &printstatus, &verbose);  /* first insert all of the top-level files or directories */  tmp = GNUNET_expand_file_name (ectx, filename);  if (!do_disable_creation_time)    GNUNET_meta_data_add_publication_date (meta);  start_time = GNUNET_get_time ();  errorCode = 1;  ul = GNUNET_FSUI_upload_start (ctx,                                 tmp,                                 (GNUNET_FSUI_DirectoryScanCallback) &                                 GNUNET_disk_directory_scan, ectx, anonymity,                                 priority,                                 do_simulate ? GNUNET_SYSERR : (!do_insert),                                 GNUNET_YES, !do_no_direct_references,                                 start_time + expiration, meta,                                 gloKeywords, topKeywords);  GNUNET_free (tmp);  if (ul != NULL)    {      GNUNET_shutdown_wait_for ();      if (errorCode == 1)        GNUNET_FSUI_upload_abort (ul);      GNUNET_FSUI_upload_stop (ul);    }  GNUNET_FSUI_stop (ctx);quit:  if (meta != NULL)    GNUNET_meta_data_destroy (meta);  if (gloKeywords != NULL)    GNUNET_ECRS_uri_destroy (gloKeywords);  if (topKeywords != NULL)    GNUNET_ECRS_uri_destroy (topKeywords);  GNUNET_fini (ectx, cfg);  return errorCode;}/* end of gnunet-insert.c */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -