diff options
Diffstat (limited to 'net-misc/snarf/files')
-rw-r--r-- | net-misc/snarf/files/snarf-basename-patch.diff | 147 | ||||
-rw-r--r-- | net-misc/snarf/files/snarf-fix-off-by-ones.diff | 45 | ||||
-rw-r--r-- | net-misc/snarf/files/snarf-unlink-empty.diff | 37 |
3 files changed, 229 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..85cafb527d68 --- /dev/null +++ b/net-misc/snarf/files/snarf-basename-patch.diff @@ -0,0 +1,147 @@ +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-fix-off-by-ones.diff b/net-misc/snarf/files/snarf-fix-off-by-ones.diff new file mode 100644 index 000000000000..c0556b3ed851 --- /dev/null +++ b/net-misc/snarf/files/snarf-fix-off-by-ones.diff @@ -0,0 +1,45 @@ +diff -ruNp snarf-7.0.orig/ftp.c snarf-7.0/ftp.c +--- snarf-7.0.orig/ftp.c 2000-08-09 00:27:24.000000000 +0100 ++++ snarf-7.0/ftp.c 2007-03-30 20:47:46.046783664 +0100 +@@ -89,7 +89,7 @@ get_line(UrlResource *rsrc, int control) + char *end; + char buf[BUFSIZE+1]; + +- while( (bytes_read = read(control, buf, BUFSIZE)) ) { ++ while( (bytes_read = read(control, buf, BUFSIZE)) > 0 ) { + if( rsrc->options & OPT_VERBOSE ) + fwrite(buf, 1, bytes_read, stderr); + +diff -ruNp snarf-7.0.orig/http.c snarf-7.0/http.c +--- snarf-7.0.orig/http.c 2007-03-30 20:46:21.176685880 +0100 ++++ snarf-7.0/http.c 2007-03-30 20:47:46.205759496 +0100 +@@ -365,7 +365,7 @@ http_transfer(UrlResource *rsrc) + + bytes_read = read(sock, buf, 8); + +- if( bytes_read == 0 ) { ++ if( bytes_read <= 0 ) { + close(sock); + return 0; + } +diff -ruNp snarf-7.0.orig/url.c snarf-7.0/url.c +--- snarf-7.0.orig/url.c 1998-11-16 01:29:44.000000000 +0000 ++++ snarf-7.0/url.c 2007-03-30 20:47:46.205759496 +0100 +@@ -96,7 +96,7 @@ get_username(char *string, Url *u) + return string; + } + +- username = malloc(i); ++ username = malloc(i+1); + memcpy(username, string, i + 1); + + username[i] = '\0'; +@@ -135,7 +135,7 @@ get_password(char *string, Url *u) + + for(i = 0 ; string[i] != '@'; i++); + +- password = malloc(i); ++ password = malloc(i+1); + + /* and finally, get the password portion */ + memcpy(password, string, i); 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..66f3089b0b63 --- /dev/null +++ b/net-misc/snarf/files/snarf-unlink-empty.diff @@ -0,0 +1,37 @@ +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 ) |