#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;
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);
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;
}
}
return 1;
}
+
/*
* MAIN
*/
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 */
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;
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)