First release

This commit is contained in:
hjp 1999-08-01 18:09:10 +00:00
parent bc6bf4ec9b
commit 9c27ca365e
3 changed files with 26 additions and 7 deletions

View File

@ -1,7 +1,7 @@
include GNUmakevars include GNUmakevars
include GNUmakerules include GNUmakerules
all: scat all: scat $(patsubst %.msg, %.cat, $(wildcard *.msg))
scat: scat.o scat: scat.o
scat.o: scat.c scat.h scat.o: scat.c scat.h

View File

@ -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 <ctype.h> #include <ctype.h>
#include <errno.h>
#include <locale.h> #include <locale.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h>
#include <features.h> #include <features.h>
#include <nl_types.h> #include <nl_types.h>
@ -29,10 +43,9 @@ void do_safecat(const char *filename) {
fp = stdin; fp = stdin;
} else { } else {
if ((fp = fopen(filename, "r")) == NULL) { if ((fp = fopen(filename, "r")) == NULL) {
fprintf(stderr, fprintf(stderr, catgets(catalog, MSG_Set, MSG_OPEN,
catgets(catalog, MSG_Set, MSG_OPEN,
"%s: cannot open `%s' for reading: %s\n"), "%s: cannot open `%s' for reading: %s\n"),
cmnd, filename); cmnd, filename, strerror(errno));
exit(1); exit(1);
} }
} }
@ -42,7 +55,7 @@ void do_safecat(const char *filename) {
fprintf(stderr, fprintf(stderr,
catgets(catalog, MSG_Set, MSG_WRITE, catgets(catalog, MSG_Set, MSG_WRITE,
"%s: cannot write stdout: %s\n"), "%s: cannot write stdout: %s\n"),
cmnd, filename); cmnd, strerror(errno));
exit(1); exit(1);
} }
} else { } else {
@ -50,7 +63,7 @@ void do_safecat(const char *filename) {
fprintf(stderr, fprintf(stderr,
catgets(catalog, MSG_Set, MSG_WRITE, catgets(catalog, MSG_Set, MSG_WRITE,
"%s: cannot write stdout: %s\n"), "%s: cannot write stdout: %s\n"),
cmnd, filename); cmnd, strerror(errno));
exit(1); exit(1);
} }
} }
@ -59,7 +72,7 @@ void do_safecat(const char *filename) {
fprintf(stderr, fprintf(stderr,
catgets(catalog, MSG_Set, MSG_READ, catgets(catalog, MSG_Set, MSG_READ,
"%s: cannot read from `%s': %s\n"), "%s: cannot read from `%s': %s\n"),
cmnd, filename); cmnd, filename, strerror(errno));
exit(1); exit(1);
} }
if (strcmp(filename, "-") == 0) { if (strcmp(filename, "-") == 0) {
@ -73,6 +86,7 @@ void do_safecat(const char *filename) {
int main(int argc, char **argv) { int main(int argc, char **argv) {
setlocale(LC_ALL, ""); setlocale(LC_ALL, "");
cmnd = argv[0];
catalog = catopen("scat", 0); catalog = catopen("scat", 0);
if (argc == 1) { if (argc == 1) {
do_safecat("-"); do_safecat("-");

5
scat/scat.de.msg Normal file
View File

@ -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