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