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