e789b1306115e4c52701532ace86ec43386fd541
[tpg/opendispense2.git] / src / server / main.c
1 /*
2  * OpenDispense 2 
3  * UCC (University [of WA] Computer Club) Electronic Accounting System
4  *
5  * main.c - Initialisation Code
6  *
7  * This file is licenced under the 3-clause BSD Licence. See the file
8  * COPYING for full details.
9  */
10 #include <stdlib.h>
11 #include <stdio.h>
12 #include <string.h>
13 #include "common.h"
14
15 // === IMPORTS ===
16 extern void     Init_Cokebank(void);    // cokebank.c
17 extern void     Load_Itemlist(void);
18 extern void     Server_Start(void);
19 extern int      giServer_Port;
20 extern char*    gsItemListFile;
21 extern char*    gsCoke_SerialPort;
22
23 // === GLOBALS ===
24  int    giDebugLevel = 0;
25
26 // === CODE ===
27 int main(int argc, char *argv[])
28 {
29          int    i;
30         
31         // Parse Arguments
32         for( i = 1; i < argc; i++ )
33         {
34                 char    *arg = argv[i];
35                 if( arg[0] == '-' && arg[1] != '-')
36                 {
37                         switch(arg[1])
38                         {
39                         case 'p':
40                                 giServer_Port = atoi(argv[++i]);
41                                 break;
42                         case 'd':
43                                 giDebugLevel = atoi(argv[++i]);
44                                 break;
45                         default:
46                                 // Usage Error?
47                                 break;
48                         }
49                 }
50                 else if( arg[0] == '-' && arg[1] == '-' ) {
51                         if( strcmp(arg, "--itemsfile") == 0 ) {
52                                 gsItemListFile = argv[++i];
53                         }
54                         if( strcmp(arg, "--cokeport") == 0 ) {
55                                 gsCoke_SerialPort = argv[++i];
56                         }
57                         else {
58                                 // Usage error?
59                         }
60                 }
61                 else {
62                         // Usage Error?
63                 }
64         }
65         
66         Init_Cokebank();
67         
68         Load_Itemlist();
69         
70         Server_Start();
71         
72         return 0;
73 }
74

UCC git Repository :: git.ucc.asn.au