Main Page   Alphabetical List   Data Structures   File List   Data Fields   Globals  

jcc.c File Reference

Main file. More...


Defines

#define IS_TOGGLED_ON_AND
#define IS_NOT_FORCED_AND
#define IS_ENABLED_AND   IS_TOGGLED_ON_AND IS_NOT_FORCED_AND

Functions

void listen_loop (void)
void chat (struct client_state *csp)
void serve (struct client_state *csp)
void sig_handler (int the_signal)
void usage (const char *myname)
int main (int argc, const char *argv[])
jb_socket bind_port_helper (struct configuration_spec *config)

Variables

const char jcc_rcs [] = "$Id: jcc.c,v 2.1 2002/06/04 16:35:56 jongfoster Exp $"
const char jcc_h_rcs [] = JCC_H_VERSION
const char project_h_rcs [] = PROJECT_H_VERSION
int no_daemon = 0
client_state clients [1]
file_list files [1]
const char VANILLA_WAFER []
const char CSUCCEED []
const char CHEADER []
const char CFORBIDDEN []


Detailed Description

Main file.

Contains main() method, main loop, and the main connection-handling function.

Log:
jcc.c,v
Revision 2.1 2002/06/04 16:35:56 jongfoster Moving three variable declarations to jcc.c from project.h

Revision 2.0 2002/06/04 14:34:21 jongfoster Moving source files to src/

Revision 1.92 2002/05/08 16:00:46 oes Chat's buffer handling:

Revision 1.91 2002/04/08 20:35:58 swa fixed JB spelling

Revision 1.90 2002/04/02 14:57:28 oes Made sending wafers independent of FEATURE_COOKIE_JAR

Revision 1.89 2002/03/31 17:18:59 jongfoster Win32 only: Enabling STRICT to fix a VC++ compile warning.

Revision 1.88 2002/03/27 14:32:43 david__schmidt More compiler warning message maintenance

Revision 1.87 2002/03/26 22:29:54 swa we have a new homepage!

Revision 1.86 2002/03/25 17:04:55 david__schmidt Workaround for closing the jarfile before load_config() comes around again

Revision 1.85 2002/03/24 15:23:33 jongfoster Name changes

Revision 1.84 2002/03/24 13:25:43 swa name change related issues

Revision 1.83 2002/03/16 23:54:06 jongfoster Adding graceful termination feature, to help look for memory leaks. If you enable this (which, by design, has to be done by hand editing config.h) and then go to http://i.j.b/die, then the program will exit cleanly after the *next* request. It should free all the memory that was used.

Revision 1.82 2002/03/13 00:27:05 jongfoster Killing warnings

Revision 1.81 2002/03/12 01:42:50 oes Introduced modular filters

Revision 1.80 2002/03/11 22:07:05 david__schmidt OS/2 port maintenance:

Revision 1.79 2002/03/09 20:03:52 jongfoster THIS WAS A MAJOR BUG - it caused frequent, unpredictable crashes, and also frequently caused JB to jump to 100% CPU and stay there. (Because it thought it had just read ((unsigned)-1) == 4Gb of data...)

Revision 1.78 2002/03/08 21:35:04 oes Added optional group supplement to --user option. Will now use default group of user if no group given

Revision 1.77 2002/03/07 03:52:06 oes

Revision 1.76 2002/03/06 22:54:35 jongfoster Automated function-comment nitpicking.

Revision 1.75 2002/03/06 10:02:19 oes Fixed stupid bug when --user was not given

Revision 1.74 2002/03/06 00:49:31 jongfoster Fixing warning on Windows Making ifdefs that refer to the same variable consistently use ifdef unix rather than mixing ifdef unix & ifndef OS2

Revision 1.73 2002/03/05 23:57:30 hal9 Stray character 's' on line 1618 was breaking build.

Revision 1.72 2002/03/05 21:33:45 david__schmidt

Revision 1.71 2002/03/05 18:13:56 oes Added --user option

Revision 1.70 2002/03/05 04:52:42 oes Deleted non-errlog debugging code

