summaryrefslogtreecommitdiffstats
path: root/src/protocol-native-unix.c
blob: a18965cdd86ef44524160155f82d3a7eccc103f0 (plain)
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
#include "module.h"

int module_init(struct core *c, struct module*m) {
    struct fn[PATH_MAX];
    struct socket_server *s;
    char *t;
    assert(c && m);

    if (!(t = getenv("TMP")))
        if (!(t = getenv("TEMP")))
            t = "/tmp";
    
    snprintf(fn, sizeof(fn), "%s/foosock", t);
             
    if (!(s = socket_server_new_unix(c->mainloop, fn)))
        return -1;

    m->userdata = protocol_native_new(s);
    assert(m->userdata);
    return 0;
}

void module_done(struct core *c, struct module*m) {
    assert(c && m);

    protocol_native_free(m->userdata);
}