Back to index

glibc  2.9
mach_error.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.4  92/02/19  15:10:52  elf
00030  *     Moved mach_error_string and mach_error_type to mach_error_string.c.
00031  *     [92/02/11            rpd]
00032  *
00033  * Revision 2.3  92/01/23  15:22:06  rpd
00034  *     Changed <servers/errorlib.h> to <errorlib.h>.
00035  *     [92/01/16            rpd]
00036  *
00037  * Revision 2.2  92/01/16  00:08:03  rpd
00038  *     Moved from user collection to mk collection.
00039  *
00040  * Revision 2.3  91/08/29  15:51:50  rpd
00041  *     Changed IPC_MIG_MOD to MACH_IPC_MIG_MOD, to get the new error strings.
00042  *     [91/08/22            rpd]
00043  *
00044  * Revision 2.2  91/03/27  16:06:29  mrt
00045  *     Changed include of "errorlib.h" to <servers/errorlib.h>
00046  *     Added new copyright
00047  *     [91/03/20            mrt]
00048  *
00049  */
00050 /*
00051  *     File:  mach_error.c
00052  *     Author:       Douglas Orr, Carnegie Mellon University
00053  *     Date:  Mar 1988
00054  *
00055  *      interprets structured mach error codes and prints
00056  *      or returns a descriptive string.
00057  */
00058 
00059 #include <stdio.h>
00060 #include <mach_error.h>
00061 #include <mach/boolean.h>
00062 
00063 extern char * mach_error_string_int(mach_error_t, boolean_t *);
00064 
00065 void
00066 mach_error( str, err )
00067        char   *str;
00068        mach_error_t         err;
00069 {
00070        char * err_str;
00071        char buf[1024];
00072        boolean_t diag;
00073 
00074        err_str=mach_error_string_int(err, &diag);
00075 
00076        if ( diag ) {
00077               sprintf( buf, "%s %s (%x)", mach_error_type(err), err_str, err );
00078               err_str = buf;
00079        }
00080 
00081        fprintf(stderr, "%s %s\n", str, err_str);
00082 }