From 9c27ca365ec4cb55095dc01ffc89448ed0bd806a Mon Sep 17 00:00:00 2001 From: hjp Date: Sun, 1 Aug 1999 18:09:10 +0000 Subject: [PATCH] First release --- scat/GNUmakefile | 2 +- scat/scat.c | 26 ++++++++++++++++++++------ scat/scat.de.msg | 5 +++++ 3 files changed, 26 insertions(+), 7 deletions(-) create mode 100644 scat/scat.de.msg diff --git a/scat/GNUmakefile b/scat/GNUmakefile index 5010a19..2f8f54a 100644 --- a/scat/GNUmakefile +++ b/scat/GNUmakefile @@ -1,7 +1,7 @@ include GNUmakevars include GNUmakerules -all: scat +all: scat $(patsubst %.msg, %.cat, $(wildcard *.msg)) scat: scat.o scat.o: scat.c scat.h diff --git a/scat/scat.c b/scat/scat.c index 93e2bab..05ca921 100644 --- a/scat/scat.c +++ b/scat/scat.c @@ -1,7 +1,21 @@ +char scat_c_cvs_version[] = + "$Id: scat.c,v 1.2 1999-08-01 18:09:09 hjp Exp $"; +/* scat - safe cat + * + * catenate input files and print to standard output. + * replace all non-printable characters with C \xXX escapes. + * + * $Log: scat.c,v $ + * Revision 1.2 1999-08-01 18:09:09 hjp + * First release + * + */ #include +#include #include #include #include +#include #include #include @@ -29,10 +43,9 @@ void do_safecat(const char *filename) { fp = stdin; } else { if ((fp = fopen(filename, "r")) == NULL) { - fprintf(stderr, - catgets(catalog, MSG_Set, MSG_OPEN, + fprintf(stderr, catgets(catalog, MSG_Set, MSG_OPEN, "%s: cannot open `%s' for reading: %s\n"), - cmnd, filename); + cmnd, filename, strerror(errno)); exit(1); } } @@ -42,7 +55,7 @@ void do_safecat(const char *filename) { fprintf(stderr, catgets(catalog, MSG_Set, MSG_WRITE, "%s: cannot write stdout: %s\n"), - cmnd, filename); + cmnd, strerror(errno)); exit(1); } } else { @@ -50,7 +63,7 @@ void do_safecat(const char *filename) { fprintf(stderr, catgets(catalog, MSG_Set, MSG_WRITE, "%s: cannot write stdout: %s\n"), - cmnd, filename); + cmnd, strerror(errno)); exit(1); } } @@ -59,7 +72,7 @@ void do_safecat(const char *filename) { fprintf(stderr, catgets(catalog, MSG_Set, MSG_READ, "%s: cannot read from `%s': %s\n"), - cmnd, filename); + cmnd, filename, strerror(errno)); exit(1); } if (strcmp(filename, "-") == 0) { @@ -73,6 +86,7 @@ void do_safecat(const char *filename) { int main(int argc, char **argv) { setlocale(LC_ALL, ""); + cmnd = argv[0]; catalog = catopen("scat", 0); if (argc == 1) { do_safecat("-"); diff --git a/scat/scat.de.msg b/scat/scat.de.msg new file mode 100644 index 0000000..ebc1564 --- /dev/null +++ b/scat/scat.de.msg @@ -0,0 +1,5 @@ +$set MSG_ +USAGE Verwendung: %s [File ...]\n +OPEN %s: Kann `%s' nicht zum Lesen öffnen: %s\n +WRITE %s: Kann nicht auf stdout schreiben: %s\n +READ %s: Kann nicht von `%s' lesen: %s\n