X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=ir%2Flpp%2Flpp_comm.c;h=4af7b41cca983f09efff4b1a2f3c5bad768c01d4;hb=6ccff2965d94c272f71df2a1655336af47bb7753;hp=21ce2815bf3c4200d081f3a8c00da307c92dce18;hpb=85f517eca982e6a4e1d1848eb67634ae33b70de9;p=libfirm diff --git a/ir/lpp/lpp_comm.c b/ir/lpp/lpp_comm.c index 21ce2815b..4af7b41cc 100644 --- a/ir/lpp/lpp_comm.c +++ b/ir/lpp/lpp_comm.c @@ -1,13 +1,28 @@ -/** - * @file lpp_comm.c - * @date 21.07.2005 - * @author Sebastian Hack +/* + * Copyright (C) 2005-2011 University of Karlsruhe. All right reserved. + * + * This file is part of libFirm. + * + * This file may be distributed and/or modified under the terms of the + * GNU General Public License version 2 as published by the Free Software + * Foundation and appearing in the file LICENSE.GPL included in the + * packaging of this file. * - * Protocol stuff for lpp server + * Licensees holding valid libFirm Professional Edition licenses may use + * this file in accordance with the libFirm Commercial License. + * Agreement provided with the Software. * - * Copyright (C) 2005 Universitaet Karlsruhe - * Released under the GPL + * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE + * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE. + */ + +/** + * @file + * @brief Protocol stuff for lpp server + * @author Sebastian Hack */ +#include "config.h" #include #include @@ -18,9 +33,6 @@ #define WIN32_LEAN_AND_MEAN #include #include - -#define vsnprintf _vsnprintf - #else #include #include @@ -28,14 +40,11 @@ #include #endif -#include "irtools.h" +#include "util.h" #include "debug.h" #include "lpp_comm.h" -/* undef to disable debugging */ -#undef ENABLE_DEBUGGING - struct _lpp_comm_t { int fd; size_t buf_size; @@ -46,6 +55,7 @@ struct _lpp_comm_t { char *r_buf; }; +#ifdef DEBUG_libfirm static inline firm_dbg_module_t *get_dbg_module(void) { static firm_dbg_module_t *dbg = NULL; @@ -55,25 +65,25 @@ static inline firm_dbg_module_t *get_dbg_module(void) return dbg; } - #define dbg get_dbg_module() +#endif /** * Try to read some bytes but block until a certain amount is read. * @param fd The file descriptor. * @param buf The buffer to read into. - * @param try The amount of bytes to try to read. + * @param try_amount The amount of bytes to try to read. * @param at_least block until this many bytes are read. * @return The number of bytes read or -1 on error. */ -static ssize_t secure_recv(int fd, void *buf, size_t try, size_t at_least) +static ssize_t secure_recv(int fd, void *buf, size_t try_amount, size_t at_least) { ssize_t res; size_t bytes_read = 0; char *data = buf; do { - res = recv(fd, &data[bytes_read], try - bytes_read, 0); + res = recv(fd, &data[bytes_read], try_amount - bytes_read, 0); if(res <= 0) { if(res == 0 || errno != EAGAIN) return -1;