0.2.38-pre1 implements AVR instructions
[fw/sdcc] / sim / ucsim / cmd.src / newcmd.cc
index 6b1001f5d8996658fe5991b2b0c50362dc312414..be85ad80a4c6812b773b93ee4b8130da4be15937 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Simulator of microcontrollers (newcmd.cc)
+ * Simulator of microcontrollers (cmd.src/newcmd.cc)
  *
  * Copyright (C) 1999,99 Drotos Daniel, Talker Bt.
  * 
@@ -57,8 +57,8 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
 #include "cmdutil.h"
 
 
-extern "C" int vasprintf();
-extern "C" int vsnprintf();
+extern "C" int vasprintf(char **strp, const  char *format, va_list ap);
+extern "C" int vsnprintf(char *str, size_t size,const char *format,va_list ap);
 
 static int
 cmd_do_print(FILE *f, char *format, va_list ap)
@@ -549,6 +549,7 @@ cl_console::cl_console(char *fin, char *fout, class cl_sim *asim):
     if (f= fopen(fout, "w+"), out= f?f:stdout, !f)
       fprintf(stderr, "Can't open `%s': %s\n", fout, strerror(errno));
   prompt= 0;
+  flags= CONS_NONE;
 }
 
 cl_console::cl_console(FILE *fin, FILE *fout, class cl_sim *asim):
@@ -558,6 +559,7 @@ cl_console::cl_console(FILE *fin, FILE *fout, class cl_sim *asim):
   sim= asim;
   in = fin;
   out= fout;
+  flags= CONS_NONE;
 }
 
 /*
@@ -657,7 +659,7 @@ cl_console::print_prompt(void)
   if (sim->arg_avail('P'))
     putc('\0', out);
   else
-    fprintf(out, "%s", prompt?prompt:
+    fprintf(out, "%s", (prompt && prompt[0])?prompt:
            ((p= sim->get_sarg(0, "prompt"))?p:"> "));
   fflush(out);
 }
@@ -838,7 +840,7 @@ int
 cl_listen_console::proc_input(void)
 {
   int newsock;
-  uint size;
+  ACCEPT_SOCKLEN_T size;
   struct sockaddr_in sock_addr;
 
   size= sizeof(struct sockaddr); 
@@ -880,24 +882,16 @@ cl_commander::init(void)
   if (!sim)
     return(1);
   if (sim->arg_avail('c'))
-    {
-      add_console(mk_console(sim->get_sarg('c', 0),
-                            sim->get_sarg('c', 0), sim));
-    }
+    add_console(mk_console(sim->get_sarg('c', 0),
+                          sim->get_sarg('c', 0), sim));
 #ifdef SOCKET_AVAIL
   if (sim->arg_avail('Z'))
-    {
-      add_console(mk_console(sim->get_iarg(0, "Zport"), sim));
-    }
+    add_console(mk_console(sim->get_iarg(0, "Zport"), sim));
   if (sim->arg_avail('r'))
-    {
-      add_console(mk_console(sim->get_iarg('r', 0), sim));
-    }
+    add_console(mk_console(sim->get_iarg('r', 0), sim));
 #endif
   if (cons->get_count() == 0)
-    {
-      add_console(mk_console(stdin, stdout, sim));
-    }
+    add_console(mk_console(stdin, stdout, sim));
   return(0);
 }
 
@@ -986,6 +980,23 @@ cl_commander::all_printf(char *format, ...)
   return(ret);
 }
 
+int
+cl_commander::all_print(char *string, int length)
+{
+  int i;
+  
+  for (i= 0; i < cons->count; i++)
+    {
+      class cl_console *c= (class cl_console*)(cons->at(i));
+      if (c->out)
+       {
+         for (int j= 0; j < length; j++)
+           putc(string[j], c->out);
+       }
+    }
+  return(0);
+}
+
 /*
  * Printing to actual_console
  */
@@ -1111,4 +1122,4 @@ cl_commander::proc_input(void)
 }
 
 
-/* End of newcmd.cc */
+/* End of cmd.src/newcmd.cc */