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