-const char amiga_rcs[] = "$Id: amiga.c,v 1.4 2001/10/07 15:35:13 oes Exp $";
+const char amiga_rcs[] = "$Id: amiga.c,v 1.5 2002/03/03 09:18:03 joergs Exp $";
/*********************************************************************
*
* File : $Source: /cvsroot/ijbswa/current/amiga.c,v $
*
* Revisions :
* $Log: amiga.c,v $
+ * Revision 1.5 2002/03/03 09:18:03 joergs
+ * Made jumbjuster work on AmigaOS again.
+ *
* Revision 1.4 2001/10/07 15:35:13 oes
* Replaced 6 boolean members of csp with one bitmap (csp->flags)
*
{
SetErrnoPtr(&(UserData.eno),sizeof(int));
local_csp->cfd=ObtainSocket(local_csp->cfd, AF_INET, SOCK_STREAM, 0);
- if(-1!=local_csp->cfd)
+ if(JB_INVALID_SOCKET!=local_csp->cfd)
{
Signal(main_task,SIGF_SINGLE);
serve((struct client_state *) local_csp);
-const char gateway_rcs[] = "$Id: gateway.c,v 1.10 2002/03/07 03:50:19 oes Exp $";
+const char gateway_rcs[] = "$Id: gateway.c,v 1.11 2002/03/08 17:46:04 jongfoster Exp $";
/*********************************************************************
*
* File : $Source: /cvsroot/ijbswa/current/gateway.c,v $
*
* Revisions :
* $Log: gateway.c,v $
+ * Revision 1.11 2002/03/08 17:46:04 jongfoster
+ * Fixing int/size_t warnings
+ *
* Revision 1.10 2002/03/07 03:50:19 oes
* - Improved handling of failed DNS lookups
* - Fixed compiler warnings
const char gateway_h_rcs[] = GATEWAY_H_VERSION;
-static int socks4_connect(const struct forward_spec * fwd,
- const char * target_host,
- int target_port,
- struct client_state *csp);
+static jb_socket socks4_connect(const struct forward_spec * fwd,
+ const char * target_host,
+ int target_port,
+ struct client_state *csp);
#define SOCKS_REQUEST_GRANTED 90
* Returns : -1 => failure, else it is the socket file descriptor.
*
*********************************************************************/
-int forwarded_connect(const struct forward_spec * fwd,
- struct http_request *http,
- struct client_state *csp)
+jb_socket forwarded_connect(const struct forward_spec * fwd,
+ struct http_request *http,
+ struct client_state *csp)
{
const char * dest_host;
int dest_port;
/* Should never get here */
log_error(LOG_LEVEL_FATAL, "SOCKS4 impossible internal error - bad SOCKS type.");
errno = EINVAL;
- return(-1);
+ return(JB_INVALID_SOCKET);
}
}
* Returns : -1 => failure, else a socket file descriptor.
*
*********************************************************************/
-static int socks4_connect(const struct forward_spec * fwd,
- const char * target_host,
- int target_port,
- struct client_state *csp)
+static jb_socket socks4_connect(const struct forward_spec * fwd,
+ const char * target_host,
+ int target_port,
+ struct client_state *csp)
{
int web_server_addr;
char cbuf[BUFFER_SIZE];
struct socks_reply *s = (struct socks_reply *)sbuf;
size_t n;
size_t csiz;
- int sfd;
+ jb_socket sfd;
int err = 0;
char *errstr;
if (err)
{
errno = EINVAL;
- return(-1);
+ return(JB_INVALID_SOCKET);
}
/* build a socks request for connection to the web server */
if (web_server_addr == INADDR_NONE)
{
log_error(LOG_LEVEL_CONNECT, "socks4_connect: could not resolve target host %s", target_host);
- return(-1);
+ return(JB_INVALID_SOCKET);
}
break;
case SOCKS_4A:
if (n > sizeof(cbuf))
{
errno = EINVAL;
- return(-1);
+ return(JB_INVALID_SOCKET);
}
strcpy(cbuf + csiz, target_host);
csiz = n;
/* Should never get here */
log_error(LOG_LEVEL_FATAL, "SOCKS4 impossible internal error - bad SOCKS type.");
errno = EINVAL;
- return(-1);
+ return(JB_INVALID_SOCKET);
}
c->vn = 4;
/* pass the request to the socks server */
sfd = connect_to(fwd->gateway_host, fwd->gateway_port, csp);
- if (sfd < 0)
+ if (sfd == JB_INVALID_SOCKET)
{
- return(-1);
+ return(JB_INVALID_SOCKET);
}
- if (write_socket(sfd, (char *)c, csiz) != csiz)
+ if (write_socket(sfd, (char *)c, (int)csiz))
{
log_error(LOG_LEVEL_CONNECT, "SOCKS4 negotiation write failed...");
close_socket(sfd);
- return(-1);
+ return(JB_INVALID_SOCKET);
}
if (read_socket(sfd, sbuf, sizeof(sbuf)) != sizeof(*s))
{
log_error(LOG_LEVEL_CONNECT, "SOCKS4 negotiation read failed...");
close_socket(sfd);
- return(-1);
+ return(JB_INVALID_SOCKET);
}
switch (s->cd)
log_error(LOG_LEVEL_CONNECT, "socks4_connect: %s ...", errstr);
close_socket(sfd);
- return(-1);
+ return(JB_INVALID_SOCKET);
}
#ifndef GATEWAY_H_INCLUDED
#define GATEWAY_H_INCLUDED
-#define GATEWAY_H_VERSION "$Id: gateway.h,v 1.2 2001/06/07 23:12:14 jongfoster Exp $"
+#define GATEWAY_H_VERSION "$Id: gateway.h,v 1.3 2001/07/29 18:58:15 jongfoster Exp $"
/*********************************************************************
*
* File : $Source: /cvsroot/ijbswa/current/gateway.h,v $
*
* Revisions :
* $Log: gateway.h,v $
+ * Revision 1.3 2001/07/29 18:58:15 jongfoster
+ * Removing nested #includes, adding forward declarations for needed
+ * structures, and changing the #define _FILENAME_H to FILENAME_H_INCLUDED.
+ *
* Revision 1.2 2001/06/07 23:12:14 jongfoster
* Removing gateways[] list - no longer used.
* Replacing function pointer in struct gateway with a directly
struct http_request;
struct client_state;
-extern int forwarded_connect(const struct forward_spec * fwd,
- struct http_request *http,
- struct client_state *csp);
+extern jb_socket forwarded_connect(const struct forward_spec * fwd,
+ struct http_request *http,
+ struct client_state *csp);
/* Revision control strings from this header and associated .c file */
extern const char gateway_rcs[];
-const char jbsockets_rcs[] = "$Id: jbsockets.c,v 1.23 2002/03/05 00:36:01 jongfoster Exp $";
+const char jbsockets_rcs[] = "$Id: jbsockets.c,v 1.24 2002/03/07 03:51:36 oes Exp $";
/*********************************************************************
*
* File : $Source: /cvsroot/ijbswa/current/jbsockets.c,v $
*
* Revisions :
* $Log: jbsockets.c,v $
+ * Revision 1.24 2002/03/07 03:51:36 oes
+ * - Improved handling of failed DNS lookups
+ * - Fixed compiler warnings etc
+ *
* Revision 1.23 2002/03/05 00:36:01 jongfoster
* Fixing bug 514988 - unable to restart JunkBuster
*
* 3 : csp = Current client state (buffers, headers, etc...)
* Not modified, only used for source IP and ACL.
*
- * Returns : -1 => failure, else it is the socket file descriptor.
+ * Returns : JB_INVALID_SOCKET => failure, else it is the socket
+ * file descriptor.
*
*********************************************************************/
-int connect_to(const char *host, int portnum, struct client_state *csp)
+jb_socket connect_to(const char *host, int portnum, struct client_state *csp)
{
struct sockaddr_in inaddr;
- int fd, addr;
+ jb_socket fd;
+ int addr;
fd_set wfds;
struct timeval tv[1];
#if !defined(_WIN32) && !defined(__BEOS__) && !defined(AMIGA)
if ((addr = resolve_hostname_to_ip(host)) == INADDR_NONE)
{
csp->http->host_ip_addr_str = strdup("unknown");
- return(-1);
+ return(JB_INVALID_SOCKET);
}
#ifdef FEATURE_ACL
#else
errno = EPERM;
#endif
- return(-1);
+ return(JB_INVALID_SOCKET);
}
#endif /* def FEATURE_ACL */
}
#endif /* ndef _WIN32 */
+#ifdef _WIN32
+ if ((fd = socket(inaddr.sin_family, SOCK_STREAM, 0)) == JB_INVALID_SOCKET)
+#else
if ((fd = socket(inaddr.sin_family, SOCK_STREAM, 0)) < 0)
+#endif
{
- return(-1);
+ return(JB_INVALID_SOCKET);
}
#ifdef TCP_NODELAY
}
#endif /* !defined(_WIN32) && !defined(__BEOS__) && !defined(AMIGA) && !defined(__OS2__) */
- while (connect(fd, (struct sockaddr *) & inaddr, sizeof inaddr) == -1)
+ while (connect(fd, (struct sockaddr *) & inaddr, sizeof inaddr) == JB_INVALID_SOCKET)
{
#ifdef _WIN32
if (errno == WSAEINPROGRESS)
#endif /* __OS2__ */
{
close_socket(fd);
- return(-1);
+ return(JB_INVALID_SOCKET);
}
}
tv->tv_sec = 30;
tv->tv_usec = 0;
- if (select(fd + 1, NULL, &wfds, NULL, tv) <= 0)
+ /* MS Windows uses int, not SOCKET, for the 1st arg of select(). Wierd! */
+ if (select((int)fd + 1, NULL, &wfds, NULL, tv) <= 0)
{
close_socket(fd);
- return(-1);
+ return(JB_INVALID_SOCKET);
}
return(fd);
* 2 : buf = pointer to data to be written.
* 3 : len = length of data to be written to the socket "fd".
*
- * Returns : Win32 & Unix: If no error occurs, returns the total number of
- * bytes sent, which can be less than the number
- * indicated by len. Otherwise, returns (-1).
+ * Returns : 0 on success (entire buffer sent).
+ * nonzero on error.
*
*********************************************************************/
-size_t write_socket(int fd, const char *buf, size_t len)
+int write_socket(jb_socket fd, const char *buf, int len)
{
- if (len <= 0)
+ if (len == 0)
{
- return(0);
+ return 0;
+ }
+
+ if (len < 0)
+ {
+ return 1;
}
log_error(LOG_LEVEL_LOG, "%N", len, buf);
#if defined(_WIN32) || defined(__BEOS__) || defined(AMIGA)
- return(send(fd, buf, len, 0));
+ return (send(fd, buf, len, 0) != len);
#elif defined(__OS2__)
/*
* Break the data up into SOCKET_SEND_MAX chunks for sending...
send_len = SOCKET_SEND_MAX;
send_rc = send(fd,(char*)buf + i, send_len, 0);
if (send_rc == -1)
- return(0);
+ return 1;
i = i + send_len;
- }
- return len;
+ }
+ return 0;
}
#else
- return(write(fd, buf, len));
+ return (write(fd, buf, len) != len);
#endif
}
* smaller than the number of bytes requested; this may hap-
* pen for example because fewer bytes are actually available
* right now (maybe because we were close to end-of-file, or
- * because we are reading from a pipe, or from a terminal),
- * or because read() was interrupted by a signal. On error,
+ * because we are reading from a pipe, or from a terminal,
+ * or because read() was interrupted by a signal). On error,
* -1 is returned, and errno is set appropriately. In this
* case it is left unspecified whether the file position (if
* any) changes.
*
*********************************************************************/
-size_t read_socket(int fd, char *buf, size_t len)
+int read_socket(jb_socket fd, char *buf, int len)
{
if (len <= 0)
{
* Returns : void
*
*********************************************************************/
-void close_socket(int fd)
+void close_socket(jb_socket fd)
{
#if defined(_WIN32) || defined(__BEOS__)
closesocket(fd);
* Parameters :
* 1 : hostnam = TCP/IP address to bind/listen to
* 2 : portnum = port to listen on
+ * 3 : pfd = pointer used to return file descriptor.
*
- * Returns : if success, return file descriptor
+ * Returns : if success, returns 0 and sets *pfd.
* if failure, returns -3 if address is in use,
* -2 if address unresolvable,
* -1 otherwise
- *
*********************************************************************/
-int bind_port(const char *hostnam, int portnum)
+int bind_port(const char *hostnam, int portnum, jb_socket *pfd)
{
struct sockaddr_in inaddr;
- int fd;
+ jb_socket fd;
#ifndef _WIN32
int one = 1;
#endif /* ndef _WIN32 */
+ *pfd = JB_INVALID_SOCKET;
+
memset((char *)&inaddr, '\0', sizeof inaddr);
inaddr.sin_family = AF_INET;
fd = socket(AF_INET, SOCK_STREAM, 0);
+#ifdef _WIN32
+ if (fd == JB_INVALID_SOCKET)
+#else
if (fd < 0)
+#endif
{
return(-1);
}
}
}
- return fd;
+ *pfd = fd;
+ return 0;
}
* On an error it returns 0 (FALSE).
*
*********************************************************************/
-int accept_connection(struct client_state * csp, int fd)
+int accept_connection(struct client_state * csp, jb_socket fd)
{
struct sockaddr_in client, server;
struct hostent *host = NULL;
- int afd;
+ jb_socket afd;
size_t c_length, s_length;
#if defined(HAVE_GETHOSTBYADDR_R_8_ARGS) || defined(HAVE_GETHOSTBYADDR_R_7_ARGS) || defined(HAVE_GETHOSTBYADDR_R_5_ARGS)
struct hostent result;
c_length = s_length = sizeof(client);
+#ifdef _WIN32
+ afd = accept (fd, (struct sockaddr *) &client, &c_length);
+ if (afd == JB_INVALID_SOCKET)
+ {
+ return 0;
+ }
+#else
do
{
afd = accept (fd, (struct sockaddr *) &client, &c_length);
} while (afd < 1 && errno == EINTR);
-
if (afd < 0)
{
return 0;
}
+#endif
/*
* Determine the IP-Adress that the client used to reach us
#ifndef JBSOCKETS_H_INCLUDED
#define JBSOCKETS_H_INCLUDED
-#define JBSOCKETS_H_VERSION "$Id: jbsockets.h,v 1.3 2001/07/29 19:01:11 jongfoster Exp $"
+#define JBSOCKETS_H_VERSION "$Id: jbsockets.h,v 1.4 2002/03/07 03:51:36 oes Exp $"
/*********************************************************************
*
* File : $Source: /cvsroot/ijbswa/current/jbsockets.h,v $
*
* Revisions :
* $Log: jbsockets.h,v $
+ * Revision 1.4 2002/03/07 03:51:36 oes
+ * - Improved handling of failed DNS lookups
+ * - Fixed compiler warnings etc
+ *
* Revision 1.3 2001/07/29 19:01:11 jongfoster
* Changed _FILENAME_H to FILENAME_H_INCLUDED.
* Added forward declarations for needed structures.
*********************************************************************/
\f
+#include "project.h"
+
#ifdef __cplusplus
extern "C" {
#endif
struct client_state;
-extern int connect_to(const char *host, int portnum, struct client_state *csp);
-extern size_t write_socket(int fd, const char *buf, size_t n);
-extern size_t read_socket(int fd, char *buf, size_t n);
-extern void close_socket(int fd);
+extern jb_socket connect_to(const char *host, int portnum, struct client_state *csp);
+extern int write_socket(jb_socket fd, const char *buf, int n);
+extern int read_socket(jb_socket fd, char *buf, int n);
+extern void close_socket(jb_socket fd);
-extern int bind_port(const char *hostnam, int portnum);
-extern int accept_connection(struct client_state * csp, int fd);
+extern int bind_port(const char *hostnam, int portnum, jb_socket *pfd);
+extern int accept_connection(struct client_state * csp, jb_socket fd);
extern unsigned long resolve_hostname_to_ip(const char *host);
-const char jcc_rcs[] = "$Id: jcc.c,v 1.77 2002/03/07 03:52:06 oes Exp $";
+const char jcc_rcs[] = "$Id: jcc.c,v 1.78 2002/03/08 21:35:04 oes Exp $";
/*********************************************************************
*
* File : $Source: /cvsroot/ijbswa/current/jcc.c,v $
*
* Revisions :
* $Log: jcc.c,v $
+ * Revision 1.78 2002/03/08 21:35:04 oes
+ * Added optional group supplement to --user option. Will now use default group of user if no group given
+ *
* Revision 1.77 2002/03/07 03:52:06 oes
* - Fixed compiler warnings etc
* - Improved handling of failed DNS lookups
#define IS_ENABLED_AND IS_TOGGLED_ON_AND IS_NOT_FORCED_AND
char buf[BUFFER_SIZE];
- char *hdr, *p, *req;
+ char *hdr;
+ char *p;
+ char *req;
fd_set rfds;
- int n, maxfd, server_body;
+ int n;
+ jb_socket maxfd;
+ int server_body;
int ms_iis5_hack = 0;
int byte_count = 0;
const struct forward_spec * fwd;
struct http_request *http;
- size_t len; /* for buffer sizes */
+ int len; /* for buffer sizes */
#ifdef FEATURE_KILL_POPUPS
int block_popups; /* bool, 1==will block popups */
int block_popups_now = 0; /* bool, 1==currently blocking popups */
)
{
/* Write the answer to the client */
- if ((write_socket(csp->cfd, rsp->head, rsp->head_length) != rsp->head_length)
- || (write_socket(csp->cfd, rsp->body, rsp->content_length) != rsp->content_length))
+ if (write_socket(csp->cfd, rsp->head, rsp->head_length)
+ || write_socket(csp->cfd, rsp->body, rsp->content_length))
{
log_error(LOG_LEVEL_ERROR, "write to: %s failed: %E", http->host);
}
csp->sfd = forwarded_connect(fwd, http, csp);
- if (csp->sfd < 0)
+ if (csp->sfd == JB_INVALID_SOCKET)
{
log_error(LOG_LEVEL_CONNECT, "connect to: %s failed: %E",
http->hostport);
/* Write the answer to the client */
if(rsp)
{
- if ((write_socket(csp->cfd, rsp->head, rsp->head_length) != rsp->head_length)
- || (write_socket(csp->cfd, rsp->body, rsp->content_length) != rsp->content_length))
+ if (write_socket(csp->cfd, rsp->head, rsp->head_length)
+ || write_socket(csp->cfd, rsp->body, rsp->content_length))
{
log_error(LOG_LEVEL_ERROR, "write to: %s failed: %E", http->host);
}
* (along with anything else that may be in the buffer)
*/
- len = strlen(hdr);
-
- if ((write_socket(csp->sfd, hdr, len) != len)
- || (flush_socket(csp->sfd, csp ) < 0))
+ if (write_socket(csp->sfd, hdr, strlen(hdr))
+ || (flush_socket(csp->sfd, csp) < 0))
{
log_error(LOG_LEVEL_CONNECT, "write header to: %s failed: %E",
http->hostport);
if(rsp)
{
- if ((write_socket(csp->cfd, rsp->head, rsp->head_length) != rsp->head_length)
- || (write_socket(csp->cfd, rsp->body, rsp->content_length) != rsp->content_length))
+ if (write_socket(csp->cfd, rsp->head, rsp->head_length)
+ || write_socket(csp->cfd, rsp->body, rsp->content_length))
{
log_error(LOG_LEVEL_ERROR, "write to: %s failed: %E", http->host);
}
log_error(LOG_LEVEL_CLF, "%s - - [%T] \"%s\" 200 2\n",
csp->ip_addr_str, http->ocmd);
- if (write_socket(csp->cfd, CSUCCEED, sizeof(CSUCCEED)-1) < 0)
+ if (write_socket(csp->cfd, CSUCCEED, sizeof(CSUCCEED)-1))
{
freez(hdr);
return;
break; /* "game over, man" */
}
- if (write_socket(csp->sfd, buf, len) != len)
+ if (write_socket(csp->sfd, buf, len))
{
log_error(LOG_LEVEL_ERROR, "write to: %s failed: %E", http->host);
return;
if(rsp)
{
- if ((write_socket(csp->cfd, rsp->head, rsp->head_length) != rsp->head_length)
- || (write_socket(csp->cfd, rsp->body, rsp->content_length) != rsp->content_length))
+ if (write_socket(csp->cfd, rsp->head, rsp->head_length)
+ || write_socket(csp->cfd, rsp->body, rsp->content_length))
{
log_error(LOG_LEVEL_ERROR, "write to: %s failed: %E", http->host);
}
log_error(LOG_LEVEL_FATAL, "Out of memory parsing server header");
}
- len = strlen(hdr);
-
- if ((write_socket(csp->cfd, hdr, len) != len)
- || (write_socket(csp->cfd, p != NULL ? p : csp->iob->cur, csp->content_length) != (int)csp->content_length))
+ if (write_socket(csp->cfd, hdr, strlen(hdr))
+ || write_socket(csp->cfd, p != NULL ? p : csp->iob->cur, csp->content_length))
{
log_error(LOG_LEVEL_ERROR, "write modified content to client failed: %E");
return;
len = strlen(hdr);
byte_count += len;
- if (((write_socket(csp->cfd, hdr, len) != len)
- || (len = flush_socket(csp->cfd, csp) < 0)))
+ if (write_socket(csp->cfd, hdr, len)
+ || (len = flush_socket(csp->cfd, csp) < 0))
{
log_error(LOG_LEVEL_CONNECT, "write header to client failed: %E");
}
else
{
- if (write_socket(csp->cfd, buf, len) != len)
+ if (write_socket(csp->cfd, buf, len))
{
log_error(LOG_LEVEL_ERROR, "write to client failed: %E");
return;
log_error(LOG_LEVEL_FATAL, "Out of memory parsing server header");
}
- len = strlen(hdr);
-
- /* write the server's (modified) header to
- * the client (along with anything else that
- * may be in the buffer)
- */
-
#ifdef FEATURE_KILL_POPUPS
/* Start blocking popups if appropriate. */
content_filter = gif_deanimate_response;
}
-
/*
* Only write if we're not buffering for content modification
*/
- if (!content_filter && ((write_socket(csp->cfd, hdr, len) != len)
- || (len = flush_socket(csp->cfd, csp) < 0)))
+ if (!content_filter)
{
- log_error(LOG_LEVEL_CONNECT, "write header to client failed: %E");
-
- /* the write failed, so don't bother
- * mentioning it to the client...
- * it probably can't hear us anyway.
+ /* write the server's (modified) header to
+ * the client (along with anything else that
+ * may be in the buffer)
*/
- freez(hdr);
- return;
- }
- if(!content_filter) byte_count += len;
+ len = strlen(hdr);
+
+ if (write_socket(csp->cfd, hdr, len)
+ || (len = flush_socket(csp->cfd, csp) < 0))
+ {
+ log_error(LOG_LEVEL_CONNECT, "write header to client failed: %E");
+
+ /* the write failed, so don't bother
+ * mentioning it to the client...
+ * it probably can't hear us anyway.
+ */
+ freez(hdr);
+ return;
+ }
+
+ byte_count += len;
+ }
/* we're finished with the server's header */
chat(csp);
close_socket(csp->cfd);
- if (csp->sfd >= 0)
+ if (csp->sfd != JB_INVALID_SOCKET)
{
close_socket(csp->sfd);
}
* Returns : Port that was opened.
*
*********************************************************************/
-static int bind_port_helper(struct configuration_spec * config)
+static jb_socket bind_port_helper(struct configuration_spec * config)
{
- int bfd;
+ int result;
+ jb_socket bfd;
if ( (config->haddr != NULL)
&& (config->haddr[0] == '1')
config->hport, config->haddr);
}
- bfd = bind_port(config->haddr, config->hport);
+ result = bind_port(config->haddr, config->hport, &bfd);
- if (bfd < 0)
+ if (result < 0)
{
- switch(bfd)
+ switch(result)
{
case -3 :
log_error(LOG_LEVEL_FATAL, "can't bind to %s:%d: "
}
/* shouldn't get here */
- return -1;
+ return JB_INVALID_SOCKET;
}
config->need_bind = 0;
static void listen_loop(void)
{
struct client_state *csp = NULL;
- int bfd;
+ jb_socket bfd;
struct configuration_spec * config;
config = load_config();
}
csp->flags |= CSP_FLAG_ACTIVE;
- csp->sfd = -1;
+ csp->sfd = JB_INVALID_SOCKET;
csp->config = config = load_config();
-const char parsers_rcs[] = "$Id: parsers.c,v 1.47 2002/02/20 23:15:13 jongfoster Exp $";
+const char parsers_rcs[] = "$Id: parsers.c,v 1.48 2002/03/07 03:46:53 oes Exp $";
/*********************************************************************
*
* File : $Source: /cvsroot/ijbswa/current/parsers.c,v $
*
* Revisions :
* $Log: parsers.c,v $
+ * Revision 1.48 2002/03/07 03:46:53 oes
+ * Fixed compiler warnings etc
+ *
* Revision 1.47 2002/02/20 23:15:13 jongfoster
* Parsing functions now handle out-of-memory gracefully by returning
* an error code.
* file, the results are not portable.
*
*********************************************************************/
-size_t flush_socket(int fd, struct client_state *csp)
+int flush_socket(jb_socket fd, struct client_state *csp)
{
struct iob *iob = csp->iob;
- size_t len = iob->eod - iob->cur;
+ int len = iob->eod - iob->cur;
if (len <= 0)
{
return(0);
}
- len = write_socket(fd, iob->cur, len);
+ if (write_socket(fd, iob->cur, len))
+ {
+ return(-1);
+ }
iob->eod = iob->cur = iob->buf;
return(len);
#ifndef PARSERS_H_INCLUDED
#define PARSERS_H_INCLUDED
-#define PARSERS_H_VERSION "$Id: parsers.h,v 1.20 2002/02/20 23:15:13 jongfoster Exp $"
+#define PARSERS_H_VERSION "$Id: parsers.h,v 1.21 2002/03/07 03:46:17 oes Exp $"
/*********************************************************************
*
* File : $Source: /cvsroot/ijbswa/current/parsers.h,v $
*
* Revisions :
* $Log: parsers.h,v $
+ * Revision 1.21 2002/03/07 03:46:17 oes
+ * Fixed compiler warnings
+ *
* Revision 1.20 2002/02/20 23:15:13 jongfoster
* Parsing functions now handle out-of-memory gracefully by returning
* an error code.
extern const add_header_func_ptr add_client_headers[];
extern const add_header_func_ptr add_server_headers[];
-extern size_t flush_socket(int fd, struct client_state *csp);
+extern int flush_socket(jb_socket fd, struct client_state *csp);
extern size_t add_to_iob(struct client_state *csp, char *buf, size_t n);
extern char *get_header(struct client_state *csp);
extern char *get_header_value(const struct list *header_list, const char *header_name);
#ifndef PROJECT_H_INCLUDED
#define PROJECT_H_INCLUDED
-#define PROJECT_H_VERSION "$Id: project.h,v 1.52 2002/03/07 03:46:17 oes Exp $"
+#define PROJECT_H_VERSION "$Id: project.h,v 1.53 2002/03/08 16:48:55 oes Exp $"
/*********************************************************************
*
* File : $Source: /cvsroot/ijbswa/current/project.h,v $
*
* Revisions :
* $Log: project.h,v $
+ * Revision 1.53 2002/03/08 16:48:55 oes
+ * Added FEATURE_NO_GIFS and BUILTIN_IMAGE_MIMETYPE
+ *
* Revision 1.52 2002/03/07 03:46:17 oes
* Fixed compiler warnings
*
#include "amiga.h"
#endif /* def AMIGA */
+#ifdef _WIN32
+/*
+ * I don't want to have to #include all this just for the declaration
+ * of SOCKET. However, it looks like we have to...
+ */
+#include <windows.h>
+#endif
+
+
#ifdef __cplusplus
extern "C" {
#endif
+/*
+ * The type used by sockets. On UNIX it's an int. Microsoft decided to
+ * make it an unsigned.
+ */
+#ifdef _WIN32
+typedef SOCKET jb_socket;
+#define JB_INVALID_SOCKET INVALID_SOCKET
+#else /* ndef _WIN32 */
+typedef int jb_socket;
+#define JB_INVALID_SOCKET (-1)
+#endif /* ndef _WIN32 */
+
/*
* Error codes. Functions returning these should return a jb_err
struct current_action_spec action[1];
/* socket to talk to client (web browser) */
- int cfd;
+ jb_socket cfd;
/* socket to talk to server (web server or proxy) */
- int sfd;
+ jb_socket sfd;
/* Multi-purpose flag container, see CSP_FLAG_* above */
unsigned short int flags;