2 * Simulator of microcontrollers (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
43 * Command line with parameters
46 class cl_cmdline: cl_base
51 class cl_list *params;
52 class cl_ustrings *tokens;
55 cl_cmdline(char *cmd);
56 virtual ~cl_cmdline(void);
57 virtual int init(void);
59 virtual int split(void);
60 virtual int shift(void);
61 virtual int repeat(void);
62 virtual class cl_cmd_arg *param(int num);
63 virtual void insert_param(int pos, class cl_cmd_arg *param);
65 char *skip_delims(char *start);
70 * Command and container
74 class cl_cmd: public cl_base
78 class cl_strings *names;
84 cl_cmd(class cl_sim *asim,
91 virtual void add_name(char *name);
92 virtual int name_match(char *aname, int strict);
93 virtual int name_match(class cl_cmdline *cmdline, int strict);
94 virtual int syntax_ok(class cl_cmdline *cmdline);
95 virtual int work(class cl_cmdline *cmdline, class cl_console *con);
96 virtual int do_work(class cl_cmdline *cmdline, class cl_console *con);
99 // Command set is list of cl_cmd objects
100 class cl_cmdset: public cl_list
104 class cl_cmd *last_command;
107 cl_cmdset(class cl_sim *asim);
109 virtual class cl_cmd *get_cmd(class cl_cmdline *cmdline);
110 virtual void del(char *name);
111 virtual void replace(char *name, class cl_cmd *cmd);
114 // subset of commands
115 class cl_super_cmd: public cl_cmd
118 class cl_cmdset *commands;
121 cl_super_cmd(class cl_sim *asim,
126 class cl_cmdset *acommands);
129 virtual int work(class cl_cmdline *cmdline, class cl_console *con);
137 class cl_console: public cl_base
143 int flags; // See CONS_XXXX
147 cl_console(): cl_base() {}
148 cl_console(char *fin, char *fout, class cl_sim *asim);
149 cl_console(FILE *fin, FILE *fout, class cl_sim *asim);
151 cl_console(int portnumber, class cl_sim *asim);
154 virtual int init(void);
156 virtual void welcome(void);
157 virtual void print_prompt(void);
158 virtual int printf(char *format, ...);
159 virtual void print_bin(long data, int bits);
160 virtual int match(int fdnum);
161 virtual int get_in_fd(void);
162 virtual int input_avail(void);
163 virtual char *read_line(void);
164 virtual int proc_input(void);
165 virtual bool interpret(char *cmd);
166 virtual bool old_command(class cl_cmdline *cmdline) { return(DD_FALSE); }
170 class cl_listen_console: public cl_console
175 cl_listen_console(int serverport, class cl_sim *asim);
177 virtual void welcome(void) {}
178 virtual void prompt(void) {}
180 virtual int match(int fdnum);
181 virtual int get_in_fd(void);
182 virtual int proc_input(void);
188 * Command interpreter
191 class cl_commander: public cl_base
195 fd_set read_set, active_set;
198 class cl_console *actual_console, *frozen_console;
201 cl_commander(class cl_sim *asim);
203 virtual int init(void);
205 virtual class cl_console *mk_console(char *fin, char *fout,
207 virtual class cl_console *mk_console(FILE *fin, FILE *fout,
210 virtual class cl_console *mk_console(int portnumber, class cl_sim *asim);
212 void add_console(class cl_console *console);
213 void del_console(class cl_console *console);
214 void set_fd_set(void);
216 int all_printf(char *format, ...); // print to all consoles
217 int all_print(char *string, int length);
218 int printf(char *format, ...); // print to actual_console
219 int debug(char *format, ...); // print consoles with debug flag set
220 int flag_printf(int iflags, char *format, ...);
221 int input_avail(void);
222 int input_avail_on_frozen(void);
223 int wait_input(void);
224 int proc_input(void);