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