Use PROGNAME in more programs
This commit is contained in:
parent
958892932e
commit
ee313c8e05
|
@ -22,6 +22,11 @@
|
|||
#include <string.h>
|
||||
#include <errno.h>
|
||||
|
||||
/* constants */
|
||||
#ifndef PROGNAME
|
||||
# define PROGNAME "cksum"
|
||||
#endif
|
||||
|
||||
|
||||
/* constants */
|
||||
static unsigned long crctab[] =
|
||||
|
@ -108,7 +113,7 @@ static int _cksum(int argc, char * argv[])
|
|||
|
||||
static int _cksum_error(char * message, int ret)
|
||||
{
|
||||
fputs("cksum: ", stderr);
|
||||
fputs(PROGNAME ": ", stderr);
|
||||
perror(message);
|
||||
return ret;
|
||||
}
|
||||
|
@ -159,7 +164,7 @@ static int _do_is_directory(FILE * fp)
|
|||
/* usage */
|
||||
static int _usage(void)
|
||||
{
|
||||
fputs("Usage: cksum [file...]\n", stderr);
|
||||
fputs("Usage: " PROGNAME " [file...]\n", stderr);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
13
src/cmp.c
13
src/cmp.c
|
@ -19,6 +19,11 @@
|
|||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
/* constants */
|
||||
#ifndef PROGNAME
|
||||
# define PROGNAME "cmp"
|
||||
#endif
|
||||
|
||||
|
||||
/* types */
|
||||
typedef enum _OutputType
|
||||
|
@ -56,7 +61,7 @@ static int _cmp(OutputType ot, char const * file1, char const * file2)
|
|||
|
||||
static int _cmp_error(char const * message, int ret)
|
||||
{
|
||||
fputs("cmp: ", stderr);
|
||||
fputs(PROGNAME ": ", stderr);
|
||||
perror(message);
|
||||
return ret;
|
||||
}
|
||||
|
@ -79,8 +84,8 @@ static int _cmp_files(OutputType ot, char const * file1, char const * file2,
|
|||
if(c1 == EOF || c2 == EOF)
|
||||
{
|
||||
if(ot != OT_NONE)
|
||||
fprintf(stderr, "%s%s\n", "cmp: EOF on ",
|
||||
c1 == EOF ? file1 : file2);
|
||||
fprintf(stderr, "%s%s\n", PROGNAME ": EOF on ",
|
||||
(c1 == EOF) ? file1 : file2);
|
||||
ret = 1;
|
||||
break;
|
||||
}
|
||||
|
@ -113,7 +118,7 @@ static int _cmp_files(OutputType ot, char const * file1, char const * file2,
|
|||
/* usage */
|
||||
static int _usage(void)
|
||||
{
|
||||
fputs("Usage: cmp [-l|-s] file1 file2\n\
|
||||
fputs("Usage: " PROGNAME " [-l|-s] file1 file2\n\
|
||||
-l Write the byte number and the differing byte for each difference\n\
|
||||
-s Write nothing for differing bytes\n", stderr);
|
||||
return 2;
|
||||
|
|
|
@ -19,6 +19,11 @@
|
|||
#include <stdio.h>
|
||||
#include <time.h>
|
||||
|
||||
/* constants */
|
||||
#ifndef PROGNAME
|
||||
# define PROGNAME "date"
|
||||
#endif
|
||||
|
||||
|
||||
/* date */
|
||||
/* private */
|
||||
|
@ -51,7 +56,7 @@ static int _date(char const * format)
|
|||
/* error */
|
||||
static int _date_error(char const * message, int ret)
|
||||
{
|
||||
fputs("date: ", stderr);
|
||||
fputs(PROGNAME ": ", stderr);
|
||||
perror(message);
|
||||
return ret;
|
||||
}
|
||||
|
@ -60,7 +65,7 @@ static int _date_error(char const * message, int ret)
|
|||
/* usage */
|
||||
static int _usage(void)
|
||||
{
|
||||
fputs("Usage: date [+format]\n", stderr);
|
||||
fputs("Usage: " PROGNAME " [+format]\n", stderr);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
9
src/df.c
9
src/df.c
|
@ -23,6 +23,11 @@
|
|||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
/* constants */
|
||||
#ifndef PROGNAME
|
||||
# define PROGNAME "df"
|
||||
#endif
|
||||
|
||||
|
||||
/* Prefs */
|
||||
typedef int Prefs;
|
||||
|
@ -52,7 +57,7 @@ static int _df(Prefs * prefs, int filec, char * filev[])
|
|||
|
||||
static int _df_error(char const * message, int ret)
|
||||
{
|
||||
fputs("df: ", stderr);
|
||||
fputs(PROGNAME ": ", stderr);
|
||||
perror(message);
|
||||
return ret;
|
||||
}
|
||||
|
@ -147,7 +152,7 @@ static int _df_do(Prefs * prefs, char const * file)
|
|||
/* usage */
|
||||
static int _usage(void)
|
||||
{
|
||||
fputs("Usage: df [-k][-P][file...]\n", stderr);
|
||||
fputs("Usage: " PROGNAME " [-k][-P][file...]\n", stderr);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user