Revision 1.69 2002/03/04 23:50:00 jongfoster Splitting off bind_port() call into bind_port_helper(), with improved logging.

Revision 1.68 2002/03/04 20:17:32 oes Fixed usage info

Revision 1.67 2002/03/04 18:18:57 oes

Revision 1.66 2002/03/03 15:06:55 oes Re-enabled automatic config reloading

Revision 1.65 2002/03/03 14:49:11 oes Fixed CLF logging: Now uses client's original HTTP request

Revision 1.64 2002/03/03 09:18:03 joergs Made jumbjuster work on AmigaOS again.

Revision 1.63 2002/03/02 04:14:50 david__schmidt Clean up a little CRLF unpleasantness that suddenly appeared

Revision 1.62 2002/02/20 23:17:23 jongfoster Detecting some out-of memory conditions and exiting with a log message.

Revision 1.61 2002/01/17 21:01:52 jongfoster Moving all our URL and URL pattern parsing code to urlmatch.c.

Revision 1.60 2001/12/30 14:07:32 steudten

Revision 1.59 2001/12/13 14:07:18 oes Fixed Bug: 503 error page now sent OK

Revision 1.58 2001/11/30 23:37:24 jongfoster Renaming the Win32 config file to config.txt - this is almost the same as the corresponding UNIX name "config"

Revision 1.57 2001/11/16 00:47:43 jongfoster Changing the tty-disconnection code to use setsid().

Revision 1.56 2001/11/13 20:20:54 jongfoster Tabs->spaces, fixing a bug with missing {} around an if()

Revision 1.55 2001/11/13 20:14:53 jongfoster Patch for FreeBSD setpgrp() as suggested by Alexander Lazic

Revision 1.54 2001/11/07 00:03:14 steudten Give reliable return value if an error occurs not just 0 with new daemon mode.

