x*: fixing whitespaces
[transsip.git] / src / transsip.c
blob9b42fa3eb6a52e0a6c805ba96eeb902a2455d50a
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 * Swiss federal institute of technology (ETH Zurich)
6 * Subject to the GPL, version 2.
7 */
9 #include <sched.h>
10 #include <pthread.h>
12 #include "die.h"
13 #include "xutils.h"
15 extern void enter_shell_loop(int tsocki, int tsocko);
16 extern void *engine_main(void *arg);
18 static pthread_t tid;
19 static struct pipepair pp;
21 static void start_server(int usocki, int usocko)
23 pp.i = usocki;
24 pp.o = usocko;
25 int ret = pthread_create(&tid, NULL, engine_main, &pp);
26 if (ret)
27 panic("Cannot create server thread!\n");
30 static void stop_server(void)
32 pthread_join(tid, NULL);
35 int main(void)
37 int ret;
38 int efd[2], refd[2];
39 struct sched_param param;
41 ret = pipe(efd);
42 if (ret < 0)
43 panic("Cannot create event fd!\n");
44 ret = pipe(refd);
45 if (ret < 0)
46 panic("Cannot create event fd!\n");
48 param.sched_priority = sched_get_priority_min(SCHED_FIFO);
49 sched_setscheduler(0, SCHED_FIFO, &param);
51 start_server(efd[0], refd[1]);
52 enter_shell_loop(refd[0], efd[1]);
53 stop_server();
55 close(efd[0]);
56 close(efd[1]);
57 close(refd[0]);
58 close(refd[1]);
60 return 0;