Debian ......: Roland Rosenfeld <roland@debian.org> (roro)
FreeBSD .....: Fabian Keil <fk@fabiankeil.de> (fabiankeil)
-OS/2 ........: David Schmidt <david__schmidt@users.sf.net> (david__schmidt)
Windows .....: Lee Rian <ler762@gmail.com> (ler762)
OS X (x86)...: Ian Silvester <iansilvester@fastmail.fm> (diem)
OS X (PPC)...: Tobias Netzel <tobias.netzel@gmail.com> (internetzel)
(Bytef *)buffer, *buffer_length, compression_level))
{
log_error(LOG_LEVEL_ERROR,
- "compress2() failed. Buffer size: %d, compression level: %d.",
+ "compress2() failed. Buffer size: %lu, compression level: %d.",
new_length, compression_level);
freez(compressed_buffer);
return NULL;
}
log_error(LOG_LEVEL_RE_FILTER,
- "Compressed content from %d to %d bytes. Compression level: %d",
+ "Compressed content from %lu to %lu bytes. Compression level: %d",
*buffer_length, new_length, compression_level);
*buffer_length = (size_t)new_length;
if (b->type == FT_CONTENT_FILTER)
{
unsigned long long executions;
- unsigned long long pages_modified;
+ unsigned long long response_bodies_modified;
unsigned long long hits;
- get_filter_statistics(b->name, &executions, &pages_modified, &hits);
+ get_filter_statistics(b->name, &executions, &response_bodies_modified, &hits);
snprintf(buf, sizeof(buf),
"<tr><td>%s</td><td style=\"text-align: right\">%llu</td>"
"<td style=\"text-align: right\">%llu</td>"
"<td style=\"text-align: right\">%llu</td><tr>\n",
- b->name, executions, pages_modified, hits);
+ b->name, executions, response_bodies_modified, hits);
if (!err) err = string_append(&statistics, buf);
}
{
struct client_specific_tag *next_tag = enabled_tags->next;
log_error(LOG_LEVEL_INFO,
- "Tag '%s' for client %s expired %u seconds ago. Deleting it.",
+ "Tag '%s' for client %s expired %ld seconds ago. Deleting it.",
enabled_tags->name, client_address,
(now - enabled_tags->end_of_life));
remove_tag_for_client(client_address, enabled_tags->name);
enabled_tags = get_tags_for_client(client_address);
while (enabled_tags != NULL)
{
- log_error(LOG_LEVEL_CGI, "Evaluating tag '%s' for client %s. End of life %d",
+ log_error(LOG_LEVEL_CGI, "Evaluating tag '%s' for client %s. End of life %ld",
enabled_tags->name, client_address, enabled_tags->end_of_life);
if (enabled_tags->end_of_life)
{
time_t time_left = enabled_tags->end_of_life - now;
/* Add a second to make sure the tag will have expired */
time_left++;
- log_error(LOG_LEVEL_CGI, "%d > %d?", next_timeout, time_left);
+ log_error(LOG_LEVEL_CGI, "%ld > %ld?", next_timeout, time_left);
if (next_timeout == 0 || next_timeout > time_left)
{
next_timeout = time_left;
privoxy_mutex_unlock(&client_tags_mutex);
- log_error(LOG_LEVEL_CGI, "Next timeout in %d seconds", next_timeout);
+ log_error(LOG_LEVEL_CGI, "Next timeout in %ld seconds", next_timeout);
return next_timeout;
{
add_tag_for_client(csp->client_address, tag_name, time_to_live);
log_error(LOG_LEVEL_INFO,
- "Tag '%s' enabled for client '%s'. TTL: %d.",
+ "Tag '%s' enabled for client '%s'. TTL: %ld.",
tag->name, csp->client_address, time_to_live);
}
dnl =================================================================
-if test "$EMXOS2" = yes || test "$host_os" = haiku; then
+if test "$host_os" = haiku; then
echo "Skipping user and group validity stuff.";
else
-privoxy (3.0.29~gitdbcfeb-1) UNRELEASED; urgency=medium
+privoxy (3.0.29~gitc62254-1) UNRELEASED; urgency=medium
* New upstream development version.
* Update all patches to new version.
incorporated upstream.
* d/copyright: use ./ prefix to upstream filenames, because orig.tar.gz
is build with a ./ prefix.
+ * Upgrade to debhelper v13.
+ * Rebuild privoxy-man-page.html.
+ * 38_SOURCE_DATE_EPOCH: Remove hardcoded SOURCE_DATE_EPOCH from
+ configure.in but use the date from debian/changelog.
+ * Remove 05_defaut_action since this is no longer needed.
+ * Tag all patches with Forwarded header.
* Compile --with-mbedtls to allow https-inspection.
* Adapt TLS/SSL settings to Debian FHS.
* Generate dirs with correct permissions for https-inspection.
- -- Roland Rosenfeld <roland@debian.org> Fri, 05 Jun 2020 18:13:53 +0200
+ -- Roland Rosenfeld <roland@debian.org> Fri, 04 Sep 2020 15:13:08 +0200
privoxy (3.0.28-3) unstable; urgency=medium
Priority: optional
Maintainer: Roland Rosenfeld <roland@debian.org>
Build-Depends: autoconf,
- debhelper-compat (= 12),
+ debhelper-compat (= 13),
docbook,
docbook-dsssl,
docbook-utils,
+++ /dev/null
-From: Roland Rosenfeld <roland@debian.org>
-Date: Sun, 15 Feb 2009 13:39:10 +0100
-Subject: Several changes/additons to default.action.
-
---- a/default.action.master
-+++ b/default.action.master
-@@ -2452,6 +2452,9 @@ schneegans.de/sv/\?url=referer
- #MASTER# REMARKS: Exclude per Debian bug report #377843
- # URL = http://blogs.msdn.com/wga/archive/2006/07/16/667063.aspx
- blogs.msdn.com
-+#MASTER# REMARKS: Exclude per Debian bug report #441256
-+#MASTER# PROBLEM-URL: http://www.memo.de/
-+www.memo.de
-
- {-filter{unsolicited-popups}}
- # Sticky Actions = -filter{unsolicited-popups}
-@@ -2510,6 +2513,11 @@ tr.anp.se/
- {+filter{tiny-textforms}}
- .sourceforge.net/tracker
-
-+{-filter{ie-exploits}}
-+#MASTER# REMARKS: Allow %01 and %02 in URLs as they are used in Amazon's
-+#MASTER# REMARKS: multi-page results see http://bugs.debian.org/243245
-+.amazon.de
-+
- {+downgrade-http-version}
- #MASTER# COMMENTS: This section not checked 10/17/06 HB
- #MASTER# REMARKS: This is work-around for CUPS http configuration.
From: Roland Rosenfeld <roland@debian.org>
Date: Fri, 05 Jun 2020 15:51:09 +0200
Subject: Several Debian specific changes to config file
+Forwarded: not-needed
--- a/config
+++ b/config
From: Roland Rosenfeld <roland@debian.org>
Date: Mon, 21 Apr 2003 11:11:31 +0200
Subject: Move man page from man section 1 to man section 8.
+Forwarded: not-needed
--- a/GNUmakefile.in
+++ b/GNUmakefile.in
Subject: Changes the 404 HTTP status code of the "No such Domain" template
to 502 Bad Gateway, which seems to be more correct according to
http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html
+Forwarded: not-needed
--- a/templates/no-such-domain
+++ b/templates/no-such-domain
Date: Sat, 23 Sep 2006 23:37:03 +0200
Subject: Change the global default from standard.Cautious to standard.Medium,
which is similar to the old 3.0.3 behavior and doesn't change too much.
+Forwarded: not-needed
--- a/match-all.action
+++ b/match-all.action
-@@ -11,7 +11,16 @@
+@@ -10,7 +10,16 @@
+client-header-tagger{css-requests} \
+client-header-tagger{image-requests} \
+client-header-tagger{range-requests} \
From: Roland Rosenfeld <roland@debian.org>
Date: Sat, 7 Oct 2006 13:12:13 +0200
Subject: Remove unnecessary linking against libnsl.
+Forwarded: not-needed
--- a/configure.in
+++ b/configure.in
Date: Tue, 18 May 2010 10:14:18 +0200
Subject: Work around bind problems on startup (Closes: #534735)
Bug-Debian: https://bugs.debian.org/534735
+Forwarded: not-needed
--- a/jbsockets.c
+++ b/jbsockets.c
From: Roland Rosenfeld <roland@debian.org>
Date: Thu, 24 Jan 2013 17:40:51 +0100
Subject: Replace all -- in man page by \-\- to make lintian happy.
+Forwarded: not-needed
--- a/GNUmakefile.in
+++ b/GNUmakefile.in
-@@ -537,8 +537,7 @@ man: dok-release
+@@ -544,8 +544,7 @@ man: dok-release
perl -pi.bak -e "s/\[ /\[/g;s/á/\\\\['a]/g;s/é/\\\\['e]/g" $(MAN_PAGE); \
perl -pi.bak -e "s/ö/\\\\[:o]/g" $(MAN_PAGE); \
perl -pi.bak -e 's/([ {])-([a-z])/$$1\\-$$2/g' $(MAN_PAGE); \
Date: Sat, 19 Sep 2015 15:05:41 +0200
Subject: Use Debian docbook2man-spec.pl (from docbook-utils) instead of local
copy, to make package reproducible.
+Forwarded: not-needed
--- a/GNUmakefile.in
+++ b/GNUmakefile.in
-@@ -532,7 +532,7 @@ dok-man:
+@@ -539,7 +539,7 @@ dok-man:
# target for man page generation!
man: dok-release
mkdir -p doc/source/temp && cd doc/source/temp && $(RM) * ;\
From: Roland Rosenfeld <roland@debian.org>
Date: Sun, 1 May 2016 14:21:22 +0200
Subject: Fix typo in man page privoxy-log-parser(1)
+Forwarded: not-needed
--- a/tools/privoxy-log-parser.pl
+++ b/tools/privoxy-log-parser.pl
-@@ -2709,7 +2709,7 @@ omitted, ANSI escape sequences are used
+@@ -2730,7 +2730,7 @@ omitted, ANSI escape sequences are used
This option is only intended to make embedding log excerpts in web pages easier.
It does not escape any input!
--- /dev/null
+From: Roland Rosenfeld <roland@debian.org>
+Date: Fri, 04 Sep 2020 16:30:48 +0200
+Subject: Remove hardcoded SOURCE_DATE_EPOCH from configure.in but use the date
+ from debian/changelog.
+Forwarded: not-necessary
+
+--- a/configure.in
++++ b/configure.in
+@@ -81,7 +81,7 @@ CODE_STATUS="stable"
+
+ dnl Timestamp (date +%s) used by the mtree-spec target.
+ dnl Should be updated before releases but forgetting it isn't critical.
+-SOURCE_DATE_EPOCH=1545411710
++dnl SOURCE_DATE_EPOCH=1545411710
+
+ dnl CODE_STATUS can be "alpha", "beta", "stable" or "UNRELEASED",
+ dnl and will be used for CGI output. Increment version number and
-05_defaut_action.patch
14_config.patch
15_mansection8.patch
17_502_no_such_domain.patch
33_manpage_hyphen.patch
34_system-docbook2man.patch
35_man-spelling.patch
+38_SOURCE_DATE_EPOCH.patch
env -u LANG LC_ALL=C.UTF-8 $(MAKE) dok
rm -f doc/webserver/user-manual/*.bak
env -u LANG LC_ALL=C.UTF-8 $(MAKE) man
+ env -u LANG LC_ALL=C.UTF-8 $(MAKE) man2html
override_dh_auto_clean:
# restore auto build documentation from source package:
+++ /dev/null
-include: https://salsa.debian.org/salsa-ci-team/pipeline/raw/master/salsa-ci.yml
-
-build:
- extends: .build-unstable
-
-reprotest:
- extends: .test-reprotest
-
-lintian:
- extends: .test-lintian
-
-autopkgtest:
- extends: .test-autopkgtest
-
-piuparts:
- extends: .test-piuparts
</para>
</sect3>
- <sect3 id="newrelease-os2"><title>OS/2</title>
- <para>
- First, <emphasis>make sure that you have freshly exported the right
- version into an empty directory</emphasis>. (See "Building and releasing
- packages" above). Then get the OS/2 Setup module:
- </para>
- <programlisting>
- cvs -z3 -d:pserver:anonymous@ijbswa.cvs.sourceforge.net:/cvsroot/ijbswa co os2setup
-</programlisting>
- <para>
- You will need a mix of development tools.
- The main compilation takes place with IBM Visual Age C++.
- Some ancillary work takes place with GNU tools, available from
- various sources like hobbes.nmsu.edu.
- Specifically, you will need <filename>autoheader</filename>,
- <filename>autoconf</filename> and <filename>sh</filename> tools.
- The packaging takes place with WarpIN, available from various sources, including
- its home page: <ulink url="http://www.xworkplace.org/">xworkplace</ulink>.
- </para>
- <para>
- Change directory to the <filename>os2setup</filename> directory.
- Edit the os2build.cmd file to set the final executable filename.
- For example,
- </para>
- <programlisting>
- installExeName='privoxyos2_setup_X.Y.Z.exe'
-</programlisting>
- <para>
- Next, edit the <filename>IJB.wis</filename> file so the release number matches
- in the <filename>PACKAGEID</filename> section:
- </para>
- <programlisting>
- PACKAGEID="Privoxy Team\Privoxy\Privoxy Package\X\Y\Z"
-</programlisting>
- <para>
- You're now ready to build. Run:
- </para>
- <programlisting>
- os2build
-</programlisting>
- <para>
- You will find the WarpIN-installable executable in the
- <filename>./files</filename> directory. Upload this anonymously to
- <filename>uploads.sourceforge.net/incoming</filename>, create a release
- for it, and you're done. Use the release notes and Change Log from the
- source tarball package.
- </para>
- </sect3>
-
<sect3 id="newrelease-solaris"><title>Solaris</title>
<para>
Login to Sourceforge's compilefarm via ssh:
</para>
<para>
- On systems that lack snprintf(), Privoxy is using a version
- written by Mark Martinec. On systems that lack strptime(),
- Privoxy is using the one from the GNU C Library written
- by Ulrich Drepper.
+ On systems that lack strptime(), Privoxy is using the one from the
+ GNU C Library written by Ulrich Drepper.
</para>
]]>
*
* Purpose : README file to give a short intro.
*
- * Copyright : Written by and Copyright (C) 2001-2018 the
+ * Copyright : Written by and Copyright (C) 2001-2020 the
* Privoxy team. https://www.privoxy.org/
*
* Based on the Internet Junkbuster originally written
Windows 95 and later versions (98, ME, 2000, XP, Vista, Windows 7 etc.),
GNU/Linux (RedHat, SuSE, Debian, Fedora, Gentoo, Slackware and others),
Mac OS X (10.4 and upwards on PPC and Intel processors),
- OS/2,
Haiku,
DragonFly, ElectroBSD, FreeBSD, NetBSD, OpenBSD,
Solaris,
</sect3>
-<!-- ~~~~~ New section ~~~~~ -->
-<sect3 id="installation-os2"><title>OS/2</title>
-
-<para>
- First, make sure that no previous installations of
- <application>Junkbuster</application> and / or
- <application>Privoxy</application> are left on your
- system. Check that no <application>Junkbuster</application>
- or <application>Privoxy</application> objects are in
- your startup folder.
-</para>
-
-<para>
- Then, just double-click the WarpIN self-installing archive, which will
- guide you through the installation process. A shadow of the
- <application>Privoxy</application> executable will be placed in your
- startup folder so it will start automatically whenever OS/2 starts.
-</para>
-
-<para>
- The directory you choose to install <application>Privoxy</application>
- into will contain all of the configuration files.
-</para>
-</sect3>
-
<!-- ~~~~~ New section ~~~~~ -->
<sect3 id="installation-mac"><title>Mac OS X</title>
<para>
</para>
</sect2>
-<sect2 id="start-os2">
-<title>OS/2</title>
-<para>
- During installation, <application>Privoxy</application> is configured to
- start automatically when the system restarts. You can start it manually by
- double-clicking on the <application>Privoxy</application> icon in the
- <application>Privoxy</application> folder.
-</para>
-</sect2>
-
<sect2 id="start-macosx">
<title>Mac OS X</title>
<para>
<title>Configuration Files Overview</title>
<para>
For Unix, *BSD and GNU/Linux, all configuration files are located in
- <filename>/etc/privoxy/</filename> by default. For MS Windows and OS/2
+ <filename>/etc/privoxy/</filename> by default. For MS Windows
these are all in the same directory as the
<application>Privoxy</application> executable. <![%p-not-stable;[ The name
and number of configuration files has changed from previous versions, and is
<listitem>
<para>
The <link linkend="config">main configuration file</link> is named <filename>config</filename>
- on GNU/Linux, Unix, BSD, and OS/2, and <filename>config.txt</filename>
+ on GNU/Linux, Unix, BSD, and <filename>config.txt</filename>
on Windows. This is a required file.
</para>
</listitem>
<dt>6.3.1. <a href="newrelease.html#PACK-GUIDELINES">Note on Privoxy Packaging</a></dt>
<dt>6.3.2. <a href="newrelease.html#NEWRELEASE-TARBALL">Source Tarball</a></dt>
<dt>6.3.3. <a href="newrelease.html#NEWRELEASE-RPM">SuSE, Conectiva or Red Hat RPM</a></dt>
- <dt>6.3.4. <a href="newrelease.html#NEWRELEASE-OS2">OS/2</a></dt>
- <dt>6.3.5. <a href="newrelease.html#NEWRELEASE-SOLARIS">Solaris</a></dt>
- <dt>6.3.6. <a href="newrelease.html#NEWRELEASE-WINDOWS">Windows</a></dt>
- <dt>6.3.7. <a href="newrelease.html#NEWRELEASE-DEBIAN">Debian</a></dt>
- <dt>6.3.8. <a href="newrelease.html#NEWRELEASE-MACOSX">Mac OS X</a></dt>
- <dt>6.3.9. <a href="newrelease.html#NEWRELEASE-FREEBSD">FreeBSD</a></dt>
+ <dt>6.3.4. <a href="newrelease.html#NEWRELEASE-SOLARIS">Solaris</a></dt>
+ <dt>6.3.5. <a href="newrelease.html#NEWRELEASE-WINDOWS">Windows</a></dt>
+ <dt>6.3.6. <a href="newrelease.html#NEWRELEASE-DEBIAN">Debian</a></dt>
+ <dt>6.3.7. <a href="newrelease.html#NEWRELEASE-MACOSX">Mac OS X</a></dt>
+ <dt>6.3.8. <a href="newrelease.html#NEWRELEASE-FREEBSD">FreeBSD</a></dt>
</dl>
</dd>
<dt>6.4. <a href="newrelease.html#RELEASING">Uploading and Releasing Your Package</a></dt>
the source tarball package.</p>
</div>
<div class="SECT3">
- <h3 class="SECT3"><a name="NEWRELEASE-OS2" id="NEWRELEASE-OS2">6.3.4. OS/2</a></h3>
- <p>First, <span class="emphasis"><i class="EMPHASIS">make sure that you have freshly exported the right version
- into an empty directory</i></span>. (See "Building and releasing packages" above). Then get the OS/2 Setup
- module:</p>
- <table border="0" bgcolor="#E0E0E0" width="100%">
- <tr>
- <td>
- <pre class=
- "PROGRAMLISTING"> cvs -z3 -d:pserver:anonymous@ijbswa.cvs.sourceforge.net:/cvsroot/ijbswa co os2setup</pre>
- </td>
- </tr>
- </table>
- <p>You will need a mix of development tools. The main compilation takes place with IBM Visual Age C++. Some
- ancillary work takes place with GNU tools, available from various sources like hobbes.nmsu.edu. Specifically,
- you will need <tt class="FILENAME">autoheader</tt>, <tt class="FILENAME">autoconf</tt> and <tt class=
- "FILENAME">sh</tt> tools. The packaging takes place with WarpIN, available from various sources, including its
- home page: <a href="http://www.xworkplace.org/" target="_top">xworkplace</a>.</p>
- <p>Change directory to the <tt class="FILENAME">os2setup</tt> directory. Edit the os2build.cmd file to set the
- final executable filename. For example,</p>
- <table border="0" bgcolor="#E0E0E0" width="100%">
- <tr>
- <td>
- <pre class="PROGRAMLISTING"> installExeName='privoxyos2_setup_X.Y.Z.exe'</pre>
- </td>
- </tr>
- </table>
- <p>Next, edit the <tt class="FILENAME">IJB.wis</tt> file so the release number matches in the <tt class=
- "FILENAME">PACKAGEID</tt> section:</p>
- <table border="0" bgcolor="#E0E0E0" width="100%">
- <tr>
- <td>
- <pre class="PROGRAMLISTING"> PACKAGEID="Privoxy Team\Privoxy\Privoxy Package\X\Y\Z"</pre>
- </td>
- </tr>
- </table>
- <p>You're now ready to build. Run:</p>
- <table border="0" bgcolor="#E0E0E0" width="100%">
- <tr>
- <td>
- <pre class="PROGRAMLISTING"> os2build</pre>
- </td>
- </tr>
- </table>
- <p>You will find the WarpIN-installable executable in the <tt class="FILENAME">./files</tt> directory. Upload
- this anonymously to <tt class="FILENAME">uploads.sourceforge.net/incoming</tt>, create a release for it, and
- you're done. Use the release notes and Change Log from the source tarball package.</p>
- </div>
- <div class="SECT3">
- <h3 class="SECT3"><a name="NEWRELEASE-SOLARIS" id="NEWRELEASE-SOLARIS">6.3.5. Solaris</a></h3>
+ <h3 class="SECT3"><a name="NEWRELEASE-SOLARIS" id="NEWRELEASE-SOLARIS">6.3.4. Solaris</a></h3>
<p>Login to Sourceforge's compilefarm via ssh:</p>
<table border="0" bgcolor="#E0E0E0" width="100%">
<tr>
release the file publicly. Use the release notes and Change Log from the source tarball package.</p>
</div>
<div class="SECT3">
- <h3 class="SECT3"><a name="NEWRELEASE-WINDOWS" id="NEWRELEASE-WINDOWS">6.3.6. Windows</a></h3>
+ <h3 class="SECT3"><a name="NEWRELEASE-WINDOWS" id="NEWRELEASE-WINDOWS">6.3.5. Windows</a></h3>
<p>Note that the docbook generated files might need some hand editing, so the Windows build makefile does not
rebuild the docs.</p>
<p>First, <span class="emphasis"><i class="EMPHASIS">make sure that you have freshly exported the right version
package.</p>
</div>
<div class="SECT3">
- <h3 class="SECT3"><a name="NEWRELEASE-DEBIAN" id="NEWRELEASE-DEBIAN">6.3.7. Debian</a></h3>
+ <h3 class="SECT3"><a name="NEWRELEASE-DEBIAN" id="NEWRELEASE-DEBIAN">6.3.6. Debian</a></h3>
<p>First, <span class="emphasis"><i class="EMPHASIS">make sure that you have freshly exported the right version
into an empty directory</i></span>. (See "Building and releasing packages" above). Then add a log entry to
<tt class="FILENAME">debian/changelog</tt>, if it is not already there, for example by running:</p>
</table>
</div>
<div class="SECT3">
- <h3 class="SECT3"><a name="NEWRELEASE-MACOSX" id="NEWRELEASE-MACOSX">6.3.8. Mac OS X</a></h3>
+ <h3 class="SECT3"><a name="NEWRELEASE-MACOSX" id="NEWRELEASE-MACOSX">6.3.7. Mac OS X</a></h3>
<p>First, <span class="emphasis"><i class="EMPHASIS">make sure that you have freshly exported the right version
into an empty directory</i></span>. (See "Building and releasing packages" above).</p>
<p>There are three modules available in the Git repository for use on Mac OS X, though technically only two of
them generate a release (the other can be used to install from source).</p>
<div class="SECT4">
- <h4 class="SECT4"><a name="OS-X-OSXPACKAGEBUILDER-MODULE" id="OS-X-OSXPACKAGEBUILDER-MODULE">6.3.8.1.
+ <h4 class="SECT4"><a name="OS-X-OSXPACKAGEBUILDER-MODULE" id="OS-X-OSXPACKAGEBUILDER-MODULE">6.3.7.1.
OSXPackageBuilder module</a></h4>
<p>The OSXPackageBuilder module generates OS X installer packages supporting all Macs running OS X 10.4 and
above. Obtain it from Git as follows into a folder parallel to the exported privoxy source:</p>
makes it clear which package is for whichversion of OS X.</p>
</div>
<div class="SECT4">
- <h4 class="SECT4"><a name="OS-X-OSXSETUP-MODULE" id="OS-X-OSXSETUP-MODULE">6.3.8.2. osxsetup module
+ <h4 class="SECT4"><a name="OS-X-OSXSETUP-MODULE" id="OS-X-OSXSETUP-MODULE">6.3.7.2. osxsetup module
(DEPRECATED)</a></h4>
<p><span class="emphasis"><i class="EMPHASIS">This module is deprecated since the installer it generates
places all Privoxy files in one folder in a non-standard location, and supports only Intel Macs running OS X
package supports.</p>
</div>
<div class="SECT4">
- <h4 class="SECT4"><a name="OS-X-MACSETUP-MODULE" id="OS-X-MACSETUP-MODULE">6.3.8.3. macsetup module</a></h4>
+ <h4 class="SECT4"><a name="OS-X-MACSETUP-MODULE" id="OS-X-MACSETUP-MODULE">6.3.7.3. macsetup module</a></h4>
<p>The macsetup module is ideal if you wish to build and install Privoxy from source on a single machine.</p>
<p>Check out the module from Git as follows into a folder parallel to the exported privoxy source:</p>
<table border="0" bgcolor="#E0E0E0" width="100%">
</div>
</div>
<div class="SECT3">
- <h3 class="SECT3"><a name="NEWRELEASE-FREEBSD" id="NEWRELEASE-FREEBSD">6.3.9. FreeBSD</a></h3>
+ <h3 class="SECT3"><a name="NEWRELEASE-FREEBSD" id="NEWRELEASE-FREEBSD">6.3.8. FreeBSD</a></h3>
<p>Update the www/privoxy port and submit a diff upstream. For details see the <a href=
"https://www.freebsd.org/doc/en_US.ISO8859-1/books/porters-handbook/" target="_top">FreeBSD Porter's
Handbook</a>.</p>
<h3 class="SECT2"><a name="WHICHOS" id="WHICHOS">2.2. Which operating systems are supported?</a></h3>
<p>At present, <span class="APPLICATION">Privoxy</span> is known to run on Windows 95 and later versions (98, ME,
2000, XP, Vista, Windows 7 etc.), GNU/Linux (RedHat, SuSE, Debian, Fedora, Gentoo, Slackware and others), Mac OS
- X (10.4 and upwards on PPC and Intel processors), OS/2, Haiku, DragonFly, ElectroBSD, FreeBSD, NetBSD, OpenBSD,
+ X (10.4 and upwards on PPC and Intel processors), Haiku, DragonFly, ElectroBSD, FreeBSD, NetBSD, OpenBSD,
Solaris, and various other flavors of Unix.</p>
<p>But any operating system that runs TCP/IP, can conceivably take advantage of <span class=
"APPLICATION">Privoxy</span> in a networked situation where <span class="APPLICATION">Privoxy</span> would run as
<h3>Silver sponsors</h3>
<p><a href="https://www.top10vpn.com">https://www.top10vpn.com</a></p>
<h3>Bronze sponsor</h3>
+ <p><a href="https://www.betrugstest.com/">https://www.betrugstest.com/</a></p>
<p><a href="https://www.vpncompare.co.uk/">https://www.vpncompare.co.uk/</a></p>
<h3>Becoming a Privoxy sponsor</h3>
<p>If you want to become a sponsor, please have a look at the <a title=
<p>The default profiles, and their associated actions, as pre-defined in <tt class=
"FILENAME">default.action</tt> are:</p>
<div class="TABLE">
- <a name="AEN3104" id="AEN3104"></a>
+ <a name="AEN3087" id="AEN3087"></a>
<p><b>Table 1. Default Configurations</b></p>
<table border="1" frame="border" rules="all" class="CALSTABLE">
<col width="1*" title="C1">
these. If not, you will get a friendly error message. Internet access is not necessary either.</p>
<ul>
<li>
- <p>Privoxy main page:</p><a name="AEN6303" id="AEN6303"></a>
+ <p>Privoxy main page:</p><a name="AEN6286" id="AEN6286"></a>
<blockquote class="BLOCKQUOTE">
<p><a href="http://config.privoxy.org/" target="_top">http://config.privoxy.org/</a></p>
</blockquote>
"APPLICATION">Privoxy</span>)</p>
</li>
<li>
- <p>View and toggle client tags:</p><a name="AEN6311" id="AEN6311"></a>
+ <p>View and toggle client tags:</p><a name="AEN6294" id="AEN6294"></a>
<blockquote class="BLOCKQUOTE">
<p><a href="http://config.privoxy.org/client-tags" target=
"_top">http://config.privoxy.org/client-tags</a></p>
</li>
<li>
<p>Show information about the current configuration, including viewing and editing of actions
- files:</p><a name="AEN6316" id="AEN6316"></a>
+ files:</p><a name="AEN6299" id="AEN6299"></a>
<blockquote class="BLOCKQUOTE">
<p><a href="http://config.privoxy.org/show-status" target=
"_top">http://config.privoxy.org/show-status</a></p>
</blockquote>
</li>
<li>
- <p>Show the browser's request headers:</p><a name="AEN6321" id="AEN6321"></a>
+ <p>Show the browser's request headers:</p><a name="AEN6304" id="AEN6304"></a>
<blockquote class="BLOCKQUOTE">
<p><a href="http://config.privoxy.org/show-request" target=
"_top">http://config.privoxy.org/show-request</a></p>
</blockquote>
</li>
<li>
- <p>Show which actions apply to a URL and why:</p><a name="AEN6326" id="AEN6326"></a>
+ <p>Show which actions apply to a URL and why:</p><a name="AEN6309" id="AEN6309"></a>
<blockquote class="BLOCKQUOTE">
<p><a href="http://config.privoxy.org/show-url-info" target=
"_top">http://config.privoxy.org/show-url-info</a></p>
<li>
<p>Toggle Privoxy on or off. This feature can be turned off/on in the main <tt class="FILENAME">config</tt>
file. When toggled <span class="QUOTE">"off"</span>, <span class="QUOTE">"Privoxy"</span> continues to run,
- but only as a pass-through proxy, with no actions taking place:</p><a name="AEN6334" id="AEN6334"></a>
+ but only as a pass-through proxy, with no actions taking place:</p><a name="AEN6317" id="AEN6317"></a>
<blockquote class="BLOCKQUOTE">
<p><a href="http://config.privoxy.org/toggle" target="_top">http://config.privoxy.org/toggle</a></p>
</blockquote>
- <p>Short cuts. Turn off, then on:</p><a name="AEN6338" id="AEN6338"></a>
+ <p>Short cuts. Turn off, then on:</p><a name="AEN6321" id="AEN6321"></a>
<blockquote class="BLOCKQUOTE">
<p><a href="http://config.privoxy.org/toggle?set=disable" target=
"_top">http://config.privoxy.org/toggle?set=disable</a></p>
- </blockquote><a name="AEN6341" id="AEN6341"></a>
+ </blockquote><a name="AEN6324" id="AEN6324"></a>
<blockquote class="BLOCKQUOTE">
<p><a href="http://config.privoxy.org/toggle?set=enable" target=
"_top">http://config.privoxy.org/toggle?set=enable</a></p>
<tr>
<td>
<pre class="SCREEN"> </pre>
- <h2 class="BRIDGEHEAD"><a name="AEN915"></a> Privoxy Menu</h2>
+ <h2 class="BRIDGEHEAD"><a name="AEN898"></a> Privoxy Menu</h2>
<pre><br></pre>
<table border="0">
<tbody>
<div class="SECT2">
<h2 class="SECT2"><a name="CONFOVERVIEW">6.2. Configuration Files Overview</a></h2>
<p>For Unix, *BSD and GNU/Linux, all configuration files are located in <tt class="FILENAME">/etc/privoxy/</tt>
- by default. For MS Windows and OS/2 these are all in the same directory as the <span class=
- "APPLICATION">Privoxy</span> executable. The name and number of configuration files has changed from previous
- versions, and is subject to change as development progresses.</p>
+ by default. For MS Windows these are all in the same directory as the <span class="APPLICATION">Privoxy</span>
+ executable. The name and number of configuration files has changed from previous versions, and is subject to
+ change as development progresses.</p>
<p>The installed defaults provide a reasonable starting point, though some settings may be aggressive by some
standards. For the time being, the principle configuration files are:</p>
<ul>
<li>
<p>The <a href="config.html">main configuration file</a> is named <tt class="FILENAME">config</tt> on
- GNU/Linux, Unix, BSD, and OS/2, and <tt class="FILENAME">config.txt</tt> on Windows. This is a required
- file.</p>
+ GNU/Linux, Unix, BSD, and <tt class="FILENAME">config.txt</tt> on Windows. This is a required file.</p>
</li>
<li>
<p><tt class="FILENAME">match-all.action</tt> is used to define which <span class="QUOTE">"actions"</span>
<dl>
<dt>2.1.1. <a href="installation.html#INSTALLATION-DEB">Debian and Ubuntu</a></dt>
<dt>2.1.2. <a href="installation.html#INSTALLATION-PACK-WIN">Windows</a></dt>
- <dt>2.1.3. <a href="installation.html#INSTALLATION-OS2">OS/2</a></dt>
- <dt>2.1.4. <a href="installation.html#INSTALLATION-MAC">Mac OS X</a></dt>
- <dt>2.1.5. <a href="installation.html#OS-X-INSTALL-FROM-PACKAGE">Installation from ready-built
+ <dt>2.1.3. <a href="installation.html#INSTALLATION-MAC">Mac OS X</a></dt>
+ <dt>2.1.4. <a href="installation.html#OS-X-INSTALL-FROM-PACKAGE">Installation from ready-built
package</a></dt>
- <dt>2.1.6. <a href="installation.html#OS-X-INSTALL-FROM-SOURCE">Installation from source</a></dt>
- <dt>2.1.7. <a href="installation.html#INSTALLATION-FREEBSD">FreeBSD</a></dt>
+ <dt>2.1.5. <a href="installation.html#OS-X-INSTALL-FROM-SOURCE">Installation from source</a></dt>
+ <dt>2.1.6. <a href="installation.html#INSTALLATION-FREEBSD">FreeBSD</a></dt>
</dl>
</dd>
<dt>2.2. <a href="installation.html#INSTALLATION-SOURCE">Building from Source</a></dt>
<dt>5.3. <a href="startup.html#START-WINDOWS">Windows</a></dt>
<dt>5.4. <a href="startup.html#START-UNICES">Generic instructions for Unix derivates (Solaris, NetBSD,
HP-UX etc.)</a></dt>
- <dt>5.5. <a href="startup.html#START-OS2">OS/2</a></dt>
- <dt>5.6. <a href="startup.html#START-MACOSX">Mac OS X</a></dt>
- <dt>5.7. <a href="startup.html#CMDOPTIONS">Command Line Options</a></dt>
+ <dt>5.5. <a href="startup.html#START-MACOSX">Mac OS X</a></dt>
+ <dt>5.6. <a href="startup.html#CMDOPTIONS">Command Line Options</a></dt>
</dl>
</dd>
<dt>6. <a href="configuration.html">Privoxy Configuration</a></dt>
files.</p>
</div>
<div class="SECT3">
- <h3 class="SECT3"><a name="INSTALLATION-OS2" id="INSTALLATION-OS2">2.1.3. OS/2</a></h3>
- <p>First, make sure that no previous installations of <span class="APPLICATION">Junkbuster</span> and / or
- <span class="APPLICATION">Privoxy</span> are left on your system. Check that no <span class=
- "APPLICATION">Junkbuster</span> or <span class="APPLICATION">Privoxy</span> objects are in your startup
- folder.</p>
- <p>Then, just double-click the WarpIN self-installing archive, which will guide you through the installation
- process. A shadow of the <span class="APPLICATION">Privoxy</span> executable will be placed in your startup
- folder so it will start automatically whenever OS/2 starts.</p>
- <p>The directory you choose to install <span class="APPLICATION">Privoxy</span> into will contain all of the
- configuration files.</p>
- </div>
- <div class="SECT3">
- <h3 class="SECT3"><a name="INSTALLATION-MAC" id="INSTALLATION-MAC">2.1.4. Mac OS X</a></h3>
+ <h3 class="SECT3"><a name="INSTALLATION-MAC" id="INSTALLATION-MAC">2.1.3. Mac OS X</a></h3>
<p>Installation instructions for the OS X platform depend upon whether you downloaded a ready-built
installation package (.pkg or .mpkg) or have downloaded the source code.</p>
</div>
<div class="SECT3">
- <h4 class="SECT3"><a name="OS-X-INSTALL-FROM-PACKAGE" id="OS-X-INSTALL-FROM-PACKAGE">2.1.5. Installation from
+ <h4 class="SECT3"><a name="OS-X-INSTALL-FROM-PACKAGE" id="OS-X-INSTALL-FROM-PACKAGE">2.1.4. Installation from
ready-built package</a></h4>
<p>The downloaded file will either be a .pkg (for OS X 10.5 upwards) or a bzipped .mpkg file (for OS X 10.4).
The former can be double-clicked as is and the installation will start; double-clicking the latter will unzip
<p>To uninstall, run /Applications/Privoxy/uninstall.command as sudo from an administrator account.</p>
</div>
<div class="SECT3">
- <h4 class="SECT3"><a name="OS-X-INSTALL-FROM-SOURCE" id="OS-X-INSTALL-FROM-SOURCE">2.1.6. Installation from
+ <h4 class="SECT3"><a name="OS-X-INSTALL-FROM-SOURCE" id="OS-X-INSTALL-FROM-SOURCE">2.1.5. Installation from
source</a></h4>
<p>To build and install the Privoxy source code on OS X you will need to obtain the macsetup module from the
Privoxy Sourceforge CVS repository (refer to Sourceforge help for details of how to set up a CVS client to have
<p>To uninstall, run the macsetup module's uninstall.sh as sudo from an administrator account.</p>
</div>
<div class="SECT3">
- <h3 class="SECT3"><a name="INSTALLATION-FREEBSD" id="INSTALLATION-FREEBSD">2.1.7. FreeBSD</a></h3>
+ <h3 class="SECT3"><a name="INSTALLATION-FREEBSD" id="INSTALLATION-FREEBSD">2.1.6. FreeBSD</a></h3>
<p>Privoxy is part of FreeBSD's Ports Collection, you can build and install it with <tt class="LITERAL">cd
/usr/ports/www/privoxy; make install clean</tt>.</p>
</div>
<p>Find <tt class="FILENAME">user.action</tt> in the top section, and click on <span class=
"QUOTE">"<span class="GUIBUTTON">Edit</span>"</span>:</p>
<div class="FIGURE">
- <a name="AEN674" id="AEN674"></a>
+ <a name="AEN663" id="AEN663"></a>
<p><b>Figure 1. Actions Files in Use</b></p>
<div class="MEDIAOBJECT">
<p><img src="files-in-use.jpg"></p>
<p>Please note that <span class="APPLICATION">Privoxy</span> can only proxy HTTP and HTTPS traffic. It will not
work with FTP or other protocols.</p>
<div class="FIGURE">
- <a name="AEN728" id="AEN728"></a>
+ <a name="AEN717" id="AEN717"></a>
<p><b>Figure 2. Proxy Configuration Showing Mozilla/Netscape HTTP and HTTPS (SSL) Settings</b></p>
<div class="MEDIAOBJECT">
<p><img src="proxy_setup.jpg"></p>
protocols"</span> is <span class="emphasis"><i class="EMPHASIS">UNCHECKED</i></span>. You want only HTTP and HTTPS
(SSL)!</p>
<div class="FIGURE">
- <a name="AEN772" id="AEN772"></a>
+ <a name="AEN761" id="AEN761"></a>
<p><b>Figure 3. Proxy Configuration Showing Internet Explorer HTTP and HTTPS (Secure) Settings</b></p>
<div class="MEDIAOBJECT">
<p><img src="proxy2.jpg"></p>
"APPLICATION">Privoxy</span> upon boot.</p>
</div>
<div class="SECT2">
- <h2 class="SECT2"><a name="START-OS2" id="START-OS2">5.5. OS/2</a></h2>
- <p>During installation, <span class="APPLICATION">Privoxy</span> is configured to start automatically when the
- system restarts. You can start it manually by double-clicking on the <span class="APPLICATION">Privoxy</span>
- icon in the <span class="APPLICATION">Privoxy</span> folder.</p>
- </div>
- <div class="SECT2">
- <h2 class="SECT2"><a name="START-MACOSX" id="START-MACOSX">5.6. Mac OS X</a></h2>
+ <h2 class="SECT2"><a name="START-MACOSX" id="START-MACOSX">5.5. Mac OS X</a></h2>
<p>The privoxy service will automatically start after a successful installation (and thereafter every time your
computer starts up) however you will need to configure your web browser(s) to use it. To do so, configure them to
use a proxy for HTTP and HTTPS at the address 127.0.0.1:8118.</p>
/Applications/Privoxy. They must be run from an administrator account, using sudo.</p>
</div>
<div class="SECT2">
- <h2 class="SECT2"><a name="CMDOPTIONS" id="CMDOPTIONS">5.7. Command Line Options</a></h2>
+ <h2 class="SECT2"><a name="CMDOPTIONS" id="CMDOPTIONS">5.6. Command Line Options</a></h2>
<p><span class="APPLICATION">Privoxy</span> may be invoked with the following command-line options:</p>
<ul>
<li>
/* For gettimeofday() */
#include <sys/time.h>
-#if !defined(_WIN32) && !defined(__OS2__)
+#if !defined(_WIN32)
#include <unistd.h>
-#endif /* !defined(_WIN32) && !defined(__OS2__) */
+#endif /* !defined(_WIN32) */
#include <errno.h>
#include <assert.h>
#define inline __inline
#endif /* def _MSC_VER */
-#ifdef __OS2__
-#include <sys/socket.h> /* For sock_errno */
-#define INCL_DOS
-#include <os2.h>
-#endif
-
#include "errlog.h"
#include "project.h"
#include "jcc.h"
#ifdef _WIN32
static char *w32_socket_strerr(int errcode, char *tmp_buf);
#endif
-#ifdef __OS2__
-static char *os2_socket_strerr(int errcode, char *tmp_buf);
-#endif
#ifdef MUTEX_LOCKS_AVAILABLE
static inline void lock_logfile(void)
if ((NULL == fp) && (logfp != NULL))
{
/*
- * Some platforms (like OS/2) don't allow us to open
- * the same file twice, therefore we give it another
- * shot after closing the old file descriptor first.
+ * Some platforms (like OS/2 (XXX: no longer supported)) don't
+ * allow us to open the same file twice, therefore we give it
+ * another shot after closing the old file descriptor first.
*
* We don't do it right away because it prevents us
* from logging the "can't open logfile" message to
{
long this_thread;
-#ifdef __OS2__
- PTIB ptib;
- APIRET ulrc; /* XXX: I have no clue what this does */
-#endif /* __OS2__ */
-
/* FIXME get current thread id */
#ifdef FEATURE_PTHREAD
this_thread = (long)pthread_self();
#endif /* def __MACH__ */
#elif defined(_WIN32)
this_thread = GetCurrentThreadId();
-#elif defined(__OS2__)
- ulrc = DosGetInfoBlocks(&ptib, NULL);
- if (ulrc == 0)
- this_thread = ptib -> tib_ptib2 -> tib2_ultid;
#else
/* Forking instead of threading. */
this_thread = 1;
/*
* XXX: Only necessary on platforms where multiple threads
* can write to the buffer at the same time because we
- * don't support mutexes (OS/2 for example).
+ * don't support mutexes.
+ * XXX: Are there any such platforms left now that OS/2 is gone?
*/
outbuf[length] = '\0';
continue;
#ifdef _WIN32
ival = WSAGetLastError();
format_string = w32_socket_strerr(ival, tempbuf);
-#elif __OS2__
- ival = sock_errno();
- if (ival != 0)
- {
- format_string = os2_socket_strerr(ival, tempbuf);
- }
- else
- {
- ival = errno;
- format_string = strerror(ival);
- }
#else /* ifndef _WIN32 */
ival = errno;
#ifdef HAVE_STRERROR
#endif /* def _WIN32 */
-#ifdef __OS2__
-/*********************************************************************
- *
- * Function : os2_socket_strerr
- *
- * Description : Translate the return value from sock_errno()
- * into a string.
- *
- * Parameters :
- * 1 : errcode = The return value from sock_errno().
- * 2 : tmp_buf = A temporary buffer that might be used to
- * store the string.
- *
- * Returns : String representing the error code. This may be
- * a global string constant or a string stored in
- * tmp_buf.
- *
- *********************************************************************/
-static char *os2_socket_strerr(int errcode, char *tmp_buf)
-{
-#define TEXT_FOR_ERROR(code,text) \
- if (errcode == code) \
- { \
- return #code " - " text; \
- }
-
- TEXT_FOR_ERROR(SOCEPERM , "Not owner.")
- TEXT_FOR_ERROR(SOCESRCH , "No such process.")
- TEXT_FOR_ERROR(SOCEINTR , "Interrupted system call.")
- TEXT_FOR_ERROR(SOCENXIO , "No such device or address.")
- TEXT_FOR_ERROR(SOCEBADF , "Bad file number.")
- TEXT_FOR_ERROR(SOCEACCES , "Permission denied.")
- TEXT_FOR_ERROR(SOCEFAULT , "Bad address.")
- TEXT_FOR_ERROR(SOCEINVAL , "Invalid argument.")
- TEXT_FOR_ERROR(SOCEMFILE , "Too many open files.")
- TEXT_FOR_ERROR(SOCEPIPE , "Broken pipe.")
- TEXT_FOR_ERROR(SOCEWOULDBLOCK , "Operation would block.")
- TEXT_FOR_ERROR(SOCEINPROGRESS , "Operation now in progress.")
- TEXT_FOR_ERROR(SOCEALREADY , "Operation already in progress.")
- TEXT_FOR_ERROR(SOCENOTSOCK , "Socket operation on non-socket.")
- TEXT_FOR_ERROR(SOCEDESTADDRREQ , "Destination address required.")
- TEXT_FOR_ERROR(SOCEMSGSIZE , "Message too long.")
- TEXT_FOR_ERROR(SOCEPROTOTYPE , "Protocol wrong type for socket.")
- TEXT_FOR_ERROR(SOCENOPROTOOPT , "Protocol not available.")
- TEXT_FOR_ERROR(SOCEPROTONOSUPPORT, "Protocol not supported.")
- TEXT_FOR_ERROR(SOCESOCKTNOSUPPORT, "Socket type not supported.")
- TEXT_FOR_ERROR(SOCEOPNOTSUPP , "Operation not supported.")
- TEXT_FOR_ERROR(SOCEPFNOSUPPORT , "Protocol family not supported.")
- TEXT_FOR_ERROR(SOCEAFNOSUPPORT , "Address family not supported by protocol family.")
- TEXT_FOR_ERROR(SOCEADDRINUSE , "Address already in use.")
- TEXT_FOR_ERROR(SOCEADDRNOTAVAIL , "Can't assign requested address.")
- TEXT_FOR_ERROR(SOCENETDOWN , "Network is down.")
- TEXT_FOR_ERROR(SOCENETUNREACH , "Network is unreachable.")
- TEXT_FOR_ERROR(SOCENETRESET , "Network dropped connection on reset.")
- TEXT_FOR_ERROR(SOCECONNABORTED , "Software caused connection abort.")
- TEXT_FOR_ERROR(SOCECONNRESET , "Connection reset by peer.")
- TEXT_FOR_ERROR(SOCENOBUFS , "No buffer space available.")
- TEXT_FOR_ERROR(SOCEISCONN , "Socket is already connected.")
- TEXT_FOR_ERROR(SOCENOTCONN , "Socket is not connected.")
- TEXT_FOR_ERROR(SOCESHUTDOWN , "Can't send after socket shutdown.")
- TEXT_FOR_ERROR(SOCETOOMANYREFS , "Too many references: can't splice.")
- TEXT_FOR_ERROR(SOCETIMEDOUT , "Operation timed out.")
- TEXT_FOR_ERROR(SOCECONNREFUSED , "Connection refused.")
- TEXT_FOR_ERROR(SOCELOOP , "Too many levels of symbolic links.")
- TEXT_FOR_ERROR(SOCENAMETOOLONG , "File name too long.")
- TEXT_FOR_ERROR(SOCEHOSTDOWN , "Host is down.")
- TEXT_FOR_ERROR(SOCEHOSTUNREACH , "No route to host.")
- TEXT_FOR_ERROR(SOCENOTEMPTY , "Directory not empty.")
- TEXT_FOR_ERROR(SOCEOS2ERR , "OS/2 Error.")
-
- sprintf(tmp_buf, "(error number %d)", errcode);
- return tmp_buf;
-}
-#endif /* def __OS2__ */
-
-
/*
Local Variables:
tab-width: 3
#include <assert.h>
#ifndef _WIN32
-#ifndef __OS2__
#include <unistd.h>
-#endif /* ndef __OS2__ */
#include <netinet/in.h>
#else
#include <winsock2.h>
#endif /* ndef _WIN32 */
-#ifdef __OS2__
-#include <utils.h>
-#endif /* def __OS2__ */
-
#include "project.h"
#include "filters.h"
#include "encode.h"
if (b->dynamic) pcrs_free_joblist(joblist);
log_error(LOG_LEVEL_RE_FILTER,
- "filtering %s%s (size %d) with \'%s\' produced %d hits (new size %d).",
+ "filtering %s%s (size %lu) with \'%s\' produced %d hits (new size %lu).",
csp->http->hostport, csp->http->path, prev_size, b->name, current_hits, size);
#ifdef FEATURE_EXTENDED_STATISTICS
update_filter_statistics(b->name, current_hits);
*/
if ((*size != 0) && fwrite(content, *size, 1, fp) != 1)
{
- log_error(LOG_LEVEL_ERROR, "fwrite(..., %d, 1, ..) failed: %E", *size);
+ log_error(LOG_LEVEL_ERROR, "fwrite(..., %lu, 1, ..) failed: %E", *size);
unlink(file_name);
fclose(fp);
return NULL;
{
log_error(LOG_LEVEL_RE_FILTER,
"Executing '%s' resulted in return value %d. "
- "Read %d of up to %d bytes.", name, (ret >> 8), new_size, *size);
+ "Read %lu of up to %lu bytes.", name, (ret >> 8), new_size, *size);
}
unlink(file_name);
}
else
{
- log_error(LOG_LEVEL_DEANIMATE, "Success! GIF shrunk from %d bytes to %d.", size, out->offset);
+ log_error(LOG_LEVEL_DEANIMATE,
+ "Success! GIF shrunk from %lu bytes to %lu.", size, out->offset);
}
csp->content_length = out->offset;
csp->flags |= CSP_FLAG_MODIFIED;
{
log_error(LOG_LEVEL_ERROR,
"Chunk size %u exceeds buffered data left. "
- "Already digested %u of %u buffered bytes.",
- chunksize, (unsigned int)newsize, (unsigned int)*size);
+ "Already digested %lu of %lu buffered bytes.",
+ chunksize, newsize, *size);
return JB_ERR_PARSE;
}
}
/* XXX: Should get its own loglevel. */
- log_error(LOG_LEVEL_RE_FILTER, "De-chunking successful. Shrunk from %d to %d", *size, newsize);
+ log_error(LOG_LEVEL_RE_FILTER,
+ "De-chunking successful. Shrunk from %lu to %lu", *size, newsize);
*size = newsize;
{
char *filter;
unsigned long long executions;
- unsigned long long pages_modified;
+ unsigned long long response_bodies_modified;
unsigned long long hits;
struct filter_statistics_entry *next;
entry->executions++;
if (hits != 0)
{
- entry->pages_modified++;
+ entry->response_bodies_modified++;
entry->hits += (unsigned)hits;
}
break;
* Parameters :
* 1 : filter = Name of the filter to get statistics for.
* 2 : executions = Storage for the execution count.
- * 3 : pages_modified = Storage for the number of modified pages.
+ * 3 : response_bodies_modified = Storage for the number
+ * of modified response bodies.
* 4 : hits = Storage for the number of hits.
*
* Returns : void
*
*********************************************************************/
void get_filter_statistics(const char *filter, unsigned long long *executions,
- unsigned long long *pages_modified,
+ unsigned long long *response_bodies_modified,
unsigned long long *hits)
{
struct filter_statistics_entry *entry;
if (!strcmp(entry->filter, filter))
{
*executions = entry->executions;
- *pages_modified = entry->pages_modified;
+ *response_bodies_modified = entry->response_bodies_modified;
*hits = entry->hits;
break;
}
#include <netdb.h>
#endif /* def __BEOS__ */
-#ifdef __OS2__
-#include <utils.h>
-#endif /* def __OS2__ */
-
#include "project.h"
#include "jcc.h"
#include "errlog.h"
{
log_error(LOG_LEVEL_CONNECT,
"The connection to %s:%d in slot %d timed out. "
- "Closing socket %d. Timeout is: %d. Assumed latency: %d.",
+ "Closing socket %d. Timeout is: %d. Assumed latency: %ld.",
reusable_connection[slot].host,
reusable_connection[slot].port, slot,
reusable_connection[slot].sfd,
reusable_connection[slot].in_use = TRUE;
sfd = reusable_connection[slot].sfd;
log_error(LOG_LEVEL_CONNECT,
- "Found reusable socket %d for %s:%d in slot %d. Timestamp made %d "
+ "Found reusable socket %d for %s:%d in slot %d. Timestamp made %ld "
"seconds ago. Timeout: %d. Latency: %d. Requests served: %d",
sfd, reusable_connection[slot].host, reusable_connection[slot].port,
slot, time(NULL) - reusable_connection[slot].timestamp,
header_length= strlen(client_headers);
log_error(LOG_LEVEL_CONNECT,
- "Optimistically sending %d bytes of client headers intended for %s",
+ "Optimistically sending %lu bytes of client headers intended for %s",
header_length, csp->http->hostport);
if (write_socket(sfd, client_headers, header_length))
#else
-#ifndef __OS2__
#include <unistd.h>
-#endif
#include <sys/time.h>
#include <netinet/in.h>
#include <sys/ioctl.h>
#ifndef __BEOS__
#include <netinet/tcp.h>
-#ifndef __OS2__
#include <arpa/inet.h>
-#endif
#else
#include <socket.h>
#endif
-#if defined(__EMX__) || defined (__OS2__)
-#include <sys/select.h> /* OS/2/EMX needs a little help with select */
-#ifdef __OS2__
-#include <nerrno.h>
-#endif
-#endif
-
#endif
#ifdef HAVE_POLL
fd_set wfds;
struct timeval timeout;
#endif
-#if !defined(_WIN32) && !defined(__BEOS__) && !defined(__OS2__)
+#if !defined(_WIN32) && !defined(__BEOS__)
int flags;
#endif
int connect_failed;
if (block_acl(dst, csp))
{
-#ifdef __OS2__
- socket_error = errno = SOCEPERM;
-#else
socket_error = errno = EPERM;
-#endif
continue;
}
#endif /* def FEATURE_ACL */
set_no_delay_flag(fd);
-#if !defined(_WIN32) && !defined(__BEOS__) && !defined(__OS2__)
+#if !defined(_WIN32) && !defined(__BEOS__)
if ((flags = fcntl(fd, F_GETFL, 0)) != -1)
{
flags |= O_NDELAY;
fcntl(fd, F_SETFL, flags);
}
-#endif /* !defined(_WIN32) && !defined(__BEOS__) && !defined(__OS2__) */
+#endif /* !defined(_WIN32) && !defined(__BEOS__) */
connect_failed = 0;
while (connect(fd, rp->ai_addr, rp->ai_addrlen) == JB_INVALID_SOCKET)
{
-#ifdef __OS2__
- errno = sock_errno();
-#endif /* __OS2__ */
-
#ifdef _WIN32
if (errno == WSAEINPROGRESS)
#else /* ifndef _WIN32 */
if (errno == EINPROGRESS)
-#endif /* ndef _WIN32 || __OS2__ */
+#endif /* ndef _WIN32 */
{
break;
}
continue;
}
-#if !defined(_WIN32) && !defined(__BEOS__) && !defined(__OS2__)
+#if !defined(_WIN32) && !defined(__BEOS__)
if (flags != -1)
{
flags &= ~O_NDELAY;
fcntl(fd, F_SETFL, flags);
}
-#endif /* !defined(_WIN32) && !defined(__BEOS__) && !defined(__OS2__) */
+#endif /* !defined(_WIN32) && !defined(__BEOS__) */
#ifdef HAVE_POLL
poll_fd[0].fd = fd;
fd_set wfds;
struct timeval tv[1];
#endif
-#if !defined(_WIN32) && !defined(__BEOS__) && !defined(__OS2__)
+#if !defined(_WIN32) && !defined(__BEOS__)
int flags;
#endif
if (block_acl(dst, csp))
{
-#ifdef __OS2__
- errno = SOCEPERM;
-#else
errno = EPERM;
-#endif
return(JB_INVALID_SOCKET);
}
#endif /* def FEATURE_ACL */
set_no_delay_flag(fd);
-#if !defined(_WIN32) && !defined(__BEOS__) && !defined(__OS2__)
+#if !defined(_WIN32) && !defined(__BEOS__)
if ((flags = fcntl(fd, F_GETFL, 0)) != -1)
{
flags |= O_NDELAY;
mark_socket_for_close_on_execute(fd);
#endif
}
-#endif /* !defined(_WIN32) && !defined(__BEOS__) && !defined(__OS2__) */
+#endif /* !defined(_WIN32) && !defined(__BEOS__) */
while (connect(fd, (struct sockaddr *) & inaddr, sizeof inaddr) == JB_INVALID_SOCKET)
{
#ifdef _WIN32
if (errno == WSAEINPROGRESS)
-#elif __OS2__
- if (sock_errno() == EINPROGRESS)
#else /* ifndef _WIN32 */
if (errno == EINPROGRESS)
-#endif /* ndef _WIN32 || __OS2__ */
+#endif /* ndef _WIN32 */
{
break;
}
-#ifdef __OS2__
- if (sock_errno() != EINTR)
-#else
if (errno != EINTR)
-#endif /* __OS2__ */
{
close_socket(fd);
return(JB_INVALID_SOCKET);
}
}
-#if !defined(_WIN32) && !defined(__BEOS__) && !defined(__OS2__)
+#if !defined(_WIN32) && !defined(__BEOS__)
if (flags != -1)
{
flags &= ~O_NDELAY;
fcntl(fd, F_SETFL, flags);
}
-#endif /* !defined(_WIN32) && !defined(__BEOS__) && !defined(__OS2__) */
+#endif /* !defined(_WIN32) && !defined(__BEOS__) */
#ifdef HAVE_POLL
poll_fd[0].fd = fd;
return (send(fd, buf, (int)len, 0) != (int)len);
#elif defined(__BEOS__)
return (send(fd, buf, len, 0) != len);
-#elif defined(__OS2__)
- /*
- * Break the data up into SOCKET_SEND_MAX chunks for sending...
- * OS/2 seemed to complain when the chunks were too large.
- */
-#define SOCKET_SEND_MAX 65000
- {
- int send_len, send_rc = 0, i = 0;
- while ((i < len) && (send_rc != -1))
- {
- if ((i + SOCKET_SEND_MAX) > len)
- send_len = len - i;
- else
- send_len = SOCKET_SEND_MAX;
- send_rc = send(fd,(char*)buf + i, send_len, 0);
- if (send_rc == -1)
- return 1;
- i = i + send_len;
- }
- return 0;
- }
#else
return (write(fd, buf, len) != len);
#endif
#if defined(_WIN32)
ret = recv(fd, buf, len, 0);
-#elif defined(__BEOS__) || defined(__OS2__)
+#elif defined(__BEOS__)
ret = recv(fd, buf, (size_t)len, 0);
#else
ret = (int)read(fd, buf, (size_t)len);
memset(&timeout, 0, sizeof(timeout));
timeout.tv_sec = seconds_to_wait;
-#ifdef __OS2__
- /* Copy and pasted from jcc.c ... */
- memset(&rfds, 0, sizeof(fd_set));
-#else
FD_ZERO(&rfds);
-#endif
FD_SET(fd, &rfds);
n = select(fd+1, &rfds, NULL, NULL, &timeout);
{
#if defined(_WIN32) || defined(__BEOS__)
closesocket(fd);
-#elif defined(__OS2__)
- soclose(fd);
#else
close(fd);
#endif
struct sockaddr_in server;
struct hostent *host = NULL;
#endif /* HAVE_RFC2553 */
-#if defined(_WIN32) || defined(__OS2__)
+#if defined(_WIN32)
/* according to accept_connection() this fixes a warning. */
int s_length, s_length_provided;
#else
struct sockaddr_in client;
#endif
jb_socket afd;
-#if defined(_WIN32) || defined(__OS2__)
+#if defined(_WIN32)
/* Weirdness - fix a warning. */
int c_length;
#else
{
log_error(LOG_LEVEL_ERROR,
"Server name (%s) and port number (%d) ASCII decimal representation"
- "don't fit into %d bytes",
+ "don't fit into %lu bytes",
host_addr, csp->config->hport[i], listen_addr_size);
return 0;
}
#else /* ifndef _WIN32 */
-# if !defined (__OS2__)
# include <unistd.h>
# include <sys/wait.h>
-# endif /* ndef __OS2__ */
# include <sys/time.h>
# include <sys/stat.h>
# include <sys/ioctl.h>
# include <OS.h> /* declarations for threads and stuff. */
# endif
-# if defined(__EMX__) || defined(__OS2__)
-# include <sys/select.h> /* OS/2/EMX needs a little help with select */
-# endif
-# ifdef __OS2__
-#define INCL_DOS
-# include <os2.h>
-# endif
-
#ifdef HAVE_POLL
#ifdef __GLIBC__
#include <sys/poll.h>
int g_terminate = 0;
#endif
-#if !defined(_WIN32) && !defined(__OS2__)
+#if !defined(_WIN32)
static void sig_handler(int the_signal);
#endif
static int client_protocol_is_unsupported(struct client_state *csp, char *req);
#define sleep(N) Sleep(((N) * 1000))
#endif
-#ifdef __OS2__
-#define sleep(N) DosSleep(((N) * 100))
-#endif
-
#ifdef FUZZ
int process_fuzzed_input(char *fuzz_input_type, char *fuzz_input_file);
void show_fuzz_usage(const char *name);
*
* here?
*/
-#if !defined(_WIN32) && !defined(__OS2__)
+#if !defined(_WIN32)
/*********************************************************************
*
* Function : sig_handler
{
log_error(LOG_LEVEL_CRUNCH, "%s: https://%s%s", crunch_reason(rsp),
http->hostport, http->path);
- log_error(LOG_LEVEL_CLF, "%s - - [%T] \"%s https://%s%s %s\" %s %llu",
+ log_error(LOG_LEVEL_CLF, "%s - - [%T] \"%s https://%s%s %s\" %s %lu",
csp->ip_addr_str, http->gpc, http->hostport, http->path,
http->version, status_code, rsp->content_length);
}
#endif
{
log_error(LOG_LEVEL_CRUNCH, "%s: %s", crunch_reason(rsp), http->url);
- log_error(LOG_LEVEL_CLF, "%s - - [%T] \"%s\" %s %u",
+ log_error(LOG_LEVEL_CLF, "%s - - [%T] \"%s\" %s %lu",
csp->ip_addr_str, http->ocmd, status_code, rsp->content_length);
}
/* Write the answer to the client */
return JB_ERR_PARSE;
}
log_error(LOG_LEVEL_CONNECT,
- "Chunked client body completely read. Length: %d", body_length);
+ "Chunked client body completely read. Length: %lu", body_length);
csp->expected_client_content_length = body_length;
return JB_ERR_OK;
if (csp->expected_client_content_length < flushed)
{
log_error(LOG_LEVEL_ERROR,
- "Flushed %d bytes of request body while only expecting %llu",
+ "Flushed %ld bytes of request body while only expecting %llu",
flushed, csp->expected_client_content_length);
csp->expected_client_content_length = 0;
}
else
{
log_error(LOG_LEVEL_CONNECT,
- "Flushed %d bytes of request body while expecting %llu",
+ "Flushed %ld bytes of request body while expecting %llu",
flushed, csp->expected_client_content_length);
csp->expected_client_content_length -= (unsigned)flushed;
if (receive_and_send_encrypted_post_data(csp))
else
{
log_error(LOG_LEVEL_CONNECT,
- "Flushed %d bytes of request body", flushed);
+ "Flushed %ld bytes of request body", flushed);
}
}
* failures etc.
*
* If a connection to the server has already been
- * opened it is reused unless the request is blocked.
+ * opened it is reused unless the request is blocked
+ * or the forwarder changed.
*
* If a connection to the server has not yet been
- * opened (because the previous request was crunched)
- * the connection is dropped so that the client retries
- * on a fresh one.
- *
- * XXX: Forwarding settings are currently ignored.
+ * opened (because the previous request was crunched),
+ * or the forwarder changed, the connection is dropped
+ * so that the client retries on a fresh one.
*
* Parameters :
* 1 : csp = Current client state (buffers, headers, etc...)
*********************************************************************/
static void continue_https_chat(struct client_state *csp)
{
+ const struct forward_spec *fwd;
+
if (JB_ERR_OK != process_encrypted_request(csp))
{
return;
csp->flags &= ~CSP_FLAG_CLIENT_CONNECTION_KEEP_ALIVE;
return;
}
+ assert(csp->server_connection.sfd != JB_INVALID_SOCKET);
+
+ fwd = forward_url(csp, csp->http);
+ if (!connection_destination_matches(&csp->server_connection, csp->http, fwd))
+ {
+ log_error(LOG_LEVEL_CONNECT,
+ "Dropping the client connection on socket %d with "
+ "server socket %d connected to %s. The forwarder has changed.",
+ csp->cfd, csp->server_connection.sfd, csp->server_connection.host);
+ csp->flags &= ~CSP_FLAG_CLIENT_CONNECTION_KEEP_ALIVE;
+ return;
+ }
+
+ log_error(LOG_LEVEL_CONNECT,
+ "Reusing server socket %d connected to %s. Requests already sent: %u.",
+ csp->server_connection.sfd, csp->server_connection.host,
+ csp->server_connection.requests_sent_total);
+
if (send_https_request(csp))
{
/*
csp->cfd);
return;
}
+ csp->server_connection.requests_sent_total++;
handle_established_connection(csp);
freez(csp->receive_buffer);
}
for (;;)
{
#ifndef HAVE_POLL
-#ifdef __OS2__
- /*
- * FD_ZERO here seems to point to an errant macro which crashes.
- * So do this by hand for now...
- */
- memset(&rfds,0x00,sizeof(fd_set));
-#else
FD_ZERO(&rfds);
-#endif
#ifdef FEATURE_CONNECTION_KEEP_ALIVE
if (!watch_client_socket)
{
{
log_error(LOG_LEVEL_CONNECT,
"Done reading from server. Content length: %llu as expected. "
- "Bytes most recently read: %d.",
+ "Bytes most recently read: %ld.",
byte_count, len);
}
else
{
log_error(LOG_LEVEL_CONNECT,
"Done reading from server. Expected content length: %llu. "
- "Actual content length: %llu. Bytes most recently read: %d.",
+ "Actual content length: %llu. Bytes most recently read: %ld.",
csp->expected_content_length, byte_count, len);
}
len = 0;
csp->expected_client_content_length -= (unsigned)len;
log_error(LOG_LEVEL_CONNECT,
"Expected client content length set to %llu "
- "after reading %d bytes.",
+ "after reading %ld bytes.",
csp->expected_client_content_length, len);
if (csp->expected_client_content_length == 0)
{
*/
log_error(LOG_LEVEL_CONNECT,
"Continuing buffering server headers from socket %d. "
- "Bytes most recently read: %d.", csp->cfd, len);
+ "Bytes most recently read: %ld.", csp->cfd, len);
continue;
}
}
/* decide how to route the HTTP request */
fwd = forward_url(csp, http);
- if (NULL == fwd)
- {
- log_error(LOG_LEVEL_FATAL, "gateway spec is NULL!?!? This can't happen!");
- /* Never get here - LOG_LEVEL_FATAL causes program exit */
- return;
- }
#ifdef FEATURE_HTTPS_INSPECTION
/*
assert(bytes_to_shift > 0);
assert(data_length > 0);
- log_error(LOG_LEVEL_CONNECT, "Shifting %d pipelined bytes by %d bytes",
+ log_error(LOG_LEVEL_CONNECT, "Shifting %lu pipelined bytes by %ld bytes",
data_length, bytes_to_shift);
memmove(csp->client_iob->buf, csp->client_iob->cur, data_length);
csp->client_iob->cur = csp->client_iob->buf;
* are handled when and where they occur without relying
* on a signal.
*/
-#if !defined(_WIN32) && !defined(__OS2__)
+#if !defined(_WIN32)
{
int idx;
const int catched_signals[] = { SIGTERM, SIGINT, SIGHUP };
for (;;)
#endif
{
-#if !defined(FEATURE_PTHREAD) && !defined(_WIN32) && !defined(__BEOS__) && !defined(__OS2__)
+#if !defined(FEATURE_PTHREAD) && !defined(_WIN32) && !defined(__BEOS__)
while (waitpid(-1, NULL, WNOHANG) > 0)
{
/* zombie children */
csp);
#endif
-#if defined(__OS2__) && !defined(SELECTED_ONE_OPTION)
-#define SELECTED_ONE_OPTION
- child_id = _beginthread(
- (void(* _Optlink)(void*))serve,
- NULL,
- 64 * 1024,
- csp);
-#endif
-
#if defined(__BEOS__) && !defined(SELECTED_ONE_OPTION)
#define SELECTED_ONE_OPTION
{
#endif
#include <string.h>
-#if !defined(_WIN32) && !defined(__OS2__)
+#if !defined(_WIN32)
#include <unistd.h>
#endif
#else /* ifndef _WIN32 */
-#ifndef __OS2__
# include <unistd.h>
# include <sys/wait.h>
-#endif
# include <sys/time.h>
# include <sys/stat.h>
# include <signal.h>
*
* On platforms were we use poll() we don't have to enforce
* an upper connection limit either.
- *
- * XXX: Do OS/2 etc. belong here as well?
*/
if (max_client_connections < 1)
{
if (config->receive_buffer_size < BUFFER_SIZE)
{
log_error(LOG_LEVEL_INFO,
- "receive-buffer-size %d seems low and may cause problems."
+ "receive-buffer-size %lu seems low and may cause problems."
"Consider setting it to at least %d.",
config->receive_buffer_size, BUFFER_SIZE);
}
#include <ctype.h>
#include <assert.h>
-#if !defined(_WIN32) && !defined(__OS2__)
+#if !defined(_WIN32)
#include <unistd.h>
#endif
}
else
{
- log_error(LOG_LEVEL_ERROR, "Ignoring job %s outside filter block in %s, line %d",
+ log_error(LOG_LEVEL_ERROR,
+ "Ignoring job %s outside filter block in %s, line %lu",
buf, csp->config->re_filterfile[fileid], linenum);
}
freez(buf);
* The timegm replacement function was taken from GnuPG,
* Copyright (C) 2004 Free Software Foundation, Inc.
*
- * The snprintf replacement function is written by
- * Mark Martinec who also holds the copyright. It can be
- * used under the terms of the GPL or the terms of the
- * "Frontier Artistic License".
- *
* This program is free software; you can redistribute it
* and/or modify it under the terms of the GNU General
* Public License as published by the Free Software
#include <stdio.h>
#include <sys/types.h>
#include <stdlib.h>
-#if !defined(_WIN32) && !defined(__OS2__)
+#if !defined(_WIN32)
#include <unistd.h>
-#endif /* #if !defined(_WIN32) && !defined(__OS2__) */
+#endif /* #if !defined(_WIN32) */
#include <string.h>
#include <ctype.h>
#include <assert.h>
}
if ((dir == NULL) || (*dir == '\0') /* No directory specified */
-#if defined(_WIN32) || defined(__OS2__)
+#if defined(_WIN32)
|| (*file == '\\') || (file[1] == ':') /* Absolute path (DOS) */
-#else /* ifndef _WIN32 || __OS2__ */
+#else /* ifndef _WIN32 */
|| (*file == '/') /* Absolute path (U*ix) */
-#endif /* ifndef _WIN32 || __OS2__ */
+#endif /* ifndef _WIN32 */
)
{
return strdup(file);
}
assert(NULL != path);
-#if defined(_WIN32) || defined(__OS2__)
+#if defined(_WIN32)
if (path[strlen(path)-1] != '\\')
{
strlcat(path, "\\", path_size);
}
-#else /* ifndef _WIN32 || __OS2__ */
+#else /* ifndef _WIN32 */
if (path[strlen(path)-1] != '/')
{
strlcat(path, "/", path_size);
}
-#endif /* ifndef _WIN32 || __OS2__ */
+#endif /* ifndef _WIN32 */
strlcat(path, file, path_size);
return path;
#elif defined (_WIN32)
Sleep(milliseconds);
- return 0;
-#elif defined(__OS2__)
- DosSleep(milliseconds * 10);
-
return 0;
#else
#warning Missing privoxy_milisleep() implementation. delay-response{} will not work.
#endif /* !defined(HAVE_TIMEGM) && defined(HAVE_TZSET) && defined(HAVE_PUTENV) */
-#ifndef HAVE_SNPRINTF
-/*
- * What follows is a portable snprintf routine, written by Mark Martinec.
- * See: http://www.ijs.si/software/snprintf/
-
- snprintf.c
- - a portable implementation of snprintf,
- including vsnprintf.c, asnprintf, vasnprintf, asprintf, vasprintf
-
- snprintf is a routine to convert numeric and string arguments to
- formatted strings. It is similar to sprintf(3) provided in a system's
- C library, yet it requires an additional argument - the buffer size -
- and it guarantees never to store anything beyond the given buffer,
- regardless of the format or arguments to be formatted. Some newer
- operating systems do provide snprintf in their C library, but many do
- not or do provide an inadequate (slow or idiosyncratic) version, which
- calls for a portable implementation of this routine.
-
-Author
-
- Mark Martinec <mark.martinec@ijs.si>, April 1999, June 2000
- Copyright © 1999, Mark Martinec
-
- */
-
-#define PORTABLE_SNPRINTF_VERSION_MAJOR 2
-#define PORTABLE_SNPRINTF_VERSION_MINOR 2
-
-#if defined(NEED_ASPRINTF) || defined(NEED_ASNPRINTF) || defined(NEED_VASPRINTF) || defined(NEED_VASNPRINTF)
-# if defined(NEED_SNPRINTF_ONLY)
-# undef NEED_SNPRINTF_ONLY
-# endif
-# if !defined(PREFER_PORTABLE_SNPRINTF)
-# define PREFER_PORTABLE_SNPRINTF
-# endif
-#endif
-
-#if defined(SOLARIS_BUG_COMPATIBLE) && !defined(SOLARIS_COMPATIBLE)
-#define SOLARIS_COMPATIBLE
-#endif
-
-#if defined(HPUX_BUG_COMPATIBLE) && !defined(HPUX_COMPATIBLE)
-#define HPUX_COMPATIBLE
-#endif
-
-#if defined(DIGITAL_UNIX_BUG_COMPATIBLE) && !defined(DIGITAL_UNIX_COMPATIBLE)
-#define DIGITAL_UNIX_COMPATIBLE
-#endif
-
-#if defined(PERL_BUG_COMPATIBLE) && !defined(PERL_COMPATIBLE)
-#define PERL_COMPATIBLE
-#endif
-
-#if defined(LINUX_BUG_COMPATIBLE) && !defined(LINUX_COMPATIBLE)
-#define LINUX_COMPATIBLE
-#endif
-
-#include <sys/types.h>
-#include <string.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <stdarg.h>
-#include <assert.h>
-#include <errno.h>
-
-#ifdef isdigit
-#undef isdigit
-#endif
-#define isdigit(c) ((c) >= '0' && (c) <= '9')
-
-/* For copying strings longer or equal to 'breakeven_point'
- * it is more efficient to call memcpy() than to do it inline.
- * The value depends mostly on the processor architecture,
- * but also on the compiler and its optimization capabilities.
- * The value is not critical, some small value greater than zero
- * will be just fine if you don't care to squeeze every drop
- * of performance out of the code.
- *
- * Small values favor memcpy, large values favor inline code.
- */
-#if defined(__alpha__) || defined(__alpha)
-# define breakeven_point 2 /* AXP (DEC Alpha) - gcc or cc or egcs */
-#endif
-#if defined(__i386__) || defined(__i386)
-# define breakeven_point 12 /* Intel Pentium/Linux - gcc 2.96 */
-#endif
-#if defined(__hppa)
-# define breakeven_point 10 /* HP-PA - gcc */
-#endif
-#if defined(__sparc__) || defined(__sparc)
-# define breakeven_point 33 /* Sun Sparc 5 - gcc 2.8.1 */
-#endif
-
-/* some other values of possible interest: */
-/* #define breakeven_point 8 */ /* VAX 4000 - vaxc */
-/* #define breakeven_point 19 */ /* VAX 4000 - gcc 2.7.0 */
-
-#ifndef breakeven_point
-# define breakeven_point 6 /* some reasonable one-size-fits-all value */
-#endif
-
-#define fast_memcpy(d,s,n) \
- { register size_t nn = (size_t)(n); \
- if (nn >= breakeven_point) memcpy((d), (s), nn); \
- else if (nn > 0) { /* proc call overhead is worth only for large strings*/\
- register char *dd; register const char *ss; \
- for (ss=(s), dd=(d); nn>0; nn--) *dd++ = *ss++; } }
-
-#define fast_memset(d,c,n) \
- { register size_t nn = (size_t)(n); \
- if (nn >= breakeven_point) memset((d), (int)(c), nn); \
- else if (nn > 0) { /* proc call overhead is worth only for large strings*/\
- register char *dd; register const int cc=(int)(c); \
- for (dd=(d); nn>0; nn--) *dd++ = cc; } }
-
-/* prototypes */
-
-#if defined(NEED_ASPRINTF)
-int asprintf (char **ptr, const char *fmt, /*args*/ ...);
-#endif
-#if defined(NEED_VASPRINTF)
-int vasprintf (char **ptr, const char *fmt, va_list ap);
-#endif
-#if defined(NEED_ASNPRINTF)
-int asnprintf (char **ptr, size_t str_m, const char *fmt, /*args*/ ...);
-#endif
-#if defined(NEED_VASNPRINTF)
-int vasnprintf (char **ptr, size_t str_m, const char *fmt, va_list ap);
-#endif
-
-#if defined(HAVE_SNPRINTF)
-/* declare our portable snprintf routine under name portable_snprintf */
-/* declare our portable vsnprintf routine under name portable_vsnprintf */
-#else
-/* declare our portable routines under names snprintf and vsnprintf */
-#define portable_snprintf snprintf
-#if !defined(NEED_SNPRINTF_ONLY)
-#define portable_vsnprintf vsnprintf
-#endif
-#endif
-
-#if !defined(HAVE_SNPRINTF) || defined(PREFER_PORTABLE_SNPRINTF)
-int portable_snprintf(char *str, size_t str_m, const char *fmt, /*args*/ ...);
-#if !defined(NEED_SNPRINTF_ONLY)
-int portable_vsnprintf(char *str, size_t str_m, const char *fmt, va_list ap);
-#endif
-#endif
-
-/* declarations */
-
-static char credits[] = "\n\
-@(#)snprintf.c, v2.2: Mark Martinec, <mark.martinec@ijs.si>\n\
-@(#)snprintf.c, v2.2: Copyright 1999, Mark Martinec. Frontier Artistic License applies.\n\
-@(#)snprintf.c, v2.2: http://www.ijs.si/software/snprintf/\n";
-
-#if defined(NEED_ASPRINTF)
-int asprintf(char **ptr, const char *fmt, /*args*/ ...) {
- va_list ap;
- size_t str_m;
- int str_l;
-
- *ptr = NULL;
- va_start(ap, fmt); /* measure the required size */
- str_l = portable_vsnprintf(NULL, (size_t)0, fmt, ap);
- va_end(ap);
- assert(str_l >= 0); /* possible integer overflow if str_m > INT_MAX */
- *ptr = (char *) malloc(str_m = (size_t)str_l + 1);
- if (*ptr == NULL) { errno = ENOMEM; str_l = -1; }
- else {
- int str_l2;
- va_start(ap, fmt);
- str_l2 = portable_vsnprintf(*ptr, str_m, fmt, ap);
- va_end(ap);
- assert(str_l2 == str_l);
- }
- return str_l;
-}
-#endif
-
-#if defined(NEED_VASPRINTF)
-int vasprintf(char **ptr, const char *fmt, va_list ap) {
- size_t str_m;
- int str_l;
-
- *ptr = NULL;
- { va_list ap2;
- va_copy(ap2, ap); /* don't consume the original ap, we'll need it again */
- str_l = portable_vsnprintf(NULL, (size_t)0, fmt, ap2);/*get required size*/
- va_end(ap2);
- }
- assert(str_l >= 0); /* possible integer overflow if str_m > INT_MAX */
- *ptr = (char *) malloc(str_m = (size_t)str_l + 1);
- if (*ptr == NULL) { errno = ENOMEM; str_l = -1; }
- else {
- int str_l2 = portable_vsnprintf(*ptr, str_m, fmt, ap);
- assert(str_l2 == str_l);
- }
- return str_l;
-}
-#endif
-
-#if defined(NEED_ASNPRINTF)
-int asnprintf (char **ptr, size_t str_m, const char *fmt, /*args*/ ...) {
- va_list ap;
- int str_l;
-
- *ptr = NULL;
- va_start(ap, fmt); /* measure the required size */
- str_l = portable_vsnprintf(NULL, (size_t)0, fmt, ap);
- va_end(ap);
- assert(str_l >= 0); /* possible integer overflow if str_m > INT_MAX */
- if ((size_t)str_l + 1 < str_m) str_m = (size_t)str_l + 1; /* truncate */
- /* if str_m is 0, no buffer is allocated, just set *ptr to NULL */
- if (str_m == 0) { /* not interested in resulting string, just return size */
- } else {
- *ptr = (char *) malloc(str_m);
- if (*ptr == NULL) { errno = ENOMEM; str_l = -1; }
- else {
- int str_l2;
- va_start(ap, fmt);
- str_l2 = portable_vsnprintf(*ptr, str_m, fmt, ap);
- va_end(ap);
- assert(str_l2 == str_l);
- }
- }
- return str_l;
-}
-#endif
-
-#if defined(NEED_VASNPRINTF)
-int vasnprintf (char **ptr, size_t str_m, const char *fmt, va_list ap) {
- int str_l;
-
- *ptr = NULL;
- { va_list ap2;
- va_copy(ap2, ap); /* don't consume the original ap, we'll need it again */
- str_l = portable_vsnprintf(NULL, (size_t)0, fmt, ap2);/*get required size*/
- va_end(ap2);
- }
- assert(str_l >= 0); /* possible integer overflow if str_m > INT_MAX */
- if ((size_t)str_l + 1 < str_m) str_m = (size_t)str_l + 1; /* truncate */
- /* if str_m is 0, no buffer is allocated, just set *ptr to NULL */
- if (str_m == 0) { /* not interested in resulting string, just return size */
- } else {
- *ptr = (char *) malloc(str_m);
- if (*ptr == NULL) { errno = ENOMEM; str_l = -1; }
- else {
- int str_l2 = portable_vsnprintf(*ptr, str_m, fmt, ap);
- assert(str_l2 == str_l);
- }
- }
- return str_l;
-}
-#endif
-
-/*
- * If the system does have snprintf and the portable routine is not
- * specifically required, this module produces no code for snprintf/vsnprintf.
- */
-#if !defined(HAVE_SNPRINTF) || defined(PREFER_PORTABLE_SNPRINTF)
-
-#if !defined(NEED_SNPRINTF_ONLY)
-int portable_snprintf(char *str, size_t str_m, const char *fmt, /*args*/ ...) {
- va_list ap;
- int str_l;
-
- va_start(ap, fmt);
- str_l = portable_vsnprintf(str, str_m, fmt, ap);
- va_end(ap);
- return str_l;
-}
-#endif
-
-#if defined(NEED_SNPRINTF_ONLY)
-int portable_snprintf(char *str, size_t str_m, const char *fmt, /*args*/ ...) {
-#else
-int portable_vsnprintf(char *str, size_t str_m, const char *fmt, va_list ap) {
-#endif
-
-#if defined(NEED_SNPRINTF_ONLY)
- va_list ap;
-#endif
- size_t str_l = 0;
- const char *p = fmt;
-
-/* In contrast with POSIX, the ISO C99 now says
- * that str can be NULL and str_m can be 0.
- * This is more useful than the old: if (str_m < 1) return -1; */
-
-#if defined(NEED_SNPRINTF_ONLY)
- va_start(ap, fmt);
-#endif
- if (!p) p = "";
- while (*p) {
- if (*p != '%') {
- /* if (str_l < str_m) str[str_l++] = *p++; -- this would be sufficient */
- /* but the following code achieves better performance for cases
- * where format string is long and contains few conversions */
- const char *q = strchr(p+1,'%');
- size_t n = !q ? strlen(p) : (q-p);
- if (str_l < str_m) {
- size_t avail = str_m-str_l;
- fast_memcpy(str+str_l, p, (n>avail?avail:n));
- }
- p += n; str_l += n;
- } else {
- const char *starting_p;
- size_t min_field_width = 0, precision = 0;
- int zero_padding = 0, precision_specified = 0, justify_left = 0;
- int alternate_form = 0, force_sign = 0;
- int space_for_positive = 1; /* If both the ' ' and '+' flags appear,
- the ' ' flag should be ignored. */
- char length_modifier = '\0'; /* allowed values: \0, h, l, L */
- char tmp[32];/* temporary buffer for simple numeric->string conversion */
-
- const char *str_arg; /* string address in case of string argument */
- size_t str_arg_l; /* natural field width of arg without padding
- and sign */
- unsigned char uchar_arg;
- /* unsigned char argument value - only defined for c conversion.
- N.B. standard explicitly states the char argument for
- the c conversion is unsigned */
-
- size_t number_of_zeros_to_pad = 0;
- /* number of zeros to be inserted for numeric conversions
- as required by the precision or minimal field width */
-
- size_t zero_padding_insertion_ind = 0;
- /* index into tmp where zero padding is to be inserted */
-
- char fmt_spec = '\0';
- /* current conversion specifier character */
-
- str_arg = credits;/* just to make compiler happy (defined but not used)*/
- str_arg = NULL;
- starting_p = p; p++; /* skip '%' */
- /* parse flags */
- while (*p == '0' || *p == '-' || *p == '+' ||
- *p == ' ' || *p == '#' || *p == '\'') {
- switch (*p) {
- case '0': zero_padding = 1; break;
- case '-': justify_left = 1; break;
- case '+': force_sign = 1; space_for_positive = 0; break;
- case ' ': force_sign = 1;
- /* If both the ' ' and '+' flags appear, the ' ' flag should be ignored */
-#ifdef PERL_COMPATIBLE
- /* ... but in Perl the last of ' ' and '+' applies */
- space_for_positive = 1;
-#endif
- break;
- case '#': alternate_form = 1; break;
- case '\'': break;
- }
- p++;
- }
- /* If the '0' and '-' flags both appear, the '0' flag should be ignored. */
-
- /* parse field width */
- if (*p == '*') {
- int j;
- p++; j = va_arg(ap, int);
- if (j >= 0) min_field_width = j;
- else { min_field_width = -j; justify_left = 1; }
- } else if (isdigit((int)(*p))) {
- /* size_t could be wider than unsigned int;
- make sure we treat argument like common implementations do */
- unsigned int uj = *p++ - '0';
- while (isdigit((int)(*p))) uj = 10*uj + (unsigned int)(*p++ - '0');
- min_field_width = uj;
- }
- /* parse precision */
- if (*p == '.') {
- p++; precision_specified = 1;
- if (*p == '*') {
- int j = va_arg(ap, int);
- p++;
- if (j >= 0) precision = j;
- else {
- precision_specified = 0; precision = 0;
- /* NOTE:
- * Solaris 2.6 man page claims that in this case the precision
- * should be set to 0. Digital Unix 4.0, HPUX 10 and BSD man page
- * claim that this case should be treated as unspecified precision,
- * which is what we do here.
- */
- }
- } else if (isdigit((int)(*p))) {
- /* size_t could be wider than unsigned int;
- make sure we treat argument like common implementations do */
- unsigned int uj = *p++ - '0';
- while (isdigit((int)(*p))) uj = 10*uj + (unsigned int)(*p++ - '0');
- precision = uj;
- }
- }
- /* parse 'h', 'l' and 'll' length modifiers */
- if (*p == 'h' || *p == 'l') {
- length_modifier = *p; p++;
- if (length_modifier == 'l' && *p == 'l') { /* double l = long long */
-#ifdef SNPRINTF_LONGLONG_SUPPORT
- length_modifier = '2'; /* double l encoded as '2' */
-#else
- length_modifier = 'l'; /* treat it as a single 'l' */
-#endif
- p++;
- }
- }
- fmt_spec = *p;
- /* common synonyms: */
- switch (fmt_spec) {
- case 'i': fmt_spec = 'd'; break;
- case 'D': fmt_spec = 'd'; length_modifier = 'l'; break;
- case 'U': fmt_spec = 'u'; length_modifier = 'l'; break;
- case 'O': fmt_spec = 'o'; length_modifier = 'l'; break;
- default: break;
- }
- /* get parameter value, do initial processing */
- switch (fmt_spec) {
- case '%': /* % behaves similar to 's' regarding flags and field widths */
- case 'c': /* c behaves similar to 's' regarding flags and field widths */
- case 's':
- length_modifier = '\0'; /* wint_t and wchar_t not supported */
- /* the result of zero padding flag with non-numeric conversion specifier*/
- /* is undefined. Solaris and HPUX 10 does zero padding in this case, */
- /* Digital Unix and Linux does not. */
-#if !defined(SOLARIS_COMPATIBLE) && !defined(HPUX_COMPATIBLE)
- zero_padding = 0; /* turn zero padding off for string conversions */
-#endif
- str_arg_l = 1;
- switch (fmt_spec) {
- case '%':
- str_arg = p; break;
- case 'c': {
- int j = va_arg(ap, int);
- uchar_arg = (unsigned char) j; /* standard demands unsigned char */
- str_arg = (const char *) &uchar_arg;
- break;
- }
- case 's':
- str_arg = va_arg(ap, const char *);
- if (!str_arg) str_arg_l = 0;
- /* make sure not to address string beyond the specified precision !!! */
- else if (!precision_specified) str_arg_l = strlen(str_arg);
- /* truncate string if necessary as requested by precision */
- else if (precision == 0) str_arg_l = 0;
- else {
- /* memchr on HP does not like n > 2^31 !!! */
- const char *q = memchr(str_arg, '\0',
- precision <= 0x7fffffff ? precision : 0x7fffffff);
- str_arg_l = !q ? precision : (q-str_arg);
- }
- break;
- default: break;
- }
- break;
- case 'd': case 'u': case 'o': case 'x': case 'X': case 'p': {
- /* NOTE: the u, o, x, X and p conversion specifiers imply
- the value is unsigned; d implies a signed value */
-
- int arg_sign = 0;
- /* 0 if numeric argument is zero (or if pointer is NULL for 'p'),
- +1 if greater than zero (or nonzero for unsigned arguments),
- -1 if negative (unsigned argument is never negative) */
-
- int int_arg = 0; unsigned int uint_arg = 0;
- /* only defined for length modifier h, or for no length modifiers */
-
- long int long_arg = 0; unsigned long int ulong_arg = 0;
- /* only defined for length modifier l */
-
- void *ptr_arg = NULL;
- /* pointer argument value -only defined for p conversion */
-
-#ifdef SNPRINTF_LONGLONG_SUPPORT
- long long int long_long_arg = 0;
- unsigned long long int ulong_long_arg = 0;
- /* only defined for length modifier ll */
-#endif
- if (fmt_spec == 'p') {
- /* HPUX 10: An l, h, ll or L before any other conversion character
- * (other than d, i, u, o, x, or X) is ignored.
- * Digital Unix:
- * not specified, but seems to behave as HPUX does.
- * Solaris: If an h, l, or L appears before any other conversion
- * specifier (other than d, i, u, o, x, or X), the behavior
- * is undefined. (Actually %hp converts only 16-bits of address
- * and %llp treats address as 64-bit data which is incompatible
- * with (void *) argument on a 32-bit system).
- */
-#ifdef SOLARIS_COMPATIBLE
-# ifdef SOLARIS_BUG_COMPATIBLE
- /* keep length modifiers even if it represents 'll' */
-# else
- if (length_modifier == '2') length_modifier = '\0';
-# endif
-#else
- length_modifier = '\0';
-#endif
- ptr_arg = va_arg(ap, void *);
- if (ptr_arg != NULL) arg_sign = 1;
- } else if (fmt_spec == 'd') { /* signed */
- switch (length_modifier) {
- case '\0':
- case 'h':
- /* It is non-portable to specify a second argument of char or short
- * to va_arg, because arguments seen by the called function
- * are not char or short. C converts char and short arguments
- * to int before passing them to a function.
- */
- int_arg = va_arg(ap, int);
- if (int_arg > 0) arg_sign = 1;
- else if (int_arg < 0) arg_sign = -1;
- break;
- case 'l':
- long_arg = va_arg(ap, long int);
- if (long_arg > 0) arg_sign = 1;
- else if (long_arg < 0) arg_sign = -1;
- break;
-#ifdef SNPRINTF_LONGLONG_SUPPORT
- case '2':
- long_long_arg = va_arg(ap, long long int);
- if (long_long_arg > 0) arg_sign = 1;
- else if (long_long_arg < 0) arg_sign = -1;
- break;
-#endif
- }
- } else { /* unsigned */
- switch (length_modifier) {
- case '\0':
- case 'h':
- uint_arg = va_arg(ap, unsigned int);
- if (uint_arg) arg_sign = 1;
- break;
- case 'l':
- ulong_arg = va_arg(ap, unsigned long int);
- if (ulong_arg) arg_sign = 1;
- break;
-#ifdef SNPRINTF_LONGLONG_SUPPORT
- case '2':
- ulong_long_arg = va_arg(ap, unsigned long long int);
- if (ulong_long_arg) arg_sign = 1;
- break;
-#endif
- }
- }
- str_arg = tmp; str_arg_l = 0;
- /* NOTE:
- * For d, i, u, o, x, and X conversions, if precision is specified,
- * the '0' flag should be ignored. This is so with Solaris 2.6,
- * Digital UNIX 4.0, HPUX 10, Linux, FreeBSD, NetBSD; but not with Perl.
- */
-#ifndef PERL_COMPATIBLE
- if (precision_specified) zero_padding = 0;
-#endif
- if (fmt_spec == 'd') {
- if (force_sign && arg_sign >= 0)
- tmp[str_arg_l++] = space_for_positive ? ' ' : '+';
- /* leave negative numbers for sprintf to handle,
- to avoid handling tricky cases like (short int)(-32768) */
-#ifdef LINUX_COMPATIBLE
- } else if (fmt_spec == 'p' && force_sign && arg_sign > 0) {
- tmp[str_arg_l++] = space_for_positive ? ' ' : '+';
-#endif
- } else if (alternate_form) {
- if (arg_sign != 0 && (fmt_spec == 'x' || fmt_spec == 'X') )
- { tmp[str_arg_l++] = '0'; tmp[str_arg_l++] = fmt_spec; }
- /* alternate form should have no effect for p conversion, but ... */
-#ifdef HPUX_COMPATIBLE
- else if (fmt_spec == 'p'
- /* HPUX 10: for an alternate form of p conversion,
- * a nonzero result is prefixed by 0x. */
-#ifndef HPUX_BUG_COMPATIBLE
- /* Actually it uses 0x prefix even for a zero value. */
- && arg_sign != 0
-#endif
- ) { tmp[str_arg_l++] = '0'; tmp[str_arg_l++] = 'x'; }
-#endif
- }
- zero_padding_insertion_ind = str_arg_l;
- if (!precision_specified) precision = 1; /* default precision is 1 */
- if (precision == 0 && arg_sign == 0
-#if defined(HPUX_BUG_COMPATIBLE) || defined(LINUX_COMPATIBLE)
- && fmt_spec != 'p'
- /* HPUX 10 man page claims: With conversion character p the result of
- * converting a zero value with a precision of zero is a null string.
- * Actually HP returns all zeroes, and Linux returns "(nil)". */
-#endif
- ) {
- /* converted to null string */
- /* When zero value is formatted with an explicit precision 0,
- the resulting formatted string is empty (d, i, u, o, x, X, p). */
- } else {
- char f[5]; int f_l = 0;
- f[f_l++] = '%'; /* construct a simple format string for sprintf */
- if (!length_modifier) { }
- else if (length_modifier=='2') { f[f_l++] = 'l'; f[f_l++] = 'l'; }
- else f[f_l++] = length_modifier;
- f[f_l++] = fmt_spec; f[f_l++] = '\0';
- if (fmt_spec == 'p') str_arg_l += sprintf(tmp+str_arg_l, f, ptr_arg);
- else if (fmt_spec == 'd') { /* signed */
- switch (length_modifier) {
- case '\0':
- case 'h': str_arg_l+=sprintf(tmp+str_arg_l, f, int_arg); break;
- case 'l': str_arg_l+=sprintf(tmp+str_arg_l, f, long_arg); break;
-#ifdef SNPRINTF_LONGLONG_SUPPORT
- case '2': str_arg_l+=sprintf(tmp+str_arg_l,f,long_long_arg); break;
-#endif
- }
- } else { /* unsigned */
- switch (length_modifier) {
- case '\0':
- case 'h': str_arg_l+=sprintf(tmp+str_arg_l, f, uint_arg); break;
- case 'l': str_arg_l+=sprintf(tmp+str_arg_l, f, ulong_arg); break;
-#ifdef SNPRINTF_LONGLONG_SUPPORT
- case '2': str_arg_l+=sprintf(tmp+str_arg_l,f,ulong_long_arg);break;
-#endif
- }
- }
- /* include the optional minus sign and possible "0x"
- in the region before the zero padding insertion point */
- if (zero_padding_insertion_ind < str_arg_l &&
- tmp[zero_padding_insertion_ind] == '-') {
- zero_padding_insertion_ind++;
- }
- if (zero_padding_insertion_ind+1 < str_arg_l &&
- tmp[zero_padding_insertion_ind] == '0' &&
- (tmp[zero_padding_insertion_ind+1] == 'x' ||
- tmp[zero_padding_insertion_ind+1] == 'X') ) {
- zero_padding_insertion_ind += 2;
- }
- }
- { size_t num_of_digits = str_arg_l - zero_padding_insertion_ind;
- if (alternate_form && fmt_spec == 'o'
-#ifdef HPUX_COMPATIBLE /* ("%#.o",0) -> "" */
- && (str_arg_l > 0)
-#endif
-#ifdef DIGITAL_UNIX_BUG_COMPATIBLE /* ("%#o",0) -> "00" */
-#else
- /* unless zero is already the first character */
- && !(zero_padding_insertion_ind < str_arg_l
- && tmp[zero_padding_insertion_ind] == '0')
-#endif
- ) { /* assure leading zero for alternate-form octal numbers */
- if (!precision_specified || precision < num_of_digits+1) {
- /* precision is increased to force the first character to be zero,
- except if a zero value is formatted with an explicit precision
- of zero */
- precision = num_of_digits+1; precision_specified = 1;
- }
- }
- /* zero padding to specified precision? */
- if (num_of_digits < precision)
- number_of_zeros_to_pad = precision - num_of_digits;
- }
- /* zero padding to specified minimal field width? */
- if (!justify_left && zero_padding) {
- int n = min_field_width - (str_arg_l+number_of_zeros_to_pad);
- if (n > 0) number_of_zeros_to_pad += n;
- }
- break;
- }
- default: /* unrecognized conversion specifier, keep format string as-is*/
- zero_padding = 0; /* turn zero padding off for non-numeric convers. */
-#ifndef DIGITAL_UNIX_COMPATIBLE
- justify_left = 1; min_field_width = 0; /* reset flags */
-#endif
-#if defined(PERL_COMPATIBLE) || defined(LINUX_COMPATIBLE)
- /* keep the entire format string unchanged */
- str_arg = starting_p; str_arg_l = p - starting_p;
- /* well, not exactly so for Linux, which does something between,
- * and I don't feel an urge to imitate it: "%+++++hy" -> "%+y" */
-#else
- /* discard the unrecognized conversion, just keep *
- * the unrecognized conversion character */
- str_arg = p; str_arg_l = 0;
-#endif
- if (*p) str_arg_l++; /* include invalid conversion specifier unchanged
- if not at end-of-string */
- break;
- }
- if (*p) p++; /* step over the just processed conversion specifier */
- /* insert padding to the left as requested by min_field_width;
- this does not include the zero padding in case of numerical conversions*/
- if (!justify_left) { /* left padding with blank or zero */
- int n = min_field_width - (str_arg_l+number_of_zeros_to_pad);
- if (n > 0) {
- if (str_l < str_m) {
- size_t avail = str_m-str_l;
- fast_memset(str+str_l, (zero_padding?'0':' '), (n>avail?avail:n));
- }
- str_l += n;
- }
- }
- /* zero padding as requested by the precision or by the minimal field width
- * for numeric conversions required? */
- if (number_of_zeros_to_pad <= 0) {
- /* will not copy first part of numeric right now, *
- * force it to be copied later in its entirety */
- zero_padding_insertion_ind = 0;
- } else {
- /* insert first part of numerics (sign or '0x') before zero padding */
- int n = zero_padding_insertion_ind;
- if (n > 0) {
- if (str_l < str_m) {
- size_t avail = str_m-str_l;
- fast_memcpy(str+str_l, str_arg, (n>avail?avail:n));
- }
- str_l += n;
- }
- /* insert zero padding as requested by the precision or min field width */
- n = number_of_zeros_to_pad;
- if (n > 0) {
- if (str_l < str_m) {
- size_t avail = str_m-str_l;
- fast_memset(str+str_l, '0', (n>avail?avail:n));
- }
- str_l += n;
- }
- }
- /* insert formatted string
- * (or as-is conversion specifier for unknown conversions) */
- { int n = str_arg_l - zero_padding_insertion_ind;
- if (n > 0) {
- if (str_l < str_m) {
- size_t avail = str_m-str_l;
- fast_memcpy(str+str_l, str_arg+zero_padding_insertion_ind,
- (n>avail?avail:n));
- }
- str_l += n;
- }
- }
- /* insert right padding */
- if (justify_left) { /* right blank padding to the field width */
- int n = min_field_width - (str_arg_l+number_of_zeros_to_pad);
- if (n > 0) {
- if (str_l < str_m) {
- size_t avail = str_m-str_l;
- fast_memset(str+str_l, ' ', (n>avail?avail:n));
- }
- str_l += n;
- }
- }
- }
- }
-#if defined(NEED_SNPRINTF_ONLY)
- va_end(ap);
-#endif
- if (str_m > 0) { /* make sure the string is null-terminated
- even at the expense of overwriting the last character
- (shouldn't happen, but just in case) */
- str[str_l <= str_m-1 ? str_l : str_m-1] = '\0';
- }
- /* Return the number of characters formatted (excluding trailing null
- * character), that is, the number of characters that would have been
- * written to the buffer if it were large enough.
- *
- * The value of str_l should be returned, but str_l is of unsigned type
- * size_t, and snprintf is int, possibly leading to an undetected
- * integer overflow, resulting in a negative return value, which is illegal.
- * Both XSH5 and ISO C99 (at least the draft) are silent on this issue.
- * Should errno be set to EOVERFLOW and EOF returned in this case???
- */
- return (int) str_l;
-}
-#endif
-#endif /* ndef HAVE_SNPRINTF */
/*
Local Variables:
tab-width: 3
long int pick_from_range(long int range);
-#ifndef HAVE_SNPRINTF
-extern int snprintf(char *, size_t, const char *, /*args*/ ...);
-#endif /* ndef HAVE_SNPRINTF */
-
#if !defined(HAVE_TIMEGM) && defined(HAVE_TZSET) && defined(HAVE_PUTENV)
time_t timegm(struct tm *tm);
#endif /* !defined(HAVE_TIMEGM) && defined(HAVE_TZSET) && defined(HAVE_PUTENV) */
if (len > (sizeof(last->file_buf) - 1))
{
log_error(LOG_LEVEL_ERROR,
- "X509 PEM cert len %d is larger than buffer len %d",
+ "X509 PEM cert len %ld is larger than buffer len %lu",
len, sizeof(last->file_buf) - 1);
len = sizeof(last->file_buf) - 1;
}
#include <brotli/decode.h>
#endif
-#if !defined(_WIN32) && !defined(__OS2__)
+#if !defined(_WIN32)
#include <unistd.h>
#endif
if (need > buffer_limit)
{
log_error(LOG_LEVEL_INFO,
- "Buffer limit reached while extending the buffer (iob). Needed: %d. Limit: %d",
+ "Buffer limit reached while extending the buffer (iob). Needed: %lu. Limit: %lu",
need, buffer_limit);
return JB_ERR_MEMORY;
}
if (decoded_buffer == NULL)
{
log_error(LOG_LEVEL_ERROR,
- "Failed to allocate %d bytes for Brotli decompression",
+ "Failed to allocate %lu bytes for Brotli decompression",
decoded_buffer_size);
return JB_ERR_MEMORY;
}
csp->iob->size = decoded_buffer_size;
log_error(LOG_LEVEL_RE_FILTER,
- "Decompression successful. Old size: %d, new size: %d.",
+ "Decompression successful. Old size: %lu, new size: %lu.",
encoded_size, decoded_size);
return JB_ERR_OK;
* but it should(?) be valid for deflated data also.
*/
log_error(LOG_LEVEL_ERROR,
- "Insufficient data to start decompression. Bytes in buffer: %d",
+ "Insufficient data to start decompression. Bytes in buffer: %ld",
csp->iob->eod - csp->iob->cur);
return JB_ERR_COMPRESS;
}
{
log_error(LOG_LEVEL_ERROR, "Buffer limit reached while decompressing iob");
freez(buf);
+ inflateEnd(&zstr);
return JB_ERR_MEMORY;
}
{
log_error(LOG_LEVEL_ERROR, "Out of memory decompressing iob");
freez(buf);
+ inflateEnd(&zstr);
return JB_ERR_MEMORY;
}
else
* Make sure the new uncompressed iob obeys some minimal
* consistency conditions.
*/
- if ((csp->iob->buf <= csp->iob->cur)
+ if ((csp->iob->buf <= csp->iob->cur)
&& (csp->iob->cur <= csp->iob->eod)
&& (csp->iob->eod <= csp->iob->buf + csp->iob->size))
{
if (new_size > (size_t)0)
{
log_error(LOG_LEVEL_RE_FILTER,
- "Decompression successful. Old size: %d, new size: %d.",
+ "Decompression successful. Old size: %lu, new size: %lu.",
old_size, new_size);
}
else
else
{
/* It seems that zlib did something weird. */
- log_error(LOG_LEVEL_ERROR,
- "Unexpected error decompressing the buffer (iob): %d==%d, %d>%d, %d<%d",
- csp->iob->cur, csp->iob->buf + skip_size, csp->iob->eod, csp->iob->buf,
- csp->iob->eod, csp->iob->buf + csp->iob->size);
+ log_error(LOG_LEVEL_ERROR, "Inconsistent buffer after decompression");
return JB_ERR_COMPRESS;
}
assert(NULL != header);
log_error(LOG_LEVEL_ERROR,
"Problems with tagger \'%s\' and header \'%s\': %s",
- b->name, *header, pcrs_strerror(hits));
+ b->name, header, pcrs_strerror(hits));
}
freez(modified_tag);
}
log_error(LOG_LEVEL_ERROR,
"Insufficient memory to add tag \'%s\', "
"based on tagger \'%s\' and header \'%s\'",
- tag, b->name, *header);
+ tag, b->name, header);
}
else
{
continue;
}
- log_error(LOG_LEVEL_RE_FILTER, "filtering \'%s\' (size %d) with \'%s\' ...",
+ log_error(LOG_LEVEL_RE_FILTER, "filtering \'%s\' (size %lu) with \'%s\' ...",
*header, size, b->name);
/* Apply all jobs from the joblist */
if (b->dynamic) pcrs_free_joblist(joblist);
- log_error(LOG_LEVEL_RE_FILTER, "... produced %d hits (new size %d).", current_hits, size);
+ log_error(LOG_LEVEL_RE_FILTER,
+ "... produced %d hits (new size %lu).", current_hits, size);
hits += current_hits;
}
seconds = rtime % 60;
log_error(LOG_LEVEL_HEADER,
- "Randomized: %s (added %d da%s %d hou%s %d minut%s %d second%s",
+ "Randomized: %s (added %ld da%s %ld hou%s %ld minut%s %ld second%s",
*header, days, (days == 1) ? "y" : "ys", hours, (hours == 1) ? "r" : "rs",
minutes, (minutes == 1) ? "e" : "es", seconds, (seconds == 1) ? ")" : "s)");
}
if (rtime)
{
- log_error(LOG_LEVEL_HEADER, "Randomizing: %s (random range: %d minut%s)",
+ log_error(LOG_LEVEL_HEADER, "Randomizing: %s (random range: %ld minut%s)",
*header, rtime, (rtime == 1 || rtime == -1) ? "e": "es");
if (negative_range)
{
}
else
{
- log_error(LOG_LEVEL_ERROR, "Random range is 0. Assuming time transformation test.",
- *header);
+ log_error(LOG_LEVEL_ERROR,
+ "Random range is 0. Assuming time transformation test.");
}
tm += rtime * (negative_range ? -1 : 1);
timeptr = privoxy_gmtime_r(&tm, &gmt);
seconds = rtime % 60;
log_error(LOG_LEVEL_HEADER,
- "Randomized: %s (%s %d hou%s %d minut%s %d second%s",
+ "Randomized: %s (%s %ld hou%s %ld minut%s %ld second%s",
*header, (negative_range) ? "subtracted" : "added", hours,
(hours == 1) ? "r" : "rs", minutes, (minutes == 1) ? "e" : "es",
seconds, (seconds == 1) ? ")" : "s)");
if (*result != result2)
{
log_error(LOG_LEVEL_ERROR, "strftime() and strptime() disagree. "
- "Format: '%s'. In: '%s', out: '%s'. %d != %d. Rejecting.",
+ "Format: '%s'. In: '%s', out: '%s'. %ld != %ld. Rejecting.",
time_formats[i], header_time, recreated_date, *result, result2);
continue;
}
log_error(LOG_LEVEL_CRUNCH, "Certificate error: %s: https://%s%s",
reason, csp->http->hostport, csp->http->path);
- log_error(LOG_LEVEL_CLF, "%s - - [%T] \"%s https://%s%s %s\" 200 %u",
+ log_error(LOG_LEVEL_CLF, "%s - - [%T] \"%s https://%s%s %s\" 200 %lu",
csp->ip_addr_str, csp->http->gpc, csp->http->hostport, csp->http->path,
csp->http->version, message_len-head_length);
+ strlen(file_name) + strlen(suffix) + 2;
/* Setting delimiter and editing path length */
-#if defined(_WIN32) || defined(__OS2__)
+#if defined(_WIN32)
char delim[] = "\\";
path_size += 1;
-#else /* ifndef _WIN32 || __OS2__ */
+#else /* ifndef _WIN32 */
char delim[] = "/";
-#endif /* ifndef _WIN32 || __OS2__ */
+#endif /* ifndef _WIN32 */
/*
* Building up path from many parts
<td class="box">
<h2>Content Filter Statistics:</h2>
<table summary="Statistics for content filters" border="1">
- <tr><th>Filter name</th><th>Executions</th><th>Pages modified</th><th>Hits</th></tr>
+ <tr><th>Filter name</th><th>Executions</th><th>Response bodies modified</th><th>Hits</th></tr>
@filter-statistics@ </table>
</td>
</tr>
<td><code>FEATURE_ZLIB</code></td>
<td>@if-FEATURE_ZLIB-then@ Yes @else-not-FEATURE_ZLIB@ No @endif-FEATURE_ZLIB@</td>
<td>Allows to decompress gzip and zlib compressed documents for filtering.
- Requires external zlib library and hasn't been tested on all platforms.</td>
+ Requires external zlib library.</td>
</tr>
</table>
</td>
#include <assert.h>
#include <string.h>
-#if !defined(_WIN32) && !defined(__OS2__)
+#if !defined(_WIN32)
#include <unistd.h>
#endif