]> git.decadent.org.uk Git - nfs-utils.git/blob - support/gssapi/g_dsp_name.c
2005-08-26 Kevin Coffman <kwc@citi.umich.edu>
[nfs-utils.git] / support / gssapi / g_dsp_name.c
1 /* #ident  "@(#)g_dsp_name.c 1.2     96/02/06 SMI" */
2
3 /*
4  * Copyright 1996 by Sun Microsystems, 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 Sun Microsystems not be used
11  * in advertising or publicity pertaining to distribution of the software
12  * without specific, written prior permission. Sun Microsystems 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  * SUN MICROSYSTEMS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
17  * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
18  * EVENT SHALL SUN MICROSYSTEMS 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  *  glue routine for gss_display_name()
27  *
28  */
29
30 #include "mglueP.h"
31 #include <stdio.h>
32 #ifdef HAVE_STDLIB_H
33 #include <stdlib.h>
34 #endif
35 #include <string.h>
36
37 OM_uint32 KRB5_CALLCONV
38 gss_display_name (minor_status,
39                   input_name,
40                   output_name_buffer,
41                   output_name_type)
42
43 OM_uint32 *             minor_status;
44 gss_name_t              input_name;
45 gss_buffer_t            output_name_buffer;
46 gss_OID *               output_name_type;
47
48 {
49     OM_uint32           major_status;
50     gss_union_name_t    union_name;
51
52     if (input_name == 0)
53         return GSS_S_BAD_NAME;
54
55     union_name = (gss_union_name_t) input_name;
56
57     if (union_name->mech_type) {
58         /*
59          * OK, we have a mechanism-specific name; let's use it!
60          */
61         return (__gss_display_internal_name(minor_status,
62                                             union_name->mech_type,
63                                             union_name->mech_name,
64                                             output_name_buffer,
65                                             output_name_type));
66     }
67
68     /*
69      * copy the value of the external_name component of the union
70      * name into the output_name_buffer and point the output_name_type
71      * to the name_type component of union_name
72      */
73     if (output_name_type != NULL) {
74         major_status = generic_gss_copy_oid(minor_status,
75                                             union_name->name_type,
76                                             output_name_type);
77         if (major_status)
78             return (major_status);
79     }
80
81     if (output_name_buffer != NULL) {
82         output_name_buffer->length = union_name->external_name->length;
83
84         output_name_buffer->value =
85             (void *) malloc(output_name_buffer->length);
86
87         memcpy(output_name_buffer->value,
88                union_name->external_name->value,
89                output_name_buffer->length);
90     }
91
92     if (minor_status)
93         *minor_status = 0;
94
95     return(GSS_S_COMPLETE);
96 }