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