xref: /titanic_51/usr/src/lib/libast/common/include/stk.h (revision 36e852a172cba914383d7341c988128b2c667fbd)
1 /***********************************************************************
2 *                                                                      *
3 *               This software is part of the ast package               *
4 *          Copyright (c) 1985-2009 AT&T Intellectual Property          *
5 *                      and is licensed under the                       *
6 *                  Common Public License, Version 1.0                  *
7 *                    by AT&T Intellectual Property                     *
8 *                                                                      *
9 *                A copy of the License is available at                 *
10 *            http://www.opensource.org/licenses/cpl1.0.txt             *
11 *         (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9)         *
12 *                                                                      *
13 *              Information and Software Systems Research               *
14 *                            AT&T Research                             *
15 *                           Florham Park NJ                            *
16 *                                                                      *
17 *                 Glenn Fowler <gsf@research.att.com>                  *
18 *                  David Korn <dgk@research.att.com>                   *
19 *                   Phong Vo <kpv@research.att.com>                    *
20 *                                                                      *
21 ***********************************************************************/
22 #pragma prototyped
23 /*
24  * David Korn
25  * AT&T Research
26  *
27  * Interface definitions for a stack-like storage library
28  *
29  */
30 
31 #ifndef _STK_H
32 #define _STK_H
33 
34 #include <sfio.h>
35 
36 #define _Stk_data	_Stak_data
37 
38 #define stkstd		(&_Stk_data)
39 
40 #define	Stk_t		Sfio_t
41 
42 #define STK_SMALL	1		/* small stkopen stack		*/
43 #define STK_NULL	2		/* return NULL on overflow	*/
44 
45 #define	stkptr(sp,n)	((char*)((sp)->_data)+(n))
46 #define stktop(sp)	((char*)(sp)->_next)
47 #define	stktell(sp)	((sp)->_next-(sp)->_data)
48 #define stkseek(sp,n)	((n)==0?(char*)((sp)->_next=(sp)->_data):_stkseek(sp,n))
49 
50 #if _BLD_ast && defined(__EXPORT__)
51 #define extern		extern __EXPORT__
52 #endif
53 #if !_BLD_ast && defined(__IMPORT__)
54 #define extern		extern __IMPORT__
55 #endif
56 
57 extern Sfio_t		_Stk_data;
58 
59 #undef	extern
60 
61 #if _BLD_ast && defined(__EXPORT__)
62 #define extern		__EXPORT__
63 #endif
64 
65 extern Stk_t*		stkopen(int);
66 extern Stk_t*		stkinstall(Stk_t*, char*(*)(int));
67 extern int		stkclose(Stk_t*);
68 extern int		stklink(Stk_t*);
69 extern char*		stkalloc(Stk_t*, unsigned);
70 extern char*		stkcopy(Stk_t*,const char*);
71 extern char*		stkset(Stk_t*, char*, unsigned);
72 extern char*		_stkseek(Stk_t*, unsigned);
73 extern char*		stkfreeze(Stk_t*, unsigned);
74 extern int		stkon(Stk_t*, char *);
75 
76 #undef	extern
77 
78 #endif
79