const char showargs_rcs[] = "$Id: showargs.c,v 1.2 2001/05/17 23:01:01 oes Exp $"; /********************************************************************* * * File : $Source: /cvsroot/ijbswa/current/showargs.c,v $ * * Purpose : Contains various utility routines needed to * generate the show-proxy-args page. * * 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 * Junkbusters Corporation. http://www.junkbusters.com * * 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 * your option) any later version. * * This program is distributed in the hope that it will * be useful, but WITHOUT ANY WARRANTY; without even the * implied warranty of MERCHANTABILITY or FITNESS FOR A * PARTICULAR PURPOSE. See the GNU General Public * License for more details. * * The GNU General Public License should be included with * this file. If not, you can view it at * http://www.gnu.org/copyleft/gpl.html * or write to the Free Software Foundation, Inc., 59 * Temple Place - Suite 330, Boston, MA 02111-1307, USA. * * Revisions : * $Log: showargs.c,v $ * Revision 1.2 2001/05/17 23:01:01 oes * - Cleaned CRLF's from the sources and related files * * Revision 1.1.1.1 2001/05/15 13:59:03 oes * Initial import of version 2.9.3 source tree * * *********************************************************************/ #include "config.h" #include #include #include #include #include #include #include "showargs.h" #include "jcc.h" #include "encode.h" #include "parsers.h" #include "errlog.h" #include "miscutil.h" #include "gateway.h" const char showargs_h_rcs[] = SHOWARGS_H_VERSION; /********************************************************************* * * Function : strsav * * Description : Reallocate "old" and append text to it. This makes * it easier to append to malloc'd strings. * * Parameters : * 1 : old = Old text that is to be extended. Will be * free()d by this routine. * 2 : text_to_append = Text to be appended to old. * * Returns : Pointer to newly malloc'ed appended string. * If there is no text to append, return old. Caller * must free(). * *********************************************************************/ char *strsav(char *old, const char *text_to_append) { int old_len, new_len; char *p; if (( text_to_append == NULL) || (*text_to_append == '\0')) { return(old); } if (NULL != old) { old_len = strlen(old); } else { old_len = 0; } new_len = old_len + strlen(text_to_append) + 1; if (old) { if ((p = realloc(old, new_len)) == NULL) { log_error(LOG_LEVEL_FATAL, "realloc(%d) bytes for proxy_args failed!", new_len); /* Never get here - LOG_LEVEL_FATAL causes program exit */ } } else { if ((p = (char *)malloc(new_len)) == NULL) { log_error(LOG_LEVEL_FATAL, "malloc(%d) bytes for proxy_args failed!", new_len); /* Never get here - LOG_LEVEL_FATAL causes program exit */ } } strcpy(p + old_len, text_to_append); return(p); } /********************************************************************* * * Function : savearg * * Description : Called from `load_config'. It saves each non-empty * and non-comment line from config into a list. This * list is used to create the show-proxy-args page. * * Parameters : * 1 : c = config setting that was found * 2 : o = the setting's argument (if any) * * Returns : N/A * *********************************************************************/ void savearg(char *c, char *o) { char buf[BUFSIZ]; *buf = '\0'; if ( ( NULL != c ) && ( '\0' != *c ) ) { if ((c = html_encode(c))) { sprintf(buf, "%s ", c, c); } freez(c); } if ( ( NULL != o ) && ( '\0' != *o ) ) { if ((o = html_encode(o))) { if (strncmpic(o, "http://", 7) == 0) { strcat(buf, ""); strcat(buf, o); strcat(buf, ""); } else { strcat(buf, o); } } freez(o); } strcat(buf, "
\n"); proxy_args->invocation = strsav(proxy_args->invocation, buf); } /********************************************************************* * * Function : init_proxy_args * * Description : Create the "top" of the show-proxy-args page. * * Parameters : * 1 : argc = argument count (same as in main) * 2 : argv[] = program arguments (same as in main) * * Returns : N/A * *********************************************************************/ void init_proxy_args(int argc, const char *argv[]) { const struct gateway *g; int i; freez(proxy_args->header); freez(proxy_args->invocation); freez(proxy_args->gateways); freez(proxy_args->trailer); proxy_args->header = strsav(proxy_args->header, "HTTP/1.0 200 OK\n" "Server: IJ/" VERSION "\n" "Content-type: text/html\n\n" "" "" "Internet Junkbuster Proxy Status" "\n" "\n" "
\n" "

" BANNER "\n" "Proxy Status\n" "

\n" "

You are using the " BANNER " TM

\n" "Version: " VERSION "\n" "
Home page: " HOME_PAGE_URL "\n" "

\n" ); proxy_args->header = strsav(proxy_args->header, "

The program was invoked as follows

\n"); for (i=0; i < argc; i++) { proxy_args->header = strsav(proxy_args->header, argv[i]); proxy_args->header = strsav(proxy_args->header, " "); } proxy_args->header = strsav(proxy_args->header, "
\n"); proxy_args->invocation = strsav( proxy_args->invocation, "
\n" "and the following options were set in the configuration file" "

