40     ev_break(loop, EVBREAK_ALL);
 
   51         while ((name++)[0] != 
'-');
 
   56                 LOG_DEBUG(
"Module '%s' did not recognise the option '%s'.", module->
id, name);
 
   57                 return ARGP_ERR_UNKNOWN;
 
   67             LOG_WARN(
"Configuration files are still very much in an early alpha state.");
 
   69             FILE *fp = fopen(arg, 
"rb");
 
   71                 fseek(fp, 0, SEEK_END);
 
   73                 size_t len = (size_t) ftell(fp);
 
   74                 fseek(fp, 0, SEEK_SET);
 
   76                 fread(buffer, 1, len, fp);
 
   84                 for (
char *a = strtok(buffer, 
" \n\t"); a; a = strtok(NULL, 
" ")) {
 
   95             return ARGP_ERR_UNKNOWN;
 
  106     char *name_alloc = NULL, *arg_alloc = NULL, *doc_alloc = NULL;
 
  113     option.name = name_alloc;
 
  115     option.arg = arg_alloc;
 
  116     option.flags = flags;
 
  117     option.doc = doc_alloc;
 
  136     hpd->
loop = ev_loop_new(EVFLAG_AUTO);
 
  144     ev_loop_destroy(hpd->
loop);
 
  156     ev_run(hpd->
loop, 0);
 
  170             goto module_create_error;
 
  174     for (; module; module = TAILQ_PREV(module, hpd_modules, 
HPD_TAILQ_FIELD))
 
  187                 goto module_destroy_error;
 
  192     module_destroy_error:
 
  193     for (; module; module = TAILQ_PREV(module, hpd_modules, 
HPD_TAILQ_FIELD))
 
  213             LOG_ERROR(
"Failed to stop module [code: %i].", rc2);
 
  232             LOG_ERROR(
"Failed to stop module [code: %i].", rc2);
 
  241     if ((rc = 
daemon_add_global_option(hpd, 
"conf", 
'c', 
"file", 0, 
"Load arguments from configuration file"))) 
goto error;
 
  259         free((
void *) option->name);
 
  260         free((
void *) option->arg);
 
  261         free((
void *) option->doc);
 
  275     if (argp_parse(&argp, argc, argv, 0, 0, hpd)) {
 
  276         LOG_DEBUG(
"Error while parsing arguments.");
 
  304     LOG_RETURN(rc, 
"Free function returned an error [code: %i]", rc);
 
  318         else LOG_ERROR(
"free function failed [code: %i]", tmp);
 
  326         else LOG_ERROR(
"free function failed [code: %i]", tmp);
 
  334         else LOG_ERROR(
"free function failed [code: %i]", tmp);
 
  337         else LOG_ERROR(
"free function failed [code: %i]", tmp);
 
  345         else LOG_ERROR(
"free function failed [code: %i]", tmp);
 
  352         else LOG_ERROR(
"free function failed [code: %i]", tmp);
 
  362     TAILQ_INIT(&(*hpd)->modules);
 
  363     TAILQ_INIT(&(*hpd)->request_watchers);
 
  364     TAILQ_INIT(&(*hpd)->respond_watchers);
 
  365     TAILQ_INIT(&(*hpd)->changed_watchers);
 
  366     TAILQ_INIT(&(*hpd)->attached_watchers);
 
  367     TAILQ_INIT(&(*hpd)->detached_watchers);
 
  370     (*hpd)->sigint_watcher.data = hpd;
 
  376             if ((*hpd)->options) 
free((*hpd)->options);
 
  399     module->
def = *module_def;
 
  405     if (module) 
free(module);
 
  416     HPD_CALLOC(name_cat, strlen(name)+strlen(context->
id)+2, 
char);
 
  417     strcpy(name_cat, context->
id);
 
  418     strcat(name_cat, 
"-");
 
  419     strcat(name_cat, name);
 
  450     hpd->
argv0 = argv[0];
 
  473     modules_create_error:
 
  475     options_create_error:
 
  477     runtime_create_error:
 
  486     modules_destroy_error:
 
  488     runtime_destroy_error:
 
  494     ev_break(hpd->
loop, EVBREAK_ALL);
 
const hpd_module_t ** option2module
 
static hpd_error_t daemon_runtime_destroy(hpd_t *hpd)
 
const char ** option2name
 
hpd_error_t discovery_free_adapter(hpd_adapter_t *adapter)
 
static hpd_error_t daemon_options_create(hpd_t *hpd)
 
hpd_parse_opt_f on_parse_opt
 
static hpd_error_t daemon_modules_create(const hpd_t *hpd)
 
#define HPD_STR_CPY(DST, SRC)
 
static void daemon_loop_destroy(hpd_t *hpd)
 
hpd_error_t daemon_stop(const hpd_t *hpd)
 
struct argp_option hpd_argp_option_t
 
#define LOG_RETURN_E_ALLOC()
 
hpd_error_t daemon_get_loop(const hpd_t *hpd, hpd_ev_loop_t **loop)
 
#define HPD_TAILQ_MAP_REMOVE(LIST, FUNC, TYPE, RC)
 
static hpd_error_t daemon_modules_start(hpd_t *hpd)
 
static void daemon_on_signal(hpd_ev_loop_t *loop, ev_signal *w, int revents)
 
static hpd_error_t daemon_runtime_create(hpd_t *hpd)
 
static hpd_error_t daemon_modules_stop(hpd_t *hpd)
 
static void daemon_loop_run(hpd_t *hpd)
 
ev_signal sigterm_watcher
 
hpd_error_t discovery_free_did(hpd_device_id_t *id)
 
hpd_ev_asyncs_t respond_watchers
 
static hpd_error_t daemon_watchers_stop(hpd_t *hpd)
 
hpd_error_t daemon_get_id(const hpd_module_t *context, const char **id)
 
hpd_listeners_t listeners
 
hpd_argp_option_t * options
 
#define HPD_CALLOC(PTR, NUM, CAST)
Allocates and zeros a structure. 
 
hpd_error_t daemon_start(hpd_t *hpd, int argc, char *argv[])
 
hpd_error_t event_free_listener(hpd_listener_t *listener)
 
static hpd_error_t daemon_loop_create(hpd_t *hpd)
 
hpd_configuration_t * configuration
 
hpd_error_t daemon_free(hpd_t *hpd)
 
static hpd_error_t daemon_options_parse(hpd_t *hpd, int argc, char **argv)
 
hpd_error_t daemon_add_option(const hpd_module_t *context, const char *name, const char *arg, int flags, const char *doc)
 
hpd_ev_asyncs_t request_watchers
 
hpd_error_t daemon_add_module(hpd_t *hpd, const char *id, const hpd_module_def_t *module_def)
 
enum hpd_error hpd_error_t
 
[Application API Callbacks] 
 
#define LOG_WARN(FMT,...)
 
hpd_error_t request_free_response(hpd_response_t *response)
 
#define LOG_RETURN(E, FMT,...)
 
#define LOG_DEBUG(FMT,...)
 
static struct ev_loop * loop
 
hpd_ev_asyncs_t changed_watchers
 
hpd_error_t value_free(hpd_value_t *value)
 
static int daemon_on_parse_opt(int key, char *arg, struct argp_state *state)
 
state
The possible states of a request. 
 
hpd_error_t request_free_request(hpd_request_t *request)
 
static hpd_error_t daemon_modules_destroy(const hpd_t *hpd)
 
static hpd_error_t daemon_add_global_option(hpd_t *hpd, const char *name, int key, const char *arg, int flags, const char *doc)
 
hpd_error_t discovery_free_sid(hpd_service_id_t *id)
 
hpd_ev_asyncs_t detached_watchers
 
hpd_ev_asyncs_t attached_watchers
 
struct ev_loop hpd_ev_loop_t
 
static void daemon_options_destroy(hpd_t *hpd)
 
hpd_error_t daemon_alloc(hpd_t **hpd)
 
#define LOG_ERROR(FMT,...)
 
#define HPD_REALLOC(PTR, NUM, CAST)
CAST is for c++ compatibility (tests).