4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
23 * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
27 * This file provides a text translation service for NT status codes.
34 * Include the generated file with ntx_table[]
35 * See smb_status_gen.awk
37 #include "smb_status_tbl.h"
38 static const int ntx_rows
= sizeof (ntx_table
) / sizeof (ntx_table
[0]);
41 * Comparison function for bsearch(3C).
44 xlate_compare(const void *vkey
, const void *vrow
)
46 const smb_status_table_t
*key
= vkey
;
47 const smb_status_table_t
*row
= vrow
;
49 if (key
->value
== row
->value
)
51 if (key
->value
< row
->value
)
57 * Translate an ntstatus value to a meaningful text string. If there isn't
58 * a corresponding text string in the table, the text representation of the
59 * status value is returned. This uses a static buffer so there is a
60 * possible concurrency issue if the caller hangs on to this pointer for a
61 * while but it should be harmless and really remote since the value will
62 * almost always be found in the table.
65 xlate_nt_status(unsigned int ntstatus
)
67 static char unknown
[16];
68 smb_status_table_t key
;
69 const smb_status_table_t
*tep
;
73 tep
= bsearch(&key
, ntx_table
, ntx_rows
,
74 sizeof (*tep
), xlate_compare
);
79 (void) sprintf(unknown
, "0x%08X", ntstatus
);
80 return ((const char *)unknown
);