xref: /netbsd-src/usr.bin/dc/extern.h (revision 7d0b3229b86df951d08b0d2830b2c39f566b3529)
1*7d0b3229Schristos /*	$OpenBSD: extern.h,v 1.5 2015/10/10 19:28:54 deraadt Exp $	*/
2*7d0b3229Schristos 
3*7d0b3229Schristos /*
4*7d0b3229Schristos  * Copyright (c) 2003, Otto Moerbeek <otto@drijf.net>
5*7d0b3229Schristos  *
6*7d0b3229Schristos  * Permission to use, copy, modify, and distribute this software for any
7*7d0b3229Schristos  * purpose with or without fee is hereby granted, provided that the above
8*7d0b3229Schristos  * copyright notice and this permission notice appear in all copies.
9*7d0b3229Schristos  *
10*7d0b3229Schristos  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11*7d0b3229Schristos  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12*7d0b3229Schristos  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13*7d0b3229Schristos  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14*7d0b3229Schristos  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15*7d0b3229Schristos  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16*7d0b3229Schristos  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17*7d0b3229Schristos  */
18*7d0b3229Schristos 
19*7d0b3229Schristos #include <stdbool.h>
20*7d0b3229Schristos #include "bcode.h"
21*7d0b3229Schristos 
22*7d0b3229Schristos 
23*7d0b3229Schristos /* inout.c */
24*7d0b3229Schristos void		src_setstream(struct source *, FILE *);
25*7d0b3229Schristos void		src_setstring(struct source *, char *);
26*7d0b3229Schristos struct number	*readnumber(struct source *, u_int);
27*7d0b3229Schristos void		printnumber(FILE *, const struct number *, u_int);
28*7d0b3229Schristos char		*read_string(struct source *);
29*7d0b3229Schristos void		print_value(FILE *, const struct value *, const char *, u_int);
30*7d0b3229Schristos void		print_ascii(FILE *, const struct number *);
31*7d0b3229Schristos 
32*7d0b3229Schristos /* mem.c */
33*7d0b3229Schristos struct number	*new_number(void);
34*7d0b3229Schristos void		free_number(struct number *);
35*7d0b3229Schristos struct number	*dup_number(const struct number *);
36*7d0b3229Schristos void		*bmalloc(size_t);
37*7d0b3229Schristos void		*breallocarray(void *, size_t, size_t);
38*7d0b3229Schristos char		*bstrdup(const char *p);
39*7d0b3229Schristos void		bn_check(int);
40*7d0b3229Schristos void		bn_checkp(const void *);
41*7d0b3229Schristos 
42*7d0b3229Schristos /* stack.c */
43*7d0b3229Schristos void		stack_init(struct stack *);
44*7d0b3229Schristos void		stack_free_value(struct value *);
45*7d0b3229Schristos struct value	*stack_dup_value(const struct value *, struct value *);
46*7d0b3229Schristos void		stack_swap(struct stack *);
47*7d0b3229Schristos size_t		stack_size(const struct stack *);
48*7d0b3229Schristos void		stack_dup(struct stack *);
49*7d0b3229Schristos void		stack_pushnumber(struct stack *, struct number *);
50*7d0b3229Schristos void		stack_pushstring(struct stack *stack, char *);
51*7d0b3229Schristos void		stack_push(struct stack *, struct value *);
52*7d0b3229Schristos void		stack_set_tos(struct stack *, struct value *);
53*7d0b3229Schristos struct value	*stack_tos(const struct stack *);
54*7d0b3229Schristos struct value	*stack_pop(struct stack *);
55*7d0b3229Schristos struct number	*stack_popnumber(struct stack *);
56*7d0b3229Schristos char *		stack_popstring(struct stack *);
57*7d0b3229Schristos void		stack_clear(struct stack *);
58*7d0b3229Schristos void		stack_print(FILE *, const struct stack *, const char *,
59*7d0b3229Schristos 		    u_int base);
60*7d0b3229Schristos void		frame_assign(struct stack *, size_t, const struct value *);
61*7d0b3229Schristos struct value *	frame_retrieve(const struct stack *, size_t);
62*7d0b3229Schristos /* void		frame_free(struct stack *); */
63*7d0b3229Schristos 
64*7d0b3229Schristos int		dc_main(int, char **);
65