xref: /illumos-gate/usr/src/lib/gss_mechs/mech_krb5/mech/disp_com_err_status.c (revision ca9327a6de44d69ddab3668cc1e143ce781387a3)
1 #pragma ident	"%Z%%M%	%I%	%E% SMI"
2 
3 /*
4  * Copyright 1993 by OpenVision Technologies, Inc.
5  *
6  * Permission to use, copy, modify, distribute, and sell this software
7  * and its documentation for any purpose is hereby granted without fee,
8  * provided that the above copyright notice appears in all copies and
9  * that both that copyright notice and this permission notice appear in
10  * supporting documentation, and that the name of OpenVision not be used
11  * in advertising or publicity pertaining to distribution of the software
12  * without specific, written prior permission. OpenVision makes no
13  * representations about the suitability of this software for any
14  * purpose.  It is provided "as is" without express or implied warranty.
15  *
16  * OPENVISION DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
17  * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
18  * EVENT SHALL OPENVISION BE LIABLE FOR ANY SPECIAL, INDIRECT OR
19  * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
20  * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
21  * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
22  * PERFORMANCE OF THIS SOFTWARE.
23  */
24 
25 /*
26  * $Id: disp_com_err_status.c 16391 2004-06-02 23:40:12Z raeburn $
27  */
28 
29 #include "gssapiP_generic.h"
30 #include "com_err.h"
31 #include "gss_libinit.h"
32 
33 /* XXXX internationalization!! */
34 
35 /**/
36 
37 static const char * const no_error = "No error";
38 
39 /**/
40 
41 /* if status_type == GSS_C_GSS_CODE, return up to three error messages,
42      for routine errors, call error, and status, in that order.
43      message_context == 0 : print the routine error
44      message_context == 1 : print the calling error
45      message_context > 2  : print supplementary info bit (message_context-2)
46    if status_type == GSS_C_MECH_CODE, return the output from error_message()
47    */
48 
49 OM_uint32
50 g_display_com_err_status(minor_status, status_value, status_string)
51      OM_uint32 *minor_status;
52      OM_uint32 status_value;
53      gss_buffer_t status_string;
54 {
55    status_string->length = 0;
56    status_string->value = NULL;
57 
58    (void) gssint_initialize_library();
59 
60    if (! g_make_string_buffer(((status_value == 0)?no_error:
61 			       error_message(status_value)),
62 			      status_string)) {
63       *minor_status = ENOMEM;
64       return(GSS_S_FAILURE);
65    }
66    *minor_status = 0;
67    return(GSS_S_COMPLETE);
68 }
69