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