Use PROGNAME in more programs
This commit is contained in:
parent
27e918dfc7
commit
ae4148e6f0
|
@ -19,6 +19,11 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
/* constants */
|
||||||
|
#ifndef PROGNAME
|
||||||
|
# define PROGNAME "cat"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/* cat */
|
/* cat */
|
||||||
/* types */
|
/* types */
|
||||||
|
@ -68,7 +73,7 @@ static int _cat(OutputDelay od, int argc, char * argv[])
|
||||||
|
|
||||||
static int _cat_error(char const * message, int ret)
|
static int _cat_error(char const * message, int ret)
|
||||||
{
|
{
|
||||||
fputs("cat: ", stderr);
|
fputs(PROGNAME ": ", stderr);
|
||||||
perror(message);
|
perror(message);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -97,7 +102,7 @@ static int _write_nonbuf(int c)
|
||||||
/* usage */
|
/* usage */
|
||||||
static int _usage(void)
|
static int _usage(void)
|
||||||
{
|
{
|
||||||
fputs("Usage: cat [-u][file ...]\n\
|
fputs("Usage: " PROGNAME " [-u][file ...]\n\
|
||||||
-u Write without delay\n", stderr);
|
-u Write without delay\n", stderr);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
15
src/chgrp.c
15
src/chgrp.c
|
@ -25,6 +25,11 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
/* constants */
|
||||||
|
#ifndef PROGNAME
|
||||||
|
# define PROGNAME "chgrp"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/* chgrp */
|
/* chgrp */
|
||||||
/* types */
|
/* types */
|
||||||
|
@ -66,7 +71,7 @@ static int _chgrp_grp_error(char * group)
|
||||||
{
|
{
|
||||||
if(errno == 0)
|
if(errno == 0)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "%s%s%s", "chgrp: ", group,
|
fprintf(stderr, "%s%s%s", PROGNAME ": ", group,
|
||||||
": Unknown group\n");
|
": Unknown group\n");
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
|
@ -75,7 +80,7 @@ static int _chgrp_grp_error(char * group)
|
||||||
|
|
||||||
static int _chgrp_error(char * message, int ret)
|
static int _chgrp_error(char * message, int ret)
|
||||||
{
|
{
|
||||||
fputs("chgrp: ", stderr);
|
fputs(PROGNAME ": ", stderr);
|
||||||
perror(message);
|
perror(message);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -150,8 +155,8 @@ static int _chgrp_do(int opts, gid_t gid, char * file)
|
||||||
/* usage */
|
/* usage */
|
||||||
static int _usage(void)
|
static int _usage(void)
|
||||||
{
|
{
|
||||||
fputs("Usage: chgrp [-hR] group file ...\n\
|
fputs("Usage: " PROGNAME " [-hR] group file ...\n\
|
||||||
chgrp -R [-H | -L | -P] group file ...\n\
|
" PROGNAME " -R [-H | -L | -P] group file ...\n\
|
||||||
-h Set the group IDs on symbolic links\n\
|
-h Set the group IDs on symbolic links\n\
|
||||||
-R Recursively change file group IDs\n", stderr);
|
-R Recursively change file group IDs\n", stderr);
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -178,7 +183,7 @@ int main(int argc, char * argv[])
|
||||||
case 'L':
|
case 'L':
|
||||||
case 'P':
|
case 'P':
|
||||||
/* FIXME implement */
|
/* FIXME implement */
|
||||||
fprintf(stderr, "%s%c%s", "chgrp: -", o,
|
fprintf(stderr, "%s%c%s", PROGNAME ": -", o,
|
||||||
": Not yet implemented\n");
|
": Not yet implemented\n");
|
||||||
default:
|
default:
|
||||||
return _usage();
|
return _usage();
|
||||||
|
|
|
@ -26,6 +26,11 @@
|
||||||
#define COMMON_MODE
|
#define COMMON_MODE
|
||||||
#include "common.c"
|
#include "common.c"
|
||||||
|
|
||||||
|
/* constants */
|
||||||
|
#ifndef PROGNAME
|
||||||
|
# define PROGNAME "chmod"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/* types */
|
/* types */
|
||||||
typedef int Prefs;
|
typedef int Prefs;
|
||||||
|
@ -52,7 +57,7 @@ static int _chmod(Prefs prefs, mode_t mode, int filec, char * filev[])
|
||||||
|
|
||||||
static int _chmod_error(char const * message, int ret)
|
static int _chmod_error(char const * message, int ret)
|
||||||
{
|
{
|
||||||
fputs("chmod: ", stderr);
|
fputs(PROGNAME ": ", stderr);
|
||||||
perror(message);
|
perror(message);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -121,7 +126,7 @@ static int _chmod_do_recursive_do(Prefs prefs, mode_t mode, char * file)
|
||||||
/* usage */
|
/* usage */
|
||||||
static int _usage(void)
|
static int _usage(void)
|
||||||
{
|
{
|
||||||
fputs("Usage: chmod [-R] mode file\n\
|
fputs("Usage: " PROGNAME " [-R] mode file\n\
|
||||||
-R Recursively change file mode bits\n", stderr);
|
-R Recursively change file mode bits\n", stderr);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
17
src/chown.c
17
src/chown.c
|
@ -27,6 +27,11 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
|
||||||
|
/* constants */
|
||||||
|
#ifndef PROGNAME
|
||||||
|
# define PROGNAME "chown"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/* types */
|
/* types */
|
||||||
typedef int Prefs;
|
typedef int Prefs;
|
||||||
|
@ -65,7 +70,7 @@ static int _chown(Prefs * prefs, char * owner, int argc, char * argv[])
|
||||||
|
|
||||||
static int _chown_error(char * message, int ret)
|
static int _chown_error(char * message, int ret)
|
||||||
{
|
{
|
||||||
fputs("chown: ", stderr);
|
fputs(PROGNAME ": ", stderr);
|
||||||
perror(message);
|
perror(message);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -112,8 +117,8 @@ static int _chown_id_error(char * message, char * unknown, int ret)
|
||||||
{
|
{
|
||||||
if(errno != 0)
|
if(errno != 0)
|
||||||
return _chown_error(message, ret);
|
return _chown_error(message, ret);
|
||||||
fprintf(stderr, "%s%s%s%s%s", "chown: ", message, ": Unknown ", unknown,
|
fprintf(stderr, "%s%s%s%s%s", PROGNAME ": ", message, ": Unknown ",
|
||||||
"\n");
|
unknown, "\n");
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -202,8 +207,8 @@ static int _chown_do(Prefs * prefs, uid_t uid, gid_t gid, char * file)
|
||||||
/* usage */
|
/* usage */
|
||||||
static int _usage(void)
|
static int _usage(void)
|
||||||
{
|
{
|
||||||
fputs("Usage: chown [-hR] owner[:group] file ...\n\
|
fputs("Usage: " PROGNAME " [-hR] owner[:group] file ...\n\
|
||||||
chown -R [-H | -L | -P] owner[:group] file ...\n\
|
" PROGNAME " -R [-H | -L | -P] owner[:group] file ...\n\
|
||||||
-h Set the user and group IDs on symbolic links\n\
|
-h Set the user and group IDs on symbolic links\n\
|
||||||
-R Recursively change file user and group IDs\n", stderr);
|
-R Recursively change file user and group IDs\n", stderr);
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -228,7 +233,7 @@ int main(int argc, char * argv[])
|
||||||
case 'H':
|
case 'H':
|
||||||
case 'L':
|
case 'L':
|
||||||
case 'P':
|
case 'P':
|
||||||
fprintf(stderr, "%s%c%s", "chown: -", o,
|
fprintf(stderr, "%s%c%s", PROGNAME ": -", o,
|
||||||
": Not yet implemented\n");
|
": Not yet implemented\n");
|
||||||
default:
|
default:
|
||||||
return _usage();
|
return _usage();
|
||||||
|
|
Loading…
Reference in New Issue
Block a user