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