From 62f70f8fd5bdacdb9b1c5813003db5439302d4c9 Mon Sep 17 00:00:00 2001 From: Pierre Pronchery Date: Sun, 22 Mar 2015 17:44:50 +0100 Subject: [PATCH] Using PROGNAME for mailer(1) and compose(1) --- src/compose-main.c | 17 ++++++++++++++++- src/main.c | 21 ++++++++++++++++++++- 2 files changed, 36 insertions(+), 2 deletions(-) diff --git a/src/compose-main.c b/src/compose-main.c index a8b7da6..f51954c 100644 --- a/src/compose-main.c +++ b/src/compose-main.c @@ -36,6 +36,9 @@ #ifndef LOCALEDIR # define LOCALEDIR DATADIR "/locale" #endif +#ifndef PROGNAME +# define PROGNAME "compose" +#endif /* private */ @@ -43,6 +46,9 @@ static Compose * _compose(Config * config, char const * subject, int toc, char * tov[]); +static int _error(char const * message, int ret); +static int _usage(void); + /* functions */ /* compose */ @@ -88,10 +94,19 @@ static Config * _compose_config(void) } +/* error */ +static int _error(char const * message, int ret) +{ + fputs(PROGNAME, stderr); + perror(message); + return ret; +} + + /* usage */ static int _usage(void) { - fputs(_("Usage: compose [-s subject] address...\n"), stderr); + fprintf(stderr, _("Usage: %s [-s subject] address...\n"), PROGNAME); return 1; } diff --git a/src/main.c b/src/main.c index 5e215d8..16fc6e0 100644 --- a/src/main.c +++ b/src/main.c @@ -35,13 +35,32 @@ #ifndef LOCALEDIR # define LOCALEDIR DATADIR "/locale" #endif +#ifndef PROGNAME +# define PROGNAME "mailer" +#endif + + +/* Mailer */ +/* private */ +/* prototypes */ +static int _error(char const * message, int ret); +static int _usage(void); /* functions */ +/* error */ +static int _error(char const * message, int ret) +{ + fputs(PROGNAME, stderr); + perror(message); + return ret; +} + + /* usage */ static int _usage(void) { - fputs(_("Usage: mailer\n"), stderr); + fprintf(stderr, _("Usage: %s\n"), PROGNAME); return 1; }