Rebuild for 3.0.17 stable
[privoxy.git] / doc / webserver / developer-manual / coding.html
index fead798..6898541 100644 (file)
@@ -1,11 +1,11 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN""http://www.w3.org/TR/html4/loose.dtd">
 <HTML
 ><HEAD
 ><TITLE
 >Coding Guidelines</TITLE
 ><META
 NAME="GENERATOR"
 <HTML
 ><HEAD
 ><TITLE
 >Coding Guidelines</TITLE
 ><META
 NAME="GENERATOR"
-CONTENT="Modular DocBook HTML Stylesheet Version 1.7"><LINK
+CONTENT="Modular DocBook HTML Stylesheet Version 1.79"><LINK
 REL="HOME"
 TITLE="Privoxy Developer Manual"
 HREF="index.html"><LINK
 REL="HOME"
 TITLE="Privoxy Developer Manual"
 HREF="index.html"><LINK
@@ -17,7 +17,10 @@ TITLE="Testing Guidelines"
 HREF="testing.html"><LINK
 REL="STYLESHEET"
 TYPE="text/css"
 HREF="testing.html"><LINK
 REL="STYLESHEET"
 TYPE="text/css"
-HREF="../p_doc.css"></HEAD
+HREF="../p_doc.css"><META
+HTTP-EQUIV="Content-Type"
+CONTENT="text/html;
+charset=ISO-8859-1"></HEAD
 ><BODY
 CLASS="SECT1"
 BGCOLOR="#EEEEEE"
 ><BODY
 CLASS="SECT1"
 BGCOLOR="#EEEEEE"
@@ -125,8 +128,8 @@ CLASS="EMPHASIS"
 ></P
 ><P
 >Comment as much as possible without commenting the obvious.
 ></P
 ><P
 >Comment as much as possible without commenting the obvious.
-    For example do not comment "aVariable is equal to bVariable".
-    Instead explain why aVariable should be equal to the bVariable.
+    For example do not comment "variable_a is equal to variable_b".
+    Instead explain why variable_a should be equal to the variable_b.
     Just because a person can read code does not mean they will
     understand why or what is being done. A reader may spend a lot
     more time figuring out what is going on when a simple comment
     Just because a person can read code does not mean they will
     understand why or what is being done. A reader may spend a lot
     more time figuring out what is going on when a simple comment
@@ -153,13 +156,13 @@ WIDTH="100%"
 ><PRE
 CLASS="PROGRAMLISTING"
 >/* if page size greater than 1k ... */
 ><PRE
 CLASS="PROGRAMLISTING"
 >/* if page size greater than 1k ... */
