/[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.1.1.1 - (hide annotations) (vendor branch)
Tue Jun 6 03:41:38 2006 UTC (19 years, 9 months ago) by sysadm
Branch: GNU
CVS Tags: arelease
Changes since 1.1: +0 -0 lines
Content type: text/x-csrc
no message

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     { "--gsscope", offsetof(t_param,scope_file), conf_type_str, 0, D2GS_SCOPE_CONF_FILE},
50     { "-l", offsetof(t_param,logfile), conf_type_str, 0, NULL },
51     { "-h", offsetof(t_param,help), conf_type_bool,0, NULL },
52     { "--help", offsetof(t_param,help), conf_type_bool,0, NULL },
53     { "-v", offsetof(t_param,version), conf_type_bool,0, NULL },
54     { "--version", offsetof(t_param,version), conf_type_bool,0, NULL },
55     { "-f", offsetof(t_param,foreground), conf_type_bool,0, NULL },
56     { "--foreground",offsetof(t_param,foreground), conf_type_bool,0, NULL },
57     { "-D", offsetof(t_param,debugmode), conf_type_bool,0, NULL },
58     { "--debug", offsetof(t_param,debugmode), conf_type_bool,0, NULL },
59     #ifdef WIN32
60     { "--service", offsetof(t_param,run_as_service),conf_type_bool,0, NULL },
61     { "-s", offsetof(t_param,make_service), conf_type_str, 0, NULL },
62     #endif
63     { NULL, 0, conf_type_none,0, NULL }
64     };
65    
66     static t_param cmdline_param;
67    
68     static char help_message[]="\n"
69     "Usage: d2cs [<options>]\n"
70     " -m <FILE>: set memory debug logging file to FILE\n"
71     " -c <FILE>: set configuration file to FILE\n"
72     " -l <FILE>: set log to FILE\n"
73     " -h, --help: show this help message and exit\n"
74     " -v, --version: show version information and exit\n"
75     " -f, --foreground: start in foreground mode (don`t daemonize)\n"
76     " -D, --debug: run in debug mode (run in foreground and log to stdout)\n"
77     #ifdef WIN32
78     " Running as service functions:\n"
79     " --service run as service\n"
80     " -s install install service\n"
81     " -s uninstall uninstall service\n"
82     #endif
83     "\n"
84     "Notes:\n"
85     " 1.You should always use absolute path here for all FILE names\n";
86    
87     extern void cmdline_show_help(void)
88     {
89     fputs(help_message,stderr);
90     return;
91     }
92    
93     extern void cmdline_show_version(void)
94     {
95     fputs(D2CS_VERSION,stderr);
96     fputs("\n\n",stderr);
97     return;
98     }
99    
100     extern int cmdline_parse(int argc, char ** argv)
101     {
102     memset(&cmdline_param,0, sizeof(cmdline_param));
103     if (conf_parse_param(argc, argv, param_conf_table, &cmdline_param, sizeof(cmdline_param))<0) {
104     return -1;
105     }
106     return 0;
107     }
108    
109     extern int cmdline_cleanup(void)
110     {
111     return conf_cleanup(param_conf_table, &cmdline_param, sizeof(cmdline_param));
112     }
113    
114     extern char const * cmdline_get_prefs_file(void)
115     {
116     return cmdline_param.prefs_file;
117     }
118    
119     extern char const * cmdline_get_gsscope_file(void)
120     {
121     return cmdline_param.scope_file;
122     }
123    
124     extern unsigned int cmdline_get_help(void)
125     {
126     return cmdline_param.help;
127     }
128    
129     extern unsigned int cmdline_get_version(void)
130     {
131     return cmdline_param.version;
132     }
133    
134     extern unsigned int cmdline_get_foreground(void)
135     {
136     return cmdline_param.foreground;
137     }
138    
139     extern unsigned int cmdline_get_debugmode(void)
140     {
141     return cmdline_param.debugmode;
142     }
143    
144     extern char const * cmdline_get_logfile(void)
145     {
146     return cmdline_param.logfile;
147     }
148    
149     #ifdef WIN32
150     extern unsigned int cmdline_get_run_as_service(void)
151     {
152     return cmdline_param.run_as_service;
153     }
154    
155     extern char const * cmdline_get_make_service(void)
156     {
157     return cmdline_param.make_service;
158     }
159    
160     #endif

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