summaryrefslogtreecommitdiff
blob: 85cafb527d684627caddcb27a454e7d7f6901d0d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
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 ) {