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 --- examples/csoap/simpleserver.c | 8 ++++---- nanohttp/nanohttp-client.c | 18 +++++++++++++++--- nanohttp/nanohttp-common.h | 7 ++++++- nanohttp/nanohttp-server.c | 13 ++++++++++--- nanohttp/nanohttp-socket.c | 9 +++++---- 5 files changed, 40 insertions(+), 15 deletions(-) diff --git a/examples/csoap/simpleserver.c b/examples/csoap/simpleserver.c index 0a3d434..1fb77a0 100644 --- a/examples/csoap/simpleserver.c +++ b/examples/csoap/simpleserver.c @@ -1,5 +1,5 @@ /****************************************************************** - * $Id: simpleserver.c,v 1.2 2004/05/12 22:19:13 snowdrop Exp $ + * $Id: simpleserver.c,v 1.3 2004/08/30 07:55:41 snowdrop Exp $ * * CSOAP Project: CSOAP examples project * Copyright (C) 2003 Ferhat Ayaz @@ -77,9 +77,9 @@ int main(int argc, char *argv[]) return 0; } - router = soap_router_new(); - soap_router_register_service(router, say_hello, method, urn); - soap_server_register_router(router, url); + router = soap_router_new(); + soap_router_register_service(router, say_hello, method, urn); + soap_server_register_router(router, url); log_info1("send SIGTERM to shutdown"); soap_server_run(); 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