home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
rtsi.com
/
2014.01.www.rtsi.com.tar
/
www.rtsi.com
/
OS9
/
OSK
/
TELECOM
/
OS9_Unix.lzh
/
RSHSRC
/
strerror.c
< prev
next >
Wrap
C/C++ Source or Header
|
1992-09-10
|
933b
|
51 lines
/*****************************************************
* char *strerror(int errnum)
* return pointer to a formatted error string
* ip sept 92
*/
#define ERR_FILE "/dd/sys/errmsg"
#include <stdio.h>
static char errstr[80];
char *strerror(num)
int num;
{
char tmp[25];
FILE *fp, *fopen();
/* format the error number */
sprintf(tmp,"%03d:%03d",(num>>8),(num&0xff));
if ( (fp=fopen(ERR_FILE,"r")) !=NULL){
while(fgets(errstr,sizeof(errstr),fp)){
if(strncmp(errstr,tmp,7) == 0){
/* match found */
errstr[ strlen(errstr)-1 ]=0; /* kill terminating lf */
fclose(fp);
return (errstr);
}
}
fclose(fp);
}
/* if we're here the error file couldn't be opened or no match */
strcpy(errstr,tmp);
return (errstr);
}
#ifdef TEST
main(argc,argv)
int argc;
char **argv;
{
int i,j;
while(--argc){
i=atoi(*++argv);
printf("code %d returns:\n",i);fflush(stdout);
puts(strerror( i));
}
}
#endif