Revision 1.53 2001/11/05 21:41:43 steudten Add changes to be a real daemon just for unix os. (change cwd to /, detach from controlling tty, set process group and session leader to the own process. Add DBG() Macro. Add some fatal-error log message for failed malloc(). Add '-d' if compiled with 'configure --with-debug' to enable debug output.

Revision 1.52 2001/10/26 20:11:20 jongfoster Fixing type mismatch

Revision 1.51 2001/10/26 17:38:28 oes Cosmetics

Revision 1.50 2001/10/25 03:40:48 david__schmidt 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.

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

Revision 1.47 2001/10/10 16:44:36 oes Added CONNECT destination port limitation check

Revision 1.46 2001/10/08 15:17:41 oes Re-enabled SSL forwarding

Revision 1.45 2001/10/07 15:42:11 oes Replaced 6 boolean members of csp with one bitmap (csp->flags)

Moved downgrading of the HTTP version from parse_http_request to chat(), since we can't decide if it is necessary before we have determined the actions for the URL. The HTTP command is now *always* re-built so the repairs need no longer be special-cased.

filter_popups now gets a csp pointer so it can raise the new CSP_FLAG_MODIFIED flag.

Bugfix

Added configurable size limit for the IOB. If the IOB grows so large that the next read would exceed the limit, the header is generated, and the header & unfiltered buffer are flushed to the client. Chat then continues in non-buffering, non-filtering body mode.

Revision 1.44 2001/10/02 18:13:57 oes Ooops

Revision 1.43 2001/10/02 15:32:13 oes Moved generation of hdr

Revision 1.42 2001/09/21 23:02:02 david__schmidt Cleaning up 2 compiler warnings on OS/2.

Revision 1.41 2001/09/16 17:05:14 jongfoster Removing unused include showarg.h

Revision 1.40 2001/09/16 15:41:45 jongfoster Fixing signed/unsigned comparison warning.

Revision 1.39 2001/09/16 13:21:27 jongfoster Changes to use new list functions.

Revision 1.38 2001/09/16 13:01:46 jongfoster Removing redundant function call that zeroed zalloc()'d memory.

Revision 1.37 2001/09/10 11:12:24 oes Deleted unused variable

Revision 1.36 2001/09/10 10:56:15 oes Silenced compiler warnings

Revision 1.35 2001/07/31 14:44:22 oes Deleted unused size parameter from filter_popups()

Revision 1.34 2001/07/30 22:08:36 jongfoster Tidying up defines:

Revision 1.33 2001/07/29 19:32:00 jongfoster Renaming _main() [mingw32 only] to real_main(), for ANSI compliance.

Revision 1.32 2001/07/29 18:47:05 jongfoster Adding missing include "loadcfg.h"

Revision 1.31 2001/07/29 12:17:48 oes Applied pthread fix by Paul Lieverse

Revision 1.30 2001/07/25 22:57:13 jongfoster __BEOS__ no longer overrides FEATURE_PTHREAD. This is because FEATURE_PTHREAD will soon be widely used, so I want to keep it simple.

Revision 1.29 2001/07/24 12:47:06 oes Applied BeOS support update by Eugenia

Revision 1.28 2001/07/23 13:26:12 oes Fixed bug in popup-killing for the first read that caused binary garbage to be sent between headers and body

Revision 1.27 2001/07/19 19:09:47 haroon

Note 2001/07/20: No, the other content modification mechanisms will process the whole iob later anyway. --oes

Revision 1.26 2001/07/18 12:31:36 oes cosmetics

Revision 1.25 2001/07/15 19:43:49 jongfoster Supports POSIX threads. Also removed some unused includes.

Revision 1.24 2001/07/13 14:00:40 oes

Revision 1.23 2001/07/02 02:28:25 iwanttokeepanon Added "ifdef ACL_FILES" conditional compilation to line 1291 to exclude the `block_acl' call. This prevents a compilation error when the user does not wish to use the "ACL" feature.

Revision 1.22 2001/06/29 21:45:41 oes Indentation, CRLF->LF, Tab-> Space

Revision 1.21 2001/06/29 13:29:36 oes

Revision 1.20 2001/06/09 10:55:28 jongfoster Changing BUFSIZ ==> BUFFER_SIZE

Revision 1.19 2001/06/07 23:12:52 jongfoster Replacing function pointer in struct gateway with a directly called function forwarded_connect(). Replacing struct gateway with struct forward_spec

Revision 1.18 2001/06/03 19:12:16 oes introduced new cgi handling

Revision 1.17 2001/06/01 20:07:23 jongfoster Now uses action +image-blocker{} rather than config->tinygif

Revision 1.16 2001/06/01 18:49:17 jongfoster Replaced "list_share" with "list" - the tiny memory gain was not worth the extra complexity.

Revision 1.15 2001/05/31 21:24:47 jongfoster Changed "permission" to "action" throughout. Removed DEFAULT_USER_AGENT - it must now be specified manually. Moved vanilla wafer check into chat(), since we must now decide whether or not to add it based on the URL.

Revision 1.14 2001/05/29 20:14:01 joergs AmigaOS bugfix: PCRS needs a lot of stack, stacksize for child threads increased.

Revision 1.13 2001/05/29 09:50:24 jongfoster Unified blocklist/imagelist/permissionslist. File format is still under discussion, but the internal changes are (mostly) done.

Also modified interceptor behaviour:

Revision 1.12 2001/05/27 22:17:04 oes

Revision 1.11 2001/05/26 17:27:53 jongfoster Added support for CLF and fixed LOG_LEVEL_LOG. Also did CRLF->LF fix of my previous patch.

Revision 1.10 2001/05/26 15:26:15 jongfoster ACL feature now provides more security by immediately dropping connections from untrusted hosts.

Revision 1.9 2001/05/26 00:28:36 jongfoster Automatic reloading of config file. Removed obsolete SIGHUP support (Unix) and Reload menu option (Win32). Most of the global variables have been moved to a new struct configuration_spec, accessed through csp->config->globalname Most of the globals remaining are used by the Win32 GUI.

Revision 1.8 2001/05/25 22:43:18 jongfoster Fixing minor memory leak and buffer overflow.

Revision 1.7 2001/05/25 22:34:30 jongfoster Hard tabs->Spaces

Revision 1.6 2001/05/23 00:13:58 joergs AmigaOS support fixed.

Revision 1.5 2001/05/22 18:46:04 oes

Revision 1.4 2001/05/21 19:34:01 jongfoster Made failure to bind() a fatal error.

Revision 1.3 2001/05/20 01:21:20 jongfoster Version 2.9.4 checkin.

Revision 1.2 2001/05/17 22:34:44 oes Revision 1.1.1.1 2001/05/15 13:58:56 oes Initial import of version 2.9.3 source tree


Function Documentation

jb_socket bind_port_helper struct configuration_spec   config [static]
 

Bind the listen port.

Handles logging, and aborts on failure.

Parameters:
config  Privoxy configuration. Specifies port to bind to.
Returns:
Port that was opened.

void chat struct client_state   csp [static]
 

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 function returns, the caller must close the client socket handle.

Parameters:
csp  Current client state (buffers, headers, etc...)
Returns:
On success, the number of bytes written are returned (zero indicates nothing was written). On error, -1 is returned, and errno is set appropriately. If count is zero and the file descriptor refers to a regular file, 0 will be returned without causing any other effect. For a special file, the results are not portable.

void listen_loop void    [static]
 

bind the listen port and enter a "FOREVER" listening loop.

Parameters : N/A

Returns:
Never.

int main int    argc,
const char *    argv[]
 

Load the config file and start the listen loop.

This function is a lot more *sane* with the `load_config' and `listen_loop' functions; although it stills does a *little* too much for my taste.

Parameters:
argc  Number of parameters (including $0).
argv  Array of (char *)'s to the parameters.
Returns:
1 if : can't open config file, unrecognized directive, stats requested in multi-thread mode, can't open the log file, can't open the jar file, listen port is invalid, 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 "File", "Exit" menu option.

void serve struct client_state   csp [static]
 

This is little more than chat.

We only "serve" to to close any socket that chat may have opened.

Parameters:
csp  Current client state (buffers, headers, etc...)
Returns:
N/A

void sig_handler int    the_signal [static]
 

Signal handler for different signals.

Exit gracefully on ABRT, TERM and INT or set a flag that will cause the errlog to be reopened by the main thread on HUP.

Parameters:
the_signal  the signal cause this function to call
Returns:
-

void usage const char *    myname
 

Print usage info & exit.

Parameters : Pointer to argv[0] for identifying ourselves

Returns:
No. ,-)


