1 Privoxy Developer Manual
5 $Id: developer-manual.sgml,v 1.18 2002/04/03 03:51:48 hal9 Exp $
7 The developer manual gives the users information on how to help the developer
8 team. It provides guidance on coding, testing, documentation and other issues.
10 Privoxy is a web proxy with advanced filtering capabilities for protecting
11 privacy, filtering web page content, managing cookies, controlling access, and
12 removing ads, banners, pop-ups and other obnoxious Internet junk. Privoxy has a
13 very flexible configuration and can be customized to suit individual needs and
14 tastes. Privoxy has application for both stand-alone systems and multi-user
17 Privoxy is based on the code of the Internet Junkbuster. Junkbuster was
18 originally written by JunkBusters Corporation, and was released as free
19 open-source software under the GNU GPL. Stefan Waldherr made many improvements,
20 and started the SourceForge project to continue development.
22 Privoxy continues the Junkbuster tradition, but adds many refinements and
25 You can find the latest version of the this manual at http://www.privoxy.org/
26 developer-manual/. Please see the Contact section of the User Manual on how to
27 contact the developers.
29 -------------------------------------------------------------------------------
33 2. Quickstart to Privoxy Development
34 3. Documentation Guidelines
40 4.2.1. Comment, Comment, Comment
41 4.2.2. Use blocks for comments
42 4.2.3. Keep Comments on their own line
43 4.2.4. Comment each logical step
44 4.2.5. Comment All Functions Thoroughly
45 4.2.6. Comment at the end of braces if the content is more than one
48 4.3. Naming Conventions
52 4.3.3. Header file prototypes
53 4.3.4. Enumerations, and #defines
58 4.4.1. Put braces on a line by themselves.
59 4.4.2. ALL control statements should have a block
60 4.4.3. Do not belabor/blow-up boolean expressions
61 4.4.4. Use white space freely because it is free
62 4.4.5. Don't use white space around structure operators
63 4.4.6. Make the last brace of a function stand out
64 4.4.7. Use 3 character indentions
68 4.5.1. Initialize all variables
72 4.6.1. Name functions that return a boolean as a question.
73 4.6.2. Always specify a return type for a function.
74 4.6.3. Minimize function calls when iterating by using variables
75 4.6.4. Pass and Return by Const Reference
76 4.6.5. Pass and Return by Value
77 4.6.6. Names of include files
78 4.6.7. Provide multiple inclusion protection
79 4.6.8. Use `extern "C"` when appropriate
80 4.6.9. Where Possible, Use Forward Struct Declaration Instead of
83 4.7. General Coding Practices
85 4.7.1. Turn on warnings
86 4.7.2. Provide a default case for all switch statements
87 4.7.3. Try to avoid falling through cases in a switch statement.
88 4.7.4. Use 'long' or 'short' Instead of 'int'
89 4.7.5. Don't mix size_t and other types
90 4.7.6. Declare each variable and struct on its own line.
91 4.7.7. Use malloc/zalloc sparingly
92 4.7.8. The Programmer Who Uses 'malloc' is Responsible for Ensuring
94 4.7.9. Add loaders to the `file_list' structure and in order
95 4.7.10. "Uncertain" new code and/or changes to exitinst code, use FIXME
97 4.8. Addendum: Template for files and function comment blocks:
99 5. Version Control Guidelines
100 6. Testing Guidelines
102 6.1. Testplan for releases
105 7. Releasing a new version
107 7.1. Before the Release
108 7.2. Update the webserver
121 8. Contact the developers
122 9. Copyright and History
127 Privoxy, as an heir to Junkbuster, is an Open Source project and licensed under
128 the GPL. As such, Privoxy development is potentially open to anyone who has the
129 time, knowledge, and desire to contribute in any capacity. Our goals are simply
130 to continue the mission, to improve Privoxy, and to make it available to as
131 wide an audience as possible.
133 One does not have to be a programmer to contribute. Packaging, testing, and
134 porting, are all important jobs as well.
136 -------------------------------------------------------------------------------
138 2. Quickstart to Privoxy Development
140 You'll need an account on Sourceforge to support our development. Mail your ID
141 to the list and wait until a project manager has added you.
143 For the time being (read, this section is under construction), please note the
144 following guidelines for changing stuff in the code. If it is
146 1. A bugfix / clean-up / cosmetic thing: shoot
148 2. A new feature that can be turned off: shoot
150 3. A clear improvement w/o side effects on other parts of the code: shoot
152 4. A matter of taste: ask the list
154 5. A major redesign of some part of the code: ask the list
156 -------------------------------------------------------------------------------
158 3. Documentation Guidelines
160 All formal documents are maintained in docbook SGML and located in the doc/
161 source directory. You will need docbook and the docbook stylesheets (or
162 comparable alternatives), and either jade or openjade installed in order to
163 build docs from source. Currently there is user-manual, FAQ, and, of course
164 this, the developer-manual in this format.
166 Other, less formal documents (e.g. README, LICENSE) are maintained as plain
167 text files in the toplevel source directory.
169 Packagers are encouraged to include this documentation. For those without the
170 ability to build the docs locally, text versions of each are kept in CVS. Or
171 HTML versions can be downloaded from the www.privoxy.org website, which should
174 Formal documents are built with the Makefile targets of make dok, or
175 alternately make redhat-dok. If you have problems, try both. The build process
176 uses the document SGML sources in doc/source to update all text files in doc/
177 text and to update all HTML documents in doc/webserver.
179 Documentation writers should please make sure documents build successfully
180 before committing to CVS.
182 How do you update the webserver (i.e. the pages on privoxy.org)?
184 1. First, build the docs by running make dok (or alternately make redhat-dok).
186 2. Run make webserver which copies all files from doc/webserver to the
187 sourceforge webserver via scp.
189 -------------------------------------------------------------------------------
195 This set of standards is designed to make our lives easier. It is developed
196 with the simple goal of helping us keep the "new and improved Privoxy"
197 consistent and reliable. Thus making maintenance easier and increasing chances
198 of success of the project.
200 And that of course comes back to us as individuals. If we can increase our
201 development and product efficiencies then we can solve more of the request for
202 changes/improvements and in general feel good about ourselves. ;->
204 -------------------------------------------------------------------------------
208 4.2.1. Comment, Comment, Comment
212 Comment as much as possible without commenting the obvious. For example do not
213 comment "aVariable is equal to bVariable". Instead explain why aVariable should
214 be equal to the bVariable. Just because a person can read code does not mean
215 they will understand why or what is being done. A reader may spend a lot more
216 time figuring out what is going on when a simple comment or explanation would
217 have prevented the extra research. Please help your brother IJB'ers out!
219 The comments will also help justify the intent of the code. If the comment
220 describes something different than what the code is doing then maybe a
221 programming error is occurring.
225 /* if page size greater than 1k ... */
226 if ( PageLength() > 1024 )
228 ... "block" the page up ...
231 /* if page size is small, send it in blocks */
232 if ( PageLength() > 1024 )
234 ... "block" the page up ...
237 This demonstrates 2 cases of "what not to do". The first is a
238 "syntax comment". The second is a comment that does not fit what
239 is actually being done.
241 -------------------------------------------------------------------------------
243 4.2.2. Use blocks for comments
247 Comments can help or they can clutter. They help when they are differentiated
248 from the code they describe. One line comments do not offer effective
249 separation between the comment and the code. Block identifiers do, by
250 surrounding the code with a clear, definable pattern.
254 /*********************************************************************
255 * This will stand out clearly in your code!
256 *********************************************************************/
257 if ( thisVariable == thatVariable )
259 DoSomethingVeryImportant();
263 /* unfortunately, this may not */
264 if ( thisVariable == thatVariable )
266 DoSomethingVeryImportant();
270 if ( thisVariable == thatVariable ) /* this may not either */
272 DoSomethingVeryImportant();
277 If you are trying to add a small logic comment and do not wish to "disrubt" the
278 flow of the code, feel free to use a 1 line comment which is NOT on the same
281 -------------------------------------------------------------------------------
283 4.2.3. Keep Comments on their own line
287 It goes back to the question of readability. If the comment is on the same line
288 as the code it will be harder to read than the comment that is on its own line.
290 There are three exceptions to this rule, which should be violated freely and
291 often: during the definition of variables, at the end of closing braces, when
292 used to comment parameters.
296 /*********************************************************************
297 * This will stand out clearly in your code,
298 * But the second example won't.
299 *********************************************************************/
300 if ( thisVariable == thatVariable )
302 DoSomethingVeryImportant();
305 if ( thisVariable == thatVariable ) /*can you see me?*/
307 DoSomethingVeryImportant(); /*not easily*/
311 /*********************************************************************
312 * But, the encouraged exceptions:
313 *********************************************************************/
314 int urls_read = 0; /* # of urls read + rejected */
315 int urls_rejected = 0; /* # of urls rejected */
319 DoSomethingVeryImportant();
323 short DoSomethingVeryImportant(
324 short firstparam, /* represents something */
325 short nextparam /* represents something else */ )
329 } /* -END- DoSomethingVeryImportant */
331 -------------------------------------------------------------------------------
333 4.2.4. Comment each logical step
337 Logical steps should be commented to help others follow the intent of the
338 written code and comments will make the code more readable.
340 If you have 25 lines of code without a comment, you should probably go back
341 into it to see where you forgot to put one.
343 Most "for", "while", "do", etc... loops _probably_ need a comment. After all,
344 these are usually major logic containers.
346 -------------------------------------------------------------------------------
348 4.2.5. Comment All Functions Thoroughly
352 A reader of the code should be able to look at the comments just prior to the
353 beginning of a function and discern the reason for its existence and the
354 consequences of using it. The reader should not have to read through the code
355 to determine if a given function is safe for a desired use. The proper
356 information thoroughly presented at the introduction of a function not only
357 saves time for subsequent maintenance or debugging, it more importantly aids in
358 code reuse by allowing a user to determine the safety and applicability of any
359 function for the problem at hand. As a result of such benefits, all functions
360 should contain the information presented in the addendum section of this
363 -------------------------------------------------------------------------------
365 4.2.6. Comment at the end of braces if the content is more than one screen
370 Each closing brace should be followed on the same line by a comment that
371 describes the origination of the brace if the original brace is off of the
372 screen, or otherwise far away from the closing brace. This will simplify the
373 debugging, maintenance, and readability of the code.
375 As a suggestion , use the following flags to make the comment and its brace
378 use following a closing brace: } /* -END- if() or while () or etc... */
384 DoSomethingVeryImportant();
385 ...some long list of commands...
386 } /* -END- if x is 1 */
392 DoSomethingVeryImportant();
393 ...some long list of commands...
394 } /* -END- if ( 1 == X ) */
396 -------------------------------------------------------------------------------
398 4.3. Naming Conventions
400 4.3.1. Variable Names
404 Use all lowercase, and seperate words via an underscore ('_'). Do not start an
405 identifier with an underscore. (ANSI C reserves these for use by the compiler
406 and system headers.) Do not use identifiers which are reserved in ANSI C++.
407 (E.g. template, class, true, false, ...). This is in case we ever decide to
412 int ms_iis5_hack = 0;
416 int msiis5hack = 0; int msIis5Hack = 0;
418 -------------------------------------------------------------------------------
420 4.3.2. Function Names
424 Use all lowercase, and seperate words via an underscore ('_'). Do not start an
425 identifier with an underscore. (ANSI C reserves these for use by the compiler
426 and system headers.) Do not use identifiers which are reserved in ANSI C++.
427 (E.g. template, class, true, false, ...). This is in case we ever decide to
432 int load_some_file( struct client_state *csp )
436 int loadsomefile( struct client_state *csp )
437 int loadSomeFile( struct client_state *csp )
439 -------------------------------------------------------------------------------
441 4.3.3. Header file prototypes
445 Use a descriptive parameter name in the function prototype in header files. Use
446 the same parameter name in the header file that you use in the c file.
450 (.h) extern int load_aclfile( struct client_state *csp );
451 (.c) int load_aclfile( struct client_state *csp )
455 (.h) extern int load_aclfile( struct client_state * ); or
456 (.h) extern int load_aclfile();
457 (.c) int load_aclfile( struct client_state *csp )
459 -------------------------------------------------------------------------------
461 4.3.4. Enumerations, and #defines
465 Use all capital letters, with underscores between words. Do not start an
466 identifier with an underscore. (ANSI C reserves these for use by the compiler
471 (enumeration) : enum Boolean { FALSE, TRUE };
472 (#define) : #define DEFAULT_SIZE 100;
474 Note: We have a standard naming scheme for #defines that toggle a feature in
475 the preprocessor: FEATURE_>, where > is a short (preferably 1 or 2 word)
480 #define FEATURE_FORCE 1
483 #define FORCE_PREFIX blah
484 #endif /* def FEATURE_FORCE */
486 -------------------------------------------------------------------------------
492 Spell common words out entirely (do not remove vowels).
494 Use only widely-known domain acronyms and abbreviations. Capitalize all letters
497 Use underscore (_) to separate adjacent acronyms and abbreviations. Never
498 terminate a name with an underscore.
502 #define USE_IMAGE_LIST 1
506 #define USE_IMG_LST 1 or
507 #define _USE_IMAGE_LIST 1 or
508 #define USE_IMAGE_LIST_ 1 or
509 #define use_image_list 1 or
510 #define UseImageList 1
512 -------------------------------------------------------------------------------
516 4.4.1. Put braces on a line by themselves.
520 The brace needs to be on a line all by itself, not at the end of the statement.
521 Curly braces should line up with the construct that they're associated with.
522 This practice makes it easier to identify the opening and closing braces for a
534 if ( this == that ) { ... }
538 if ( this == that ) { ... }
540 Note: In the special case that the if-statement is inside a loop, and it is
541 trivial, i.e. it tests for a condidtion that is obvious from the purpose of the
542 block, one-liners as above may optically preserve the loop structure and make
545 Status: developer-discrection.
549 while ( more lines are read )
551 /* Please document what is/is not a comment line here */
552 if ( it's a comment ) continue;
554 do_something( line );
557 -------------------------------------------------------------------------------
559 4.4.2. ALL control statements should have a block
563 Using braces to make a block will make your code more readable and less prone
564 to error. All control statements should have a block defined.
576 if ( this == that ) DoSomething(); DoSomethingElse();
580 if ( this == that ) DoSomething();
582 Note: The first example in "Instead of" will execute in a manner other than
583 that which the developer desired (per indentation). Using code braces would
584 have prevented this "feature". The "explanation" and "exception" from the point
587 -------------------------------------------------------------------------------
589 4.4.3. Do not belabor/blow-up boolean expressions
593 structure->flag = ( condition );
597 if ( condition ) { structure->flag = 1; } else { structure->flag = 0; }
599 Note: The former is readable and consice. The later is wordy and inefficient.
600 Please assume that any developer new to the project has at least a "good"
601 knowledge of C/C++. (Hope I do not offend by that last comment ... 8-)
603 -------------------------------------------------------------------------------
605 4.4.4. Use white space freely because it is free
609 Make it readable. The notable exception to using white space freely is listed
610 in the next guideline.
616 int anotherValue = 0;
617 int thisVariable = 0;
619 if ( thisVariable == thatVariable )
621 firstValue = oldValue + ( ( someValue - anotherValue ) - whatever )
623 -------------------------------------------------------------------------------
625 4.4.5. Don't use white space around structure operators
629 - structure pointer operator ( "->" ) - member operator ( "." ) - functions and
632 It is a general coding practice to put pointers, references, and function
633 parentheses next to names. With spaces, the connection between the object and
634 variable/function name is not as clear.
642 Instead of: aStruct -> aMember; aStruct . aMember; FunctionName ();
644 -------------------------------------------------------------------------------
646 4.4.6. Make the last brace of a function stand out
655 } /* -END- function1 */
660 } /* -END- function2 */
664 int function1( ... ) { ...code... return( retCode ); } int function2( ... ) { }
666 Note: Use 1 blank line before the closing brace and 2 lines afterwards. This
667 makes the end of function standout to the most casual viewer. Although function
668 comments help seperate functions, this is still a good coding practice. In
669 fact, I follow these rules when using blocks in "for", "while", "do" loops, and
670 long if {} statements too. After all whitespace is free!
672 Status: developer-discrection on the number of blank lines. Enforced is the end
673 of function comments.
675 -------------------------------------------------------------------------------
677 4.4.7. Use 3 character indentions
681 If some use 8 character TABs and some use 3 character TABs, the code can look *
682 very* ragged. So use 3 character indentions only. If you like to use TABs, pass
683 your code through a filter such as "expand -t3" before checking in your code.
687 static const char * const url_code_map[256] =
697 return( ALWAYS_TRUE );
701 return( HOW_DID_YOU_GET_HERE );
704 return( NEVER_GETS_HERE );
708 -------------------------------------------------------------------------------
712 4.5.1. Initialize all variables
716 Do not assume that the variables declared will not be used until after they
717 have been assigned a value somewhere else in the code. Remove the chance of
718 accidentally using an unassigned variable.
726 Note: It is much easier to debug a SIGSEGV if the message says you are trying
727 to access memory address 00000000 and not 129FA012; or arrayPtr[20] causes a
728 SIGSEV vs. arrayPtr[0].
730 Status: developer-discrection if and only if the variable is assigned a value
731 "shortly after" declaration.
733 -------------------------------------------------------------------------------
737 4.6.1. Name functions that return a boolean as a question.
741 Value should be phrased as a question that would logically be answered as a
742 true or false statement
750 -------------------------------------------------------------------------------
752 4.6.2. Always specify a return type for a function.
756 The default return for a function is an int. To avoid ambiguity, create a
757 return for a function when the return has a purpose, and create a void return
758 type if the function does not need to return anything.
760 -------------------------------------------------------------------------------
762 4.6.3. Minimize function calls when iterating by using variables
766 It is easy to write the following code, and a clear argument can be made that
767 the code is easy to understand:
771 for ( size_t cnt = 0; cnt < blockListLength(); cnt ++ )
776 Note: Unfortunately, this makes a function call for each and every iteration.
777 This increases the overhead in the program, because the compiler has to look up
778 the function each time, call it, and return a value. Depending on what occurs
779 in the blockListLength() call, it might even be creating and destroying
780 structures with each iteration, even though in each case it is comparing "cnt"
781 to the same value, over and over. Remember too - even a call to blockListLength
782 () is a function call, with the same overhead.
784 Instead of using a function call during the iterations, assign the value to a
785 variable, and evaluate using the variable.
789 size_t len = blockListLength();
791 for ( size_t cnt = 0; cnt < len; cnt ++ )
796 Exceptions: if the value of blockListLength() *may* change or could *
797 potentially* change, then you must code the function call in the for/while
800 -------------------------------------------------------------------------------
802 4.6.4. Pass and Return by Const Reference
806 This allows a developer to define a const pointer and call your function. If
807 your function does not have the const keyword, we may not be able to use your
808 function. Consider strcmp, if it were defined as: extern int strcmp( char *s1,
811 I could then not use it to compare argv's in main: int main( int argc, const
812 char *argv[] ) { strcmp( argv[0], "privoxy" ); }
814 Both these pointers are *const*! If the c runtime library maintainers do it, we
817 -------------------------------------------------------------------------------
819 4.6.5. Pass and Return by Value
823 Most structures cannot fit onto a normal stack entry (i.e. they are not 4 bytes
824 or less). Aka, a function declaration like: int load_aclfile( struct
827 would not work. So, to be consistent, we should declare all prototypes with
828 "pass by value": int load_aclfile( struct client_state *csp )
830 -------------------------------------------------------------------------------
832 4.6.6. Names of include files
836 Your include statements should contain the file name without a path. The path
837 should be listed in the Makefile, using -I as processor directive to search the
838 indicated paths. An exception to this would be for some proprietary software
839 that utilizes a partial path to distinguish their header files from system or
844 #include <iostream.h> /* This is not a local include */
845 #include "config.h" /* This IS a local include */
849 /* This is not a local include, but requires a path element. */
850 #include <sys/fileName.h>
852 Note: Please! do not add "-I." to the Makefile without a _very_ good reason.
853 This duplicates the #include "file.h" behaviour.
855 -------------------------------------------------------------------------------
857 4.6.7. Provide multiple inclusion protection
861 Prevents compiler and linker errors resulting from redefinition of items.
863 Wrap each header file with the following syntax to prevent multiple inclusions
864 of the file. Of course, replace PROJECT_H with your file name, with "." Changed
865 to "_", and make it uppercase.
869 #ifndef PROJECT_H_INCLUDED
870 #define PROJECT_H_INCLUDED
872 #endif /* ndef PROJECT_H_INCLUDED */
874 -------------------------------------------------------------------------------
876 4.6.8. Use `extern "C"` when appropriate
880 If our headers are included from C++, they must declare our functions as
881 `extern "C"`. This has no cost in C, but increases the potential re-usability
889 #endif /* def __cplusplus */
891 ... function definitions here ...
895 #endif /* def __cplusplus */
897 -------------------------------------------------------------------------------
899 4.6.9. Where Possible, Use Forward Struct Declaration Instead of Includes
903 Useful in headers that include pointers to other struct's. Modifications to
904 excess header files may cause needless compiles.
908 /*********************************************************************
909 * We're avoiding an include statement here!
910 *********************************************************************/
912 extern file_list *xyz;
914 Note: If you declare "file_list xyz;" (without the pointer), then including the
915 proper header file is necessary. If you only want to prototype a pointer,
916 however, the header file is unneccessary.
918 Status: Use with discrection.
920 -------------------------------------------------------------------------------
922 4.7. General Coding Practices
924 4.7.1. Turn on warnings
928 Compiler warnings are meant to help you find bugs. You should turn on as many
929 as possible. With GCC, the switch is "-Wall". Try and fix as many warnings as
932 -------------------------------------------------------------------------------
934 4.7.2. Provide a default case for all switch statements
938 What you think is guaranteed is never really guaranteed. The value that you
939 don't think you need to check is the one that someday will be passed. So, to
940 protect yourself from the unknown, always have a default step in a switch
945 switch( hash_string( cmd ) )
947 case hash_actions_file :
957 ... anomly code goes here ...
958 continue; / break; / exit( 1 ); / etc ...
960 } /* end switch( hash_string( cmd ) ) */
962 Note: If you already have a default condition, you are obviously exempt from
963 this point. Of note, most of the WIN32 code calls `DefWindowProc' after the
964 switch statement. This API call *should* be included in a default statement.
966 Another Note: This is not so much a readability issue as a robust programming
967 issue. The "anomly code goes here" may be no more than a print to the STDERR
968 stream (as in load_config). Or it may really be an ABEND condition.
970 Status: Programmer discretion is advised.
972 -------------------------------------------------------------------------------
974 4.7.3. Try to avoid falling through cases in a switch statement.
978 In general, you will want to have a 'break' statement within each 'case' of a
979 switch statement. This allows for the code to be more readable and
980 understandable, and furthermore can prevent unwanted surprises if someone else
981 later gets creative and moves the code around.
983 The language allows you to plan the fall through from one case statement to
984 another simply by omitting the break statement within the case statement. This
985 feature does have benefits, but should only be used in rare cases. In general,
986 use a break statement for each case statement.
988 If you choose to allow fall through, you should comment both the fact of the
989 fall through and reason why you felt it was necessary.
991 -------------------------------------------------------------------------------
993 4.7.4. Use 'long' or 'short' Instead of 'int'
997 On 32-bit platforms, int usually has the range of long. On 16-bit platforms,
998 int has the range of short.
1000 Status: open-to-debate. In the case of most FSF projects (including X/
1001 GNU-Emacs), there are typedefs to int4, int8, int16, (or equivalence ... I
1002 forget the exact typedefs now). Should we add these to IJB now that we have a
1005 -------------------------------------------------------------------------------
1007 4.7.5. Don't mix size_t and other types
1011 The type of size_t varies across platforms. Do not make assumptions about
1012 whether it is signed or unsigned, or about how long it is. Do not compare a
1013 size_t against another variable of a different type (or even against a
1014 constant) without casting one of the values. Try to avoid using size_t if you
1017 -------------------------------------------------------------------------------
1019 4.7.6. Declare each variable and struct on its own line.
1023 It can be tempting to declare a series of variables all on one line. Don't.
1035 Explanation: - there is more room for comments on the individual variables -
1036 easier to add new variables without messing up the original ones - when
1037 searching on a variable to find its type, there is less clutter to "visually"
1040 Exceptions: when you want to declare a bunch of loop variables or other trivial
1041 variables; feel free to declare them on 1 line. You should, although, provide a
1042 good comment on their functions.
1044 Status: developer-discrection.
1046 -------------------------------------------------------------------------------
1048 4.7.7. Use malloc/zalloc sparingly
1052 Create a local stuct (on the stack) if the variable will live and die within
1053 the context of one function call.
1055 Only "malloc" a struct (on the heap) if the variable's life will extend beyond
1056 the context of one function call.
1060 If a function creates a struct and stores a pointer to it in a
1061 list, then it should definately be allocated via `malloc'.
1063 -------------------------------------------------------------------------------
1065 4.7.8. The Programmer Who Uses 'malloc' is Responsible for Ensuring 'free'
1069 If you have to "malloc" an instance, you are responsible for insuring that the
1070 instance is `free'd, even if the deallocation event falls within some other
1071 programmer's code. You are also responsible for ensuring that deletion is
1072 timely (i.e. not too soon, not too late). This is known as "low-coupling" and
1073 is a "good thing (tm)". You may need to offer a free/unload/destuctor type
1074 function to accomodate this.
1078 int load_re_filterfile( struct client_state *csp ) { ... }
1079 static void unload_re_filterfile( void *f ) { ... }
1083 The developer cannot be expected to provide `free'ing functions for C run-time
1084 library functions ... such as `strdup'.
1086 Status: developer-discrection. The "main" use of this standard is for
1087 allocating and freeing data structures (complex or nested).
1089 -------------------------------------------------------------------------------
1091 4.7.9. Add loaders to the `file_list' structure and in order
1095 I have ordered all of the "blocker" file code to be in alpha order. It is
1096 easier to add/read new blockers when you expect a certain order.
1098 Note: It may appear that the alpha order is broken in places by POPUP tests
1099 coming before PCRS tests. But since POPUPs can also be referred to as
1100 KILLPOPUPs, it is clear that it should come first.
1102 -------------------------------------------------------------------------------
1104 4.7.10. "Uncertain" new code and/or changes to exitinst code, use FIXME
1108 If you have enough confidence in new code or confidence in your changes, but
1109 are not *quite* sure of the reprocussions, add this:
1111 /* FIXME: this code has a logic error on platform XYZ, * attempthing to fix */
1112 #ifdef PLATFORM ...changed code here... #endif
1116 /* FIXME: I think the original author really meant this... */ ...changed code
1121 /* FIXME: new code that *may* break something else... */ ...new code here...
1123 Note: If you make it clear that this may or may not be a "good thing (tm)", it
1124 will be easier to identify and include in the project (or conversly exclude
1127 -------------------------------------------------------------------------------
1129 4.8. Addendum: Template for files and function comment blocks:
1131 Example for file comments:
1133 const char FILENAME_rcs[] = "$Id: developer-manual.sgml,v 1.18 2002/04/03 03:51:48 hal9 Exp $";
1134 /*********************************************************************
1138 * Purpose : (Fill me in with a good description!)
1140 * Copyright : Written by and Copyright (C) 2001 the SourceForge
1141 * Privoxy team. http://www.privoxy.org/
1143 * Based on the Internet Junkbuster originally written
1144 * by and Copyright (C) 1997 Anonymous Coders and
1145 * Junkbusters Corporation. http://www.junkbusters.com
1147 * This program is free software; you can redistribute it
1148 * and/or modify it under the terms of the GNU General
1149 * Public License as published by the Free Software
1150 * Foundation; either version 2 of the License, or (at
1151 * your option) any later version.
1153 * This program is distributed in the hope that it will
1154 * be useful, but WITHOUT ANY WARRANTY; without even the
1155 * implied warranty of MERCHANTABILITY or FITNESS FOR A
1156 * PARTICULAR PURPOSE. See the GNU General Public
1157 * License for more details.
1159 * The GNU General Public License should be included with
1160 * this file. If not, you can view it at
1161 * http://www.gnu.org/copyleft/gpl.html
1162 * or write to the Free Software Foundation, Inc., 59
1163 * Temple Place - Suite 330, Boston, MA 02111-1307, USA.
1168 *********************************************************************/
1173 ...necessary include files for us to do our work...
1175 const char FILENAME_h_rcs[] = FILENAME_H_VERSION;
1177 Note: This declares the rcs variables that should be added to the
1178 "show-proxy-args" page. If this is a brand new creation by you, you are free to
1179 change the "Copyright" section to represent the rights you wish to maintain.
1181 Note: The formfeed character that is present right after the comment flower box
1182 is handy for (X|GNU)Emacs users to skip the verbige and get to the heart of the
1183 code (via `forward-page' and `backward-page'). Please include it if you can.
1185 Example for file header comments:
1189 #define FILENAME_H_VERSION "$Id: developer-manual.sgml,v 1.18 2002/04/03 03:51:48 hal9 Exp $"
1190 /*********************************************************************
1194 * Purpose : (Fill me in with a good description!)
1196 * Copyright : Written by and Copyright (C) 2001 the SourceForge
1197 * Privoxy team. http://www.privoxy.org/
1199 * Based on the Internet Junkbuster originally written
1200 * by and Copyright (C) 1997 Anonymous Coders and
1201 * Junkbusters Corporation. http://www.junkbusters.com
1203 * This program is free software; you can redistribute it
1204 * and/or modify it under the terms of the GNU General
1205 * Public License as published by the Free Software
1206 * Foundation; either version 2 of the License, or (at
1207 * your option) any later version.
1209 * This program is distributed in the hope that it will
1210 * be useful, but WITHOUT ANY WARRANTY; without even the
1211 * implied warranty of MERCHANTABILITY or FITNESS FOR A
1212 * PARTICULAR PURPOSE. See the GNU General Public
1213 * License for more details.
1215 * The GNU General Public License should be included with
1216 * this file. If not, you can view it at
1217 * http://www.gnu.org/copyleft/gpl.html
1218 * or write to the Free Software Foundation, Inc., 59
1219 * Temple Place - Suite 330, Boston, MA 02111-1307, USA.
1224 *********************************************************************/
1227 #include "project.h"
1233 ... function headers here ...
1236 /* Revision control strings from this header and associated .c file */
1237 extern const char FILENAME_rcs[];
1238 extern const char FILENAME_h_rcs[];
1245 #endif /* ndef _FILENAME_H */
1253 Example for function comments:
1255 /*********************************************************************
1257 * Function : FUNCTION_NAME
1259 * Description : (Fill me in with a good description!)
1262 * 1 : param1 = pointer to an important thing
1263 * 2 : x = pointer to something else
1265 * Returns : 0 => Ok, everything else is an error.
1267 *********************************************************************/
1268 int FUNCTION_NAME( void *param1, const char *x )
1275 Note: If we all follow this practice, we should be able to parse our code to
1276 create a "self-documenting" web page.
1278 -------------------------------------------------------------------------------
1280 5. Version Control Guidelines
1282 To be filled. note on cvs comments. Don't only comment what you did, but also
1285 -------------------------------------------------------------------------------
1287 6. Testing Guidelines
1291 -------------------------------------------------------------------------------
1293 6.1. Testplan for releases
1295 Explain release numbers. major, minor. developer releases. etc.
1297 1. Remove any existing rpm with rpm -e
1299 2. Remove any file that was left over. This includes (but is not limited to)
1307 + /etc/init.d/privoxy
1311 3. Install the rpm. Any error messages?
1313 4. start,stop,status Privoxy with the specific script (e.g. /etc/rc.d/init/
1314 privoxy stop). Reboot your machine. Does autostart work?
1316 5. Start browsing. Does Privoxy work? Logfile written?
1318 6. Remove the rpm. Any error messages? All files removed?
1320 -------------------------------------------------------------------------------
1324 Please submit test reports only with the test form at sourceforge. Three simple
1327 * Select category: the distribution you test on.
1329 * Select group: the version of Privoxy that we are about to release.
1331 * Fill the Summary and Detailed Description with something intelligent (keep
1332 it short and precise).
1334 Do not mail to the mailinglist (we cannot keep track on issues there).
1336 -------------------------------------------------------------------------------
1338 7. Releasing a new version
1340 To minimize trouble with distribution contents, webpage errors and the like, we
1341 strongly encourage you to follow this section if you prepare a new release of
1342 code or new pages on the webserver.
1344 The following programs are required to follow this process: ncftpput (ncftp),
1345 scp (ssh), gmake (GNU's version of make), autoconf, cvs, ???.
1347 -------------------------------------------------------------------------------
1349 7.1. Before the Release
1351 The following must be done by one of the developers prior to each new release:
1353 * Make sure that everybody who has worked on the code in the last couple of
1354 days has had a chance to yell "no!" in case they have pending changes/fixes
1357 * Increment the version number in configure.in in CVS. Also, the RPM release
1358 number in configure.in. Do NOT touch version information after export from
1359 CVS. All packages will use the version and release data from configure.in.
1360 Local files should not be changed, except prior to a CVS commit!!! This way
1361 we are all on the same page!
1363 * If the default actionsfile has changed since last release, bump up its
1364 version info in this line:
1366 {+add-header{X-Actions-File-Version: A.B} -filter -no-popups}
1369 Then change the version info in doc/webserver/actions/index.php, line:
1370 '$required_actions_file_version = "A.B";'
1372 * Tag all files in CVS with the version number with "cvs tag v_X_Y_Z" (where
1373 X = major, Y = minor, Z = point). Don't use vX_Y_Z, ver_X_Y_Z, v_X.Y.Z
1376 * The first package uploaded should be the official "tarball" release. This
1377 is built with the "make tarball-dist" Makefile target, and then can be
1378 uploaded with "make tarball-upload" (see below).
1380 -------------------------------------------------------------------------------
1382 7.2. Update the webserver
1384 All files must be group-readable and group-writable (or no one else will be
1385 able to change them). To update the webserver, create any pages locally in the
1386 doc/webserver directory (or create new directories under doc/webserver), then
1392 Note that "make dok" (or "make redhat-dok") creates doc/webserver/user-manual,
1393 doc/webserver/developer-manual, doc/webserver/faq and doc/webserver/man-page
1396 Please do NOT use any other means of transferring files to the webserver. "make
1397 webserver" not only uploads, but will make sure that the appropriate
1398 permissions are preserved for shared group access.
1400 -------------------------------------------------------------------------------
1402 7.3. SuSE or Red Hat
1404 Ensure that you have the latest code version. Hence run:
1407 cvs -d:pserver:anonymous@cvs.ijbswa.sourceforge.net:/cvsroot/ijbswa login
1408 cvs -z3 -d:pserver:anonymous@cvs.ijbswa.sourceforge.net:/cvsroot/ijbswa export -r v_X_Y_Z current
1413 autoheader && autoconf && ./configure
1418 make suse-dist or make redhat-dist
1421 To upload the package to Sourceforge, simply issue
1423 make suse-upload or make redhat-upload
1426 Go to the displayed URL and release the file publicly on Sourceforge.
1428 -------------------------------------------------------------------------------
1432 Ensure that you have the latest code version. Hence run:
1435 cvs -d:pserver:anonymous@cvs.ijbswa.sourceforge.net:/cvsroot/ijbswa login
1436 cvs -z3 -d:pserver:anonymous@cvs.ijbswa.sourceforge.net:/cvsroot/ijbswa export -r v_X_Y_Z current
1441 autoheader && autoconf && ./configure
1446 -------------------------------------------------------------------------------
1450 Login to Sourceforge's compilefarm via ssh
1452 ssh cf.sourceforge.net
1455 Choose the right operating system (not the Debian one). If you have downloaded
1459 cvs -d:pserver:anonymous@cvs.ijbswa.sourceforge.net:/cvsroot/ijbswa login
1460 cvs -z3 -d:pserver:anonymous@cvs.ijbswa.sourceforge.net:/cvsroot/ijbswa export -r v_X_Y_Z current
1463 If not, please checkout Privoxy via CVS first. Run:
1465 autoheader && autoconf && ./configure
1473 which creates a gzip'ed tar archive. Sadly, you cannot use make solaris-upload
1474 on the Sourceforge machine (no ncftpput). You now have to manually upload the
1475 archive to Sourceforge's ftp server and release the file publicly.
1477 -------------------------------------------------------------------------------
1481 Ensure that you have the latest code version. Hence run
1484 cvs -d:pserver:anonymous@cvs.ijbswa.sourceforge.net:/cvsroot/ijbswa login
1485 cvs -z3 -d:pserver:anonymous@cvs.ijbswa.sourceforge.net:/cvsroot/ijbswa export -r v_X_Y_Z current
1490 autoheader && autoconf && ./configure
1495 -------------------------------------------------------------------------------
1499 Ensure that you have the latest code version. Hence run:
1502 cvs -d:pserver:anonymous@cvs.ijbswa.sourceforge.net:/cvsroot/ijbswa login
1503 cvs -z3 -d:pserver:anonymous@cvs.ijbswa.sourceforge.net:/cvsroot/ijbswa export -r v_X_Y_Z current
1508 autoheader && autoconf && ./configure
1513 -------------------------------------------------------------------------------
1517 Login to Sourceforge's compilefarm via ssh
1519 ssh cf.sourceforge.net
1522 Choose the right operating system. If you have downloaded Privoxy before,
1525 cvs -d:pserver:anonymous@cvs.ijbswa.sourceforge.net:/cvsroot/ijbswa login
1526 cvs -z3 -d:pserver:anonymous@cvs.ijbswa.sourceforge.net:/cvsroot/ijbswa export -r v_X_Y_Z current
1529 If not, please checkout Privoxy via CVS first. Run:
1531 autoheader && autoconf && ./configure
1539 which creates a gzip'ed tar archive. Sadly, you cannot use make macosx-upload
1540 on the Sourceforge machine (no ncftpput). You now have to manually upload the
1541 archive to Sourceforge's ftp server and release the file publicly.
1543 -------------------------------------------------------------------------------
1547 Change the version number of Privoxy in the configure.in file. Run:
1549 autoheader && autoconf && ./configure
1554 Login to Sourceforge's compilefarm via ssh:
1556 ssh cf.sourceforge.net
1559 Choose the right operating system. If you have downloaded Privoxy before,
1562 cvs -d:pserver:anonymous@cvs.ijbswa.sourceforge.net:/cvsroot/ijbswa login
1563 cvs -z3 -d:pserver:anonymous@cvs.ijbswa.sourceforge.net:/cvsroot/ijbswa export -r v_X_Y_Z current
1566 If not, please checkout Privoxy via CVS first. Run:
1568 autoheader && autoconf && ./configure
1576 which creates a gzip'ed tar archive. Sadly, you cannot use make freebsd-upload
1577 on the Sourceforge machine (no ncftpput). You now have to manually upload the
1578 archive to Sourceforge's ftp server and release the file publicly.
1580 -------------------------------------------------------------------------------
1584 Ensure that you have the latest code version. Hence run:
1587 cvs -d:pserver:anonymous@cvs.ijbswa.sourceforge.net:/cvsroot/ijbswa login
1588 cvs -z3 -d:pserver:anonymous@cvs.ijbswa.sourceforge.net:/cvsroot/ijbswa export -r v_X_Y_Z current
1594 autoheader && autoconf && ./configure
1602 To upload the package to Sourceforge, simply issue
1607 Goto the displayed URL and release the file publicly on Sourceforge.
1609 -------------------------------------------------------------------------------
1613 Ensure that you have the latest code version. Hence run:
1616 cvs -d:pserver:anonymous@cvs.ijbswa.sourceforge.net:/cvsroot/ijbswa login
1617 cvs -z3 -d:pserver:anonymous@cvs.ijbswa.sourceforge.net:/cvsroot/ijbswa export -r v_X_Y_Z current
1622 autoheader && autoconf && ./configure
1627 -------------------------------------------------------------------------------
1631 Ensure that you have the latest code version. Hence run:
1634 cvs -d:pserver:anonymous@cvs.ijbswa.sourceforge.net:/cvsroot/ijbswa login
1635 cvs -z3 -d:pserver:anonymous@cvs.ijbswa.sourceforge.net:/cvsroot/ijbswa export -r v_X_Y_Z current
1640 autoheader && autoconf && ./configure
1645 -------------------------------------------------------------------------------
1649 Login to Sourceforge's compilefarm via ssh:
1651 ssh cf.sourceforge.net
1654 Choose the right operating system. If you have downloaded Privoxy before:
1657 cvs -d:pserver:anonymous@cvs.ijbswa.sourceforge.net:/cvsroot/ijbswa login
1658 cvs -z3 -d:pserver:anonymous@cvs.ijbswa.sourceforge.net:/cvsroot/ijbswa export -r v_X_Y_Z current
1661 If not, please checkout Privoxy via CVS first. Run:
1663 autoheader && autoconf && ./configure
1671 which creates a gzip'ed tar archive. Sadly, you cannot use make aix-upload on
1672 the Sourceforge machine (no ncftpput). You now have to manually upload the
1673 archive to Sourceforge's ftp server and release the file publicly.
1675 -------------------------------------------------------------------------------
1677 8. Contact the developers
1679 Please see the contact page in the user-manual for details.
1681 -------------------------------------------------------------------------------
1683 9. Copyright and History
1685 Please see the user-manual for information on Copyright and History.
1687 -------------------------------------------------------------------------------
1691 Please see the user-manual for others references.