parser seems to work
[sip-router] / main.c
1 /*
2  * $Id$
3  */
4
5 #include <stdio.h>
6 #include <errno.h>
7 #include <string.h>
8
9 #include "dprint.h"
10 #include "route.h"
11
12 #define CFG_FILE "./sip_router.cfg"
13
14
15 /* debuging function */
16
17 void receive_stdin_loop()
18 {
19         #define BSIZE 1024
20         char buf[BSIZE+1];
21         int len;
22         
23         while(1){
24                 len=fread(buf,1,BSIZE,stdin);
25                 buf[len+1]=0;
26                 receive_msg(buf, len);
27                 printf("-------------------------\n");
28         }
29 }
30
31
32
33 int main(int argc, char** argv)
34 {
35
36         char * cfg_file;
37         FILE* cfg_stream;
38
39         cfg_file=CFG_FILE;
40         
41         /* process command line (get port no, cfg. file path etc) */
42         /* ...*/
43
44         /* load config file or die */
45         cfg_stream=fopen (cfg_file, "r");
46         if (cfg_stream==0){
47                 DPrint("ERROR: could not load config file: %s\n", strerror(errno));
48                 goto error;
49         }
50
51         if (cfg_parse_stream(cfg_stream)!=0){
52                 DPrint("ERROR: config parser failure\n");
53                 goto error;
54         }
55         
56                 
57         print_rl();
58
59
60
61         /* start/init other processes/threads ? */
62
63         /* receive loop */
64
65         receive_stdin_loop();
66
67
68 error:
69         return -1;
70
71 }