diff options
author | swhite <swhite@1faa4e14-9dd3-4be0-9f0e-ffe519881164> | 2004-04-13 13:42:54 +0000 |
---|---|---|
committer | swhite <swhite@1faa4e14-9dd3-4be0-9f0e-ffe519881164> | 2004-04-13 13:42:54 +0000 |
commit | 310f5363afe8ed31b6381ff002991d5c7cfa6d96 (patch) | |
tree | 8915b41c6318d49e0577f63e4cce0cad2cdcdaad /src/Sockets.c | |
parent | 373f2b276ec87294bb96e5b148972303308f7763 (diff) |
Made HTTPD to correctly describe interface by INCLUDE HEADER mechanism.
Changed internal names of
http_Auth.h
http_Cookies.h
http_Steer.h
http_Content.h
so that HTTPD thorn developers will be required to use this interface,
rather than incorrectly explicitly including the source header files.
* Protected SString against C++ name mangling
* Gave exported functions the HTTP_ prefix
* Wrote doc/Content.h
* Fixed bug that disabled some steering functionality
git-svn-id: http://svn.cactuscode.org/arrangements/CactusConnect/HTTPD/trunk@192 1faa4e14-9dd3-4be0-9f0e-ffe519881164
Diffstat (limited to 'src/Sockets.c')
-rw-r--r-- | src/Sockets.c | 55 |
1 files changed, 37 insertions, 18 deletions
diff --git a/src/Sockets.c b/src/Sockets.c index 60aee22..b080ed0 100644 --- a/src/Sockets.c +++ b/src/Sockets.c @@ -61,13 +61,13 @@ CCTK_FILEVERSION(CactusConnect_HTTPD_Sockets_c) typedef enum {closed, open} httpSocketState; -typedef struct HTTPSocket +typedef struct HTTPSocketTag { - struct HTTPSocket *prev; - struct HTTPSocket *next; + httpSocket *prev; + httpSocket *next; unsigned long filedes; httpSocketState state; -} httpSocket; +} httpSocket_PLACEHOLDER; /******************************************************************** ********************* Local Routine Prototypes ********************* @@ -101,6 +101,26 @@ static unsigned long int httpport = 0; ********************* External Routines ********************** ********************************************************************/ + /*@@ + @routine HTTP_Send + @date 10.04.2004 + @author Steve White + @desc + Writes all of an HTTP reply. + @enddesc + @calls + @calledby + @history + + @endhistory + +@@*/ +int +HTTP_Send( httpRequest * request, const char * message ) +{ + return HTTP_Write(request, message, strlen(message)); +} + /*@@ @routine HTTP_SetupServer @date Wed Sep 13 20:39:15 2000 @@ -203,13 +223,7 @@ int HTTP_ShutdownServer(void) @@*/ int HTTP_Poll(cGH *cctkGH, long sec, long usec) { -#ifdef HAVE_SOCKLEN_T - socklen_t size; -#else - int size; -#endif - SOCKET new; - fd_set read_fd_set; + fd_set read_fd_set = active_fd_set; struct sockaddr_in clientname; struct timeval timeout; httpSocket *this, *next; @@ -219,7 +233,6 @@ int HTTP_Poll(cGH *cctkGH, long sec, long usec) timeout.tv_usec = usec; /* Check if any input is available on one or more active sockets. */ - read_fd_set = active_fd_set; if (select (FD_SETSIZE, &read_fd_set, NULL, NULL, sec >= 0 ? &timeout : NULL) == SOCKET_ERROR) @@ -232,8 +245,12 @@ int HTTP_Poll(cGH *cctkGH, long sec, long usec) if (FD_ISSET (sock, &read_fd_set)) { /* Connection request on original socket. */ - size = sizeof (clientname); - new = accept (sock, (struct sockaddr *) &clientname, &size); +#ifdef HAVE_SOCKLEN_T + socklen_t size = sizeof (clientname); +#else + int size = sizeof (clientname); +#endif + SOCKET new = accept (sock, (struct sockaddr *) &clientname, &size); if (new == INVALID_SOCKET) { perror ("accept"); @@ -253,15 +270,17 @@ int HTTP_Poll(cGH *cctkGH, long sec, long usec) } } - for(this = socklist; this; this = next) + this = socklist; + while( this ) { - next = this->next; + httpSocket *next = this->next; /* Data arriving on an already-connected socket. */ if (FD_ISSET (this->filedes, &read_fd_set) && HTTP_ReadFromClient (cctkGH, this) < 0) { SocketDestroy(this); } + this = next; } return (0); @@ -287,7 +306,7 @@ int HTTP_Write(httpRequest *request, const char *buffer, size_t count) int retval = -1; size_t bytes_sent = 0; size_t halfcount; - httpSocket *connection = (httpSocket *)request->connection; + httpSocket *connection = HTTP_Connection( request); int done = 0; int tmp; fd_set this_set; @@ -427,7 +446,7 @@ int HTTP_Read(httpRequest *request, char *buffer, size_t count) { int retval = -1; - httpSocket *connection = (httpSocket *)request->connection; + httpSocket *connection = HTTP_Connection( request ); if(connection->state == open) { |