\n" ); proxy_args->gateways = strsav(proxy_args->gateways, "

It supports the following gateway protocols:

\n"); for (g = gateways; g->name; g++) { proxy_args->gateways = strsav(proxy_args->gateways, g->name); proxy_args->gateways = strsav(proxy_args->gateways, " "); } proxy_args->gateways = strsav(proxy_args->gateways, "
\n"); } /********************************************************************* * * Function : end_proxy_args * * Description : Create the "bottom" of the show-proxy-args page. * * Parameters : None * * Returns : N/A * *********************************************************************/ void end_proxy_args(void) { char *b = NULL; char buf[BUFSIZ]; /* Instead of including *all* dot h's in the project (thus creating a * tremendous amount of dependencies), I will concede to declaring them * as extern's. This forces the developer to add to this list, but oh well. */ #ifndef SPLIT_PROXY_ARGS if (suppress_blocklists && suppress_message!=NULL) { b = strsav(b, "

File contents

\n"); b = strsav(b, suppress_message); b = strsav(b, "\n"); } #endif /* ndef SPLIT_PROXY_ARGS */ b = strsav(b, "

Source versions:

\n"); b = strsav(b, "
");

#define SHOW_RCS(__x)            \
   {                             \
      extern const char __x[];   \
      sprintf(buf, "%s\n", __x); \
      b = strsav(b, buf);        \
   }

   /* In alphabetical order */
#ifdef __MINGW32__
   SHOW_RCS(cygwin_h_rcs)
#endif
   SHOW_RCS(encode_h_rcs)
   SHOW_RCS(encode_rcs)
   SHOW_RCS(errlog_h_rcs)
   SHOW_RCS(errlog_rcs)
   SHOW_RCS(filters_h_rcs)
   SHOW_RCS(filters_rcs)
   SHOW_RCS(gateway_h_rcs)
   SHOW_RCS(gateway_rcs)
#ifdef GNU_REGEX
   SHOW_RCS(gnu_regex_h_rcs)
   SHOW_RCS(gnu_regex_rcs)
#endif /* def GNU_REGEX */
   SHOW_RCS(jbsockets_h_rcs)
   SHOW_RCS(jbsockets_rcs)
   SHOW_RCS(jcc_h_rcs)
   SHOW_RCS(jcc_rcs)
#ifdef KILLPOPUPS
   SHOW_RCS(killpopup_h_rcs)
   SHOW_RCS(killpopup_rcs)
#endif /* def KILLPOPUPS */
   SHOW_RCS(loadcfg_h_rcs)
   SHOW_RCS(loadcfg_rcs)
   SHOW_RCS(loaders_h_rcs)
   SHOW_RCS(loaders_rcs)
   SHOW_RCS(miscutil_h_rcs)
   SHOW_RCS(miscutil_rcs)
   SHOW_RCS(parsers_h_rcs)
   SHOW_RCS(parsers_rcs)
#ifdef PCRS
   SHOW_RCS(pcrs_rcs)
   SHOW_RCS(pcrs_h_rcs)
#endif /* def PCRS */
   SHOW_RCS(project_h_rcs)
   SHOW_RCS(showargs_h_rcs)
   SHOW_RCS(showargs_rcs)
   SHOW_RCS(ssplit_h_rcs)
   SHOW_RCS(ssplit_rcs)
#ifdef _WIN32
   SHOW_RCS(w32log_h_rcs)
   SHOW_RCS(w32log_rcs)
   SHOW_RCS(w32res_h_rcs)
   SHOW_RCS(w32rulesdlg_h_rcs)
   SHOW_RCS(w32rulesdlg_rcs)
   SHOW_RCS(w32taskbar_h_rcs)
   SHOW_RCS(w32taskbar_rcs)
   SHOW_RCS(win32_h_rcs)
   SHOW_RCS(win32_rcs)
#endif /* def _WIN32 */