Variable Documentation

const char CFORBIDDEN[] [static]
 

Initial value:

   "HTTP/1.0 403 Connection not allowable\r\nX-Hint: If you read this message interactively, then you know why this happens ,-)\r\n\r\n"
HTTP reply sent when the browser tries to tunnel ("CONNECT") to something other than a HTTPS port (as defined by +limit-connect).

const char CHEADER[] [static]
 

Initial value:

   "HTTP/1.0 400 Invalid header received from browser\r\n\r\n"
HTTP reply sent when the browser sends something unintelligible.

const char CSUCCEED[] [static]
 

Initial value:

   "HTTP/1.0 200 Connection established\n"
   "Proxy-Agent: Privoxy/" VERSION "\r\n\r\n"
HTTP header sent when doing HTTPS tunnelling ("CONNECT" method).

const char jcc_h_rcs[] = JCC_H_VERSION
 

Version information about jcc.h.

const char jcc_rcs[] = "$Id: jcc.c,v 2.1 2002/06/04 16:35:56 jongfoster Exp $"
 

Version information about jcc.c.

const char VANILLA_WAFER[] [static]
 

Initial value:

   "NOTICE=TO_WHOM_IT_MAY_CONCERN_"
   "Do_not_send_me_any_copyrighted_information_other_than_the_"
   "document_that_I_am_requesting_or_any_of_its_necessary_components._"
   "In_particular_do_not_send_me_any_cookies_that_"
   "are_subject_to_a_claim_of_copyright_by_anybody._"
   "Take_notice_that_I_refuse_to_be_bound_by_any_license_condition_"
   "(copyright_or_otherwise)_applying_to_any_cookie._"
The vanilla wafer.


Generated on Tue Jun 4 18:54:49 2002 for Privoxy 3.1.1 by doxygen1.2.15