Unified error output

This commit is contained in:
Pierre Pronchery 2005-02-14 12:58:44 +00:00
parent 37bb1bc062
commit 91bf2347d3

View File

@ -21,6 +21,7 @@ typedef enum _OutputDelay {
* returns:
* 0 successful
* 2 an error occured */
static int _cat_error(char * message, int ret);
static void _cat_file(FILE * fp, OutputDelay od);
static int _cat(OutputDelay od, int argc, char * argv[])
{
@ -40,8 +41,7 @@ static int _cat(OutputDelay od, int argc, char * argv[])
fp = stdin;
else if((fp = fopen(argv[i], "r")) == NULL)
{
perror("fopen");
res = 2;
res = _cat_error(argv[i], 2);
continue;
}
_cat_file(fp, od);
@ -51,6 +51,13 @@ static int _cat(OutputDelay od, int argc, char * argv[])
return res;
}
static int _cat_error(char * message, int ret)
{
fprintf(stderr, "%s", "cat: ");
perror(message);
return ret;
}
static int _write_nonbuf(int c);
static int _write_buf(int c);
static void _cat_file(FILE * fp, OutputDelay od)