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