2023-03-02 21:10:44 +02:00
|
|
|
#include <errno.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
int errno = 0;
|
|
|
|
|
|
|
|
char* strerror(int error)
|
|
|
|
{
|
2023-03-02 22:13:08 +02:00
|
|
|
static char buffer[100];
|
|
|
|
buffer[0] = 0;
|
|
|
|
|
2023-03-02 21:10:44 +02:00
|
|
|
switch (error)
|
|
|
|
{
|
|
|
|
case ENOMEM:
|
2023-03-02 22:13:08 +02:00
|
|
|
strcpy(buffer, "Cannot allocate memory");
|
|
|
|
break;
|
2023-03-02 21:10:44 +02:00
|
|
|
case EINVAL:
|
2023-03-02 22:13:08 +02:00
|
|
|
strcpy(buffer, "Invalid argument");
|
|
|
|
break;
|
2023-03-02 21:10:44 +02:00
|
|
|
case EISDIR:
|
2023-03-02 22:13:08 +02:00
|
|
|
strcpy(buffer, "Is a directory");
|
|
|
|
break;
|
2023-03-02 21:10:44 +02:00
|
|
|
case ENOTDIR:
|
2023-03-02 22:13:08 +02:00
|
|
|
strcpy(buffer, "Not a directory");
|
|
|
|
break;
|
2023-03-02 21:10:44 +02:00
|
|
|
case ENOENT:
|
2023-03-02 22:13:08 +02:00
|
|
|
strcpy(buffer, "No such file or directory");
|
|
|
|
break;
|
2023-03-02 21:10:44 +02:00
|
|
|
case EIO:
|
2023-03-02 22:13:08 +02:00
|
|
|
strcpy(buffer, "Input/output error");
|
2023-03-02 21:10:44 +02:00
|
|
|
break;
|
2023-03-02 22:13:08 +02:00
|
|
|
default:
|
|
|
|
{
|
|
|
|
// FIXME: sprintf
|
|
|
|
//sprintf(buffer, "Unknown error %d", error);
|
|
|
|
strcpy(buffer, "Unknown error");
|
|
|
|
errno = EINVAL;
|
|
|
|
break;
|
|
|
|
}
|
2023-03-02 21:10:44 +02:00
|
|
|
}
|
|
|
|
|
2023-03-02 22:13:08 +02:00
|
|
|
return buffer;
|
2023-03-02 21:10:44 +02:00
|
|
|
}
|