- if (!args_info.inputs_num) {
- PARA_ERROR_LOG("%s", "syntax error\n");
- exit(EXIT_FAILURE);
- }
- /* concat args */
- for (i = 0; i < args_info.inputs_num; i++)
- append_str(&command, args_info.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);
- if (!(he = get_host_info(args_info.hostname_arg)))
- exit(EXIT_FAILURE);
- /* get new socket */
- if ((sockfd = get_socket()) < 0)
- exit(EXIT_FAILURE);
- /* init their_addr */
- init_sockaddr(&their_addr, args_info.server_port_arg, he);
- /* Connect */
- PARA_NOTICE_LOG("connecting to %s...\n",
- args_info.hostname_arg);
- if (para_connect(sockfd, &their_addr) < 0)
- exit(EXIT_FAILURE);
- /* Receive Welcome message */
- if ((numbytes = recv_buffer(sockfd, buf, sizeof(buf))) < 0)
- exit(EXIT_FAILURE);
+ ret = client_open(pcd);
+ if (ret < 0)
+ goto out;
+ /* receive welcome message */
+ ret = recv_buffer(pcd->fd, buf, sizeof(buf));
+ if (ret < 0)
+ goto out;