summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTavis Ormandy <taviso@gentoo.org>2003-08-01 15:51:06 +0000
committerTavis Ormandy <taviso@gentoo.org>2003-08-01 15:51:06 +0000
commit12d5f65a2be817d36d5f5eed05a0bb5354754bf4 (patch)
tree5e7e8d4320ea260c3971256e298d19fa4f5791f8 /net-misc/snarf
parentsome patches for ~arch users. (diff)
downloadhistorical-12d5f65a2be817d36d5f5eed05a0bb5354754bf4.tar.gz
historical-12d5f65a2be817d36d5f5eed05a0bb5354754bf4.tar.bz2
historical-12d5f65a2be817d36d5f5eed05a0bb5354754bf4.zip
some patches for ~arch users.
Diffstat (limited to 'net-misc/snarf')
-rw-r--r--net-misc/snarf/Manifest4
-rw-r--r--net-misc/snarf/files/digest-snarf-7.0-r21
-rw-r--r--net-misc/snarf/files/snarf-basename-patch.diff177
-rw-r--r--net-misc/snarf/files/snarf-unlink-empty.diff43
-rw-r--r--net-misc/snarf/snarf-7.0-r2.ebuild31
5 files changed, 254 insertions, 2 deletions
diff --git a/net-misc/snarf/Manifest b/net-misc/snarf/Manifest
index 130e2c251772..c68b067f5ef8 100644
--- a/net-misc/snarf/Manifest
+++ b/net-misc/snarf/Manifest
@@ -1,6 +1,6 @@
MD5 e862286e5ca3e30d992be29f9efef876 snarf-7.0-r1.ebuild 638
-MD5 dd7b3190200bffd18abb6d249283af4d snarf-7.0-r2.ebuild 751
-MD5 9804869ca3b2f2feb0d630c6206a1158 ChangeLog 1537
+MD5 a23ac522a8217c61b2aaab80414d94c9 snarf-7.0-r2.ebuild 750
+MD5 4904424b0399a49ed5de2a6f104f9bdb ChangeLog 1537
MD5 600c99f449fb48c1cf7fa2ee0a2001b0 files/snarf-unlink-empty.diff 1856
MD5 527ee7471f71033c73ce0f96e62c234f files/snarf-basename-patch.diff 5499
MD5 cd29624c2e8f0ab7a4614a8f12578f56 files/digest-snarf-7.0-r1 60
diff --git a/net-misc/snarf/files/digest-snarf-7.0-r2 b/net-misc/snarf/files/digest-snarf-7.0-r2
new file mode 100644
index 000000000000..47370af7b7a2
--- /dev/null
+++ b/net-misc/snarf/files/digest-snarf-7.0-r2
@@ -0,0 +1 @@
+MD5 7470d8457bc0d347b5cd8668c9e735c4 snarf-7.0.tar.gz 64495
diff --git a/net-misc/snarf/files/snarf-basename-patch.diff b/net-misc/snarf/files/snarf-basename-patch.diff
new file mode 100644
index 000000000000..814cfbf5f18f
--- /dev/null
+++ b/net-misc/snarf/files/snarf-basename-patch.diff
@@ -0,0 +1,177 @@
+######################################################
+# Purpose: Add a -b option to snarf, to only display basename() of target file.
+# Author: Tavis Ormandy <taviso@gentoo.org>
+# Date: 28/07/2003
+# Applies Against: snarf-7.0
+#
+# example output without patch:
+#
+# # emerge elinks
+# Calculating dependencies ...done!
+# >>> emerge (1 of 1) net-www/elinks-0.4.2 to /
+# >>> Downloading http://../elinks-0.4.2.tar.bz2
+# http://../elinks-0.4.2.tar.bz2 (742K)
+# /usr/portage/distfiles/e [##### ] 172K | 20.31K/s
+#
+# example with:
+#
+# # emerge elinks
+# Calculating dependencies ...done!
+# >>> emerge (1 of 1) net-www/elinks-0.4.2 to /
+# >>> Downloading http://../elinks-0.4.2.tar.bz2
+# http://../elinks-0.4.2.tar.bz2 (742K)
+# elinks-0.4.2.tar.bz2 [##### ] 172K | 20.31K/s
+#
+# I use these fetch/resume commands:
+#
+# FETCHCOMMAND="/usr/bin/snarf -b \${URI} \${DISTDIR}/\${FILE}"
+# RESUMECOMMAND="/usr/bin/snarf -br \${URI} \${DISTDIR}/\${FILE}"
+#
+##############################################################
+diff -ruN snarf-7.0.orig/http.c snarf-7.0/http.c
+--- snarf-7.0.orig/http.c 2000-08-09 01:33:30.000000000 +0100
++++ snarf-7.0/http.c 2003-07-28 12:19:08.000000000 +0100
+@@ -14,8 +14,6 @@
+ #include "util.h"
+ #include "llist.h"
+
+-extern int default_opts;
+-
+ int redirect_count = 0;
+ #define REDIRECT_MAX 10
+
+diff -ruN snarf-7.0.orig/options.c snarf-7.0/options.c
+--- snarf-7.0.orig/options.c 1999-07-27 20:42:51.000000000 +0100
++++ snarf-7.0/options.c 2003-07-28 11:59:05.000000000 +0100
+@@ -8,8 +8,8 @@
+ int default_opts;
+ extern int debug_enabled;
+
+-unsigned char
+-set_options(unsigned char opts, char *optstring)
++unsigned int
++set_options(unsigned int opts, char *optstring)
+ {
+ int i;
+
+@@ -78,6 +78,15 @@
+ case 'd':
+ debug_enabled = !debug_enabled;
+ break;
++
++ case 'b':
++ opts |= OPT_BASENAME;
++ break;
++
++ case 'B':
++ default_opts |= OPT_BASENAME;
++ break;
++
+ default:
+ report(WARN, "unknown option `%c', ignoring", optstring[i]);
+ }
+diff -ruN snarf-7.0.orig/options.h snarf-7.0/options.h
+--- snarf-7.0.orig/options.h 1999-07-27 20:42:51.000000000 +0100
++++ snarf-7.0/options.h 2003-07-28 12:20:47.000000000 +0100
+@@ -12,12 +12,13 @@
+ #define OPT_PROGRESS (1 << 5) /* for python aka markus fleck */
+ #define OPT_BE_MOZILLA (1 << 6) /* To act like Mozilla */
+ #define OPT_BE_MSIE (1 << 7) /* To act like MSIE */
++#define OPT_BASENAME (1 << 8) /* Only show basename() of output */
+
+ /* Funcs */
+
+ #ifdef PROTOTYPES
+
+-unsigned char set_options(unsigned char, char *);
++unsigned int set_options(unsigned int, char *);
+
+ #endif /* PROTOTYPES */
+
+diff -ruN snarf-7.0.orig/snarf.1 snarf-7.0/snarf.1
+--- snarf-7.0.orig/snarf.1 2000-01-17 14:26:13.000000000 +0000
++++ snarf-7.0/snarf.1 2003-07-28 12:45:26.000000000 +0100
+@@ -90,6 +90,9 @@
+ .I "\-m"
+ Send a user-agent string similar to what Microsoft Internet Explorer
+ uses.
++.TP
++.I "\-b"
++Only print the basename of output file with the progress bars.
+ .PP
+ Each option only affects the URL that immediately follows it. To have
+ an option affect all URLs that follow it, use an uppercase letter for
+diff -ruN snarf-7.0.orig/snarf.c snarf-7.0/snarf.c
+--- snarf-7.0.orig/snarf.c 2000-08-09 01:34:45.000000000 +0100
++++ snarf-7.0/snarf.c 2003-07-28 12:43:29.000000000 +0100
+@@ -50,6 +50,7 @@
+ " -n Ignore '-r' and transfer file in its entirety\n"
+ " -m Spoof MSIE user-agent string\n"
+ " -z Spoof Navigator user-agent string\n"
++ " -b Only print basename of output file\n"
+ "\n"
+ "Lowercase option letters only affect the URLs that "
+ "immediately follow them.\n"
+diff -ruN snarf-7.0.orig/url.h snarf-7.0/url.h
+--- snarf-7.0.orig/url.h 1999-07-27 20:42:51.000000000 +0100
++++ snarf-7.0/url.h 2003-07-28 12:00:03.000000000 +0100
+@@ -28,7 +28,7 @@
+ char *proxy;
+ char *proxy_username;
+ char *proxy_password;
+- unsigned char options;
++ unsigned int options;
+ off_t outfile_size;
+ off_t outfile_offset;
+ };
+diff -ruN snarf-7.0.orig/util.c snarf-7.0/util.c
+--- snarf-7.0.orig/util.c 2000-08-09 01:12:39.000000000 +0100
++++ snarf-7.0/util.c 2003-07-28 13:29:46.000000000 +0100
+@@ -32,6 +32,7 @@
+ #include <ctype.h>
+ #include <errno.h>
+ #include <time.h>
++#include <libgen.h>
+ #include "url.h"
+ #include "options.h"
+
+@@ -292,6 +293,10 @@
+
+ filename = strdup(rsrc->outfile);
+
++ if( rsrc->options & OPT_BASENAME ){
++ filename = basename(filename);
++ }
++
+ if( strlen(filename) > 24 )
+ filename[24] = '\0';
+
+@@ -312,6 +317,7 @@
+ progress_update(Progress * p,
+ long int increment)
+ {
++ char *filename = NULL;
+ unsigned int units;
+ char *anim = "-\\|/";
+
+@@ -320,12 +326,16 @@
+
+ p->current += increment;
+
+- if (strlen(p->rsrc->outfile) > 24) {
+- p->rsrc->outfile[24] = '\0';
+- }
++ if( p->rsrc->options & OPT_BASENAME ){
++ filename = basename(strdup(p->rsrc->outfile));
++ } else
++ filename = strdup(p->rsrc->outfile);
+
++ if (strlen(filename) > 24)
++ filename[24] = '\0';
++
+ fprintf(stderr, "\r");
+- fprintf(stderr, "%-25s [", p->rsrc->outfile);
++ fprintf(stderr, "%-25s [", filename);
+
+
+ if( p->length ) {
diff --git a/net-misc/snarf/files/snarf-unlink-empty.diff b/net-misc/snarf/files/snarf-unlink-empty.diff
new file mode 100644
index 000000000000..d9f4487839c4
--- /dev/null
+++ b/net-misc/snarf/files/snarf-unlink-empty.diff
@@ -0,0 +1,43 @@
+######################################################
+# Purpose: If the requested file isnt empty, and snarf created the file, unlink it.
+# Author: Tavis Ormandy <taviso@gentoo.org>
+# Date: 1/08/2003
+# Applies Against: Snarf-7.0+basename
+###################################
+diff -urN snarf-7.0.orig/http.c snarf-7.0/http.c
+--- snarf-7.0.orig/http.c 2003-08-01 14:46:26.000000000 +0100
++++ snarf-7.0/http.c 2003-08-01 14:44:02.000000000 +0100
+@@ -447,6 +447,10 @@
+ cleanup:
+ free_http_header(header);
+ close(sock); fclose(out);
++ if ((rsrc->open_created) && (rsrc->outfile_size == 0)
++ && (retval == 0))
++ if (unlink(rsrc->outfile))
++ report(ERR, "unlink %s: %s", rsrc->outfile, strerror(errno));
+ return retval;
+
+ }
+diff -urN snarf-7.0.orig/url.h snarf-7.0/url.h
+--- snarf-7.0.orig/url.h 2003-08-01 14:46:26.000000000 +0100
++++ snarf-7.0/url.h 2003-08-01 13:27:22.000000000 +0100
+@@ -25,6 +25,7 @@
+ struct _UrlResource {
+ Url *url;
+ char *outfile;
++ unsigned int open_created;
+ char *proxy;
+ char *proxy_username;
+ char *proxy_password;
+diff -urN snarf-7.0.orig/util.h snarf-7.0/util.h
+--- snarf-7.0.orig/util.h 2000-08-09 01:12:25.000000000 +0100
++++ snarf-7.0/util.h 2003-08-01 14:53:54.000000000 +0100
+@@ -53,7 +53,7 @@
+ extern int debug_enabled;
+
+ #define open_outfile(x) (((x)->outfile[0] == '-') ? stdout : real_open_outfile(x))
+-#define real_open_outfile(x) (((x)->options & OPT_RESUME && !((x)->options & OPT_NORESUME)) ? (fopen((x)->outfile, "a")) : (fopen((x)->outfile, "w")))
++#define real_open_outfile(x) (((x)->open_created = (access ((x)->outfile, F_OK)) ? 1 : 0 ),((x)->options & OPT_RESUME && !((x)->options & OPT_NORESUME)) ? (fopen((x)->outfile, "a")) : (fopen((x)->outfile, "w")))
+
+ #define safe_free(x) if(x) free(x)
+ #define safe_strdup(x) ( (x) ? strdup(x) : NULL )
diff --git a/net-misc/snarf/snarf-7.0-r2.ebuild b/net-misc/snarf/snarf-7.0-r2.ebuild
new file mode 100644
index 000000000000..47831658af8a
--- /dev/null
+++ b/net-misc/snarf/snarf-7.0-r2.ebuild
@@ -0,0 +1,31 @@
+# Copyright 1999-2003 Gentoo Technologies, Inc.
+# Distributed under the terms of the GNU General Public License v2
+# $Header: /var/cvsroot/gentoo-x86/net-misc/snarf/snarf-7.0-r2.ebuild,v 1.1 2003/08/01 15:50:57 taviso Exp $
+
+S=${WORKDIR}/${P}
+DESCRIPTION="A full featured small web-spider"
+SRC_URI="http://www.xach.com/snarf/${P}.tar.gz"
+HOMEPAGE="http://www.xach.com/snarf/"
+KEYWORDS="~x86 ~alpha"
+LICENSE="GPL-2"
+SLOT="0"
+
+DEPEND=">=sys-libs/glibc-2.1.3"
+
+src_unpack() {
+ unpack ${A}
+ epatch ${FILESDIR}/snarf-basename-patch.diff
+ epatch ${FILESDIR}/snarf-unlink-empty.diff
+}
+
+src_compile() {
+ econf || die
+ make || die
+}
+
+src_install() {
+ into /usr
+ dobin snarf
+ doman snarf.1
+ dodoc COPYING ChangeLog README TODO
+}