17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate * Copyright 1993 by OpenVision Technologies, Inc.
37c478bd9Sstevel@tonic-gate *
47c478bd9Sstevel@tonic-gate * Permission to use, copy, modify, distribute, and sell this software
57c478bd9Sstevel@tonic-gate * and its documentation for any purpose is hereby granted without fee,
67c478bd9Sstevel@tonic-gate * provided that the above copyright notice appears in all copies and
77c478bd9Sstevel@tonic-gate * that both that copyright notice and this permission notice appear in
87c478bd9Sstevel@tonic-gate * supporting documentation, and that the name of OpenVision not be used
97c478bd9Sstevel@tonic-gate * in advertising or publicity pertaining to distribution of the software
107c478bd9Sstevel@tonic-gate * without specific, written prior permission. OpenVision makes no
117c478bd9Sstevel@tonic-gate * representations about the suitability of this software for any
127c478bd9Sstevel@tonic-gate * purpose. It is provided "as is" without express or implied warranty.
137c478bd9Sstevel@tonic-gate *
147c478bd9Sstevel@tonic-gate * OPENVISION DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
157c478bd9Sstevel@tonic-gate * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
167c478bd9Sstevel@tonic-gate * EVENT SHALL OPENVISION BE LIABLE FOR ANY SPECIAL, INDIRECT OR
177c478bd9Sstevel@tonic-gate * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
187c478bd9Sstevel@tonic-gate * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
197c478bd9Sstevel@tonic-gate * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
207c478bd9Sstevel@tonic-gate * PERFORMANCE OF THIS SOFTWARE.
217c478bd9Sstevel@tonic-gate */
227c478bd9Sstevel@tonic-gate
237c478bd9Sstevel@tonic-gate /*
24*ab9b2e15Sgtb * $Id: util_buffer.c 11001 1998-10-30 02:56:35Z marc $
257c478bd9Sstevel@tonic-gate */
267c478bd9Sstevel@tonic-gate
27*ab9b2e15Sgtb #include "gssapiP_generic.h"
287c478bd9Sstevel@tonic-gate #include <string.h>
297c478bd9Sstevel@tonic-gate
307c478bd9Sstevel@tonic-gate /* return nonzero on success, 0 on failure
317c478bd9Sstevel@tonic-gate make sure that buffer is consistent (release'able) when this
327c478bd9Sstevel@tonic-gate function exits, no matter what the exit value */
337c478bd9Sstevel@tonic-gate
g_make_string_buffer(str,buffer)347c478bd9Sstevel@tonic-gate int g_make_string_buffer(str, buffer)
357c478bd9Sstevel@tonic-gate const char *str;
367c478bd9Sstevel@tonic-gate gss_buffer_t buffer;
377c478bd9Sstevel@tonic-gate {
387c478bd9Sstevel@tonic-gate buffer->length = strlen(str);
397c478bd9Sstevel@tonic-gate
407c478bd9Sstevel@tonic-gate if ((buffer->value = (void *) xmalloc(buffer->length + 1)) == NULL) {
417c478bd9Sstevel@tonic-gate buffer->length = 0;
427c478bd9Sstevel@tonic-gate return(0);
437c478bd9Sstevel@tonic-gate }
447c478bd9Sstevel@tonic-gate
457c478bd9Sstevel@tonic-gate strcpy(buffer->value, str);
467c478bd9Sstevel@tonic-gate
477c478bd9Sstevel@tonic-gate return(1);
487c478bd9Sstevel@tonic-gate }
49