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