X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=blobdiff_plain;f=client_common.c;h=f34f81bfc3b4aecc8cd4bdba5631e30116e4a352;hp=2a93d488ed1141fcbac9be8265491002f3fc9455;hb=45b4e8b0ba410fd929a341a9bf84b1ac3995d734;hpb=fc100a582159c001bd5eb2244f314343309bb503 diff --git a/client_common.c b/client_common.c index 2a93d488..f34f81bf 100644 --- a/client_common.c +++ b/client_common.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 1997-2009 Andre Noll + * Copyright (C) 1997-2010 Andre Noll * * Licensed under the GPL v2. For licencing details see COPYING. */ @@ -178,7 +178,7 @@ static void client_post_select(struct sched *s, struct task *t) ret = client_recv_buffer(ct, buf, sizeof(buf)); if (ret < 0) goto err; - PARA_INFO_LOG("<-- [challenge] (%zu bytes)\n", ret); + PARA_INFO_LOG("<-- [challenge] (%d bytes)\n", ret); ret = para_decrypt_buffer(ct->key_file, crypt_buf, (unsigned char *)buf, ret); if (ret < 0) @@ -278,7 +278,6 @@ static void client_post_select(struct sched *s, struct task *t) case CL_RECEIVING: { char *buf2; - buf2 = para_malloc(CLIENT_BUFSIZE); ret = btr_node_status(btrn, 0, BTR_NT_ROOT); if (ret < 0) goto err; @@ -286,6 +285,7 @@ static void client_post_select(struct sched *s, struct task *t) return; if (!FD_ISSET(ct->rc4c.fd, &s->rfds)) return; + buf2 = para_malloc(CLIENT_BUFSIZE); ret = client_recv_buffer(ct, buf2, CLIENT_BUFSIZE); if (ret < 0) { free(buf2); @@ -311,8 +311,8 @@ static int client_connect(struct client_task *ct) int ret; ct->rc4c.fd = -1; - ret = makesock(AF_UNSPEC, IPPROTO_TCP, 0, ct->conf.hostname_arg, - ct->conf.server_port_arg); + ret = para_connect_simple(IPPROTO_TCP, ct->conf.hostname_arg, + ct->conf.server_port_arg); if (ret < 0) return ret; ct->rc4c.fd = ret; @@ -339,6 +339,8 @@ err_out: * \param ct_ptr Points to dynamically allocated and initialized client task * struct upon successful return. * \param loglevel If not \p NULL, the number of the loglevel is stored here. + * \param parent Add the new buffer tree node as a child of this node. + * \param child Add the new buffer tree node as a parent of this node. * * Check the command line options given by \a argc and argv, set default values * for user name and rsa key file, read further option from the config file. @@ -364,12 +366,6 @@ int client_open(int argc, char *argv[], struct client_task **ct_ptr, ret = -E_CLIENT_SYNTAX; if (!ct->conf.inputs_num) goto out; - ct->user = ct->conf.user_given? - para_strdup(ct->conf.user_arg) : para_logname(); - - ct->key_file = ct->conf.key_file_given? - para_strdup(ct->conf.key_file_arg) : - make_message("%s/.paraslash/key.%s", home, ct->user); ct->config_file = ct->conf.config_file_given? para_strdup(ct->conf.config_file_arg) : @@ -392,6 +388,13 @@ int client_open(int argc, char *argv[], struct client_task **ct_ptr, &ct->conf, ¶ms)) goto out; } + ct->user = ct->conf.user_given? + para_strdup(ct->conf.user_arg) : para_logname(); + + ct->key_file = ct->conf.key_file_given? + para_strdup(ct->conf.key_file_arg) : + make_message("%s/.paraslash/key.%s", home, ct->user); + if (loglevel) *loglevel = get_loglevel_by_name(ct->conf.loglevel_arg); PARA_INFO_LOG("loglevel: %s\n", ct->conf.loglevel_arg); @@ -404,6 +407,7 @@ out: free(home); if (ret < 0) { PARA_ERROR_LOG("%s\n", para_strerror(-ret)); + btr_remove_node(ct->btrn); btr_free_node(ct->btrn); client_close(ct); *ct_ptr = NULL;