/[LeafOK_CVS]/pvpgn-1.7.4/src/d2cs/cmdline_parse.c
ViewVC logotype

Annotation of /pvpgn-1.7.4/src/d2cs/cmdline_parse.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.2 - (hide annotations)
Tue Jun 13 16:07:52 2006 UTC (19 years, 9 months ago) by sysadm
Branch: MAIN
CVS Tags: pvpgn_1-7-4-0_MIL, HEAD
Changes since 1.1: +9 -1 lines
Content type: text/x-csrc
Antibot (for non-password protected game)

1 sysadm 1.1 /*
2     * Copyright (C) 2000,2001 Onlyer (onlyer@263.net)
3     *
4     * This program is free software; you can redistribute it and/or
5     * modify it under the terms of the GNU General Public License
6     * as published by the Free Software Foundation; either version 2
7     * of the License, or (at your option) any later version.
8     *
9     * This program is distributed in the hope that it will be useful,
10     * but WITHOUT ANY WARRANTY; without even the implied warranty of
11     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12     * GNU General Public License for more details.
13     *
14     * You should have received a copy of the GNU General Public License
15     * along with this program; if not, write to the Free Software
16     * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17     */
18     #include "common/setup_before.h"
19     #include "setup.h"
20    
21     #ifdef HAVE_STDDEF_H
22     # include <stddef.h>
23     #else
24     # ifndef NULL
25     # define NULL ((void *)0)
26     # endif
27     #endif
28     #include <stdio.h>
29     #ifdef HAVE_STRING_H
30     # include <string.h>
31     #else
32     # ifdef HAVE_STRINGS_H
33     # include <strings.h>
34     # endif
35     # ifdef HAVE_MEMORY_H
36     # include <memory.h>
37     # endif
38     #endif
39     #include "compat/memset.h"
40    
41     #include "conf.h"
42     #include "version.h"
43     #include "cmdline_parse.h"
44     #include "common/eventlog.h"
45     #include "common/setup_after.h"
46    
47     static t_conf_table param_conf_table[]={
48     { "-c", offsetof(t_param,prefs_file), conf_type_str, 0, D2CS_DEFAULT_CONF_FILE},
49 sysadm 1.2 { "--gsscope", offsetof(t_param,scope_file), conf_type_str, 0, D2GS_SCOPE_CONF_FILE },
50     { "--charstatus",offsetof(t_param,cs_file), conf_type_str, 0, CHAR_STATUS_DUMP_FILE },
51 sysadm 1.1 { "-l", offsetof(t_param,logfile), conf_type_str, 0, NULL },
52     { "-h", offsetof(t_param,help), conf_type_bool,0, NULL },
53     { "--help", offsetof(t_param,help), conf_type_bool,0, NULL },
54     { "-v", offsetof(t_param,version), conf_type_bool,0, NULL },
55     { "--version", offsetof(t_param,version), conf_type_bool,0, NULL },
56     { "-f", offsetof(t_param,foreground), conf_type_bool,0, NULL },
57     { "--foreground",offsetof(t_param,foreground), conf_type_bool,0, NULL },
58     { "-D", offsetof(t_param,debugmode), conf_type_bool,0, NULL },
59     { "--debug", offsetof(t_param,debugmode), conf_type_bool,0, NULL },
60     #ifdef WIN32
61     { "--service", offsetof(t_param,run_as_service),conf_type_bool,0, NULL },
62     { "-s", offsetof(t_param,make_service), conf_type_str, 0, NULL },
63     #endif
64     { NULL, 0, conf_type_none,0, NULL }
65     };
66    
67     static t_param cmdline_param;
68    
69     static char help_message[]="\n"
70     "Usage: d2cs [<options>]\n"
71     " -m <FILE>: set memory debug logging file to FILE\n"
72 sysadm 1.2 " --gsscope <FILE>: set game server scope configuration file to FILE\n"
73     " --charstatus <FILE>: set character status dump file to FILE\n"
74 sysadm 1.1 " -c <FILE>: set configuration file to FILE\n"
75     " -l <FILE>: set log to FILE\n"
76     " -h, --help: show this help message and exit\n"
77     " -v, --version: show version information and exit\n"
78     " -f, --foreground: start in foreground mode (don`t daemonize)\n"
79     " -D, --debug: run in debug mode (run in foreground and log to stdout)\n"
80     #ifdef WIN32
81     " Running as service functions:\n"
82     " --service run as service\n"
83     " -s install install service\n"
84     " -s uninstall uninstall service\n"
85     #endif
86     "\n"
87     "Notes:\n"
88     " 1.You should always use absolute path here for all FILE names\n";
89    
90     extern void cmdline_show_help(void)
91     {
92     fputs(help_message,stderr);
93     return;
94     }
95    
96     extern void cmdline_show_version(void)
97     {
98     fputs(D2CS_VERSION,stderr);
99     fputs("\n\n",stderr);
100     return;
101     }
102    
103     extern int cmdline_parse(int argc, char ** argv)
104     {
105     memset(&cmdline_param,0, sizeof(cmdline_param));
106     if (conf_parse_param(argc, argv, param_conf_table, &cmdline_param, sizeof(cmdline_param))<0) {
107     return -1;
108     }
109     return 0;
110     }
111    
112     extern int cmdline_cleanup(void)
113     {
114     return conf_cleanup(param_conf_table, &cmdline_param, sizeof(cmdline_param));
115     }
116    
117     extern char const * cmdline_get_prefs_file(void)
118     {
119     return cmdline_param.prefs_file;
120     }
121    
122     extern char const * cmdline_get_gsscope_file(void)
123     {
124     return cmdline_param.scope_file;
125     }
126    
127 sysadm 1.2 extern char const * cmdline_get_charstatus_file(void)
128     {
129     return cmdline_param.cs_file;
130     }
131    
132 sysadm 1.1 extern unsigned int cmdline_get_help(void)
133     {
134     return cmdline_param.help;
135     }
136    
137     extern unsigned int cmdline_get_version(void)
138     {
139     return cmdline_param.version;
140     }
141    
142     extern unsigned int cmdline_get_foreground(void)
143     {
144     return cmdline_param.foreground;
145     }
146    
147     extern unsigned int cmdline_get_debugmode(void)
148     {
149     return cmdline_param.debugmode;
150     }
151    
152     extern char const * cmdline_get_logfile(void)
153     {
154     return cmdline_param.logfile;
155     }
156    
157     #ifdef WIN32
158     extern unsigned int cmdline_get_run_as_service(void)
159     {
160     return cmdline_param.run_as_service;
161     }
162    
163     extern char const * cmdline_get_make_service(void)
164     {
165     return cmdline_param.make_service;
166     }
167    
168     #endif

webmaster@leafok.com
ViewVC Help
Powered by ViewVC 1.3.0-beta1