home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
rtsi.com
/
2014.01.www.rtsi.com.tar
/
www.rtsi.com
/
OS9
/
OSK
/
TELECOM
/
stg_v4.lzh
/
errmsg.c
< prev
next >
Wrap
C/C++ Source or Header
|
1994-11-11
|
1KB
|
79 lines
/*
* char * errmsg(err) - return ptr to errmsg string from /dd/sys/errmsg
*
* 92/10/29 StG - initial version
*/
#include "stglib.h"
#ifdef _OSK
char err_msg[256];
char err_num[10];
char *
errmsg(err)
int err;
{
int hFile;
int n;
char *p;
char *d;
stringf(err_num,"%03d:%03d",(err&0xFF00)>>8,err&0x00FF);
hFile=open(ERRMSG,O_RDONLY);
if (hFile==ERR)
return(err_num);
while (n=readln(hFile,err_msg,256))
{
if (n==ERR)
break;
err_msg[n-1]=0;
if (!strncmp(err_num,err_msg,7))
{
close(hFile);
p=err_msg+7;
while (*p && *p==' ') p++;
if (*p=='(')
while (*p && *p!=')') p++;
if (*p==')') p++;
while (*p && *p==' ') p++;
if (*p)
{
d=p;
while (*d)
d++;
if (*--d=='.')
*d=0;
return(p);
}
break;
}
}
close(hFile);
return(err_num);
}
#else
extern int sys_nerr;
extern char *sys_errlist[];
char *
errmsg(err)
int err;
{
if (err>=0 && err<=sys_nerr)
return(sys_errlist[err]);
return("Unknown");
}
#endif