-const char cgi_rcs[] = "$Id: cgi.c,v 1.47 2002/03/08 16:41:33 oes Exp $";
+const char cgi_rcs[] = "$Id: cgi.c,v 1.48 2002/03/08 17:47:07 jongfoster Exp $";
/*********************************************************************
*
* File : $Source: /cvsroot/ijbswa/current/cgi.c,v $
*
* Revisions :
* $Log: cgi.c,v $
+ * Revision 1.48 2002/03/08 17:47:07 jongfoster
+ * Adding comments
+ *
* Revision 1.47 2002/03/08 16:41:33 oes
* Added GIF images again
*
csp->ip_addr_str, csp->http->cmd);
/* Find and start the right CGI function*/
- for (d = cgi_dispatchers; FOREVER; d++)
+ d = cgi_dispatchers;
+ for (;;)
{
if ((d->name == NULL) || (strcmp(path_copy, d->name) == 0))
{
return cgi_error_memory();
}
}
+ d++;
}
}
-const char deanimate_rcs[] = "$Id: deanimate.c,v 1.7 2002/03/08 17:46:04 jongfoster Exp $";
+const char deanimate_rcs[] = "$Id: deanimate.c,v 1.8 2002/03/09 19:42:47 jongfoster Exp $";
/*********************************************************************
*
* File : $Source: /cvsroot/ijbswa/current/deanimate.c,v $
*
* Revisions :
* $Log: deanimate.c,v $
+ * Revision 1.8 2002/03/09 19:42:47 jongfoster
+ * Fixing more warnings
+ *
* Revision 1.7 2002/03/08 17:46:04 jongfoster
* Fixing int/size_t warnings
*
* by a one-byte length field, with the last chunk having
* zero length.
*/
- while((c = buf_getbyte(buf, 0)))
+ while((c = buf_getbyte(buf, 0)) != '\0')
{
if ((buf->offset += c + 1) >= buf->size - 1)
{
/*
* Copy the image chunk by chunk.
*/
- while((c = buf_getbyte(src, 0)))
+ while((c = buf_getbyte(src, 0)) != '\0')
{
if (buf_copy(src, dst, 1 + (size_t) c)) return 1;
}
-const char encode_rcs[] = "$Id: encode.c,v 1.4 2002/01/22 23:28:07 jongfoster Exp $";
+const char encode_rcs[] = "$Id: encode.c,v 1.5 2002/03/07 03:46:53 oes Exp $";
/*********************************************************************
*
* File : $Source: /cvsroot/ijbswa/current/encode.c,v $
*
* Revisions :
* $Log: encode.c,v $
+ * Revision 1.5 2002/03/07 03:46:53 oes
+ * Fixed compiler warnings etc
+ *
* Revision 1.4 2002/01/22 23:28:07 jongfoster
* Adding convenience function html_encode_and_free_original()
* Making all functions accept NULL paramaters - in this case, they
break;
case '%':
- if ((*q = xtoi(s + 1)))
+ if ((*q = xtoi(s + 1)) != '\0')
{
s += 3;
q++;
-const char errlog_rcs[] = "$Id: errlog.c,v 1.31 2002/03/06 23:02:57 jongfoster Exp $";
+const char errlog_rcs[] = "$Id: errlog.c,v 1.32 2002/03/07 03:46:17 oes Exp $";
/*********************************************************************
*
* File : $Source: /cvsroot/ijbswa/current/errlog.c,v $
*
* Revisions :
* $Log: errlog.c,v $
+ * Revision 1.32 2002/03/07 03:46:17 oes
+ * Fixed compiler warnings
+ *
* Revision 1.31 2002/03/06 23:02:57 jongfoster
* Removing tabs
*
/* set the designated log file */
if( logfname )
{
- if( !(fp = fopen(logfname, "a")) )
+ if( NULL == (fp = fopen(logfname, "a")) )
{
log_error(LOG_LEVEL_FATAL, "init_error_log(): can't open logfile: %s", logfname);
}
-const char gateway_rcs[] = "$Id: gateway.c,v 1.11 2002/03/08 17:46:04 jongfoster Exp $";
+const char gateway_rcs[] = "$Id: gateway.c,v 1.12 2002/03/09 20:03:52 jongfoster Exp $";
/*********************************************************************
*
* File : $Source: /cvsroot/ijbswa/current/gateway.c,v $
*
* Revisions :
* $Log: gateway.c,v $
+ * Revision 1.12 2002/03/09 20:03:52 jongfoster
+ * - Making various functions return int rather than size_t.
+ * (Undoing a recent change). Since size_t is unsigned on
+ * Windows, functions like read_socket that return -1 on
+ * error cannot return a size_t.
+ *
+ * THIS WAS A MAJOR BUG - it caused frequent, unpredictable
+ * crashes, and also frequently caused JB to jump to 100%
+ * CPU and stay there. (Because it thought it had just
+ * read ((unsigned)-1) == 4Gb of data...)
+ *
+ * - The signature of write_socket has changed, it now simply
+ * returns success=0/failure=nonzero.
+ *
+ * - Trying to get rid of a few warnings --with-debug on
+ * Windows, I've introduced a new type "jb_socket". This is
+ * used for the socket file descriptors. On Windows, this
+ * is SOCKET (a typedef for unsigned). Everywhere else, it's
+ * an int. The error value can't be -1 any more, so it's
+ * now JB_INVALID_SOCKET (which is -1 on UNIX, and in
+ * Windows it maps to the #define INVALID_SOCKET.)
+ *
+ * - The signature of bind_port has changed.
+ *
* Revision 1.11 2002/03/08 17:46:04 jongfoster
* Fixing int/size_t warnings
*
return(JB_INVALID_SOCKET);
}
- if (write_socket(sfd, (char *)c, (int)csiz))
+ if (write_socket(sfd, (char *)c, csiz))
{
log_error(LOG_LEVEL_CONNECT, "SOCKS4 negotiation write failed...");
close_socket(sfd);
-const char jbsockets_rcs[] = "$Id: jbsockets.c,v 1.25 2002/03/09 20:03:52 jongfoster Exp $";
+const char jbsockets_rcs[] = "$Id: jbsockets.c,v 1.26 2002/03/11 22:07:02 david__schmidt Exp $";
/*********************************************************************
*
* File : $Source: /cvsroot/ijbswa/current/jbsockets.c,v $
*
* Revisions :
* $Log: jbsockets.c,v $
+ * Revision 1.26 2002/03/11 22:07:02 david__schmidt
+ * OS/2 port maintenance:
+ * - Fixed EMX build - it had decayed a little
+ * - Fixed inexplicable crash during FD_ZERO - must be due to a bad macro.
+ * substituted a memset for now.
+ *
* Revision 1.25 2002/03/09 20:03:52 jongfoster
* - Making various functions return int rather than size_t.
* (Undoing a recent change). Since size_t is unsigned on
* nonzero on error.
*
*********************************************************************/
-int write_socket(jb_socket fd, const char *buf, int len)
+int write_socket(jb_socket fd, const char *buf, size_t len)
{
if (len == 0)
{
log_error(LOG_LEVEL_LOG, "%N", len, buf);
-#if defined(_WIN32) || defined(__BEOS__) || defined(AMIGA)
+#if defined(_WIN32)
+ return (send(fd, buf, (int)len, 0) != (int)len);
+#elif defined(__BEOS__) || defined(AMIGA)
return (send(fd, buf, len, 0) != len);
#elif defined(__OS2__)
/*
return(0);
}
-#if defined(_WIN32) || defined(__BEOS__) || defined(AMIGA) || defined(__OS2__)
+#if defined(_WIN32)
return(recv(fd, buf, len, 0));
+#elif defined(__BEOS__) || defined(AMIGA) || defined(__OS2__)
+ return(recv(fd, buf, (size_t)len, 0));
#else
- return(read(fd, buf, len));
+ return(read(fd, buf, (size_t)len));
#endif
}
struct sockaddr_in client, server;
struct hostent *host = NULL;
jb_socket afd;
+#ifdef _WIN32
+ /* Microsoft wierdness - fix a warning. */
+ int c_length, s_length;
+#else
size_t c_length, s_length;
+#endif
#if defined(HAVE_GETHOSTBYADDR_R_8_ARGS) || defined(HAVE_GETHOSTBYADDR_R_7_ARGS) || defined(HAVE_GETHOSTBYADDR_R_5_ARGS)
struct hostent result;
#if defined(HAVE_GETHOSTBYADDR_R_5_ARGS)
#ifndef JBSOCKETS_H_INCLUDED
#define JBSOCKETS_H_INCLUDED
-#define JBSOCKETS_H_VERSION "$Id: jbsockets.h,v 1.4 2002/03/07 03:51:36 oes Exp $"
+#define JBSOCKETS_H_VERSION "$Id: jbsockets.h,v 1.5 2002/03/09 20:03:52 jongfoster Exp $"
/*********************************************************************
*
* File : $Source: /cvsroot/ijbswa/current/jbsockets.h,v $
*
* Revisions :
* $Log: jbsockets.h,v $
+ * Revision 1.5 2002/03/09 20:03:52 jongfoster
+ * - Making various functions return int rather than size_t.
+ * (Undoing a recent change). Since size_t is unsigned on
+ * Windows, functions like read_socket that return -1 on
+ * error cannot return a size_t.
+ *
+ * THIS WAS A MAJOR BUG - it caused frequent, unpredictable
+ * crashes, and also frequently caused JB to jump to 100%
+ * CPU and stay there. (Because it thought it had just
+ * read ((unsigned)-1) == 4Gb of data...)
+ *
+ * - The signature of write_socket has changed, it now simply
+ * returns success=0/failure=nonzero.
+ *
+ * - Trying to get rid of a few warnings --with-debug on
+ * Windows, I've introduced a new type "jb_socket". This is
+ * used for the socket file descriptors. On Windows, this
+ * is SOCKET (a typedef for unsigned). Everywhere else, it's
+ * an int. The error value can't be -1 any more, so it's
+ * now JB_INVALID_SOCKET (which is -1 on UNIX, and in
+ * Windows it maps to the #define INVALID_SOCKET.)
+ *
+ * - The signature of bind_port has changed.
+ *
* Revision 1.4 2002/03/07 03:51:36 oes
* - Improved handling of failed DNS lookups
* - Fixed compiler warnings etc
struct client_state;
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 write_socket(jb_socket fd, const char *buf, size_t n);
extern int read_socket(jb_socket fd, char *buf, int n);
extern void close_socket(jb_socket fd);
-const char jcc_rcs[] = "$Id: jcc.c,v 1.80 2002/03/11 22:07:05 david__schmidt Exp $";
+const char jcc_rcs[] = "$Id: jcc.c,v 1.81 2002/03/12 01:42:50 oes Exp $";
/*********************************************************************
*
* File : $Source: /cvsroot/ijbswa/current/jcc.c,v $
*
* Revisions :
* $Log: jcc.c,v $
+ * Revision 1.81 2002/03/12 01:42:50 oes
+ * Introduced modular filters
+ *
* Revision 1.80 2002/03/11 22:07:05 david__schmidt
* OS/2 port maintenance:
* - Fixed EMX build - it had decayed a little
* could get blocked here if a client connected, then didn't say anything!
*/
- while (FOREVER)
+ for (;;)
{
len = read_socket(csp->cfd, buf, sizeof(buf));
/* grab the rest of the client's headers */
- while (FOREVER)
+ for (;;)
{
- if ( ( p = get_header(csp) ) && ( *p == '\0' ) )
+ if ( ( ( p = get_header(csp) ) != NULL) && ( *p == '\0' ) )
{
len = read_socket(csp->cfd, buf, sizeof(buf));
if (len <= 0)
server_body = 0;
- while (FOREVER)
+ for (;;)
{
#ifdef __OS2__
/*
FD_SET(csp->cfd, &rfds);
FD_SET(csp->sfd, &rfds);
- n = select(maxfd+1, &rfds, NULL, NULL, NULL);
+ n = select((int)maxfd+1, &rfds, NULL, NULL, NULL);
if (n < 0)
{
break; /* "game over, man" */
}
- if (write_socket(csp->sfd, buf, len))
+ if (write_socket(csp->sfd, buf, (size_t)len))
{
log_error(LOG_LEVEL_ERROR, "write to: %s failed: %E", http->host);
return;
*/
if (((size_t)(csp->iob->eod - csp->iob->buf)) + (size_t)BUFFER_SIZE > csp->config->buffer_limit)
{
+ size_t hdrlen;
+
log_error(LOG_LEVEL_ERROR, "Buffer size limit reached! Flushing and stepping back.");
hdr = sed(server_patterns, add_server_headers, csp);
log_error(LOG_LEVEL_FATAL, "Out of memory parsing server header");
}
- len = strlen(hdr);
- byte_count += len;
+ hdrlen = strlen(hdr);
+ byte_count += hdrlen;
- if (write_socket(csp->cfd, hdr, len)
- || (len = flush_socket(csp->cfd, csp) < 0))
+ if (write_socket(csp->cfd, hdr, hdrlen)
+ || ((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))
+ if (write_socket(csp->cfd, buf, (size_t)len))
{
log_error(LOG_LEVEL_ERROR, "write to client failed: %E");
return;
/* get header lines from the iob */
- while ((p = get_header(csp)))
+ while ((p = get_header(csp)) != NULL)
{
if (*p == '\0')
{
* may be in the buffer)
*/
- len = strlen(hdr);
-
- if (write_socket(csp->cfd, hdr, len)
- || (len = flush_socket(csp->cfd, csp) < 0))
+ if (write_socket(csp->cfd, hdr, strlen(hdr))
+ || ((len = flush_socket(csp->cfd, csp)) < 0))
{
log_error(LOG_LEVEL_CONNECT, "write header to client failed: %E");
bfd = bind_port_helper(config);
- while (FOREVER)
+ for (;;)
{
#if !defined(FEATURE_PTHREAD) && !defined(_WIN32) && !defined(__BEOS__) && !defined(AMIGA) && !defined(__OS2__)
while (waitpid(-1, NULL, WNOHANG) > 0)
#if defined(_WIN32) && !defined(_CYGWIN) && !defined(SELECTED_ONE_OPTION)
#define SELECTED_ONE_OPTION
child_id = _beginthread(
- (void*)serve,
+ (void (*)(void *))serve,
64 * 1024,
csp);
#endif
-const char loadcfg_rcs[] = "$Id: loadcfg.c,v 1.34 2002/03/06 23:14:35 jongfoster Exp $";
+const char loadcfg_rcs[] = "$Id: loadcfg.c,v 1.35 2002/03/07 03:52:44 oes Exp $";
/*********************************************************************
*
* File : $Source: /cvsroot/ijbswa/current/loadcfg.c,v $
*
* Revisions :
* $Log: loadcfg.c,v $
+ * Revision 1.35 2002/03/07 03:52:44 oes
+ * Set logging to tty for --no-daemon mode
+ *
* Revision 1.34 2002/03/06 23:14:35 jongfoster
* Trivial cosmetic changes to make function comments easier to find.
*
{
cur_fwd->forward_host = strdup(p);
- if ((p = strchr(cur_fwd->forward_host, ':')))
+ if (NULL != (p = strchr(cur_fwd->forward_host, ':')))
{
*p++ = '\0';
cur_fwd->forward_port = atoi(p);
{
cur_fwd->gateway_host = strdup(p);
- if ((p = strchr(cur_fwd->gateway_host, ':')))
+ if (NULL != (p = strchr(cur_fwd->gateway_host, ':')))
{
*p++ = '\0';
cur_fwd->gateway_port = atoi(p);
{
cur_fwd->forward_host = strdup(p);
- if ((p = strchr(cur_fwd->forward_host, ':')))
+ if (NULL != (p = strchr(cur_fwd->forward_host, ':')))
{
*p++ = '\0';
cur_fwd->forward_port = atoi(p);
cur_fwd->gateway_host = strdup(p);
- if ((p = strchr(cur_fwd->gateway_host, ':')))
+ if (NULL != (p = strchr(cur_fwd->gateway_host, ':')))
{
*p++ = '\0';
cur_fwd->gateway_port = atoi(p);
{
cur_fwd->forward_host = strdup(p);
- if ((p = strchr(cur_fwd->forward_host, ':')))
+ if (NULL != (p = strchr(cur_fwd->forward_host, ':')))
{
*p++ = '\0';
cur_fwd->forward_port = atoi(p);
if ( NULL != config->haddr )
{
- if ((p = strchr(config->haddr, ':')))
+ if (NULL != (p = strchr(config->haddr, ':')))
{
*p++ = '\0';
if (*p)
-const char loaders_rcs[] = "$Id: loaders.c,v 1.40 2002/03/08 17:46:04 jongfoster Exp $";
+const char loaders_rcs[] = "$Id: loaders.c,v 1.41 2002/03/12 01:42:50 oes Exp $";
/*********************************************************************
*
* File : $Source: /cvsroot/ijbswa/current/loaders.c,v $
*
* Revisions :
* $Log: loaders.c,v $
+ * Revision 1.41 2002/03/12 01:42:50 oes
+ * Introduced modular filters
+ *
* Revision 1.40 2002/03/08 17:46:04 jongfoster
* Fixing int/size_t warnings
*
fl->active = 0;
}
- for (csp = clients; csp && (ncsp = csp->next) ; csp = csp->next)
+ for (csp = clients; csp && (NULL != (ncsp = csp->next)) ; csp = csp->next)
{
if (ncsp->flags & CSP_FLAG_ACTIVE)
{
freez(ncsp);
/* are there any more in sequence after it? */
- if( !(ncsp = csp->next) )
+ if( (ncsp = csp->next) == NULL)
break;
}
}
}
- for (fl = files; fl && (nfl = fl->next) ; fl = fl->next)
+ for (fl = files; fl && ((nfl = fl->next) != NULL) ; fl = fl->next)
{
if ( ( 0 == nfl->active ) && ( NULL != nfl->unloader ) )
{
#define CHAR_CR '\r' /* ASCII 13 */
#define CHAR_LF '\n' /* ASCII 10 */
- while (FOREVER)
+ for (;;)
{
ch = fgetc(fp);
if (ch == EOF)
reject = 0;
p = buf;
q = p+1;
- while ((*p++ = *q++))
+ while ((*p++ = *q++) != '\0')
{
/* nop */
}
-const char parsers_rcs[] = "$Id: parsers.c,v 1.49 2002/03/09 20:03:52 jongfoster Exp $";
+const char parsers_rcs[] = "$Id: parsers.c,v 1.50 2002/03/12 01:45:35 oes Exp $";
/*********************************************************************
*
* File : $Source: /cvsroot/ijbswa/current/parsers.c,v $
*
* Revisions :
* $Log: parsers.c,v $
+ * Revision 1.50 2002/03/12 01:45:35 oes
+ * More verbose logging
+ *
* Revision 1.49 2002/03/09 20:03:52 jongfoster
* - Making various functions return int rather than size_t.
* (Undoing a recent change). Since size_t is unsigned on
return(0);
}
- if (write_socket(fd, iob->cur, len))
+ if (write_socket(fd, iob->cur, (size_t)len))
{
return(-1);
}
* 2 : buf = holds the content to be added to the page
* 3 : n = number of bytes to be added
*
- * Returns : Number of bytes in the content buffer.
+ * Returns : None
*
*********************************************************************/
-size_t add_to_iob(struct client_state *csp, char *buf, size_t n)
+void add_to_iob(struct client_state *csp, char *buf, int n)
{
struct iob *iob = csp->iob;
size_t have, need;
if (n <= 0)
{
- return(have);
+ return;
}
need = have + n;
}
/* copy the new data into the iob buffer */
- memcpy(p, buf, n);
+ memcpy(p, buf, (size_t)n);
/* point to the end of the data */
p += n;
iob->cur = iob->buf;
iob->eod = p;
- return(need);
+ return;
}
iob->cur = p+1;
- if ((q = strchr(ret, '\r'))) *q = '\0';
+ if ((q = strchr(ret, '\r')) != NULL) *q = '\0';
/* is this a blank linke (i.e. the end of the header) ? */
if (*ret == '\0')
int hits = 0, len = strlen(substring);
char *pos, *p;
- while((pos = strstr(string, substring)))
+ while((pos = strstr(string, substring)) != NULL)
{
p = pos + len;
do
#ifndef PARSERS_H_INCLUDED
#define PARSERS_H_INCLUDED
-#define PARSERS_H_VERSION "$Id: parsers.h,v 1.21 2002/03/07 03:46:17 oes Exp $"
+#define PARSERS_H_VERSION "$Id: parsers.h,v 1.22 2002/03/09 20:03:52 jongfoster Exp $"
/*********************************************************************
*
* File : $Source: /cvsroot/ijbswa/current/parsers.h,v $
*
* Revisions :
* $Log: parsers.h,v $
+ * Revision 1.22 2002/03/09 20:03:52 jongfoster
+ * - Making various functions return int rather than size_t.
+ * (Undoing a recent change). Since size_t is unsigned on
+ * Windows, functions like read_socket that return -1 on
+ * error cannot return a size_t.
+ *
+ * THIS WAS A MAJOR BUG - it caused frequent, unpredictable
+ * crashes, and also frequently caused JB to jump to 100%
+ * CPU and stay there. (Because it thought it had just
+ * read ((unsigned)-1) == 4Gb of data...)
+ *
+ * - The signature of write_socket has changed, it now simply
+ * returns success=0/failure=nonzero.
+ *
+ * - Trying to get rid of a few warnings --with-debug on
+ * Windows, I've introduced a new type "jb_socket". This is
+ * used for the socket file descriptors. On Windows, this
+ * is SOCKET (a typedef for unsigned). Everywhere else, it's
+ * an int. The error value can't be -1 any more, so it's
+ * now JB_INVALID_SOCKET (which is -1 on UNIX, and in
+ * Windows it maps to the #define INVALID_SOCKET.)
+ *
+ * - The signature of bind_port has changed.
+ *
* Revision 1.21 2002/03/07 03:46:17 oes
* Fixed compiler warnings
*
extern const add_header_func_ptr add_server_headers[];
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 void add_to_iob(struct client_state *csp, char *buf, int n);
extern char *get_header(struct client_state *csp);
extern char *get_header_value(const struct list *header_list, const char *header_name);
extern char *sed(const struct parsers pats[], const add_header_func_ptr more_headers[], struct client_state *csp);
-const char urlmatch_rcs[] = "$Id: urlmatch.c,v 1.3 2002/03/03 14:51:11 oes Exp $";
+const char urlmatch_rcs[] = "$Id: urlmatch.c,v 1.4 2002/03/07 03:46:17 oes Exp $";
/*********************************************************************
*
* File : $Source: /cvsroot/ijbswa/current/urlmatch.c,v $
*
* Revisions :
* $Log: urlmatch.c,v $
+ * Revision 1.4 2002/03/07 03:46:17 oes
+ * Fixed compiler warnings
+ *
* Revision 1.3 2002/03/03 14:51:11 oes
* Fixed CLF logging: Added ocmd member for client's request to struct http_request
*
return JB_ERR_MEMORY;
}
- if ((p = strchr(buf, '/')))
+ if ((p = strchr(buf, '/')) != NULL)
{
if (NULL == (url->path = strdup(p)))
{