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