From 632b4b8564290bae074cf95ca91b90256101fd9d Mon Sep 17 00:00:00 2001 From: snowdrop Date: Mon, 30 Aug 2004 07:55:41 +0000 Subject: fixed some bugs corresponding win32 port code --- nanohttp/nanohttp-client.c | 18 +++++++++++++++--- nanohttp/nanohttp-common.h | 7 ++++++- nanohttp/nanohttp-server.c | 13 ++++++++++--- nanohttp/nanohttp-socket.c | 9 +++++---- 4 files changed, 36 insertions(+), 11 deletions(-) (limited to 'nanohttp') diff --git a/nanohttp/nanohttp-client.c b/nanohttp/nanohttp-client.c index 8f49048..e0456e8 100644 --- a/nanohttp/nanohttp-client.c +++ b/nanohttp/nanohttp-client.c @@ -1,5 +1,5 @@ /****************************************************************** -* $Id: nanohttp-client.c,v 1.13 2004/08/26 17:07:47 rans Exp $ +* $Id: nanohttp-client.c,v 1.14 2004/08/30 07:55:41 snowdrop Exp $ * * CSOAP Project: A http client/server library in C * Copyright (C) 2003 Ferhat Ayaz @@ -36,11 +36,15 @@ #include #include #include + + #ifdef WIN32 + #include + static struct tm *localtime_r(const time_t *const timep, struct tm *p_tm) { - static tm* tmp; + static struct tm* tmp; tmp = localtime(timep); if (tmp) { memcpy(p_tm, tmp, sizeof(struct tm)); @@ -48,6 +52,7 @@ static struct tm *localtime_r(const time_t *const timep, struct tm *p_tm) } return tmp; } + #endif /*-------------------------------------------------- FUNCTION: httpc_new @@ -572,6 +577,14 @@ int httpc_talk_to_server(hreq_method method, httpc_conn_t *conn, char buffer[4096]; int status; +#ifndef WIN32 + #if HSOCKET_BLOCKMODE!=0 + fcntl(conn->sock, F_SETFL, O_NONBLOCK); + #endif +#else + unsigned long iMode = HSOCKET_BLOCKMODE; +#endif + if (conn == NULL) { log_error1("Connection object is NULL"); @@ -604,7 +617,6 @@ int httpc_talk_to_server(hreq_method method, httpc_conn_t *conn, fcntl(conn->sock, F_SETFL, O_NONBLOCK); #endif #else - unsigned long iMode = HSOCKET_BLOCKMODE; if(ioctlsocket(conn->sock, FIONBIO, (u_long FAR*) &iMode) == INVALID_SOCKET) { log_error1("ioctlsocket error"); diff --git a/nanohttp/nanohttp-common.h b/nanohttp/nanohttp-common.h index 365fdf3..ea38866 100644 --- a/nanohttp/nanohttp-common.h +++ b/nanohttp/nanohttp-common.h @@ -1,5 +1,5 @@ /****************************************************************** - * $Id: nanohttp-common.h,v 1.7 2004/08/26 17:07:47 rans Exp $ + * $Id: nanohttp-common.h,v 1.8 2004/08/30 07:55:41 snowdrop Exp $ * * CSOAP Project: A http client/server library in C * Copyright (C) 2003 Ferhat Ayaz @@ -138,6 +138,11 @@ typedef enum log_level log_level_t log_set_level(log_level_t level); log_level_t log_get_level(); + +#ifdef WIN32 + #define __FUNCTION__ "***" +#endif + #define log_verbose1(a1) log_verbose(__FUNCTION__, a1) #define log_verbose2(a1,a2) log_verbose(__FUNCTION__, a1,a2) #define log_verbose3(a1,a2,a3) log_verbose(__FUNCTION__, a1,a2,a3) diff --git a/nanohttp/nanohttp-server.c b/nanohttp/nanohttp-server.c index ef7c503..da71273 100644 --- a/nanohttp/nanohttp-server.c +++ b/nanohttp/nanohttp-server.c @@ -1,5 +1,5 @@ /****************************************************************** -* $Id: nanohttp-server.c,v 1.8 2004/08/26 17:07:47 rans Exp $ +* $Id: nanohttp-server.c,v 1.9 2004/08/30 07:55:42 snowdrop Exp $ * * CSOAP Project: A http client/server library in C * Copyright (C) 2003 Ferhat Ayaz @@ -356,7 +356,15 @@ int httpd_run() fd_set fds; struct timeval timeout; - pthread_attr_init(&attr); + +#ifndef WIN32 +#if HSOCKET_BLOCKMODE!=0 +#endif +#else + unsigned long iMode=HSOCKET_BLOCKMODE; +#endif + +pthread_attr_init(&attr); #ifdef PTHREAD_CREATE_DETACHED pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); #endif @@ -383,7 +391,6 @@ int httpd_run() fcntl(_httpd_socket, F_SETFL, O_NONBLOCK); #endif #else - unsigned long iMode=HSOCKET_BLOCKMODE; if(ioctlsocket(_httpd_socket, FIONBIO, (u_long FAR*) &iMode) == INVALID_SOCKET) { log_error1("ioctlsocket error"); diff --git a/nanohttp/nanohttp-socket.c b/nanohttp/nanohttp-socket.c index 9b0e673..8ff722a 100644 --- a/nanohttp/nanohttp-socket.c +++ b/nanohttp/nanohttp-socket.c @@ -1,5 +1,5 @@ /****************************************************************** -* $Id: nanohttp-socket.c,v 1.9 2004/08/26 17:07:47 rans Exp $ +* $Id: nanohttp-socket.c,v 1.10 2004/08/30 07:55:42 snowdrop Exp $ * * CSOAP Project: A http client/server library in C * Copyright (C) 2003 Ferhat Ayaz @@ -82,14 +82,15 @@ FUNCTION: hsocket_init ----------------------------------------------------*/ int hsocket_init(hsocket_t *sock) { - /* nothing to init for unix sockets */ - /* just set the descriptor to -1 */ - *sock = -1; #ifdef WIN32 // WSACleanup(); struct WSAData info; WSAStartup(MAKEWORD(2,2), &info); +#else + /* nothing to init for unix sockets */ #endif + /* just set the descriptor to -1 */ + *sock = -1; return 0; } -- cgit v1.1-32-gdbae