From: David Schmidt Date: Thu, 25 Oct 2001 03:40:48 +0000 (+0000) Subject: Change in porting tactics: OS/2's EMX porting layer doesn't allow multiple X-Git-Tag: v_2_9_10~77 X-Git-Url: http://www.privoxy.org/gitweb/?p=privoxy.git;a=commitdiff_plain;h=5f390b415777db21894f1b856ab3d21c9c24f7c6;hp=7a6bc2c1cf80345d0a120809bbde5ade5b4f4165 Change in porting tactics: OS/2's EMX porting layer doesn't allow multiple threads to call select() simultaneously. So, it's time to do a real, live, native OS/2 port. See defines for __EMX__ (the porting layer) vs. __OS2__ (native). Both versions will work, but using __OS2__ offers multi-threading. --- diff --git a/actions.c b/actions.c index 3b01d36e..fff75a69 100644 --- a/actions.c +++ b/actions.c @@ -1,4 +1,4 @@ -const char actions_rcs[] = "$Id: actions.c,v 1.15 2001/10/14 21:58:22 jongfoster Exp $"; +const char actions_rcs[] = "$Id: actions.c,v 1.16 2001/10/23 21:30:30 jongfoster Exp $"; /********************************************************************* * * File : $Source: /cvsroot/ijbswa/current/actions.c,v $ @@ -10,10 +10,10 @@ const char actions_rcs[] = "$Id: actions.c,v 1.15 2001/10/14 21:58:22 jongfoster * IJBSWA team. http://ijbswa.sourceforge.net * * Based on the Internet Junkbuster originally written - * by and Copyright (C) 1997 Anonymous Coders and + * by and Copyright (C) 1997 Anonymous Coders and * Junkbusters Corporation. http://www.junkbusters.com * - * This program is free software; you can redistribute it + * This program is free software; you can redistribute it * and/or modify it under the terms of the GNU General * Public License as published by the Free Software * Foundation; either version 2 of the License, or (at @@ -33,6 +33,9 @@ const char actions_rcs[] = "$Id: actions.c,v 1.15 2001/10/14 21:58:22 jongfoster * * Revisions : * $Log: actions.c,v $ + * Revision 1.16 2001/10/23 21:30:30 jongfoster + * Adding error-checking to selected functions. + * * Revision 1.15 2001/10/14 21:58:22 jongfoster * Adding support for the CGI-based editor: * - Exported get_actions() @@ -135,7 +138,7 @@ const char actions_h_rcs[] = ACTIONS_H_VERSION; #define AV_REM_MULTI 4 /* -multiopt{string} -multiopt{*} */ /* - * We need a structure to hold the name, flag changes, + * We need a structure to hold the name, flag changes, * type, and string index. */ struct action_name @@ -194,7 +197,7 @@ static const struct action_name action_names[] = * Returns : JB_ERR_OK or JB_ERR_MEMORY * *********************************************************************/ -jb_err merge_actions (struct action_spec *dest, +jb_err merge_actions (struct action_spec *dest, const struct action_spec *src) { int i; @@ -271,11 +274,11 @@ jb_err merge_actions (struct action_spec *dest, * Returns : N/A * *********************************************************************/ -jb_err copy_action (struct action_spec *dest, +jb_err copy_action (struct action_spec *dest, const struct action_spec *src) { int i; - jb_err err; + jb_err err = JB_ERR_OK; memset(dest, '\0', sizeof(*dest)); @@ -306,6 +309,7 @@ jb_err copy_action (struct action_spec *dest, return err; } } + return err; } @@ -362,7 +366,7 @@ void free_action (struct action_spec *src) * we found an action. * 2 : name = [out] Start of action name, null * terminated. NULL on EOL - * 3 : value = [out] Start of action value, null + * 3 : value = [out] Start of action value, null * terminated. NULL if none or EOL. * * Returns : JB_ERR_OK => Ok @@ -399,7 +403,7 @@ jb_err get_action_token(char **line, char **name, char **value) *name = str; /* parse option */ - while (((ch = *str) != '\0') && + while (((ch = *str) != '\0') && (ch != ' ') && (ch != '\t') && (ch != '{')) { if (ch == '}') @@ -488,7 +492,7 @@ jb_err get_actions(char *line, if (option) { /* handle option in 'option' */ - + /* Check for standard action name */ const struct action_name * action = action_names; @@ -598,7 +602,7 @@ jb_err get_actions(char *line, { /* try user aliases. */ const struct action_alias * alias = alias_list; - + while ( (alias != NULL) && (0 != strcmpic(alias->name, option)) ) { alias = alias->next; @@ -964,14 +968,15 @@ void init_action (struct action_spec *dest) * 1 : dest = Current actions, to modify. * 2 : src = Action to add. * - * Returns : N/A + * Returns 0 : no error + * !=0 : error * *********************************************************************/ -jb_err merge_current_action (struct current_action_spec *dest, +jb_err merge_current_action (struct current_action_spec *dest, const struct action_spec *src) { int i; - jb_err err; + jb_err err = JB_ERR_OK; dest->flags &= src->mask; dest->flags |= src->add; @@ -1012,6 +1017,7 @@ jb_err merge_current_action (struct current_action_spec *dest, } } } + return err; } @@ -1093,7 +1099,7 @@ void free_alias_list(struct action_alias *alias_list) { struct action_alias * next = alias_list->next; alias_list->next = NULL; - freez((char *)alias_list->name); + freez(alias_list->name); free_action(alias_list->action); free(alias_list); alias_list = next; @@ -1186,7 +1192,7 @@ int load_actions_file(struct client_state *csp) { /* too short */ fclose(fp); - log_error(LOG_LEVEL_FATAL, + log_error(LOG_LEVEL_FATAL, "can't load actions file '%s': invalid line: %s", csp->config->actions_file, buf); return 1; /* never get here */ @@ -1200,7 +1206,7 @@ int load_actions_file(struct client_state *csp) { /* too short */ fclose(fp); - log_error(LOG_LEVEL_FATAL, + log_error(LOG_LEVEL_FATAL, "can't load actions file '%s': invalid line: {{ }}", csp->config->actions_file); return 1; /* never get here */ @@ -1232,7 +1238,7 @@ int load_actions_file(struct client_state *csp) * appear once. */ fclose(fp); - log_error(LOG_LEVEL_FATAL, + log_error(LOG_LEVEL_FATAL, "can't load actions file '%s': {{settings}} must only appear once, and it must be before anything else.", csp->config->actions_file); } @@ -1246,7 +1252,7 @@ int load_actions_file(struct client_state *csp) /* {{description}} is a singleton and only {{settings}} may proceed it */ fclose(fp); - log_error(LOG_LEVEL_FATAL, + log_error(LOG_LEVEL_FATAL, "can't load actions file '%s': {{description}} must only appear once, and only a {{settings}} block may be above it.", csp->config->actions_file); } @@ -1268,7 +1274,7 @@ int load_actions_file(struct client_state *csp) * completely rewriting the file becomes non-trivial) */ fclose(fp); - log_error(LOG_LEVEL_FATAL, + log_error(LOG_LEVEL_FATAL, "can't load actions file '%s': {{alias}} must only appear once, and it must be before all actions.", csp->config->actions_file, start); } @@ -1278,7 +1284,7 @@ int load_actions_file(struct client_state *csp) { /* invalid {{something}} block */ fclose(fp); - log_error(LOG_LEVEL_FATAL, + log_error(LOG_LEVEL_FATAL, "can't load actions file '%s': invalid line: {{%s}}", csp->config->actions_file, start); return 1; /* never get here */ @@ -1309,7 +1315,7 @@ int load_actions_file(struct client_state *csp) if (cur_action == NULL) { fclose(fp); - log_error(LOG_LEVEL_FATAL, + log_error(LOG_LEVEL_FATAL, "can't load actions file '%s': out of memory", csp->config->actions_file); return 1; /* never get here */ @@ -1325,7 +1331,7 @@ int load_actions_file(struct client_state *csp) { /* No closing } */ fclose(fp); - log_error(LOG_LEVEL_FATAL, + log_error(LOG_LEVEL_FATAL, "can't load actions file '%s': invalid line: %s", csp->config->actions_file, buf); return 1; /* never get here */ @@ -1339,7 +1345,7 @@ int load_actions_file(struct client_state *csp) { /* error */ fclose(fp); - log_error(LOG_LEVEL_FATAL, + log_error(LOG_LEVEL_FATAL, "can't load actions file '%s': invalid line: %s", csp->config->actions_file, buf); return 1; /* never get here */ @@ -1374,7 +1380,7 @@ int load_actions_file(struct client_state *csp) if ((start == NULL) || (start == buf)) { - log_error(LOG_LEVEL_FATAL, + log_error(LOG_LEVEL_FATAL, "can't load actions file '%s': invalid alias line: %s", csp->config->actions_file, buf); return 1; /* never get here */ @@ -1409,7 +1415,7 @@ int load_actions_file(struct client_state *csp) } if (*start == '\0') { - log_error(LOG_LEVEL_FATAL, + log_error(LOG_LEVEL_FATAL, "can't load actions file '%s': invalid alias line: %s", csp->config->actions_file, buf); return 1; /* never get here */ @@ -1423,12 +1429,12 @@ int load_actions_file(struct client_state *csp) { /* error */ fclose(fp); - log_error(LOG_LEVEL_FATAL, + log_error(LOG_LEVEL_FATAL, "can't load actions file '%s': invalid alias line: %s = %s", csp->config->actions_file, buf, start); return 1; /* never get here */ } - + /* add to list */ new_alias->next = alias_list; alias_list = new_alias; @@ -1454,7 +1460,7 @@ int load_actions_file(struct client_state *csp) if (create_url_spec(perm->url, buf)) { fclose(fp); - log_error(LOG_LEVEL_FATAL, + log_error(LOG_LEVEL_FATAL, "can't load actions file '%s': cannot create URL pattern from: %s", csp->config->actions_file, buf); return 1; /* never get here */ @@ -1468,7 +1474,7 @@ int load_actions_file(struct client_state *csp) { /* oops - please have a {} line as 1st line in file. */ fclose(fp); - log_error(LOG_LEVEL_FATAL, + log_error(LOG_LEVEL_FATAL, "can't load actions file '%s': first line is invalid: %s", csp->config->actions_file, buf); return 1; /* never get here */ @@ -1477,7 +1483,7 @@ int load_actions_file(struct client_state *csp) { /* How did we get here? This is impossible! */ fclose(fp); - log_error(LOG_LEVEL_FATAL, + log_error(LOG_LEVEL_FATAL, "can't load actions file '%s': INTERNAL ERROR - mode = %d", csp->config->actions_file, mode); return 1; /* never get here */ @@ -1485,7 +1491,7 @@ int load_actions_file(struct client_state *csp) } fclose(fp); - + free_action(cur_action); free_alias_list(alias_list); diff --git a/cgiedit.c b/cgiedit.c index bcba4250..683b1864 100644 --- a/cgiedit.c +++ b/cgiedit.c @@ -1,21 +1,21 @@ -const char cgiedit_rcs[] = "$Id: cgiedit.c,v 1.3 2001/10/14 22:12:49 jongfoster Exp $"; +const char cgiedit_rcs[] = "$Id: cgiedit.c,v 1.4 2001/10/23 21:48:19 jongfoster Exp $"; /********************************************************************* * * File : $Source: /cvsroot/ijbswa/current/cgiedit.c,v $ * * Purpose : CGI-based actionsfile editor. - * + * * Functions declared include: - * + * * * Copyright : Written by and Copyright (C) 2001 the SourceForge * IJBSWA team. http://ijbswa.sourceforge.net * * Based on the Internet Junkbuster originally written - * by and Copyright (C) 1997 Anonymous Coders and + * by and Copyright (C) 1997 Anonymous Coders and * Junkbusters Corporation. http://www.junkbusters.com * - * This program is free software; you can redistribute it + * This program is free software; you can redistribute it * and/or modify it under the terms of the GNU General * Public License as published by the Free Software * Foundation; either version 2 of the License, or (at @@ -35,6 +35,18 @@ const char cgiedit_rcs[] = "$Id: cgiedit.c,v 1.3 2001/10/14 22:12:49 jongfoster * * Revisions : * $Log: cgiedit.c,v $ + * Revision 1.4 2001/10/23 21:48:19 jongfoster + * Cleaning up error handling in CGI functions - they now send back + * a HTML error page and should never cause a FATAL error. (Fixes one + * potential source of "denial of service" attacks). + * + * CGI actions file editor that works and is actually useful. + * + * Ability to toggle JunkBuster remotely using a CGI call. + * + * You can turn off both the above features in the main configuration + * file, e.g. if you are running a multi-user proxy. + * * Revision 1.3 2001/10/14 22:12:49 jongfoster * New version of CGI-based actionsfile editor. * Major changes, including: @@ -79,6 +91,13 @@ const char cgiedit_rcs[] = "$Id: cgiedit.c,v 1.3 2001/10/14 22:12:49 jongfoster #define snprintf _snprintf #endif /* def _WIN32 */ +#ifdef __OS2__ +/* + * FIXME: gotta write a snprintf routine. snprintf. You guys kill me. + */ +#define snprintf(X,Y,Z) sprintf(X,Z) +#endif /* __OS2__ */ + #include "project.h" #include "cgi.h" #include "cgiedit.h" @@ -103,7 +122,7 @@ struct file_line char * prefix; char * unprocessed; int type; - + union { struct action_spec action[1]; @@ -157,7 +176,7 @@ struct editable_file * significant anyway. */ struct file_line * parse_error; /* On parse error, this is the offending line. */ - const char * parse_error_text; /* On parse error, this is the problem. + const char * parse_error_text; /* On parse error, this is the problem. * (Statically allocated) */ }; @@ -215,7 +234,7 @@ static jb_err get_number_param(struct client_state *csp, /* Internal actionsfile <==> HTML conversion functions */ static jb_err map_radio(struct map * exports, - const char * optionname, + const char * optionname, const char * values, char value); static jb_err actions_to_radio(struct map * exports, @@ -262,7 +281,7 @@ static jb_err simple_read_line(char **dest, FILE *fp) { return JB_ERR_MEMORY; } - + *buf = '\0'; len = 0; @@ -289,7 +308,7 @@ static jb_err simple_read_line(char **dest, FILE *fp) *dest = buf; return JB_ERR_OK; } - + if (NULL == (newbuf = realloc(buf, len + BUFFER_SIZE))) { free(buf); @@ -309,7 +328,7 @@ static jb_err simple_read_line(char **dest, FILE *fp) * and respects escaping of newline and comment char. * Provides the line in 2 alternative forms: raw and * preprocessed. - * - raw is the raw data read from the file. If the + * - raw is the raw data read from the file. If the * line is not modified, then this should be written * to the new file. * - prefix is any comments and blank lines that were @@ -396,7 +415,7 @@ static jb_err edit_read_line(FILE *fp, char **raw_out, char **prefix_out, char * free(linebuf); return JB_ERR_MEMORY; } - + /* Trim off newline */ p = linebuf + strlen(linebuf); if ((p != linebuf) && ((p[-1] == '\r') || (p[-1] == '\n'))) @@ -499,7 +518,7 @@ static jb_err edit_read_line(FILE *fp, char **raw_out, char **prefix_out, char * { /* Got at least some data */ - /* Remove trailing whitespace */ + /* Remove trailing whitespace */ chomp(data); if (raw_out) @@ -631,7 +650,7 @@ jb_err edit_write_file(struct editable_file * file) file->version = (unsigned)statbuf->st_mtime; /* Correct file->version_str */ - freez((char *)file->version_str); + freez(file->version_str); snprintf(version_buf, 22, "%u", file->version); version_buf[21] = '\0'; file->version_str = strdup(version_buf); @@ -648,7 +667,7 @@ jb_err edit_write_file(struct editable_file * file) * * Function : edit_free_file * - * Description : Free a complete file in memory. + * Description : Free a complete file in memory. * * Parameters : * 1 : file = Data structure to free. @@ -665,9 +684,9 @@ void edit_free_file(struct editable_file * file) } edit_free_file_lines(file->lines); - freez((char *)file->filename); - freez((char *)file->identifier); - freez((char *)file->version_str); + freez(file->filename); + freez(file->identifier); + freez(file->version_str); file->version = 0; file->parse_error_text = NULL; /* Statically allocated */ file->parse_error = NULL; @@ -680,7 +699,7 @@ void edit_free_file(struct editable_file * file) * * Function : edit_free_file * - * Description : Free an entire linked list of file lines. + * Description : Free an entire linked list of file lines. * * Parameters : * 1 : first_line = Data structure to free. @@ -737,7 +756,7 @@ static void edit_free_file_lines(struct file_line * first_line) * * Function : match_actions_file_header_line * - * Description : Match an actions file {{header}} line + * Description : Match an actions file {{header}} line * * Parameters : * 1 : line - String from file @@ -795,7 +814,7 @@ static int match_actions_file_header_line(const char * line, const char * name) * * Function : match_actions_file_header_line * - * Description : Match an actions file {{header}} line + * Description : Match an actions file {{header}} line * * Parameters : * 1 : line - String from file. Must not start with @@ -873,7 +892,7 @@ static jb_err split_line_on_equals(const char * line, char ** pname, char ** pva * * Function : edit_parse_actions_file * - * Description : Parse an actions file in memory. + * Description : Parse an actions file in memory. * * Passed linked list must have the "data" member * zeroed, and must contain valid "next" and @@ -908,7 +927,7 @@ jb_err edit_parse_actions_file(struct editable_file * file) cur_line = file->lines; - /* A note about blank line support: Blank lines should only + /* A note about blank line support: Blank lines should only * ever occur as the last line in the file. This function * is more forgiving than that - FILE_LINE_BLANK can occur * anywhere. @@ -1171,7 +1190,7 @@ jb_err edit_parse_actions_file(struct editable_file * file) * * Function : edit_read_file_lines * - * Description : Read all the lines of a file into memory. + * Description : Read all the lines of a file into memory. * Handles whitespace, comments and line continuation. * * Parameters : @@ -1371,7 +1390,7 @@ jb_err edit_read_file(struct client_state *csp, } /* Correct file->version_str */ - freez((char *)file->version_str); + freez(file->version_str); snprintf(version_buf, 22, "%u", file->version); version_buf[21] = '\0'; file->version_str = strdup(version_buf); @@ -1658,7 +1677,7 @@ static jb_err get_number_param(struct client_state *csp, * * defines UINT_MAX * - * (UINT_MAX - ch) / 10 is the largest number that + * (UINT_MAX - ch) / 10 is the largest number that * can be safely multiplied by 10 then have ch added. */ if (value > ((UINT_MAX - (unsigned)ch) / 10U)) @@ -1703,7 +1722,7 @@ static jb_err get_number_param(struct client_state *csp, * *********************************************************************/ static jb_err map_radio(struct map * exports, - const char * optionname, + const char * optionname, const char * values, char value) { @@ -1711,7 +1730,7 @@ static jb_err map_radio(struct map * exports, char * buf; char * p; char c; - + assert(exports); assert(optionname); assert(values); @@ -2020,7 +2039,7 @@ static jb_err actions_from_radio(const struct map * parameters, * * Description : CGI function that is called when a file is modified * outside the CGI editor. - * + * * Parameters : * 1 : csp = Current client state (buffers, headers, etc...) * 2 : rsp = http_response data structure for output @@ -2029,7 +2048,7 @@ static jb_err actions_from_radio(const struct map * parameters, * CGI Parameters : none * * Returns : JB_ERR_OK on success - * JB_ERR_MEMORY on out-of-memory error. + * JB_ERR_MEMORY on out-of-memory error. * *********************************************************************/ jb_err cgi_error_modified(struct client_state *csp, @@ -2065,7 +2084,7 @@ jb_err cgi_error_modified(struct client_state *csp, * * Description : CGI function that is called when a file cannot * be parsed by the CGI editor. - * + * * Parameters : * 1 : csp = Current client state (buffers, headers, etc...) * 2 : rsp = http_response data structure for output @@ -2074,7 +2093,7 @@ jb_err cgi_error_modified(struct client_state *csp, * CGI Parameters : none * * Returns : JB_ERR_OK on success - * JB_ERR_MEMORY on out-of-memory error. + * JB_ERR_MEMORY on out-of-memory error. * *********************************************************************/ jb_err cgi_error_parse(struct client_state *csp, @@ -2119,7 +2138,7 @@ jb_err cgi_error_parse(struct client_state *csp, * * Description : CGI function that is called when a file cannot be * opened by the CGI editor. - * + * * Parameters : * 1 : csp = Current client state (buffers, headers, etc...) * 2 : rsp = http_response data structure for output @@ -2128,7 +2147,7 @@ jb_err cgi_error_parse(struct client_state *csp, * CGI Parameters : none * * Returns : JB_ERR_OK on success - * JB_ERR_MEMORY on out-of-memory error. + * JB_ERR_MEMORY on out-of-memory error. * *********************************************************************/ jb_err cgi_error_file(struct client_state *csp, @@ -2164,7 +2183,7 @@ jb_err cgi_error_file(struct client_state *csp, * * Description : CGI function that is called if the parameters * (query string) for a CGI were wrong. - * + * * Parameters : * 1 : csp = Current client state (buffers, headers, etc...) * 2 : rsp = http_response data structure for output @@ -2172,7 +2191,7 @@ jb_err cgi_error_file(struct client_state *csp, * CGI Parameters : none * * Returns : JB_ERR_OK on success - * JB_ERR_MEMORY on out-of-memory error. + * JB_ERR_MEMORY on out-of-memory error. * *********************************************************************/ jb_err cgi_error_disabled(struct client_state *csp, @@ -2318,7 +2337,7 @@ jb_err cgi_edit_actions_list(struct client_state *csp, } return err; } - + err = template_load(csp, &url_template, "edit-actions-list-url"); if (err) { @@ -2384,7 +2403,7 @@ jb_err cgi_edit_actions_list(struct client_state *csp, snprintf(buf, 50, "%d", line_number); err = map(section_exports, "sectionid", 1, buf, 1); - err = err || map(section_exports, "actions", 1, + err = err || map(section_exports, "actions", 1, actions_to_html(cur_line->data.action), 0); if ((cur_line->next != NULL) && (cur_line->next->type == FILE_LINE_URL)) @@ -2442,7 +2461,7 @@ jb_err cgi_edit_actions_list(struct client_state *csp, snprintf(buf, 50, "%d", url_1_2); err = err || map(url_exports, "url-1-2", 1, buf, 1); - err = err || map(url_exports, "url", 1, + err = err || map(url_exports, "url", 1, html_encode(cur_line->unprocessed), 0); if (err) @@ -2666,7 +2685,7 @@ jb_err cgi_edit_actions_submit(struct client_state *csp, struct http_response *rsp, const struct map *parameters) { - int sectionid; + unsigned sectionid; char * actiontext; char * newtext; int len; diff --git a/errlog.c b/errlog.c index b9ff49ef..4fa72903 100644 --- a/errlog.c +++ b/errlog.c @@ -1,4 +1,4 @@ -const char errlog_rcs[] = "$Id: errlog.c,v 1.19 2001/09/13 20:08:06 jongfoster Exp $"; +const char errlog_rcs[] = "$Id: errlog.c,v 1.20 2001/09/16 23:04:34 jongfoster Exp $"; /********************************************************************* * * File : $Source: /cvsroot/ijbswa/current/errlog.c,v $ @@ -33,6 +33,9 @@ const char errlog_rcs[] = "$Id: errlog.c,v 1.19 2001/09/13 20:08:06 jongfoster E * * Revisions : * $Log: errlog.c,v $ + * Revision 1.20 2001/09/16 23:04:34 jongfoster + * Fixing a warning + * * Revision 1.19 2001/09/13 20:08:06 jongfoster * Adding support for LOG_LEVEL_CGI * @@ -150,11 +153,12 @@ const char errlog_rcs[] = "$Id: errlog.c,v 1.19 2001/09/13 20:08:06 jongfoster E #include #include -#ifndef _WIN32 +#if !defined(_WIN32) && !defined(__OS2__) #include -#endif /* ndef _WIN32 */ +#endif /* !defined(_WIN32) && !defined(__OS2__) */ #include +#include #ifdef FEATURE_PTHREAD #include #endif /* def FEATURE_PTHREAD */ @@ -166,6 +170,11 @@ const char errlog_rcs[] = "$Id: errlog.c,v 1.19 2001/09/13 20:08:06 jongfoster E #endif /* ndef _WIN_CONSOLE */ #endif /* def _WIN32 */ +#ifdef __OS2__ +#define INCL_DOS +#include +#endif + #include "errlog.h" #include "project.h" @@ -294,10 +303,14 @@ void init_error_log(const char *prog_name, const char *logfname, int debuglevel) void log_error(int loglevel, char *fmt, ...) { va_list ap; - char outbuf[BUFFER_SIZE]; + char *outbuf= NULL; char * src = fmt; int outc = 0; long this_thread = 1; /* was: pthread_t this_thread;*/ +#ifdef __OS2__ + PTIB ptib; + APIRET ulrc; +#endif /* __OS2__ */ #if defined(_WIN32) && !defined(_WIN_CONSOLE) /* @@ -320,8 +333,15 @@ void log_error(int loglevel, char *fmt, ...) /* FIXME get current thread id */ #ifdef FEATURE_PTHREAD this_thread = (long)pthread_self(); +#elif __OS2__ + + ulrc = DosGetInfoBlocks(&ptib, NULL); + if (ulrc == 0) + this_thread = ptib -> tib_ptib2 -> tib2_ultid; #endif /* def FEATURE_PTHREAD */ + outbuf = (char*)malloc(BUFFER_SIZE); + assert(outbuf); switch (loglevel) { case LOG_LEVEL_ERROR: @@ -743,4 +763,3 @@ static char *w32_socket_strerr(int errcode, char *tmp_buf) tab-width: 3 end: */ - diff --git a/filters.c b/filters.c index 57ad34c5..dd7ccb44 100644 --- a/filters.c +++ b/filters.c @@ -1,4 +1,4 @@ -const char filters_rcs[] = "$Id: filters.c,v 1.37 2001/10/22 15:33:56 david__schmidt Exp $"; +const char filters_rcs[] = "$Id: filters.c,v 1.38 2001/10/23 21:32:33 jongfoster Exp $"; /********************************************************************* * * File : $Source: /cvsroot/ijbswa/current/filters.c,v $ @@ -15,10 +15,10 @@ const char filters_rcs[] = "$Id: filters.c,v 1.37 2001/10/22 15:33:56 david__sch * IJBSWA team. http://ijbswa.sourceforge.net * * Based on the Internet Junkbuster originally written - * by and Copyright (C) 1997 Anonymous Coders and + * by and Copyright (C) 1997 Anonymous Coders and * Junkbusters Corporation. http://www.junkbusters.com * - * This program is free software; you can redistribute it + * This program is free software; you can redistribute it * and/or modify it under the terms of the GNU General * Public License as published by the Free Software * Foundation; either version 2 of the License, or (at @@ -38,6 +38,9 @@ const char filters_rcs[] = "$Id: filters.c,v 1.37 2001/10/22 15:33:56 david__sch * * Revisions : * $Log: filters.c,v $ + * Revision 1.38 2001/10/23 21:32:33 jongfoster + * Adding error-checking to selected functions + * * Revision 1.37 2001/10/22 15:33:56 david__schmidt * Special-cased OS/2 out of the Netscape-abort-on-404-in-js problem in * filters.c. Added a FIXME in front of the offending code. I'll gladly @@ -316,11 +319,17 @@ const char filters_rcs[] = "$Id: filters.c,v 1.37 2001/10/22 15:33:56 david__sch #include #ifndef _WIN32 +#ifndef __OS2__ #include +#endif /* ndef __OS2__ */ #include #else #include -#endif +#endif /* ndef _WIN32 */ + +#ifdef __OS2__ +#include +#endif /* def __OS2__ */ #include "project.h" #include "filters.h" @@ -516,7 +525,7 @@ int match_portlist(const char *portlist, int port) { *next++ = '\0'; } - + /* * Loop through all items, checking for match */ @@ -545,8 +554,8 @@ int match_portlist(const char *portlist, int port) free(portlist_copy); return(1); } - - } + + } /* * Jump to next item @@ -561,7 +570,7 @@ int match_portlist(const char *portlist, int port) *next++ = '\0'; } } - + free(portlist_copy); return 0; @@ -587,7 +596,7 @@ struct http_response *block_url(struct client_state *csp) #endif /* def FEATURE_IMAGE_BLOCKING */ struct http_response *rsp; - /* + /* * If it's not blocked, don't block it ;-) */ if ((csp->action->flags & ACTION_BLOCK) == 0) @@ -595,7 +604,7 @@ struct http_response *block_url(struct client_state *csp) return NULL; } - /* + /* * Else, prepare a response */ if (NULL == (rsp = alloc_http_response())) @@ -664,17 +673,17 @@ struct http_response *block_url(struct client_state *csp) return cgi_error_memory(); } } - } + } else #endif /* def FEATURE_IMAGE_BLOCKING */ - /* + /* * Else, generate an HTML "blocked" message: */ { jb_err err; struct map * exports; - + /* FIXME */ #ifdef __EMX__ /* @@ -685,7 +694,7 @@ struct http_response *block_url(struct client_state *csp) * what the csp->http->user_agent is (yet). So we can't use * it to decide if we should work around the NS bug or not. */ - rsp->status = strdup("200 Request for blocked URL"); + rsp->status = strdup("200 Request for blocked URL"); #else /* * Workaround for stupid Netscape bug which prevents @@ -698,11 +707,11 @@ struct http_response *block_url(struct client_state *csp) && !strstr(csp->http->user_agent, "compatible") && !strstr(csp->http->user_agent, "Opera")) { - rsp->status = strdup("200 Request for blocked URL"); + rsp->status = strdup("200 Request for blocked URL"); } else { - rsp->status = strdup("404 Request for blocked URL"); + rsp->status = strdup("404 Request for blocked URL"); } #endif /* __EMX__ */ if (rsp->status == NULL) @@ -781,7 +790,7 @@ struct http_response *trust_url(struct client_state *csp) return NULL; } - /* + /* * Else, prepare a response: */ if (NULL == (rsp = alloc_http_response())) @@ -796,7 +805,7 @@ struct http_response *trust_url(struct client_state *csp) return cgi_error_memory(); } - /* + /* * Export the host, port, and referrer information */ err = map(exports, "hostport", 1, csp->http->hostport, 1) @@ -920,7 +929,7 @@ struct http_response *redirect_url(struct client_state *csp) p = q = csp->http->path; log_error(LOG_LEVEL_REDIRECTS, "checking path for redirects: %s", p); - /* + /* * find the last URL encoded in the request */ while ((p = strstr(p, "http://"))) @@ -928,7 +937,7 @@ struct http_response *redirect_url(struct client_state *csp) q = p++; } - /* + /* * if there was any, generate and return a HTTP redirect */ if (q != csp->http->path) @@ -967,7 +976,7 @@ struct http_response *redirect_url(struct client_state *csp) * using either the info from a previous +image action * or, #ifdef FEATURE_IMAGE_DETECT_MSIE, the info from * the browser's accept header. - * + * * Parameters : * 1 : csp = Current client state (buffers, headers, etc...) * @@ -978,13 +987,13 @@ struct http_response *redirect_url(struct client_state *csp) int is_imageurl(struct client_state *csp) { #ifdef FEATURE_IMAGE_DETECT_MSIE - if ((csp->accept_types + if ((csp->accept_types & (ACCEPT_TYPE_IS_MSIE|ACCEPT_TYPE_MSIE_IMAGE|ACCEPT_TYPE_MSIE_HTML)) == (ACCEPT_TYPE_IS_MSIE|ACCEPT_TYPE_MSIE_IMAGE)) { return 1; } - else if ((csp->accept_types + else if ((csp->accept_types & (ACCEPT_TYPE_IS_MSIE|ACCEPT_TYPE_MSIE_IMAGE|ACCEPT_TYPE_MSIE_HTML)) == (ACCEPT_TYPE_IS_MSIE|ACCEPT_TYPE_MSIE_HTML)) { @@ -1168,7 +1177,7 @@ int is_untrusted_url(struct client_state *csp) * Function : pcrs_filter_response * * Description : Apply all the pcrs jobs from the joblist (re_filterfile) - * to the text buffer that's been accumulated in + * to the text buffer that's been accumulated in * csp->iob->buf and set csp->content_length to the modified * size and raise the CSP_FLAG_MODIFIED flag if appropriate. * @@ -1177,7 +1186,7 @@ int is_untrusted_url(struct client_state *csp) * * Returns : a pointer to the (newly allocated) modified buffer. * or NULL in case something went wrong - * + * *********************************************************************/ char *pcrs_filter_response(struct client_state *csp) { @@ -1237,7 +1246,7 @@ char *pcrs_filter_response(struct client_state *csp) log_error(LOG_LEVEL_RE_FILTER, " produced %d hits (new size %d).", hits, size); - /* + /* * If there were no hits, destroy our copy and let * chat() use the original in csp->iob */ @@ -1260,7 +1269,7 @@ char *pcrs_filter_response(struct client_state *csp) * * Function : gif_deanimate_response * - * Description : Deanimate the GIF image that has been accumulated in + * Description : Deanimate the GIF image that has been accumulated in * csp->iob->buf, set csp->content_length to the modified * size and raise the CSP_FLAG_MODIFIED flag. * @@ -1269,7 +1278,7 @@ char *pcrs_filter_response(struct client_state *csp) * * Returns : a pointer to the (newly allocated) modified buffer. * or NULL in case something went wrong. - * + * *********************************************************************/ char *gif_deanimate_response(struct client_state *csp) { @@ -1318,7 +1327,7 @@ char *gif_deanimate_response(struct client_state *csp) free(in); free(out); return(p); - } + } } @@ -1337,7 +1346,7 @@ char *gif_deanimate_response(struct client_state *csp) * Returns : The new size, i.e. the number of bytes from buffer which * are occupied by the stripped body, or 0 in case something * went wrong - * + * *********************************************************************/ int remove_chunked_transfer_coding(char *buffer, const size_t size) { @@ -1363,7 +1372,7 @@ int remove_chunked_transfer_coding(char *buffer, const size_t size) } newsize += chunksize; from_p += 2; - + memmove(to_p, from_p, (size_t) chunksize); to_p = buffer + newsize; from_p += chunksize + 2; @@ -1395,7 +1404,7 @@ int remove_chunked_transfer_coding(char *buffer, const size_t size) * Returns : N/A * *********************************************************************/ -void url_actions(struct http_request *http, +void url_actions(struct http_request *http, struct client_state *csp) { struct file_list *fl; @@ -1427,8 +1436,8 @@ void url_actions(struct http_request *http, * Returns : N/A * *********************************************************************/ -void apply_url_actions(struct current_action_spec *action, - struct http_request *http, +void apply_url_actions(struct current_action_spec *action, + struct http_request *http, struct url_actions *b) { struct url_spec url[1]; @@ -1552,7 +1561,7 @@ const struct forward_spec * forward_url(struct http_request *http, * them). * * FIXME: Returning a structure is horribly inefficient, please can - * this structure take a (struct url_spec * dest) + * this structure take a (struct url_spec * dest) * pointer instead? * *********************************************************************/ @@ -1623,7 +1632,7 @@ struct url_spec dsplit(char *domain) * * Function : simple_domaincmp * - * Description : Domain-wise Compare fqdn's. The comparison is + * Description : Domain-wise Compare fqdn's. The comparison is * both left- and right-anchored. The individual * domain names are compared with simplematch(). * This is only used by domaincmp. diff --git a/gateway.c b/gateway.c index 4236ca5c..2e36abb3 100644 --- a/gateway.c +++ b/gateway.c @@ -1,4 +1,4 @@ -const char gateway_rcs[] = "$Id: gateway.c,v 1.7 2001/09/12 17:58:26 steudten Exp $"; +const char gateway_rcs[] = "$Id: gateway.c,v 1.8 2001/09/13 20:10:12 jongfoster Exp $"; /********************************************************************* * * File : $Source: /cvsroot/ijbswa/current/gateway.c,v $ @@ -11,10 +11,10 @@ const char gateway_rcs[] = "$Id: gateway.c,v 1.7 2001/09/12 17:58:26 steudten Ex * IJBSWA team. http://ijbswa.sourceforge.net * * Based on the Internet Junkbuster originally written - * by and Copyright (C) 1997 Anonymous Coders and + * by and Copyright (C) 1997 Anonymous Coders and * Junkbusters Corporation. http://www.junkbusters.com * - * This program is free software; you can redistribute it + * This program is free software; you can redistribute it * and/or modify it under the terms of the GNU General * Public License as published by the Free Software * Foundation; either version 2 of the License, or (at @@ -34,6 +34,9 @@ const char gateway_rcs[] = "$Id: gateway.c,v 1.7 2001/09/12 17:58:26 steudten Ex * * Revisions : * $Log: gateway.c,v $ + * Revision 1.8 2001/09/13 20:10:12 jongfoster + * Fixing missing #include under Windows + * * Revision 1.7 2001/09/12 17:58:26 steudten * * add #include @@ -88,6 +91,10 @@ const char gateway_rcs[] = "$Id: gateway.c,v 1.7 2001/09/12 17:58:26 steudten Ex #include #endif /* def __BEOS__ */ +#ifdef __OS2__ +#include +#endif /* def __OS2__ */ + #include "project.h" #include "jcc.h" #include "errlog.h" @@ -96,7 +103,7 @@ const char gateway_rcs[] = "$Id: gateway.c,v 1.7 2001/09/12 17:58:26 steudten Ex const char gateway_h_rcs[] = GATEWAY_H_VERSION; -static int socks4_connect(const struct forward_spec * fwd, +static int socks4_connect(const struct forward_spec * fwd, const char * target_host, int target_port, struct client_state *csp); @@ -143,8 +150,8 @@ static const char socks_userid[] = "anonymous"; * Returns : -1 => failure, else it is the socket file descriptor. * *********************************************************************/ -int forwarded_connect(const struct forward_spec * fwd, - struct http_request *http, +int forwarded_connect(const struct forward_spec * fwd, + struct http_request *http, struct client_state *csp) { const char * dest_host; @@ -201,7 +208,7 @@ int forwarded_connect(const struct forward_spec * fwd, * Returns : -1 => failure, else a socket file descriptor. * *********************************************************************/ -static int socks4_connect(const struct forward_spec * fwd, +static int socks4_connect(const struct forward_spec * fwd, const char * target_host, int target_port, struct client_state *csp) diff --git a/jbsockets.c b/jbsockets.c index 3b36d9db..443e52d8 100644 --- a/jbsockets.c +++ b/jbsockets.c @@ -1,4 +1,4 @@ -const char jbsockets_rcs[] = "$Id: jbsockets.c,v 1.17 2001/09/13 20:11:46 jongfoster Exp $"; +const char jbsockets_rcs[] = "$Id: jbsockets.c,v 1.18 2001/09/21 23:02:02 david__schmidt Exp $"; /********************************************************************* * * File : $Source: /cvsroot/ijbswa/current/jbsockets.c,v $ @@ -35,6 +35,9 @@ const char jbsockets_rcs[] = "$Id: jbsockets.c,v 1.17 2001/09/13 20:11:46 jongfo * * Revisions : * $Log: jbsockets.c,v $ + * Revision 1.18 2001/09/21 23:02:02 david__schmidt + * Cleaning up 2 compiler warnings on OS/2. + * * Revision 1.17 2001/09/13 20:11:46 jongfoster * Fixing 2 compiler warnings under Win32 * @@ -114,7 +117,9 @@ const char jbsockets_rcs[] = "$Id: jbsockets.c,v 1.17 2001/09/13 20:11:46 jongfo #else +#ifndef __OS2__ #include +#endif #include #include #include @@ -123,13 +128,16 @@ const char jbsockets_rcs[] = "$Id: jbsockets.c,v 1.17 2001/09/13 20:11:46 jongfo #ifndef __BEOS__ #include +#ifndef __OS2__ #include +#endif #else #include #endif -#ifdef __EMX__ +#if defined(__EMX__) || defined (__OS2__) #include /* OS/2/EMX needs a little help with select */ +#include #endif #endif @@ -186,7 +194,11 @@ int connect_to(const char *host, int portnum, struct client_state *csp) if (block_acl(dst, csp)) { +#ifdef __OS2__ + errno = SOCEPERM; +#else errno = EPERM; +#endif return(-1); } #endif /* def FEATURE_ACL */ @@ -220,39 +232,45 @@ int connect_to(const char *host, int portnum, struct client_state *csp) } #endif /* def TCP_NODELAY */ -#if !defined(_WIN32) && !defined(__BEOS__) && !defined(AMIGA) +#if !defined(_WIN32) && !defined(__BEOS__) && !defined(AMIGA) && !defined(__OS2__) if ((flags = fcntl(fd, F_GETFL, 0)) != -1) { flags |= O_NDELAY; fcntl(fd, F_SETFL, flags); } -#endif /* !defined(_WIN32) && !defined(__BEOS__) && !defined(AMIGA) */ +#endif /* !defined(_WIN32) && !defined(__BEOS__) && !defined(AMIGA) && !defined(__OS2__) */ while (connect(fd, (struct sockaddr *) & inaddr, sizeof inaddr) == -1) { #ifdef _WIN32 if (errno == WSAEINPROGRESS) +#elif __OS2__ + if (sock_errno() == EINPROGRESS) #else /* ifndef _WIN32 */ if (errno == EINPROGRESS) -#endif /* ndef _WIN32 */ +#endif /* ndef _WIN32 || __OS2__ */ { break; } +#ifdef __OS2__ + if (sock_errno() != EINTR) +#else if (errno != EINTR) +#endif /* __OS2__ */ { close_socket(fd); return(-1); } } -#if !defined(_WIN32) && !defined(__BEOS__) && !defined(AMIGA) +#if !defined(_WIN32) && !defined(__BEOS__) && !defined(AMIGA) && !defined(__OS2__) if (flags != -1) { flags &= ~O_NDELAY; fcntl(fd, F_SETFL, flags); } -#endif /* !defined(_WIN32) && !defined(__BEOS__) && !defined(AMIGA) */ +#endif /* !defined(_WIN32) && !defined(__BEOS__) && !defined(AMIGA) && !defined(__OS2__) */ /* wait for connection to complete */ FD_ZERO(&wfds); @@ -296,7 +314,7 @@ int write_socket(int fd, const char *buf, int len) log_error(LOG_LEVEL_LOG, "%N", len, buf); -#if defined(_WIN32) || defined(__BEOS__) || defined(AMIGA) +#if defined(_WIN32) || defined(__BEOS__) || defined(AMIGA) || defined(__OS2__) return( send(fd, buf, len, 0)); #else return( write(fd, buf, len)); @@ -337,7 +355,7 @@ int read_socket(int fd, char *buf, int len) return(0); } -#if defined(_WIN32) || defined(__BEOS__) || defined(AMIGA) +#if defined(_WIN32) || defined(__BEOS__) || defined(AMIGA) || defined(__OS2__) return( recv(fd, buf, len, 0)); #else return( read(fd, buf, len)); @@ -363,6 +381,8 @@ void close_socket(int fd) closesocket(fd); #elif defined(AMIGA) CloseSocket(fd); +#elif defined(__OS2__) + soclose(fd); #else close(fd); #endif diff --git a/jcc.c b/jcc.c index 44f93989..4700d2f4 100644 --- a/jcc.c +++ b/jcc.c @@ -1,19 +1,19 @@ -const char jcc_rcs[] = "$Id: jcc.c,v 1.48 2001/10/10 19:56:46 jongfoster Exp $"; +const char jcc_rcs[] = "$Id: jcc.c,v 1.49 2001/10/23 21:41:35 jongfoster Exp $"; /********************************************************************* * * File : $Source: /cvsroot/ijbswa/current/jcc.c,v $ * - * Purpose : Main file. Contains main() method, main loop, and + * Purpose : Main file. Contains main() method, main loop, and * the main connection-handling function. * * Copyright : Written by and Copyright (C) 2001 the SourceForge * IJBSWA team. http://ijbswa.sourceforge.net * * Based on the Internet Junkbuster originally written - * by and Copyright (C) 1997 Anonymous Coders and + * by and Copyright (C) 1997 Anonymous Coders and * Junkbusters Corporation. http://www.junkbusters.com * - * This program is free software; you can redistribute it + * This program is free software; you can redistribute it * and/or modify it under the terms of the GNU General * Public License as published by the Free Software * Foundation; either version 2 of the License, or (at @@ -33,6 +33,10 @@ const char jcc_rcs[] = "$Id: jcc.c,v 1.48 2001/10/10 19:56:46 jongfoster Exp $"; * * Revisions : * $Log: jcc.c,v $ + * Revision 1.49 2001/10/23 21:41:35 jongfoster + * Added call to initialize the (statically-allocated of course) + * "out of memory" CGI response. + * * Revision 1.48 2001/10/10 19:56:46 jongfoster * Moving some code that wasn't cookie-related out of an #ifdef * FEATURE_COOKIE_JAR @@ -360,9 +364,11 @@ const char jcc_rcs[] = "$Id: jcc.c,v 1.48 2001/10/10 19:56:46 jongfoster Exp $"; #else /* ifndef _WIN32 */ +# if !defined (__OS2__) # include -# include # include +# endif /* ndef __OS2__ */ +# include # include # include @@ -371,9 +377,14 @@ const char jcc_rcs[] = "$Id: jcc.c,v 1.48 2001/10/10 19:56:46 jongfoster Exp $"; # include /* declarations for threads and stuff. */ # endif -# ifdef __EMX__ +# if defined(__EMX__) || defined(__OS2__) # include /* OS/2/EMX needs a little help with select */ # endif +# ifdef __OS2__ +#define INCL_DOS +# include +#define bzero(B,N) memset(B,0x00,n) +# endif # ifndef FD_ZERO # include @@ -424,6 +435,10 @@ static int32 server_thread(void *data); #define sleep(N) Sleep(((N) * 1000)) #endif +#ifdef __OS2__ +#define sleep(N) DosSleep(((N) * 100)) +#endif + /* The vanilla wafer. */ static const char VANILLA_WAFER[] = @@ -442,7 +457,7 @@ static const char VANILLA_WAFER[] = * * Description : Once a connection to the client has been accepted, * this function is called (via serve()) to handle the - * main business of the communication. When this + * main business of the communication. When this * function returns, the caller must close the client * socket handle. * @@ -461,7 +476,7 @@ static void chat(struct client_state *csp) { /* * This next lines are a little ugly, but they simplifies the if statements - * below. Basically if TOGGLE, then we want the if to test if the + * below. Basically if TOGGLE, then we want the if to test if the * CSP_FLAG_TOGGLED_ON flag ist set, else we don't. And if FEATURE_FORCE_LOAD, * then we want the if to test for CSP_FLAG_FORCED , else we don't */ @@ -471,7 +486,7 @@ static void chat(struct client_state *csp) # define IS_TOGGLED_ON_AND #endif /* ndef FEATURE_TOGGLE */ #ifdef FEATURE_FORCE_LOAD -# define IS_NOT_FORCED_AND !(csp->flags & CSP_FLAG_FORCED) && +# define IS_NOT_FORCED_AND !(csp->flags & CSP_FLAG_FORCED) && #else /* ifndef FEATURE_FORCE_LOAD */ # define IS_NOT_FORCED_AND #endif /* def FEATURE_FORCE_LOAD */ @@ -495,7 +510,7 @@ static void chat(struct client_state *csp) int gif_deanimate; /* bool, 1==will deanimate gifs */ /* Function that does the content filtering for the current request */ - char *(*content_filter)() = NULL; + char *(*content_filter)() = NULL; /* Skeleton for HTTP response, if we should intercept the request */ struct http_response *rsp; @@ -526,7 +541,7 @@ static void chat(struct client_state *csp) { continue; /* more to come! */ } - + #ifdef FEATURE_FORCE_LOAD /* If this request contains the FORCE_PREFIX, * better get rid of it now and set the force flag --oes @@ -537,7 +552,7 @@ static void chat(struct client_state *csp) strclean(req, FORCE_PREFIX); log_error(LOG_LEVEL_FORCE, "Enforcing request \"%s\".\n", req); csp->flags |= CSP_FLAG_FORCED; - } + } #endif /* def FEATURE_FORCE_LOAD */ @@ -573,7 +588,7 @@ static void chat(struct client_state *csp) * full orininal URL (w/url) * Note that the path and/or the HTTP version may * have been altered by now. - * + * * connect = Open a socket to the host:port of the server * and short-circuit server and client socket. * @@ -585,7 +600,7 @@ static void chat(struct client_state *csp) * parent's). After sending the request to the parent, we simply * tunnel. * - * here's the matrix: + * here's the matrix: * SSL * 0 1 * +--------+--------+ @@ -600,7 +615,7 @@ static void chat(struct client_state *csp) * */ - /* + /* * Determine the actions for this URL */ #ifdef FEATURE_TOGGLE @@ -623,20 +638,20 @@ static void chat(struct client_state *csp) */ if(http->ssl) { - if( ( !(csp->action->flags & ACTION_LIMIT_CONNECT) && csp->http->port != 443) + if( ( !(csp->action->flags & ACTION_LIMIT_CONNECT) && csp->http->port != 443) || (csp->action->flags & ACTION_LIMIT_CONNECT && !match_portlist(csp->action->string[ACTION_STRING_LIMIT_CONNECT], csp->http->port)) ) { strcpy(buf, CFORBIDDEN); write_socket(csp->cfd, buf, strlen(buf)); - + log_error(LOG_LEVEL_CONNECT, "Denying suspicious CONNECT request from %s", csp->ip_addr_str); log_error(LOG_LEVEL_CLF, "%s - - [%T] \" \" 403 0", csp->ip_addr_str); return; } } - + /* * Downgrade http version from 1.1 to 1.0 if +downgrade @@ -652,8 +667,8 @@ static void chat(struct client_state *csp) * (Re)build the HTTP request for non-SSL requests. * If forwarding, use the whole URL, else, use only the path. */ - if (http->ssl == 0) - { + if (http->ssl == 0) + { freez(http->cmd); http->cmd = strsav(http->cmd, http->gpc); @@ -723,14 +738,14 @@ static void chat(struct client_state *csp) /* We have a request. */ - /* + /* * Now, check to see if we need to intercept it, i.e. * If */ - + if ( /* a CGI call was detected and answered */ - (NULL != (rsp = dispatch_cgi(csp))) + (NULL != (rsp = dispatch_cgi(csp))) /* or we are enabled and... */ || (IS_ENABLED_AND ( @@ -745,7 +760,7 @@ static void chat(struct client_state *csp) /* ..or a fast redirect kicked in */ #ifdef FEATURE_FAST_REDIRECTS - || (((csp->action->flags & ACTION_FAST_REDIRECTS) != 0) && + || (((csp->action->flags & ACTION_FAST_REDIRECTS) != 0) && (NULL != (rsp = redirect_url(csp)))) #endif /* def FEATURE_FAST_REDIRECTS */ )) @@ -754,7 +769,7 @@ static void chat(struct client_state *csp) /* 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)) - { + { log_error(LOG_LEVEL_ERROR, "write to: %s failed: %E", http->host); } @@ -765,7 +780,7 @@ static void chat(struct client_state *csp) /* Log (FIXME: All intercept reasons apprear as "crunch" with Status 200) */ log_error(LOG_LEVEL_GPC, "%s%s crunch!", http->hostport, http->path); - log_error(LOG_LEVEL_CLF, "%s - - [%T] \"%s\" 200 3", csp->ip_addr_str, http->cmd); + log_error(LOG_LEVEL_CLF, "%s - - [%T] \"%s\" 200 3", csp->ip_addr_str, http->cmd); /* Clean up and return */ free_http_response(rsp); @@ -797,14 +812,14 @@ static void chat(struct client_state *csp) { rsp = error_response(csp, "no-such-domain", errno); - log_error(LOG_LEVEL_CLF, "%s - - [%T] \"%s\" 404 0", + log_error(LOG_LEVEL_CLF, "%s - - [%T] \"%s\" 404 0", csp->ip_addr_str, http->cmd); } else { rsp = error_response(csp, "connect-failed", errno); - log_error(LOG_LEVEL_CLF, "%s - - [%T] \"%s\" 503 0", + log_error(LOG_LEVEL_CLF, "%s - - [%T] \"%s\" 503 0", csp->ip_addr_str, http->cmd); } @@ -813,7 +828,7 @@ static void chat(struct client_state *csp) { 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)) - { + { log_error(LOG_LEVEL_ERROR, "write to: %s failed: %E", http->host); } } @@ -841,8 +856,8 @@ static void chat(struct client_state *csp) log_error(LOG_LEVEL_CONNECT, "write header to: %s failed: %E", http->hostport); - log_error(LOG_LEVEL_CLF, "%s - - [%T] \"%s\" 503 0", - csp->ip_addr_str, http->cmd); + log_error(LOG_LEVEL_CLF, "%s - - [%T] \"%s\" 503 0", + csp->ip_addr_str, http->cmd); rsp = error_response(csp, "connect-failed", errno); @@ -850,7 +865,7 @@ static void chat(struct client_state *csp) { if ((write_socket(csp->cfd, rsp->head, n) != n) || (write_socket(csp->cfd, rsp->body, rsp->content_length) != rsp->content_length)) - { + { log_error(LOG_LEVEL_ERROR, "write to: %s failed: %E", http->host); } } @@ -867,8 +882,8 @@ static void chat(struct client_state *csp) * so just send the "connect succeeded" message to the * client, flush the rest, and get out of the way. */ - log_error(LOG_LEVEL_CLF, "%s - - [%T] \"%s\" 200 2\n", - csp->ip_addr_str, http->cmd); + log_error(LOG_LEVEL_CLF, "%s - - [%T] \"%s\" 200 2\n", + csp->ip_addr_str, http->cmd); if (write_socket(csp->cfd, CSUCCEED, sizeof(CSUCCEED)-1) < 0) { @@ -941,8 +956,8 @@ static void chat(struct client_state *csp) { log_error(LOG_LEVEL_ERROR, "read from: %s failed: %E", http->host); - log_error(LOG_LEVEL_CLF, "%s - - [%T] \"%s\" 503 0", - csp->ip_addr_str, http->cmd); + log_error(LOG_LEVEL_CLF, "%s - - [%T] \"%s\" 503 0", + csp->ip_addr_str, http->cmd); rsp = error_response(csp, "connect-failed", errno); @@ -950,7 +965,7 @@ static void chat(struct client_state *csp) { 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)) - { + { log_error(LOG_LEVEL_ERROR, "write to: %s failed: %E", http->host); } } @@ -992,7 +1007,7 @@ static void chat(struct client_state *csp) */ if (n == 0) { - + if (server_body || http->ssl) { /* @@ -1032,7 +1047,7 @@ static void chat(struct client_state *csp) } /* - * This is NOT the body, so + * This is NOT the body, so * Let's pretend the server just sent us a blank line. */ n = sprintf(buf, "\r\n"); @@ -1055,7 +1070,7 @@ static void chat(struct client_state *csp) { if (content_filter) { - add_to_iob(csp, buf, n); + add_to_iob(csp, buf, n); /* * If the buffer limit will be reached on the next read, @@ -1065,7 +1080,7 @@ static void chat(struct client_state *csp) if (csp->iob->eod - csp->iob->buf + BUFFER_SIZE > csp->config->buffer_limit) { log_error(LOG_LEVEL_ERROR, "Buffer size limit reached! Flushing and stepping back."); - + hdr = sed(server_patterns, add_server_headers, csp); n = strlen(hdr); byte_count += n; @@ -1237,8 +1252,8 @@ static void chat(struct client_state *csp) return; /* huh? we should never get here */ } - log_error(LOG_LEVEL_CLF, "%s - - [%T] \"%s\" 200 %d", - csp->ip_addr_str, http->cmd, byte_count); + log_error(LOG_LEVEL_CLF, "%s - - [%T] \"%s\" 200 %d", + csp->ip_addr_str, http->cmd, byte_count); } @@ -1315,7 +1330,7 @@ static int32 server_thread(void *data) * any load fails, and can't bind port. * * Else main never returns, the process must be signaled - * to terminate execution. Or, on Windows, use the + * to terminate execution. Or, on Windows, use the * "File", "Exit" menu option. * *********************************************************************/ @@ -1369,7 +1384,7 @@ int main(int argc, const char *argv[]) #endif -#ifndef _WIN32 +#if !defined(_WIN32) && !defined(__OS2__) signal(SIGPIPE, SIG_IGN); signal(SIGCHLD, SIG_IGN); @@ -1423,8 +1438,8 @@ static void listen_loop(void) { log_error(LOG_LEVEL_FATAL, "can't bind %s:%d: %E " "- There may be another junkbuster or some other " - "proxy running on port %d", - (NULL != config->haddr) ? config->haddr : "INADDR_ANY", + "proxy running on port %d", + (NULL != config->haddr) ? config->haddr : "INADDR_ANY", config->hport, config->hport ); /* shouldn't get here */ @@ -1436,7 +1451,7 @@ static void listen_loop(void) while (FOREVER) { -#if !defined(FEATURE_PTHREAD) && !defined(_WIN32) && !defined(__BEOS__) && !defined(AMIGA) +#if !defined(FEATURE_PTHREAD) && !defined(_WIN32) && !defined(__BEOS__) && !defined(AMIGA) && !defined(__OS2__) while (waitpid(-1, NULL, WNOHANG) > 0) { /* zombie children */ @@ -1480,8 +1495,8 @@ static void listen_loop(void) { log_error(LOG_LEVEL_FATAL, "can't bind %s:%d: %E " "- There may be another junkbuster or some other " - "proxy running on port %d", - (NULL != config->haddr) ? config->haddr : "INADDR_ANY", + "proxy running on port %d", + (NULL != config->haddr) ? config->haddr : "INADDR_ANY", config->hport, config->hport ); /* shouldn't get here */ @@ -1500,7 +1515,7 @@ static void listen_loop(void) #ifdef AMIGA if(!childs) { - exit(1); + exit(1); } #endif freez(csp); @@ -1568,6 +1583,15 @@ static void listen_loop(void) csp); #endif +#if defined(__OS2__) && !defined(SELECTED_ONE_OPTION) +#define SELECTED_ONE_OPTION + child_id = _beginthread( + serve, + NULL, + 64 * 1024, + csp); +#endif + #if defined(__BEOS__) && !defined(SELECTED_ONE_OPTION) #define SELECTED_ONE_OPTION { diff --git a/killpopup.c b/killpopup.c index 22f44e27..3e594c54 100644 --- a/killpopup.c +++ b/killpopup.c @@ -1,4 +1,4 @@ -const char killpopup_rcs[] = "$Id: killpopup.c,v 1.10 2001/09/22 16:34:44 jongfoster Exp $"; +const char killpopup_rcs[] = "$Id: killpopup.c,v 1.11 2001/10/07 15:42:41 oes Exp $"; /********************************************************************* * * File : $Source: /cvsroot/ijbswa/current/killpopup.c,v $ @@ -9,10 +9,10 @@ const char killpopup_rcs[] = "$Id: killpopup.c,v 1.10 2001/09/22 16:34:44 jongfo * IJBSWA team. http://ijbswa.sourceforge.net * * Based on the Internet Junkbuster originally written - * by and Copyright (C) 1997 Anonymous Coders and + * by and Copyright (C) 1997 Anonymous Coders and * Junkbusters Corporation. http://www.junkbusters.com * - * This program is free software; you can redistribute it + * This program is free software; you can redistribute it * and/or modify it under the terms of the GNU General * Public License as published by the Free Software * Foundation; either version 2 of the License, or (at @@ -32,6 +32,10 @@ const char killpopup_rcs[] = "$Id: killpopup.c,v 1.10 2001/09/22 16:34:44 jongfo * * Revisions : * $Log: killpopup.c,v $ + * Revision 1.11 2001/10/07 15:42:41 oes + * filter_popups now gets a csp pointer so it can raise the new + * CSP_FLAG_MODIFIED flag. + * * Revision 1.10 2001/09/22 16:34:44 jongfoster * Removing unneeded #includes * @@ -94,7 +98,7 @@ const char killpopup_rcs[] = "$Id: killpopup.c,v 1.10 2001/09/22 16:34:44 jongfo #include #include -#ifndef _WIN32 +#if !defined(_WIN32) && !defined(__OS2__) #include #endif @@ -141,7 +145,7 @@ void filter_popups(char *buff, struct client_state *csp) csp->flags |= CSP_FLAG_MODIFIED; } } - + while ((popup = strstr( buff, ".resizeTo(" )) != NULL) { if ( popup ) diff --git a/list.c b/list.c index 752948f0..078723cc 100644 --- a/list.c +++ b/list.c @@ -1,4 +1,4 @@ -const char list_rcs[] = "$Id: list.c,v 1.10 2001/09/16 17:30:24 jongfoster Exp $"; +const char list_rcs[] = "$Id: list.c,v 1.11 2001/10/23 21:21:03 jongfoster Exp $"; /********************************************************************* * * File : $Source: /cvsroot/ijbswa/current/list.c,v $ @@ -11,10 +11,10 @@ const char list_rcs[] = "$Id: list.c,v 1.10 2001/09/16 17:30:24 jongfoster Exp $ * IJBSWA team. http://ijbswa.sourceforge.net * * Based on the Internet Junkbuster originally written - * by and Copyright (C) 1997 Anonymous Coders and + * by and Copyright (C) 1997 Anonymous Coders and * Junkbusters Corporation. http://www.junkbusters.com * - * This program is free software; you can redistribute it + * This program is free software; you can redistribute it * and/or modify it under the terms of the GNU General * Public License as published by the Free Software * Foundation; either version 2 of the License, or (at @@ -34,6 +34,11 @@ const char list_rcs[] = "$Id: list.c,v 1.10 2001/09/16 17:30:24 jongfoster Exp $ * * Revisions : * $Log: list.c,v $ + * Revision 1.11 2001/10/23 21:21:03 jongfoster + * New error handling - error codes are now jb_errs, not ints. + * Changed the way map() handles out-of-memory, to dramatically + * reduce the amount of error-checking clutter needed. + * * Revision 1.10 2001/09/16 17:30:24 jongfoster * Fixing a compiler warning. * @@ -105,7 +110,7 @@ const char list_rcs[] = "$Id: list.c,v 1.10 2001/09/16 17:30:24 jongfoster Exp $ #endif #include -#ifndef _WIN32 +#if !defined(_WIN32) && !defined(__OS2__) #include #endif @@ -130,8 +135,8 @@ static int list_is_valid (const struct list *the_list); * then pass it to this function. * (Implementation note: Rather than calling this * function, you can also just memset the memory to - * zero, e.g. if you have a larger structure you - * want to initialize quickly. However, that isn't + * zero, e.g. if you have a larger structure you + * want to initialize quickly. However, that isn't * really good design.) * * Parameters : @@ -157,9 +162,9 @@ void init_list(struct list *the_list) * calling list_init(). * * (Implementation note: You *can* reuse the_list - * without calling list_init(), but please don't. + * without calling list_init(), but please don't. * If you want to remove all entries from a list - * and still have a usable list, then use + * and still have a usable list, then use * list_remove_all().) * * Parameters : @@ -177,7 +182,7 @@ void destroy_list (struct list *the_list) for (cur_entry = the_list->first; cur_entry ; cur_entry = next_entry) { next_entry = cur_entry->next; - freez((char *)cur_entry->str); + freez(cur_entry->str); free(cur_entry); } @@ -193,7 +198,7 @@ void destroy_list (struct list *the_list) * Description : Check that a string list is valid. The intended * usage is "assert(list_is_valid(the_list))". * Currently this checks that "the_list->last" - * is correct, and that the list dosn't contain + * is correct, and that the list dosn't contain * circular references. It is likely to crash if * it's passed complete garbage. * @@ -223,7 +228,7 @@ static int list_is_valid (const struct list *the_list) if (cur_entry->str) { /* - * Just check that this string can be accessed - i.e. it's a valid + * Just check that this string can be accessed - i.e. it's a valid * pointer. */ strlen(cur_entry->str); @@ -273,7 +278,7 @@ static int list_is_valid (const struct list *the_list) * 2 : str = string to add to the list (maybe NULL) * * Returns : JB_ERR_OK on success - * JB_ERR_MEMORY on out-of-memory error. + * JB_ERR_MEMORY on out-of-memory error. * On error, the_list will be unchanged. * *********************************************************************/ @@ -329,7 +334,7 @@ jb_err enlist(struct list *the_list, const char *str) * 2 : str = string to add to the list (maybe NULL) * * Returns : JB_ERR_OK on success - * JB_ERR_MEMORY on out-of-memory error. + * JB_ERR_MEMORY on out-of-memory error. * On error, the_list will be unchanged. * *********************************************************************/ @@ -354,7 +359,7 @@ jb_err enlist_first(struct list *the_list, const char *str) } } /* else { cur->str = NULL; } - implied by zalloc */ - + cur->next = the_list->first; the_list->first = cur; @@ -375,7 +380,7 @@ jb_err enlist_first(struct list *the_list, const char *str) * Description : Append a string into a specified string list, * if & only if it's not there already. * If the num_significant_chars argument is nonzero, - * only compare up to the nth character. + * only compare up to the nth character. * * Parameters : * 1 : the_list = pointer to list @@ -384,7 +389,7 @@ jb_err enlist_first(struct list *the_list, const char *str) * for uniqueness test, or 0 to require an exact match. * * Returns : JB_ERR_OK on success - * JB_ERR_MEMORY on out-of-memory error. + * JB_ERR_MEMORY on out-of-memory error. * On error, the_list will be unchanged. * "Success" does not indicate whether or not the * item was already in the list. @@ -444,7 +449,7 @@ jb_err enlist_unique(struct list *the_list, const char *str, * 3 : value = HTTP header value (e.g. "text/html") * * Returns : JB_ERR_OK on success - * JB_ERR_MEMORY on out-of-memory error. + * JB_ERR_MEMORY on out-of-memory error. * On error, the_list will be unchanged. * "Success" does not indicate whether or not the * header was already in the list. @@ -489,7 +494,7 @@ jb_err enlist_unique_header(struct list *the_list, const char *name, * Description : Remove all entries from a list. On return, the_list * is a valid, empty list. Note that this is similar * to destroy_list(), but the difference is that this - * function guarantees that the list structure is still + * function guarantees that the list structure is still * valid after the call. * * Parameters : @@ -509,7 +514,7 @@ void list_remove_all(struct list *the_list) for (cur_entry = the_list->first; cur_entry ; cur_entry = next_entry) { next_entry = cur_entry->next; - freez((char *)cur_entry->str); + freez(cur_entry->str); free(cur_entry); } @@ -688,7 +693,7 @@ int list_remove_list(struct list *dest, const struct list *src) * 1 : src = pointer to source list for copy. * * Returns : JB_ERR_OK on success - * JB_ERR_MEMORY on out-of-memory error. + * JB_ERR_MEMORY on out-of-memory error. * On error, dest will be empty. * *********************************************************************/ @@ -785,7 +790,7 @@ jb_err list_duplicate(struct list *dest, const struct list *src) * 2 : src = pointer to source for merge. * * Returns : JB_ERR_OK on success - * JB_ERR_MEMORY on out-of-memory error. + * JB_ERR_MEMORY on out-of-memory error. * On error, some (but not all) of src might have * been copied into dest. * @@ -836,7 +841,7 @@ int list_is_empty(const struct list *the_list) { assert(the_list); assert(list_is_valid(the_list)); - + return (the_list->first == NULL); } @@ -881,10 +886,10 @@ void free_map(struct map *the_map) return; } - for (cur_entry = the_map->first; cur_entry != NULL; cur_entry = next_entry) + for (cur_entry = the_map->first; cur_entry != NULL; cur_entry = next_entry) { - freez((char *)cur_entry->name); - freez((char *)cur_entry->value); + freez(cur_entry->name); + freez(cur_entry->value); next_entry = cur_entry->next; free(cur_entry); @@ -923,9 +928,9 @@ void free_map(struct map *the_map) * err = map(mymap, "xyz", 1, html_encode(somestring), 0); * * err will be set to JB_ERR_MEMORY if either call runs - * out-of-memory. Without these features, you would - * need to check the return value of html_encode in the - * above example for NULL, which (at least) doubles the + * out-of-memory. Without these features, you would + * need to check the return value of html_encode in the + * above example for NULL, which (at least) doubles the * amount of error-checking code needed. * * Parameters : @@ -936,7 +941,7 @@ void free_map(struct map *the_map) * 5 : value_needs_copying = flag set if a copy of value should be used * * Returns : JB_ERR_OK on success - * JB_ERR_MEMORY on out-of-memory error. + * JB_ERR_MEMORY on out-of-memory error. * *********************************************************************/ jb_err map(struct map *the_map, diff --git a/loadcfg.c b/loadcfg.c index aade4ea3..d92dbeca 100644 --- a/loadcfg.c +++ b/loadcfg.c @@ -1,10 +1,10 @@ -const char loadcfg_rcs[] = "$Id: loadcfg.c,v 1.23 2001/10/07 15:36:00 oes Exp $"; +const char loadcfg_rcs[] = "$Id: loadcfg.c,v 1.24 2001/10/23 21:40:30 jongfoster Exp $"; /********************************************************************* * * File : $Source: /cvsroot/ijbswa/current/loadcfg.c,v $ * * Purpose : Loads settings from the configuration file into - * global variables. This file contains both the + * global variables. This file contains both the * routine to load the configuration and the global * variables it writes to. * @@ -12,10 +12,10 @@ const char loadcfg_rcs[] = "$Id: loadcfg.c,v 1.23 2001/10/07 15:36:00 oes Exp $" * IJBSWA team. http://ijbswa.sourceforge.net * * Based on the Internet Junkbuster originally written - * by and Copyright (C) 1997 Anonymous Coders and + * by and Copyright (C) 1997 Anonymous Coders and * Junkbusters Corporation. http://www.junkbusters.com * - * This program is free software; you can redistribute it + * This program is free software; you can redistribute it * and/or modify it under the terms of the GNU General * Public License as published by the Free Software * Foundation; either version 2 of the License, or (at @@ -35,6 +35,10 @@ const char loadcfg_rcs[] = "$Id: loadcfg.c,v 1.23 2001/10/07 15:36:00 oes Exp $" * * Revisions : * $Log: loadcfg.c,v $ + * Revision 1.24 2001/10/23 21:40:30 jongfoster + * Added support for enable-edit-actions and enable-remote-toggle config + * file options. + * * Revision 1.23 2001/10/07 15:36:00 oes * Introduced new config option "buffer-limit" * @@ -229,9 +233,11 @@ const char loadcfg_rcs[] = "$Id: loadcfg.c,v 1.23 2001/10/07 15:36:00 oes Exp $" #else /* ifndef _WIN32 */ +#ifndef __OS2__ # include -# include # include +#endif +# include # include # include @@ -368,7 +374,7 @@ void unload_configfile (void * data) cur_fwd = next_fwd; } config->forward = NULL; - + #ifdef FEATURE_COOKIE_JAR if ( NULL != config->jar ) { @@ -377,22 +383,22 @@ void unload_configfile (void * data) } #endif /* def FEATURE_COOKIE_JAR */ - freez((char *)config->confdir); - freez((char *)config->logdir); + freez(config->confdir); + freez(config->logdir); - freez((char *)config->haddr); - freez((char *)config->logfile); + freez(config->haddr); + freez(config->logfile); - freez((char *)config->actions_file); - freez((char *)config->admin_address); - freez((char *)config->proxy_info_url); - freez((char *)config->proxy_args); + freez(config->actions_file); + freez(config->admin_address); + freez(config->proxy_info_url); + freez(config->proxy_args); #ifdef FEATURE_COOKIE_JAR - freez((char *)config->jarfile); + freez(config->jarfile); #endif /* def FEATURE_COOKIE_JAR */ - freez((char *)config->re_filterfile); + freez(config->re_filterfile); } @@ -404,7 +410,7 @@ void unload_configfile (void * data) * Description : Load the config file and all parameters. * * Parameters : - * 1 : csp = Client state (the config member will be + * 1 : csp = Client state (the config member will be * filled in by this function). * * Returns : 0 => Ok, everything else is an error. @@ -448,9 +454,9 @@ struct configuration_spec * load_config(void) /* * This is backwards from how it's usually done. - * Following the usual pattern, "fs" would be stored in a member + * Following the usual pattern, "fs" would be stored in a member * variable in "csp", and then we'd access "config" from "fs->f", - * using a cast. However, "config" is used so often that a + * using a cast. However, "config" is used so often that a * cast each time would be very ugly, and the extra indirection * would waste CPU cycles. Therefore we store "config" in * "csp->config", and "fs" in "csp->config->config_file_list". @@ -530,7 +536,7 @@ struct configuration_spec * load_config(void) * In confdir by default ****************************************************************************/ case hash_actions_file : - freez((char *)config->actions_file); + freez(config->actions_file); config->actions_file = make_path(config->confdir, arg); continue; @@ -538,24 +544,24 @@ struct configuration_spec * load_config(void) * admin-address email-address ****************************************************************************/ case hash_admin_address : - freez((char *)config->admin_address); + freez(config->admin_address); config->admin_address = strdup(arg); - continue; + continue; /**************************************************************************** * buffer-limit n ****************************************************************************/ case hash_buffer_limit : config->buffer_limit = (size_t) 1024 * atoi(arg); - continue; + continue; /**************************************************************************** * confdir directory-name ****************************************************************************/ case hash_confdir : - freez((char *)config->confdir); + freez(config->confdir); config->confdir = strdup(arg); - continue; + continue; /**************************************************************************** * debug n @@ -631,7 +637,7 @@ struct configuration_spec * load_config(void) * actions file, the last match wins. However, the internal * implementations are different: The actions file is stored * in the same order as the file, and scanned completely. - * With the ACL, we reverse the order as we load it, then + * With the ACL, we reverse the order as we load it, then * when we scan it we stop as soon as we get a match. */ cur_acl->next = config->acl; @@ -813,7 +819,7 @@ struct configuration_spec * load_config(void) /* Add to list. */ cur_fwd->next = config->forward; config->forward = cur_fwd; - + continue; /**************************************************************************** @@ -891,7 +897,7 @@ struct configuration_spec * load_config(void) /* Add to list. */ cur_fwd->next = config->forward; config->forward = cur_fwd; - + continue; /**************************************************************************** @@ -900,7 +906,7 @@ struct configuration_spec * load_config(void) ****************************************************************************/ #ifdef FEATURE_COOKIE_JAR case hash_jarfile : - freez((char *)config->jarfile); + freez(config->jarfile); config->jarfile = make_path(config->logdir, arg); continue; #endif /* def FEATURE_COOKIE_JAR */ @@ -909,7 +915,7 @@ struct configuration_spec * load_config(void) * listen-address [ip][:port] ****************************************************************************/ case hash_listen_address : - freez((char *)config->haddr); + freez(config->haddr); config->haddr = strdup(arg); continue; @@ -917,16 +923,16 @@ struct configuration_spec * load_config(void) * logdir directory-name ****************************************************************************/ case hash_logdir : - freez((char *)config->logdir); + freez(config->logdir); config->logdir = strdup(arg); - continue; + continue; /**************************************************************************** * logfile log-file-name * In logdir by default ****************************************************************************/ case hash_logfile : - freez((char *)config->logfile); + freez(config->logfile); config->logfile = make_path(config->logdir, arg); continue; @@ -998,7 +1004,7 @@ struct configuration_spec * load_config(void) * actions file, the last match wins. However, the internal * implementations are different: The actions file is stored * in the same order as the file, and scanned completely. - * With the ACL, we reverse the order as we load it, then + * With the ACL, we reverse the order as we load it, then * when we scan it we stop as soon as we get a match. */ cur_acl->next = config->acl; @@ -1011,7 +1017,7 @@ struct configuration_spec * load_config(void) * proxy-info-url url ****************************************************************************/ case hash_proxy_info_url : - freez((char *)config->proxy_info_url); + freez(config->proxy_info_url); config->proxy_info_url = strdup(arg); continue; @@ -1020,7 +1026,7 @@ struct configuration_spec * load_config(void) * In confdir by default. ****************************************************************************/ case hash_re_filterfile : - freez((char *)config->re_filterfile); + freez(config->re_filterfile); config->re_filterfile = make_path(config->confdir, arg); continue; @@ -1055,7 +1061,7 @@ struct configuration_spec * load_config(void) ****************************************************************************/ #ifdef FEATURE_TRUST case hash_trustfile : - freez((char *)config->trustfile); + freez(config->trustfile); config->trustfile = make_path(config->confdir, arg); continue; #endif /* def FEATURE_TRUST */ @@ -1294,7 +1300,7 @@ struct configuration_spec * load_config(void) #ifdef FEATURE_TRUST g_trustfile = config->trustfile; #endif /* def FEATURE_TRUST */ - + #endif /* defined(_WIN32) && !defined (_WIN_CONSOLE) */ /* FIXME: end kludge */ diff --git a/loaders.c b/loaders.c index 7843fc4c..4cf6663f 100644 --- a/loaders.c +++ b/loaders.c @@ -1,21 +1,21 @@ -const char loaders_rcs[] = "$Id: loaders.c,v 1.28 2001/10/07 15:40:39 oes Exp $"; +const char loaders_rcs[] = "$Id: loaders.c,v 1.29 2001/10/23 21:38:53 jongfoster Exp $"; /********************************************************************* * * File : $Source: /cvsroot/ijbswa/current/loaders.c,v $ * * Purpose : Functions to load and unload the various * configuration files. Also contains code to manage - * the list of active loaders, and to automatically + * the list of active loaders, and to automatically * unload files that are no longer in use. * * Copyright : Written by and Copyright (C) 2001 the SourceForge * IJBSWA team. http://ijbswa.sourceforge.net * * Based on the Internet Junkbuster originally written - * by and Copyright (C) 1997 Anonymous Coders and + * by and Copyright (C) 1997 Anonymous Coders and * Junkbusters Corporation. http://www.junkbusters.com * - * This program is free software; you can redistribute it + * This program is free software; you can redistribute it * and/or modify it under the terms of the GNU General * Public License as published by the Free Software * Foundation; either version 2 of the License, or (at @@ -35,6 +35,9 @@ const char loaders_rcs[] = "$Id: loaders.c,v 1.28 2001/10/07 15:40:39 oes Exp $" * * Revisions : * $Log: loaders.c,v $ + * Revision 1.29 2001/10/23 21:38:53 jongfoster + * Adding error-checking to create_url_spec() + * * Revision 1.28 2001/10/07 15:40:39 oes * Replaced 6 boolean members of csp with one bitmap (csp->flags) * @@ -189,7 +192,7 @@ const char loaders_rcs[] = "$Id: loaders.c,v 1.28 2001/10/07 15:40:39 oes Exp $" #include #include -#ifndef _WIN32 +#if !defined(_WIN32) && !defined(__OS2__) #include #endif @@ -295,8 +298,8 @@ void sweep(void) } else - /* - * this client is not active, release its resources + /* + * this client is not active, release its resources * and the ones of all inactive clients that might * follow it */ @@ -304,22 +307,22 @@ void sweep(void) while (!(ncsp->flags & CSP_FLAG_ACTIVE)) { csp->next = ncsp->next; - + freez(ncsp->ip_addr_str); freez(ncsp->my_ip_addr_str); freez(ncsp->my_hostname); - + #ifdef FEATURE_TRUST freez(ncsp->referrer); #endif /* def FEATURE_TRUST */ freez(ncsp->x_forwarded); freez(ncsp->iob->buf); - + free_http_request(ncsp->http); - + destroy_list(ncsp->headers); destroy_list(ncsp->cookie_list); - + free_current_action(ncsp->action); #ifdef FEATURE_STATISTICS @@ -329,9 +332,9 @@ void sweep(void) urls_rejected++; } #endif /* def FEATURE_STATISTICS */ - + freez(ncsp); - + /* are there any more in sequence after it? */ if( !(ncsp = csp->next) ) break; @@ -530,12 +533,12 @@ void free_url(struct url_spec *url) * * Description : Helper function to check if a file needs reloading. * If "current" is still current, return it. Otherwise - * allocates a new (zeroed) "struct file_list", fills + * allocates a new (zeroed) "struct file_list", fills * in the disk file name and timestamp, and returns it. * * Parameters : * 1 : current = The file_list currently being used - will - * be checked to see if it is out of date. + * be checked to see if it is out of date. * May be NULL (which is treated as out of * date). * 2 : filename = Name of file to check. @@ -678,7 +681,7 @@ char *read_config_line(char *buf, int buflen, FILE *fp) continue; } - /* Remove leading and trailing whitespace */ + /* Remove leading and trailing whitespace */ chomp(buf); if (*buf) @@ -944,7 +947,7 @@ int load_re_filterfile(struct client_state *csp) /* We have a meaningful line -> make it a job */ if ((dummy = pcrs_compile_command(buf, &error)) == NULL) { - log_error(LOG_LEVEL_RE_FILTER, + log_error(LOG_LEVEL_RE_FILTER, "Adding re_filter job %s failed with error %d.", buf, error); continue; } @@ -976,7 +979,7 @@ int load_re_filterfile(struct client_state *csp) return( 0 ); load_re_filterfile_error: - log_error(LOG_LEVEL_FATAL, "can't load re_filterfile '%s': %E", + log_error(LOG_LEVEL_FATAL, "can't load re_filterfile '%s': %E", csp->config->re_filterfile); return(-1); @@ -998,7 +1001,7 @@ load_re_filterfile_error: * Returns : N/A * *********************************************************************/ -void add_loader(int (*loader)(struct client_state *), +void add_loader(int (*loader)(struct client_state *), struct configuration_spec * config) { int i; @@ -1054,4 +1057,4 @@ int run_loader(struct client_state *csp) Local Variables: tab-width: 3 end: -*/ +*/ \ No newline at end of file diff --git a/parsers.c b/parsers.c index 02e01173..2272e87b 100644 --- a/parsers.c +++ b/parsers.c @@ -1,4 +1,4 @@ -const char parsers_rcs[] = "$Id: parsers.c,v 1.36 2001/10/13 12:51:51 joergs Exp $"; +const char parsers_rcs[] = "$Id: parsers.c,v 1.37 2001/10/23 21:36:02 jongfoster Exp $"; /********************************************************************* * * File : $Source: /cvsroot/ijbswa/current/parsers.c,v $ @@ -18,10 +18,10 @@ const char parsers_rcs[] = "$Id: parsers.c,v 1.36 2001/10/13 12:51:51 joergs Exp * IJBSWA team. http://ijbswa.sourceforge.net * * Based on the Internet Junkbuster originally written - * by and Copyright (C) 1997 Anonymous Coders and + * by and Copyright (C) 1997 Anonymous Coders and * Junkbusters Corporation. http://www.junkbusters.com * - * This program is free software; you can redistribute it + * This program is free software; you can redistribute it * and/or modify it under the terms of the GNU General * Public License as published by the Free Software * Foundation; either version 2 of the License, or (at @@ -41,6 +41,9 @@ const char parsers_rcs[] = "$Id: parsers.c,v 1.36 2001/10/13 12:51:51 joergs Exp * * Revisions : * $Log: parsers.c,v $ + * Revision 1.37 2001/10/23 21:36:02 jongfoster + * Documenting sed()'s error behaviou (doc change only) + * * Revision 1.36 2001/10/13 12:51:51 joergs * Removed client_host, (was only required for the old 2.0.2-11 http://noijb. * force-load), instead crumble Host: and add it (again) in client_host_adder @@ -306,7 +309,7 @@ const char parsers_rcs[] = "$Id: parsers.c,v 1.36 2001/10/13 12:51:51 joergs Exp #include #include -#ifndef _WIN32 +#if !defined(_WIN32) && !defined(__OS2__) #include #endif @@ -327,8 +330,8 @@ const char parsers_h_rcs[] = PARSERS_H_VERSION; * as an array index. Therefore we need to make sure that high-bit * characters generate +ve values, and ideally we also want to make * the argument match the declared parameter type of "int". - * - * Why did they write a character function that can't take a simple + * + * Why did they write a character function that can't take a simple * "char" argument? Doh! */ #define ijb_isupper(__X) isupper((int)(unsigned char)(__X)) @@ -351,7 +354,7 @@ const struct parsers client_patterns[] = { /* { "if-modified-since:", 18, crumble }, */ { "Keep-Alive:", 11, crumble }, { "connection:", 11, crumble }, - { "proxy-connection:", 17, crumble }, + { "proxy-connection:", 17, crumble }, { NULL, 0, NULL } }; @@ -363,7 +366,7 @@ const struct parsers server_patterns[] = { { "Content-Type:", 13, server_content_type }, { "Content-Length:", 15, server_content_length }, { "Content-MD5:", 12, server_content_md5 }, - { "Content-Encoding:", 17, server_content_encoding }, + { "Content-Encoding:", 17, server_content_encoding }, { "Transfer-Encoding:", 18, server_transfer_coding }, { "Keep-Alive:", 11, crumble }, { NULL, 0, NULL } @@ -376,13 +379,13 @@ void (* const add_client_headers[])(struct client_state *) = { client_x_forwarded_adder, client_xtra_adder, client_accept_encoding_adder, - connection_close_adder, + connection_close_adder, NULL }; void (* const add_server_headers[])(struct client_state *) = { - connection_close_adder, + connection_close_adder, NULL }; @@ -584,7 +587,7 @@ char *sed(const struct parsers pats[], void (* const more_headers[])(struct clie if (strncmpic(p->str, v->str, v->len) == 0) { hdr = v->parser(v, p->str, csp); - freez((char *)p->str); /* FIXME: Yuck! patching a list...*/ + freez(p->str); /* FIXME: Yuck! patching a list...*/ p->str = hdr; } } @@ -653,7 +656,7 @@ void parse_http_request(char *req, struct http_request *http, struct client_stat int n; memset(http, '\0', sizeof(*http)); - http->cmd = strdup(req); + http->cmd = strdup(req); buf = strdup(req); n = ssplit(buf, " \r\n", v, SZ(v), 1, 1); @@ -713,7 +716,7 @@ void parse_http_request(char *req, struct http_request *http, struct client_stat *p = '\0'; http->hostport = strdup(url); } - /* + /* * Repair broken HTTP requests that don't contain a path */ else @@ -862,7 +865,7 @@ char *server_transfer_coding(const struct parsers *v, const char *s, struct clie csp->content_type = CT_TABOO; } - /* + /* * Raise flag if body chunked */ if (strstr(s, "chunked")) @@ -870,7 +873,7 @@ char *server_transfer_coding(const struct parsers *v, const char *s, struct clie csp->flags |= CSP_FLAG_CHUNKED; /* - * If the body was modified, it has been + * If the body was modified, it has been * de-chunked first, so adjust the header: */ if (csp->flags & CSP_FLAG_MODIFIED) @@ -1067,7 +1070,7 @@ char *client_referrer(const struct parsers *v, const char *s, struct client_stat #ifdef FEATURE_FORCE_LOAD /* Since the referrer can include the prefix even * even if the request itself is non-forced, we must - * clean it unconditionally + * clean it unconditionally */ strclean(s, FORCE_PREFIX); #endif /* def FEATURE_FORCE_LOAD */ @@ -1371,7 +1374,7 @@ char *client_accept(const struct parsers *v, const char *s, struct client_state if (strstr (s, "image/gif")) { /* Client will accept HTML. If this seems counterintuitive, - * blame Microsoft. + * blame Microsoft. */ csp->accept_types |= ACCEPT_TYPE_MSIE_HTML; } @@ -1607,7 +1610,7 @@ void connection_close_adder(struct client_state *csp) char *server_http(const struct parsers *v, const char *s, struct client_state *csp) { char *ret = strdup(s); - + sscanf(ret, "HTTP/%*d.%*d %d", &(csp->http->status)); if (csp->http->status == 206) { @@ -1659,12 +1662,12 @@ char *server_set_cookie(const struct parsers *v, const char *s, struct client_st } -#ifdef FEATURE_FORCE_LOAD +#ifdef FEATURE_FORCE_LOAD /********************************************************************* * * Function : strclean * - * Description : In-Situ-Eliminate all occurances of substring in + * Description : In-Situ-Eliminate all occurances of substring in * string * * Parameters : @@ -1684,7 +1687,7 @@ int strclean(const char *string, const char *substring) p = pos + len; do { - *(p - len) = *p; + *(p - len) = *p; } while (*p++ != '\0');