xref: /titanic_51/usr/src/cmd/ndmpd/include/cstack.h (revision 2654012f83cec5dc15b61dfe3e4a4915f186e7a6)
1*2654012fSReza Sabdar /*
2*2654012fSReza Sabdar  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
3*2654012fSReza Sabdar  * Use is subject to license terms.
4*2654012fSReza Sabdar  */
5*2654012fSReza Sabdar 
6*2654012fSReza Sabdar /*
7*2654012fSReza Sabdar  * BSD 3 Clause License
8*2654012fSReza Sabdar  *
9*2654012fSReza Sabdar  * Copyright (c) 2007, The Storage Networking Industry Association.
10*2654012fSReza Sabdar  *
11*2654012fSReza Sabdar  * Redistribution and use in source and binary forms, with or without
12*2654012fSReza Sabdar  * modification, are permitted provided that the following conditions
13*2654012fSReza Sabdar  * are met:
14*2654012fSReza Sabdar  * 	- Redistributions of source code must retain the above copyright
15*2654012fSReza Sabdar  *	  notice, this list of conditions and the following disclaimer.
16*2654012fSReza Sabdar  *
17*2654012fSReza Sabdar  * 	- Redistributions in binary form must reproduce the above copyright
18*2654012fSReza Sabdar  *	  notice, this list of conditions and the following disclaimer in
19*2654012fSReza Sabdar  *	  the documentation and/or other materials provided with the
20*2654012fSReza Sabdar  *	  distribution.
21*2654012fSReza Sabdar  *
22*2654012fSReza Sabdar  *	- Neither the name of The Storage Networking Industry Association (SNIA)
23*2654012fSReza Sabdar  *	  nor the names of its contributors may be used to endorse or promote
24*2654012fSReza Sabdar  *	  products derived from this software without specific prior written
25*2654012fSReza Sabdar  *	  permission.
26*2654012fSReza Sabdar  *
27*2654012fSReza Sabdar  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
28*2654012fSReza Sabdar  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
29*2654012fSReza Sabdar  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
30*2654012fSReza Sabdar  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
31*2654012fSReza Sabdar  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
32*2654012fSReza Sabdar  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
33*2654012fSReza Sabdar  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
34*2654012fSReza Sabdar  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
35*2654012fSReza Sabdar  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
36*2654012fSReza Sabdar  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
37*2654012fSReza Sabdar  * POSSIBILITY OF SUCH DAMAGE.
38*2654012fSReza Sabdar  */
39*2654012fSReza Sabdar 
40*2654012fSReza Sabdar /*
41*2654012fSReza Sabdar  * Interface definition for the list based stack class. The stack only
42*2654012fSReza Sabdar  * holds pointers/references to application objects. The objects are not
43*2654012fSReza Sabdar  * copied and the stack never attempts to dereference or access the data
44*2654012fSReza Sabdar  * objects. Applications should treat cstack_t references as opaque
45*2654012fSReza Sabdar  * handles.
46*2654012fSReza Sabdar  */
47*2654012fSReza Sabdar 
48*2654012fSReza Sabdar #ifndef _CSTACK_H_
49*2654012fSReza Sabdar #define	_CSTACK_H_
50*2654012fSReza Sabdar 
51*2654012fSReza Sabdar 
52*2654012fSReza Sabdar #ifdef __cplusplus
53*2654012fSReza Sabdar extern "C" {
54*2654012fSReza Sabdar #endif
55*2654012fSReza Sabdar 
56*2654012fSReza Sabdar 
57*2654012fSReza Sabdar typedef struct cstack {
58*2654012fSReza Sabdar 	struct cstack *next;
59*2654012fSReza Sabdar 	void *data;
60*2654012fSReza Sabdar 	int len;
61*2654012fSReza Sabdar } cstack_t;
62*2654012fSReza Sabdar 
63*2654012fSReza Sabdar 
64*2654012fSReza Sabdar cstack_t *cstack_new(void);
65*2654012fSReza Sabdar void cstack_delete(cstack_t *);
66*2654012fSReza Sabdar int cstack_push(cstack_t *, void *, int);
67*2654012fSReza Sabdar int cstack_pop(cstack_t *, void **, int *);
68*2654012fSReza Sabdar int cstack_top(cstack_t *, void **, int *);
69*2654012fSReza Sabdar 
70*2654012fSReza Sabdar 
71*2654012fSReza Sabdar #ifdef __cplusplus
72*2654012fSReza Sabdar }
73*2654012fSReza Sabdar #endif
74*2654012fSReza Sabdar 
75*2654012fSReza Sabdar 
76*2654012fSReza Sabdar #endif /* _CSTACK_H_ */
77