std::map<variant, variant>& get_default_properties() { static std::map<variant, variant> defs; if(defs.empty()) { load_default_properties(&defs); } return defs; }
/** * Main function that will be run by the scheduler. * * @param cls closure * @param args remaining command-line arguments * @param cfgfile name of the configuration file used (for saving, can be NULL!) * @param cfg configuration */ static void run (void *cls, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *mycfg) { struct GNUNET_CONFIGURATION_Handle *properties; char *file; end_task = GNUNET_SCHEDULER_add_delayed(GNUNET_TIME_UNIT_FOREVER_REL, &shutdown_task, NULL); cfg = mycfg; GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "sysdaemon starting ... \n"); if (GNUNET_SYSERR ==GNUNET_CONFIGURATION_get_value_filename (mycfg, "sysmon", "CFGFILE", &file)) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Sysmon configuration file not set, exit! \n"); shutdown_now(); ret = 1; return; } properties = GNUNET_CONFIGURATION_create(); if (NULL == properties) { GNUNET_break (0); shutdown_now(); ret = 1; return; } if (GNUNET_SYSERR == GNUNET_CONFIGURATION_load (properties, file)) { GNUNET_break (0); GNUNET_CONFIGURATION_destroy (properties); GNUNET_free (file); ret = 1; shutdown_now(); return; } GNUNET_free (file); GNUNET_CONFIGURATION_iterate_sections (properties, &load_property, properties); GNUNET_CONFIGURATION_destroy (properties); /* Creating statistics */ stats = GNUNET_STATISTICS_create ("sysmon", mycfg); if (NULL == stats) { GNUNET_break (0); shutdown_now(); ret = 1; return; } /* load properties */ if (GNUNET_SYSERR == load_default_properties ()) { GNUNET_break (0); shutdown_now(); ret = 1; return; } /* run properties */ if (GNUNET_SYSERR == run_properties ()) { GNUNET_break (0); shutdown_now(); ret = 1; return; } }