#undef SHOW_RCS

   b = strsav(b, "
\n"); b = strsav(b, "

Conditional defines:

\n
    "); #ifdef REGEX b = strsav(b, "
  • #define REGEX - Support for regular expressions in the path specs.
  • \n"); #else /* ifndef REGEX */ b = strsav(b, "
  • #undef REGEX - No support for regular expressions in the path specs.
  • \n"); #endif /* ndef REGEX */ #ifdef PCRE b = strsav(b, "
  • #define PCRE - Use PCRE rather than old GNU regex library.
  • \n"); #else /* ifndef PCRE */ b = strsav(b, "
  • #undef PCRE - Use old GNU regex library rather than PCRE.
  • \n"); #endif /* ndef PCRE */ #ifdef PCRS b = strsav(b, "
  • #define PCRS - Enables arbitrary content modification regexps.
  • \n"); #else /* ifndef PCRS */ b = strsav(b, "
  • #undef PCRS - Disables arbitrary content modification regexps.
  • \n"); #endif /* ndef PCRS */ #ifdef TOGGLE b = strsav(b, "
  • #define TOGGLE - Allow JunkBuster to be \"disabled\" so it is just a normal non-blocking non-anonymizing proxy.
  • \n"); #else /* ifndef TOGGLE */ b = strsav(b, "
  • #undef TOGGLE - Do not allow JunkBuster to be \"disabled\" so it is just a normal non-blocking non-anonymizing proxy.
  • \n"); #endif /* ndef TOGGLE */ #ifdef FORCE_LOAD b = strsav(b, "
  • #define FORCE_LOAD - Enables bypassing filtering for a single page using the prefix \"" FORCE_PREFIX "\".
  • \n"); #else /* ifndef FORCE_LOAD */ b = strsav(b, "
  • #undef FORCE_LOAD - Disables bypassing filtering for a single page.
  • \n"); #endif /* ndef FORCE_LOAD */ #ifdef DENY_GZIP b = strsav(b, "
  • #define DENY_GZIP - Prevents requests from being compressed - required for PCRS.
  • \n"); #else /* ifndef DENY_GZIP */ b = strsav(b, "
  • #undef DENY_GZIP - Allows requests to be compressed if the browser and server support it.
  • \n"); #endif /* ndef DENY_GZIP */ #ifdef STATISTICS b = strsav(b, "
  • #define STATISTICS - Enables statistics function.
  • \n"); #else /* ifndef STATISTICS */ b = strsav(b, "
  • #undef STATISTICS - Disables statistics function.
  • \n"); #endif /* ndef STATISTICS */ #ifdef SPLIT_PROXY_ARGS b = strsav(b, "
  • #define SPLIT_PROXY_ARGS - Split this page up by placing the configuration files on separate pages.
  • \n"); #else /* ifndef SPLIT_PROXY_ARGS */ b = strsav(b, "
  • #undef SPLIT_PROXY_ARGS - This page contains the text of the configuration files, they are not split onto separate pages.
  • \n"); #endif /* ndef SPLIT_PROXY_ARGS */ #ifdef KILLPOPUPS b = strsav(b, "
  • #define KILLPOPUPS - Enables killing JavaScript popups.
  • \n"); #else /* ifndef KILLPOPUPS */ b = strsav(b, "
  • #undef KILLPOPUPS - Disables killing JavaScript popups.
  • \n"); #endif /* ndef KILLPOPUPS */ #ifdef WEBDAV b = strsav(b, "
  • #define WEBDAV - Enables support for webDAV - e.g. stops Microsoft Outlook from accessing HotMail e-mail.
  • \n"); #else /* ifndef WEBDAV */ b = strsav(b, "
  • #undef WEBDAV - Disables support for webDAV - e.g. so Microsoft Outlook can access HotMail e-mail.
  • \n"); #endif /* ndef WEBDAV */ #ifdef DETECT_MSIE_IMAGES b = strsav(b, "
  • #define DETECT_MSIE_IMAGES - Enables detecting image requests automatically for MSIE.
  • \n"); #else /* ifndef DETECT_MSIE_IMAGES */ b = strsav(b, "
  • #undef DETECT_MSIE_IMAGES - Disables detecting image requests automatically for MSIE.
  • \n"); #endif /* ndef DETECT_MSIE_IMAGES */ #ifdef USE_IMAGE_LIST b = strsav(b, "
  • #define USE_IMAGE_LIST - Enables using image list to detect images.
  • \n"); #else /* ifndef USE_IMAGE_LIST */ b = strsav(b, "
  • #undef USE_IMAGE_LIST - Disables using image list to detect images.
  • \n"); #endif /* ndef USE_IMAGE_LIST */ #ifdef ACL_FILES b = strsav(b, "
  • #define ACL_FILES - Enables the use of ACL files to control access to the proxy by IP address.
  • \n"); #else /* ifndef ACL_FILES */ b = strsav(b, "
  • #undef ACL_FILES - Disables the use of ACL files to control access to the proxy by IP address.
  • \n"); #endif /* ndef ACL_FILES */ #ifdef TRUST_FILES b = strsav(b, "
  • #define TRUST_FILES - Enables the use of trust files.
  • \n"); #else /* ifndef TRUST_FILES */ b = strsav(b, "
  • #undef TRUST_FILES - Disables the use of trust files.
  • \n"); #endif /* ndef TRUST_FILES */ #ifdef JAR_FILES b = strsav(b, "
  • #define JAR_FILES - Enables the use of jar files to capture cookies.
  • \n"); #else /* ifndef JAR_FILES */ b = strsav(b, "
  • #undef JAR_FILES - Disables the use of jar files to capture cookies.
  • \n"); #endif /* ndef JAR_FILES */ b = strsav(b, "
\n
\n"); b = strsav(b, "

\n" "Code and documentation of the " BANNER " Proxy" "TM\n" "\n" "Copyright© 1997 Junkbusters Corporation\n" "TM
\n" "Copying and distribution permitted under the" "\n" "GNU " "General Public License.\n" "
" "

webmaster@junkbusters.com
" "
" "\n" ); proxy_args->trailer = b; } /* Local Variables: tab-width: 3 end: */