Back to index

lightning-sunbird  0.9+nobinonly
Defines | Functions
strerror.c File Reference
#include "watcomfx.h"
#include <string.h>

Go to the source code of this file.

Defines

#define UPREFIX   "Unknown error: "

Functions

char * strerror (int num)

Define Documentation

#define UPREFIX   "Unknown error: "

Function Documentation

char* strerror ( int  num)

Definition at line 47 of file strerror.c.

{
       extern int sys_nerr;
       extern char *sys_errlist[];
#define       UPREFIX       "Unknown error: "
       static char ebuf[40] = UPREFIX;           /* 64-bit number + slop */
       register unsigned int errnum;
       register char *p, *t;
       char tmp[40];

       errnum = num;                      /* convert to unsigned */
       if (errnum < sys_nerr)
              return(sys_errlist[errnum]);

       /* Do this by hand, so we don't include stdio(3). */
       t = tmp;
       do {
              *t++ = "0123456789"[errnum % 10];
       } while (errnum /= 10);
       for (p = ebuf + sizeof(UPREFIX) - 1;;) {
              *p++ = *--t;
              if (t <= tmp)
                     break;
       }
       return(ebuf);
}

Here is the caller graph for this function: