File: stack.h

package info (click to toggle)
xmhtml 1.1.7-18
  • links: PTS
  • area: main
  • in suites: wheezy
  • size: 6,576 kB
  • sloc: ansic: 68,174; makefile: 438; sh: 158; perl: 36
file content (103 lines) | stat: -rw-r--r-- 3,153 bytes parent folder | download | duplicates (10)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
/*****
* stack.h : generic stack routines
*
* This file Version	$Revision: 1.1 $
*
* Creation date:		Thu Apr  2 12:26:52 GMT+0100 1998
* Last modification: 	$Date: 1998/04/04 06:27:26 $
* By:					$Author: newt $
* Current State:		$State: Exp $
*
* Author:				newt
*
* Copyright (C) 1994-1998 by Ripley Software Development 
* All Rights Reserved
*
* This file is part of the XmHTML Widget Library
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the Free
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
*****/
/*****
* $Source: /usr/local/rcs/Newt/XmHTML/RCS/stack.h,v $
*****/
/*****
* ChangeLog 
* $Log: stack.h,v $
* Revision 1.1  1998/04/04 06:27:26  newt
* Initial Revision
*
*****/ 

#ifndef _stack_h_
#define _stack_h_

/* Stack is an opaque definition, defined in stack.c */
typedef struct _StackRegistry *Stack;

/*****
* Create a stack.
* fallback: data to return when the stack is becoming negative.
* destroy_data_func is a function that will be called when the stack
* is destroyed while items are still remaining on the stack.
*****/
extern Stack StackCreate(void *fallback, void (*destroy_data_func)(void*));

/* create a stack that can stack two sets of data */
extern Stack StackCreateDouble(void *fallback_data1, void *fallback_data2,
	void (*destroy_data_func)(void*),
	void (*second_destroy_data_func)(void*));

/*****
* Destroy the given stack (and any data remaining). Returns the no
* of items that still remained on the stack.
*****/
extern int StackDestroy(Stack stack);

/*****
* Push data onto a stack. data is the data to be pushed, and should be cast
* to void* by the caller. Returns 1 when data was successfully pushed, 0
* if not.
*****/
extern int StackPushData(Stack stack, void *data);

/* push two sets of data on the stack */
extern int StackPushDoubleData(Stack stack, void *data1, void *data2);

/*****
* Pop data from the stack. Returned data should be cast to an appropriate
* type by the caller.
*****/
extern void* StackPopData(Stack stack);

/* pop two sets of data from the stack */
extern void* StackPopDoubleData(Stack stack, void **data);

/* return size of the stack */
extern int StackSize(Stack stack);

/* convenient macros, take care of typecasting when pushing & popping data */
#define StackPush(S,D)				StackPushData(S,(void*)(D))

#define StackPop(S)					StackPopData(S)

#define StackPushDouble(S,D1,D2) \
	StackPushDoubleData(S,(void*)(D1), (void*)(D2))

#define StackPopDouble(S,D) \
	StackPopDoubleData(S,(void**)&(D))

/* Don't add anything after this endif! */
#endif /* _stack_h_ */