Back to index

glibc  2.9
errstring.c
Go to the documentation of this file.
00001 /*
00002  * Mach Operating System
00003  * Copyright (c) 1991,1990,1989 Carnegie Mellon University
00004  * All Rights Reserved.
00005  *
00006  * Permission to use, copy, modify and distribute this software and its
00007  * documentation is hereby granted, provided that both the copyright
00008  * notice and this permission notice appear in all copies of the
00009  * software, derivative works or modified versions, and any portions
00010  * thereof, and that both notices appear in supporting documentation.
00011  *
00012  * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
00013  * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
00014  * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
00015  *
00016  * Carnegie Mellon requests users of this software to return to
00017  *
00018  *  Software Distribution Coordinator  or  Software.Distribution@CS.CMU.EDU
00019  *  School of Computer Science
00020  *  Carnegie Mellon University
00021  *  Pittsburgh PA 15213-3890
00022  *
00023  * any improvements or extensions that they make and grant Carnegie Mellon
00024  * the rights to redistribute these changes.
00025  */
00026 /*
00027  * (pre-GNU) HISTORY
00028  *
00029  * Revision 2.3  92/04/01  19:38:18  rpd
00030  *     Updated do_compat for kernel device errors,
00031  *     bootstrap file-system errors.
00032  *     [92/03/09            rpd]
00033  *
00034  * Revision 2.2  92/02/20  15:58:08  elf
00035  *     Created from mach_error.c.
00036  *     [92/02/11            rpd]
00037  *
00038  */
00039 
00040 #define EXPORT_BOOLEAN
00041 #include <mach/boolean.h>
00042 #include <mach/error.h>
00043 #include <mach_error.h>
00044 #include <errorlib.h>
00045 
00046 extern void __mach_error_map_compat (mach_error_t *);
00047 
00048 const char *
00049 mach_error_type( err )
00050        mach_error_t         err;
00051 {
00052        int sub, system;
00053 
00054        __mach_error_map_compat( &err );
00055 
00056        sub = err_get_sub(err);
00057        system = err_get_system(err);
00058 
00059        if (system > err_max_system
00060        ||  sub >= errors[system].max_sub ) return( "(?/?)" );
00061        return( errors[system].subsystem[sub].subsys_name );
00062 }
00063 
00064 boolean_t mach_error_full_diag = FALSE;
00065 
00066 const char *
00067 mach_error_string_int(mach_error_t err,
00068                     boolean_t             * diag)
00069 {
00070        int sub, system, code;
00071 
00072        __mach_error_map_compat( &err );
00073 
00074        sub = err_get_sub(err);
00075        system = err_get_system(err);
00076        code = err_get_code(err);
00077 
00078        *diag = TRUE;
00079 
00080        if (system > err_max_system) return( "(?/?) unknown error system" );
00081        if (sub >= errors[system].max_sub) return( errors[system].bad_sub );
00082        if (code >= errors[system].subsystem[sub].max_code) return ( NO_SUCH_ERROR );
00083 
00084        *diag = mach_error_full_diag;
00085        return( errors[system].subsystem[sub].codes[code] );
00086 }
00087 
00088 const char *
00089 mach_error_string( err )
00090        mach_error_t         err;
00091 {
00092        boolean_t diag;
00093 
00094        return mach_error_string_int( err, &diag );
00095 
00096 }