summaryrefslogtreecommitdiff
path: root/src/bin/config.c
blob: 192feb0d4ce73c1ba1daf6c3752642f5e237d9f7 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#include "smman.h"

void
config_done(void *data,
            Conf *conf)
{
   Smman *smman;
   Eina_Iterator *it;
   char *s;

   smman = data;

   it = eina_hash_iterator_tuple_new(conf_variables_get(conf));
   while (eina_iterator_next(it, &data))
     {
        const char *variable,
                   *value;
        Eina_Hash_Tuple *t = data;

        variable = t->key;
        value = t->data;

        if (!strcmp("server", variable))
          smman->cfg.server = strdup(value);
        else if (!strcmp("host", variable))
          smman->cfg.host = strdup(value);
     }

   DBG("Server = %s", smman->cfg.server);
   DBG("Host = %s", smman->cfg.host);
   eina_iterator_free(it);

   s = sdupf("%s%s%s",
             smman->cfg.server,
             (smman->cfg.server[strlen(smman->cfg.server)-1] == '/') ?
                "" : "/",
             "logs/");
   smman->store = store_new(s);
   free(s);
}

void
config_error(void *data EINA_UNUSED,
             Conf *conf EINA_UNUSED,
             const char *errstr)
{
   ERR("Failed to load /etc/smman/smman.conf : %s", errstr);
   ecore_main_loop_quit();
}