Tue Jul 2 10:44:37 1996 Roland McGrath <roland@delasyd.gnu.ai.mit.edu>
[glibc.git] / mach / errstring.c
blob761a615e296dd5c48ca50e3ac670a2d6443763ca
1 /*
2 * Mach Operating System
3 * Copyright (c) 1991,1990,1989 Carnegie Mellon University
4 * All Rights Reserved.
5 *
6 * Permission to use, copy, modify and distribute this software and its
7 * documentation is hereby granted, provided that both the copyright
8 * notice and this permission notice appear in all copies of the
9 * software, derivative works or modified versions, and any portions
10 * thereof, and that both notices appear in supporting documentation.
12 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
13 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
14 * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
16 * Carnegie Mellon requests users of this software to return to
18 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
19 * School of Computer Science
20 * Carnegie Mellon University
21 * Pittsburgh PA 15213-3890
23 * any improvements or extensions that they make and grant Carnegie Mellon
24 * the rights to redistribute these changes.
27 * HISTORY
28 * $Log$
29 * Revision 1.1 1993/11/30 17:35:58 roland
30 * entered into RCS
32 * Revision 2.3 92/04/01 19:38:18 rpd
33 * Updated do_compat for kernel device errors,
34 * bootstrap file-system errors.
35 * [92/03/09 rpd]
37 * Revision 2.2 92/02/20 15:58:08 elf
38 * Created from mach_error.c.
39 * [92/02/11 rpd]
43 #define EXPORT_BOOLEAN
44 #include <mach/boolean.h>
45 #include <mach/error.h>
46 #include <mach_error.h>
47 #include <errorlib.h>
49 extern void __mach_error_map_compat (mach_error_t *);
51 const char *
52 mach_error_type( err )
53 mach_error_t err;
55 int sub, system;
57 __mach_error_map_compat( &err );
59 sub = err_get_sub(err);
60 system = err_get_system(err);
62 if (system > err_max_system
63 || sub >= errors[system].max_sub ) return( "(?/?)" );
64 return( errors[system].subsystem[sub].subsys_name );
67 boolean_t mach_error_full_diag = FALSE;
69 const char *
70 mach_error_string_int( err, diag )
71 mach_error_t err;
72 boolean_t * diag;
74 int sub, system, code;
76 __mach_error_map_compat( &err );
78 sub = err_get_sub(err);
79 system = err_get_system(err);
80 code = err_get_code(err);
82 *diag = TRUE;
84 if (system > err_max_system) return( "(?/?) unknown error system" );
85 if (sub >= errors[system].max_sub) return( errors[system].bad_sub );
86 if (code >= errors[system].subsystem[sub].max_code) return ( NO_SUCH_ERROR );
88 *diag = mach_error_full_diag;
89 return( errors[system].subsystem[sub].codes[code] );
92 const char *
93 mach_error_string( err )
94 mach_error_t err;
96 boolean_t diag;
98 return mach_error_string_int( err, &diag );