1*5d2e36e8Schristos /* $NetBSD: proto.h,v 1.2 2017/04/10 15:13:22 christos Exp $ */ 2ed857e95Sphil 3ed857e95Sphil /* 4ed857e95Sphil * Copyright (C) 1991-1994, 1997, 2006, 2008, 2012-2017 Free Software Foundation, Inc. 5ed857e95Sphil * Copyright (C) 2016-2017 Philip A. Nelson. 6ed857e95Sphil * All rights reserved. 7ed857e95Sphil * 8ed857e95Sphil * Redistribution and use in source and binary forms, with or without 9ed857e95Sphil * modification, are permitted provided that the following conditions 10ed857e95Sphil * are met: 11ed857e95Sphil * 12ed857e95Sphil * 1. Redistributions of source code must retain the above copyright 13ed857e95Sphil * notice, this list of conditions and the following disclaimer. 14ed857e95Sphil * 2. Redistributions in binary form must reproduce the above copyright 15ed857e95Sphil * notice, this list of conditions and the following disclaimer in the 16ed857e95Sphil * documentation and/or other materials provided with the distribution. 17ed857e95Sphil * 3. The names Philip A. Nelson and Free Software Foundation may not be 18ed857e95Sphil * used to endorse or promote products derived from this software 19ed857e95Sphil * without specific prior written permission. 20ed857e95Sphil * 21ed857e95Sphil * THIS SOFTWARE IS PROVIDED BY PHILIP A. NELSON ``AS IS'' AND ANY EXPRESS OR 22ed857e95Sphil * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 23ed857e95Sphil * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 24ed857e95Sphil * IN NO EVENT SHALL PHILIP A. NELSON OR THE FREE SOFTWARE FOUNDATION BE 25ed857e95Sphil * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 26ed857e95Sphil * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 27ed857e95Sphil * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28ed857e95Sphil * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 29ed857e95Sphil * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 30ed857e95Sphil * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 31ed857e95Sphil * THE POSSIBILITY OF SUCH DAMAGE. 32ed857e95Sphil */ 33ed857e95Sphil 34ed857e95Sphil /* proto.h: Prototype function definitions for "external" functions. */ 35ed857e95Sphil 36ed857e95Sphil /* For the pc version using k&r ACK. (minix1.5 and earlier.) */ 37ed857e95Sphil #ifdef SHORTNAMES 38ed857e95Sphil #define init_numbers i_numbers 39ed857e95Sphil #define push_constant push__constant 40ed857e95Sphil #define load_const in_load_const 41ed857e95Sphil #define yy_get_next_buffer yyget_next_buffer 42ed857e95Sphil #define yy_init_buffer yyinit_buffer 43ed857e95Sphil #define yy_last_accepting_state yylast_accepting_state 44ed857e95Sphil #define arglist1 arg1list 45ed857e95Sphil #endif 46ed857e95Sphil 47ed857e95Sphil /* Include the standard library header files. */ 48ed857e95Sphil #ifdef HAVE_UNISTD_H 49ed857e95Sphil #include <unistd.h> 50ed857e95Sphil #endif 51ed857e95Sphil #ifdef HAVE_STDLIB_H 52ed857e95Sphil #include <stdlib.h> 53ed857e95Sphil #endif 54ed857e95Sphil 55ed857e95Sphil /* From execute.c */ 56ed857e95Sphil void stop_execution (int); 57ed857e95Sphil unsigned char byte (program_counter *pc_); 58ed857e95Sphil void execute (void); 59ed857e95Sphil int prog_char (void); 60ed857e95Sphil int input_char (void); 61ed857e95Sphil void push_constant (int (*in_char)(void), int conv_base); 62ed857e95Sphil void push_b10_const (program_counter *pc_); 63ed857e95Sphil void assign (char code); 64ed857e95Sphil 65ed857e95Sphil /* From util.c */ 66ed857e95Sphil char *strcopyof (const char *str); 67ed857e95Sphil arg_list *nextarg (arg_list *args, int val, int is_var); 68ed857e95Sphil char *arg_str (arg_list *args); 69ed857e95Sphil char *call_str (arg_list *args); 70ed857e95Sphil void free_args (arg_list *args); 71ed857e95Sphil void check_params (arg_list *params, arg_list *autos); 72ed857e95Sphil void set_genstr_size (int); 73ed857e95Sphil void init_gen (void); 74ed857e95Sphil void generate (const char *str); 75ed857e95Sphil void run_code (void); 76ed857e95Sphil void out_char (int ch); 77ed857e95Sphil void out_schar (int ch); 78ed857e95Sphil id_rec *find_id (id_rec *tree, const char *id); 79ed857e95Sphil int insert_id_rec (id_rec **root, id_rec *new_id); 80ed857e95Sphil void init_tree (void); 81ed857e95Sphil int lookup (char *name, int namekind); 82ed857e95Sphil void *bc_malloc (size_t); 83*5d2e36e8Schristos void out_of_memory (void) __attribute__((__noreturn__)); 84ed857e95Sphil void welcome (void); 85ed857e95Sphil void warranty (const char *); 86ed857e95Sphil void show_bc_version (void); 87ed857e95Sphil void limits (void); 88*5d2e36e8Schristos void yyerror (const char *str, ...) 89*5d2e36e8Schristos __attribute__((__format__ (__printf__, 1, 2))); 90*5d2e36e8Schristos void ct_warn (const char *mesg, ...) 91*5d2e36e8Schristos __attribute__((__format__ (__printf__, 1, 2))); 92*5d2e36e8Schristos void rt_error (const char *mesg, ...) 93*5d2e36e8Schristos __attribute__((__format__ (__printf__, 1, 2))); 94*5d2e36e8Schristos void rt_warn (const char *mesg, ...) 95*5d2e36e8Schristos __attribute__((__format__ (__printf__, 1, 2))); 96*5d2e36e8Schristos void bc_exit (int) __attribute__((__noreturn__)); 97ed857e95Sphil 98ed857e95Sphil /* From load.c */ 99ed857e95Sphil void init_load (void); 100ed857e95Sphil void addbyte (unsigned char thebyte); 101ed857e95Sphil void def_label (unsigned long lab); 102ed857e95Sphil long long_val (const char **str); 103ed857e95Sphil void load_code (const char *code); 104ed857e95Sphil 105ed857e95Sphil /* From main.c */ 106ed857e95Sphil int open_new_file (void); 107ed857e95Sphil void new_yy_file (FILE *file); 108*5d2e36e8Schristos void use_quit (int) __attribute__((__noreturn__)); 109ed857e95Sphil 110ed857e95Sphil /* From storage.c */ 111ed857e95Sphil void init_storage (void); 112ed857e95Sphil void more_functions (void); 113ed857e95Sphil void more_variables (void); 114ed857e95Sphil void more_arrays (void); 115ed857e95Sphil void clear_func (int func); 116ed857e95Sphil int fpop (void); 117ed857e95Sphil void fpush (int val); 118ed857e95Sphil void pop (void); 119ed857e95Sphil void push_copy (bc_num num); 120ed857e95Sphil void push_num (bc_num num); 121ed857e95Sphil char check_stack (int depth); 122ed857e95Sphil bc_var *get_var (int var_name); 123ed857e95Sphil bc_num *get_array_num (int var_index, unsigned long _index_); 124ed857e95Sphil void store_var (int var_name); 125ed857e95Sphil void store_array (int var_name); 126ed857e95Sphil void load_var (int var_name); 127ed857e95Sphil void load_array (int var_name); 128ed857e95Sphil void decr_var (int var_name); 129ed857e95Sphil void decr_array (int var_name); 130ed857e95Sphil void incr_var (int var_name); 131ed857e95Sphil void incr_array (int var_name); 132ed857e95Sphil void auto_var (int name); 133ed857e95Sphil void free_a_tree (bc_array_node *root, int depth); 134ed857e95Sphil void pop_vars (arg_list *list); 135ed857e95Sphil void process_params (program_counter *_pc_, int func); 136ed857e95Sphil 137ed857e95Sphil /* For the scanner and parser.... */ 138ed857e95Sphil int yyparse (void); 139ed857e95Sphil int yylex (void); 140ed857e95Sphil 141ed857e95Sphil #if defined(LIBEDIT) 142ed857e95Sphil /* The *?*&^ prompt function */ 143ed857e95Sphil char *null_prompt (EditLine *); 144ed857e95Sphil #endif 145ed857e95Sphil 146ed857e95Sphil /* Other things... */ 147ed857e95Sphil #ifndef HAVE_UNISTD_H 148ed857e95Sphil (int getopt (int, char *[], CONST char *); 149ed857e95Sphil #endif 150