2 * Simulator of microcontrollers (cmd.src/cmdcl.h)
4 * Copyright (C) 1999,99 Drotos Daniel, Talker Bt.
6 * To contact author send email to drdani@mazsola.iit.uni-miskolc.hu
10 /* This file is part of microcontroller simulator: ucsim.
12 UCSIM is free software; you can redistribute it and/or modify
13 it under the terms of the GNU General Public License as published by
14 the Free Software Foundation; either version 2 of the License, or
15 (at your option) any later version.
17 UCSIM is distributed in the hope that it will be useful,
18 but WITHOUT ANY WARRANTY; without even the implied warranty of
19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 GNU General Public License for more details.
22 You should have received a copy of the GNU General Public License
23 along with UCSIM; see the file COPYING. If not, write to the Free
24 Software Foundation, 59 Temple Place - Suite 330, Boston, MA
28 #ifndef CMD_NEWCMDCL_HEADER
29 #define CMD_NEWCMDCL_HEADER
35 #include <sys/types.h>
47 #include "commandcl.h"
52 #define CONS_DEBUG 0x01 // Print debug messages on this console
53 #define CONS_FROZEN 0x02 // Console is frozen (g command issued)
54 #define CONS_PROMPT 0x04 // Prompt is out, waiting for input
55 #define CONS_INTERACTIVE 0x08 // Interactive console
56 #define CONS_NOWELCOME 0x10 // Do not print welcome message
57 #define CONS_INACTIVE 0x20 // Do not do any action
58 #define CONS_ECHO 0x40 // Echo commands
72 #define SY_DATALIST 'D'
78 class cl_prompt_option: public cl_optref
81 class cl_console *con;
83 cl_prompt_option(class cl_console *console);
84 virtual int init(void);
85 virtual void option_changed(void);
88 class cl_debug_option: public cl_prompt_option
91 cl_debug_option(class cl_console *console);
92 virtual int init(void);
93 virtual void option_changed(void);
100 class cl_console: public cl_base
102 friend class cl_commander;
104 FILE *in, *out, *rout/*redirected output*/;
106 class cl_prompt_option *prompt_option;
107 class cl_optref *null_prompt_option;
108 class cl_debug_option *debug_option;
112 int flags; // See CONS_XXXX
116 cl_console(void): cl_base() { app= 0; in= out= 0; flags= 0; }
117 cl_console(char *fin, char *fout, class cl_app *the_app);
118 cl_console(FILE *fin, FILE *fout, class cl_app *the_app);
119 cl_console(char *fin, FILE *fout);
121 cl_console(int portnumber, class cl_app *the_app);
123 virtual ~cl_console(void);
124 virtual class cl_console *cl_console::clone_for_exec(char *fin);
125 virtual int init(void);
127 virtual void welcome(void);
128 virtual void redirect(char *fname, char *mode);
129 virtual void un_redirect(void);
130 virtual FILE *get_out(void) { return(rout?rout:out); }
131 virtual void print_prompt(void);
132 virtual int dd_printf(char *format, ...);
133 virtual void print_bin(long data, int bits);
134 virtual void print_char_octal(char c);
135 virtual int match(int fdnum);
136 virtual int get_in_fd(void);
137 virtual int input_avail(void);
138 virtual char *read_line(void);
139 virtual int proc_input(class cl_cmdset *cmdset);
140 virtual bool interpret(char *cmd);
141 virtual void set_id(int new_id);
142 virtual int get_id(void) { return(id); }
143 virtual void set_prompt(char *p);
147 class cl_listen_console: public cl_console
152 cl_listen_console(int serverport, class cl_app *the_app);
154 virtual void welcome(void) {}
155 virtual void prompt(void) {}
157 virtual int match(int fdnum);
158 virtual int get_in_fd(void);
159 virtual int proc_input(class cl_cmdset *cmdset);
164 class cl_sub_console: public cl_console
166 class cl_console *parent;
168 cl_sub_console(class cl_console *the_parent,
169 FILE *fin, FILE *fout, class cl_app *the_app);
170 virtual ~cl_sub_console(void);
171 virtual int init(void);
176 * Command interpreter
179 class cl_commander: public cl_base
184 fd_set read_set, active_set;
187 class cl_console *actual_console, *frozen_console;
188 class cl_cmdset *cmdset;
191 cl_commander(class cl_app *the_app,
192 class cl_cmdset *acmdset/*, class cl_sim *asim*/);
193 virtual ~cl_commander(void);
194 virtual int init(void);
196 virtual class cl_console *mk_console(char *fin, char *fout);
197 virtual class cl_console *mk_console(FILE *fin, FILE *fout);
199 virtual class cl_console *mk_console(int portnumber);
201 void add_console(class cl_console *console);
202 void del_console(class cl_console *console);
203 void activate_console(class cl_console *console);
204 void deactivate_console(class cl_console *console);
205 void set_fd_set(void);
208 int all_printf(char *format, ...); // print to all consoles
209 int all_print(char *string, int length);
210 int dd_printf(char *format, ...); // print to actual_console
211 int debug(char *format, ...); // print consoles with debug flag set
212 int flag_printf(int iflags, char *format, ...);
213 int input_avail(void);
214 int input_avail_on_frozen(void);
215 int wait_input(void);
216 int proc_input(void);
222 /* End of cmd.src/cmdcl.h */