3 * UCC (University [of WA] Computer Club) Electronic Accounting System
5 * main.c - Initialisation Code
7 * This file is licenced under the 3-clause BSD Licence. See the file
8 * COPYING for full details.
17 extern void Init_Cokebank(const char *Argument); // cokebank.c
18 extern void Init_Handlers(void);
19 extern void Load_Itemlist(void);
20 extern void Server_Start(void);
21 extern int giServer_Port;
22 extern char* gsItemListFile;
23 extern char* gsCoke_SerialPort;
24 extern char* gsSnack_SerialPort;
28 char *gsCokebankPath = "cokebank.db";
36 int main(int argc, char *argv[])
41 for( i = 1; i < argc; i++ )
44 if( arg[0] == '-' && arg[1] != '-')
49 giServer_Port = atoi(argv[++i]);
52 giDebugLevel = atoi(argv[++i]);
59 else if( arg[0] == '-' && arg[1] == '-' ) {
60 if( strcmp(arg, "--itemsfile") == 0 ) {
61 gsItemListFile = argv[++i];
63 else if( strcmp(arg, "--cokeport") == 0 ) {
64 gsCoke_SerialPort = argv[++i];
66 else if( strcmp(arg, "--snackport") == 0 ) {
67 gsSnack_SerialPort = argv[++i];
78 signal(SIGINT, sigint_handler);
80 Init_Cokebank(gsCokebankPath);
92 int RunRegex(regex_t *regex, const char *string, int nMatches, regmatch_t *matches, const char *errorMessage)
96 ret = regexec(regex, string, nMatches, matches, 0);
98 size_t len = regerror(ret, regex, NULL, 0);
100 regerror(ret, regex, errorStr, len);
101 printf("string = '%s'\n", string);
102 fprintf(stderr, "%s\n%s", errorMessage, errorStr);
109 void CompileRegex(regex_t *regex, const char *pattern, int flags)
111 int ret = regcomp(regex, pattern, flags);
113 size_t len = regerror(ret, regex, NULL, 0);
115 regerror(ret, regex, errorStr, len);
116 fprintf(stderr, "Regex compilation failed - %s\n", errorStr);