1 /*
2 
3     YABASIC ---  a simple Basic Interpreter
4     written by Marc Ihm 1995-2021
5     more info at www.yabasic.de
6 
7     yabasic.h --- function prototypes and global variables
8 
9     This file is part of yabasic and may be copied under the terms of
10     MIT License which can be found in the file LICENSE.
11 
12 */
13 
14 #define YABASIC_INCLUDED
15 
16 /* ------------- defines ---------------- */
17 
18 /*
19   Define one and only one of the following symbols, depending on your
20   System:
21   - UNIX: uses some UNIX-features and X11
22   - WINDOWS: uses WIN32-features
23 */
24 
25 #if defined(UNIX) && defined(WINDOWS)
26 #error UNIX and WINDOWS are defined together; check your compiler settings
27 #endif
28 #ifdef WINDOWS
29 #define _CRT_NONSTDC_NO_WARNINGS
30 #endif
31 /* ------------- includes ---------------- */
32 #include "config.h"
33 #include <stdio.h>
34 #include <stdlib.h>
35 #include <float.h>
36 #include <math.h>
37 #include <time.h>
38 #include <limits.h>
39 #include <errno.h>
40 #ifdef WINDOWS
41 #include <string.h>
42 #include <windows.h>
43 #include <io.h>
44 #include <Winspool.h>
45 #define ARCHITECTURE "windows"
46 #define YY_NO_UNISTD_H
47 #ifdef __LCC__			/* fix for lccwin32 */
48 #include <winspool.h>
49 #endif
50 #endif
51 #ifdef UNIX
52 #define ARCHITECTURE UNIX_ARCHITECTURE
53 #ifdef HAS_STRING_HEADER
54 #include <string.h>
55 #elif HAS_STRINGS_HEADER
56 #include <strings.h>
57 #endif
58 #include <sys/time.h>
59 #include <sys/wait.h>
60 #include <sys/ipc.h>
61 #include <sys/ioctl.h>
62 #include <X11/Xlib.h>
63 #include <X11/Xutil.h>
64 #define XK_LATIN1
65 #define XK_MISCELLANY
66 #include <X11/keysymdef.h>
67 #include <unistd.h>
68 #include <fcntl.h>
69 #include <term.h>
70 #ifdef HAVE_NCURSES_H
71 #include <ncurses.h>
72 #else
73 #ifdef HAVE_CURSES_H
74 #include <curses.h>
75 #endif
76 #endif
77 #ifndef KEY_MAX
78 #define KEY_MAX 0777
79 #endif
80 #endif
81 #ifndef FOPEN_MAX
82 #define FOPEN_MAX 9
83 #endif
84 #include <signal.h>
85 #include <ctype.h>
86 #ifdef UNIX
87 #ifndef LIBRARY_PATH
88 #define LIBRARY_PATH "/usr/lib"
89 #endif
90 #ifdef HAVE_LINUX_PERF_EVENT_H
91 #include <linux/perf_event.h>
92 #include <linux/hw_breakpoint.h>
93 #endif
94 #endif
95 #define OPEN_HAS_STREAM 1
96 #define OPEN_HAS_MODE 2
97 #define OPEN_PRINTER 8
98 #define STDIO_STREAM 1234
99 
100 /* -------- variables needed in all files and defined in ... -------- */
101 
102 /* main.c */
103 extern struct command *currcmd;	        /* currently executed command */
104 extern struct command *cmd_root;	/* first command */
105 extern struct command *cmd_head;	/* next command */
106 extern struct command *last_cmd;	/* last command */
107 extern int severity_threshold;  /* minimum severity the user wants to see */
108 extern int severity_so_far;     /* maximum severity that has been printed until now */
109 extern int interactive;		/* true, if commands come from stdin */
110 extern char *progname;		/* name of yabasic-program */
111 extern char *cexplanation[];	/* explanations of commands */
112 extern char *fexplanation[];	/* explanations of functions */
113 extern char **yabargv;		/* arguments for yabasic */
114 extern int yabargc;		/* number of arguments in yabargv */
115 extern long long int compilation_start, compilation_end, execution_end;
116 extern char *string;		/* for trash-strings */
117 extern char *estring;	/* for error-strings */
118 extern int errorcode;		/* error-codes */
119 extern char library_path[];	/* full path to search libraries */
120 extern int program_state;	/* state of program */
121 extern int check_compat;	/* true, if compatibility should be checked */
122 extern int is_bound;		/* true, if this executable is bound */
123 extern char *progname;		/* name of yabasic-program */
124 extern char *main_file_name;	/* name of program to be executed */
125 extern char *inter_path;	/* name of interpreter executing; i.e. ARGV[0] */
126 
127 /* io.c */
128 extern FILE *streams[];		/* file streams */
129 extern int read_controls;	/* TRUE, if input should read control characters */
130 extern int stream_modes[];	/* modes for streams */
131 extern int curinized;		/* true, if curses has been initialized */
132 extern int badstream (int, int);	/* test for valid stream id */
133 void myseek (struct command *);	/* reposition file pointer */
134 void mystream (int);		/* switch to specified stream */
135 #ifdef WINDOWS
136 extern HANDLE gotwinkey;		/* mutex to signal key reception */
137 extern char conkeybuff[]; /* Key received from console */
138 extern char winkeybuff[]; /* Key received from window */
139 extern HANDLE wthandle;		/* handle of win thread */
140 extern HANDLE kthandle;		/* handle of inkey thread */
141 extern DWORD ktid;		/* id of inkey thread */
142 extern int LINES;		/* number of lines on screen */
143 extern int COLS;		/* number of columns on screen */
144 extern HANDLE ConsoleInput;	/* handle for console input */
145 extern HANDLE ConsoleOutput;	/* handle for console output */
146 #else
147 extern int winpid;		/* pid of process waiting for window keys */
148 extern int termpid;		/* pid of process waiting for terminal keys */
149 #endif
150 
151 /* foreign.c */
152 extern char last_frnfn_call_error_text[]; /* last error message produced by foreign call */
153 extern int last_frnfn_call_okay;         /* true, if last foreign call has been okay */
154 
155 /* graphic.c */
156 /* printing and plotting */
157 extern int print_to_file;	/* print to file ? */
158 #ifdef WINDOWS
159 extern HFONT printerfont;	/* handle of printer-font */
160 extern HDC printer;		/* handle of printer */
161 #endif
162 extern FILE *printerfile;	/* file to print on */
163 extern double xoff;		/* offset for x-mapping */
164 extern double xinc;		/* inclination of x-mapping */
165 extern double yoff;		/* offset for y-mapping */
166 extern double yinc;		/* inclination for y-mapping */
167 /* window coordinates */
168 extern int winopened;		/* flag if window is open already */
169 extern char *winorigin;		/* e.g. "lt","rc"; defines origin of grafic window */
170 extern int winwidth, winheight;	/* size of window */
171 /* mouse, console and keyboard */
172 extern int mousex, mousey, mouseb, mousemod;	/* last know mouse coordinates */
173 extern char *ykey[];		/* keys returned by inkey */
174 /* text and font */
175 extern char *getreg (char *);	/* get defaults from Registry */
176 extern char *text_align;	/* specifies alignement of text */
177 extern int fontheight;		/* height of font in pixel */
178 extern int check_alignment (char *);	/* checks, if text-alignement is valid */
179 
180 #ifdef WINDOWS
181 extern HFONT myfont;		/* handle of font for screen */
182 #endif
183 /* general window stuff */
184 extern char *foreground;
185 extern char *background;
186 extern char *geometry;
187 extern char *displayname;
188 extern char *fontname;
189 extern int drawmode;
190 #ifdef UNIX
191 extern Display *display;
192 #endif
193 #ifdef WINDOWS
194 extern HWND window;		/* handle of my window */
195 extern HANDLE mainthread;	/* handle to main thread */
196 extern HANDLE this_instance;
197 extern WNDCLASS myclass;	/* window class for my program */
198 extern char *my_class;
199 extern BOOL Commandline;	/* true if launched from command line */
200 #else
201 extern int backpid;		/* pid of process waiting for redraw events */
202 #endif
203 
204 /* function.c */
205 extern struct command *datapointer;	/* current location for read-command */
206 extern char *last_inkey; /* last result of inkey */
207 void switch_compare (void);	/* compare topmost values for switch statement */
208 
209 /* symbol.c */
210 extern struct stackentry *stackroot;	/* first element of stack */
211 extern struct stackentry *stackhead;	/* last element of stack; actually stackhead->prev is the last element, that has contents */
212 extern void query_array (struct command *cmd);	/* query array */
213 extern struct command *last_symref;
214 extern struct command *first_symref;
215 extern int labelcount;		/* count self-generated labels */
216 
217 /* flex.c */
218 extern struct library *library_stack[];	/* stack for library file names */
219 extern struct library *currlib;	/* current libfile as relevant to bison */
220 extern int inlib;		/* true, while in library */
221 extern int in_short_if;		/* true, if within a short if */
222 extern int library_chain_length;	/* length of library_chain */
223 extern struct library *library_chain[];	/* list of all library file names */
224 extern int include_depth; /* current position in libfile_stack */
225 extern int start_token; /* pseudo token used to switch start state */
226 
227 /* bison.c */
228 extern char *current_function;	/* name of currently parsed function */
229 extern int yydebug;
230 extern int missing_endif;
231 extern int missing_endif_line;
232 void report_if_missing(char *,int);
233 void report_conflicting_close(char *,int);
234 void collect_missing_clauses(char *, char);
235 
236 /*-------------------------- defs and undefs ------------------------*/
237 
238 /* undef symbols */
239 #undef FATAL
240 #undef ERROR
241 #undef WARNING
242 #undef NOTE
243 #undef DEBUG
244 #undef DUMP
245 
246 #if !defined(TRUE)
247 #define TRUE (1==1)
248 #endif
249 
250 #ifndef FALSE
251 #define FALSE (1!=1)
252 #endif
253 
254 /* I've been told, that some symbols are missing under SunOs ... */
255 #ifndef RAND_MAX
256 #define RAND_MAX 32767
257 #endif
258 
259 /* length of buffers for system() and input */
260 #define PIPEBUFFLEN 1000   /* writing into pipes, e.g. for system$ */
261 #define INBUFFLEN 10000 /* user input */
262 #define NAMEBUFFLEN 200 /* names chosen by user */
263 
264 
265 /* ---------------------- enum types ------------------------------- */
266 
267 enum severity {
268     /* error levels  */
269     sBISON, sDEBUG, sNOTE, sWARNING, sDUMP, sINFO, sERROR, sFATAL
270 };
271 
272 enum end_reasons {
273     /* ways to end the program */
274     rNONE, rERROR, rREQUEST, rEOF
275 };
276 
277 enum stream_modes {
278     /* ways to access a stream */
279     mCLOSED = 0, mREAD = 1, mWRITE = 2, mPRINT = 4
280 };
281 
282 enum functions {
283     /* functions in yabasic (sorted by number of arguments) */
284     fFIRST_FUNCTION,		/* no function, just marks start of list */
285     fRAN2, fDATE, fTIME,
286     fFRNFN_CALL, fFRNFN_CALL2, fFRNBF_ALLOC, fFRNBF_DUMP, fFRNBF_DUMP2,
287     fFRNBF_GET_NUMBER, fFRNBF_GET_STRING, fFRNBF_GET_BUFFER, fFRNFN_SIZE, fFRNBF_SIZE,
288     fZEROARGS,
289     fINKEY, fMOUSEX, fMOUSEY, fMOUSEB, fMOUSEMOD,
290     fSIN, fASIN, fCOS, fACOS, fTAN,
291     fATAN, fSYSTEM, fSYSTEM2, fPEEK, fPEEK2, fPEEK4, fTELL, fEXP, fLOG, fLEN,
292     fSTR, fSTR4,
293     fSQRT, fSQR, fFRAC, fROUND, fABS, fSIG, fRAN, fINT, fCEIL, fFLOOR, fVAL, fASC, fHEX, fBIN, fDEC,
294     fUPPER, fLOWER, fCHOMP,
295     fLTRIM, fRTRIM, fTRIM, fCHR, fBITNOT,
296     fONEARGS, fDEC2, fATAN2, fLEFT, fAND, fOR,
297     fEOR, fSHL, fSHR, fLOG2,
298     fRIGHT, fINSTR, fRINSTR, fSTR2, fMOD, fMIN, fMAX, fPEEK3, fMID2,
299     fTWOARGS,
300     fMID, fINSTR2, fRINSTR2, fSTR3,
301     fTHREEARGS,
302     fGETBIT, fGETCHAR,
303     fLAST_FUNCTION,		/* no function, just marks end of list */
304 };
305 
306 enum arraymode {
307     /* type of array access */
308     CALLARRAY, ASSIGNARRAY, CALLSTRINGARRAY, ASSIGNSTRINGARRAY,
309     GETSTRINGPOINTER
310 };
311 
312 enum drawing_modes {
313     /* various ways to draw */
314     dmNORMAL = 0, dmCLEAR = 1, dmFILL = 2
315 };
316 
317 enum eval_types {
318     /* different types of eval */
319     evNONE = 0, evNUMBER = 1, evSTRING = 2
320 };
321 
322 enum cmd_type {
323     /* type of command */
324     cFIRST_COMMAND,		/* no command, just marks start of list */
325 
326     cLABEL, cLINK_SUBR, cGOTO, cQGOTO, cGOSUB, cQGOSUB, cRETURN_FROM_GOSUB,	/* flow control */
327     cEND, cEXIT, cBIND, cDECIDE, cSKIPPER, cNOP, cFINDNOP, cEXCEPTION,
328     cANDSHORT,
329     cORSHORT, cSKIPONCE, cRESETSKIPONCE, cRESETSKIPONCE2, cCOMPILE, cEXECUTE, cEXECUTE2, cEVAL, cEVAL_CODE,
330 
331     cDIM, cFUNCTION, cDOARRAY, cARRAYLINK, cPUSHARRAYREF, cCLEARSYMREFS,	/* everything with "()" */
332     cARDIM, cARSIZE, cTOKEN, cTOKEN2, cTOKENALT, cTOKENALT2,
333     cSPLIT, cSPLIT2, cSPLITALT, cSPLITALT2,
334     cSTARTFOR, cFORCHECK, cFORINCREMENT,	/* for for-loops */
335 
336     cSWITCH_COMPARE, cNEXT_CASE, cNEXT_CASE_HERE, cBREAK_MULTI, 	/* break-continue-switch */
337     cCONTINUE, cBREAK_HERE, cCONTINUE_HERE, cPOP_MULTI,
338     cBEGIN_LOOP_MARK, cEND_LOOP_MARK, cBEGIN_SWITCH_MARK, cEND_SWITCH_MARK,
339 
340     cDBLADD, cDBLMIN, cDBLMUL, cDBLDIV, cDBLPOW,	/* double operations */
341     cNEGATE, cPUSHDBLSYM, cPOP, cPOPDBLSYM, cPUSHDBL,
342 
343     cREQUIRE, cPUSHFREE, cMAKELOCAL, cMAKESTATIC, cCOUNT_PARAMS,	/* functions and procedures */
344     cCALL, cQCALL, cPUSHSYMLIST, cPOPSYMLIST, cRETURN_FROM_CALL,
345     cUSER_FUNCTION, cCHECK_RETURN_VALUE, cEND_FUNCTION,
346     cFUNCTION_OR_ARRAY, cSTRINGFUNCTION_OR_ARRAY,
347 
348     cPOKE, cPOKEFILE, cSWAP, cDUPLICATE, cDOCU,	/* internals */
349 
350     cAND, cOR, cNOT, cLT, cGT, cLE, cGE, cEQ, cNE,	/* comparisons */
351     cSTREQ, cSTRNE, cSTRLT, cSTRLE, cSTRGT, cSTRGE,
352 
353     cPUSHSTRSYM, cPOPSTRSYM, cPUSHSTR, cCONCAT,	/* string operations */
354     cPUSHSTRPTR, cCHANGESTRING, cGLOB,
355 
356     cPRINT, cREAD, cRESTORE, cQRESTORE, cONESTRING,	/* i/o operations */
357     cREADDATA, cDATA, cOPEN, cCHECKOPEN, cCHECKSEEK, cCLOSE, cPUSHSTREAM,
358     cPOPSTREAM,
359     cSEEK, cSEEK2, cTESTEOF, cWAIT, cBELL, cMOVE,
360     cCLEARSCR, cCOLOUR, cCHKPROMPT, cERROR,
361 
362     cOPENWIN, cDOT, cLINE, cCIRCLE, cTRIANGLE, cTEXT1, cTEXT2, cTEXT3, cCLOSEWIN, cCLEARWIN,	/* grafics */
363     cOPENPRN, cCLOSEPRN, cMOVEORIGIN, cRECT, cGCOLOUR, cGCOLOUR2,
364     cGBACKCOLOUR, cGBACKCOLOUR2, cPUTBIT, cPUTCHAR,
365 
366     cFRNBF_SET_NUMBER, cFRNBF_SET_STRING, cFRNBF_FREE,    /* foreign libraries */
367     cFRNBF_SET_BUFFER,
368 
369     cLAST_COMMAND			/* no command, just marks end of list */
370 };
371 
372 enum stackentries {
373     /* different types of stackentries */
374     stGOTO, stSTRING, stSTRINGARRAYREF, stNUMBER, stNUMBERARRAYREF, stLABEL,
375     stRET_ADDR, stRET_ADDR_CALL, stFREE, stROOT,
376     stANY, stSTRING_OR_NUMBER, stSTRING_OR_NUMBER_ARRAYREF,	/* these will never appear on stack but are used to check with pop */
377     stSWITCH_STRING, stSWITCH_NUMBER	/* only used in switch statement, compares true to every string or number */
378 };
379 
380 enum symbols {
381     /* different types of symbols */
382     sySTRING, syNUMBER, syFREE, syARRAY
383 };
384 
385 enum function_type {
386     /* different types of functions */
387     ftNONE, ftNUMBER, ftSTRING
388 };
389 
390 enum addmodes {
391     /* different modes for adding symbols */
392     amSEARCH, amSEARCH_PRE, amADD_LOCAL, amADD_GLOBAL, amSEARCH_VERY_LOCAL
393 };
394 
395 enum states {
396     /* current state of program (variable program_state) */
397     spHATCHED, spINITIALIZED, spCOMPILING, spRUNNING, spFINISHED
398 };
399 
400 enum yabkeys {
401     /* recognized special keys */
402     kERR, kUP, kDOWN, kLEFT, kRIGHT, kDEL, kINS, kCLEAR, kHOME, kEND,
403     kF0, kF1, kF2, kF3, kF4, kF5, kF6, kF7, kF8, kF9, kF10, kF11, kF12,
404     kF13, kF14, kF15, kF16, kF17, kF18, kF19, kF20, kF21, kF22, kF23, kF24,
405     kBACKSPACE, kSCRNDOWN, kSCRNUP, kENTER, kESC, kTAB, kLASTKEY
406 };
407 
408 enum search_modes {
409     /* modes for searching labels */
410     srmSUBR = 1, srmLINK = 2, srmLABEL = 4, srmGLOBAL = 8
411 };
412 
413 /* ------------- global types ---------------- */
414 
415 struct stackentry {
416     /* one element on stack */
417     int type;			/* type of entry */
418     struct stackentry *next;
419     struct stackentry *prev;
420     void *pointer;		/* multi-use pointer, e.g. for strings */
421     double value;		/* double value, only one of pointer or value is used */
422 };
423 
424 struct symstack {
425     /* stack of symbol lists */
426     struct symbol *next_in_list;
427     struct symstack *next_in_stack;
428     struct symstack *prev_in_stack;
429 };
430 
431 struct symbol {
432     /* general symbol; either variable, string */
433     int type;
434     struct symbol *link;		/* points to linked symbol, if any */
435     struct symbol *next_in_list;	/* next symbol in symbollist */
436     char *name;			/* name of symbol */
437     void *pointer;		/* pointer to string contents (if any) */
438     char *args;			/* used to store number of arguments for functions/array */
439     double value;
440 };
441 
442 struct command {
443     /* one interpreter command */
444     int type;			/* type of command */
445     int cnt;			/* count of this command */
446     struct command *prev;		/* link to previous command */
447     struct command *next;		/* link to next command */
448     void *pointer;		/* pointer to data */
449     void *symbol;			/* pointer to symbol (or data within symbol) associated with command */
450     struct command *jump;		/* pointer to jump destination */
451     char *symname;			/* name of symbol associated with command */
452     struct command *next_symref;	/* next cmd within function referencing a symbol */
453     struct command *next_assoc;	/* next cmd within chain of associated commands; used for commands: data, docu, label */
454     int args;			/* number of arguments for function/array call
455 				   or stream number for open/close */
456     int tag;			/* char/int to pass some information */
457     int line;			/* line this command has been created for */
458     int first_column;           /* column, at which this command started */
459     int last_column;            /* column, at which this command ended */
460     struct library *lib;	/* associated library */
461     char *diag;                 /* optional text for diagnostics */
462     struct switch_state *switch_state;  /* state for switch statements */
463 };
464 
465 struct switch_state {    /* records surrounding of a statement; used to check gotos into, out-of, within and between switch-statements (i.e. to err on most)  */
466     int id;           /* unique id for each switch-statment */
467     int nesting;      /* number of nested switch-statements */
468     int pop_on_qgoto; /* number of stack entries to pop on quick goto */
469 };
470 
471 struct array {
472     /* data structure for arrays */
473     int bounds[10];		/* index boundaries */
474     int dimension;		/* dimension of array */
475     void *pointer;		/* contents of array */
476     char type;			/* decide between string- ('s') and double-Arrays ('d') */
477 };
478 
479 struct buff_chain {
480     /* buffer chain for system-input */
481     char buff[PIPEBUFFLEN + 1];	/* content of buffer */
482     int len;			/* used length of buff */
483     struct buff_chain *next;	/* next buffer in chain */
484 };
485 
486 struct library {
487     /* used to store library names and other details */
488     char *long_name;		/* long version, including path */
489     int long_len;		/* length of l */
490     char *short_name;		/* short version */
491     int short_len;		/* length of s */
492     struct command *datapointer;/* data pointer of this library */
493     struct command *firstdata;	/* first data-command in library */
494     struct library *next_lib;	/* next in chain */
495     struct library *imported_from; /* where has this library been imported from ? */
496     int yylineno_at_start;      /* value of yylineno at import of library */
497 };
498 
499 /* ------------- function prototypes defined in ... ---------------- */
500 
501 /* main.c */
502 void error (int, char *);
503 void error_with_position (int, char *, char *, int, int, int);
504 void error_without_position(int, char *);
505 void show_and_mark_line (char *, int, int, int);
506 void std_diag (char *, int, char *, char *);
507 void *my_malloc (unsigned);
508 void my_free (void *);
509 char *my_strerror (int);
510 struct command *add_command (int);
511 struct command *add_command_with_sym (int, char *);
512 struct command *add_command_with_diag (int, char *);
513 struct command *add_command_with_sym_and_diag (int, char *, char *);
514 struct command *add_command_with_switch_state(int);
515 void dump_commands (char *);
516 void signal_handler (int);
517 char *my_strdup (char *);
518 char *my_strndup (char *, int);
519 struct library *new_library (char *, char *);
520 char *dotify (char *, int);
521 char *strip (char *);
522 void create_docu (char *);
523 extern void add_variables (char *);
524 void compile (void);
525 void create_execute (int);
526 void execute (struct command *);
527 void create_eval (int);
528 void eval (struct command *);
529 int isbound (void);
530 
531 /* io.c */
532 void checkopen (void);
533 void create_colour (int);
534 void colour (struct command *cmd);
535 void create_print (char);
536 void print (struct command *);
537 void create_myread (char, int);
538 void myread (struct command *);
539 void create_onestring (char *);
540 void onestring (char *);
541 void chkprompt (void);
542 void create_myopen (int);
543 void myopen (struct command *);
544 void testeof (struct command *);
545 void myclose ();
546 void create_pps (int, int);
547 void push_stream (struct command *);
548 void pop_stream (void);
549 void mymove ();
550 void clearscreen ();
551 char *inkey (double);
552 char *replace_escapes (char *);
553 int count_backslashes(char *);
554 
555 /* graphic.c */
556 void create_openwin (int);
557 void openwin (struct command *);
558 void create_openprinter (int);
559 void openprinter (struct command *);
560 void closeprinter (void);
561 void putindrawmode (int);
562 void dot (struct command *);
563 void create_line (int);
564 void line (struct command *);
565 void moveorigin ();
566 int check_alignement (char *);
567 void circle (struct command *);
568 void triangle (struct command *);
569 void create_text (int);
570 void text (struct command *);
571 void closewin (void);
572 void clearwin (void);
573 void rect (struct command *);
574 void putbit (void);
575 void putchars (void);
576 void create_marker (int);
577 void marker (struct command *);
578 void getwinkey (char *);
579 void gettermkey (char *);
580 char *getbit (int, int, int, int);
581 char *getchars (int, int, int, int);
582 void change_colour (struct command *);
583 #ifdef WINDOWS
584 LRESULT CALLBACK mywindowproc (HWND, unsigned, UINT, DWORD);
585 #else
586 void calc_psscale (void);
587 #endif
588 
589 /* foreign.c */
590 void frnfn_call (int,double *,char **);
591 double frnfn_size (void);
592 char *frnbf_alloc (void);
593 void frnbf_free (void);
594 char *frnbf_dump (int);
595 int frnbf_size ();
596 void frnbf_set (void);
597 void frnbf_set2 (void);
598 double frnbf_get (void);
599 char *frnbf_get2 (void);
600 char *frnbf_get_buffer (void);
601 void frnbf_set_buffer (void);
602 
603 /* function.c */
604 void create_exception (int);
605 void exception (struct command *);
606 void create_poke (char);
607 void poke ();
608 void pokefile (struct command *);
609 void create_dblrelop (char);
610 void dblrelop (struct command *);
611 void concat (void);
612 void create_strrelop (char);
613 void strrelop (struct command *);
614 void create_changestring (int);
615 void changestring (struct command *);
616 void glob (void);
617 void create_boole (char);
618 void boole (struct command *);
619 void create_function (int);
620 void function (struct command *);
621 int myformat (char *, int, double, char *, char *);
622 int myformat2 (char *, int, double, char *, char *);
623 void create_restore (char *);
624 void restore (struct command *);
625 void create_dbldata (double);
626 void create_strdata (char *);
627 void create_readdata (char);
628 void readdata (struct command *);
629 void mywait ();
630 void mybell ();
631 void getmousexybm (char *, int *, int *, int *, int *);
632 void token (struct command *);
633 void tokenalt (struct command *);
634 long long current_millis(void);
635 
636 
637 /* symbol.c */
638 struct array *create_array (int, int);
639 void start_symref_chain (void);
640 void end_symref_chain (void);
641 void clear_symrefs (struct command *);
642 void duplicate (void);
643 void negate (void);
644 void create_require (int);
645 void require (struct command *);
646 void create_makelocal (char *, int);
647 void create_makestatic (char *, int);
648 void create_arraylink (char *, int);
649 void create_pusharrayref (char *, int);
650 void pusharrayref (struct command *);
651 void arraylink (struct command *);
652 void makestatic (struct command *);
653 void makelocal (struct command *);
654 void pushdblsym (struct command *);
655 void popdblsym (struct command *);
656 void create_pushdbl (double);
657 void pushdbl (struct command *);
658 void create_dblbin (char);
659 void dblbin (struct command *);
660 void pushstrsym (struct command *);
661 void popstrsym (struct command *);
662 void create_pushstr (char *);
663 void pushstr (struct command *);
664 void pushname (char *);
665 void pushstrptr (struct command *);
666 void logical_shortcut (struct command *type);
667 void create_doarray (char *, int);
668 void doarray (struct command *);
669 void create_dim (char *, char);
670 void dim (struct command *);
671 void swap (void);
672 struct stackentry *push (void);
673 struct stackentry *pop (int);
674 void pop_multi (struct command *);
675 struct symbol *get_sym (char *, int, int);
676 void link_symbols (struct symbol *, struct symbol *);
677 void pushsymlist (void);
678 void popsymlist (void);
679 void dump_sym ();
680 void dump_sub (int);
681 void function_or_array (struct command *);
682 int count_args (int);
683 void stackdesc (int, char *);
684 
685 
686 /* flow.c */
687 void link_label (struct command *);
688 void create_count_params (void);
689 void count_params (struct command *);
690 void forcheck (void);
691 void forincrement (void);
692 void startfor (void);
693 void create_goto (char *);
694 void create_gosub (char *);
695 void create_call (char *);
696 void create_label (char *, int);
697 void create_subr_link (char *);
698 struct command *add_switch_state(struct command *);
699 void pushgoto (void);
700 void popgoto (void);
701 void jump (struct command *);
702 void myreturn (struct command *);
703 void findnop ();
704 void skipper (void);
705 void skiponce (struct command *);
706 void resetskiponce (struct command *, int);
707 void decide (void);
708 void pushlabel (void);
709 void poplabel (void);
710 void storelabel ();
711 void matchgoto ();
712 void create_check_return_value (int, int);
713 void check_return_value (struct command *);
714 void create_endfunction (void);
715 struct command *search_label (char *, int);
716 void reorder_stack_before_call (struct stackentry *);
717 void reorder_stack_after_call (int);
718 void create_mybreak(int);
719 void mybreak (struct command *);
720 void mycontinue (struct command *cmd);
721 void next_case (struct command *);
722 int check_leave_switch (struct command *, struct command *);
723 void pop_switch_value (struct command *);
724 void initialize_switch_id_stack(void);
725 void push_switch_id (void);
726 void pop_switch_id (void);
727 
728 
729 /* flex.c */
730 void yyerror (char *);
731 void open_main (FILE *, char *, char *);
732 FILE *open_library (char *, char **);
733 void leave_lib (void);
734 void start_flex_from_string(char *);
735 void end_flex_from_string(void);
736