a85668090adf9d6f5d83c9f20d641eb612ebecc5
[privoxy.git] / doc / source / developer-manual.sgml
1 <!DOCTYPE article PUBLIC "-//OASIS//DTD DocBook V3.1//EN"[
2 <!entity % dummy "IGNORE">
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 p-version "3.0.29">
9 <!entity p-status "stable">
10 <!entity % p-not-stable "IGNORE">
11 <!entity % p-stable "INCLUDE">
12 <!entity % p-text "IGNORE">        <!-- define we are not a text only doc -->
13 <!entity % p-doc "INCLUDE">        <!-- and we are a formal doc           -->
14 <!entity % seealso-extra "INCLUDE"> <!-- extra stuff from seealso.sgml    -->
15 <!entity  my-copy "&copy;">        <!-- kludge for docbook2man            -->
16 ]>
17 <!--
18  File        :  doc/source/developer-manual.sgml
19
20  Purpose     :  developer manual
21
22  Copyright (C) 2001-2020 Privoxy Developers https://www.privoxy.org/
23  See LICENSE.
24
25  ========================================================================
26  NOTE: Please read developer-manual/documentation.html before touching
27  anything in this, or other Privoxy documentation. You have been warned!
28  Failure to abide by this rule will result in the revocation of your license
29  to live a peaceful existence!
30  ========================================================================
31
32 -->
33
34 <article id="index">
35   <artheader>
36     <title>Privoxy Developer Manual</title>
37     <pubdate>
38      <subscript>
39     <!-- Completely the wrong markup, but very little is allowed  -->
40     <!-- in this part of an article. FIXME -->
41       <ulink url="https://www.privoxy.org/user-manual/copyright.html">Copyright</ulink>
42       &my-copy; 2001-2020 by
43       <ulink url="https://www.privoxy.org/">Privoxy Developers</ulink>
44      </subscript>
45     </pubdate>
46
47 <!--
48
49 Note: this should generate a separate page, and a live link to it.
50 But it doesn't for some mysterious reason. Please leave commented
51 unless it can be fixed proper. For the time being, the copyright
52 statement will be in copyright.smgl.
53
54 Hal.
55
56 <legalnotice id="legalnotice">
57  <para>
58   text goes here ........
59  </para>
60 </legalnotice>
61
62 -->
63
64     <abstract>
65
66 <![%dummy;[
67  <para>
68  <comment>
69   This is here to keep vim syntax file from breaking :/
70   If I knew enough to fix it, I would.
71   PLEASE DO NOT REMOVE! HB: hal@foobox.net
72  </comment>
73  </para>
74  ]]>
75 <para>
76  The developer manual provides guidance on coding, testing, packaging, documentation
77  and other issues of importance to those involved with
78  <application>Privoxy</application> development. It is mandatory (and helpful!) reading
79  for anyone who wants to join the team. Note that it's currently out of date
80  and may not be entirely correct. As always, patches are welcome.
81 </para>
82
83 <!-- Include privoxy.sgml boilerplate text: -->
84
85 <!--  &p-intro; Someone interested enough in the project to contribute
86                 will already know at this point what Privoxy is. -->
87
88 <!-- end boilerplate -->
89
90 <para>
91  Please note that this document is constantly evolving. This copy represents
92  the state at the release of version &p-version;.
93  You can find the latest version of the this manual at <ulink
94  url="https://www.privoxy.org/developer-manual/">https://www.privoxy.org/developer-manual/</ulink>.
95  Please have a look at the
96  <ulink url="https://www.privoxy.org/user-manual/contact.html">contact section in the user manual</ulink>
97  if you are interested in contacting the developers.
98 </para>
99
100     </abstract>
101   </artheader>
102
103
104 <!--   ~~~~~       New section      ~~~~~     -->
105   <sect1 id="introduction"><title>Introduction</title>
106 <!--
107
108  I don't like seeing blank space :) So added *something* here.
109
110  -->
111     <para>
112      <application>Privoxy</application>, as an heir to
113      <application>Junkbuster</application>, is a Free Software project
114      and the code is licensed under the GNU General Public License version 2.
115      As such, <application>Privoxy</application> development is potentially open
116      to anyone who has the time, knowledge, and desire to contribute
117      in any capacity. Our goals are simply to continue the mission,
118      to improve <application>Privoxy</application>, and
119      to make it available to as wide an audience as possible.
120     </para>
121     <para>
122      One does not have to be a programmer to contribute. Packaging, testing,
123      documenting and porting, are all important jobs as well.
124     </para>
125
126   <!--   ~~~~~       New section      ~~~~~     -->
127   <sect2 id="quickstart"><title>Quickstart to Privoxy Development</title>
128    <para>
129     The first step is to join the <ulink
130       url="https://lists.privoxy.org/mailman/listinfo/privoxy-devel">privoxy-devel mailing list</ulink>.
131     You can submit your ideas or, even better, patches.
132     Patches can also be submitted to the
133     <ulink url="https://sourceforge.net/p/ijbswa/patches/">Sourceforge patch tracker</ulink>.
134    </para>
135     <para>
136      You will also need to have a git package installed,
137      in order to access the git repository.
138      Having the GNU build tools is also going to be important (particularly,
139      autoconf and gmake).
140     </para>
141     <para>
142       For the time being (read, this section is under construction), you can
143       also refer to the extensive comments in the source code. In fact,
144       reading the code is recommended in any case.
145     </para>
146    </sect2>
147   </sect1>
148
149   <!--   ~~~~~       New section      ~~~~~     -->
150   <sect1 id="git"><title>The Git Repository</title>
151     <para>
152       If you become part of the active development team, you will eventually
153       need write access to our holy grail, the Git repository. One of the
154       team members will need to set this up for you. Please read
155       this chapter completely before accessing via Git.
156     </para>
157
158     <sect2 id="gitaccess"><title>Access to Git</title>
159       <para>
160         The project's Git repository is hosted at the
161         <ulink url="https://privoxy.org/">Privoxy website</ulink>.
162         For Privoxy team members with push privileges the Git repository URL is
163         <literal>ssh://git@git.privoxy.org:23/git/privoxy.git</literal>.
164       </para>
165       <para>
166        Contributors without push privileges can
167        <quote>git clone https://www.privoxy.org/git/privoxy.git</quote>.
168       </para>
169       <para>
170         The central repository is called <literal>privoxy</literal>, and the
171         source branch is called <literal>master</literal>. Subfolders exist
172         within the project for target-dependent build and  packaging tools, each
173         including the name of the target operating system in their name (e.g.
174         Windows, OSXPackageBuilder, debian). There is a webview of the Git
175         hierarchy at
176         <ulink url="https://www.privoxy.org/gitweb/?p=privoxy.git;a=tree">
177                     https://www.privoxy.org/gitweb/?p=privoxy.git;a=tree</ulink>,
178         which might help with visualizing how these pieces fit together.
179       </para>
180     </sect2>
181
182     <sect2 id="gitbranches">
183     <title>Branches</title>
184      <para>
185        Whilst the central repository contains only the master branch, developers
186        are of course free to create branches in their local repositories as they
187        develop features, fixes, or update the target-dependent tools. Only once
188        such changes are fully tested ought they be pushed back to the central
189        repository master branch.
190      </para>
191      <!--
192      <para>
193        Branches are used to fork a sub-development path from the main trunk.
194        Within the <literal>current</literal> module where the sources are, there
195        is always at least one <quote>branch</quote> from the main trunk
196        devoted to a stable release series. The main trunk is where active
197        development takes place for the next stable series (e.g. 3.2.x).
198        So just prior to each stable series (e.g. 3.0.x), a branch is created
199        just for stable series releases (e.g. 3.0.0 -> 3.0.1 -> 3.0.2, etc).
200        Once the initial stable release of any stable branch has taken place,
201        this branch is <emphasis>only used for bugfixes</emphasis>, which have
202        had prior testing before being committed to Git. (See <link
203        linkend="versionnumbers">Version Numbers</link> below for details on
204        versioning.)
205      </para>
206      -->
207      <para>
208       At one time there were two distinct branches: stable and unstable. The
209       more drastic changes were to be in the unstable branch. These branches
210       have now been merged to minimize time and effort of maintaining two
211       branches.
212      </para>
213     <!--
214      <para>
215        This will result in at least two active branches, which means there may
216        be occasions that require the same (or similar) item to be
217        checked into to two different places (assuming its a bugfix and needs
218        fixing in both the stable and unstable trees). This also means that in
219        order to have access to both trees, both will have to be checked out
220        separately. Use the <literal>cvs -r</literal> flag to check out a
221        branch, e.g: <literal>cvs co -r v_3_0_branch current</literal>.
222      </para>
223     -->
224     </sect2>
225
226     <sect2 id="gitcommit"><title>Git Commit Guidelines</title>
227       <para>
228         The source tree is the heart of every software project. Every effort must
229         be made to ensure that it is readable, compilable and consistent at all
230         times. <!-- There are differing guidelines for the stable branch and the
231         main development trunk, and --> We expect anyone with Git access to strictly
232         adhere to the following guidelines:
233       </para>
234
235       <para>
236        Basic Guidelines, for all branches:
237       </para>
238         <itemizedlist>
239           <listitem><para>
240             Please don't commit even
241             a small change without testing it thoroughly first. When we're
242             close to a public release, ask a fellow developer to review your
243             changes.
244           </para></listitem>
245           <listitem><para>
246             Your commit message should give a concise overview of <emphasis>what you
247             changed</emphasis> (no big details) and <emphasis>why you changed it</emphasis>
248             Just check previous messages for good examples.
249           </para></listitem>
250           <listitem><para>
251             Don't use the same message on multiple files, unless it equally applies to
252             all those files.
253           </para></listitem>
254           <listitem><para>
255             If your changes span multiple files, and the code won't recompile unless
256             all changes are committed (e.g. when changing the signature of a function),
257             then commit all files one after another, without long delays in between.
258             If necessary, prepare the commit messages in advance.
259           </para></listitem>
260           <listitem><para>
261             Before changing things on Git, make sure that your changes are in line
262             with the team's general consensus on what should be done.
263           </para></listitem>
264           <listitem>
265            <para>
266             Note that near a major public release, we get more cautious.
267             There is always the possibility to submit a patch to the <ulink
268             url="https://sourceforge.net/p/ijbswa/patches/">patch
269             tracker</ulink> instead.
270           </para>
271          </listitem>
272         </itemizedlist>
273
274 <!--
275       <para>
276        Stable branches are handled with more care, especially after the
277        initial *.*.0 release, and we are just in bugfix mode. In addition to
278        the above, the below applies only to the stable branch (currently the
279        <literal>v_3_0_branch</literal> branch):
280       </para>
281
282       <para>
283        <itemizedlist>
284         <listitem>
285          <para>
286            Do not commit <emphasis>anything</emphasis> unless your proposed
287            changes have been well tested first, preferably by other members of the
288            project, or have prior approval of the project leaders or consensus
289            of the devel list.
290          </para>
291         </listitem>
292        <listitem>
293         <para>
294          Where possible, bugfixes and changes should be tested in the main
295          development trunk first. There may be occasions where this is not
296          feasible, though.
297         </para>
298        </listitem>
299        <listitem>
300         <para>
301           Alternately, proposed changes can be submitted as patches output by
302           <literal>git format-patch</literal> to the privoxy-devel mailing list
303           or alternatively to the patch tracker on Sourceforge:
304           <ulink url="https://sourceforge.net/p/ijbswa/patches/">
305                       https://sourceforge.net/p/ijbswa/patches/</ulink>.
306           Then ask for peer review.
307         </para>
308        </listitem>
309         <listitem>
310          <para>
311           Do not even think about anything except bugfixes. No new features!
312          </para>
313         </listitem>
314
315        </itemizedlist>
316       </para>
317     -->
318     </sect2>
319
320   </sect1>
321
322   <!--   ~~~~~       New section      ~~~~~     -->
323 <sect1 id="documentation"><title>Documentation Guidelines</title>
324   <para>
325     All formal documents are maintained in Docbook SGML and located in the
326     <computeroutput>doc/source/*</computeroutput> directory. You will need
327     <ulink url="https://www.docbook.org/">Docbook</ulink>, the Docbook
328     DTD's and the Docbook modular stylesheets (or comparable alternatives),
329     and either <application>jade</application> or
330     <application>openjade</application> (recommended) installed in order to
331     build docs from source. Currently there is <ulink
332     url="../user-manual/index.html"><citetitle>user-manual</citetitle></ulink>,
333     <ulink url="../faq/index.html"><citetitle>FAQ</citetitle></ulink>, and, of
334     course this, the <citetitle>developer-manual</citetitle> in this format.
335     The <citetitle>README</citetitle>, <citetitle>AUTHORS</citetitle>,
336     <citetitle>INSTALL</citetitle>,
337     <citetitle>privoxy.1</citetitle> (man page), and
338     <citetitle>config</citetitle> files are also now maintained as Docbook
339     SGML. These files, when built, in the top-level source directory are
340     generated files! Also, the <application>Privoxy</application> <filename>index.html</filename> (and a
341     variation on this file, <filename>privoxy-index.html</filename>,
342     meant for inclusion with doc packages), are maintained as SGML as well.
343     <emphasis>DO NOT edit these directly</emphasis>. Edit the SGML source, or
344     contact someone involved in the documentation.
345     </para>
346     <para>
347      <filename>config</filename> requires some special handling. The reason it
348      is maintained this way is so that the extensive comments in the file
349      mirror those in <citetitle>user-manual</citetitle>. But the conversion
350      process requires going from SGML to HTML to text to special formatting
351      required for the embedded comments. Some of this does not survive so
352      well. Especially some of the examples that are longer than 80 characters.
353     </para>
354     <para>
355      Other, less formal documents (e.g. <filename>LICENSE</filename>) are
356      maintained as plain text files in the top-level source directory.
357     </para>
358     <para>
359      Packagers are encouraged to include this documentation. For those without
360      the ability to build the docs locally, text versions of each are kept in
361      Git. HTML versions are also being kept in Git under
362      <filename>doc/webserver/*</filename>.
363     </para>
364     <para>
365      Formal documents are built with the Makefile targets of
366      <computeroutput>make dok</computeroutput>.
367      The build process uses the document SGML sources in
368      <computeroutput>doc/source/*/*</computeroutput> to update all text files in
369      <computeroutput>doc/text/</computeroutput> and to update all HTML
370      documents in <computeroutput>doc/webserver/</computeroutput>.
371     </para>
372     <para>
373      Documentation writers should please make sure documents build
374      successfully before committing to Git, if possible.
375     </para>
376     <para>
377      How do you update the webserver (i.e. the pages on privoxy.org)?
378     </para>
379
380      <orderedlist numeration="arabic">
381       <listitem><para>
382         First, build the docs by running <computeroutput>make
383         dok</computeroutput>.
384       </para></listitem>
385       <listitem><para>
386         Run <computeroutput>make webserver</computeroutput> which copies all
387         files from <computeroutput>doc/webserver</computeroutput> to the
388         sourceforge webserver via ssh.
389       </para></listitem>
390      </orderedlist>
391
392   <para>
393    Finished docs should be occasionally submitted to Git
394    (<filename>doc/webserver/*/*.html</filename>) so that those without
395    the ability to build them locally, have access to them if needed.
396    This is especially important just prior to a new release! Please
397    do this <emphasis>after</emphasis> the <literal>$VERSION</literal> and
398    other release specific data in <filename>configure.in</filename> has been
399    updated (this is done just prior to a new release).
400   </para>
401
402 <!--   ~~~~~       New section      ~~~~~     -->
403 <sect2 id="sgml">
404 <title>Quickstart to Docbook and SGML</title>
405 <para>
406  If you are not familiar with SGML, it is a markup language similar to HTML.
407  Actually, not a mark up language per se, but a language used to define
408  markup languages. In fact, HTML is an SGML application. Both will use
409  <quote>tags</quote> to format text and other content. SGML tags can be much
410  more varied, and flexible, but do much of the same kinds of things. The tags,
411  or <quote>elements</quote>, are definable in SGML. There is no set
412  <quote>standards</quote>. Since we are using
413  <application>Docbook</application>, our tags are those that are defined by
414  <application>Docbook</application>. Much of how the finish document is
415  rendered is determined by the <quote>stylesheets</quote>.
416  The stylesheets determine how each tag gets translated to HTML, or other
417  formats.
418 </para>
419
420 <para>
421  Tags in Docbook SGML need to be always <quote>closed</quote>. If not, you
422  will likely generate errors. Example: <literal>&lt;title&gt;My
423  Title&lt;/title&gt;</literal>. They are also case-insensitive, but we
424  strongly suggest using all lower case. This keeps compatibility with
425  [Docbook] <application>XML</application>.
426 </para>
427
428 <para>
429  Our documents use <quote>sections</quote> for the most part. Sections
430  will be processed into HTML headers (e.g. <literal>h1</literal> for
431  <literal>sect1</literal>). The <application>Docbook</application> stylesheets
432  will use these to also generate the Table of Contents for each doc. Our
433  TOC's are set to a depth of three. Meaning <literal>sect1</literal>,
434  <literal>sect2</literal>, and <literal>sect3</literal> will have TOC
435  entries, but <literal>sect4</literal> will not. Each section requires
436  a <literal>&lt;title&gt;</literal> element, and at least one
437  <literal>&lt;para&gt;</literal>. There is a limit of five section
438  levels in Docbook, but generally three should be sufficient for our
439  purposes.
440 </para>
441
442 <para>
443  Some common elements that you likely will use:
444 </para>
445
446   <simplelist>
447     <member>
448       <emphasis>&lt;para&gt;&lt;/para&gt;</emphasis>, paragraph delimiter. Most
449       text needs to be within paragraph elements (there are some exceptions).
450     </member>
451     <member>
452       <emphasis>&lt;emphasis&gt;&lt;/emphasis&gt;</emphasis>, the stylesheets
453       make this italics.
454     </member>
455     <member>
456       <emphasis>&lt;filename&gt;&lt;/filename&gt;</emphasis>, files and directories.
457     </member>
458     <member>
459       <emphasis>&lt;command&gt;&lt;/command&gt;</emphasis>, command examples.
460     </member>
461     <member>
462       <emphasis>&lt;literallayout&gt;&lt;/literallayout&gt;</emphasis>, like
463       <literal>&lt;pre&gt;</literal>, more or less.
464     </member>
465     <member>
466       <emphasis>&lt;itemizedlist&gt;&lt;/itemizedlist&gt;</emphasis>, list with bullets.
467     </member>
468     <member>
469       <emphasis>&lt;listitem&gt;&lt;/listitem&gt;</emphasis>, member of the above.
470     </member>
471     <member>
472       <emphasis>&lt;screen&gt;&lt;/screen&gt;</emphasis>, screen output, implies
473       <literal>&lt;literallayout&gt;</literal>.
474     </member>
475     <member>
476       <emphasis>&lt;ulink url="example.com"&gt;&lt;/ulink&gt;</emphasis>, like
477       HTML <literal>&lt;a&gt;</literal> tag.
478     </member>
479     <member>
480       <emphasis>&lt;quote&gt;&lt;/quote&gt;</emphasis>, for, doh, quoting text.
481     </member>
482   </simplelist>
483
484 <para>
485  Look at any of the existing docs for examples of all these and more.
486 </para>
487
488 <para>
489  You might also find
490  <!-- <quote><ulink url="http://opensource.bureau-cornavin.com/crash-course/index.html">
491               domain no longer exists so link to the wayback archive -->
492  <quote><ulink url="https://web.archive.org/web/20160315230758/http://opensource.bureau-cornavin.com/crash-course/index.html">
493  Writing Documentation Using DocBook - A Crash Course</ulink></quote> useful.
494 </para>
495 </sect2>
496
497 <!--   ~~~~~       New section      ~~~~~     -->
498   <sect2 id="docstyle">
499   <title><application>Privoxy</application> Documentation Style</title>
500    <para>
501     It will be easier if everyone follows a similar writing style. This
502     just makes it easier to read what someone else has written if it
503     is all done in a similar fashion.
504    </para>
505    <para>
506     Here it is:
507    </para>
508     <itemizedlist>
509      <listitem>
510       <para>
511        All tags should be lower case.
512       </para>
513     </listitem>
514     <listitem>
515      <para>
516        Tags delimiting a <emphasis>block</emphasis> of text (even small
517        blocks) should be on their own line. Like:
518      </para>
519        <literallayout>
520  &lt;para&gt;
521   Some text goes here.
522  &lt;/para&gt;
523 </literallayout>
524      <para>
525        Tags marking individual words, or few words, should be in-line:
526      </para>
527        <literallayout>
528   Just to &lt;emphasis&gt;emphasize&lt;/emphasis&gt;, some text goes here.
529 </literallayout>
530    </listitem>
531    <listitem>
532     <para>
533       Tags should be nested and step indented for block text like: (except
534       in-line tags)
535     </para>
536      <literallayout>
537  &lt;para&gt;
538   &lt;itemizedlist&gt;
539    &lt;para&gt;
540     &lt;listitem&gt;
541       Some text goes here in our list example.
542      &lt;/listitem&gt;
543    &lt;/para&gt;
544   &lt;/itemizedlist&gt;
545  &lt;/para&gt;
546 </literallayout>
547     <para>
548       This makes it easier to find the text amongst the tags ;-)
549     </para>
550    </listitem>
551    <listitem>
552     <para>
553      Use white space to separate logical divisions within a document,
554      like between sections. Running everything together consistently
555      makes it harder to read and work on.
556     </para>
557    </listitem>
558    <listitem>
559     <para>
560      Do not hesitate to make comments. Comments can either use the
561      &lt;comment&gt; element, or the &lt;!--  --&gt; style comment
562      familiar from HTML. (Note in Docbook v4.x &lt;comment&gt; is
563      replaced by &lt;remark&gt;.)
564     </para>
565   </listitem>
566   <listitem>
567    <para>
568      We have an international audience. Refrain from slang, or English
569      idiosyncrasies (too many to list :). Humor also does not translate
570      well sometimes.
571    </para>
572   </listitem>
573   <listitem>
574    <para>
575     Try to keep overall line lengths in source files to 80 characters or less
576     for obvious reasons. This is not always possible, with lengthy URLs for
577     instance.
578    </para>
579   </listitem>
580   <listitem>
581    <para>
582     Our documents are available in differing formats. Right now, they
583     are just plain text and/or HTML, but others are always a
584     future possibility. Be careful with URLs (&lt;ulink&gt;), and avoid
585     this mistake:
586    </para>
587    <para>
588      My favorite site is &lt;ulink url="http://example.com"&gt;here&lt;/ulink&gt;.
589    </para>
590    <para>
591      This will render as <quote>My favorite site is here</quote>, which is
592      not real helpful in a text doc. Better like this:
593    </para>
594    <para>
595      My favorite site is &lt;ulink url="http://example.com"&gt;example.com&lt;/ulink&gt;.
596    </para>
597   </listitem>
598   <listitem>
599    <para>
600     All documents should be spell checked occasionally.
601     <application>aspell</application> can check SGML with the
602     <literal>-H</literal> option. (<application>ispell</application> I think
603     too.)
604    </para>
605   </listitem>
606
607   </itemizedlist>
608
609   </sect2>
610
611
612  <!--   ~~~~~       New section      ~~~~~     -->
613
614  <sect2><title>Privoxy Custom Entities</title>
615  <para>
616   <application>Privoxy</application> documentation is using
617   a number of customized <quote>entities</quote> to facilitate
618   documentation maintenance.
619  </para>
620  <para>
621   We are using a set of <quote>boilerplate</quote> files with generic text,
622   that is used by multiple docs. This way we can write something once, and use
623   it repeatedly without having to re-write the same content over and over again.
624   If editing such a file, keep in mind that it should be
625   <emphasis>generic</emphasis>. That is the purpose; so it can be used in varying
626   contexts without additional modifications.
627  </para>
628  <para>
629   We are also using what <application>Docbook</application> calls
630   <quote>internal entities</quote>. These are like variables in
631   programming. Well, sort of. For instance, we have the
632   <literal>p-version</literal> entity that contains the current
633   <application>Privoxy</application> version string. You are strongly
634   encouraged to use these where possible. Some of these obviously
635   require re-setting with each release (done by the Makefile). A sampling of
636   custom entities are listed below. See any of the main docs for examples.
637  </para>
638
639   <itemizedlist>
640   <listitem>
641    <para>
642     Re- <quote>boilerplate</quote> text entities are defined like:
643    </para>
644    <para>
645     <literal>&lt;!entity supported SYSTEM "supported.sgml"&gt;</literal>
646    </para>
647    <para>
648      In this example, the contents of the file,
649      <filename>supported.sgml</filename> is available for inclusion anywhere
650      in the doc. To make this happen, just reference the now defined
651      entity: <literal>&#38;supported;</literal> (starts with an ampersand
652      and ends with a semi-colon), and the contents will be dumped into
653      the finished doc at that point.
654    </para>
655   </listitem>
656
657   <listitem>
658    <para>
659     Commonly used <quote>internal entities</quote>:
660   </para>
661   <simplelist>
662    <member>
663     <emphasis>p-version</emphasis>: the <application>Privoxy</application>
664     version string, e.g. <quote>&p-version;</quote>.
665    </member>
666    <member>
667     <emphasis>p-status</emphasis>: the project status, either
668     <quote>alpha</quote>, <quote>beta</quote>, or <quote>stable</quote>.
669    </member>
670    <member>
671     <emphasis>p-not-stable</emphasis>: use to conditionally include
672     text in <quote>not stable</quote> releases (e.g. <quote>beta</quote>).
673    </member>
674    <member>
675     <emphasis>p-stable</emphasis>: just the opposite.
676    </member>
677    <member>
678     <emphasis>p-text</emphasis>: this doc is only generated as text.
679    </member>
680   </simplelist>
681  </listitem>
682  </itemizedlist>
683  <para>
684   There are others in various places that are defined for a specific
685   purpose. Read the source!
686  </para>
687
688  </sect2>
689
690  </sect1>
691
692 <!--     <listitem><para>be consistent with the redirect script (i.e. the <application>Privoxy</application> program -->
693 <!--       points via the redirect URL at sf to valid end-points in the document)</para></listitem> -->
694
695   <!--   ~~~~~       New section      ~~~~~     -->
696   <sect1 id="coding"><title>Coding Guidelines</title>
697
698     <sect2 id="s1"><title>Introduction</title>
699
700     <para>This set of standards is designed to make our lives easier.  It is
701     developed with the simple goal of helping us keep the "new and improved
702     <application>Privoxy</application>" consistent and reliable. Thus making
703     maintenance easier and increasing chances of success of the
704     project.</para>
705
706     <para>And that of course comes back to us as individuals. If we can
707     increase our development and product efficiencies then we can solve more
708     of the request for changes/improvements and in general feel good about
709     ourselves. ;-></para>
710
711   </sect2>
712
713     <sect2 id="s2"><title>Using Comments</title>
714
715
716     <sect3 id="s3"><title>Comment, Comment, Comment</title>
717
718     <para><emphasis>Explanation:</emphasis></para>
719
720     <para>Comment as much as possible without commenting the obvious.
721     For example do not comment "variable_a is equal to variable_b".
722     Instead explain why variable_a should be equal to the variable_b.
723     Just because a person can read code does not mean they will
724     understand why or what is being done. A reader may spend a lot
725     more time figuring out what is going on when a simple comment
726     or explanation would have prevented the extra research. Please
727     help your fellow Privoxy developers out!</para>
728
729     <para>The comments will also help justify the intent of the code.
730     If the comment describes something different than what the code
731     is doing then maybe a programming error is occurring.</para>
732
733     <para><emphasis>Example:</emphasis></para>
734 <programlisting>
735 /* if page size greater than 1k ... */
736 if (page_length() > 1024)
737 {
738     ... "block" the page up ...
739 }
740
741 /* if page size is small, send it in blocks */
742 if (page_length() > 1024)
743 {
744     ... "block" the page up ...
745 }
746
747 This demonstrates 2 cases of "what not to do".  The first is a
748 "syntax comment".  The second is a comment that does not fit what
749 is actually being done.
750 </programlisting>
751   </sect3>
752
753
754
755     <sect3 id="s4"><title>Use blocks for comments</title>
756
757     <para><emphasis>Explanation:</emphasis></para>
758
759     <para>Comments can help or they can clutter. They help when they
760     are differentiated from the code they describe. One line
761     comments do not offer effective separation between the comment
762     and the code. Block identifiers do, by surrounding the code
763     with a clear, definable pattern.</para>
764
765     <para><emphasis>Example:</emphasis></para>
766 <programlisting>
767 /*********************************************************************
768  * This will stand out clearly in your code!
769  *********************************************************************/
770 if (this_variable == that_variable)
771 {
772    do_something_very_important();
773 }
774
775
776 /* unfortunately, this may not */
777 if (this_variable == that_variable)
778 {
779    do_something_very_important();
780 }
781
782
783 if (this_variable == that_variable) /* this may not either */
784 {
785    do_something_very_important();
786 }</programlisting>
787
788     <para><emphasis>Exception:</emphasis></para>
789
790     <para>If you are trying to add a small logic comment and do not
791     wish to "disrupt" the flow of the code, feel free to use a 1
792     line comment which is NOT on the same line as the code.</para>
793
794
795   </sect3>
796
797
798     <sect3 id="s5"><title>Keep Comments on their own line</title>
799
800     <para><emphasis>Explanation:</emphasis></para>
801
802     <para>It goes back to the question of readability. If the comment
803     is on the same line as the code it will be harder to read than
804     the comment that is on its own line.</para>
805
806     <para>There are three exceptions to this rule, which should be
807     violated freely and often: during the definition of variables,
808     at the end of closing braces, when used to comment
809     parameters.</para>
810
811     <para><emphasis>Example:</emphasis></para>
812 <programlisting>
813 /*********************************************************************
814  * This will stand out clearly in your code,
815  * But the second example won't.
816  *********************************************************************/
817 if (this_variable == this_variable)
818 {
819    do_something_very_important();
820 }
821
822 if (this_variable == this_variable) /*can you see me?*/
823 {
824    do_something_very_important(); /*not easily*/
825 }
826
827
828 /*********************************************************************
829  * But, the encouraged exceptions:
830  *********************************************************************/
831 int urls_read     = 0;     /* # of urls read + rejected */
832 int urls_rejected = 0;     /* # of urls rejected */
833
834 if (1 == X)
835 {
836    do_something_very_important();
837 }
838
839
840 short do_something_very_important(
841    short firstparam,   /* represents something */
842    short nextparam     /* represents something else */ )
843 {
844    ...code here...
845
846 }   /* -END- do_something_very_important */
847 </programlisting>
848   </sect3>
849
850
851     <sect3 id="s6"><title>Comment each logical step</title>
852
853     <para><emphasis>Explanation:</emphasis></para>
854
855     <para>Logical steps should be commented to help others follow the
856     intent of the written code and comments will make the code more
857     readable.</para>
858
859     <para>If you have 25 lines of code without a comment, you should
860     probably go back into it to see where you forgot to put
861     one.</para>
862
863     <para>Most "for", "while", "do", etc... loops _probably_ need a
864     comment. After all, these are usually major logic
865     containers.</para>
866
867
868   </sect3>
869
870
871     <sect3 id="s7"><title>Comment All Functions Thoroughly</title>
872
873     <para><emphasis>Explanation:</emphasis></para>
874
875     <para>A reader of the code should be able to look at the comments
876     just prior to the beginning of a function and discern the
877     reason for its existence and the consequences of using it. The
878     reader should not have to read through the code to determine if
879     a given function is safe for a desired use. The proper
880     information thoroughly presented at the introduction of a
881     function not only saves time for subsequent maintenance or
882     debugging, it more importantly aids in code reuse by allowing a
883     user to determine the safety and applicability of any function
884     for the problem at hand. As a result of such benefits, all
885     functions should contain the information presented in the
886     addendum section of this document.</para>
887
888
889   </sect3>
890
891
892     <sect3 id="s8"><title>Comment at the end of braces if the
893     content is more than one screen length</title>
894
895     <para><emphasis>Explanation:</emphasis></para>
896
897     <para>Each closing brace should be followed on the same line by a
898     comment that describes the origination of the brace if the
899     original brace is off of the screen, or otherwise far away from
900     the closing brace. This will simplify the debugging,
901     maintenance, and readability of the code.</para>
902
903     <para>As a suggestion , use the following flags to make the
904     comment and its brace more readable:</para>
905
906     <para>use following a closing brace: } /* -END- if() or while ()
907     or etc... */</para>
908
909     <para><emphasis>Example:</emphasis></para>
910 <programlisting>
911 if (1 == X)
912 {
913    do_something_very_important();
914    ...some long list of commands...
915 } /* -END- if x is 1 */
916
917 or:
918
919 if (1 == X)
920 {
921    do_something_very_important();
922    ...some long list of commands...
923 } /* -END- if (1 == X) */
924 </programlisting>
925   </sect3>
926
927   </sect2>
928
929     <sect2 id="s9"><title>Naming Conventions</title>
930
931
932
933     <sect3 id="s10"><title>Variable Names</title>
934
935     <para><emphasis>Explanation:</emphasis></para>
936
937     <para>Use all lowercase, and separate words via an underscore
938     ('_'). Do not start an identifier with an underscore. (ANSI C
939     reserves these for use by the compiler and system headers.) Do
940     not use identifiers which are reserved in ANSI C++. (E.g.
941     template, class, true, false, ...). This is in case we ever
942     decide to port Privoxy to C++.</para>
943
944     <para><emphasis>Example:</emphasis></para>
945 <programlisting>
946 int ms_iis5_hack = 0;</programlisting>
947
948     <para><emphasis>Instead of:</emphasis></para>
949
950 <programlisting>
951 int msiis5hack = 0; int msIis5Hack = 0;
952 </programlisting>
953
954
955
956   </sect3>
957
958     <sect3 id="s11"><title>Function Names</title>
959
960     <para><emphasis>Explanation:</emphasis></para>
961
962     <para>Use all lowercase, and separate words via an underscore
963     ('_'). Do not start an identifier with an underscore. (ANSI C
964     reserves these for use by the compiler and system headers.) Do
965     not use identifiers which are reserved in ANSI C++. (E.g.
966     template, class, true, false, ...). This is in case we ever
967     decide to port Privoxy to C++.</para>
968
969     <para><emphasis>Example:</emphasis></para>
970 <programlisting>
971 int load_some_file(struct client_state *csp)</programlisting>
972
973     <para><emphasis>Instead of:</emphasis></para>
974
975 <programlisting>
976 int loadsomefile(struct client_state *csp)
977 int loadSomeFile(struct client_state *csp)
978 </programlisting>
979
980
981   </sect3>
982
983
984     <sect3 id="s12"><title>Header file prototypes</title>
985
986     <para><emphasis>Explanation:</emphasis></para>
987
988     <para>Use a descriptive parameter name in the function prototype
989     in header files. Use the same parameter name in the header file
990     that you use in the c file.</para>
991
992     <para><emphasis>Example:</emphasis></para>
993 <programlisting>
994 (.h) extern int load_aclfile(struct client_state *csp);
995 (.c) int load_aclfile(struct client_state *csp)</programlisting>
996
997     <para><emphasis>Instead of:</emphasis></para>
998 <programlisting>
999 (.h) extern int load_aclfile(struct client_state *); or
1000 (.h) extern int load_aclfile();
1001 (.c) int load_aclfile(struct client_state *csp)
1002 </programlisting>
1003
1004
1005   </sect3>
1006
1007
1008     <sect3 id="s13"><title>Enumerations, and #defines</title>
1009
1010     <para><emphasis>Explanation:</emphasis></para>
1011
1012     <para>Use all capital letters, with underscores between words. Do
1013     not start an identifier with an underscore. (ANSI C reserves
1014     these for use by the compiler and system headers.)</para>
1015
1016     <para><emphasis>Example:</emphasis></para>
1017 <programlisting>
1018 (enumeration) : enum Boolean {FALSE, TRUE};
1019 (#define) : #define DEFAULT_SIZE 100;</programlisting>
1020
1021     <para><emphasis>Note:</emphasis> We have a standard naming scheme for #defines
1022     that toggle a feature in the preprocessor: FEATURE_>, where
1023     > is a short (preferably 1 or 2 word) description.</para>
1024
1025     <para><emphasis>Example:</emphasis></para>
1026 <programlisting>
1027 #define FEATURE_FORCE 1
1028
1029 #ifdef FEATURE_FORCE
1030 #define FORCE_PREFIX blah
1031 #endif /* def FEATURE_FORCE */
1032 </programlisting>
1033   </sect3>
1034
1035
1036     <sect3 id="s14"><title>Constants</title>
1037
1038     <para><emphasis>Explanation:</emphasis></para>
1039
1040     <para>Spell common words out entirely (do not remove vowels).</para>
1041
1042     <para>Use only widely-known domain acronyms and abbreviations.
1043     Capitalize all letters of an acronym.</para>
1044
1045     <para>Use underscore (_) to separate adjacent acronyms and
1046     abbreviations. Never terminate a name with an underscore.</para>
1047
1048     <para><emphasis>Example:</emphasis></para>
1049 <programlisting>
1050 #define USE_IMAGE_LIST 1</programlisting>
1051
1052     <para><emphasis>Instead of:</emphasis></para>
1053
1054 <programlisting>
1055 #define USE_IMG_LST 1 or
1056 #define _USE_IMAGE_LIST 1 or
1057 #define USE_IMAGE_LIST_ 1 or
1058 #define use_image_list 1 or
1059 #define UseImageList 1
1060 </programlisting>
1061
1062
1063   </sect3>
1064
1065   </sect2>
1066
1067
1068     <sect2 id="s15"><title>Using Space</title>
1069
1070
1071
1072     <sect3 id="s16"><title>Put braces on a line by themselves.</title>
1073
1074     <para><emphasis>Explanation:</emphasis></para>
1075
1076     <para>The brace needs to be on a line all by itself, not at the
1077     end of the statement. Curly braces should line up with the
1078     construct that they're associated with. This practice makes it
1079     easier to identify the opening and closing braces for a
1080     block.</para>
1081
1082     <para><emphasis>Example:</emphasis></para>
1083 <programlisting>
1084 if (this == that)
1085 {
1086    ...
1087 }</programlisting>
1088
1089     <para><emphasis>Instead of:</emphasis></para>
1090
1091     <para>if (this == that) { ... }</para>
1092
1093     <para>or</para>
1094
1095     <para>if (this == that) { ... }</para>
1096
1097     <para><emphasis>Note:</emphasis> In the special case that the if-statement is
1098     inside a loop, and it is trivial, i.e. it tests for a
1099     condition that is obvious from the purpose of the block,
1100     one-liners as above may optically preserve the loop structure
1101     and make it easier to read.</para>
1102
1103     <para><emphasis>Status:</emphasis> developer-discretion.</para>
1104
1105     <para><emphasis>Example exception:</emphasis></para>
1106 <programlisting>
1107 while (more lines are read)
1108 {
1109    /* Please document what is/is not a comment line here */
1110    if (it's a comment) continue;
1111
1112    do_something(line);
1113 }
1114 </programlisting>
1115   </sect3>
1116
1117
1118     <sect3 id="s17"><title>ALL control statements should have a
1119     block</title>
1120
1121     <para><emphasis>Explanation:</emphasis></para>
1122
1123     <para>Using braces to make a block will make your code more
1124     readable and less prone to error. All control statements should
1125     have a block defined.</para>
1126
1127     <para><emphasis>Example:</emphasis></para>
1128 <programlisting>
1129 if (this == that)
1130 {
1131    do_something();
1132    do_something_else();
1133 }</programlisting>
1134
1135     <para><emphasis>Instead of:</emphasis></para>
1136
1137     <para>if (this == that) do_something(); do_something_else();</para>
1138
1139     <para>or</para>
1140
1141     <para>if (this == that) do_something();</para>
1142
1143     <para><emphasis>Note:</emphasis> The first example in "Instead of" will execute
1144     in a manner other than that which the developer desired (per
1145     indentation). Using code braces would have prevented this
1146     "feature". The "explanation" and "exception" from the point
1147     above also applies.</para>
1148
1149
1150   </sect3>
1151
1152
1153     <sect3 id="s18"><title>Do not belabor/blow-up boolean
1154     expressions</title>
1155
1156     <para><emphasis>Example:</emphasis></para>
1157 <programlisting>
1158 structure->flag = (condition);</programlisting>
1159
1160     <para><emphasis>Instead of:</emphasis></para>
1161
1162     <para>if (condition) { structure->flag = 1; } else {
1163     structure->flag = 0; }</para>
1164
1165     <para><emphasis>Note:</emphasis> The former is readable and concise. The later
1166     is wordy and inefficient. Please assume that any developer new
1167     to the project has at least a "good" knowledge of C/C++. (Hope
1168     I do not offend by that last comment ... 8-)</para>
1169
1170
1171   </sect3>
1172
1173
1174     <sect3 id="s19"><title>Use white space freely because it is
1175     free</title>
1176
1177     <para><emphasis>Explanation:</emphasis></para>
1178
1179     <para>Make it readable. The notable exception to using white space
1180     freely is listed in the next guideline.</para>
1181
1182     <para><emphasis>Example:</emphasis></para>
1183 <programlisting>
1184 int first_value   = 0;
1185 int some_value    = 0;
1186 int another_value = 0;
1187 int this_variable = 0;
1188 </programlisting>
1189   </sect3>
1190
1191
1192     <sect3 id="s20"><title>Don't use white space around structure
1193     operators</title>
1194
1195     <para><emphasis>Explanation:</emphasis></para>
1196
1197     <para>- structure pointer operator ( "->" ) - member operator (
1198     "." ) - functions and parentheses</para>
1199
1200     <para>It is a general coding practice to put pointers, references,
1201     and function parentheses next to names. With spaces, the
1202     connection between the object and variable/function name is not
1203     as clear.</para>
1204
1205     <para><emphasis>Example:</emphasis></para>
1206 <programlisting>
1207 a_struct->a_member;
1208 a_struct.a_member;
1209 function_name();</programlisting>
1210
1211     <para><emphasis>Instead of:</emphasis> a_struct -> a_member; a_struct . a_member;
1212     function_name ();</para>
1213
1214
1215   </sect3>
1216
1217
1218     <sect3 id="s21"><title>Make the last brace of a function stand
1219     out</title>
1220
1221     <para><emphasis>Example:</emphasis></para>
1222 <programlisting>
1223 int function1( ... )
1224 {
1225    ...code...
1226    return(ret_code);
1227
1228 } /* -END- function1 */
1229
1230
1231 int function2( ... )
1232 {
1233 } /* -END- function2 */
1234 </programlisting>
1235
1236     <para><emphasis>Instead of:</emphasis></para>
1237
1238     <para>int function1( ... ) { ...code... return(ret_code); } int
1239     function2( ... ) { }</para>
1240
1241     <para><emphasis>Note:</emphasis> Use 1 blank line before the closing brace and 2
1242     lines afterward. This makes the end of function standout to
1243     the most casual viewer. Although function comments help
1244     separate functions, this is still a good coding practice. In
1245     fact, I follow these rules when using blocks in "for", "while",
1246     "do" loops, and long if {} statements too. After all whitespace
1247     is free!</para>
1248
1249     <para><emphasis>Status:</emphasis> developer-discretion on the number of blank
1250     lines. Enforced is the end of function comments.</para>
1251
1252
1253   </sect3>
1254
1255
1256     <sect3 id="s22"><title>Use 3 character indentions</title>
1257
1258     <para><emphasis>Explanation:</emphasis></para>
1259
1260     <para>If some use 8 character TABs and some use 3 character TABs,
1261     the code can look *very* ragged. So use 3 character indentions
1262     only. If you like to use TABs, pass your code through a filter
1263     such as "expand -t3" before checking in your code.</para>
1264
1265     <para><emphasis>Example:</emphasis></para>
1266 <programlisting>
1267 static const char * const url_code_map[256] =
1268 {
1269    NULL, ...
1270 };
1271
1272
1273 int function1( ... )
1274 {
1275    if (1)
1276    {
1277       return ALWAYS_TRUE;
1278    }
1279    else
1280    {
1281       return HOW_DID_YOU_GET_HERE;
1282    }
1283
1284    return NEVER_GETS_HERE;
1285
1286 }
1287 </programlisting>
1288   </sect3>
1289
1290   </sect2>
1291
1292
1293     <sect2 id="s23"><title>Initializing</title>
1294
1295
1296
1297     <sect3 id="s24"><title>Initialize all variables</title>
1298
1299     <para><emphasis>Explanation:</emphasis></para>
1300
1301     <para>Do not assume that the variables declared will not be used
1302     until after they have been assigned a value somewhere else in
1303     the code. Remove the chance of accidentally using an unassigned
1304     variable.</para>
1305
1306     <para><emphasis>Example:</emphasis></para>
1307 <programlisting>
1308 short a_short = 0;
1309 float a_float  = 0;
1310 struct *ptr = NULL;</programlisting>
1311
1312     <para><emphasis>Note:</emphasis> It is much easier to debug a SIGSEGV if the
1313     message says you are trying to access memory address 00000000
1314     and not 129FA012; or array_ptr[20] causes a SIGSEV vs.
1315     array_ptr[0].</para>
1316
1317     <para><emphasis>Status:</emphasis> developer-discretion if and only if the
1318     variable is assigned a value "shortly after" declaration.</para>
1319
1320   </sect3>
1321   </sect2>
1322
1323
1324     <sect2 id="s25"><title>Functions</title>
1325
1326
1327
1328     <sect3 id="s26"><title>Name functions that return a boolean as a
1329     question.</title>
1330
1331     <para><emphasis>Explanation:</emphasis></para>
1332
1333     <para>Value should be phrased as a question that would logically
1334     be answered as a true or false statement</para>
1335
1336     <para><emphasis>Example:</emphasis></para>
1337 <programlisting>
1338 should_we_block_this();
1339 contains_an_image();
1340 is_web_page_blank();
1341 </programlisting>
1342   </sect3>
1343
1344
1345     <sect3 id="s27"><title>Always specify a return type for a
1346     function.</title>
1347
1348     <para><emphasis>Explanation:</emphasis></para>
1349
1350     <para>The default return for a function is an int. To avoid
1351     ambiguity, create a return for a function when the return has a
1352     purpose, and create a void return type if the function does not
1353     need to return anything.</para>
1354
1355
1356   </sect3>
1357
1358
1359     <sect3 id="s28"><title>Minimize function calls when iterating by
1360     using variables</title>
1361
1362     <para><emphasis>Explanation:</emphasis></para>
1363
1364     <para>It is easy to write the following code, and a clear argument
1365     can be made that the code is easy to understand:</para>
1366
1367     <para><emphasis>Example:</emphasis></para>
1368 <programlisting>
1369 for (size_t cnt = 0; cnt &lt; block_list_length(); cnt++)
1370 {
1371    ....
1372 }</programlisting>
1373
1374     <para><emphasis>Note:</emphasis> Unfortunately, this makes a function call for
1375     each and every iteration. This increases the overhead in the
1376     program, because the compiler has to look up the function each
1377     time, call it, and return a value. Depending on what occurs in
1378     the block_list_length() call, it might even be creating and
1379     destroying structures with each iteration, even though in each
1380     case it is comparing "cnt" to the same value, over and over.
1381     Remember too - even a call to block_list_length() is a function
1382     call, with the same overhead.</para>
1383
1384     <para>Instead of using a function call during the iterations,
1385     assign the value to a variable, and evaluate using the
1386     variable.</para>
1387
1388     <para><emphasis>Example:</emphasis></para>
1389 <programlisting>
1390 size_t len = block_list_length();
1391
1392 for (size_t cnt = 0; cnt &lt; len; cnt++)
1393 {
1394    ....
1395 }</programlisting>
1396
1397     <para><emphasis>Exceptions:</emphasis> if the value of block_list_length()
1398     *may* change or could *potentially* change, then you must code the
1399     function call in the for/while loop.</para>
1400
1401
1402   </sect3>
1403
1404
1405     <sect3 id="s29"><title>Pass and Return by Const Reference</title>
1406
1407     <para><emphasis>Explanation:</emphasis></para>
1408
1409     <para>This allows a developer to define a const pointer and call
1410     your function. If your function does not have the const
1411     keyword, we may not be able to use your function. Consider
1412     strcmp, if it were defined as: extern int strcmp(char *s1,
1413     char *s2);</para>
1414
1415     <para>I could then not use it to compare argv's in main: int
1416     main(int argc, const char *argv[]) { strcmp(argv[0], "privoxy");
1417      }</para>
1418
1419     <para>Both these pointers are *const*! If the c runtime library
1420     maintainers do it, we should too.</para>
1421
1422
1423   </sect3>
1424
1425
1426     <sect3 id="s30"><title>Pass and Return by Value</title>
1427
1428     <para><emphasis>Explanation:</emphasis></para>
1429
1430     <para>Most structures cannot fit onto a normal stack entry (i.e.
1431     they are not 4 bytes or less). Aka, a function declaration
1432     like: int load_aclfile(struct client_state csp)</para>
1433
1434     <para>would not work. So, to be consistent, we should declare all
1435     prototypes with "pass by value": int load_aclfile(struct
1436     client_state *csp)</para>
1437
1438
1439   </sect3>
1440
1441
1442     <sect3 id="s31"><title>Names of include files</title>
1443
1444     <para><emphasis>Explanation:</emphasis></para>
1445
1446     <para>Your include statements should contain the file name without
1447     a path. The path should be listed in the Makefile, using -I as
1448     processor directive to search the indicated paths. An exception
1449     to this would be for some proprietary software that utilizes a
1450     partial path to distinguish their header files from system or
1451     other header files.</para>
1452
1453     <para><emphasis>Example:</emphasis></para>
1454 <programlisting>
1455 #include &lt;iostream.h&gt;     /* This is not a local include */
1456 #include "config.h"       /* This IS a local include */
1457 </programlisting>
1458
1459     <para><emphasis>Exception:</emphasis></para>
1460
1461 <programlisting>
1462 /* This is not a local include, but requires a path element. */
1463 #include &lt;sys/fileName.h&gt;
1464 </programlisting>
1465
1466     <para><emphasis>Note:</emphasis> Please! do not add "-I." to the Makefile
1467     without a _very_ good reason. This duplicates the #include
1468     "file.h" behavior.</para>
1469
1470
1471   </sect3>
1472
1473
1474     <sect3 id="s32"><title>Provide multiple inclusion
1475     protection</title>
1476
1477     <para><emphasis>Explanation:</emphasis></para>
1478
1479     <para>Prevents compiler and linker errors resulting from
1480     redefinition of items.</para>
1481
1482     <para>Wrap each header file with the following syntax to prevent
1483     multiple inclusions of the file. Of course, replace PROJECT_H
1484     with your file name, with "." Changed to "_", and make it
1485     uppercase.</para>
1486
1487     <para><emphasis>Example:</emphasis></para>
1488 <programlisting>
1489 #ifndef PROJECT_H_INCLUDED
1490 #define PROJECT_H_INCLUDED
1491  ...
1492 #endif /* ndef PROJECT_H_INCLUDED */
1493 </programlisting>
1494   </sect3>
1495
1496
1497     <sect3 id="s33"><title>Use `extern "C"` when appropriate</title>
1498
1499     <para><emphasis>Explanation:</emphasis></para>
1500
1501     <para>If our headers are included from C++, they must declare our
1502     functions as `extern "C"`. This has no cost in C, but increases
1503     the potential re-usability of our code.</para>
1504
1505     <para><emphasis>Example:</emphasis></para>
1506 <programlisting>
1507 #ifdef __cplusplus
1508 extern "C"
1509 {
1510 #endif /* def __cplusplus */
1511
1512 ... function definitions here ...
1513
1514 #ifdef __cplusplus
1515 }
1516 #endif /* def __cplusplus */
1517 </programlisting>
1518   </sect3>
1519
1520
1521     <sect3 id="s34"><title>Where Possible, Use Forward Struct
1522     Declaration Instead of Includes</title>
1523
1524     <para><emphasis>Explanation:</emphasis></para>
1525
1526     <para>Useful in headers that include pointers to other struct's.
1527     Modifications to excess header files may cause needless
1528     compiles.</para>
1529
1530     <para><emphasis>Example:</emphasis></para>
1531 <programlisting>
1532 /*********************************************************************
1533  * We're avoiding an include statement here!
1534  *********************************************************************/
1535 struct file_list;
1536 extern file_list *xyz;</programlisting>
1537
1538     <para><emphasis>Note:</emphasis> If you declare "file_list xyz;" (without the
1539     pointer), then including the proper header file is necessary.
1540     If you only want to prototype a pointer, however, the header
1541     file is unnecessary.</para>
1542
1543     <para><emphasis>Status:</emphasis> Use with discretion.</para>
1544
1545
1546   </sect3>
1547   </sect2>
1548
1549     <sect2 id="s35"><title>General Coding Practices</title>
1550
1551
1552
1553     <sect3 id="s36"><title>Turn on warnings</title>
1554
1555     <para><emphasis>Explanation</emphasis></para>
1556
1557     <para>Compiler warnings are meant to help you find bugs. You
1558     should turn on as many as possible. With GCC, the switch is
1559     "-Wall". Try and fix as many warnings as possible.</para>
1560
1561
1562   </sect3>
1563
1564
1565     <sect3 id="s37"><title>Provide a default case for all switch
1566     statements</title>
1567
1568     <para><emphasis>Explanation:</emphasis></para>
1569
1570     <para>What you think is guaranteed is never really guaranteed. The
1571     value that you don't think you need to check is the one that
1572     someday will be passed. So, to protect yourself from the
1573     unknown, always have a default step in a switch statement.</para>
1574
1575     <para><emphasis>Example:</emphasis></para>
1576 <programlisting>
1577 switch (hash_string(cmd))
1578 {
1579    case hash_actions_file:
1580       ... code ...
1581       break;
1582
1583    case hash_confdir:
1584       ... code ...
1585       break;
1586
1587    default:
1588       log_error( ... );
1589       ... anomaly code goes here ...
1590       continue; / break; / exit( 1 ); / etc ...
1591
1592 } /* end switch (hash_string(cmd)) */</programlisting>
1593
1594     <para><emphasis>Note:</emphasis> If you already have a default condition, you
1595     are obviously exempt from this point. Of note, most of the
1596     WIN32 code calls `DefWindowProc' after the switch statement.
1597     This API call *should* be included in a default statement.</para>
1598
1599     <para><emphasis>Another Note:</emphasis> This is not so much a readability issue
1600     as a robust programming issue. The "anomaly code goes here" may
1601     be no more than a print to the STDERR stream (as in
1602     load_config). Or it may really be an abort condition.</para>
1603
1604     <para><emphasis>Status:</emphasis> Programmer discretion is advised.</para>
1605
1606
1607   </sect3>
1608
1609
1610     <sect3 id="s38"><title>Try to avoid falling through cases in a
1611     switch statement.</title>
1612
1613     <para><emphasis>Explanation:</emphasis></para>
1614
1615     <para>In general, you will want to have a 'break' statement within
1616     each 'case' of a switch statement. This allows for the code to
1617     be more readable and understandable, and furthermore can
1618     prevent unwanted surprises if someone else later gets creative
1619     and moves the code around.</para>
1620
1621     <para>The language allows you to plan the fall through from one
1622     case statement to another simply by omitting the break
1623     statement within the case statement. This feature does have
1624     benefits, but should only be used in rare cases. In general,
1625     use a break statement for each case statement.</para>
1626
1627     <para>If you choose to allow fall through, you should comment both
1628     the fact of the fall through and reason why you felt it was
1629     necessary.</para>
1630
1631
1632   </sect3>
1633
1634
1635     <sect3 id="s40"><title>Don't mix size_t and other types</title>
1636
1637     <para><emphasis>Explanation:</emphasis></para>
1638
1639     <para>The type of size_t varies across platforms. Do not make
1640     assumptions about whether it is signed or unsigned, or about
1641     how long it is. Do not compare a size_t against another
1642     variable of a different type (or even against a constant)
1643     without casting one of the values.</para>
1644
1645
1646   </sect3>
1647
1648
1649     <sect3 id="s41"><title>Declare each variable and struct on its
1650     own line.</title>
1651
1652     <para><emphasis>Explanation:</emphasis></para>
1653
1654     <para>It can be tempting to declare a series of variables all on
1655     one line. Don't.</para>
1656
1657     <para><emphasis>Example:</emphasis></para>
1658 <programlisting>
1659 long a = 0;
1660 long b = 0;
1661 long c = 0;</programlisting>
1662
1663     <para><emphasis>Instead of:</emphasis></para>
1664
1665     <para>long a, b, c;</para>
1666
1667     <para><emphasis>Explanation:</emphasis> - there is more room for comments on the
1668     individual variables - easier to add new variables without
1669     messing up the original ones - when searching on a variable to
1670     find its type, there is less clutter to "visually"
1671     eliminate</para>
1672
1673     <para><emphasis>Exceptions:</emphasis> when you want to declare a bunch of loop
1674     variables or other trivial variables; feel free to declare them
1675     on one line. You should, although, provide a good comment on
1676     their functions.</para>
1677
1678     <para><emphasis>Status:</emphasis> developer-discretion.</para>
1679
1680
1681   </sect3>
1682
1683
1684     <sect3 id="s42"><title>Use malloc/zalloc sparingly</title>
1685
1686     <para><emphasis>Explanation:</emphasis></para>
1687
1688     <para>Create a local struct (on the stack) if the variable will
1689     live and die within the context of one function call.</para>
1690
1691     <para>Only "malloc" a struct (on the heap) if the variable's life
1692     will extend beyond the context of one function call.</para>
1693
1694     <para><emphasis>Example:</emphasis></para>
1695 <programlisting>
1696 If a function creates a struct and stores a pointer to it in a
1697 list, then it should definitely be allocated via `malloc'.
1698 </programlisting>
1699   </sect3>
1700
1701
1702     <sect3 id="s43"><title>The Programmer Who Uses 'malloc' is
1703     Responsible for Ensuring 'free'</title>
1704
1705     <para><emphasis>Explanation:</emphasis></para>
1706
1707     <para>If you have to "malloc" an instance, you are responsible for
1708     insuring that the instance is `free'd, even if the deallocation
1709     event falls within some other programmer's code. You are also
1710     responsible for ensuring that deletion is timely (i.e. not too
1711     soon, not too late). This is known as "low-coupling" and is a
1712     "good thing (tm)". You may need to offer a
1713     free/unload/destructor type function to accommodate this.</para>
1714
1715     <para><emphasis>Example:</emphasis></para>
1716 <programlisting>
1717 int load_re_filterfile(struct client_state *csp) { ... }
1718 static void unload_re_filterfile(void *f) { ... }</programlisting>
1719
1720     <para><emphasis>Exceptions:</emphasis></para>
1721
1722     <para>The developer cannot be expected to provide `free'ing
1723     functions for C run-time library functions ... such as
1724     `strdup'.</para>
1725
1726     <para><emphasis>Status:</emphasis> developer-discretion. The "main" use of this
1727     standard is for allocating and freeing data structures (complex
1728     or nested).</para>
1729
1730
1731   </sect3>
1732
1733
1734     <sect3 id="s44"><title>Add loaders to the `file_list' structure
1735     and in order</title>
1736
1737     <para><emphasis>Explanation:</emphasis></para>
1738
1739     <para>I have ordered all of the "blocker" file code to be in alpha
1740     order. It is easier to add/read new blockers when you expect a
1741     certain order.</para>
1742
1743     <para><emphasis>Note:</emphasis> It may appear that the alpha order is broken in
1744     places by POPUP tests coming before PCRS tests. But since
1745     POPUPs can also be referred to as KILLPOPUPs, it is clear that
1746     it should come first.</para>
1747
1748
1749   </sect3>
1750
1751
1752     <sect3 id="s45"><title>"Uncertain" new code and/or changes to
1753     existing code, use XXX</title>
1754
1755     <para><emphasis>Explanation:</emphasis></para>
1756
1757     <para>If you have enough confidence in new code or confidence in
1758     your changes, but are not *quite* sure of the repercussions,
1759     add this:</para>
1760
1761     <para>/* XXX: this code has a logic error on platform XYZ, *
1762     attempting to fix */ #ifdef PLATFORM ...changed code here...
1763     #endif</para>
1764
1765     <para>or:</para>
1766
1767     <para>/* XXX: I think the original author really meant this...
1768     */ ...changed code here...</para>
1769
1770     <para>or:</para>
1771
1772     <para>/* XXX: new code that *may* break something else... */
1773     ...new code here...</para>
1774
1775     <para><emphasis>Note:</emphasis> If you make it clear that this may or may not
1776     be a "good thing (tm)", it will be easier to identify and
1777     include in the project (or conversely exclude from the
1778     project).</para>
1779
1780
1781   </sect3>
1782
1783   </sect2>
1784
1785     <sect2 id="s46"><title>Addendum: Template for files and function
1786     comment blocks:</title>
1787
1788     <para><emphasis>Example for file comments:</emphasis></para>
1789 <programlisting>
1790 /*********************************************************************
1791  *
1792  * File        :  $Source
1793  *
1794  * Purpose     :  (Fill me in with a good description!)
1795  *
1796  * Copyright   :  Written by and Copyright (C) 2001-2009
1797  *                the Privoxy team. https://www.privoxy.org/
1798  *
1799  *                This program is free software; you can redistribute it
1800  *                and/or modify it under the terms of the GNU General
1801  *                Public License as published by the Free Software
1802  *                Foundation; either version 2 of the License, or (at
1803  *                your option) any later version.
1804  *
1805  *                This program is distributed in the hope that it will
1806  *                be useful, but WITHOUT ANY WARRANTY; without even the
1807  *                implied warranty of MERCHANTABILITY or FITNESS FOR A
1808  *                PARTICULAR PURPOSE.  See the GNU General Public
1809  *                License for more details.
1810  *
1811  *                The GNU General Public License should be included with
1812  *                this file.  If not, you can view it at
1813  *                http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
1814  *                or write to the Free Software Foundation, Inc.,
1815  *                51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 ,
1816  *                USA
1817  *
1818  *********************************************************************/
1819
1820
1821 #include "config.h"
1822
1823    ...necessary include files for us to do our work...
1824
1825 const char FILENAME_h_rcs[] = FILENAME_H_VERSION;
1826 </programlisting>
1827
1828     <para><emphasis>Note:</emphasis> This declares the rcs variables that should be
1829     added to the "show-version" page. If this is a brand new
1830     creation by you, you are free to change the "Copyright" section
1831     to represent the rights you wish to maintain.</para>
1832
1833     <para><emphasis>Note:</emphasis> The formfeed character that is present right
1834     after the comment flower box is handy for (X|GNU)Emacs users to
1835     skip the verbiage and get to the heart of the code (via
1836     `forward-page' and `backward-page'). Please include it if you
1837     can.</para>
1838
1839     <para><emphasis>Example for file header comments:</emphasis></para>
1840 <programlisting>
1841 #ifndef _FILENAME_H
1842 #define _FILENAME_H
1843 /*********************************************************************
1844  *
1845  * File        :  $Source
1846  *
1847  * Purpose     :  (Fill me in with a good description!)
1848  *
1849  * Copyright   :  Written by and Copyright (C) 2001-2009
1850  *                the Privoxy team. https://www.privoxy.org/
1851  *
1852  *                This program is free software; you can redistribute it
1853  *                and/or modify it under the terms of the GNU General
1854  *                Public License as published by the Free Software
1855  *                Foundation; either version 2 of the License, or (at
1856  *                your option) any later version.
1857  *
1858  *                This program is distributed in the hope that it will
1859  *                be useful, but WITHOUT ANY WARRANTY; without even the
1860  *                implied warranty of MERCHANTABILITY or FITNESS FOR A
1861  *                PARTICULAR PURPOSE.  See the GNU General Public
1862  *                License for more details.
1863  *
1864  *                The GNU General Public License should be included with
1865  *                this file.  If not, you can view it at
1866  *                http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
1867  *                or write to the Free Software Foundation, Inc.,
1868  *                51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 ,
1869  *                USA
1870  *
1871  *********************************************************************/
1872
1873
1874 #include "project.h"
1875
1876 #ifdef __cplusplus
1877 extern "C" {
1878 #endif
1879
1880    ... function headers here ...
1881
1882
1883 /* Revision control strings from this header and associated .c file */
1884 extern const char FILENAME_rcs[];
1885 extern const char FILENAME_h_rcs[];
1886
1887
1888 #ifdef __cplusplus
1889 } /* extern "C" */
1890 #endif
1891
1892 #endif /* ndef _FILENAME_H */
1893
1894 /*
1895   Local Variables:
1896   tab-width: 3
1897   end:
1898 */
1899 </programlisting>
1900
1901     <para><emphasis>Example for function comments:</emphasis></para>
1902 <programlisting>
1903 /*********************************************************************
1904  *
1905  * Function    :  FUNCTION_NAME
1906  *
1907  * Description :  (Fill me in with a good description!)
1908  *
1909  * parameters  :
1910  *          1  :  param1 = pointer to an important thing
1911  *          2  :  x      = pointer to something else
1912  *
1913  * Returns     :  0 => Ok, everything else is an error.
1914  *
1915  *********************************************************************/
1916 int FUNCTION_NAME(void *param1, const char *x)
1917 {
1918    ...
1919    return 0;
1920
1921 }
1922 </programlisting>
1923
1924     <para><emphasis>Note:</emphasis> If we all follow this practice, we should be
1925     able to parse our code to create a "self-documenting" web
1926     page.</para>
1927
1928   </sect2>
1929
1930   </sect1>
1931
1932   <!--   ~~~~~       New section      ~~~~~     -->
1933   <sect1 id="testing"><title>Testing Guidelines</title>
1934     <para>To be filled.
1935 </para>
1936
1937     <!--   ~~~~~       New section      ~~~~~     -->
1938     <sect2 id="testing-plan"><title>Testplan for releases</title>
1939       <para>
1940        Explain release numbers. major, minor. developer releases. etc.
1941       </para>
1942 <orderedlist numeration="arabic">
1943           <listitem><para>
1944 Remove any existing rpm with rpm -e
1945 </para></listitem>
1946           <listitem><para>
1947 Remove any file that was left over. This includes (but is not limited to)
1948           </para>
1949       <itemizedlist>
1950                 <listitem><para>/var/log/privoxy</para></listitem>
1951                 <listitem><para>/etc/privoxy</para></listitem>
1952                 <listitem><para>/usr/sbin/privoxy</para></listitem>
1953                 <listitem><para>/etc/init.d/privoxy</para></listitem>
1954                 <listitem><para>/usr/doc/privoxy*</para></listitem>
1955               </itemizedlist>
1956           </listitem>
1957           <listitem><para>
1958 Install the rpm. Any error messages?
1959 </para></listitem>
1960           <listitem><para>start,stop,status <application>Privoxy</application> with the specific script
1961       (e.g. /etc/rc.d/init/privoxy stop). Reboot your machine. Does
1962       autostart work?</para></listitem>
1963           <listitem><para>Start browsing. Does <application>Privoxy</application> work? Logfile written?</para></listitem>
1964           <listitem><para>Remove the rpm. Any error messages? All files removed?</para></listitem>
1965         </orderedlist>
1966     </sect2>
1967     <!-- XXX: Document how to write test reports and where to send them -->
1968
1969     <!--   ~~~~~       New section      ~~~~~     -->
1970     <sect2 id="fuzzing"><title>Fuzzing Privoxy</title>
1971      <para>
1972        To make fuzzing more convenient, Privoxy can be configured
1973        with --enable-fuzz which will result in the --fuzz option
1974        becoming available.
1975      </para>
1976      <para>
1977       Example (tested on ElectroBSD):
1978      </para>
1979      <programlisting>
1980 # Compile Privoxy with instrumentation for afl
1981 $ export CC=afl-clang
1982 $ export CFLAGS="-fsanitize=address -ggdb"
1983 $ export CPPFLAGS=-I/usr/local/include/
1984 $ export LDFLAGS="-fsanitize=address -L/usr/local/lib"
1985 $ export AFL_USE_ASAN=1
1986 $ export AFL_HARDEN=1
1987 $ ./configure --with-debug --enable-extended-host-patterns --enable-accept-filter --enable-no-gifs --enable-compression --enable-strptime-sanity-checks --enable-external-filters --enable-fuzz
1988
1989 $ ./privoxy --fuzz
1990 Privoxy version 3.0.24 (http://www.privoxy.org/)
1991 Usage: ./privoxy [--config-test] [--chroot] [--help] [--no-daemon] [--pidfile pidfile] [--pre-chroot-nslookup hostname] [--user user[.group]] [--version] [configfile]
1992        ./privoxy --fuzz fuzz-mode ./path/to/fuzzed/input [--stfu]
1993
1994 Supported fuzz modes and the expected input:
1995  action: Text to parse as action file.
1996  client-request: Client request to parse. Currently incomplete
1997  client-header: Client header to parse.
1998  chunked-transfer-encoding: Chunk-encoded data to dechunk.
1999  deflate: deflate-compressed data to decompress.
2000  filter: Text to parse as filter file.
2001  gif: gif to deanimate.
2002  gzip: gzip-compressed data to decompress.
2003  pcrs-substitute: A pcrs-substitute to compile. Not a whole pcrs job! Example: Bla $1 bla C $3 blah.
2004  server-header: Server header to parse.
2005  server-response: Server response to parse.
2006
2007 The following fuzz modes read data from stdin if the 'file' is '-'
2008  client-request
2009  client-header
2010  chunked-transfer-encoding
2011  deflate
2012  gif
2013  gzip
2014  pcrs-substitute
2015  server-header
2016  server-response
2017
2018 Aborting
2019
2020 $ export ASAN_OPTIONS='abort_on_error=1'
2021 $ mkdir input output
2022 $ echo '$1 bla fasel $2' > input/pcrs
2023 $ afl-fuzz -i input -o output -m none ~/git/privoxy/privoxy --fuzz pcrs-substitute - --stfu
2024
2025 $ cat >input/pcrs.txt
2026 FILTER: bla fasel
2027 s@(.{1})[432](\d+)@$1$2$hostname@UgisT
2028
2029 $ afl-fuzz -i input/ -o output/ -f bla.filter -m none privoxy --fuzz filter bla.filter --stfu
2030 </programlisting>
2031     </sect2>
2032   </sect1>
2033
2034   <!--   ~~~~~       New section      ~~~~~     -->
2035   <sect1 id="newrelease"><title>Releasing a New Version</title>
2036     <para>
2037         When we release versions of <application>Privoxy</application>,
2038         our work leaves our cozy secret lab and has to work in the cold
2039         RealWorld[tm]. Once it is released, there is no way to call it
2040         back, so it is very important that great care is taken to ensure
2041         that everything runs fine, and not to introduce problems in the
2042         very last minute.
2043     </para>
2044     <para>
2045         So when releasing a new version, please adhere exactly to the
2046         procedure outlined in this chapter.
2047     </para>
2048
2049     <para>
2050         The following programs are required to follow this process:
2051         <filename>ssh</filename>,
2052         <filename>gmake</filename> (GNU's version of make), autoconf, git,
2053         a web browser.
2054     </para>
2055
2056     <sect2 id="versionnumbers">
2057     <title>Version numbers</title>
2058
2059     <para>
2060       First you need to determine which version number the release will have.
2061       <application>Privoxy</application> version numbers consist of three numbers,
2062       separated by dots, like in X.Y.Z (e.g. 3.0.0), where:
2063     </para>
2064         <itemizedlist>
2065           <listitem>
2066             <para>
2067               X, the version major, is rarely ever changed. It is increased by one if
2068               turning a development branch into stable substantially changes the functionality,
2069               user interface or configuration syntax. Majors 1 and 2 were
2070               <application>Junkbuster</application>, and 3 is the first stable
2071               <application>Privoxy</application> release.
2072             </para>
2073           </listitem>
2074           <listitem>
2075             <para>
2076  <!-- FIXME   this is not the way it works anymore -->
2077               Y, the version minor, represents the branch within the major version.
2078               At any point in time, there are two branches being maintained:
2079               The stable branch, with an even minor, say, 2N, in which no functionality is
2080               being added and only bug-fixes are made, and 2N+1, the development branch, in
2081               which the further development of <application>Privoxy</application> takes
2082               place.
2083               This enables us to turn the code upside down and inside out, while at the same time
2084               providing and maintaining a stable version.
2085               The minor is reset to zero (and one) when the major is incremented. When a development
2086               branch has matured to the point where it can be turned into stable, the old stable branch
2087               2N is given up (i.e. no longer maintained), the former development branch 2N+1 becomes the
2088               new stable branch 2N+2, and a new development branch 2N+3 is opened.
2089             </para>
2090           </listitem>
2091           <listitem>
2092             <para>
2093               Z, the point or sub version, represents a release of the software within a branch.
2094               It is therefore incremented immediately after each software release.
2095       <!-- FIXME   this is not the way it works any more
2096               In development branches, only the even point versions correspond to actual releases,
2097               while the odd ones denote the evolving state of the sources on Git in between.
2098               It follows that Z is odd on Git in development branches most of the time. There, it gets
2099               increased to an even number immediately before a code freeze, and is increased to an odd
2100               number again immediately thereafter.
2101               This ensures that builds from Git snapshots are easily distinguished from released versions.
2102            didn't Fabian get rid of the even=stable, odd=dev convention for release numbering? -->
2103               The point version is reset to zero when the minor changes.
2104             </para>
2105             <para>
2106               Stable branches work a little differently, since there should be
2107               little to no development happening in such branches. Remember,
2108               only bugfixes, which presumably should have had some testing
2109               before being committed. Stable branches will then have their
2110               version reported as <literal>0.0.0</literal>, during that period
2111               between releases when changes are being added. This is to denote
2112               that this code is <emphasis>not for release</emphasis>. Then
2113               as the release nears, the version is bumped according: e.g.
2114               <literal>3.0.1 -> 0.0.0 -> 3.0.2</literal>.
2115             </para>
2116           </listitem>
2117         </itemizedlist>
2118     <para>
2119      In summary, the main Git trunk is the development branch where new
2120      features are being worked on for the next stable series. This should
2121      almost always be where the most activity takes place. There is always at
2122      least one stable branch from the trunk, e.g now it is
2123      <literal>3.0</literal>, which is only used to release stable versions.
2124      Once the initial *.0 release of the stable branch has been done, then as a
2125      rule, only bugfixes that have had prior testing should be committed to
2126      the stable branch. Once there are enough bugfixes to justify a new
2127      release, the version of this branch is again incremented Example: 3.0.0
2128      -> 3.0.1 -> 3.0.2, etc are all stable releases from within the stable
2129      branch. 3.1.x is currently the main trunk, and where work on 3.2.x is
2130      taking place. If any questions, please post to the devel list
2131      <emphasis>before</emphasis> committing to a stable branch!
2132     </para>
2133     <para>
2134      Developers should remember too that if they commit a bugfix to the stable
2135      branch, this will more than likely require a separate submission to the
2136      main trunk, since these are separate development trees within Git. If you
2137      are working on both, then this would require at least two separate check
2138      outs (i.e main trunk, <emphasis>and</emphasis> the stable release branch,
2139      which is <literal>v_3_0_branch</literal> at the moment).
2140     </para>
2141
2142     </sect2>
2143
2144     <sect2 id="beforerelease">
2145     <title>Before the Release</title>
2146      <para>
2147        The following <emphasis>must be done by one of the
2148        developers</emphasis> prior to each new release.
2149      </para>
2150      <itemizedlist>
2151       <listitem>
2152        <para>
2153          Make sure that everybody who has worked on the code in the last
2154          couple of days has had a chance to yell <quote>no!</quote> in case
2155          they have pending changes/fixes in their pipelines. Announce the
2156          freeze so that nobody will interfere with last minute changes.
2157        </para>
2158       </listitem>
2159       <listitem>
2160        <para>
2161          Update the code status (CODE_STATUS="xxx") in configure.in to one of
2162          "alpha", "beta" or "stable".
2163        </para>
2164       </listitem>
2165       <listitem>
2166        <para>
2167          Rebuild configure and GNUMakefile to make sure the updated values are being used.
2168        </para>
2169
2170        <programlisting>
2171 $ autoheader && autoconf     # rebuild configure
2172 $ ./configure                # rebuild GNUmakefile
2173 </programlisting>
2174       </listitem>
2175       <listitem>
2176        <para>
2177         <command>make dok-release</command> to update the sgml documentation source files.
2178        </para>
2179       </listitem>
2180       <listitem>
2181        <para>
2182         If action file processing has changed and is not backward-compatible,
2183         make sure the "for-privoxy-version=x.y.z" minimum version number in
2184         default.action.master has been updated:
2185        </para>
2186         <programlisting>
2187 {{settings}}
2188 #############################################################################
2189 #MASTER# COMMENT: The minimum Privoxy version:
2190 for-privoxy-version=3.0.11
2191 </programlisting>
2192       </listitem>
2193       <listitem>
2194        <para>
2195         Create the change log:
2196        </para>
2197        <programlisting>
2198   $ git tag
2199   #   to see the tags
2200   $ git log [last release tag]..HEAD &gt; /tmp/log
2201   #   get the commit log since the last release
2202   $ utils/makeChangeLog /tmp/log &gt; /tmp/change.log
2203   #   reformat the commit log
2204 </programlisting>
2205        <para>
2206         Edit <filename>/tmp/change.log</filename> to remove trivial
2207         changes and group the changes under general headings like:
2208        </para>
2209        <programlisting>
2210 - Bug fixes:
2211 - Action file improvements:
2212 - Filter file improvements:
2213 - General improvements:
2214 - Documentation improvements:
2215 - Build system improvements:
2216 - Code cleanups:
2217 - Privoxy-Log-Parser:
2218 - Privoxy-Regression-Test:
2219 </programlisting>
2220        <para>
2221         Add the contents of <filename>/tmp/change.log</filename> to the
2222         start of <filename>ChangeLog</filename> and re-create
2223         <filename>doc/source/changelog.sgml</filename>:
2224        </para>
2225        <programlisting>
2226   $ utils/changelog2doc.pl /tmp/change.log &gt;| doc/source/changelog.sgml
2227 </programlisting>
2228       </listitem>
2229       <listitem>
2230        <para>
2231         All developers should look at the <filename>ChangeLog</filename> and
2232         make sure noteworthy changes are referenced.
2233        </para>
2234       </listitem>
2235       <listitem>
2236        <para>
2237         All documentation should be rebuilt:
2238        <programlisting>
2239   $ make man
2240   $ make dok
2241   $ make dok-man
2242   $ make dok-tidy
2243   $ make config-file
2244 </programlisting>
2245         Finished docs should be then be committed to Git (for those
2246         without the ability to build these). Some docs may require
2247         rather obscure processing tools. <filename>config</filename>,
2248         the man page (and the html version of the man page)
2249         fall in this category. README, the man page, AUTHORS, and config
2250         should all also be committed to Git for other packagers. The
2251         formal docs should be uploaded to the webserver. See the section
2252         <ulink url="webserver-update.html">"Updating the webserver"</ulink>
2253         in this manual for details.
2254        </para>
2255       </listitem>
2256       <listitem>
2257        <para>
2258         <emphasis>Commit all files that were changed in the above steps!</emphasis>
2259        </para>
2260       </listitem>
2261       <listitem>
2262        <para>
2263          The <citetitle>User Manual</citetitle> is also used for context
2264          sensitive help for the CGI editor. This is version sensitive, so that
2265          the user will get appropriate help for his/her release. So with
2266          each release a fresh version should be uploaded to the webserver
2267          (this is in addition to the main <citetitle>User Manual</citetitle>
2268          link from the main page since we need to keep manuals for various
2269          versions available). The CGI pages will link to something like
2270          <literal>https://www.privoxy.org/$(VERSION)/user-manual/</literal>. This
2271          will need to be updated for each new release. There is no Makefile
2272          target for this at this time!!! It needs to be done manually.
2273        </para>
2274       </listitem>
2275       <listitem>
2276        <para>
2277         Tag all files in Git with the version number with
2278         <quote><command>git tag v_X_Y_Z</command></quote>.
2279         Don't use vX_Y_Z, ver_X_Y_Z, v_X.Y.Z (won't work) etc.
2280        </para>
2281       </listitem>
2282      <listitem>
2283        <para>
2284         On the webserver, copy the user manual to a new top-level directory
2285         called <filename>X.Y.Z</filename>. This ensures that help links from the CGI
2286         pages, which have the version as a prefix, will go into the right version of the manual.
2287         If this is a development branch release, also symlink <filename>X.Y.(Z-1)</filename>
2288         to <filename>X.Y.Z</filename> and <filename>X.Y.(Z+1)</filename> to
2289         <filename>.</filename> (i.e. dot).
2290        </para>
2291       </listitem>
2292       </itemizedlist>
2293     </sect2>
2294
2295     <sect2 id="therelease">
2296     <title>Building and Releasing the Packages</title>
2297      <para>
2298       Now the individual packages can be built and released. Note that for
2299       GPL reasons the first package to be released is always the source tarball.
2300      </para>
2301
2302      <para>
2303       For <emphasis>all</emphasis> types of packages, including the source tarball,
2304       <emphasis>you must make sure that you build from clean sources by exporting
2305       the right version from Git into an empty directory</emphasis> (just press return when
2306       asked for a password):
2307      </para>
2308
2309       <programlisting>
2310   mkdir dist # delete or choose different name if it already exists
2311   cd dist
2312   git clone https://www.privoxy.org/git/privoxy.git
2313   cd privoxy
2314   git checkout v_X_Y_Z
2315 </programlisting>
2316
2317     <para>
2318      <emphasis>Do NOT change</emphasis> a single bit, including, but not limited to
2319      version information after export from Git. This is to make sure that
2320      all release packages, and with them, all future bug reports, are based
2321      on exactly the same code.
2322     </para>
2323
2324     <warning>
2325      <para>
2326       Every significant release of Privoxy has included at least one
2327       package that either had incorrect versions of files, missing files,
2328       or incidental leftovers from a previous build process that gave
2329       unknown numbers of users headaches to try to figure out what was
2330       wrong. PLEASE, make sure you are using pristene sources, and are
2331       following the prescribed process!
2332      </para>
2333     </warning>
2334
2335     <para>
2336      Please find additional instructions for the source tarball and the
2337      individual platform dependent binary packages below. And details
2338      on the Sourceforge release process below that.
2339     </para>
2340
2341     <sect3 id="pack-guidelines">
2342     <title>Note on Privoxy Packaging</title>
2343      <para>
2344       Please keep these general guidelines in mind when putting together
2345       your package. These apply to <emphasis>all</emphasis> platforms!
2346      </para>
2347       <itemizedlist>
2348        <listitem>
2349         <para>
2350           <application>Privoxy</application> <emphasis>requires</emphasis>
2351           write access to: all <filename>*.action</filename> files, all
2352           logfiles, and the <filename>trust</filename> file. You will
2353           need to determine the best way to do this for your platform.
2354         </para>
2355        </listitem>
2356        <listitem>
2357         <para>
2358           Please include up to date documentation. At a bare minimum:
2359         </para>
2360         <simplelist>
2361          <member>
2362           <filename>LICENSE</filename> (top-level directory)
2363          </member>
2364         </simplelist>
2365         <simplelist>
2366          <member>
2367           <filename>README</filename> (top-level directory)
2368          </member>
2369         </simplelist>
2370         <simplelist>
2371          <member>
2372           <filename>AUTHORS</filename> (top-level directory)
2373          </member>
2374         </simplelist>
2375         <simplelist>
2376          <member>
2377           <filename>man page</filename> (top-level directory, Unix-like
2378           platforms only)
2379          </member>
2380         </simplelist>
2381         <simplelist>
2382          <member>
2383           <filename>The User Manual</filename> (doc/webserver/user-manual/)
2384          </member>
2385         </simplelist>
2386         <simplelist>
2387          <member>
2388           <filename>FAQ</filename> (doc/webserver/faq/)
2389          </member>
2390         </simplelist>
2391         <para>
2392           Also suggested: <filename>Developer Manual</filename>
2393           (doc/webserver/developer-manual) and <filename>ChangeLog</filename>
2394           (top-level directory). <filename>FAQ</filename> and the manuals are
2395           HTML docs. There are also text versions in
2396           <filename>doc/text/</filename> which could conceivably also be
2397           included.
2398         </para>
2399         <para>
2400          The documentation has been designed such that the manuals are linked
2401          to each other from parallel directories, and should be packaged
2402          that way. <filename>privoxy-index.html</filename> can also be
2403          included and can serve as a focal point for docs and other links of
2404          interest (and possibly renamed to <filename>index.html</filename>).
2405          This should be one level up from the manuals. There is a link also
2406          on this page to an HTMLized version of the man page. To avoid 404 for
2407          this, it is in Git as
2408          <filename>doc/webserver/man-page/privoxy-man-page.html</filename>,
2409          and should be included along with the manuals. There is also a
2410          css stylesheets that can be included for better presentation:
2411          <filename>p_doc.css</filename>. This should be in the same directory
2412          with <filename>privoxy-index.html</filename>, (i.e. one level up from
2413          the manual directories).
2414         </para>
2415       </listitem>
2416       <listitem>
2417        <para>
2418         <filename>user.action</filename> and <filename>user.filter</filename>
2419         are designed for local preferences. Make sure these do not get overwritten!
2420         <filename>config</filename> should not be overwritten either. This
2421         has especially important configuration data in it.
2422         <filename>trust</filename> should be left in tact as well.
2423        </para>
2424       </listitem>
2425       <listitem>
2426        <para>
2427         Other configuration files (<filename>default.action</filename> and
2428         <filename>default.filter</filename>) should be installed as the new
2429         defaults, but all previously installed configuration files should be
2430         preserved as backups. This is just good manners :-) These files are
2431         likely to change between releases and contain important new features
2432         and bug fixes.
2433        </para>
2434      </listitem>
2435      <listitem>
2436       <para>
2437        Please check platform specific notes in this doc, if you haven't
2438        done <quote>Privoxy</quote> packaging before for other platform
2439        specific issues. Conversely, please add any notes that you know
2440        are important for your platform (or contact one of the doc
2441        maintainers to do this if you can't).
2442       </para>
2443     </listitem>
2444     <listitem>
2445      <para>
2446        Packagers should do a <quote>clean</quote> install of their
2447        package after building it. So any previous installs should be
2448        removed first to ensure the integrity of the newly built package.
2449        Then run the package for a while to make sure there are no
2450        obvious problems, before uploading.
2451      </para>
2452     </listitem>
2453
2454       </itemizedlist>
2455
2456     </sect3>
2457
2458     <sect3 id="newrelease-tarball"><title>Source Tarball</title>
2459       <para>
2460         First, <emphasis>make sure that you have freshly exported the right
2461         version into an empty directory</emphasis>. (See "Building and releasing
2462         packages" above). Then run:
2463       </para>
2464         <programlisting>
2465   cd current
2466   autoheader && autoconf && ./configure
2467 </programlisting>
2468       <para>
2469         Then do:
2470       </para>
2471         <programlisting>
2472   make tarball-dist
2473 </programlisting>
2474       <para>
2475         To upload the package to Sourceforge, simply issue
2476       </para>
2477         <programlisting>
2478   make tarball-upload
2479 </programlisting>
2480       <para>
2481         Go to the displayed URL and release the file publicly on Sourceforge.
2482         For the change log field, use the relevant section of the
2483         <filename>ChangeLog</filename> file.
2484       </para>
2485     </sect3>
2486
2487     <sect3 id="newrelease-rpm"><title>SuSE, Conectiva or Red Hat RPM</title>
2488       <para>
2489         In following text, replace <replaceable class="parameter">dist</replaceable>
2490         with either <quote>rh</quote> for Red Hat or <quote>suse</quote> for SuSE.
2491       </para>
2492       <para>
2493         First, <emphasis>make sure that you have freshly exported the right
2494         version into an empty directory</emphasis>. (See "Building and releasing
2495         packages" above).
2496       </para>
2497       <para>
2498         As the only exception to not changing anything after export from Git,
2499         now examine the file <filename>privoxy-</filename><replaceable class="parameter">dist</replaceable><filename>.spec</filename>
2500         and make sure that the version information and the RPM release number are
2501         correct. The RPM release numbers for each version start at one. Hence it must
2502         be reset to one if this is the first RPM for
2503         <replaceable class="parameter">dist</replaceable> which is built from version
2504         X.Y.Z. Check the
2505         <ulink url="https://sourceforge.net/projects/ijbswa/files/">file
2506         list</ulink> if unsure. Else, it must be set to the highest already available RPM
2507         release number for that version plus one.
2508       </para>
2509       <para>
2510         Then run:
2511       </para>
2512         <programlisting>
2513   cd current
2514   autoheader && autoconf && ./configure
2515 </programlisting>
2516       <para>
2517         Then do
2518       </para>
2519         <programlisting>
2520   make <replaceable class="parameter">dist</replaceable>-dist
2521 </programlisting>
2522       <para>
2523         To upload the package to Sourceforge, simply issue
2524       </para>
2525         <programlisting>
2526   make <replaceable class="parameter">dist</replaceable>-upload <replaceable class="parameter">rpm_packagerev</replaceable>
2527 </programlisting>
2528       <para>
2529         where <replaceable class="parameter">rpm_packagerev</replaceable> is the
2530         RPM release number as determined above.
2531         Go to the displayed URL and release the file publicly on Sourceforge.
2532         Use the release notes and change log from the source tarball package.
2533       </para>
2534     </sect3>
2535
2536     <sect3 id="newrelease-solaris"><title>Solaris</title>
2537       <para>
2538         Login to Sourceforge's compilefarm via ssh:
2539       </para>
2540         <programlisting>
2541   ssh cf.sourceforge.net
2542 </programlisting>
2543       <para>
2544         Choose the right operating system (not the Debian one).
2545         When logged in, <emphasis>make sure that you have freshly exported the right
2546         version into an empty directory</emphasis>. (See "Building and releasing
2547         packages" above). Then run:
2548       </para>
2549         <programlisting>
2550   cd current
2551   autoheader && autoconf && ./configure
2552 </programlisting>
2553       <para>
2554         Then run
2555       </para>
2556         <programlisting>
2557   gmake solaris-dist
2558 </programlisting>
2559       <para>
2560         which creates a gzip'ed tar archive. Sadly, you cannot use <command>make
2561         solaris-upload</command> on the Sourceforge machine (no ncftpput). You now have
2562         to manually upload the archive to Sourceforge's ftp server and release
2563         the file publicly. Use the release notes and Change Log from the
2564         source tarball package.
2565       </para>
2566     </sect3>
2567
2568     <sect3 id="NEWRELEASE-WINDOWS"><title>Windows</title>
2569     <!-- so annoying: docbook generated ids are UPPERCASE so
2570                 links to "whatever.html#idtag" DO NOT WORK!!
2571          They have to be "whatever.html#IDTAG".
2572          So be consistent and use uppercase on the definition.
2573       -->
2574       <para>
2575         Note that the docbook generated files might need some hand editing,
2576         so the Windows build makefile does not rebuild the docs.
2577       </para>
2578
2579       <para>
2580         First, <emphasis>make sure that you have freshly exported the right
2581         version into an empty directory</emphasis>. (See "Building and releasing
2582         packages" above).
2583         <!-- XXX  ??? are we still basing releases off a tarball???
2584           -->
2585       </para>
2586       <para>
2587         Then you can build the package.  This is fully automated, and is
2588         controlled by <filename>windows/GNUmakefile</filename>.
2589         All you need to do is:
2590       </para>
2591       <programlisting>
2592   cd windows
2593   make
2594 </programlisting>
2595       <para>
2596         Now you can manually rename <filename>privoxy_setup.exe</filename> to
2597         <filename>privoxy_setup_X.Y.Z.exe</filename>, and the <filename>build</filename>
2598         directory to <filename>privoxy_X.Y.Z</filename>.
2599         Create a .zip file of the newly renamed <filename>privoxy_X.Y.Z</filename> directory,
2600         GPG sign the installer and zip file,
2601       </para>
2602       <programlisting>
2603   $ gpg --armor --detach --sign <filename>privoxy_setup_X.Y.Z.exe</filename>
2604   $ gpg --armor --detach --sign <filename>privoxy_X.Y.Z.zip</filename>
2605 </programlisting>
2606       <para>
2607         and upload the files to SourceForge.
2608       </para>
2609
2610       <para>
2611         When releasing the package on SourceForge, use the release notes
2612         and Change Log from the source tarball package.
2613       </para>
2614     </sect3>
2615
2616     <sect3 id="newrelease-debian"><title>Debian</title>
2617       <para>
2618         First, <emphasis>make sure that you have freshly exported the
2619         right version into an empty directory</emphasis>. (See
2620         "Building and releasing packages" above).  Then add a log
2621         entry to <filename>debian/changelog</filename>, if it is not
2622         already there, for example by running:
2623       </para>
2624         <programlisting>
2625   debchange -v &p-version;-&p-status;-1 "New upstream version"
2626 </programlisting>
2627       <para>
2628         Then, run:
2629       </para>
2630         <programlisting>
2631   dpkg-buildpackage -rfakeroot -us -uc -b
2632 </programlisting>
2633       <para>
2634         This will create
2635         <filename>../privoxy_&p-version;-&p-status;-1_i386.deb</filename>
2636         which can be uploaded.  To upload the package to Sourceforge, simply
2637         issue
2638       </para>
2639         <programlisting>
2640   make debian-upload
2641 </programlisting>
2642     </sect3>
2643
2644     <sect3 id="newrelease-macosx"><title>Mac OS X</title>
2645       <para>
2646         First, <emphasis>make sure that you have freshly exported the right
2647         version into an empty directory</emphasis>. (See "Building and releasing
2648         packages" above).
2649       </para>
2650       <para>
2651         There are three modules available in the CVS repository backups for use on Mac
2652         OS X, though technically only two of them generate a release (the other
2653         can be used to install from source).
2654       </para>
2655       <sect4 id="OS-X-OSXPackageBuilder-module">
2656       <title>OSXPackageBuilder module</title>
2657         <para>
2658           The OSXPackageBuilder module generates OS X installer packages
2659           supporting all Macs running OS X 10.4 and above. Obtain it from Git as
2660           follows into a folder parallel to the exported privoxy source:
2661         </para>
2662           <programlisting>
2663   cvs -z3 -d:pserver:anonymous@ijbswa.cvs.sourceforge.net:/cvsroot/ijbswa co OSXPackageBuilder
2664 </programlisting>
2665         <para>
2666           The module contains complete instructions on its usage in the file
2667           <filename>OS X Package Builder HOWTO.txt</filename>.
2668         </para>
2669         <para>
2670           Once the package(s) have been generated, you can then upload them
2671           directly to the Files section of the Sourceforge project in the
2672           Macintosh (OS X) folder. Each new version release of Privoxy should
2673           have a new subfolder created in which to store its files. Please
2674           ensure that the folder contains a readme file that makes it clear
2675           which package is for whichversion of OS X.
2676         </para>
2677       </sect4>
2678       <sect4 id="OS-X-osxsetup-module">
2679       <title>osxsetup module (DEPRECATED)</title>
2680         <para>
2681           <emphasis>This module is deprecated since the installer it generates
2682           places all Privoxy files in one folder in a non-standard location, and
2683           supports only Intel Macs running OS X 10.6 or higher.</emphasis>
2684         </para>
2685         <para>
2686           Check out the module from Git as follows into a folder parallel to the
2687           exported privoxy source:
2688         </para>
2689           <programlisting>
2690   cvs -z3 -d:pserver:anonymous@ijbswa.cvs.sourceforge.net:/cvsroot/ijbswa co osxsetup
2691 </programlisting>
2692         <para>
2693           Then run:
2694         </para>
2695           <programlisting>
2696   cd osxsetup
2697   build
2698 </programlisting>
2699         <para>
2700           This will run <filename>autoheader</filename>, <filename>autoconf</filename>
2701           and <filename>configure</filename> as well as <filename>make</filename>.
2702           Finally, it will copy over the necessary files to the ./osxsetup/files
2703           directory for further processing by <filename>PackageMaker</filename>.
2704         </para>
2705         <para>
2706         Bring up PackageMaker with the PrivoxyPackage.pmsp definition file,
2707         modify the package name to match the release, and hit the "Create
2708         package" button. If you specify ./Privoxy.pkg as the output package
2709         name, you can then create the distributable zip file with the command:
2710         </para>
2711           <programlisting>
2712   zip -r privoxyosx_setup_x.y.z.zip Privoxy.pkg
2713 </programlisting>
2714         <para>
2715           You can then upload this file directly to the Files section of the
2716           Sourceforge project in the Macintosh (OS X) folder. Each new version
2717           release of Privoxy should have a new subfolder created in which to
2718           store its files.
2719           Please ensure that the folder contains a readme file that makes it
2720           clear which version(s) of OS X the package supports.
2721         </para>
2722       </sect4>
2723       <sect4 id="OS-X-macsetup-module">
2724       <title>macsetup module</title>
2725         <para>
2726           The macsetup module is ideal if you wish to build and install Privoxy
2727           from source on a single machine.
2728         </para>
2729         <para>
2730           Check out the module from Git as follows into a folder parallel to the
2731           exported privoxy source:
2732         </para>
2733           <programlisting>
2734   cvs -z3 -d:pserver:anonymous@ijbswa.cvs.sourceforge.net:/cvsroot/ijbswa co macsetup
2735 </programlisting>
2736         <para>
2737           The module contains complete instructions on its usage in its
2738           <filename>README</filename> file. The end result will be the
2739           exported version of Privoxy installed on the build machine.
2740         </para>
2741       </sect4>
2742     </sect3>
2743
2744     <sect3 id="newrelease-freebsd"><title>FreeBSD</title>
2745       <para>
2746         Update the www/privoxy port and submit a diff upstream.
2747         For details see the <ulink url="https://www.freebsd.org/doc/en_US.ISO8859-1/books/porters-handbook/">FreeBSD Porter's Handbook</ulink>.
2748       </para>
2749     </sect3>
2750    </sect2>
2751
2752    <sect2 id="releasing">
2753    <title>Uploading and Releasing Your Package</title>
2754     <para>
2755       After the package is ready, it is time to upload it
2756       to SourceForge, and go through the release steps. The upload
2757       is done via FTP:
2758     </para>
2759     <itemizedlist>
2760      <listitem>
2761       <para>
2762         Upload to: <ulink url="ftp://upload.sourceforge.net/incoming">ftp://upload.sourceforge.net/incoming</ulink>
2763       </para>
2764      </listitem>
2765      <listitem>
2766       <para>
2767        user: <literal>anonymous</literal>
2768       </para>
2769      </listitem>
2770      <listitem>
2771       <para>
2772        password: <literal>ijbswa-developers@lists.sourceforge.net</literal>
2773       </para>
2774      </listitem>
2775     </itemizedlist>
2776     <para>
2777      Or use the <command>make</command> targets as described above.
2778     </para>
2779     <para>
2780      Once this done go to
2781      <ulink url="https://sourceforge.net/project/admin/editpackages.php?group_id=11118">
2782                  https://sourceforge.net/project/admin/editpackages.php?group_id=11118</ulink>,
2783      making sure you are logged in. Find your target platform in the
2784      second column, and click <literal>Add Release</literal>. You will
2785      then need to create a new release for your package, using the format
2786      of <literal>$VERSION ($CODE_STATUS)</literal>, e.g. <emphasis>&p-version;
2787      (beta)</emphasis>.
2788     </para>
2789     <para>
2790      Now just follow the prompts. Be sure to add any appropriate Release
2791      notes. You should see your freshly uploaded packages in
2792      <quote>Step 2. Add Files To This Release</quote>. Check the
2793      appropriate box(es). Remember at each step to hit the
2794      <quote>Refresh/Submit</quote> buttons! You should now see your
2795      file(s) listed in Step 3. Fill out the forms with the appropriate
2796      information for your platform, being sure to hit <quote>Update</quote>
2797      for each file. If anyone is monitoring your platform, check the
2798      <quote>email</quote> box at the very bottom to notify them of
2799      the new package. This should do it!
2800     </para>
2801     <para>
2802      If you have made errors, or need to make changes, you can go through
2803      essentially the same steps, but select <literal>Edit Release</literal>,
2804      instead of <literal>Add Release</literal>.
2805     </para>
2806    </sect2>
2807
2808     <sect2 id="afterrelease">
2809     <title>After the Release</title>
2810      <para>
2811       When all (or: most of the) packages have been uploaded and made available,
2812       send an email to the
2813       <ulink url="mailto:privoxy-announce@lists.privoxy.org">announce mailing
2814       list</ulink>, Subject: "Version X.Y.Z available for download". Be sure to
2815       include the
2816       <ulink url="https://sourceforge.net/projects/ijbswa/files/">
2817       download location</ulink>, the release notes and the Changelog. Also, post an
2818       updated News item on the project page Sourceforge, and update the Home
2819       page and docs linked from the Home page (see below). Other news sites
2820       and release oriented sites, such as Freshmeat, should also be notified.
2821      </para>
2822      <para>
2823       Then update the source code for the next version to be released:
2824      </para>
2825      <itemizedlist>
2826       <listitem>
2827        <para>
2828         Increment the version number and change the code status to "UNRELEASED"
2829         in <filename>configure.in</filename>
2830        </para>
2831       </listitem>
2832       <listitem>
2833        <para>
2834         Rebuild configure (<quote><command>autoheader && autoconf</command></quote>)
2835         and GNUMakefile (<quote><command>./configure</command></quote>)
2836        </para>
2837       </listitem>
2838       <listitem>
2839        <para>
2840         <quote><command>make dok-release</command></quote> to update the sgml documentation source files.
2841        </para>
2842       </listitem>
2843       <listitem>
2844        <para>
2845         Commit all your changes.
2846        </para>
2847       </listitem>
2848      </itemizedlist>
2849
2850    </sect2>
2851
2852   </sect1>
2853
2854   <!--   ~~~~~       New section      ~~~~~     -->
2855   <sect1 id="webserver-update"><title>Update the Webserver</title>
2856    <para>
2857     The webserver should be updated at least with each stable release. When
2858     updating, please follow these steps to make sure that no broken links,
2859     inconsistent contents or permission problems will occur (as it has many
2860     times in the past!):
2861    </para>
2862    <para>
2863     If you have changed anything in the stable-branch documentation source
2864     SGML files, do:
2865    </para>
2866     <programlisting>
2867   make dok
2868 </programlisting>
2869    <para>
2870     That will generate <filename>doc/webserver/user-manual</filename>,
2871     <filename>doc/webserver/developer-manual</filename>,
2872     <filename>doc/webserver/faq</filename>,
2873     <filename>doc/webserver/index.html</filename> automatically.
2874    </para>
2875    <para>
2876     If you changed the manual page sources, generate
2877     <filename>doc/webserver/man-page/privoxy-man-page.html</filename>
2878     by running <quote><command>make man</command></quote>. (This is
2879     a separate target due to dependencies on some obscure perl scripts
2880     [now in Git, but not well tested]. See comments in <filename>GNUmakefile</filename>.)
2881    </para>
2882    <para>
2883     If you want to add new files to the webserver, create them locally in
2884     the <filename>doc/webserver/*</filename> directory (or
2885     create new directories under <filename>doc/webserver</filename>).
2886    </para>
2887    <para>
2888     Next, commit any changes from the above steps to Git. All set?
2889     If these are docs in the stable branch, then do:
2890    </para>
2891     <programlisting>
2892   make webserver
2893 </programlisting>
2894    <para>
2895     This will do the upload to <ulink url="https://www.privoxy.org/">the
2896     webserver</ulink> (www.privoxy.org) and ensure all files and directories
2897     there are group writable.
2898    </para>
2899    <para>
2900     Please do <emphasis>NOT</emphasis> use any other means of transferring
2901     files to the webserver to avoid permission problems. Also, please do not
2902     upload docs from development branches or versions. The publicly posted
2903     docs should be in sync with the last official release.
2904    </para>
2905   </sect1>
2906
2907   <!--
2908
2909   This program is free software; you can redistribute it
2910   and/or modify it under the terms of the GNU General
2911   Public License as published by the Free Software
2912   Foundation; either version 2 of the License, or (at
2913   your option) any later version.
2914
2915   This program is distributed in the hope that it will
2916   be useful, but WITHOUT ANY WARRANTY; without even the
2917   implied warranty of MERCHANTABILITY or FITNESS FOR A
2918   PARTICULAR PURPOSE.  See the GNU General Public
2919   License for more details.
2920
2921   The GNU General Public License should be included with
2922   this file.  If not, you can view it at
2923   http://www.gnu.org/copyleft/gpl.html
2924   or write to the Free Software Foundation, Inc., 59
2925   Temple Place - Suite 330, Boston, MA  02111-1307, USA.
2926
2927   -->
2928
2929 </article>