4 >Coding Guidelines</TITLE
7 CONTENT="Modular DocBook HTML Stylesheet Version 1.76b+
10 TITLE="Privoxy Developer Manual"
11 HREF="index.html"><LINK
13 TITLE="Documentation Guidelines"
14 HREF="documentation.html"><LINK
16 TITLE="Testing Guidelines"
17 HREF="testing.html"><LINK
20 HREF="../p_doc.css"></HEAD
31 SUMMARY="Header navigation table"
40 >Privoxy Developer Manual</TH
48 HREF="documentation.html"
76 NAME="CODING">4. Coding Guidelines</H1
82 NAME="S1">4.1. Introduction</H2
84 >This set of standards is designed to make our lives easier. It is
85 developed with the simple goal of helping us keep the "new and improved
89 >" consistent and reliable. Thus making
90 maintenance easier and increasing chances of success of the
93 >And that of course comes back to us as individuals. If we can
94 increase our development and product efficiencies then we can solve more
95 of the request for changes/improvements and in general feel good about
103 NAME="S2">4.2. Using Comments</H2
109 NAME="S3">4.2.1. Comment, Comment, Comment</H3
119 >Comment as much as possible without commenting the obvious.
120 For example do not comment "aVariable is equal to bVariable".
121 Instead explain why aVariable should be equal to the bVariable.
122 Just because a person can read code does not mean they will
123 understand why or what is being done. A reader may spend a lot
124 more time figuring out what is going on when a simple comment
125 or explanation would have prevented the extra research. Please
126 help your brother IJB'ers out!</P
128 >The comments will also help justify the intent of the code.
129 If the comment describes something different than what the code
130 is doing then maybe a programming error is occurring.</P
146 CLASS="PROGRAMLISTING"
147 >/* if page size greater than 1k ... */
148 if ( PageLength() > 1024 )
150 ... "block" the page up ...
153 /* if page size is small, send it in blocks */
154 if ( PageLength() > 1024 )
156 ... "block" the page up ...
159 This demonstrates 2 cases of "what not to do". The first is a
160 "syntax comment". The second is a comment that does not fit what
161 is actually being done.</PRE
171 NAME="S4">4.2.2. Use blocks for comments</H3
181 >Comments can help or they can clutter. They help when they
182 are differentiated from the code they describe. One line
183 comments do not offer effective separation between the comment
184 and the code. Block identifiers do, by surrounding the code
185 with a clear, definable pattern.</P
201 CLASS="PROGRAMLISTING"
202 >/*********************************************************************
203 * This will stand out clearly in your code!
204 *********************************************************************/
205 if ( thisVariable == thatVariable )
207 DoSomethingVeryImportant();
211 /* unfortunately, this may not */
212 if ( thisVariable == thatVariable )
214 DoSomethingVeryImportant();
218 if ( thisVariable == thatVariable ) /* this may not either */
220 DoSomethingVeryImportant();
234 >If you are trying to add a small logic comment and do not
235 wish to "disrupt" the flow of the code, feel free to use a 1
236 line comment which is NOT on the same line as the code.</P
243 NAME="S5">4.2.3. Keep Comments on their own line</H3
253 >It goes back to the question of readability. If the comment
254 is on the same line as the code it will be harder to read than
255 the comment that is on its own line.</P
257 >There are three exceptions to this rule, which should be
258 violated freely and often: during the definition of variables,
259 at the end of closing braces, when used to comment
276 CLASS="PROGRAMLISTING"
277 >/*********************************************************************
278 * This will stand out clearly in your code,
279 * But the second example won't.
280 *********************************************************************/
281 if ( thisVariable == thatVariable )
283 DoSomethingVeryImportant();
286 if ( thisVariable == thatVariable ) /*can you see me?*/
288 DoSomethingVeryImportant(); /*not easily*/
292 /*********************************************************************
293 * But, the encouraged exceptions:
294 *********************************************************************/
295 int urls_read = 0; /* # of urls read + rejected */
296 int urls_rejected = 0; /* # of urls rejected */
300 DoSomethingVeryImportant();
304 short DoSomethingVeryImportant(
305 short firstparam, /* represents something */
306 short nextparam /* represents something else */ )
310 } /* -END- DoSomethingVeryImportant */</PRE
320 NAME="S6">4.2.4. Comment each logical step</H3
330 >Logical steps should be commented to help others follow the
331 intent of the written code and comments will make the code more
334 >If you have 25 lines of code without a comment, you should
335 probably go back into it to see where you forgot to put
338 >Most "for", "while", "do", etc... loops _probably_ need a
339 comment. After all, these are usually major logic
347 NAME="S7">4.2.5. Comment All Functions Thoroughly</H3
357 >A reader of the code should be able to look at the comments
358 just prior to the beginning of a function and discern the
359 reason for its existence and the consequences of using it. The
360 reader should not have to read through the code to determine if
361 a given function is safe for a desired use. The proper
362 information thoroughly presented at the introduction of a
363 function not only saves time for subsequent maintenance or
364 debugging, it more importantly aids in code reuse by allowing a
365 user to determine the safety and applicability of any function
366 for the problem at hand. As a result of such benefits, all
367 functions should contain the information presented in the
368 addendum section of this document.</P
375 NAME="S8">4.2.6. Comment at the end of braces if the
376 content is more than one screen length</H3
386 >Each closing brace should be followed on the same line by a
387 comment that describes the origination of the brace if the
388 original brace is off of the screen, or otherwise far away from
389 the closing brace. This will simplify the debugging,
390 maintenance, and readability of the code.</P
392 >As a suggestion , use the following flags to make the
393 comment and its brace more readable:</P
395 >use following a closing brace: } /* -END- if() or while ()
412 CLASS="PROGRAMLISTING"
415 DoSomethingVeryImportant();
416 ...some long list of commands...
417 } /* -END- if x is 1 */
423 DoSomethingVeryImportant();
424 ...some long list of commands...
425 } /* -END- if ( 1 == X ) */</PRE
436 NAME="S9">4.3. Naming Conventions</H2
442 NAME="S10">4.3.1. Variable Names</H3
452 >Use all lowercase, and separate words via an underscore
453 ('_'). Do not start an identifier with an underscore. (ANSI C
454 reserves these for use by the compiler and system headers.) Do
455 not use identifiers which are reserved in ANSI C++. (E.g.
456 template, class, true, false, ...). This is in case we ever
457 decide to port Privoxy to C++.</P
473 CLASS="PROGRAMLISTING"
474 >int ms_iis5_hack = 0;</PRE
494 CLASS="PROGRAMLISTING"
495 >int msiis5hack = 0; int msIis5Hack = 0;</PRE
506 NAME="S11">4.3.2. Function Names</H3
516 >Use all lowercase, and separate words via an underscore
517 ('_'). Do not start an identifier with an underscore. (ANSI C
518 reserves these for use by the compiler and system headers.) Do
519 not use identifiers which are reserved in ANSI C++. (E.g.
520 template, class, true, false, ...). This is in case we ever
521 decide to port Privoxy to C++.</P
537 CLASS="PROGRAMLISTING"
538 >int load_some_file( struct client_state *csp )</PRE
558 CLASS="PROGRAMLISTING"
559 >int loadsomefile( struct client_state *csp )
560 int loadSomeFile( struct client_state *csp )</PRE
571 NAME="S12">4.3.3. Header file prototypes</H3
581 >Use a descriptive parameter name in the function prototype
582 in header files. Use the same parameter name in the header file
583 that you use in the c file.</P
599 CLASS="PROGRAMLISTING"
600 >(.h) extern int load_aclfile( struct client_state *csp );
601 (.c) int load_aclfile( struct client_state *csp )</PRE
620 CLASS="PROGRAMLISTING"
621 >(.h) extern int load_aclfile( struct client_state * ); or
622 (.h) extern int load_aclfile();
623 (.c) int load_aclfile( struct client_state *csp )</PRE
634 NAME="S13">4.3.4. Enumerations, and #defines</H3
644 >Use all capital letters, with underscores between words. Do
645 not start an identifier with an underscore. (ANSI C reserves
646 these for use by the compiler and system headers.)</P
662 CLASS="PROGRAMLISTING"
663 >(enumeration) : enum Boolean { FALSE, TRUE };
664 (#define) : #define DEFAULT_SIZE 100;</PRE
675 > We have a standard naming scheme for #defines
676 that toggle a feature in the preprocessor: FEATURE_>, where
677 > is a short (preferably 1 or 2 word) description.</P
693 CLASS="PROGRAMLISTING"
694 >#define FEATURE_FORCE 1
697 #define FORCE_PREFIX blah
698 #endif /* def FEATURE_FORCE */</PRE
708 NAME="S14">4.3.5. Constants</H3
718 >Spell common words out entirely (do not remove vowels).</P
720 >Use only widely-known domain acronyms and abbreviations.
721 Capitalize all letters of an acronym.</P
723 >Use underscore (_) to separate adjacent acronyms and
724 abbreviations. Never terminate a name with an underscore.</P
740 CLASS="PROGRAMLISTING"
741 >#define USE_IMAGE_LIST 1</PRE
761 CLASS="PROGRAMLISTING"
762 >#define USE_IMG_LST 1 or
763 #define _USE_IMAGE_LIST 1 or
764 #define USE_IMAGE_LIST_ 1 or
765 #define use_image_list 1 or
766 #define UseImageList 1</PRE
778 NAME="S15">4.4. Using Space</H2
784 NAME="S16">4.4.1. Put braces on a line by themselves.</H3
794 >The brace needs to be on a line all by itself, not at the
795 end of the statement. Curly braces should line up with the
796 construct that they're associated with. This practice makes it
797 easier to identify the opening and closing braces for a
814 CLASS="PROGRAMLISTING"
831 >if ( this == that ) { ... }</P
835 >if ( this == that ) { ... }</P
843 > In the special case that the if-statement is
844 inside a loop, and it is trivial, i.e. it tests for a
845 condition that is obvious from the purpose of the block,
846 one-liners as above may optically preserve the loop structure
847 and make it easier to read.</P
855 > developer-discretion.</P
861 >Example exception:</I
871 CLASS="PROGRAMLISTING"
872 >while ( more lines are read )
874 /* Please document what is/is not a comment line here */
875 if ( it's a comment ) continue;
877 do_something( line );
888 NAME="S17">4.4.2. ALL control statements should have a
899 >Using braces to make a block will make your code more
900 readable and less prone to error. All control statements should
901 have a block defined.</P
917 CLASS="PROGRAMLISTING"
935 >if ( this == that ) DoSomething(); DoSomethingElse();</P
939 >if ( this == that ) DoSomething();</P
947 > The first example in "Instead of" will execute
948 in a manner other than that which the developer desired (per
949 indentation). Using code braces would have prevented this
950 "feature". The "explanation" and "exception" from the point
951 above also applies.</P
958 NAME="S18">4.4.3. Do not belabor/blow-up boolean
975 CLASS="PROGRAMLISTING"
976 >structure->flag = ( condition );</PRE
989 >if ( condition ) { structure->flag = 1; } else {
990 structure->flag = 0; }</P
998 > The former is readable and concise. The later
999 is wordy and inefficient. Please assume that any developer new
1000 to the project has at least a "good" knowledge of C/C++. (Hope
1001 I do not offend by that last comment ... 8-)</P
1008 NAME="S19">4.4.4. Use white space freely because it is
1019 >Make it readable. The notable exception to using white space
1020 freely is listed in the next guideline.</P
1036 CLASS="PROGRAMLISTING"
1037 >int firstValue = 0;
1039 int anotherValue = 0;
1040 int thisVariable = 0;
1042 if ( thisVariable == thatVariable )
1044 firstValue = oldValue + ( ( someValue - anotherValue ) - whatever )</PRE
1054 NAME="S20">4.4.5. Don't use white space around structure
1065 >- structure pointer operator ( "->" ) - member operator (
1066 "." ) - functions and parentheses</P
1068 >It is a general coding practice to put pointers, references,
1069 and function parentheses next to names. With spaces, the
1070 connection between the object and variable/function name is not
1087 CLASS="PROGRAMLISTING"
1088 >aStruct->aMember;
1090 FunctionName();</PRE
1101 > aStruct -> aMember; aStruct . aMember;
1109 NAME="S21">4.4.6. Make the last brace of a function stand
1126 CLASS="PROGRAMLISTING"
1127 >int function1( ... )
1132 } /* -END- function1 */
1135 int function2( ... )
1137 } /* -END- function2 */</PRE
1150 >int function1( ... ) { ...code... return( retCode ); } int
1151 function2( ... ) { }</P
1159 > Use 1 blank line before the closing brace and 2
1160 lines afterward. This makes the end of function standout to
1161 the most casual viewer. Although function comments help
1162 separate functions, this is still a good coding practice. In
1163 fact, I follow these rules when using blocks in "for", "while",
1164 "do" loops, and long if {} statements too. After all whitespace
1173 > developer-discretion on the number of blank
1174 lines. Enforced is the end of function comments.</P
1181 NAME="S22">4.4.7. Use 3 character indentions</H3
1191 >If some use 8 character TABs and some use 3 character TABs,
1192 the code can look *very* ragged. So use 3 character indentions
1193 only. If you like to use TABs, pass your code through a filter
1194 such as "expand -t3" before checking in your code.</P
1210 CLASS="PROGRAMLISTING"
1211 >static const char * const url_code_map[256] =
1217 int function1( ... )
1221 return( ALWAYS_TRUE );
1225 return( HOW_DID_YOU_GET_HERE );
1228 return( NEVER_GETS_HERE );
1241 NAME="S23">4.5. Initializing</H2
1247 NAME="S24">4.5.1. Initialize all variables</H3
1257 >Do not assume that the variables declared will not be used
1258 until after they have been assigned a value somewhere else in
1259 the code. Remove the chance of accidentally using an unassigned
1276 CLASS="PROGRAMLISTING"
1279 struct *ptr = NULL;</PRE
1290 > It is much easier to debug a SIGSEGV if the
1291 message says you are trying to access memory address 00000000
1292 and not 129FA012; or arrayPtr[20] causes a SIGSEV vs.
1301 > developer-discretion if and only if the
1302 variable is assigned a value "shortly after" declaration.</P
1310 NAME="S25">4.6. Functions</H2
1316 NAME="S26">4.6.1. Name functions that return a boolean as a
1327 >Value should be phrased as a question that would logically
1328 be answered as a true or false statement</P
1344 CLASS="PROGRAMLISTING"
1345 >ShouldWeBlockThis();
1347 IsWebPageBlank();</PRE
1357 NAME="S27">4.6.2. Always specify a return type for a
1368 >The default return for a function is an int. To avoid
1369 ambiguity, create a return for a function when the return has a
1370 purpose, and create a void return type if the function does not
1371 need to return anything.</P
1378 NAME="S28">4.6.3. Minimize function calls when iterating by
1389 >It is easy to write the following code, and a clear argument
1390 can be made that the code is easy to understand:</P
1406 CLASS="PROGRAMLISTING"
1407 >for ( size_t cnt = 0; cnt < blockListLength(); cnt ++ )
1421 > Unfortunately, this makes a function call for
1422 each and every iteration. This increases the overhead in the
1423 program, because the compiler has to look up the function each
1424 time, call it, and return a value. Depending on what occurs in
1425 the blockListLength() call, it might even be creating and
1426 destroying structures with each iteration, even though in each
1427 case it is comparing "cnt" to the same value, over and over.
1428 Remember too - even a call to blockListLength() is a function
1429 call, with the same overhead.</P
1431 >Instead of using a function call during the iterations,
1432 assign the value to a variable, and evaluate using the
1449 CLASS="PROGRAMLISTING"
1450 >size_t len = blockListLength();
1452 for ( size_t cnt = 0; cnt < len; cnt ++ )
1466 > if the value of blockListLength() *may*
1467 change or could *potentially* change, then you must code the
1468 function call in the for/while loop.</P
1475 NAME="S29">4.6.4. Pass and Return by Const Reference</H3
1485 >This allows a developer to define a const pointer and call
1486 your function. If your function does not have the const
1487 keyword, we may not be able to use your function. Consider
1488 strcmp, if it were defined as: extern int strcmp( char *s1,
1491 >I could then not use it to compare argv's in main: int main(
1492 int argc, const char *argv[] ) { strcmp( argv[0], "privoxy"
1495 >Both these pointers are *const*! If the c runtime library
1496 maintainers do it, we should too.</P
1503 NAME="S30">4.6.5. Pass and Return by Value</H3
1513 >Most structures cannot fit onto a normal stack entry (i.e.
1514 they are not 4 bytes or less). Aka, a function declaration
1515 like: int load_aclfile( struct client_state csp )</P
1517 >would not work. So, to be consistent, we should declare all
1518 prototypes with "pass by value": int load_aclfile( struct
1519 client_state *csp )</P
1526 NAME="S31">4.6.6. Names of include files</H3
1536 >Your include statements should contain the file name without
1537 a path. The path should be listed in the Makefile, using -I as
1538 processor directive to search the indicated paths. An exception
1539 to this would be for some proprietary software that utilizes a
1540 partial path to distinguish their header files from system or
1541 other header files.</P
1557 CLASS="PROGRAMLISTING"
1558 >#include <iostream.h> /* This is not a local include */
1559 #include "config.h" /* This IS a local include */</PRE
1579 CLASS="PROGRAMLISTING"
1580 >/* This is not a local include, but requires a path element. */
1581 #include <sys/fileName.h></PRE
1593 > Please! do not add "-I." to the Makefile
1594 without a _very_ good reason. This duplicates the #include
1595 "file.h" behavior.</P
1602 NAME="S32">4.6.7. Provide multiple inclusion
1613 >Prevents compiler and linker errors resulting from
1614 redefinition of items.</P
1616 >Wrap each header file with the following syntax to prevent
1617 multiple inclusions of the file. Of course, replace PROJECT_H
1618 with your file name, with "." Changed to "_", and make it
1635 CLASS="PROGRAMLISTING"
1636 >#ifndef PROJECT_H_INCLUDED
1637 #define PROJECT_H_INCLUDED
1639 #endif /* ndef PROJECT_H_INCLUDED */</PRE
1649 NAME="S33">4.6.8. Use `extern "C"` when appropriate</H3
1659 >If our headers are included from C++, they must declare our
1660 functions as `extern "C"`. This has no cost in C, but increases
1661 the potential re-usability of our code.</P
1677 CLASS="PROGRAMLISTING"
1681 #endif /* def __cplusplus */
1683 ... function definitions here ...
1687 #endif /* def __cplusplus */</PRE
1697 NAME="S34">4.6.9. Where Possible, Use Forward Struct
1698 Declaration Instead of Includes</H3
1708 >Useful in headers that include pointers to other struct's.
1709 Modifications to excess header files may cause needless
1726 CLASS="PROGRAMLISTING"
1727 >/*********************************************************************
1728 * We're avoiding an include statement here!
1729 *********************************************************************/
1731 extern file_list *xyz;</PRE
1742 > If you declare "file_list xyz;" (without the
1743 pointer), then including the proper header file is necessary.
1744 If you only want to prototype a pointer, however, the header
1745 file is unnecessary.</P
1753 > Use with discretion.</P
1761 NAME="S35">4.7. General Coding Practices</H2
1767 NAME="S36">4.7.1. Turn on warnings</H3
1777 >Compiler warnings are meant to help you find bugs. You
1778 should turn on as many as possible. With GCC, the switch is
1779 "-Wall". Try and fix as many warnings as possible.</P
1786 NAME="S37">4.7.2. Provide a default case for all switch
1797 >What you think is guaranteed is never really guaranteed. The
1798 value that you don't think you need to check is the one that
1799 someday will be passed. So, to protect yourself from the
1800 unknown, always have a default step in a switch statement.</P
1816 CLASS="PROGRAMLISTING"
1817 >switch( hash_string( cmd ) )
1819 case hash_actions_file :
1829 ... anomaly code goes here ...
1830 continue; / break; / exit( 1 ); / etc ...
1832 } /* end switch( hash_string( cmd ) ) */</PRE
1843 > If you already have a default condition, you
1844 are obviously exempt from this point. Of note, most of the
1845 WIN32 code calls `DefWindowProc' after the switch statement.
1846 This API call *should* be included in a default statement.</P
1854 > This is not so much a readability issue
1855 as a robust programming issue. The "anomaly code goes here" may
1856 be no more than a print to the STDERR stream (as in
1857 load_config). Or it may really be an ABEND condition.</P
1865 > Programmer discretion is advised.</P
1872 NAME="S38">4.7.3. Try to avoid falling through cases in a
1873 switch statement.</H3
1883 >In general, you will want to have a 'break' statement within
1884 each 'case' of a switch statement. This allows for the code to
1885 be more readable and understandable, and furthermore can
1886 prevent unwanted surprises if someone else later gets creative
1887 and moves the code around.</P
1889 >The language allows you to plan the fall through from one
1890 case statement to another simply by omitting the break
1891 statement within the case statement. This feature does have
1892 benefits, but should only be used in rare cases. In general,
1893 use a break statement for each case statement.</P
1895 >If you choose to allow fall through, you should comment both
1896 the fact of the fall through and reason why you felt it was
1904 NAME="S39">4.7.4. Use 'long' or 'short' Instead of
1915 >On 32-bit platforms, int usually has the range of long. On
1916 16-bit platforms, int has the range of short.</P
1924 > open-to-debate. In the case of most FSF
1925 projects (including X/GNU-Emacs), there are typedefs to int4,
1926 int8, int16, (or equivalence ... I forget the exact typedefs
1927 now). Should we add these to IJB now that we have a "configure"
1935 NAME="S40">4.7.5. Don't mix size_t and other types</H3
1945 >The type of size_t varies across platforms. Do not make
1946 assumptions about whether it is signed or unsigned, or about
1947 how long it is. Do not compare a size_t against another
1948 variable of a different type (or even against a constant)
1949 without casting one of the values. Try to avoid using size_t if
1957 NAME="S41">4.7.6. Declare each variable and struct on its
1968 >It can be tempting to declare a series of variables all on
1985 CLASS="PROGRAMLISTING"
2009 > - there is more room for comments on the
2010 individual variables - easier to add new variables without
2011 messing up the original ones - when searching on a variable to
2012 find its type, there is less clutter to "visually"
2021 > when you want to declare a bunch of loop
2022 variables or other trivial variables; feel free to declare them
2023 on 1 line. You should, although, provide a good comment on
2032 > developer-discretion.</P
2039 NAME="S42">4.7.7. Use malloc/zalloc sparingly</H3
2049 >Create a local struct (on the stack) if the variable will
2050 live and die within the context of one function call.</P
2052 >Only "malloc" a struct (on the heap) if the variable's life
2053 will extend beyond the context of one function call.</P
2069 CLASS="PROGRAMLISTING"
2070 >If a function creates a struct and stores a pointer to it in a
2071 list, then it should definitely be allocated via `malloc'.</PRE
2081 NAME="S43">4.7.8. The Programmer Who Uses 'malloc' is
2082 Responsible for Ensuring 'free'</H3
2092 >If you have to "malloc" an instance, you are responsible for
2093 insuring that the instance is `free'd, even if the deallocation
2094 event falls within some other programmer's code. You are also
2095 responsible for ensuring that deletion is timely (i.e. not too
2096 soon, not too late). This is known as "low-coupling" and is a
2097 "good thing (tm)". You may need to offer a
2098 free/unload/destructor type function to accommodate this.</P
2114 CLASS="PROGRAMLISTING"
2115 >int load_re_filterfile( struct client_state *csp ) { ... }
2116 static void unload_re_filterfile( void *f ) { ... }</PRE
2129 >The developer cannot be expected to provide `free'ing
2130 functions for C run-time library functions ... such as
2139 > developer-discretion. The "main" use of this
2140 standard is for allocating and freeing data structures (complex
2148 NAME="S44">4.7.9. Add loaders to the `file_list' structure
2159 >I have ordered all of the "blocker" file code to be in alpha
2160 order. It is easier to add/read new blockers when you expect a
2169 > It may appear that the alpha order is broken in
2170 places by POPUP tests coming before PCRS tests. But since
2171 POPUPs can also be referred to as KILLPOPUPs, it is clear that
2172 it should come first.</P
2179 NAME="S45">4.7.10. "Uncertain" new code and/or changes to
2180 existing code, use FIXME</H3
2190 >If you have enough confidence in new code or confidence in
2191 your changes, but are not *quite* sure of the repercussions,
2194 >/* FIXME: this code has a logic error on platform XYZ, *
2195 attempting to fix */ #ifdef PLATFORM ...changed code here...
2200 >/* FIXME: I think the original author really meant this...
2201 */ ...changed code here...</P
2205 >/* FIXME: new code that *may* break something else... */
2206 ...new code here...</P
2214 > If you make it clear that this may or may not
2215 be a "good thing (tm)", it will be easier to identify and
2216 include in the project (or conversely exclude from the
2225 NAME="S46">4.8. Addendum: Template for files and function
2232 >Example for file comments:</I
2242 CLASS="PROGRAMLISTING"
2243 >const char FILENAME_rcs[] = "$Id: developer-manual.sgml,v 2.3 2002/09/05 02:27:59 hal9 Exp $";
2244 /*********************************************************************
2248 * Purpose : (Fill me in with a good description!)
2250 * Copyright : Written by and Copyright (C) 2001 the SourceForge
2251 * Privoxy team. http://www.privoxy.org/
2253 * Based on the Internet Junkbuster originally written
2254 * by and Copyright (C) 1997 Anonymous Coders and
2255 * Junkbusters Corporation. http://www.junkbusters.com
2257 * This program is free software; you can redistribute it
2258 * and/or modify it under the terms of the GNU General
2259 * Public License as published by the Free Software
2260 * Foundation; either version 2 of the License, or (at
2261 * your option) any later version.
2263 * This program is distributed in the hope that it will
2264 * be useful, but WITHOUT ANY WARRANTY; without even the
2265 * implied warranty of MERCHANTABILITY or FITNESS FOR A
2266 * PARTICULAR PURPOSE. See the GNU General Public
2267 * License for more details.
2269 * The GNU General Public License should be included with
2270 * this file. If not, you can view it at
2271 * http://www.gnu.org/copyleft/gpl.html
2272 * or write to the Free Software Foundation, Inc., 59
2273 * Temple Place - Suite 330, Boston, MA 02111-1307, USA.
2278 *********************************************************************/
2283 ...necessary include files for us to do our work...
2285 const char FILENAME_h_rcs[] = FILENAME_H_VERSION;</PRE
2296 > This declares the rcs variables that should be
2297 added to the "show-proxy-args" page. If this is a brand new
2298 creation by you, you are free to change the "Copyright" section
2299 to represent the rights you wish to maintain.</P
2307 > The formfeed character that is present right
2308 after the comment flower box is handy for (X|GNU)Emacs users to
2309 skip the verbiage and get to the heart of the code (via
2310 `forward-page' and `backward-page'). Please include it if you
2317 >Example for file header comments:</I
2327 CLASS="PROGRAMLISTING"
2328 >#ifndef _FILENAME_H
2330 #define FILENAME_H_VERSION "$Id: developer-manual.sgml,v 2.3 2002/09/05 02:27:59 hal9 Exp $"
2331 /*********************************************************************
2335 * Purpose : (Fill me in with a good description!)
2337 * Copyright : Written by and Copyright (C) 2001 the SourceForge
2338 * Privoxy team. http://www.privoxy.org/
2340 * Based on the Internet Junkbuster originally written
2341 * by and Copyright (C) 1997 Anonymous Coders and
2342 * Junkbusters Corporation. http://www.junkbusters.com
2344 * This program is free software; you can redistribute it
2345 * and/or modify it under the terms of the GNU General
2346 * Public License as published by the Free Software
2347 * Foundation; either version 2 of the License, or (at
2348 * your option) any later version.
2350 * This program is distributed in the hope that it will
2351 * be useful, but WITHOUT ANY WARRANTY; without even the
2352 * implied warranty of MERCHANTABILITY or FITNESS FOR A
2353 * PARTICULAR PURPOSE. See the GNU General Public
2354 * License for more details.
2356 * The GNU General Public License should be included with
2357 * this file. If not, you can view it at
2358 * http://www.gnu.org/copyleft/gpl.html
2359 * or write to the Free Software Foundation, Inc., 59
2360 * Temple Place - Suite 330, Boston, MA 02111-1307, USA.
2365 *********************************************************************/
2368 #include "project.h"
2374 ... function headers here ...
2377 /* Revision control strings from this header and associated .c file */
2378 extern const char FILENAME_rcs[];
2379 extern const char FILENAME_h_rcs[];
2386 #endif /* ndef _FILENAME_H */
2401 >Example for function comments:</I
2411 CLASS="PROGRAMLISTING"
2412 >/*********************************************************************
2414 * Function : FUNCTION_NAME
2416 * Description : (Fill me in with a good description!)
2419 * 1 : param1 = pointer to an important thing
2420 * 2 : x = pointer to something else
2422 * Returns : 0 => Ok, everything else is an error.
2424 *********************************************************************/
2425 int FUNCTION_NAME( void *param1, const char *x )
2441 > If we all follow this practice, we should be
2442 able to parse our code to create a "self-documenting" web
2451 SUMMARY="Footer navigation table"
2462 HREF="documentation.html"
2490 >Documentation Guidelines</TD
2500 >Testing Guidelines</TD