1 /* Copyright (C) 1996 Robert de Bath <robert@debath.thenet.co.uk>
2 * This file is part of the Linux-8086 C library and is distributed
3 * under the GNU Library General Public License.
6 /* This is a flash way of auto-initing the error array from an external file
7 * I wouldn't be surprised tho if it's a lot better just to hard code the
8 * error messages into the array.
10 * Of course the best of all is to use strerror().
13 #if defined(__AS386_16__) || defined(__AS386_32__)
16 extern char **__sys_errlist
;
17 extern int __sys_nerr
;
19 char *sys_errlist
[NR_ERRORS
];
20 int sys_nerr
= NR_ERRORS
;
24 loc
1 ! Make sure the pointer is in the correct segment
25 auto_func
: ! Label
for bcc
-M to work
.
26 .word _init_vars
! Pointer to the autorun function
27 .text
! So the function after is also in the correct seg
.
31 loc
1 ! Make sure the pointer is in the correct segment
32 auto_func
: ! Label
for bcc
-M to work
.
33 .long _init_vars
! Pointer to the autorun function
34 .text
! So the function after is also in the correct seg
.
38 static void init_vars()
42 int i
, cc
, fd
, err
, len
, bufoff
=0;
45 fd
= open("/usr/lib/bcc/liberror.txt", 0);
46 if (fd
< 0) fd
= open("/lib/liberror.txt", 0);
49 for(i
=0; i
<NR_ERRORS
; i
++) sys_errlist
[i
] = "Unknown error";
51 while( (cc
=read(fd
, inbuf
, sizeof(inbuf
))) > 0 )
55 if( inbuf
[i
] == '\n' )
57 errbuf
[bufoff
] = '\0';
59 ptr
= strchr(errbuf
, ' ');
60 if( ptr
&& err
> 0 && err
< NR_ERRORS
)
62 while(*ptr
== ' ') ptr
++;
64 sys_errlist
[err
] = (void*)sbrk(len
);
65 if( (int)sys_errlist
[err
] == -1 )
67 sys_errlist
[err
] == "";
70 memcpy(sys_errlist
[err
], ptr
, len
);
74 else if( bufoff
< sizeof(errbuf
)-1 )
75 errbuf
[bufoff
++] = inbuf
[i
];
80 __sys_errlist
= sys_errlist
;
81 __sys_nerr
= sys_nerr
= NR_ERRORS
;
84 #endif /* __AS386_??__ */