]> sourceware.org Git - glibc.git/blame - sysdeps/mach/_strerror.c
Sat May 6 11:06:47 1995 Roland McGrath <roland@churchy.gnu.ai.mit.edu>
[glibc.git] / sysdeps / mach / _strerror.c
CommitLineData
421f82e5 1/* Copyright (C) 1993, 1995 Free Software Foundation, Inc.
28f540f4
RM
2This file is part of the GNU C Library.
3
4The GNU C Library is free software; you can redistribute it and/or
5modify it under the terms of the GNU Library General Public License as
6published by the Free Software Foundation; either version 2 of the
7License, or (at your option) any later version.
8
9The GNU C Library is distributed in the hope that it will be useful,
10but WITHOUT ANY WARRANTY; without even the implied warranty of
11MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12Library General Public License for more details.
13
14You should have received a copy of the GNU Library General Public
15License along with the GNU C Library; see the file COPYING.LIB. If
16not, write to the Free Software Foundation, Inc., 675 Mass Ave,
17Cambridge, 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. */
26char *
27DEFUN(_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}
This page took 0.038456 seconds and 5 git commands to generate.