-
-
Notifications
You must be signed in to change notification settings - Fork 606
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add GNU libc extension function error()
This patch adds GNU libc extension function error() as specified at https://linux.die.net/man/3/error. This function is used by core utils programs on Linux. Signed-off-by: Waldemar Kozaczuk <[email protected]> Message-Id: <[email protected]>
- Loading branch information
Showing
2 changed files
with
38 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/* | ||
* Copyright (C) 2019 Waldemar Kozaczuk | ||
* | ||
* This work is open source software, licensed under the terms of the | ||
* BSD license as described in the LICENSE file in the top-level directory. | ||
*/ | ||
|
||
#include <stdlib.h> | ||
#include <stdio.h> | ||
#include <stdarg.h> | ||
#include <string.h> | ||
|
||
extern char *program_invocation_name; | ||
|
||
void | ||
error (int status, int errnum, const char *message, ...) | ||
{ | ||
fflush(stdout); | ||
|
||
fprintf(stderr, "%s: ", program_invocation_name); | ||
|
||
va_list args; | ||
int ret; | ||
va_start(args, message); | ||
ret = vfprintf(stderr, message, args); | ||
va_end(args); | ||
|
||
if (errnum) { | ||
fprintf(stderr, ": %s", strerror(errnum)); | ||
} | ||
|
||
fprintf(stderr, "\n" ); | ||
|
||
if (status) { | ||
exit(status); | ||
} | ||
} |