1*5053Sgtb /*
2*5053Sgtb * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
3*5053Sgtb * Use is subject to license terms.
4*5053Sgtb */
5*5053Sgtb
60Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI"
7*5053Sgtb
80Sstevel@tonic-gate /*
90Sstevel@tonic-gate * Copyright 1995 by OpenVision Technologies, Inc.
100Sstevel@tonic-gate *
110Sstevel@tonic-gate * Permission to use, copy, modify, distribute, and sell this software
120Sstevel@tonic-gate * and its documentation for any purpose is hereby granted without fee,
130Sstevel@tonic-gate * provided that the above copyright notice appears in all copies and
140Sstevel@tonic-gate * that both that copyright notice and this permission notice appear in
150Sstevel@tonic-gate * supporting documentation, and that the name of OpenVision not be used
160Sstevel@tonic-gate * in advertising or publicity pertaining to distribution of the software
170Sstevel@tonic-gate * without specific, written prior permission. OpenVision makes no
180Sstevel@tonic-gate * representations about the suitability of this software for any
190Sstevel@tonic-gate * purpose. It is provided "as is" without express or implied warranty.
200Sstevel@tonic-gate *
210Sstevel@tonic-gate * OPENVISION DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
220Sstevel@tonic-gate * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
230Sstevel@tonic-gate * EVENT SHALL OPENVISION BE LIABLE FOR ANY SPECIAL, INDIRECT OR
240Sstevel@tonic-gate * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
250Sstevel@tonic-gate * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
260Sstevel@tonic-gate * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
270Sstevel@tonic-gate * PERFORMANCE OF THIS SOFTWARE.
280Sstevel@tonic-gate */
290Sstevel@tonic-gate
300Sstevel@tonic-gate /*
31*5053Sgtb * $Id: util_set.c 16165 2004-03-14 05:31:43Z raeburn $
320Sstevel@tonic-gate */
330Sstevel@tonic-gate
34*5053Sgtb #include <mechglueP.h> /* SUNW15resync - for MALLOC/FREE */
35*5053Sgtb #include "gssapiP_generic.h"
360Sstevel@tonic-gate
37*5053Sgtb struct _g_set_elt {
380Sstevel@tonic-gate void *key;
390Sstevel@tonic-gate void *value;
40*5053Sgtb struct _g_set_elt *next;
410Sstevel@tonic-gate };
420Sstevel@tonic-gate
g_set_init(g_set_elt * s)43*5053Sgtb int g_set_init(g_set_elt *s)
440Sstevel@tonic-gate {
450Sstevel@tonic-gate *s = NULL;
460Sstevel@tonic-gate
470Sstevel@tonic-gate return(0);
480Sstevel@tonic-gate }
490Sstevel@tonic-gate
50*5053Sgtb #if 0
51*5053Sgtb int g_set_destroy(g_set_elt *s)
520Sstevel@tonic-gate {
530Sstevel@tonic-gate g_set next;
540Sstevel@tonic-gate
550Sstevel@tonic-gate while (*s) {
560Sstevel@tonic-gate next = (*s)->next;
570Sstevel@tonic-gate FREE(*s, sizeof(struct _g_set));
580Sstevel@tonic-gate *s = next;
590Sstevel@tonic-gate }
600Sstevel@tonic-gate
610Sstevel@tonic-gate return(0);
620Sstevel@tonic-gate }
63*5053Sgtb #endif
640Sstevel@tonic-gate
g_set_entry_add(g_set_elt * s,void * key,void * value)65*5053Sgtb int g_set_entry_add(g_set_elt *s, void *key, void *value)
660Sstevel@tonic-gate {
67*5053Sgtb g_set_elt first;
680Sstevel@tonic-gate
69*5053Sgtb if ((first = (struct _g_set_elt *) MALLOC(sizeof(struct _g_set_elt))) == NULL)
700Sstevel@tonic-gate return(ENOMEM);
710Sstevel@tonic-gate
720Sstevel@tonic-gate first->key = key;
730Sstevel@tonic-gate first->value = value;
740Sstevel@tonic-gate first->next = *s;
750Sstevel@tonic-gate
760Sstevel@tonic-gate *s = first;
770Sstevel@tonic-gate
780Sstevel@tonic-gate return(0);
790Sstevel@tonic-gate }
800Sstevel@tonic-gate
g_set_entry_delete(g_set_elt * s,void * key)81*5053Sgtb int g_set_entry_delete(g_set_elt *s, void *key)
820Sstevel@tonic-gate {
83*5053Sgtb g_set_elt *p;
840Sstevel@tonic-gate
850Sstevel@tonic-gate for (p=s; *p; p = &((*p)->next)) {
860Sstevel@tonic-gate if ((*p)->key == key) {
87*5053Sgtb g_set_elt next = (*p)->next;
88*5053Sgtb FREE(*p, sizeof(struct _g_set_elt));
890Sstevel@tonic-gate *p = next;
900Sstevel@tonic-gate
910Sstevel@tonic-gate return(0);
920Sstevel@tonic-gate }
930Sstevel@tonic-gate }
940Sstevel@tonic-gate
950Sstevel@tonic-gate return(-1);
960Sstevel@tonic-gate }
970Sstevel@tonic-gate
g_set_entry_get(g_set_elt * s,void * key,void ** value)98*5053Sgtb int g_set_entry_get(g_set_elt *s, void *key, void **value)
990Sstevel@tonic-gate {
100*5053Sgtb g_set_elt p;
1010Sstevel@tonic-gate
1020Sstevel@tonic-gate for (p = *s; p; p = p->next) {
1030Sstevel@tonic-gate if (p->key == key) {
1040Sstevel@tonic-gate *value = p->value;
1050Sstevel@tonic-gate
1060Sstevel@tonic-gate return(0);
1070Sstevel@tonic-gate }
1080Sstevel@tonic-gate }
1090Sstevel@tonic-gate
1100Sstevel@tonic-gate *value = NULL;
1110Sstevel@tonic-gate
1120Sstevel@tonic-gate return(-1);
1130Sstevel@tonic-gate }
114