From: Andre Date: Sun, 11 Jun 2006 23:17:56 +0000 (+0200) Subject: client: rename "args_info" to "conf" X-Git-Tag: v0.2.14~62^2~24 X-Git-Url: http://git.tue.mpg.de/?a=commitdiff_plain;h=d731ceace1fe263c622337872560788f05ed8750;p=paraslash.git client: rename "args_info" to "conf" just to be consistent. --- diff --git a/Makefile.in b/Makefile.in index bf571ef4..ed887fa4 100644 --- a/Makefile.in +++ b/Makefile.in @@ -141,7 +141,7 @@ grab_client.cmdline.h grab_client.cmdline.c: grab_client.ggo --func-name $(subst _write.ggo,,$<)_cmdline_parser < $< %.cmdline.h %.cmdline.c: %.ggo - case $< in client.ggo) O="--unamed-opts=command";; \ + case $< in client.ggo) O="--unamed-opts=command --arg-struct-name=$(subst .ggo,,$<)_args_info";; \ audioc.ggo) O="--unamed-opts=command";; \ esac; \ gengetopt $$O --conf-parser --file-name=$(*F).cmdline --set-package="para_$(subst .cmdline,,$(*F))" --set-version="$V" < $< diff --git a/client.c b/client.c index a28be42f..45b27f59 100644 --- a/client.c +++ b/client.c @@ -28,7 +28,19 @@ #include "string.h" #include "error.h" -struct gengetopt_args_info args_info; +#if 0 +enum {CL_CONNECTED, CL_SENT_AUTH, CL_RECEIVED_CHALLENGE, CL_SENT_CH_RESPONSE, + CL_RECEIVED_PROCEED, CL_SENT_COMMAND, CL_SENDING_STDIN, CL_RECV_DATA}; + +struct private_client_data { + int status; + int fd; + struct client_conf *conf; +}; +#endif + +//struct gengetopt_conf conf; +struct client_args_info conf; INIT_CLIENT_ERRLISTS; @@ -40,7 +52,7 @@ void para_log(int ll, const char* fmt,...) va_list argp; /* ignore log message if loglevel is not high enough */ - if (ll < args_info.loglevel_arg) + if (ll < conf.loglevel_arg) return; va_start(argp, fmt); vfprintf(stderr, fmt, argp); @@ -56,34 +68,34 @@ static int get_options(int argc, char *argv[], struct stat statbuf; int ret; - cmdline_parser(argc, argv, &args_info); - if (!args_info.user_given) - args_info.user_arg = para_logname(); - if (!args_info.key_file_given) { + cmdline_parser(argc, argv, &conf); + if (!conf.user_given) + conf.user_arg = para_logname(); + if (!conf.key_file_given) { home = para_homedir(); sprintf(default_key_file, "%s/.paraslash/key.%s", home, - args_info.user_arg); + conf.user_arg); free(home); } - if (!args_info.config_file_given) { + if (!conf.config_file_given) { home = para_homedir(); sprintf(default_config_file, "%s/.paraslash/client.conf", home); free(home); } - if (!args_info.config_file_given) + if (!conf.config_file_given) *config_file = default_config_file; else - *config_file = args_info.config_file_arg; + *config_file = conf.config_file_arg; ret = stat(*config_file, &statbuf); - if (ret && args_info.config_file_given) + if (ret && conf.config_file_given) return -E_NO_CONFIG; if (!ret) - cmdline_parser_configfile(*config_file, &args_info, 0, 0, 0); - if (!args_info.key_file_given) + cmdline_parser_configfile(*config_file, &conf, 0, 0, 0); + if (!conf.key_file_given) *key_file = default_key_file; else - *key_file = args_info.key_file_arg; + *key_file = conf.key_file_arg; return 1; } @@ -131,6 +143,7 @@ static int send_stdin(int fd) } return 1; } + /* * MAIN */ @@ -149,31 +162,31 @@ int main(int argc, char *argv[]) ret = get_options(argc, argv, &config_file, &key_file); if (ret < 0) goto out; - if (args_info.loglevel_arg <= NOTICE) + if (conf.loglevel_arg <= NOTICE) cmdline_parser_print_version(); PARA_INFO_LOG( "current loglevel: %d\n" "using config_file: %s\n" "using key_file: %s\n" "connecting to %s:%d\n", - args_info.loglevel_arg, + conf.loglevel_arg, config_file, key_file, - args_info.hostname_arg, - args_info.server_port_arg + conf.hostname_arg, + conf.server_port_arg ); ret = - E_CLIENT_SYNTAX; - if (!args_info.inputs_num) + if (!conf.inputs_num) goto out; /* concat args */ - for (i = 0; i < args_info.inputs_num; i++) - append_str(&command, args_info.inputs[i]); + for (i = 0; i < conf.inputs_num; i++) + append_str(&command, conf.inputs[i]); crypt_function_recv = NULL; crypt_function_send = NULL; /* get the host info */ PARA_NOTICE_LOG("getting host info of %s\n", - args_info.hostname_arg); - ret = get_host_info(args_info.hostname_arg, &he); + conf.hostname_arg); + ret = get_host_info(conf.hostname_arg, &he); if (ret < 0) goto out; /* get new socket */ @@ -182,9 +195,9 @@ int main(int argc, char *argv[]) goto out; sockfd = ret; /* init their_addr */ - init_sockaddr(&their_addr, args_info.server_port_arg, he); + init_sockaddr(&their_addr, conf.server_port_arg, he); /* connect */ - PARA_NOTICE_LOG("connecting to %s\n", args_info.hostname_arg); + PARA_NOTICE_LOG("connecting to %s\n", conf.hostname_arg); ret = para_connect(sockfd, &their_addr); if (ret < 0) goto out; @@ -193,8 +206,8 @@ int main(int argc, char *argv[]) if (ret < 0) goto out; /* send auth command */ - auth_str = make_message("auth %s%s", args_info.plain_given? "" : "rc4 ", - args_info.user_arg); + auth_str = make_message("auth %s%s", conf.plain_given? "" : "rc4 ", + conf.user_arg); PARA_INFO_LOG("<-- %s--> %s\n", buf, auth_str); ret = send_buffer(sockfd, auth_str); if (ret < 0)