mailmap: add mail alias
[transsip-mirror.git] / src / transsip.c
blob4ecf14433eb1f1949697bbf9fb864321ccf0725e
1 /*
2 * transsip - the telephony toolkit
3 * By Daniel Borkmann <daniel@transsip.org>
4 * Copyright 2011, 2012 Daniel Borkmann <dborkma@tik.ee.ethz.ch>
5 * Subject to the GPL, version 2.
6 */
8 #include <sched.h>
9 #include <pthread.h>
11 #include "die.h"
12 #include "xutils.h"
14 extern void enter_shell_loop(int tsocki, int tsocko);
15 extern void *engine_main(void *arg);
17 static pthread_t tid;
18 static struct pipepair pp;
20 static void start_server(int usocki, int usocko)
22 pp.i = usocki;
23 pp.o = usocko;
24 int ret = pthread_create(&tid, NULL, engine_main, &pp);
25 if (ret)
26 panic("Cannot create server thread!\n");
29 static void stop_server(void)
31 pthread_join(tid, NULL);
34 int main(void)
36 int ret;
37 int efd[2], refd[2];
38 struct sched_param param;
40 ret = pipe(efd);
41 if (ret < 0)
42 panic("Cannot create event fd!\n");
43 ret = pipe(refd);
44 if (ret < 0)
45 panic("Cannot create event fd!\n");
47 param.sched_priority = sched_get_priority_min(SCHED_FIFO);
48 sched_setscheduler(0, SCHED_FIFO, &param);
50 start_server(efd[0], refd[1]);
51 enter_shell_loop(refd[0], efd[1]);
52 stop_server();
54 close(efd[0]);
55 close(efd[1]);
56 close(refd[0]);
57 close(refd[1]);
59 return 0;