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

Contents of /pvpgn-1.7.4/src/d2dbs/cmdline_parse.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1.1.1 - (show annotations) (vendor branch)
Tue Jun 6 03:41:38 2006 UTC (19 years, 9 months ago) by sysadm
Branch: GNU, MAIN
CVS Tags: arelease, HEAD
Changes since 1.1: +0 -0 lines
Content type: text/x-csrc
no message

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

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