-
Notifications
You must be signed in to change notification settings - Fork 0
/
commandline.cc
77 lines (69 loc) · 2.27 KB
/
commandline.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
/* Copyright (C) 2005 Jaap Taal and Marcel Vlastuin.
This file is part of the Caia project. This project can be
downloaded from the website www.codecup.nl. You can email to
[email protected] or write to Marcel Vlastuin, Perenstraat 40,
2564 SE Den Haag, The Netherlands.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; see the file COPYING. If not, write to
the Free Software Foundation, 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
#include <stdlib.h>
#include <string.h>
#include "manager.h"
#include "commandline.h"
#include "prflush.h"
#include "debug.h"
commandflag command_parse_token(const char * const word)
{
commandflag r;
if (!strcmp(word, STR_CMD_MANAGER)) r = CMD_MANAGER;
else if (!strcmp(word, STR_CMD_MANAGER_FILE)) r = CMD_MANAGER_FILE;
else if (!strcmp(word, STR_CMD_DEBUG)) r = CMD_DEBUG;
else r = CMD_UNKNOWN;
return r;
}
void commandline(int argc, char *argv[])
{
int i;
commandflag cmd;
for (i = 1; i < argc; i++)
{
cmd = command_parse_token(argv[i]);
switch (cmd)
{
case CMD_MANAGER:
if (cmd_manager != NULL)
{
delete cmd_manager;
}
cmd_manager = new char[strlen(argv[++i])+1];
strcpy(cmd_manager, argv[i]);
// debug("** Commando voor de manager: %s\n", argv[i]);
break;
case CMD_MANAGER_FILE:
if (cmd_manager_file != NULL)
{
delete cmd_manager_file;
}
cmd_manager_file = new char[strlen(argv[++i])+1];
strcpy(cmd_manager_file, argv[i]);
// debug("** Instructie bestand voor de manager: %s\n", argv[i]);
break;
case CMD_DEBUG:
debug_flag = 1;
debug(DEBUG_ON);
break;
default:
fprflush(stderr, "Non-existing option is used\n");
exit(1);
}
}
}