Fixing basic cokebank to actually work
[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(const char *Argument);    // 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 char    *gsCokebankPath = "cokebank.db";
26
27 // === CODE ===
28 int main(int argc, char *argv[])
29 {
30          int    i;
31         
32         // Parse Arguments
33         for( i = 1; i < argc; i++ )
34         {
35                 char    *arg = argv[i];
36                 if( arg[0] == '-' && arg[1] != '-')
37                 {
38                         switch(arg[1])
39                         {
40                         case 'p':
41                                 giServer_Port = atoi(argv[++i]);
42                                 break;
43                         case 'd':
44                                 giDebugLevel = atoi(argv[++i]);
45                                 break;
46                         default:
47                                 // Usage Error?
48                                 break;
49                         }
50                 }
51                 else if( arg[0] == '-' && arg[1] == '-' ) {
52                         if( strcmp(arg, "--itemsfile") == 0 ) {
53                                 gsItemListFile = argv[++i];
54                         }
55                         if( strcmp(arg, "--cokeport") == 0 ) {
56                                 gsCoke_SerialPort = argv[++i];
57                         }
58                         else {
59                                 // Usage error?
60                         }
61                 }
62                 else {
63                         // Usage Error?
64                 }
65         }
66         
67         Init_Cokebank(gsCokebankPath);
68         
69         Load_Itemlist();
70         
71         Server_Start();
72         
73         return 0;
74 }
75

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