]>
Commit | Line | Data |
---|---|---|
421f82e5 | 1 | /* Copyright (C) 1993, 1995 Free Software Foundation, Inc. |
28f540f4 RM |
2 | This file is part of the GNU C Library. |
3 | ||
4 | The GNU C Library is free software; you can redistribute it and/or | |
5 | modify it under the terms of the GNU Library General Public License as | |
6 | published by the Free Software Foundation; either version 2 of the | |
7 | License, or (at your option) any later version. | |
8 | ||
9 | The GNU C Library is distributed in the hope that it will be useful, | |
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
12 | Library General Public License for more details. | |
13 | ||
14 | You should have received a copy of the GNU Library General Public | |
15 | License along with the GNU C Library; see the file COPYING.LIB. If | |
16 | not, write to the Free Software Foundation, Inc., 675 Mass Ave, | |
17 | Cambridge, MA 02139, USA. */ | |
18 | ||
19 | #include <ansidecl.h> | |
20 | #include <stdio.h> | |
21 | #include <string.h> | |
22 | #include <mach/error.h> | |
421f82e5 | 23 | #include <errorlib.h> |
28f540f4 RM |
24 | |
25 | /* Return a string describing the errno code in ERRNUM. */ | |
26 | char * | |
27 | DEFUN(_strerror_internal, (errnum, buf), int errnum AND char buf[1024]) | |
28 | { | |
29 | int system; | |
30 | int sub; | |
31 | int code; | |
32 | const struct error_system *es; | |
33 | extern void __mach_error_map_compat (int *); | |
34 | ||
35 | __mach_error_map_compat (&errnum); | |
36 | ||
37 | system = err_get_system (errnum); | |
38 | sub = err_get_sub (errnum); | |
39 | code = err_get_code (errnum); | |
40 | ||
421f82e5 | 41 | if (system > err_max_system || ! __mach_error_systems[system].bad_sub) |
28f540f4 RM |
42 | { |
43 | sprintf (buf, "Unknown error system %d", system); | |
44 | return buf; | |
45 | } | |
46 | ||
47 | es = &__mach_error_systems[system]; | |
48 | ||
49 | if (sub >= es->max_sub) | |
50 | return (char *) es->bad_sub; | |
51 | ||
52 | if (code >= es->subsystem[sub].max_code) | |
53 | { | |
54 | sprintf (buf, "Unknown error %d in system %d subsystem %d", | |
55 | code, system, sub); | |
56 | return buf; | |
57 | } | |
58 | ||
59 | return (char *) es->subsystem[sub].codes[code]; | |
60 | } |