aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatt Kraai <kraai@debian.org>2000-07-12 00:53:06 +0000
committerMatt Kraai <kraai@debian.org>2000-07-12 00:53:06 +0000
commite714bce003a1b0e2c49e58fe14af86abc8b31f23 (patch)
tree83dc60ba6291ab2839a8eeca47076582578841c7
parent3ecbe9f4dca998d224760f537dc1c3fd7269893b (diff)
downloadbusybox-w32-e714bce003a1b0e2c49e58fe14af86abc8b31f23.tar.gz
busybox-w32-e714bce003a1b0e2c49e58fe14af86abc8b31f23.tar.bz2
busybox-w32-e714bce003a1b0e2c49e58fe14af86abc8b31f23.zip
Use global applet_name instead of local versions.
-rw-r--r--chmod_chown_chgrp.c18
-rw-r--r--console-tools/deallocvt.c10
-rw-r--r--coreutils/cut.c7
-rw-r--r--cp_mv.c30
-rw-r--r--cut.c7
-rw-r--r--deallocvt.c10
6 files changed, 32 insertions, 50 deletions
diff --git a/chmod_chown_chgrp.c b/chmod_chown_chgrp.c
index d3e267827..a5d9af491 100644
--- a/chmod_chown_chgrp.c
+++ b/chmod_chown_chgrp.c
@@ -36,7 +36,6 @@
36static unsigned long uid = -1; 36static unsigned long uid = -1;
37static unsigned long gid = -1; 37static unsigned long gid = -1;
38static int whichApp; 38static int whichApp;
39static char *invocationName = NULL;
40static char *theMode = NULL; 39static char *theMode = NULL;
41 40
42 41
@@ -88,7 +87,7 @@ static int fileAction(const char *fileName, struct stat *statbuf, void* junk)
88 case CHMOD_APP: 87 case CHMOD_APP:
89 /* Parse the specified modes */ 88 /* Parse the specified modes */
90 if (parse_mode(theMode, &(statbuf->st_mode)) == FALSE) { 89 if (parse_mode(theMode, &(statbuf->st_mode)) == FALSE) {
91 fatalError( "%s: unknown mode: %s\n", invocationName, theMode); 90 fatalError( "%s: unknown mode: %s\n", applet_name, theMode);
92 } 91 }
93 if (chmod(fileName, statbuf->st_mode) == 0) 92 if (chmod(fileName, statbuf->st_mode) == 0)
94 return (TRUE); 93 return (TRUE);
@@ -105,8 +104,8 @@ int chmod_chown_chgrp_main(int argc, char **argv)
105 char *p=NULL; 104 char *p=NULL;
106 const char *appUsage; 105 const char *appUsage;
107 106
108 whichApp = (strcmp(*argv, "chown") == 0)? 107 whichApp = (strcmp(applet_name, "chown") == 0)?
109 CHOWN_APP : (strcmp(*argv, "chmod") == 0)? 108 CHOWN_APP : (strcmp(applet_name, "chmod") == 0)?
110 CHMOD_APP : CHGRP_APP; 109 CHMOD_APP : CHGRP_APP;
111 110
112 appUsage = (whichApp == CHOWN_APP)? 111 appUsage = (whichApp == CHOWN_APP)?
@@ -114,7 +113,6 @@ int chmod_chown_chgrp_main(int argc, char **argv)
114 113
115 if (argc < 2) 114 if (argc < 2)
116 usage(appUsage); 115 usage(appUsage);
117 invocationName = *argv;
118 argv++; 116 argv++;
119 117
120 /* Parse options */ 118 /* Parse options */
@@ -125,7 +123,7 @@ int chmod_chown_chgrp_main(int argc, char **argv)
125 recursiveFlag = TRUE; 123 recursiveFlag = TRUE;
126 break; 124 break;
127 default: 125 default:
128 fprintf(stderr, invalid_option, invocationName, **argv); 126 fprintf(stderr, invalid_option, applet_name, **argv);
129 usage(appUsage); 127 usage(appUsage);
130 } 128 }
131 } 129 }
@@ -133,7 +131,7 @@ int chmod_chown_chgrp_main(int argc, char **argv)
133 } 131 }
134 132
135 if (argc == 0 || *argv == NULL) { 133 if (argc == 0 || *argv == NULL) {
136 fprintf(stderr, too_few_args, invocationName); 134 fprintf(stderr, too_few_args, applet_name);
137 usage(appUsage); 135 usage(appUsage);
138 } 136 }
139 137
@@ -172,14 +170,14 @@ int chmod_chown_chgrp_main(int argc, char **argv)
172 uid = my_getpwnam(*argv); 170 uid = my_getpwnam(*argv);
173 if (uid == -1) { 171 if (uid == -1) {
174 fatalError( "%s: unknown user name: %s\n", 172 fatalError( "%s: unknown user name: %s\n",
175 invocationName, *argv); 173 applet_name, *argv);
176 } 174 }
177 } 175 }
178 } 176 }
179 177
180 /* Ok, ready to do the deed now */ 178 /* Ok, ready to do the deed now */
181 if (argc <= 1) { 179 if (argc <= 1) {
182 fatalError( "%s: too few arguments\n", invocationName); 180 fatalError( "%s: too few arguments\n", applet_name);
183 } 181 }
184 while (argc-- > 1) { 182 while (argc-- > 1) {
185 if (recursiveAction (*(++argv), recursiveFlag, FALSE, FALSE, 183 if (recursiveAction (*(++argv), recursiveFlag, FALSE, FALSE,
@@ -189,7 +187,7 @@ int chmod_chown_chgrp_main(int argc, char **argv)
189 exit(TRUE); 187 exit(TRUE);
190 188
191 bad_group: 189 bad_group:
192 fatalError( "%s: unknown group name: %s\n", invocationName, groupName); 190 fatalError( "%s: unknown group name: %s\n", applet_name, groupName);
193} 191}
194 192
195/* 193/*
diff --git a/console-tools/deallocvt.c b/console-tools/deallocvt.c
index 0cad7717b..53d4d9a7c 100644
--- a/console-tools/deallocvt.c
+++ b/console-tools/deallocvt.c
@@ -14,8 +14,6 @@
14#define VT_DISALLOCATE 0x5608 /* free memory associated to vt */ 14#define VT_DISALLOCATE 0x5608 /* free memory associated to vt */
15 15
16 16
17char *progname;
18
19int deallocvt_main(int argc, char *argv[]) 17int deallocvt_main(int argc, char *argv[])
20{ 18{
21 int fd, num, i; 19 int fd, num, i;
@@ -29,8 +27,6 @@ int deallocvt_main(int argc, char *argv[])
29 ); 27 );
30 } 28 }
31 29
32 progname = argv[0];
33
34 fd = get_console_fd("/dev/console"); 30 fd = get_console_fd("/dev/console");
35 31
36 if (argc == 1) { 32 if (argc == 1) {
@@ -43,14 +39,14 @@ int deallocvt_main(int argc, char *argv[])
43 for (i = 1; i < argc; i++) { 39 for (i = 1; i < argc; i++) {
44 num = atoi(argv[i]); 40 num = atoi(argv[i]);
45 if (num == 0) 41 if (num == 0)
46 fprintf(stderr, "%s: 0: illegal VT number\n", progname); 42 fprintf(stderr, "%s: 0: illegal VT number\n", applet_name);
47 else if (num == 1) 43 else if (num == 1)
48 fprintf(stderr, "%s: VT 1 cannot be deallocated\n", 44 fprintf(stderr, "%s: VT 1 cannot be deallocated\n",
49 progname); 45 applet_name);
50 else if (ioctl(fd, VT_DISALLOCATE, num)) { 46 else if (ioctl(fd, VT_DISALLOCATE, num)) {
51 perror("VT_DISALLOCATE"); 47 perror("VT_DISALLOCATE");
52 fprintf(stderr, "%s: could not deallocate console %d\n", 48 fprintf(stderr, "%s: could not deallocate console %d\n",
53 progname, num); 49 applet_name, num);
54 exit( FALSE); 50 exit( FALSE);
55 } 51 }
56 } 52 }
diff --git a/coreutils/cut.c b/coreutils/cut.c
index a8a9d7fd1..820074e60 100644
--- a/coreutils/cut.c
+++ b/coreutils/cut.c
@@ -71,7 +71,6 @@ int num_args;
71int mode; /* 0 = dump stdin to stdout, 1=-f, 2=-c */ 71int mode; /* 0 = dump stdin to stdout, 1=-f, 2=-c */
72char delim = '\t'; /* default delimiting character */ 72char delim = '\t'; /* default delimiting character */
73FILE *fd; 73FILE *fd;
74char *name;
75char line[BUFSIZ]; 74char line[BUFSIZ];
76int exit_status; 75int exit_status;
77int option = 0; /* for -s option */ 76int option = 0; /* for -s option */
@@ -91,7 +90,7 @@ void warn(int warn_number, char *option)
91 "%s: Cannot open %s\n" 90 "%s: Cannot open %s\n"
92 }; 91 };
93 92
94 fprintf(stderr, warn_msg[warn_number], name, option); 93 fprintf(stderr, warn_msg[warn_number], applet_name, option);
95 exit_status = warn_number + 1; 94 exit_status = warn_number + 1;
96 95
97} 96}
@@ -107,7 +106,7 @@ void cuterror(int err)
107 "%s: MAX_ARGS exceeded\n" 106 "%s: MAX_ARGS exceeded\n"
108 }; 107 };
109 108
110 fprintf(stderr, err_mes[err - 101], name); 109 fprintf(stderr, err_mes[err - 101], applet_name);
111 exit(err); 110 exit(err);
112} 111}
113 112
@@ -213,8 +212,6 @@ int cut_main(int argc, char **argv)
213 int i = 1; 212 int i = 1;
214 int numberFilenames = 0; 213 int numberFilenames = 0;
215 214
216 name = argv[0];
217
218 if (argc == 1 || strcmp(argv[1], dash_dash_help)==0) 215 if (argc == 1 || strcmp(argv[1], dash_dash_help)==0)
219 usage( "cut [OPTION]... [FILE]...\n" 216 usage( "cut [OPTION]... [FILE]...\n"
220#ifndef BB_FEATURE_TRIVIAL_HELP 217#ifndef BB_FEATURE_TRIVIAL_HELP
diff --git a/cp_mv.c b/cp_mv.c
index b15235a25..3dc637d7f 100644
--- a/cp_mv.c
+++ b/cp_mv.c
@@ -45,7 +45,6 @@
45#define is_cp 0 45#define is_cp 0
46#define is_mv 1 46#define is_mv 1
47static int dz_i; /* index into cp_mv_usage */ 47static int dz_i; /* index into cp_mv_usage */
48static const char *dz; /* dollar zero, .bss */
49static const char *cp_mv_usage[] = /* .rodata */ 48static const char *cp_mv_usage[] = /* .rodata */
50{ 49{
51 "cp [OPTION]... SOURCE DEST\n" 50 "cp [OPTION]... SOURCE DEST\n"
@@ -89,7 +88,7 @@ static void name_too_long__exit (void) __attribute__((noreturn));
89static 88static
90void name_too_long__exit (void) 89void name_too_long__exit (void)
91{ 90{
92 fprintf(stderr, name_too_long, dz); 91 fprintf(stderr, name_too_long, applet_name);
93 exit(FALSE); 92 exit(FALSE);
94} 93}
95 94
@@ -124,14 +123,14 @@ cp_mv_Action(const char *fileName, struct stat *statbuf, void* junk)
124 123
125 if (srcDirFlag == TRUE) { 124 if (srcDirFlag == TRUE) {
126 if (recursiveFlag == FALSE) { 125 if (recursiveFlag == FALSE) {
127 fprintf(stderr, omitting_directory, dz, baseSrcName); 126 fprintf(stderr, omitting_directory, applet_name, baseSrcName);
128 return TRUE; 127 return TRUE;
129 } 128 }
130 srcBasename = (strstr(fileName, baseSrcName) 129 srcBasename = (strstr(fileName, baseSrcName)
131 + strlen(baseSrcName)); 130 + strlen(baseSrcName));
132 131
133 if (destLen + strlen(srcBasename) > BUFSIZ) { 132 if (destLen + strlen(srcBasename) > BUFSIZ) {
134 fprintf(stderr, name_too_long, dz); 133 fprintf(stderr, name_too_long, applet_name);
135 return FALSE; 134 return FALSE;
136 } 135 }
137 strcat(destName, srcBasename); 136 strcat(destName, srcBasename);
@@ -146,7 +145,7 @@ cp_mv_Action(const char *fileName, struct stat *statbuf, void* junk)
146 mv_Action_first_time = errno = 0; 145 mv_Action_first_time = errno = 0;
147 if (rename(fileName, destName) < 0 && errno != EXDEV) { 146 if (rename(fileName, destName) < 0 && errno != EXDEV) {
148 fprintf(stderr, "%s: rename(%s, %s): %s\n", 147 fprintf(stderr, "%s: rename(%s, %s): %s\n",
149 dz, fileName, destName, strerror(errno)); 148 applet_name, fileName, destName, strerror(errno));
150 goto do_copyFile; /* Try anyway... */ 149 goto do_copyFile; /* Try anyway... */
151 } 150 }
152 else if (errno == EXDEV) 151 else if (errno == EXDEV)
@@ -159,7 +158,7 @@ cp_mv_Action(const char *fileName, struct stat *statbuf, void* junk)
159 if (is_in_ino_dev_hashtable(statbuf, &name)) { 158 if (is_in_ino_dev_hashtable(statbuf, &name)) {
160 if (link(name, destName) < 0) { 159 if (link(name, destName) < 0) {
161 fprintf(stderr, "%s: link(%s, %s): %s\n", 160 fprintf(stderr, "%s: link(%s, %s): %s\n",
162 dz, name, destName, strerror(errno)); 161 applet_name, name, destName, strerror(errno));
163 return FALSE; 162 return FALSE;
164 } 163 }
165 return TRUE; 164 return TRUE;
@@ -178,11 +177,11 @@ rm_Action(const char *fileName, struct stat *statbuf, void* junk)
178 177
179 if (S_ISDIR(statbuf->st_mode)) { 178 if (S_ISDIR(statbuf->st_mode)) {
180 if (rmdir(fileName) < 0) { 179 if (rmdir(fileName) < 0) {
181 fprintf(stderr, "%s: rmdir(%s): %s\n", dz, fileName, strerror(errno)); 180 fprintf(stderr, "%s: rmdir(%s): %s\n", applet_name, fileName, strerror(errno));
182 status = FALSE; 181 status = FALSE;
183 } 182 }
184 } else if (unlink(fileName) < 0) { 183 } else if (unlink(fileName) < 0) {
185 fprintf(stderr, "%s: unlink(%s): %s\n", dz, fileName, strerror(errno)); 184 fprintf(stderr, "%s: unlink(%s): %s\n", applet_name, fileName, strerror(errno));
186 status = FALSE; 185 status = FALSE;
187 } 186 }
188 return status; 187 return status;
@@ -190,8 +189,7 @@ rm_Action(const char *fileName, struct stat *statbuf, void* junk)
190 189
191extern int cp_mv_main(int argc, char **argv) 190extern int cp_mv_main(int argc, char **argv)
192{ 191{
193 dz = *argv; /* already basename'd by busybox.c:main */ 192 if (*applet_name == 'c' && *(applet_name + 1) == 'p')
194 if (*dz == 'c' && *(dz + 1) == 'p')
195 dz_i = is_cp; 193 dz_i = is_cp;
196 else 194 else
197 dz_i = is_mv; 195 dz_i = is_mv;
@@ -276,20 +274,20 @@ extern int cp_mv_main(int argc, char **argv)
276 char *pushd, *d, *p; 274 char *pushd, *d, *p;
277 275
278 if ((pushd = getcwd(NULL, BUFSIZ + 1)) == NULL) { 276 if ((pushd = getcwd(NULL, BUFSIZ + 1)) == NULL) {
279 fprintf(stderr, "%s: getcwd(): %s\n", dz, strerror(errno)); 277 fprintf(stderr, "%s: getcwd(): %s\n", applet_name, strerror(errno));
280 continue; 278 continue;
281 } 279 }
282 if (chdir(baseDestName) < 0) { 280 if (chdir(baseDestName) < 0) {
283 fprintf(stderr, "%s: chdir(%s): %s\n", dz, baseSrcName, strerror(errno)); 281 fprintf(stderr, "%s: chdir(%s): %s\n", applet_name, baseSrcName, strerror(errno));
284 continue; 282 continue;
285 } 283 }
286 if ((d = getcwd(NULL, BUFSIZ + 1)) == NULL) { 284 if ((d = getcwd(NULL, BUFSIZ + 1)) == NULL) {
287 fprintf(stderr, "%s: getcwd(): %s\n", dz, strerror(errno)); 285 fprintf(stderr, "%s: getcwd(): %s\n", applet_name, strerror(errno));
288 continue; 286 continue;
289 } 287 }
290 while (!state && *d != '\0') { 288 while (!state && *d != '\0') {
291 if (stat(d, &sb) < 0) { /* stat not lstat - always dereference targets */ 289 if (stat(d, &sb) < 0) { /* stat not lstat - always dereference targets */
292 fprintf(stderr, "%s: stat(%s) :%s\n", dz, d, strerror(errno)); 290 fprintf(stderr, "%s: stat(%s) :%s\n", applet_name, d, strerror(errno));
293 state = -1; 291 state = -1;
294 continue; 292 continue;
295 } 293 }
@@ -298,7 +296,7 @@ extern int cp_mv_main(int argc, char **argv)
298 fprintf(stderr, 296 fprintf(stderr,
299 "%s: Cannot %s `%s' " 297 "%s: Cannot %s `%s' "
300 "into a subdirectory of itself, `%s/%s'\n", 298 "into a subdirectory of itself, `%s/%s'\n",
301 dz, dz, baseSrcName, baseDestName, baseSrcName); 299 applet_name, applet_name, baseSrcName, baseDestName, baseSrcName);
302 state = -1; 300 state = -1;
303 continue; 301 continue;
304 } 302 }
@@ -307,7 +305,7 @@ extern int cp_mv_main(int argc, char **argv)
307 } 305 }
308 } 306 }
309 if (chdir(pushd) < 0) { 307 if (chdir(pushd) < 0) {
310 fprintf(stderr, "%s: chdir(%s): %s\n", dz, pushd, strerror(errno)); 308 fprintf(stderr, "%s: chdir(%s): %s\n", applet_name, pushd, strerror(errno));
311 free(pushd); 309 free(pushd);
312 free(d); 310 free(d);
313 continue; 311 continue;
diff --git a/cut.c b/cut.c
index a8a9d7fd1..820074e60 100644
--- a/cut.c
+++ b/cut.c
@@ -71,7 +71,6 @@ int num_args;
71int mode; /* 0 = dump stdin to stdout, 1=-f, 2=-c */ 71int mode; /* 0 = dump stdin to stdout, 1=-f, 2=-c */
72char delim = '\t'; /* default delimiting character */ 72char delim = '\t'; /* default delimiting character */
73FILE *fd; 73FILE *fd;
74char *name;
75char line[BUFSIZ]; 74char line[BUFSIZ];
76int exit_status; 75int exit_status;
77int option = 0; /* for -s option */ 76int option = 0; /* for -s option */
@@ -91,7 +90,7 @@ void warn(int warn_number, char *option)
91 "%s: Cannot open %s\n" 90 "%s: Cannot open %s\n"
92 }; 91 };
93 92
94 fprintf(stderr, warn_msg[warn_number], name, option); 93 fprintf(stderr, warn_msg[warn_number], applet_name, option);
95 exit_status = warn_number + 1; 94 exit_status = warn_number + 1;
96 95
97} 96}
@@ -107,7 +106,7 @@ void cuterror(int err)
107 "%s: MAX_ARGS exceeded\n" 106 "%s: MAX_ARGS exceeded\n"
108 }; 107 };
109 108
110 fprintf(stderr, err_mes[err - 101], name); 109 fprintf(stderr, err_mes[err - 101], applet_name);
111 exit(err); 110 exit(err);
112} 111}
113 112
@@ -213,8 +212,6 @@ int cut_main(int argc, char **argv)
213 int i = 1; 212 int i = 1;
214 int numberFilenames = 0; 213 int numberFilenames = 0;
215 214
216 name = argv[0];
217
218 if (argc == 1 || strcmp(argv[1], dash_dash_help)==0) 215 if (argc == 1 || strcmp(argv[1], dash_dash_help)==0)
219 usage( "cut [OPTION]... [FILE]...\n" 216 usage( "cut [OPTION]... [FILE]...\n"
220#ifndef BB_FEATURE_TRIVIAL_HELP 217#ifndef BB_FEATURE_TRIVIAL_HELP
diff --git a/deallocvt.c b/deallocvt.c
index 0cad7717b..53d4d9a7c 100644
--- a/deallocvt.c
+++ b/deallocvt.c
@@ -14,8 +14,6 @@
14#define VT_DISALLOCATE 0x5608 /* free memory associated to vt */ 14#define VT_DISALLOCATE 0x5608 /* free memory associated to vt */
15 15
16 16
17char *progname;
18
19int deallocvt_main(int argc, char *argv[]) 17int deallocvt_main(int argc, char *argv[])
20{ 18{
21 int fd, num, i; 19 int fd, num, i;
@@ -29,8 +27,6 @@ int deallocvt_main(int argc, char *argv[])
29 ); 27 );
30 } 28 }
31 29
32 progname = argv[0];
33
34 fd = get_console_fd("/dev/console"); 30 fd = get_console_fd("/dev/console");
35 31
36 if (argc == 1) { 32 if (argc == 1) {
@@ -43,14 +39,14 @@ int deallocvt_main(int argc, char *argv[])
43 for (i = 1; i < argc; i++) { 39 for (i = 1; i < argc; i++) {
44 num = atoi(argv[i]); 40 num = atoi(argv[i]);
45 if (num == 0) 41 if (num == 0)
46 fprintf(stderr, "%s: 0: illegal VT number\n", progname); 42 fprintf(stderr, "%s: 0: illegal VT number\n", applet_name);
47 else if (num == 1) 43 else if (num == 1)
48 fprintf(stderr, "%s: VT 1 cannot be deallocated\n", 44 fprintf(stderr, "%s: VT 1 cannot be deallocated\n",
49 progname); 45 applet_name);
50 else if (ioctl(fd, VT_DISALLOCATE, num)) { 46 else if (ioctl(fd, VT_DISALLOCATE, num)) {
51 perror("VT_DISALLOCATE"); 47 perror("VT_DISALLOCATE");
52 fprintf(stderr, "%s: could not deallocate console %d\n", 48 fprintf(stderr, "%s: could not deallocate console %d\n",
53 progname, num); 49 applet_name, num);
54 exit( FALSE); 50 exit( FALSE);
55 } 51 }
56 } 52 }