Sdiff g_dsp_name.c
  1 /*
  2  * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
  3  * Use is subject to license terms.
  4  */
  5 
  6 #pragma ident   "@(#)g_dsp_name.c       1.14    04/09/08 SMI" 
  7 
  8 /*
  9  *  glue routine for gss_display_name()
 10  *
 11  */
 12 
 13 #include <mechglueP.h>
 14 #include <stdio.h>
 15 #ifdef HAVE_STDLIB_H
 16 #include <stdlib.h>
 17 #endif
 18 #include <string.h>
 19 
 20 OM_uint32
 21 gss_display_name(minor_status,
 22                         input_name,
 23                         output_name_buffer,
 24                         output_name_type)
 25 
 26 OM_uint32 *                     minor_status;
 27 const gss_name_t                input_name;
 28 gss_buffer_t                    output_name_buffer;
 29 gss_OID *                       output_name_type;
 30 
 31 {
 32         OM_uint32                       major_status;
 33         gss_union_name_t                union_name;
 34 




 35         if (input_name == 0)
 36                 return (GSS_S_BAD_NAME); 
 37 






 38         union_name = (gss_union_name_t)input_name;
 39 
 40         if (union_name->mech_type) {
 41                 /*
 42                  * OK, we have a mechanism-specific name; let's use it!
 43                  */
 44                 return (__gss_display_internal_name(minor_status,
 45                                                         union_name->mech_type,
 46                                                         union_name->mech_name,
 47                                                         output_name_buffer,
 48                                                         output_name_type));
 49         }
 50 
 51         /*
 52          * copy the value of the external_name component of the union
 53          * name into the output_name_buffer and point the output_name_type
 54          * to the name_type component of union_name
 55          */
 56         if (output_name_type != NULL) { 

 57                 major_status = generic_gss_copy_oid(minor_status,
 58                                                 union_name->name_type,
 59                                                 output_name_type);
 60                 if (major_status) 
 61                         return (major_status);
 62         }
 63 
 64         if ((output_name_buffer != NULL) { 








 65                 output_name_buffer->length = union_name->external_name->length;
 66  
 67                 output_name_buffer->value = 
 68                     (void *) malloc(output_name_buffer->length); 
 69  
 70                 memcpy(output_name_buffer->value, 
 71                         union_name->external_name->value,
 72                         output_name_buffer->length); 
 73     } 
 74 
 75     if (minor_status) 
 76         *minor_status = 0; 
 77  
 78         return (GSS_S_COMPLETE);
 79 }
  1 /*
  2  * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
  3  * Use is subject to license terms.
  4  */
  5 
  6 #pragma ident   "@(#)g_dsp_name.c       1.13    04/02/23 SMI" 
  7 
  8 /*
  9  *  glue routine for gss_display_name()
 10  *
 11  */
 12 
 13 #include <mechglueP.h>
 14 #include <stdio.h>
 15 #ifdef HAVE_STDLIB_H
 16 #include <stdlib.h>
 17 #endif
 18 #include <string.h>
 19 
 20 OM_uint32
 21 gss_display_name(minor_status,
 22                         input_name,
 23                         output_name_buffer,
 24                         output_name_type)
 25 
 26 OM_uint32 *                     minor_status;
 27 const gss_name_t                input_name;
 28 gss_buffer_t                    output_name_buffer;
 29 gss_OID *                       output_name_type;
 30 
 31 {
 32         OM_uint32                       major_status;
 33         gss_union_name_t                union_name;
 34 
 35         if (minor_status == NULL)
 36                 return (GSS_S_CALL_INACCESSIBLE_WRITE);
 37         *minor_status = 0;
 38 
 39         if (input_name == 0)
 40                 return (GSS_S_CALL_INACCESSIBLE_READ | GSS_S_BAD_NAME); 
 41 
 42         if (output_name_buffer == NULL)
 43                 return (GSS_S_CALL_INACCESSIBLE_WRITE);
 44 
 45         if (output_name_type)
 46                 *output_name_type = NULL;
 47 
 48         union_name = (gss_union_name_t)input_name;
 49 
 50         if (union_name->mech_type) {
 51                 /*
 52                  * OK, we have a mechanism-specific name; let's use it!
 53                  */
 54                 return (__gss_display_internal_name(minor_status,
 55                                                         union_name->mech_type,
 56                                                         union_name->mech_name,
 57                                                         output_name_buffer,
 58                                                         output_name_type));
 59         }
 60 
 61         /*
 62          * copy the value of the external_name component of the union
 63          * name into the output_name_buffer and point the output_name_type
 64          * to the name_type component of union_name
 65          */
 66         if (output_name_type != NULL && 
 67             union_name->name_type != GSS_C_NULL_OID) { 
 68                 major_status = generic_gss_copy_oid(minor_status,
 69                                                 union_name->name_type,
 70                                                 output_name_type);
 71                 if (major_status != GSS_S_COMPLETE) 
 72                         return (major_status);
 73         }
 74 
 75         if ((output_name_buffer->value = 
 76                 malloc(union_name->external_name->length + 1)) == NULL) { 
 77                 if (output_name_type && *output_name_type != GSS_C_NULL_OID) { 
 78                         (void) generic_gss_release_oid(minor_status, 
 79                                                     output_name_type); 
 80                         *output_name_type = NULL; 
 81                 } 
 82                 return (GSS_S_FAILURE); 
 83         } 
 84         output_name_buffer->length = union_name->external_name->length;
 85         (void) memcpy(output_name_buffer->value, 




 86                     union_name->external_name->value,
 87                 union_name->external_name->length); 
 88         ((char *)output_name_buffer->value)[output_name_buffer->length] = '\0'; 
 89 



 90         return (GSS_S_COMPLETE);
 91 }