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