From c26febc1a981e309aaf9e1f785a2f5c3376ddfdc Mon Sep 17 00:00:00 2001 From: jongfoster Date: Tue, 4 Jun 2002 17:55:24 +0000 Subject: [PATCH] Adding comments --- src/actions.c | 75 +++++++++++++++++++++++++++++++-------------------- src/actions.h | 17 +++++++----- src/cgi.c | 32 +++++++++++++++++----- src/encode.c | 19 +++++++++---- src/gateway.c | 38 +++++++++++++++++--------- 5 files changed, 121 insertions(+), 60 deletions(-) diff --git a/src/actions.c b/src/actions.c index 967faad1..977f1161 100644 --- a/src/actions.c +++ b/src/actions.c @@ -1,7 +1,7 @@ -const char actions_rcs[] = "$Id: actions.c,v 1.33 2002/05/26 12:14:19 roro Exp $"; +const char actions_rcs[] = "$Id: actions.c,v 2.0 2002/06/04 14:34:21 jongfoster Exp $"; /********************************************************************* * - * File : $Source: /cvsroot/ijbswa/current/actions.c,v $ + * File : $Source: /cvsroot/ijbswa/current/src/actions.c,v $ * * Purpose : Declares functions to work with actions files * Functions declared include: FIXME @@ -33,6 +33,9 @@ const char actions_rcs[] = "$Id: actions.c,v 1.33 2002/05/26 12:14:19 roro Exp $ * * Revisions : * $Log: actions.c,v $ + * Revision 2.0 2002/06/04 14:34:21 jongfoster + * Moving source files to src/ + * * Revision 1.33 2002/05/26 12:14:19 roro * Change unsigned to unsigned long in actions_name struct. This closes * SourceForge Bug #539284. @@ -212,27 +215,26 @@ const char actions_h_rcs[] = ACTIONS_H_VERSION; * an enumerated type (well, the preprocessor equivalent). Here are * the values: */ -#define AV_NONE 0 /* +opt -opt */ -#define AV_ADD_STRING 1 /* +stropt{string} */ -#define AV_REM_STRING 2 /* -stropt */ -#define AV_ADD_MULTI 3 /* +multiopt{string} +multiopt{string2} */ -#define AV_REM_MULTI 4 /* -multiopt{string} -multiopt */ - -/* - * We need a structure to hold the name, flag changes, - * type, and string index. +#define AV_NONE 0 /**< Action type: +bool-action or -bool-action */ +#define AV_ADD_STRING 1 /**< Action type: +string-action{string} */ +#define AV_REM_STRING 2 /**< Action type: -string-action */ +#define AV_ADD_MULTI 3 /**< Action type: +multi-action{string} */ +#define AV_REM_MULTI 4 /**< Action type: -multi-action{string} or -multi-action */ + +/** + * A structure holding information about a single built-in action string. */ struct action_name { - const char * name; - unsigned long mask; /* a bit set to "0" = remove action */ - unsigned long add; /* a bit set to "1" = add action */ - int takes_value; /* an AV_... constant */ - int index; /* index into strings[] or multi[] */ + const char * name; /**< Action name */ + unsigned long mask; /**< A bit set to "0" = remove action */ + unsigned long add; /**< A bit set to "1" = add action */ + int takes_value; /**< An AV_... constant */ + int index; /**< Index into strings[] or multi[] */ }; -/* - * And with those building blocks in place, here's the array. +/** + * The array of all built-in action strings. */ static const struct action_name action_names[] = { @@ -264,6 +266,15 @@ static const struct action_name action_names[] = }; +/** + * The currently loaded actions files. + */ +static struct file_list *current_actions_file[MAX_ACTION_FILES] = { + NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL +}; + + static int load_one_actions_file(struct client_state *csp, int fileid); @@ -857,12 +868,6 @@ void free_current_action (struct current_action_spec *src) } -static struct file_list *current_actions_file[MAX_ACTION_FILES] = { - NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, NULL -}; - - #ifdef FEATURE_GRACEFUL_TERMINATION /********************************************************************* * @@ -980,6 +985,23 @@ int load_actions_file(struct client_state *csp) return 0; } + +/** load_one_actions_file() parser status: At start of file. */ +#define MODE_START_OF_FILE 1 + +/** load_one_actions_file() parser status: In "{{settings}}" block. */ +#define MODE_SETTINGS 2 + +/** load_one_actions_file() parser status: In "{{description}}" block. */ +#define MODE_DESCRIPTION 3 + +/** load_one_actions_file() parser status: In "{{alias}}" block. */ +#define MODE_ALIAS 4 + +/** load_one_actions_file() parser status: In "{+some-actions}" block. */ +#define MODE_ACTIONS 5 + + /********************************************************************* * * Function : load_one_actions_file @@ -1002,11 +1024,6 @@ static int load_one_actions_file(struct client_state *csp, int fileid) * Note: Keep these in the order they occur in the file, they are * sometimes tested with <= */ -#define MODE_START_OF_FILE 1 -#define MODE_SETTINGS 2 -#define MODE_DESCRIPTION 3 -#define MODE_ALIAS 4 -#define MODE_ACTIONS 5 int mode = MODE_START_OF_FILE; diff --git a/src/actions.h b/src/actions.h index 07cf2ed2..c0513fff 100644 --- a/src/actions.h +++ b/src/actions.h @@ -1,9 +1,9 @@ #ifndef ACTIONS_H_INCLUDED #define ACTIONS_H_INCLUDED -#define ACTIONS_H_VERSION "$Id: actions.h,v 1.12 2002/05/06 07:56:50 oes Exp $" +#define ACTIONS_H_VERSION "$Id: actions.h,v 2.0 2002/06/04 14:34:21 jongfoster Exp $" /********************************************************************* * - * File : $Source: /cvsroot/ijbswa/current/actions.h,v $ + * File : $Source: /cvsroot/ijbswa/current/src/actions.h,v $ * * Purpose : Declares functions to work with actions files * Functions declared include: FIXME @@ -35,6 +35,9 @@ * * Revisions : * $Log: actions.h,v $ + * Revision 2.0 2002/06/04 14:34:21 jongfoster + * Moving source files to src/ + * * Revision 1.12 2002/05/06 07:56:50 oes * Made actions_to_html independent of FEATURE_CGI_EDIT_ACTIONS * @@ -104,12 +107,14 @@ struct client_state; -/* This structure is used to hold user-defined aliases */ +/** + * This structure is used to hold user-defined aliases + */ struct action_alias { - const char * name; - struct action_spec action[1]; - struct action_alias * next; + const char * name; /**< Alias name. */ + struct action_spec action[1]; /**< Alias value. */ + struct action_alias * next; /**< Next alias in list */ }; diff --git a/src/cgi.c b/src/cgi.c index e20d8bf6..7e3fb739 100644 --- a/src/cgi.c +++ b/src/cgi.c @@ -1,7 +1,7 @@ -const char cgi_rcs[] = "$Id: cgi.c,v 1.70 2002/05/19 11:33:20 jongfoster Exp $"; +const char cgi_rcs[] = "$Id: cgi.c,v 2.0 2002/06/04 14:34:21 jongfoster Exp $"; /********************************************************************* * - * File : $Source: /cvsroot/ijbswa/current/cgi.c,v $ + * File : $Source: /cvsroot/ijbswa/current/src/cgi.c,v $ * * Purpose : Declares functions to intercept request, generate * html or gif answers, and to compose HTTP resonses. @@ -38,6 +38,9 @@ const char cgi_rcs[] = "$Id: cgi.c,v 1.70 2002/05/19 11:33:20 jongfoster Exp $"; * * Revisions : * $Log: cgi.c,v $ + * Revision 2.0 2002/06/04 14:34:21 jongfoster + * Moving source files to src/ + * * Revision 1.70 2002/05/19 11:33:20 jongfoster * If a CGI error was not handled, and propogated back to * dispatch_known_cgi(), then it was assumed to be "out of memory". @@ -418,8 +421,8 @@ const char cgi_rcs[] = "$Id: cgi.c,v 1.70 2002/05/19 11:33:20 jongfoster Exp $"; const char cgi_h_rcs[] = CGI_H_VERSION; -/* - * List of CGI functions: name, handler, description +/** + * List of CGI functions: name, handler, description. * Note: Do NOT use single quotes in the description; * this will break the dynamic "blocked" template! */ @@ -533,7 +536,7 @@ static const struct cgi_dispatcher cgi_dispatchers[] = { /* - * Bulit-in images for ad replacement + * Built-in images for ad replacement * * Hint: You can encode your own images like this: * cat your-image | perl -e 'while (read STDIN, $c, 1) { printf("\\%.3o", unpack("C", $c)); }' @@ -568,7 +571,7 @@ const char image_blank_data[] = "\000\000\000\000\111\105\116\104\256\102\140\202"; #else -/* +/** * Checkerboard pattern, as a GIF. */ const char image_pattern_data[] = @@ -578,7 +581,7 @@ const char image_pattern_data[] = "\054\000\000\000\000\004\000\004\000\000\002\005\104\174\147" "\270\005\000\073"; -/* +/** * 1x1 transparant GIF. */ const char image_blank_data[] = @@ -587,12 +590,27 @@ const char image_blank_data[] = "\000\001\000\000\002\002D\001\000;"; #endif +/** + * The size of the image_pattern, in bytes. + */ const size_t image_pattern_length = sizeof(image_pattern_data) - 1; + +/** + * The size of the image_blank, in bytes. + */ const size_t image_blank_length = sizeof(image_blank_data) - 1; +/** + * The "Out of memory" CGI response. This is statically allocated + * and is initialized at startup, for obvious reasons. It's + * read-only. finish_http_response() and free_http_response() + * have been special-cased to do nothing if they are passed + * this structure. + */ static struct http_response cgi_error_memory_response[1]; + static struct http_response *dispatch_known_cgi(struct client_state * csp, const char * path); static struct map *parse_cgi_parameters(char *argstring); diff --git a/src/encode.c b/src/encode.c index c1e38d85..e4219f0b 100644 --- a/src/encode.c +++ b/src/encode.c @@ -1,7 +1,7 @@ -const char encode_rcs[] = "$Id: encode.c,v 1.8 2002/03/26 22:29:54 swa Exp $"; +const char encode_rcs[] = "$Id: encode.c,v 2.0 2002/06/04 14:34:21 jongfoster Exp $"; /********************************************************************* * - * File : $Source: /cvsroot/ijbswa/current/encode.c,v $ + * File : $Source: /cvsroot/ijbswa/current/src/encode.c,v $ * * Purpose : Functions to encode and decode URLs, and also to * encode cookies and HTML text. @@ -33,6 +33,9 @@ const char encode_rcs[] = "$Id: encode.c,v 1.8 2002/03/26 22:29:54 swa Exp $"; * * Revisions : * $Log: encode.c,v $ + * Revision 2.0 2002/06/04 14:34:21 jongfoster + * Moving source files to src/ + * * Revision 1.8 2002/03/26 22:29:54 swa * we have a new homepage! * @@ -74,7 +77,9 @@ const char encode_rcs[] = "$Id: encode.c,v 1.8 2002/03/26 22:29:54 swa Exp $"; const char encode_h_rcs[] = ENCODE_H_VERSION; -/* Maps special characters in a URL to their equivalent % codes. */ +/** + * Maps special characters in a URL to their equivalent % codes. + */ static const char * const url_code_map[256] = { NULL, "%01", "%02", "%03", "%04", "%05", "%06", "%07", "%08", "%09", "%0A", "%0B", "%0C", "%0D", "%0E", "%0F", "%10", "%11", "%12", "%13", @@ -104,7 +109,9 @@ static const char * const url_code_map[256] = { "%FA", "%FB", "%FC", "%FD", "%FE", "%FF" }; -/* Maps special characters in HTML to their equivalent entites. */ +/** + * Maps special characters in HTML to their equivalent entities. + */ static const char * const html_code_map[256] = { NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, @@ -134,7 +141,9 @@ static const char * const html_code_map[256] = { NULL, NULL, NULL, NULL, NULL, NULL }; -/* Maps special characters in a cookie to their equivalent % codes. */ +/** + * Maps special characters in a cookie to their equivalent % codes. + */ static const char * const cookie_code_map[256] = { NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, diff --git a/src/gateway.c b/src/gateway.c index 6ff762a9..22f9f7b6 100644 --- a/src/gateway.c +++ b/src/gateway.c @@ -1,7 +1,7 @@ -const char gateway_rcs[] = "$Id: gateway.c,v 1.16 2002/05/12 21:36:29 jongfoster Exp $"; +const char gateway_rcs[] = "$Id: gateway.c,v 2.0 2002/06/04 14:34:21 jongfoster Exp $"; /********************************************************************* * - * File : $Source: /cvsroot/ijbswa/current/gateway.c,v $ + * File : $Source: /cvsroot/ijbswa/current/src/gateway.c,v $ * * Purpose : Contains functions to connect to a server, possibly * using a "forwarder" (i.e. HTTP proxy and/or a SOCKS4 @@ -34,6 +34,9 @@ const char gateway_rcs[] = "$Id: gateway.c,v 1.16 2002/05/12 21:36:29 jongfoster * * Revisions : * $Log: gateway.c,v $ + * Revision 2.0 2002/06/04 14:34:21 jongfoster + * Moving source files to src/ + * * Revision 1.16 2002/05/12 21:36:29 jongfoster * Correcting function comments * @@ -158,29 +161,38 @@ static jb_socket socks4_connect(const struct forward_spec * fwd, struct client_state *csp); +/** SOCKS command code. */ #define SOCKS_REQUEST_GRANTED 90 + +/** SOCKS command code. */ #define SOCKS_REQUEST_REJECT 91 + +/** SOCKS command code. */ #define SOCKS_REQUEST_IDENT_FAILED 92 + +/** SOCKS command code. */ #define SOCKS_REQUEST_IDENT_CONFLICT 93 -/* structure of a socks client operation */ + +/** Structure of a socks client operation */ struct socks_op { - unsigned char vn; /* socks version number */ - unsigned char cd; /* command code */ - unsigned char dstport[2]; /* destination port */ - unsigned char dstip[4]; /* destination address */ - unsigned char userid; /* first byte of userid */ + unsigned char vn; /**< Socks version number */ + unsigned char cd; /**< Command code */ + unsigned char dstport[2]; /**< Destination port */ + unsigned char dstip[4]; /**< Destination address */ + unsigned char userid; /**< First byte of userid */ /* more bytes of the userid follow, terminated by a NULL */ }; -/* structure of a socks server reply */ +/** Structure of a socks server reply */ struct socks_reply { - unsigned char vn; /* socks version number */ - unsigned char cd; /* command code */ - unsigned char dstport[2]; /* destination port */ - unsigned char dstip[4]; /* destination address */ + unsigned char vn; /**< Socks version number */ + unsigned char cd; /**< Command code */ + unsigned char dstport[2]; /**< Destination port */ + unsigned char dstip[4]; /**< Destination address */ }; +/** The SOCKS user ID to use */ static const char socks_userid[] = "anonymous"; -- 2.39.2