2003-11-29 23:41:33 +01:00
|
|
|
/* $PostgreSQL: pgsql/src/port/strerror.c,v 1.3 2003/11/29 22:41:31 pgsql Exp $ */
|
1997-12-19 14:35:17 +01:00
|
|
|
|
1997-03-19 03:37:42 +01:00
|
|
|
/*
|
|
|
|
* 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
|
|
|
|
*/
|
|
|
|
|
1999-07-16 01:04:24 +02:00
|
|
|
#include <string.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <errno.h>
|
1997-03-19 03:37:42 +01:00
|
|
|
|
1997-09-07 07:04:48 +02:00
|
|
|
extern const char *const sys_errlist[];
|
1997-09-08 04:41:22 +02:00
|
|
|
extern int sys_nerr;
|
1997-03-19 03:37:42 +01:00
|
|
|
|
1997-09-08 04:41:22 +02:00
|
|
|
const char *
|
1997-03-19 03:37:42 +01:00
|
|
|
strerror(int errnum)
|
|
|
|
{
|
1997-09-08 04:41:22 +02:00
|
|
|
static char buf[24];
|
1997-03-19 03:37:42 +01:00
|
|
|
|
1997-09-07 07:04:48 +02:00
|
|
|
if (errnum < 0 || errnum > sys_nerr)
|
|
|
|
{
|
2003-07-28 02:09:16 +02:00
|
|
|
sprintf(buf, "unrecognized error %d", errnum);
|
1998-09-01 05:29:17 +02:00
|
|
|
return buf;
|
1997-09-07 07:04:48 +02:00
|
|
|
}
|
1997-03-19 03:37:42 +01:00
|
|
|
|
1998-09-01 05:29:17 +02:00
|
|
|
return sys_errlist[errnum];
|
1997-03-19 03:37:42 +01:00
|
|
|
}
|