Fix LP64 bugs

* Don't abuse an int as a pointer (optarg).
* Consistently provide lowercase and MixedCase options.

Signed-off-by: Masanori Ogino <mogino@acm.org>
This commit is contained in:
Dan McMahill 2001-05-07 18:13:13 +00:00 committed by Masanori Ogino
commit 89151996c6

View file

@ -139,10 +139,13 @@ u_char *src, *dst;
static u_char *get_str(p, dst)
static u_char *get_str(p, pv_dst)
u_char *p;
char **dst;
void *pv_dst;
{
char **dst;
dst = pv_dst;
if (!*dst) {
*dst = malloc(strlen((char *)p) + 1);
if (!*dst) RcError("no more memory");
@ -151,21 +154,26 @@ char **dst;
while (*p++) ;
return p;
}
static u_char *get_int(p, dst)
static u_char *get_int(p, pv_dst)
u_char *p;
int *dst;
void *pv_dst;
{
register char *fmt;
int *dst;
dst = pv_dst;
fmt = (*p == '0') ? "%o" : "%d";
if (sscanf((char *)p, fmt, dst) != 1) RcError("bad integer");
while (*p++) ;
return p;
}
static u_char *get_flag(p, dst)
static u_char *get_flag(p, pv_dst)
u_char *p;
int *dst;
void *pv_dst;
{
int *dst;
dst = pv_dst;
if (sscanf((char *)p, "%d", dst) == 1)
;
else if (!cmpstr("on", p))
@ -219,33 +227,56 @@ StrList **dst;
struct optlist {
char *optname;
u_char *(*optfunc)();
int optarg;
void *optarg;
} option[] = {
"DebugOut", get_str, (int)&debug_file,
"DebugLevel", get_int, (int)&debug_level,
"ForkFlag", get_flag, (int)&fork_flag,
/*
* Add option flag.
* Because They are lacked in here. See document.
* Patched by Hidekazu Kuroki(hidekazu@cs.titech.ac.jp) 1996/8/10
*/
"DebugOut", get_str, &debug_file,
"debugout", get_str, &debug_file,
"DebugLevel", get_int, &debug_level,
"debuglevel", get_int, &debug_level,
"ForkFlag", get_flag, &fork_flag,
"forkflag", get_flag, &fork_flag,
"PortName", get_str, (int)&port_name,
"PortName", get_str, &port_name,
"portname", get_str, &port_name,
#ifdef TLI
"PortNumber", get_str, (int)&port_number,
"ProtoName", get_str, (int)&proto_name,
"PortNumber", get_str, &port_number,
"portnumber", get_str, &port_number,
"ProtoName", get_str, &proto_name,
"protoname", get_str, &proto_name,
#else
"PortNumber", get_int, (int)&port_number,
"PortNumber", get_int, &port_number,
"portnumber", get_int, &port_number,
#endif
"SocketName", get_str, (int)&socket_name,
"SocketName", get_str, &socket_name,
"socketname", get_str, &socket_name,
#ifdef LOCK_FILE
"LockFile", get_str, (int)&lock_file;
"LockFile", get_str, &lock_file;
"lockfile", get_str, &lock_file;
#endif
"maxclient", get_int, (int)&max_client,
"dictdir", get_str, (int)&dict_dir,
"readdict", get_list, (int)&read_dict,
"opendict", get_list, (int)&open_dict,
"errorout", get_str, (int)&error_file,
"logout", get_str, (int)&log_file,
"dirmode", get_int, (int)&dir_mode,
"filemode", get_int, (int)&file_mode,
"allowuser", get_list, (int)&allow_user,
"MaxClient", get_int, &max_client,
"maxclient", get_int, &max_client,
"DictDir", get_str, &dict_dir,
"dictdir", get_str, &dict_dir,
"ReadDict", get_list, &read_dict,
"readdict", get_list, &read_dict,
"OpenDict", get_list, &open_dict,
"opendict", get_list, &open_dict,
"ErrorOut", get_str, &error_file,
"errorout", get_str, &error_file,
"LogOut", get_str, &log_file,
"logout", get_str, &log_file,
"DirMode", get_int, &dir_mode,
"dirmode", get_int, &dir_mode,
"FileMode", get_int, &file_mode,
"filemode", get_int, &file_mode,
"AllowUser", get_list, &allow_user,
"allowuser", get_list, &allow_user,
0, 0, 0
};