-/**
- * @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 <stdlib.h>
#include <string.h>
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <winsock2.h>
-
-#define vsnprintf _vsnprintf
-
#else
#include <unistd.h>
#include <sys/types.h>
#include <arpa/inet.h>
#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;
char *r_buf;
};
+#ifdef DEBUG_libfirm
static inline firm_dbg_module_t *get_dbg_module(void)
{
static firm_dbg_module_t *dbg = NULL;
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;
const char *lpp_get_cmd_name(int cmd)
{
switch(cmd) {
-#define LPP_CMD(x) case LPP_CMD_ ## x: return #x;
-#include "lpp_cmd.def"
-#undef LPP_CMD
+ case LPP_CMD_BAD: return "BAD";
+ case LPP_CMD_OK: return "OK";
+ case LPP_CMD_PROBLEM: return "PROBLEM";
+ case LPP_CMD_SOLUTION: return "SOLUTION";
+ case LPP_CMD_SOLVER: return "SOLVER";
+ case LPP_CMD_BYE: return "BYE";
+ case LPP_CMD_SOLVERS: return "SOLVERS";
+ case LPP_CMD_SET_DEBUG: return "SET_DEBUG";
+ case LPP_CMD_INFO: return "INFO";
+ case LPP_CMD_LAST:
+ break;
}
return "<unknown>";