2 * Simulator of microcontrollers (cmd.src/newcmdcl.h)
4 * Copyright (C) 1999,99 Drotos Daniel, Talker Bt.
5 * Copyright (C) 2006, Borut Razem - borut.razem@siol.net
7 * To contact author send email to drdani@mazsola.iit.uni-miskolc.hu
11 /* This file is part of microcontroller simulator: ucsim.
13 UCSIM is free software; you can redistribute it and/or modify
14 it under the terms of the GNU General Public License as published by
15 the Free Software Foundation; either version 2 of the License, or
16 (at your option) any later version.
18 UCSIM is distributed in the hope that it will be useful,
19 but WITHOUT ANY WARRANTY; without even the implied warranty of
20 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 GNU General Public License for more details.
23 You should have received a copy of the GNU General Public License
24 along with UCSIM; see the file COPYING. If not, write to the Free
25 Software Foundation, 59 Temple Place - Suite 330, Boston, MA
29 #ifndef CMD_NEWCMDCL_HEADER
30 #define CMD_NEWCMDCL_HEADER
37 #include <sys/types.h>
46 #include "commandcl.h"
51 #define CONS_DEBUG 0x01 // Print debug messages on this console
52 #define CONS_FROZEN 0x02 // Console is frozen (g command issued)
53 #define CONS_PROMPT 0x04 // Prompt is out, waiting for input
54 #define CONS_INTERACTIVE 0x08 // Interactive console
55 #define CONS_NOWELCOME 0x10 // Do not print welcome message
56 #define CONS_INACTIVE 0x20 // Do not do any action
57 #define CONS_ECHO 0x40 // Echo commands
71 #define SY_DATALIST 'D'
77 class cl_prompt_option: public cl_optref
80 class cl_console_base *con;
82 cl_prompt_option(class cl_console_base *console);
83 virtual int init(void);
84 virtual void option_changed(void);
87 class cl_debug_option: public cl_prompt_option
90 cl_debug_option(class cl_console_base *console);
91 virtual int init(void);
92 virtual void option_changed(void);
99 class cl_console_base: public cl_base
102 class cl_prompt_option *prompt_option;
103 class cl_optref *null_prompt_option;
104 class cl_debug_option *debug_option;
105 class cl_ustrings *lines_printed;
106 class cl_cmd *last_command;
107 class cl_cmdline *last_cmdline;
110 cl_console_base(void): cl_base() { app = 0; flags = 0; prompt = 0; }
112 virtual class cl_console_base *clone_for_exec(char *fin) = 0;
114 virtual void redirect(char *fname, char *mode) = 0;
115 virtual void un_redirect(void) = 0;
116 virtual int cmd_do_print(const char *format, va_list ap) = 0;
117 virtual bool is_tty(void) const = 0;
118 virtual bool is_eof(void) const = 0;
119 virtual int input_avail(void) = 0;
120 virtual char *read_line(void) = 0;
122 virtual int init(void);
123 virtual void welcome(void);
124 virtual int proc_input(class cl_cmdset *cmdset);
126 void print_prompt(void);
127 int dd_printf(const char *format, ...);
128 int debug(const char *format, ...);
129 void print_bin(long data, int bits);
130 void print_char_octal(char c);
132 bool interpret(char *cmd);
133 int get_id(void) const { return(id); }
134 void set_id(int new_id);
135 void set_prompt(char *p);
137 bool input_active(void) const;
138 bool accept_last(void) { return is_tty() ? DD_TRUE : DD_FALSE; }
141 int flags; // See CONS_XXXX
150 * Command interpreter
153 class cl_commander_base: public cl_base
158 class cl_console_base *actual_console, *frozen_console;
159 class cl_cmdset *cmdset;
162 cl_commander_base(class cl_app *the_app, class cl_cmdset *acmdset);
163 virtual ~cl_commander_base(void);
165 void add_console(class cl_console_base *console);
166 void del_console(class cl_console_base *console);
167 void activate_console(class cl_console_base *console);
168 void deactivate_console(class cl_console_base *console);
171 int all_printf(const char *format, ...); // print to all consoles
172 int dd_printf(const char *format, va_list ap); // print to actual_console
173 int dd_printf(const char *format, ...); // print to actual_console
174 int debug(const char *format, ...); // print consoles with debug flag set
175 int debug(const char *format, va_list ap); // print consoles with debug flag set
176 int flag_printf(int iflags, const char *format, ...);
177 int input_avail_on_frozen(void);
178 void exec_on(class cl_console_base *cons, char *file_name);
180 virtual int init(void) = 0;
181 virtual void set_fd_set(void) = 0;
182 virtual int proc_input(void) = 0;
183 virtual int input_avail(void) = 0;
184 virtual int wait_input(void) = 0;
190 /* End of cmd.src/newcmdcl.h */