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