Sync.
[privoxy.git] / doc / text / developer-manual.txt
1 Privoxy Developer Manual
2
3 By: Privoxy Developers
4
5 $Id: developer-manual.sgml,v 1.31 2002/04/11 09:32:52 oes Exp $
6
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.
9
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
15 networks.
16
17 Privoxy is based on the code of the Internet Junkbuster (tm). 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.
21
22 Privoxy continues the Junkbuster tradition, but adds many refinements,
23 enhancements and new features.
24
25 You can find the latest version of the this manual at http://www.privoxy.org/
26 developer-manual/. Please see the Contact section on how to contact the
27 developers.
28
29 -------------------------------------------------------------------------------
30
31 Table of Contents
32  
33 1. Introduction
34 3. Quickstart to Privoxy Development
35 4. Documentation Guidelines
36    
37     4.1. Quickstart to Docbook and SGML
38     4.2. Privoxy Documentation Style
39     4.3. Privoxy Custom Entities
40    
41 5. Coding Guidelines
42    
43     5.1. Introduction
44     5.2. Using Comments
45        
46         5.2.1. Comment, Comment, Comment
47         5.2.2. Use blocks for comments
48         5.2.3. Keep Comments on their own line
49         5.2.4. Comment each logical step
50         5.2.5. Comment All Functions Thoroughly
51         5.2.6. Comment at the end of braces if the content is more than one
52             screen length
53        
54     5.3. Naming Conventions
55        
56         5.3.1. Variable Names
57         5.3.2. Function Names
58         5.3.3. Header file prototypes
59         5.3.4. Enumerations, and #defines
60         5.3.5. Constants
61        
62     5.4. Using Space
63        
64         5.4.1. Put braces on a line by themselves.
65         5.4.2. ALL control statements should have a block
66         5.4.3. Do not belabor/blow-up boolean expressions
67         5.4.4. Use white space freely because it is free
68         5.4.5. Don't use white space around structure operators
69         5.4.6. Make the last brace of a function stand out
70         5.4.7. Use 3 character indentions
71        
72     5.5. Initializing
73        
74         5.5.1. Initialize all variables
75        
76     5.6. Functions
77        
78         5.6.1. Name functions that return a boolean as a question.
79         5.6.2. Always specify a return type for a function.
80         5.6.3. Minimize function calls when iterating by using variables
81         5.6.4. Pass and Return by Const Reference
82         5.6.5. Pass and Return by Value
83         5.6.6. Names of include files
84         5.6.7. Provide multiple inclusion protection
85         5.6.8. Use `extern "C"` when appropriate
86         5.6.9. Where Possible, Use Forward Struct Declaration Instead of
87             Includes
88        
89     5.7. General Coding Practices
90        
91         5.7.1. Turn on warnings
92         5.7.2. Provide a default case for all switch statements
93         5.7.3. Try to avoid falling through cases in a switch statement.
94         5.7.4. Use 'long' or 'short' Instead of 'int'
95         5.7.5. Don't mix size_t and other types
96         5.7.6. Declare each variable and struct on its own line.
97         5.7.7. Use malloc/zalloc sparingly
98         5.7.8. The Programmer Who Uses 'malloc' is Responsible for Ensuring
99             'free'
100         5.7.9. Add loaders to the `file_list' structure and in order
101         5.7.10. "Uncertain" new code and/or changes to existing code, use FIXME
102        
103     5.8. Addendum: Template for files and function comment blocks:
104    
105 6. Version Control Guidelines
106 7. Testing Guidelines
107    
108     7.1. Testplan for releases
109     7.2. Test reports
110    
111 8. Releasing a new version
112    
113     8.1. Before the Release
114     8.2. Update the webserver
115     8.3. SuSE or Red Hat
116     8.4. OS/2
117     8.5. Solaris
118     8.6. Windows
119     8.7. Debian
120     8.8. Mac OSX
121     8.9. FreeBSD
122     8.10. Tarball
123     8.11. HP-UX 11
124     8.12. Amiga OS
125     8.13. AIX
126    
127 9. Contacting the developers, Bug Reporting and Feature Requests
128 10. Copyright and History
129    
130     10.1. Copyright
131     10.2. History
132    
133 11. See also
134
135 -------------------------------------------------------------------------------
136
137 1. Introduction
138
139 Privoxy, as an heir to Junkbuster, is an Open Source project and licensed under
140 the GPL. As such, Privoxy development is potentially open to anyone who has the
141 time, knowledge, and desire to contribute in any capacity. Our goals are simply
142 to continue the mission, to improve Privoxy, and to make it available to as
143 wide an audience as possible.
144
145 One does not have to be a programmer to contribute. Packaging, testing, and
146 porting, are all important jobs as well.
147
148 -------------------------------------------------------------------------------
149
150 3. Quickstart to Privoxy Development
151
152 You'll need an account on Sourceforge to support our development. Mail your ID
153 to the list and wait until a project manager has added you.
154
155 For the time being (read, this section is under construction), please note the
156 following guidelines for changing stuff in the code. If it is
157
158  1. A bug-fix / clean-up / cosmetic thing: shoot
159    
160  2. A new feature that can be turned off: shoot
161    
162  3. A clear improvement w/o side effects on other parts of the code: shoot
163    
164  4. A matter of taste: ask the list
165    
166  5. A major redesign of some part of the code: ask the list
167    
168 -------------------------------------------------------------------------------
169
170 4. Documentation Guidelines
171
172 All formal documents are maintained in Docbook SGML and located in the doc/
173 source/* directory. You will need Docbook, the Docbook DTD's and the Docbook
174 modular stylesheets (or comparable alternatives), and either jade or openjade
175 (recommended) installed in order to build docs from source. Currently there is 
176 user-manual, FAQ, and, of course this, the developer-manual in this format. The
177 README, AUTHORS privoxy.1 (man page) files are also now maintained as Docbook
178 SGML. The finished files are all in the top-level source directory are
179 generated files! Also, index.html, the Privoxy home page, is maintained as
180 SGML. DO NOT edit these directly. Edit the SGML source, or contact someone
181 involved in the documentation (at present Stefan and Hal).
182
183 Other, less formal documents (e.g. LICENSE, INSTALL) are maintained as plain
184 text files in the top-level source directory. At least for the time being.
185
186 Packagers are encouraged to include this documentation. For those without the
187 ability to build the docs locally, text versions of each are kept in CVS. HTML
188 versions are also now being kept in CVS under doc/webserver/*.
189
190 Formal documents are built with the Makefile targets of make dok, or
191 alternately make redhat-dok. If you have problems, try both. The build process
192 uses the document SGML sources in doc/source/*/* to update all text files in
193 doc/text/ and to update all HTML documents in doc/webserver/.
194
195 Documentation writers should please make sure documents build successfully
196 before committing to CVS.
197
198 How do you update the webserver (i.e. the pages on privoxy.org)?
199
200  1. First, build the docs by running make dok (or alternately make redhat-dok).
201    
202  2. Run make webserver which copies all files from doc/webserver to the
203     sourceforge webserver via scp.
204    
205 Finished docs should be occasionally submitted to CVS (doc/webserver/*/*.html)
206 so that those without the ability to build them locally, have access to them if
207 needed. This is especially important just prior to a new release! Please do
208 this after the $VERSION and other release specific data in configure.in has
209 been updated (this is done just prior to a new release).
210
211 -------------------------------------------------------------------------------
212
213 4.1. Quickstart to Docbook and SGML
214
215 If you are not familiar with SGML, it is a markup language similar to HTML.
216 Actually, not a mark up language per se, but a language used to define markup
217 languages. In fact, HTML is an SGML application. Both will use "tags" to format
218 text and other content. SGML tags can be much more varied, and flexible, but do
219 much of the same kinds of things. The tags, or "elements", are definable in
220 SGML. There is no set "standards". Since we are using Docbook, our tags are
221 those that are defined by Docbook. Much of how the finish document is rendered
222 is determined by the "stylesheets". The stylesheets determine how each tag gets
223 translated to HTML, or other formats.
224
225 Tags in Docbook SGML need to be always "closed". If not, you will likely
226 generate errors. Example: <title>My Title</title>. They are also
227 case-insensitive, but we strongly suggest using all lower case. This keeps
228 compatibility with [Docbook] XML.
229
230 Our documents use "sections" for the most part. Sections will be processed into
231 HTML headers (e.g. h1 for sect1). The Docbook stylesheets will use these to
232 also generate the Table of Contents for each doc. Our TOC's are set to a depth
233 of three. Meaning sect1, sect2, and sect3 will have TOC entries, but sect4 will
234 not. Each section requires a <title> element, and at least one <para>. There is
235 a limit of five section levels in Docbook, but generally three should be
236 sufficient for our purposes.
237
238 Some common elements that you likely will use:
239
240 <para></para>, paragraph delimiter. Most text needs to be within paragraph     
241 elements (there are some exceptions).                                          
242 <emphasis></emphasis>, the stylesheets make this italics.                      
243 <filename></filename>, files and directories.                                  
244 <command></command>, command examples.                                         
245 <literallayout></literallayout>, like <pre>, more or less.                     
246 <itemizedlist></itemizedlist>, list with bullets.                              
247 <listitem></listitem>, member of the above.                                    
248 <screen></screen>, screen output, implies <literallayout>.                     
249 <ulink url="example.com"></ulink>, like HTML <a> tag.                          
250 <quote></quote>, for, doh, quoting text.                                       
251
252 Look at any of the existing docs for examples of all these and more.
253
254 -------------------------------------------------------------------------------
255
256 4.2. Privoxy Documentation Style
257
258 It will be easier if everyone follows a similar writing style. This just makes
259 it easier to read what someone else has written if it is all done in a similar
260 fashion.
261
262 Here it is:
263
264   * All tags should be lower case.
265    
266   * Tags delimiting a block of text (even small blocks) should be on their own
267     line. Like:
268    
269      <para>
270       Some text goes here.
271      </para>
272            
273    
274     Tags marking individual words, or few words, should be in-line:
275    
276       Just to <emphasis>emphasize</emphasis>, some text goes here.
277            
278    
279   * Tags should be nested and step indented for block text like: (except
280     in-line tags)
281    
282      <para>
283       <itemizedlist>
284        <para>
285         <listitem>
286           Some text goes here in our list example.
287          </listitem>
288        </para>
289       </itemizedlist>
290      </para>
291            
292    
293     This makes it easier to find the text amongst the tags ;-)
294    
295   * Use white space to separate logical divisions within a document, like
296     between sections. Running everything together consistently makes it harder
297     to read and work on.
298    
299   * Do not hesitate to make comments. Comments can either use the <comment>
300     element, or the <!-- --> style comment familiar from HTML. (Note in Docbook
301     v4.x <comment> is replaced by <remark>.)
302    
303   * We have an international audience. Refrain from slang, or English
304     idiosyncrasies (too many to list :). Humor also does not translate well
305     sometimes.
306    
307   * Try to keep overall line lengths in source files to 80 characters or less
308     for obvious reasons. This is not always possible, with lengthy URLs for
309     instance.
310    
311   * Our documents are available in differing formats. Right now, they are just
312     plain text, and HTML, but PDF, and others is always a future possibility.
313     Be careful with URLs (<ulink>), and avoid this mistake:
314    
315     My favorite site is <ulink url="http://example.com">here</ulink>.
316    
317     This will render as "My favorite site is here", which is not real helpful
318     in a text doc. Better like this:
319    
320     My favorite site is <ulink url="http://example.com">example.com</ulink>.
321    
322   * All documents should be spell checked occasionally. aspell can check SGML
323     with the -H option. (ispell I think too.)
324    
325 -------------------------------------------------------------------------------
326
327 4.3. Privoxy Custom Entities
328
329 Privoxy documentation is using a number of customized "entities" to facilitate
330 documentation maintenance.
331
332 We are using a set of "boilerplate" files with generic text, that is used by
333 multiple docs. This way we can write something once, and use it repeatedly
334 without having to re-write the same content over and over again. If editing
335 such a file, keep in mind that it should be generic. That is the purpose; so it
336 can be used in varying contexts without additional modifications.
337
338 We are also using what Docbook calls "internal entities". These are like
339 variables in programming. Well, sort of. For instance, we have the p-version
340 entity that contains the current Privoxy version string. You are strongly
341 encouraged to use these where possible. Some of these obviously require
342 re-setting with each release (done by the Makefile). A sampling of custom
343 entities are listed below. See any of the main docs for examples.
344
345   * Re- "boilerplate" text entities are defined like:
346    
347     <!entity supported SYSTEM "supported.sgml">
348    
349     In this example, the contents of the file, supported.sgml is available for
350     inclusion anywhere in the doc. To make this happen, just reference the now
351     defined entity: &supported; (starts with an ampersand and ends with a
352     semi-colon), and the contents will be dumped into the finished doc at that
353     point.
354    
355   * Commonly used "internal entities":
356    
357     p-version: the Privoxy version string, e.g. "2.9.14".                      
358     p-status: the project status, either "alpha", "beta", or "stable".         
359     p-not-stable: use to conditionally include text in "not stable" releases   
360     (e.g. "beta").                                                             
361     p-stable: just the opposite.                                               
362     p-text: this doc is only generated as text.                                
363    
364 There are others in various places that are defined for a specific purpose.
365 Read the source!
366
367 -------------------------------------------------------------------------------
368
369 5. Coding Guidelines
370
371 5.1. Introduction
372
373 This set of standards is designed to make our lives easier. It is developed
374 with the simple goal of helping us keep the "new and improved Privoxy"
375 consistent and reliable. Thus making maintenance easier and increasing chances
376 of success of the project.
377
378 And that of course comes back to us as individuals. If we can increase our
379 development and product efficiencies then we can solve more of the request for
380 changes/improvements and in general feel good about ourselves. ;->
381
382 -------------------------------------------------------------------------------
383
384 5.2. Using Comments
385
386 5.2.1. Comment, Comment, Comment
387
388 Explanation:
389
390 Comment as much as possible without commenting the obvious. For example do not
391 comment "aVariable is equal to bVariable". Instead explain why aVariable should
392 be equal to the bVariable. Just because a person can read code does not mean
393 they will understand why or what is being done. A reader may spend a lot more
394 time figuring out what is going on when a simple comment or explanation would
395 have prevented the extra research. Please help your brother IJB'ers out!
396
397 The comments will also help justify the intent of the code. If the comment
398 describes something different than what the code is doing then maybe a
399 programming error is occurring.
400
401 Example:
402
403 /* if page size greater than 1k ... */                                         
404 if ( PageLength() > 1024 )                                                     
405 {                                                                              
406     ... "block" the page up ...                                                
407 }                                                                              
408                                                                                
409 /* if page size is small, send it in blocks */                                 
410 if ( PageLength() > 1024 )                                                     
411 {                                                                              
412     ... "block" the page up ...                                                
413 }                                                                              
414                                                                                
415 This demonstrates 2 cases of "what not to do".  The first is a                 
416 "syntax comment".  The second is a comment that does not fit what              
417 is actually being done.                                                        
418
419 -------------------------------------------------------------------------------
420
421 5.2.2. Use blocks for comments
422
423 Explanation:
424
425 Comments can help or they can clutter. They help when they are differentiated
426 from the code they describe. One line comments do not offer effective
427 separation between the comment and the code. Block identifiers do, by
428 surrounding the code with a clear, definable pattern.
429
430 Example:
431
432 /*********************************************************************         
433  * This will stand out clearly in your code!                                   
434  *********************************************************************/        
435 if ( thisVariable == thatVariable )                                            
436 {                                                                              
437    DoSomethingVeryImportant();                                                 
438 }                                                                              
439                                                                                
440                                                                                
441 /* unfortunately, this may not */                                              
442 if ( thisVariable == thatVariable )                                            
443 {                                                                              
444    DoSomethingVeryImportant();                                                 
445 }                                                                              
446                                                                                
447                                                                                
448 if ( thisVariable == thatVariable ) /* this may not either */                  
449 {                                                                              
450    DoSomethingVeryImportant();                                                 
451 }                                                                              
452
453 Exception:
454
455 If you are trying to add a small logic comment and do not wish to "disrupt" the
456 flow of the code, feel free to use a 1 line comment which is NOT on the same
457 line as the code.
458
459 -------------------------------------------------------------------------------
460
461 5.2.3. Keep Comments on their own line
462
463 Explanation:
464
465 It goes back to the question of readability. If the comment is on the same line
466 as the code it will be harder to read than the comment that is on its own line.
467
468 There are three exceptions to this rule, which should be violated freely and
469 often: during the definition of variables, at the end of closing braces, when
470 used to comment parameters.
471
472 Example:
473
474 /*********************************************************************         
475  * This will stand out clearly in your code,                                   
476  * But the second example won't.                                               
477  *********************************************************************/        
478 if ( thisVariable == thatVariable )                                            
479 {                                                                              
480    DoSomethingVeryImportant();                                                 
481 }                                                                              
482                                                                                
483 if ( thisVariable == thatVariable ) /*can you see me?*/                        
484 {                                                                              
485    DoSomethingVeryImportant(); /*not easily*/                                  
486 }                                                                              
487                                                                                
488                                                                                
489 /*********************************************************************         
490  * But, the encouraged exceptions:                                             
491  *********************************************************************/        
492 int urls_read     = 0;     /* # of urls read + rejected */                     
493 int urls_rejected = 0;     /* # of urls rejected */                            
494                                                                                
495 if ( 1 == X )                                                                  
496 {                                                                              
497    DoSomethingVeryImportant();                                                 
498 }                                                                              
499                                                                                
500                                                                                
501 short DoSomethingVeryImportant(                                                
502    short firstparam,   /* represents something */                              
503    short nextparam     /* represents something else */ )                       
504 {                                                                              
505    ...code here...                                                             
506                                                                                
507 }   /* -END- DoSomethingVeryImportant */                                       
508
509 -------------------------------------------------------------------------------
510
511 5.2.4. Comment each logical step
512
513 Explanation:
514
515 Logical steps should be commented to help others follow the intent of the
516 written code and comments will make the code more readable.
517
518 If you have 25 lines of code without a comment, you should probably go back
519 into it to see where you forgot to put one.
520
521 Most "for", "while", "do", etc... loops _probably_ need a comment. After all,
522 these are usually major logic containers.
523
524 -------------------------------------------------------------------------------
525
526 5.2.5. Comment All Functions Thoroughly
527
528 Explanation:
529
530 A reader of the code should be able to look at the comments just prior to the
531 beginning of a function and discern the reason for its existence and the
532 consequences of using it. The reader should not have to read through the code
533 to determine if a given function is safe for a desired use. The proper
534 information thoroughly presented at the introduction of a function not only
535 saves time for subsequent maintenance or debugging, it more importantly aids in
536 code reuse by allowing a user to determine the safety and applicability of any
537 function for the problem at hand. As a result of such benefits, all functions
538 should contain the information presented in the addendum section of this
539 document.
540
541 -------------------------------------------------------------------------------
542
543 5.2.6. Comment at the end of braces if the content is more than one screen
544 length
545
546 Explanation:
547
548 Each closing brace should be followed on the same line by a comment that
549 describes the origination of the brace if the original brace is off of the
550 screen, or otherwise far away from the closing brace. This will simplify the
551 debugging, maintenance, and readability of the code.
552
553 As a suggestion , use the following flags to make the comment and its brace
554 more readable:
555
556 use following a closing brace: } /* -END- if() or while () or etc... */
557
558 Example:
559
560 if ( 1 == X )                                                                  
561 {                                                                              
562    DoSomethingVeryImportant();                                                 
563    ...some long list of commands...                                            
564 } /* -END- if x is 1 */                                                        
565                                                                                
566 or:                                                                            
567                                                                                
568 if ( 1 == X )                                                                  
569 {                                                                              
570    DoSomethingVeryImportant();                                                 
571    ...some long list of commands...                                            
572 } /* -END- if ( 1 == X ) */                                                    
573
574 -------------------------------------------------------------------------------
575
576 5.3. Naming Conventions
577
578 5.3.1. Variable Names
579
580 Explanation:
581
582 Use all lowercase, and separate words via an underscore ('_'). Do not start an
583 identifier with an underscore. (ANSI C reserves these for use by the compiler
584 and system headers.) Do not use identifiers which are reserved in ANSI C++.
585 (E.g. template, class, true, false, ...). This is in case we ever decide to
586 port Privoxy to C++.
587
588 Example:
589
590 int ms_iis5_hack = 0;                                                          
591
592 Instead of:
593
594 int msiis5hack = 0; int msIis5Hack = 0;                                        
595
596 -------------------------------------------------------------------------------
597
598 5.3.2. Function Names
599
600 Explanation:
601
602 Use all lowercase, and separate words via an underscore ('_'). Do not start an
603 identifier with an underscore. (ANSI C reserves these for use by the compiler
604 and system headers.) Do not use identifiers which are reserved in ANSI C++.
605 (E.g. template, class, true, false, ...). This is in case we ever decide to
606 port Privoxy to C++.
607
608 Example:
609
610 int load_some_file( struct client_state *csp )                                 
611
612 Instead of:
613
614 int loadsomefile( struct client_state *csp )                                   
615 int loadSomeFile( struct client_state *csp )                                   
616
617 -------------------------------------------------------------------------------
618
619 5.3.3. Header file prototypes
620
621 Explanation:
622
623 Use a descriptive parameter name in the function prototype in header files. Use
624 the same parameter name in the header file that you use in the c file.
625
626 Example:
627
628 (.h) extern int load_aclfile( struct client_state *csp );                      
629 (.c) int load_aclfile( struct client_state *csp )                              
630
631 Instead of:
632
633 (.h) extern int load_aclfile( struct client_state * ); or                      
634 (.h) extern int load_aclfile();                                                
635 (.c) int load_aclfile( struct client_state *csp )                              
636
637 -------------------------------------------------------------------------------
638
639 5.3.4. Enumerations, and #defines
640
641 Explanation:
642
643 Use all capital letters, with underscores between words. Do not start an
644 identifier with an underscore. (ANSI C reserves these for use by the compiler
645 and system headers.)
646
647 Example:
648
649 (enumeration) : enum Boolean { FALSE, TRUE };                                  
650 (#define) : #define DEFAULT_SIZE 100;                                          
651
652 Note: We have a standard naming scheme for #defines that toggle a feature in
653 the preprocessor: FEATURE_>, where > is a short (preferably 1 or 2 word)
654 description.
655
656 Example:
657
658 #define FEATURE_FORCE 1                                                        
659                                                                                
660 #ifdef FEATURE_FORCE                                                           
661 #define FORCE_PREFIX blah                                                      
662 #endif /* def FEATURE_FORCE */                                                 
663
664 -------------------------------------------------------------------------------
665
666 5.3.5. Constants
667
668 Explanation:
669
670 Spell common words out entirely (do not remove vowels).
671
672 Use only widely-known domain acronyms and abbreviations. Capitalize all letters
673 of an acronym.
674
675 Use underscore (_) to separate adjacent acronyms and abbreviations. Never
676 terminate a name with an underscore.
677
678 Example:
679
680 #define USE_IMAGE_LIST 1                                                       
681
682 Instead of:
683
684 #define USE_IMG_LST 1 or                                                       
685 #define _USE_IMAGE_LIST 1 or                                                   
686 #define USE_IMAGE_LIST_ 1 or                                                   
687 #define use_image_list 1 or                                                    
688 #define UseImageList 1                                                         
689
690 -------------------------------------------------------------------------------
691
692 5.4. Using Space
693
694 5.4.1. Put braces on a line by themselves.
695
696 Explanation:
697
698 The brace needs to be on a line all by itself, not at the end of the statement.
699 Curly braces should line up with the construct that they're associated with.
700 This practice makes it easier to identify the opening and closing braces for a
701 block.
702
703 Example:
704
705 if ( this == that )                                                            
706 {                                                                              
707    ...                                                                         
708 }                                                                              
709
710 Instead of:
711
712 if ( this == that ) { ... }
713
714 or
715
716 if ( this == that ) { ... }
717
718 Note: In the special case that the if-statement is inside a loop, and it is
719 trivial, i.e. it tests for a condition that is obvious from the purpose of the
720 block, one-liners as above may optically preserve the loop structure and make
721 it easier to read.
722
723 Status: developer-discretion.
724
725 Example exception:
726
727 while ( more lines are read )                                                  
728 {                                                                              
729    /* Please document what is/is not a comment line here */                    
730    if ( it's a comment ) continue;                                             
731                                                                                
732    do_something( line );                                                       
733 }                                                                              
734
735 -------------------------------------------------------------------------------
736
737 5.4.2. ALL control statements should have a block
738
739 Explanation:
740
741 Using braces to make a block will make your code more readable and less prone
742 to error. All control statements should have a block defined.
743
744 Example:
745
746 if ( this == that )                                                            
747 {                                                                              
748    DoSomething();                                                              
749    DoSomethingElse();                                                          
750 }                                                                              
751
752 Instead of:
753
754 if ( this == that ) DoSomething(); DoSomethingElse();
755
756 or
757
758 if ( this == that ) DoSomething();
759
760 Note: The first example in "Instead of" will execute in a manner other than
761 that which the developer desired (per indentation). Using code braces would
762 have prevented this "feature". The "explanation" and "exception" from the point
763 above also applies.
764
765 -------------------------------------------------------------------------------
766
767 5.4.3. Do not belabor/blow-up boolean expressions
768
769 Example:
770
771 structure->flag = ( condition );                                               
772
773 Instead of:
774
775 if ( condition ) { structure->flag = 1; } else { structure->flag = 0; }
776
777 Note: The former is readable and concise. The later is wordy and inefficient.
778 Please assume that any developer new to the project has at least a "good"
779 knowledge of C/C++. (Hope I do not offend by that last comment ... 8-)
780
781 -------------------------------------------------------------------------------
782
783 5.4.4. Use white space freely because it is free
784
785 Explanation:
786
787 Make it readable. The notable exception to using white space freely is listed
788 in the next guideline.
789
790 Example:
791
792 int firstValue   = 0;                                                          
793 int someValue    = 0;                                                          
794 int anotherValue = 0;                                                          
795 int thisVariable = 0;                                                          
796                                                                                
797 if ( thisVariable == thatVariable )                                            
798                                                                                
799 firstValue = oldValue + ( ( someValue - anotherValue ) - whatever )            
800
801 -------------------------------------------------------------------------------
802
803 5.4.5. Don't use white space around structure operators
804
805 Explanation:
806
807 - structure pointer operator ( "->" ) - member operator ( "." ) - functions and
808 parentheses
809
810 It is a general coding practice to put pointers, references, and function
811 parentheses next to names. With spaces, the connection between the object and
812 variable/function name is not as clear.
813
814 Example:
815
816 aStruct->aMember;                                                              
817 aStruct.aMember;                                                               
818 FunctionName();                                                                
819
820 Instead of: aStruct -> aMember; aStruct . aMember; FunctionName ();
821
822 -------------------------------------------------------------------------------
823
824 5.4.6. Make the last brace of a function stand out
825
826 Example:
827
828 int function1( ... )                                                           
829 {                                                                              
830    ...code...                                                                  
831    return( retCode );                                                          
832                                                                                
833 }   /* -END- function1 */                                                      
834                                                                                
835                                                                                
836 int function2( ... )                                                           
837 {                                                                              
838 }   /* -END- function2 */                                                      
839
840 Instead of:
841
842 int function1( ... ) { ...code... return( retCode ); } int function2( ... ) { }
843
844 Note: Use 1 blank line before the closing brace and 2 lines afterward. This
845 makes the end of function standout to the most casual viewer. Although function
846 comments help separate functions, this is still a good coding practice. In
847 fact, I follow these rules when using blocks in "for", "while", "do" loops, and
848 long if {} statements too. After all whitespace is free!
849
850 Status: developer-discretion on the number of blank lines. Enforced is the end
851 of function comments.
852
853 -------------------------------------------------------------------------------
854
855 5.4.7. Use 3 character indentions
856
857 Explanation:
858
859 If some use 8 character TABs and some use 3 character TABs, the code can look *
860 very* ragged. So use 3 character indentions only. If you like to use TABs, pass
861 your code through a filter such as "expand -t3" before checking in your code.
862
863 Example:
864
865 static const char * const url_code_map[256] =                                  
866 {                                                                              
867    NULL, ...                                                                   
868 };                                                                             
869                                                                                
870                                                                                
871 int function1( ... )                                                           
872 {                                                                              
873    if ( 1 )                                                                    
874    {                                                                           
875       return( ALWAYS_TRUE );                                                   
876    }                                                                           
877    else                                                                        
878    {                                                                           
879       return( HOW_DID_YOU_GET_HERE );                                          
880    }                                                                           
881                                                                                
882    return( NEVER_GETS_HERE );                                                  
883                                                                                
884 }                                                                              
885
886 -------------------------------------------------------------------------------
887
888 5.5. Initializing
889
890 5.5.1. Initialize all variables
891
892 Explanation:
893
894 Do not assume that the variables declared will not be used until after they
895 have been assigned a value somewhere else in the code. Remove the chance of
896 accidentally using an unassigned variable.
897
898 Example:
899
900 short anShort = 0;                                                             
901 float aFloat  = 0;                                                             
902 struct *ptr = NULL;                                                            
903
904 Note: It is much easier to debug a SIGSEGV if the message says you are trying
905 to access memory address 00000000 and not 129FA012; or arrayPtr[20] causes a
906 SIGSEV vs. arrayPtr[0].
907
908 Status: developer-discretion if and only if the variable is assigned a value
909 "shortly after" declaration.
910
911 -------------------------------------------------------------------------------
912
913 5.6. Functions
914
915 5.6.1. Name functions that return a boolean as a question.
916
917 Explanation:
918
919 Value should be phrased as a question that would logically be answered as a
920 true or false statement
921
922 Example:
923
924 ShouldWeBlockThis();                                                           
925 ContainsAnImage();                                                             
926 IsWebPageBlank();                                                              
927
928 -------------------------------------------------------------------------------
929
930 5.6.2. Always specify a return type for a function.
931
932 Explanation:
933
934 The default return for a function is an int. To avoid ambiguity, create a
935 return for a function when the return has a purpose, and create a void return
936 type if the function does not need to return anything.
937
938 -------------------------------------------------------------------------------
939
940 5.6.3. Minimize function calls when iterating by using variables
941
942 Explanation:
943
944 It is easy to write the following code, and a clear argument can be made that
945 the code is easy to understand:
946
947 Example:
948
949 for ( size_t cnt = 0; cnt < blockListLength(); cnt ++ )                        
950 {                                                                              
951    ....                                                                        
952 }                                                                              
953
954 Note: Unfortunately, this makes a function call for each and every iteration.
955 This increases the overhead in the program, because the compiler has to look up
956 the function each time, call it, and return a value. Depending on what occurs
957 in the blockListLength() call, it might even be creating and destroying
958 structures with each iteration, even though in each case it is comparing "cnt"
959 to the same value, over and over. Remember too - even a call to blockListLength
960 () is a function call, with the same overhead.
961
962 Instead of using a function call during the iterations, assign the value to a
963 variable, and evaluate using the variable.
964
965 Example:
966
967 size_t len = blockListLength();                                                
968                                                                                
969 for ( size_t cnt = 0; cnt < len; cnt ++ )                                      
970 {                                                                              
971    ....                                                                        
972 }                                                                              
973
974 Exceptions: if the value of blockListLength() *may* change or could *
975 potentially* change, then you must code the function call in the for/while
976 loop.
977
978 -------------------------------------------------------------------------------
979
980 5.6.4. Pass and Return by Const Reference
981
982 Explanation:
983
984 This allows a developer to define a const pointer and call your function. If
985 your function does not have the const keyword, we may not be able to use your
986 function. Consider strcmp, if it were defined as: extern int strcmp( char *s1,
987 char *s2 );
988
989 I could then not use it to compare argv's in main: int main( int argc, const
990 char *argv[] ) { strcmp( argv[0], "privoxy" ); }
991
992 Both these pointers are *const*! If the c runtime library maintainers do it, we
993 should too.
994
995 -------------------------------------------------------------------------------
996
997 5.6.5. Pass and Return by Value
998
999 Explanation:
1000
1001 Most structures cannot fit onto a normal stack entry (i.e. they are not 4 bytes
1002 or less). Aka, a function declaration like: int load_aclfile( struct
1003 client_state csp )
1004
1005 would not work. So, to be consistent, we should declare all prototypes with
1006 "pass by value": int load_aclfile( struct client_state *csp )
1007
1008 -------------------------------------------------------------------------------
1009
1010 5.6.6. Names of include files
1011
1012 Explanation:
1013
1014 Your include statements should contain the file name without a path. The path
1015 should be listed in the Makefile, using -I as processor directive to search the
1016 indicated paths. An exception to this would be for some proprietary software
1017 that utilizes a partial path to distinguish their header files from system or
1018 other header files.
1019
1020 Example:
1021
1022 #include <iostream.h>     /* This is not a local include */                    
1023 #include "config.h"       /* This IS a local include */                        
1024
1025 Exception:
1026
1027 /* This is not a local include, but requires a path element. */                
1028 #include <sys/fileName.h>                                                      
1029
1030 Note: Please! do not add "-I." to the Makefile without a _very_ good reason.
1031 This duplicates the #include "file.h" behavior.
1032
1033 -------------------------------------------------------------------------------
1034
1035 5.6.7. Provide multiple inclusion protection
1036
1037 Explanation:
1038
1039 Prevents compiler and linker errors resulting from redefinition of items.
1040
1041 Wrap each header file with the following syntax to prevent multiple inclusions
1042 of the file. Of course, replace PROJECT_H with your file name, with "." Changed
1043 to "_", and make it uppercase.
1044
1045 Example:
1046
1047 #ifndef PROJECT_H_INCLUDED                                                     
1048 #define PROJECT_H_INCLUDED                                                     
1049  ...                                                                           
1050 #endif /* ndef PROJECT_H_INCLUDED */                                           
1051
1052 -------------------------------------------------------------------------------
1053
1054 5.6.8. Use `extern "C"` when appropriate
1055
1056 Explanation:
1057
1058 If our headers are included from C++, they must declare our functions as
1059 `extern "C"`. This has no cost in C, but increases the potential re-usability
1060 of our code.
1061
1062 Example:
1063
1064 #ifdef __cplusplus                                                             
1065 extern "C"                                                                     
1066 {                                                                              
1067 #endif /* def __cplusplus */                                                   
1068                                                                                
1069 ... function definitions here ...                                              
1070                                                                                
1071 #ifdef __cplusplus                                                             
1072 }                                                                              
1073 #endif /* def __cplusplus */                                                   
1074
1075 -------------------------------------------------------------------------------
1076
1077 5.6.9. Where Possible, Use Forward Struct Declaration Instead of Includes
1078
1079 Explanation:
1080
1081 Useful in headers that include pointers to other struct's. Modifications to
1082 excess header files may cause needless compiles.
1083
1084 Example:
1085
1086 /*********************************************************************         
1087  * We're avoiding an include statement here!                                   
1088  *********************************************************************/        
1089 struct file_list;                                                              
1090 extern file_list *xyz;                                                         
1091
1092 Note: If you declare "file_list xyz;" (without the pointer), then including the
1093 proper header file is necessary. If you only want to prototype a pointer,
1094 however, the header file is unnecessary.
1095
1096 Status: Use with discretion.
1097
1098 -------------------------------------------------------------------------------
1099
1100 5.7. General Coding Practices
1101
1102 5.7.1. Turn on warnings
1103
1104 Explanation
1105
1106 Compiler warnings are meant to help you find bugs. You should turn on as many
1107 as possible. With GCC, the switch is "-Wall". Try and fix as many warnings as
1108 possible.
1109
1110 -------------------------------------------------------------------------------
1111
1112 5.7.2. Provide a default case for all switch statements
1113
1114 Explanation:
1115
1116 What you think is guaranteed is never really guaranteed. The value that you
1117 don't think you need to check is the one that someday will be passed. So, to
1118 protect yourself from the unknown, always have a default step in a switch
1119 statement.
1120
1121 Example:
1122
1123 switch( hash_string( cmd ) )                                                   
1124 {                                                                              
1125    case hash_actions_file :                                                    
1126       ... code ...                                                             
1127       break;                                                                   
1128                                                                                
1129    case hash_confdir :                                                         
1130       ... code ...                                                             
1131       break;                                                                   
1132                                                                                
1133    default :                                                                   
1134       log_error( ... );                                                        
1135       ... anomaly code goes here ...                                           
1136       continue; / break; / exit( 1 ); / etc ...                                
1137                                                                                
1138 } /* end switch( hash_string( cmd ) ) */                                       
1139
1140 Note: If you already have a default condition, you are obviously exempt from
1141 this point. Of note, most of the WIN32 code calls `DefWindowProc' after the
1142 switch statement. This API call *should* be included in a default statement.
1143
1144 Another Note: This is not so much a readability issue as a robust programming
1145 issue. The "anomaly code goes here" may be no more than a print to the STDERR
1146 stream (as in load_config). Or it may really be an ABEND condition.
1147
1148 Status: Programmer discretion is advised.
1149
1150 -------------------------------------------------------------------------------
1151
1152 5.7.3. Try to avoid falling through cases in a switch statement.
1153
1154 Explanation:
1155
1156 In general, you will want to have a 'break' statement within each 'case' of a
1157 switch statement. This allows for the code to be more readable and
1158 understandable, and furthermore can prevent unwanted surprises if someone else
1159 later gets creative and moves the code around.
1160
1161 The language allows you to plan the fall through from one case statement to
1162 another simply by omitting the break statement within the case statement. This
1163 feature does have benefits, but should only be used in rare cases. In general,
1164 use a break statement for each case statement.
1165
1166 If you choose to allow fall through, you should comment both the fact of the
1167 fall through and reason why you felt it was necessary.
1168
1169 -------------------------------------------------------------------------------
1170
1171 5.7.4. Use 'long' or 'short' Instead of 'int'
1172
1173 Explanation:
1174
1175 On 32-bit platforms, int usually has the range of long. On 16-bit platforms,
1176 int has the range of short.
1177
1178 Status: open-to-debate. In the case of most FSF projects (including X/
1179 GNU-Emacs), there are typedefs to int4, int8, int16, (or equivalence ... I
1180 forget the exact typedefs now). Should we add these to IJB now that we have a
1181 "configure" script?
1182
1183 -------------------------------------------------------------------------------
1184
1185 5.7.5. Don't mix size_t and other types
1186
1187 Explanation:
1188
1189 The type of size_t varies across platforms. Do not make assumptions about
1190 whether it is signed or unsigned, or about how long it is. Do not compare a
1191 size_t against another variable of a different type (or even against a
1192 constant) without casting one of the values. Try to avoid using size_t if you
1193 can.
1194
1195 -------------------------------------------------------------------------------
1196
1197 5.7.6. Declare each variable and struct on its own line.
1198
1199 Explanation:
1200
1201 It can be tempting to declare a series of variables all on one line. Don't.
1202
1203 Example:
1204
1205 long a = 0;                                                                    
1206 long b = 0;                                                                    
1207 long c = 0;                                                                    
1208
1209 Instead of:
1210
1211 long a, b, c;
1212
1213 Explanation: - there is more room for comments on the individual variables -
1214 easier to add new variables without messing up the original ones - when
1215 searching on a variable to find its type, there is less clutter to "visually"
1216 eliminate
1217
1218 Exceptions: when you want to declare a bunch of loop variables or other trivial
1219 variables; feel free to declare them on 1 line. You should, although, provide a
1220 good comment on their functions.
1221
1222 Status: developer-discretion.
1223
1224 -------------------------------------------------------------------------------
1225
1226 5.7.7. Use malloc/zalloc sparingly
1227
1228 Explanation:
1229
1230 Create a local struct (on the stack) if the variable will live and die within
1231 the context of one function call.
1232
1233 Only "malloc" a struct (on the heap) if the variable's life will extend beyond
1234 the context of one function call.
1235
1236 Example:
1237
1238 If a function creates a struct and stores a pointer to it in a                 
1239 list, then it should definitely be allocated via `malloc'.                     
1240
1241 -------------------------------------------------------------------------------
1242
1243 5.7.8. The Programmer Who Uses 'malloc' is Responsible for Ensuring 'free'
1244
1245 Explanation:
1246
1247 If you have to "malloc" an instance, you are responsible for insuring that the
1248 instance is `free'd, even if the deallocation event falls within some other
1249 programmer's code. You are also responsible for ensuring that deletion is
1250 timely (i.e. not too soon, not too late). This is known as "low-coupling" and
1251 is a "good thing (tm)". You may need to offer a free/unload/destuctor type
1252 function to accommodate this.
1253
1254 Example:
1255
1256 int load_re_filterfile( struct client_state *csp ) { ... }                     
1257 static void unload_re_filterfile( void *f ) { ... }                            
1258
1259 Exceptions:
1260
1261 The developer cannot be expected to provide `free'ing functions for C run-time
1262 library functions ... such as `strdup'.
1263
1264 Status: developer-discretion. The "main" use of this standard is for allocating
1265 and freeing data structures (complex or nested).
1266
1267 -------------------------------------------------------------------------------
1268
1269 5.7.9. Add loaders to the `file_list' structure and in order
1270
1271 Explanation:
1272
1273 I have ordered all of the "blocker" file code to be in alpha order. It is
1274 easier to add/read new blockers when you expect a certain order.
1275
1276 Note: It may appear that the alpha order is broken in places by POPUP tests
1277 coming before PCRS tests. But since POPUPs can also be referred to as
1278 KILLPOPUPs, it is clear that it should come first.
1279
1280 -------------------------------------------------------------------------------
1281
1282 5.7.10. "Uncertain" new code and/or changes to existing code, use FIXME
1283
1284 Explanation:
1285
1286 If you have enough confidence in new code or confidence in your changes, but
1287 are not *quite* sure of the repercussions, add this:
1288
1289 /* FIXME: this code has a logic error on platform XYZ, * attempting to fix */ #
1290 ifdef PLATFORM ...changed code here... #endif
1291
1292 or:
1293
1294 /* FIXME: I think the original author really meant this... */ ...changed code
1295 here...
1296
1297 or:
1298
1299 /* FIXME: new code that *may* break something else... */ ...new code here...
1300
1301 Note: If you make it clear that this may or may not be a "good thing (tm)", it
1302 will be easier to identify and include in the project (or conversely exclude
1303 from the project).
1304
1305 -------------------------------------------------------------------------------
1306
1307 5.8. Addendum: Template for files and function comment blocks:
1308
1309 Example for file comments:
1310
1311 const char FILENAME_rcs[] = "$Id: developer-manual.sgml,v 1.31 2002/04/11 09:32:52 oes Exp $"; 
1312 /*********************************************************************                         
1313  *                                                                                             
1314  * File        :  $Source$                                                                     
1315  *                                                                                             
1316  * Purpose     :  (Fill me in with a good description!)                                        
1317  *                                                                                             
1318  * Copyright   :  Written by and Copyright (C) 2001 the SourceForge                            
1319  *                Privoxy team. http://www.privoxy.org/                                        
1320  *                                                                                             
1321  *                Based on the Internet Junkbuster originally written                          
1322  *                by and Copyright (C) 1997 Anonymous Coders and                               
1323  *                Junkbusters Corporation.  http://www.junkbusters.com                         
1324  *                                                                                             
1325  *                This program is free software; you can redistribute it                       
1326  *                and/or modify it under the terms of the GNU General                          
1327  *                Public License as published by the Free Software                             
1328  *                Foundation; either version 2 of the License, or (at                          
1329  *                your option) any later version.                                              
1330  *                                                                                             
1331  *                This program is distributed in the hope that it will                         
1332  *                be useful, but WITHOUT ANY WARRANTY; without even the                        
1333  *                implied warranty of MERCHANTABILITY or FITNESS FOR A                         
1334  *                PARTICULAR PURPOSE.  See the GNU General Public                              
1335  *                License for more details.                                                    
1336  *                                                                                             
1337  *                The GNU General Public License should be included with                       
1338  *                this file.  If not, you can view it at                                       
1339  *                http://www.gnu.org/copyleft/gpl.html                                         
1340  *                or write to the Free Software Foundation, Inc., 59                           
1341  *                Temple Place - Suite 330, Boston, MA  02111-1307, USA.                       
1342  *                                                                                             
1343  * Revisions   :                                                                               
1344  *    $Log$                                                                                    
1345  *                                                                                             
1346  *********************************************************************/                        
1347                                                                                                
1348                                                                                                
1349 #include "config.h"                                                                            
1350                                                                                                
1351    ...necessary include files for us to do our work...                                         
1352                                                                                                
1353 const char FILENAME_h_rcs[] = FILENAME_H_VERSION;                                              
1354
1355 Note: This declares the rcs variables that should be added to the
1356 "show-proxy-args" page. If this is a brand new creation by you, you are free to
1357 change the "Copyright" section to represent the rights you wish to maintain.
1358
1359 Note: The formfeed character that is present right after the comment flower box
1360 is handy for (X|GNU)Emacs users to skip the verbiage and get to the heart of
1361 the code (via `forward-page' and `backward-page'). Please include it if you
1362 can.
1363
1364 Example for file header comments:
1365
1366 #ifndef _FILENAME_H                                                                          
1367 #define _FILENAME_H                                                                          
1368 #define FILENAME_H_VERSION "$Id: developer-manual.sgml,v 1.31 2002/04/11 09:32:52 oes Exp $" 
1369 /*********************************************************************                       
1370  *                                                                                           
1371  * File        :  $Source$                                                                   
1372  *                                                                                           
1373  * Purpose     :  (Fill me in with a good description!)                                      
1374  *                                                                                           
1375  * Copyright   :  Written by and Copyright (C) 2001 the SourceForge                          
1376  *                Privoxy team. http://www.privoxy.org/                                      
1377  *                                                                                           
1378  *                Based on the Internet Junkbuster originally written                        
1379  *                by and Copyright (C) 1997 Anonymous Coders and                             
1380  *                Junkbusters Corporation.  http://www.junkbusters.com                       
1381  *                                                                                           
1382  *                This program is free software; you can redistribute it                     
1383  *                and/or modify it under the terms of the GNU General                        
1384  *                Public License as published by the Free Software                           
1385  *                Foundation; either version 2 of the License, or (at                        
1386  *                your option) any later version.                                            
1387  *                                                                                           
1388  *                This program is distributed in the hope that it will                       
1389  *                be useful, but WITHOUT ANY WARRANTY; without even the                      
1390  *                implied warranty of MERCHANTABILITY or FITNESS FOR A                       
1391  *                PARTICULAR PURPOSE.  See the GNU General Public                            
1392  *                License for more details.                                                  
1393  *                                                                                           
1394  *                The GNU General Public License should be included with                     
1395  *                this file.  If not, you can view it at                                     
1396  *                http://www.gnu.org/copyleft/gpl.html                                       
1397  *                or write to the Free Software Foundation, Inc., 59                         
1398  *                Temple Place - Suite 330, Boston, MA  02111-1307, USA.                     
1399  *                                                                                           
1400  * Revisions   :                                                                             
1401  *    $Log$                                                                                  
1402  *                                                                                           
1403  *********************************************************************/                      
1404                                                                                              
1405                                                                                              
1406 #include "project.h"                                                                         
1407                                                                                              
1408 #ifdef __cplusplus                                                                           
1409 extern "C" {                                                                                 
1410 #endif                                                                                       
1411                                                                                              
1412    ... function headers here ...                                                             
1413                                                                                              
1414                                                                                              
1415 /* Revision control strings from this header and associated .c file */                       
1416 extern const char FILENAME_rcs[];                                                            
1417 extern const char FILENAME_h_rcs[];                                                          
1418                                                                                              
1419                                                                                              
1420 #ifdef __cplusplus                                                                           
1421 } /* extern "C" */                                                                           
1422 #endif                                                                                       
1423                                                                                              
1424 #endif /* ndef _FILENAME_H */                                                                
1425                                                                                              
1426 /*                                                                                           
1427   Local Variables:                                                                           
1428   tab-width: 3                                                                               
1429   end:                                                                                       
1430 */                                                                                           
1431
1432 Example for function comments:
1433
1434 /*********************************************************************         
1435  *                                                                             
1436  * Function    :  FUNCTION_NAME                                                
1437  *                                                                             
1438  * Description :  (Fill me in with a good description!)                        
1439  *                                                                             
1440  * parameters  :                                                               
1441  *          1  :  param1 = pointer to an important thing                       
1442  *          2  :  x      = pointer to something else                           
1443  *                                                                             
1444  * Returns     :  0 => Ok, everything else is an error.                        
1445  *                                                                             
1446  *********************************************************************/        
1447 int FUNCTION_NAME( void *param1, const char *x )                               
1448 {                                                                              
1449    ...                                                                         
1450    return( 0 );                                                                
1451                                                                                
1452 }                                                                              
1453
1454 Note: If we all follow this practice, we should be able to parse our code to
1455 create a "self-documenting" web page.
1456
1457 -------------------------------------------------------------------------------
1458
1459 6. Version Control Guidelines
1460
1461 To be filled. note on cvs comments. Don't only comment what you did, but also
1462 why you did it!
1463
1464 -------------------------------------------------------------------------------
1465
1466 7. Testing Guidelines
1467
1468 To be filled.
1469
1470 -------------------------------------------------------------------------------
1471
1472 7.1. Testplan for releases
1473
1474 Explain release numbers. major, minor. developer releases. etc.
1475
1476  1. Remove any existing rpm with rpm -e
1477    
1478  2. Remove any file that was left over. This includes (but is not limited to)
1479    
1480       + /var/log/privoxy
1481        
1482       + /etc/privoxy
1483        
1484       + /usr/sbin/privoxy
1485        
1486       + /etc/init.d/privoxy
1487        
1488       + /usr/doc/privoxy*
1489        
1490  3. Install the rpm. Any error messages?
1491    
1492  4. start,stop,status Privoxy with the specific script (e.g. /etc/rc.d/init/
1493     privoxy stop). Reboot your machine. Does autostart work?
1494    
1495  5. Start browsing. Does Privoxy work? Logfile written?
1496    
1497  6. Remove the rpm. Any error messages? All files removed?
1498    
1499 -------------------------------------------------------------------------------
1500
1501 7.2. Test reports
1502
1503 Please submit test reports only with the test form at sourceforge. Three simple
1504 steps:
1505
1506   * Select category: the distribution you test on.
1507    
1508   * Select group: the version of Privoxy that we are about to release.
1509    
1510   * Fill the Summary and Detailed Description with something intelligent (keep
1511     it short and precise).
1512    
1513 Do not mail to the mailinglist (we cannot keep track on issues there).
1514
1515 -------------------------------------------------------------------------------
1516
1517 8. Releasing a new version
1518
1519 To minimize trouble with distribution contents, web-page errors and the like,
1520 we strongly encourage you to follow this section if you prepare a new release
1521 of code or new pages on the webserver.
1522
1523 The following programs are required to follow this process: ncftpput (ncftp),
1524 scp (ssh), gmake (GNU's version of make), autoconf, cvs, ???.
1525
1526 Replace X, Y and Z with the actual version number (X = major, Y = minor, Z =
1527 point):
1528
1529 -------------------------------------------------------------------------------
1530
1531 8.1. Before the Release
1532
1533 The following must be done by one of the developers prior to each new release.
1534
1535   * Make sure that everybody who has worked on the code in the last couple of
1536     days has had a chance to yell "no!" in case they have pending changes/fixes
1537     in their pipelines.
1538    
1539   * Increment the version number in configure.in in CVS. Also, increase or
1540     reset the RPM release number in configure.in as appropriate. Do NOT touch
1541     version information after export from CVS. All packages will use the
1542     version and release data from configure.in. Local files should not be
1543     changed, except prior to a CVS commit!!! This way we are all on the same
1544     page!
1545    
1546   * If the default actionsfile has changed since last release, bump up its
1547     version info in this line:
1548    
1549       {+add-header{X-Actions-File-Version: A.B} -filter -no-popups}    
1550                                                                        
1551    
1552     Then change the version info in doc/webserver/actions/index.php, line:
1553     '$required_actions_file_version = "A.B";'
1554    
1555   * Commit all files that were changed in the above steps!
1556    
1557   * Tag all files in CVS with the version number with "cvs tag v_X_Y_Z". Don't
1558     use vX_Y_Z, ver_X_Y_Z, v_X.Y.Z (won't work) etc.
1559    
1560   * The first package uploaded should be the official "tarball" release, as
1561     required by the GPL. This is built with the "make tarball-dist" Makefile
1562     target, and then can be uploaded with "make tarball-upload" (see below).
1563    
1564 -------------------------------------------------------------------------------
1565
1566 8.2. Update the webserver
1567
1568 All files must be group-readable and group-writable (or no one else will be
1569 able to change them)! To update the webserver, create any pages locally in the
1570 doc/webserver/* directory (or create new directories under doc/webserver), then
1571 do
1572
1573   make webserver                                                               
1574                                                                                
1575
1576 This will do the upload to the webserver (www.privoxy.org).
1577
1578 Note that "make dok" (or "make redhat-dok") creates doc/webserver/user-manual,
1579 doc/webserver/developer-manual, doc/webserver/faq and doc/webserver/index.html
1580 automatically. (doc/webserver/man-page/privoxy-man-page.html is created by a
1581 separate Makefile target, "make man", due to dependencies on some obscure perl
1582 scripts. See comments in GNUmakefile.)
1583
1584 Someone should also commit these to CVS so that packagers without the ability
1585 to build docs locally, have access to them. This is a separate step, and should
1586 also be done before each official release.
1587
1588 Please do NOT use any other means of transferring files to the webserver. "make
1589 webserver" not only uploads, but will make sure that the appropriate
1590 permissions are preserved for shared group access.
1591
1592 -------------------------------------------------------------------------------
1593
1594 8.3. SuSE or Red Hat
1595
1596 Ensure that you have the latest code version. Hence run:
1597
1598   cvs -d:pserver:anonymous@cvs.ijbswa.sourceforge.net:/cvsroot/ijbswa login                           
1599   cvs -z3  -d:pserver:anonymous@cvs.ijbswa.sourceforge.net:/cvsroot/ijbswa export -r  v_X_Y_Z current 
1600   cd current                                                                                          
1601                                                                                                       
1602
1603 first.
1604
1605   autoheader && autoconf && ./configure                                        
1606                                                                                
1607
1608 Then do
1609
1610   make suse-dist or make redhat-dist                                           
1611                                                                                
1612
1613 To upload the package to Sourceforge, simply issue
1614
1615   make suse-upload (or make redhat-upload)                                     
1616                                                                                
1617
1618 Go to the displayed URL and release the file publicly on Sourceforge.
1619
1620 -------------------------------------------------------------------------------
1621
1622 8.4. OS/2
1623
1624 Ensure that you have the latest code version. Hence run:
1625
1626   cvs -d:pserver:anonymous@cvs.ijbswa.sourceforge.net:/cvsroot/ijbswa login                          
1627   cvs -z3 -d:pserver:anonymous@cvs.ijbswa.sourceforge.net:/cvsroot/ijbswa export -r  v_X_Y_Z current 
1628   cd ..                                                                                              
1629   cvs -z3 -d:pserver:anonymous@cvs.ijbswa.sourceforge.net:/cvsroot/ijbswa co os2setup                
1630                                                                                                      
1631
1632 You will need a mix of development tools. The main compilation takes place with
1633 IBM Visual Age C++. Some ancillary work takes place with GNU tools, available
1634 from various sources like hobbes.nmsu.edu. Specificially, you will need
1635 autoheader, autoconf and sh tools. The packaging takes place with WarpIN,
1636 available from various sources, including its home page: xworkplace.
1637
1638 Change directory to the os2setup directory. Edit the os2build.cmd file to set
1639 the final executable filename. For example,
1640
1641   installExeName='privoxyos2_setup_X.Y.Z.exe'                                  
1642                                                                                
1643
1644 Next, edit the IJB.wis file so the release number matches in the PACKAGEID
1645 section:
1646
1647   PACKAGEID="Privoxy Team\Privoxy\Privoxy Package\X\Y\Z"                       
1648                                                                                
1649
1650 You're now ready to build. Run:
1651
1652   os2build                                                                     
1653                                                                                
1654
1655 And in the ./files directory you will have the WarpIN-installable executable.
1656 Upload this anonymously to uploads.sourceforge.net/incoming, create a release
1657 for it, and you're done.
1658
1659 -------------------------------------------------------------------------------
1660
1661 8.5. Solaris
1662
1663 Login to Sourceforge's compilefarm via ssh
1664
1665   ssh cf.sourceforge.net                                                       
1666                                                                                
1667
1668 Choose the right operating system (not the Debian one). If you have downloaded
1669 Privoxy before,
1670
1671   cvs -d:pserver:anonymous@cvs.ijbswa.sourceforge.net:/cvsroot/ijbswa login                           
1672   cvs -z3  -d:pserver:anonymous@cvs.ijbswa.sourceforge.net:/cvsroot/ijbswa export -r  v_X_Y_Z current 
1673   cd current                                                                                          
1674                                                                                                       
1675
1676 If not, please checkout Privoxy via CVS first. Run:
1677
1678   autoheader && autoconf && ./configure                                        
1679                                                                                
1680
1681 Then run
1682
1683   gmake solaris-dist                                                           
1684                                                                                
1685
1686 which creates a gzip'ed tar archive. Sadly, you cannot use make solaris-upload
1687 on the Sourceforge machine (no ncftpput). You now have to manually upload the
1688 archive to Sourceforge's ftp server and release the file publicly.
1689
1690 -------------------------------------------------------------------------------
1691
1692 8.6. Windows
1693
1694 Ensure that you have the latest code version. Hence run
1695
1696   cvs -d:pserver:anonymous@cvs.ijbswa.sourceforge.net:/cvsroot/ijbswa login                           
1697   cvs -z3  -d:pserver:anonymous@cvs.ijbswa.sourceforge.net:/cvsroot/ijbswa export -r  v_X_Y_Z current 
1698   cd current                                                                                          
1699                                                                                                       
1700
1701 Run:
1702
1703   autoheader && autoconf && ./configure                                        
1704                                                                                
1705
1706 Then do FIXME.
1707
1708 -------------------------------------------------------------------------------
1709
1710 8.7. Debian
1711
1712 Ensure that you have the latest code version. Hence run:
1713
1714   cvs -d:pserver:anonymous@cvs.ijbswa.sourceforge.net:/cvsroot/ijbswa login                           
1715   cvs -z3  -d:pserver:anonymous@cvs.ijbswa.sourceforge.net:/cvsroot/ijbswa export -r  v_X_Y_Z current 
1716   cd current                                                                                          
1717                                                                                                       
1718
1719 first. Run:
1720
1721   autoheader && autoconf && ./configure                                        
1722                                                                                
1723
1724 Then do FIXME.
1725
1726 -------------------------------------------------------------------------------
1727
1728 8.8. Mac OSX
1729
1730 Ensure that you have the latest code version. Hence run:
1731
1732   cvs -d:pserver:anonymous@cvs.ijbswa.sourceforge.net:/cvsroot/ijbswa login                          
1733   cvs -z3 -d:pserver:anonymous@cvs.ijbswa.sourceforge.net:/cvsroot/ijbswa export -r  v_X_Y_Z current 
1734   cd ..                                                                                              
1735   cvs -z3 -d:pserver:anonymous@cvs.ijbswa.sourceforge.net:/cvsroot/ijbswa co osxsetup                
1736                                                                                                      
1737
1738 From the osxsetup directory, run:
1739
1740   build                                                                        
1741                                                                                
1742
1743 This will run autoheader, autoconf and configure as well as make. Finally, it
1744 will copy over the necessary files to the ./osxsetup/files directory for
1745 further processing by PackageMaker.
1746
1747 Bring up PackageMaker with the PrivoxyPackage.pmsp definition file, modify the
1748 package name to match the release, and hit the "Create package" button. If you
1749 specify ./Privoxy.pkg as the output package name, you can then create the
1750 distributable zip file with the command:
1751
1752 zip -r privoxyosx_setup_x.y.z.zip Privoxy.pkg                                  
1753                                                                                
1754
1755 You can then upload privoxyosx_setup_x.y.z.zip anonymously to
1756 uploads.sourceforge.net/incoming, create a release for it, and you're done.
1757
1758 -------------------------------------------------------------------------------
1759
1760 8.9. FreeBSD
1761
1762 Change the version number of Privoxy in the configure.in file. Run:
1763
1764   autoheader && autoconf && ./configure                                        
1765                                                                                
1766
1767 Then ...
1768
1769 Login to Sourceforge's compilefarm via ssh:
1770
1771   ssh cf.sourceforge.net                                                       
1772                                                                                
1773
1774 Choose the right operating system.
1775
1776   cvs -d:pserver:anonymous@cvs.ijbswa.sourceforge.net:/cvsroot/ijbswa login                           
1777   cvs -z3  -d:pserver:anonymous@cvs.ijbswa.sourceforge.net:/cvsroot/ijbswa export -r  v_X_Y_Z current 
1778   cd current                                                                                          
1779                                                                                                       
1780
1781 Run:
1782
1783   autoheader && autoconf && ./configure                                        
1784                                                                                
1785
1786 Then run:
1787
1788   gmake freebsd-dist                                                           
1789                                                                                
1790
1791 which creates a gzip'ed tar archive. Sadly, you cannot use make freebsd-upload
1792 on the Sourceforge machine (no ncftpput). You now have to manually upload the
1793 archive to Sourceforge's ftp server and release the file publicly.
1794
1795 -------------------------------------------------------------------------------
1796
1797 8.10. Tarball
1798
1799 Ensure that you have the right code version. Hence run:
1800
1801   cvs -d:pserver:anonymous@cvs.ijbswa.sourceforge.net:/cvsroot/ijbswa login                           
1802   cvs -z3  -d:pserver:anonymous@cvs.ijbswa.sourceforge.net:/cvsroot/ijbswa export -r  v_X_Y_Z current 
1803   cd current                                                                                          
1804                                                                                                       
1805
1806 first. Run:
1807
1808   autoheader && autoconf && ./configure                                        
1809                                                                                
1810
1811 Then do:
1812
1813   make tarball-dist                                                            
1814                                                                                
1815
1816 To upload the package to Sourceforge, simply issue
1817
1818   make tarball-upload                                                          
1819                                                                                
1820
1821 Goto the displayed URL and release the file publicly on Sourceforge.
1822
1823 -------------------------------------------------------------------------------
1824
1825 8.11. HP-UX 11
1826
1827 Ensure that you have the latest code version. Hence run:
1828
1829   cvs -d:pserver:anonymous@cvs.ijbswa.sourceforge.net:/cvsroot/ijbswa login                           
1830   cvs -z3  -d:pserver:anonymous@cvs.ijbswa.sourceforge.net:/cvsroot/ijbswa export -r  v_X_Y_Z current 
1831   cd current                                                                                          
1832                                                                                                       
1833
1834 first. Run:
1835
1836   autoheader && autoconf && ./configure                                        
1837                                                                                
1838
1839 Then do FIXME.
1840
1841 -------------------------------------------------------------------------------
1842
1843 8.12. Amiga OS
1844
1845 Ensure that you have the latest code version. Hence run:
1846
1847   cvs -d:pserver:anonymous@cvs.ijbswa.sourceforge.net:/cvsroot/ijbswa login                           
1848   cvs -z3  -d:pserver:anonymous@cvs.ijbswa.sourceforge.net:/cvsroot/ijbswa export -r  v_X_Y_Z current 
1849   cd current                                                                                          
1850                                                                                                       
1851
1852 first. Run:
1853
1854   autoheader && autoconf && ./configure                                        
1855                                                                                
1856
1857 Then do FIXME.
1858
1859 -------------------------------------------------------------------------------
1860
1861 8.13. AIX
1862
1863 Login to Sourceforge's compilefarm via ssh:
1864
1865   ssh cf.sourceforge.net                                                       
1866                                                                                
1867
1868 Choose the right operating system. If you have downloaded Privoxy before:
1869
1870   cvs -d:pserver:anonymous@cvs.ijbswa.sourceforge.net:/cvsroot/ijbswa login                           
1871   cvs -z3  -d:pserver:anonymous@cvs.ijbswa.sourceforge.net:/cvsroot/ijbswa export -r  v_X_Y_Z current 
1872   cd current                                                                                          
1873                                                                                                       
1874
1875 If not, please checkout Privoxy via CVS first. Run:
1876
1877   autoheader && autoconf && ./configure                                        
1878                                                                                
1879
1880 Then run:
1881
1882   make aix-dist                                                                
1883                                                                                
1884
1885 which creates a gzip'ed tar archive. Sadly, you cannot use make aix-upload on
1886 the Sourceforge machine (no ncftpput). You now have to manually upload the
1887 archive to Sourceforge's ftp server and release the file publicly.
1888
1889 -------------------------------------------------------------------------------
1890
1891 9. Contacting the developers, Bug Reporting and Feature Requests
1892
1893 We value your feedback. However, to provide you with the best support, please
1894 note:
1895
1896   *  Use the Sourceforge Support Forum to get help:
1897        
1898         http://sourceforge.net/tracker/?group_id=11118&atid=211118
1899        
1900    
1901   *  Submit bugs only through our Sourceforge Bug Forum:
1902      
1903         http://sourceforge.net/tracker/?group_id=11118&atid=111118. 
1904         
1905    
1906     Make sure that the bug has not already been submitted. Please try to verify
1907     that it is a Privoxy bug, and not a browser or site bug first. If you are
1908     using your own custom configuration, please try the stock configs to see if
1909     the problem is a configuration related bug. And if not using the latest
1910     development snapshot, please try the latest one. Or even better, CVS
1911     sources. Please be sure to include the Privoxy/Junkbuster version,
1912     platform, browser, any pertinent log data, any other relevant details
1913     (please be specific) and, if possible, some way to reproduce the bug.
1914    
1915   *  Submit feature requests only through our Sourceforge feature request forum:
1916      
1917         http://sourceforge.net/tracker/?atid=361118&group_id=11118&func=browse.
1918        
1919    
1920   *  Submit missed ads and banners, and incorrectly blocked images, popups, etc:
1921           
1922         http://p.p/, and select "actions file feedback system"
1923        
1924    
1925     This page can also be reached from many of the internal CGI pages.
1926    
1927   *  For any other issues, feel free to use the mailing lists:
1928      
1929         http://sourceforge.net/mail/?group_id=11118.
1930      
1931    
1932     Anyone interested in actively participating in development and related
1933     discussions can also join the appropriate mailing list. Archives are
1934     available too.
1935    
1936 -------------------------------------------------------------------------------
1937
1938 10. Copyright and History
1939
1940 10.1. Copyright
1941
1942 Privoxy is free software; you can redistribute it and/or modify it under the
1943 terms of the GNU General Public License as published by the Free Software
1944 Foundation; either version 2 of the License, or (at your option) any later
1945 version.
1946
1947 This program is distributed in the hope that it will be useful, but WITHOUT ANY
1948 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
1949 PARTICULAR PURPOSE. See the GNU General Public License for more details, which
1950 is available from the Free Software Foundation, Inc, 59 Temple Place - Suite
1951 330, Boston, MA 02111-1307, USA.
1952
1953 You should have received a copy of the GNU General Public License along with
1954 this program; if not, write to the Free Software Foundation, Inc., 59 Temple
1955 Place, Suite 330, Boston, MA 02111-1307 USA.
1956
1957 -------------------------------------------------------------------------------
1958
1959 10.2. History
1960
1961 Privoxy is evolved, and derived from, the Internet Junkbuster, with many
1962 improvments and enhancements over the original.
1963
1964 Junkbuster was originally written by Anonymous Coders and Junkbusters
1965 Corporation, and was released as free open-source software under the GNU GPL. 
1966 Stefan Waldherr made many improvements, and started the SourceForge project
1967 Privoxy to rekindle development. There are now several active developers
1968 contributing. The last stable release of Junkbuster was v2.0.2, which has now
1969 grown whiskers ;-).
1970
1971 -------------------------------------------------------------------------------
1972
1973 11. See also
1974
1975 Other references and sites of interest to Privoxy users:
1976
1977 http://www.privoxy.org/, The Privoxy Home page.
1978
1979 http://sourceforge.net/projects/ijbswa, the Project Page for Privoxy on        
1980 Sourceforge.                                                                   
1981
1982 http://p.p/, access Privoxy from your browser. Alternately, http://            
1983 config.privoxy.org may work in some situations where the first does not.       
1984
1985 http://p.p/, and select "actions file feedback system" to submit "misses" to   
1986 the developers.                                                                
1987
1988 http://www.junkbusters.com/ht/en/cookies.html
1989
1990 http://www.waldherr.org/junkbuster/
1991
1992 http://privacy.net/analyze/
1993
1994 http://www.squid-cache.org/
1995
1996  
1997