-if ( PageLength() &#62; 1024 )
+if ( page_length() &#62; 1024 )
 {
     ... "block" the page up ...
 }
 
 /* if page size is small, send it in blocks */
 {
     ... "block" the page up ...
 }
 
 /* if page size is small, send it in blocks */
-if ( PageLength() &#62; 1024 )
+if ( page_length() &#62; 1024 )
 {
     ... "block" the page up ...
 }
 {
     ... "block" the page up ...
 }
@@ -212,22 +215,22 @@ CLASS="PROGRAMLISTING"
 >/*********************************************************************
  * This will stand out clearly in your code!
  *********************************************************************/
 >/*********************************************************************
  * This will stand out clearly in your code!
  *********************************************************************/
-if ( thisVariable == thatVariable )
+if ( this_variable == that_variable )
 {
 {
-   DoSomethingVeryImportant();
+   do_something_very_important();
 }
 
 
 /* unfortunately, this may not */
 }
 
 
 /* unfortunately, this may not */
-if ( thisVariable == thatVariable )
+if ( this_variable == that_variable )
 {
 {
-   DoSomethingVeryImportant();
+   do_something_very_important();
 }
 
 
 }
 
 
-if ( thisVariable == thatVariable ) /* this may not either */
+if ( this_variable == that_variable ) /* this may not either */
 {
 {
-   DoSomethingVeryImportant();
+   do_something_very_important();
 }</PRE
 ></TD
 ></TR
 }</PRE
 ></TD
 ></TR
@@ -290,14 +293,14 @@ CLASS="PROGRAMLISTING"
  * This will stand out clearly in your code,
  * But the second example won't.
  *********************************************************************/
  * This will stand out clearly in your code,
  * But the second example won't.
  *********************************************************************/
-if ( thisVariable == thatVariable )
+if ( this_variable == this_variable )
 {
 {
-   DoSomethingVeryImportant();
+   do_something_very_important();
 }
 
 }
 
-if ( thisVariable == thatVariable ) /*can you see me?*/
+if ( this_variable == this_variable ) /*can you see me?*/
 {
 {
-   DoSomethingVeryImportant(); /*not easily*/
+   do_something_very_important(); /*not easily*/
 }
 
 
 }
 
 
@@ -309,17 +312,17 @@ int urls_rejected = 0;     /* # of urls rejected */
 
 if ( 1 == X )
 {
 
 if ( 1 == X )
 {
-   DoSomethingVeryImportant();
+   do_something_very_important();
 }
 
 
 }
 
 
-short DoSomethingVeryImportant(
+short do_something_very_important(
    short firstparam,   /* represents something */
    short nextparam     /* represents something else */ )
 {
    ...code here...
 
    short firstparam,   /* represents something */
    short nextparam     /* represents something else */ )
 {
    ...code here...
 
-}   /* -END- DoSomethingVeryImportant */</PRE
+}   /* -END- do_something_very_important */</PRE
 ></TD
 ></TR
 ></TABLE
 ></TD
 ></TR
 ></TABLE
@@ -430,7 +433,7 @@ WIDTH="100%"
 CLASS="PROGRAMLISTING"
 >if ( 1 == X )
 {
 CLASS="PROGRAMLISTING"
 >if ( 1 == X )
 {
-   DoSomethingVeryImportant();
+   do_something_very_important();
    ...some long list of commands...
 } /* -END- if x is 1 */
 
    ...some long list of commands...
 } /* -END- if x is 1 */
 
@@ -438,7 +441,7 @@ or:
 
 if ( 1 == X )
 {
 
 if ( 1 == X )
 {
-   DoSomethingVeryImportant();
+   do_something_very_important();
    ...some long list of commands...
 } /* -END- if ( 1 == X ) */</PRE
 ></TD
    ...some long list of commands...
 } /* -END- if ( 1 == X ) */</PRE
 ></TD
@@ -953,8 +956,8 @@ WIDTH="100%"
 CLASS="PROGRAMLISTING"
 >if ( this == that )
 {
 CLASS="PROGRAMLISTING"
 >if ( this == that )
 {
-   DoSomething();
-   DoSomethingElse();
+   do_something();
+   do_something_else();
 }</PRE
 ></TD
 ></TR
 }</PRE
 ></TD
 ></TR
@@ -968,11 +971,11 @@ CLASS="EMPHASIS"
 ></SPAN
 ></P
 ><P
 ></SPAN
 ></P
 ><P
->if ( this == that ) DoSomething(); DoSomethingElse();</P
+>if ( this == that ) do_something(); do_something_else();</P
 ><P
 >or</P
 ><P
 ><P
 >or</P
 ><P
->if ( this == that ) DoSomething();</P
+>if ( this == that ) do_something();</P
 ><P
 ><SPAN
 CLASS="emphasis"
 ><P
 ><SPAN
 CLASS="emphasis"
@@ -1074,14 +1077,14 @@ WIDTH="100%"
 ><TD
 ><PRE
 CLASS="PROGRAMLISTING"
 ><TD
 ><PRE
 CLASS="PROGRAMLISTING"
->int firstValue   = 0;
-int someValue    = 0;
-int anotherValue = 0;
-int thisVariable = 0;
+>int first_value   = 0;
+int some_value    = 0;
+int another_value = 0;
+int this_variable = 0;
 
 
-if ( thisVariable == thatVariable )
+if ( this_variable == this_variable )
 
 
-firstValue = oldValue + ( ( someValue - anotherValue ) - whatever )</PRE
+first_value = old_value + ( ( some_value - another_value ) - whatever )</PRE
 ></TD
 ></TR
 ></TABLE
 ></TD
 ></TR
 ></TABLE
@@ -1127,9 +1130,9 @@ WIDTH="100%"
 ><TD
 ><PRE
 CLASS="PROGRAMLISTING"
 ><TD
 ><PRE
 CLASS="PROGRAMLISTING"
->aStruct-&#62;aMember;
-aStruct.aMember;
-FunctionName();</PRE
+>a_struct-&#62;a_member;
+a_struct.a_member;
+function_name();</PRE
 ></TD
 ></TR
 ></TABLE
 ></TD
 ></TR
 ></TABLE
@@ -1140,8 +1143,8 @@ CLASS="emphasis"
 CLASS="EMPHASIS"
 >Instead of:</I
 ></SPAN
 CLASS="EMPHASIS"
 >Instead of:</I
 ></SPAN
-> aStruct -&#62; aMember; aStruct . aMember;
-    FunctionName ();</P
+> a_struct -&#62; a_member; a_struct . a_member;
+    function_name ();</P
 ></DIV
 ><DIV
 CLASS="SECT3"
 ></DIV
 ><DIV
 CLASS="SECT3"
@@ -1171,7 +1174,7 @@ CLASS="PROGRAMLISTING"
 >int function1( ... )
 {
    ...code...
 >int function1( ... )
 {
    ...code...
-   return( retCode );
+   return( ret_code );
 
 }   /* -END- function1 */
 
 
 }   /* -END- function1 */
 
@@ -1191,7 +1194,7 @@ CLASS="EMPHASIS"
 ></SPAN
 ></P
 ><P
 ></SPAN
 ></P
 ><P
->int function1( ... ) { ...code... return( retCode ); } int
+>int function1( ... ) { ...code... return( ret_code ); } int
     function2( ... ) { }</P
 ><P
 ><SPAN
     function2( ... ) { }</P
 ><P
 ><SPAN
@@ -1324,8 +1327,8 @@ WIDTH="100%"
 ><TD
 ><PRE
 CLASS="PROGRAMLISTING"
 ><TD
 ><PRE
 CLASS="PROGRAMLISTING"
->short anShort = 0;
-float aFloat  = 0;
+>short a_short = 0;
+float a_float  = 0;
 struct *ptr = NULL;</PRE
 ></TD
 ></TR
 struct *ptr = NULL;</PRE
 ></TD
 ></TR
@@ -1339,8 +1342,8 @@ CLASS="EMPHASIS"
 ></SPAN
 > It is much easier to debug a SIGSEGV if the
     message says you are trying to access memory address 00000000
 ></SPAN
 > It is much easier to debug a SIGSEGV if the
     message says you are trying to access memory address 00000000
-    and not 129FA012; or arrayPtr[20] causes a SIGSEV vs.
-    arrayPtr[0].</P
+    and not 129FA012; or array_ptr[20] causes a SIGSEV vs.
+    array_ptr[0].</P
 ><P
 ><SPAN
 CLASS="emphasis"
 ><P
 ><SPAN
 CLASS="emphasis"
@@ -1396,9 +1399,9 @@ WIDTH="100%"
 ><TD
 ><PRE
 CLASS="PROGRAMLISTING"
 ><TD
 ><PRE
 CLASS="PROGRAMLISTING"
->ShouldWeBlockThis();
-ContainsAnImage();
-IsWebPageBlank();</PRE
+>should_we_block_this();
+contains_an_image();
+is_web_page_blank();</PRE
 ></TD
 ></TR
 ></TABLE
 ></TD
 ></TR
 ></TABLE
@@ -1462,7 +1465,7 @@ WIDTH="100%"
 ><TD
 ><PRE
 CLASS="PROGRAMLISTING"
 ><TD
 ><PRE
 CLASS="PROGRAMLISTING"
->for ( size_t cnt = 0; cnt &#60; blockListLength(); cnt ++ )
+>for ( size_t cnt = 0; cnt &#60; block_list_length(); cnt++ )
 {
    ....
 }</PRE
 {
    ....
 }</PRE
@@ -1480,10 +1483,10 @@ CLASS="EMPHASIS"
     each and every iteration. This increases the overhead in the
     program, because the compiler has to look up the function each
     time, call it, and return a value. Depending on what occurs in
     each and every iteration. This increases the overhead in the
     program, because the compiler has to look up the function each
     time, call it, and return a value. Depending on what occurs in
-    the blockListLength() call, it might even be creating and
+    the block_list_length() call, it might even be creating and
     destroying structures with each iteration, even though in each
     case it is comparing "cnt" to the same value, over and over.
     destroying structures with each iteration, even though in each
     case it is comparing "cnt" to the same value, over and over.
-    Remember too - even a call to blockListLength() is a function
+    Remember too - even a call to block_list_length() is a function
     call, with the same overhead.</P
 ><P
 >Instead of using a function call during the iterations,
     call, with the same overhead.</P
 ><P
 >Instead of using a function call during the iterations,
@@ -1505,9 +1508,9 @@ WIDTH="100%"
 ><TD
 ><PRE
 CLASS="PROGRAMLISTING"
 ><TD
 ><PRE
 CLASS="PROGRAMLISTING"
->size_t len = blockListLength();
+>size_t len = block_list_length();
 
 
-for ( size_t cnt = 0; cnt &#60; len; cnt ++ )
+for ( size_t cnt = 0; cnt &#60; len; cnt++ )
 {
    ....
 }</PRE
 {
    ....
 }</PRE
@@ -1521,8 +1524,8 @@ CLASS="emphasis"
 CLASS="EMPHASIS"
 >Exceptions:</I
 ></SPAN
 CLASS="EMPHASIS"
 >Exceptions:</I
 ></SPAN
-> if the value of blockListLength() *may*
-    change or could *potentially* change, then you must code the
+> if the value of block_list_length()
+    *may* change or could *potentially* change, then you must code the
     function call in the for/while loop.</P
 ></DIV
 ><DIV
     function call in the for/while loop.</P
 ></DIV
 ><DIV
@@ -1930,7 +1933,7 @@ CLASS="EMPHASIS"
 > This is not so much a readability issue
     as a robust programming issue. The "anomaly code goes here" may
     be no more than a print to the STDERR stream (as in
 > This is not so much a readability issue
     as a robust programming issue. The "anomaly code goes here" may
     be no more than a print to the STDERR stream (as in
-    load_config). Or it may really be an ABEND condition.</P
+    load_config). Or it may really be an abort condition.</P
 ><P
 ><SPAN
 CLASS="emphasis"
 ><P
 ><SPAN
 CLASS="emphasis"
@@ -2028,8 +2031,7 @@ CLASS="EMPHASIS"
     assumptions about whether it is signed or unsigned, or about
     how long it is. Do not compare a size_t against another
     variable of a different type (or even against a constant)
     assumptions about whether it is signed or unsigned, or about
     how long it is. Do not compare a size_t against another
     variable of a different type (or even against a constant)
-    without casting one of the values. Try to avoid using size_t if
-    you can.</P
+    without casting one of the values.</P
 ></DIV
 ><DIV
 CLASS="SECT3"
 ></DIV
 ><DIV
 CLASS="SECT3"
@@ -2104,7 +2106,7 @@ CLASS="EMPHASIS"
 ></SPAN
 > when you want to declare a bunch of loop
     variables or other trivial variables; feel free to declare them
 ></SPAN
 > when you want to declare a bunch of loop
     variables or other trivial variables; feel free to declare them
-    on 1 line. You should, although, provide a good comment on
+    on one line. You should, although, provide a good comment on
     their functions.</P
 ><P
 ><SPAN
     their functions.</P
 ><P
 ><SPAN
@@ -2268,7 +2270,7 @@ CLASS="SECT3"
 ><A
 NAME="S45"
 >4.7.10. "Uncertain" new code and/or changes to
 ><A
 NAME="S45"
 >4.7.10. "Uncertain" new code and/or changes to
-    existing code, use FIXME</A
+    existing code, use FIXME or XXX</A
 ></H3
 ><P
 ><SPAN
 ></H3
 ><P
 ><SPAN
@@ -2334,19 +2336,15 @@ WIDTH="100%"
 ><TD
 ><PRE
 CLASS="PROGRAMLISTING"
 ><TD
 ><PRE
 CLASS="PROGRAMLISTING"
->const char FILENAME_rcs[] = "$Id: coding.html,v 1.19.2.7 2004/01/31 00:05:44 oes Exp $";
+>const char FILENAME_rcs[] = "$Id$";
 /*********************************************************************
  *
 /*********************************************************************
  *
- * File        :  $Source: /cvsroot/ijbswa/current/doc/webserver/developer-manual/coding.html,v $
+ * File        :  $Source$
  *
  * Purpose     :  (Fill me in with a good description!)
  *
  *
  * Purpose     :  (Fill me in with a good description!)
  *
- * Copyright   :  Written by and Copyright (C) 2001 the SourceForge
- *                Privoxy team. http://www.privoxy.org/
- *
- *                Based on the Internet Junkbuster originally written
- *                by and Copyright (C) 1997 Anonymous Coders and
- *                Junkbusters Corporation.  http://www.junkbusters.com
+ * Copyright   :  Written by and Copyright (C) 2001-2009
+ *                the Privoxy team. http://www.privoxy.org/
  *
  *                This program is free software; you can redistribute it
  *                and/or modify it under the terms of the GNU General
  *
  *                This program is free software; you can redistribute it
  *                and/or modify it under the terms of the GNU General
@@ -2362,15 +2360,10 @@ CLASS="PROGRAMLISTING"
  *
  *                The GNU General Public License should be included with
  *                this file.  If not, you can view it at
  *
  *                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: coding.html,v $
- *    Revision 1.19.2.7  2004/01/31 00:05:44  oes
- *    Regenerated from sgml source
- *
+ *                http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
+ *                or write to the Free Software Foundation, Inc., 
+ *                51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 ,
+ *                USA
  *
  *********************************************************************/
 
  *
  *********************************************************************/
 
@@ -2424,19 +2417,15 @@ WIDTH="100%"
 CLASS="PROGRAMLISTING"
 >#ifndef _FILENAME_H
 #define _FILENAME_H
 CLASS="PROGRAMLISTING"
 >#ifndef _FILENAME_H
 #define _FILENAME_H
-#define FILENAME_H_VERSION "$Id: coding.html,v 1.19.2.7 2004/01/31 00:05:44 oes Exp $"
+#define FILENAME_H_VERSION "$Id$"
 /*********************************************************************
  *
 /*********************************************************************
  *
- * File        :  $Source: /cvsroot/ijbswa/current/doc/webserver/developer-manual/coding.html,v $
+ * File        :  $Source$
  *
  * Purpose     :  (Fill me in with a good description!)
  *
  *
  * Purpose     :  (Fill me in with a good description!)
  *
- * Copyright   :  Written by and Copyright (C) 2001 the SourceForge
- *                Privoxy team. http://www.privoxy.org/
- *
- *                Based on the Internet Junkbuster originally written
- *                by and Copyright (C) 1997 Anonymous Coders and
- *                Junkbusters Corporation.  http://www.junkbusters.com
+ * Copyright   :  Written by and Copyright (C) 2001-2009
+ *                the Privoxy team. http://www.privoxy.org/
  *
  *                This program is free software; you can redistribute it
  *                and/or modify it under the terms of the GNU General
  *
  *                This program is free software; you can redistribute it
  *                and/or modify it under the terms of the GNU General
@@ -2452,15 +2441,10 @@ CLASS="PROGRAMLISTING"
  *
  *                The GNU General Public License should be included with
  *                this file.  If not, you can view it at
  *
  *                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: coding.html,v $
- *    Revision 1.19.2.7  2004/01/31 00:05:44  oes
- *    Regenerated from sgml source
- *
+ *                http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
+ *                or write to the Free Software Foundation, Inc., 
+ *                51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 ,
+ *                USA
  *
  *********************************************************************/
 
  *
  *********************************************************************/
 
@@ -2603,4 +2587,4 @@ VALIGN="top"
 ></DIV
 ></BODY
 ></HTML
 ></DIV
 ></BODY
 ></HTML
->
\ No newline at end of file
+>