diff options
author | snowdrop | 2004-08-30 07:55:41 +0000 |
---|---|---|
committer | snowdrop | 2004-08-30 07:55:41 +0000 |
commit | 632b4b8564290bae074cf95ca91b90256101fd9d (patch) | |
tree | 2a213a11db1515f42d34bd2f1dc3a7cf7162b112 /nanohttp | |
parent | 5673c701448b9dfeb2bcf78fbdeeeff0089dd446 (diff) | |
download | csoap-632b4b8564290bae074cf95ca91b90256101fd9d.tar.gz csoap-632b4b8564290bae074cf95ca91b90256101fd9d.tar.bz2 |
fixed some bugs corresponding win32 port code
Diffstat (limited to 'nanohttp')
-rw-r--r-- | nanohttp/nanohttp-client.c | 18 | ||||
-rw-r--r-- | nanohttp/nanohttp-common.h | 7 | ||||
-rw-r--r-- | nanohttp/nanohttp-server.c | 13 | ||||
-rw-r--r-- | nanohttp/nanohttp-socket.c | 9 |
4 files changed, 36 insertions, 11 deletions
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 <time.h> #include <stdio.h> #include <stdlib.h> + + #ifdef WIN32 + #include <string.h> + 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; } |