diff options
Diffstat (limited to 'net-misc/snarf/files/snarf-basename-patch.diff')
-rw-r--r-- | net-misc/snarf/files/snarf-basename-patch.diff | 177 |
1 files changed, 177 insertions, 0 deletions
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 ) { |