diff options
author | Bruce Momjian <bruce@momjian.us> | 2002-07-18 04:13:59 +0000 |
---|---|---|
committer | Bruce Momjian <bruce@momjian.us> | 2002-07-18 04:13:59 +0000 |
commit | 404e9a12a5aef6d77af9b407c5737cb688f8e1cc (patch) | |
tree | a79dc34675672225ef7d7f802832f65efd4da2fb /src/port/strerror.c | |
parent | 7f43165dd272f6df9e3df8a0fa8386ad60276e4a (diff) | |
download | postgresql-404e9a12a5aef6d77af9b407c5737cb688f8e1cc.tar.gz postgresql-404e9a12a5aef6d77af9b407c5737cb688f8e1cc.zip |
Move libc replacement files from src/backend/port to src/port.
Diffstat (limited to 'src/port/strerror.c')
-rw-r--r-- | src/port/strerror.c | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/src/port/strerror.c b/src/port/strerror.c new file mode 100644 index 00000000000..b878388ea25 --- /dev/null +++ b/src/port/strerror.c @@ -0,0 +1,31 @@ +/* $Id: strerror.c,v 1.1 2002/07/18 04:13:59 momjian Exp $ */ + +/* + * strerror - map error number to descriptive string + * + * This version is obviously somewhat Unix-specific. + * + * based on code by Henry Spencer + * modified for ANSI by D'Arcy J.M. Cain + */ + +#include <string.h> +#include <stdio.h> +#include <errno.h> + +extern const char *const sys_errlist[]; +extern int sys_nerr; + +const char * +strerror(int errnum) +{ + static char buf[24]; + + if (errnum < 0 || errnum > sys_nerr) + { + sprintf(buf, "unknown error %d", errnum); + return buf; + } + + return sys_errlist[errnum]; +} |