1*6b6d114aSBen Gras /* $NetBSD: prop_stack.h,v 1.2 2007/08/30 12:23:54 joerg Exp $ */ 2*6b6d114aSBen Gras 3*6b6d114aSBen Gras /*- 4*6b6d114aSBen Gras * Copyright (c) 2007 Joerg Sonnenberger <joerg@NetBSD.org>. 5*6b6d114aSBen Gras * All rights reserved. 6*6b6d114aSBen Gras * 7*6b6d114aSBen Gras * Redistribution and use in source and binary forms, with or without 8*6b6d114aSBen Gras * modification, are permitted provided that the following conditions 9*6b6d114aSBen Gras * are met: 10*6b6d114aSBen Gras * 11*6b6d114aSBen Gras * 1. Redistributions of source code must retain the above copyright 12*6b6d114aSBen Gras * notice, this list of conditions and the following disclaimer. 13*6b6d114aSBen Gras * 2. Redistributions in binary form must reproduce the above copyright 14*6b6d114aSBen Gras * notice, this list of conditions and the following disclaimer in 15*6b6d114aSBen Gras * the documentation and/or other materials provided with the 16*6b6d114aSBen Gras * distribution. 17*6b6d114aSBen Gras * 18*6b6d114aSBen Gras * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19*6b6d114aSBen Gras * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20*6b6d114aSBen Gras * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 21*6b6d114aSBen Gras * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 22*6b6d114aSBen Gras * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 23*6b6d114aSBen Gras * INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, 24*6b6d114aSBen Gras * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 25*6b6d114aSBen Gras * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 26*6b6d114aSBen Gras * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 27*6b6d114aSBen Gras * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 28*6b6d114aSBen Gras * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 29*6b6d114aSBen Gras * SUCH DAMAGE. 30*6b6d114aSBen Gras */ 31*6b6d114aSBen Gras 32*6b6d114aSBen Gras #ifndef _PROP_STACK_H 33*6b6d114aSBen Gras #define _PROP_STACK_H 34*6b6d114aSBen Gras 35*6b6d114aSBen Gras #include <sys/queue.h> 36*6b6d114aSBen Gras 37*6b6d114aSBen Gras #include <prop/prop_object.h> 38*6b6d114aSBen Gras 39*6b6d114aSBen Gras struct _prop_stack_intern_elem { 40*6b6d114aSBen Gras prop_object_t object; 41*6b6d114aSBen Gras void *object_data[3]; 42*6b6d114aSBen Gras }; 43*6b6d114aSBen Gras 44*6b6d114aSBen Gras struct _prop_stack_extern_elem { 45*6b6d114aSBen Gras SLIST_ENTRY(_prop_stack_extern_elem) stack_link; 46*6b6d114aSBen Gras prop_object_t object; 47*6b6d114aSBen Gras void *object_data[3]; 48*6b6d114aSBen Gras }; 49*6b6d114aSBen Gras 50*6b6d114aSBen Gras #define PROP_STACK_INTERN_ELEMS 16 51*6b6d114aSBen Gras 52*6b6d114aSBen Gras struct _prop_stack { 53*6b6d114aSBen Gras struct _prop_stack_intern_elem intern_elems[PROP_STACK_INTERN_ELEMS]; 54*6b6d114aSBen Gras size_t used_intern_elems; 55*6b6d114aSBen Gras SLIST_HEAD(, _prop_stack_extern_elem) extern_elems; 56*6b6d114aSBen Gras }; 57*6b6d114aSBen Gras 58*6b6d114aSBen Gras typedef struct _prop_stack *prop_stack_t; 59*6b6d114aSBen Gras 60*6b6d114aSBen Gras void _prop_stack_init(prop_stack_t); 61*6b6d114aSBen Gras bool _prop_stack_push(prop_stack_t, prop_object_t, void *, void *, void *); 62*6b6d114aSBen Gras bool _prop_stack_pop(prop_stack_t, prop_object_t *, void **, void **, void **); 63*6b6d114aSBen Gras 64*6b6d114aSBen Gras #endif 65