]> pd.if.org Git - pdclib/blob - functions/stdio/perror.c
Ad-hoc solutions for perror() and strerror().
[pdclib] / functions / stdio / perror.c
1 /* $Id$ */
2
3 /* perror( const char * )
4
5    This file is part of the Public Domain C Library (PDCLib).
6    Permission is granted to use, modify, and / or redistribute at will.
7 */
8
9 #include <stdio.h>
10
11 #ifndef REGTEST
12
13 #include <errno.h>
14
15 /* TODO: Doing this via a static array is not the way to do it. */
16 void perror( const char * s )
17 {
18     if ( ( s != NULL ) && ( s[0] != '\n' ) )
19     {
20         fprintf( stderr, "%s: ", s );
21     }
22     fprintf( stderr, "%s\n", _PDCLIB_errno_texts[ errno ] );
23     return;
24 }
25
26 #endif
27
28 #ifdef TEST
29 #include <_PDCLIB_test.h>
30
31 int main( void )
32 {
33     TESTCASE( NO_TESTDRIVER );
34     return TEST_RESULTS;
35 }
36
37 #endif