/[gxemul]/trunk/src/console.c
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /trunk/src/console.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 41 by dpavlin, Mon Oct 8 16:21:17 2007 UTC revision 42 by dpavlin, Mon Oct 8 16:22:32 2007 UTC
# Line 25  Line 25 
25   *  SUCH DAMAGE.   *  SUCH DAMAGE.
26   *   *
27   *   *
28   *  $Id: console.c,v 1.22 2006/12/30 13:30:51 debug Exp $   *  $Id: console.c,v 1.26 2007/06/15 18:07:33 debug Exp $
29   *   *
30   *  Generic console support functions.   *  Generic console support functions.
31   *   *
# Line 70  Line 70 
70  #include <termios.h>  #include <termios.h>
71  #include <unistd.h>  #include <unistd.h>
72  #include <sys/types.h>  #include <sys/types.h>
73    #include <time.h>
74    
75  #include "console.h"  #include "console.h"
76  #include "emul.h"  #include "emul.h"
77  #include "machine.h"  #include "machine.h"
 #include "memory.h"  
 #include "misc.h"  
78  #include "settings.h"  #include "settings.h"
79    
80    
# Line 205  static void start_xterm(int handle) Line 204  static void start_xterm(int handle)
204          /*  printf("filedesB = %i,%i\n", filedesB[0], filedesB[1]);  */          /*  printf("filedesB = %i,%i\n", filedesB[0], filedesB[1]);  */
205    
206          /*  NOTE/warning: Hardcoded max nr of args!  */          /*  NOTE/warning: Hardcoded max nr of args!  */
207          a = malloc(sizeof(char *) * 20);          CHECK_ALLOCATION(a = malloc(sizeof(char *) * 20));
         if (a == NULL) {  
                 fprintf(stderr, "start_xterm(): out of memory\n");  
                 exit(1);  
         }  
208    
209          a[0] = getenv("XTERM");          a[0] = getenv("XTERM");
210          if (a[0] == NULL)          if (a[0] == NULL)
# Line 219  static void start_xterm(int handle) Line 214  static void start_xterm(int handle)
214          a[3] = "-title";          a[3] = "-title";
215          mlen = strlen(console_handles[handle].name) +          mlen = strlen(console_handles[handle].name) +
216              strlen(console_handles[handle].machine_name) + 30;              strlen(console_handles[handle].machine_name) + 30;
217          a[4] = malloc(mlen);          CHECK_ALLOCATION(a[4] = malloc(mlen));
218          snprintf(a[4], mlen, "GXemul: %s %s",          snprintf(a[4], mlen, "GXemul: %s %s",
219              console_handles[handle].machine_name,              console_handles[handle].machine_name,
220              console_handles[handle].name);              console_handles[handle].name);
221          a[5] = "-e";          a[5] = "-e";
222          a[6] = progname;          a[6] = progname;
223          a[7] = malloc(80);          CHECK_ALLOCATION(a[7] = malloc(80));
224          snprintf(a[7], 80, "-WW@S%i,%i", filedes[0], filedesB[1]);          snprintf(a[7], 80, "-WW@S%i,%i", filedes[0], filedesB[1]);
225          a[8] = NULL;          a[8] = NULL;
226    
# Line 616  static struct console_handle *console_ne Line 611  static struct console_handle *console_ne
611          if (found_free == -1) {          if (found_free == -1) {
612                  /*  Let's realloc console_handles[], to make room                  /*  Let's realloc console_handles[], to make room
613                      for the new one:  */                      for the new one:  */
614                  console_handles = realloc(console_handles, sizeof(                  CHECK_ALLOCATION(console_handles =
615                      struct console_handle) * (n_console_handles + 1));                      realloc(console_handles, sizeof(
616                  if (console_handles == NULL) {                      struct console_handle) * (n_console_handles + 1)));
                         printf("console_new_handle(): out of memory\n");  
                         exit(1);  
                 }  
617                  found_free = n_console_handles;                  found_free = n_console_handles;
618                  n_console_handles ++;                  n_console_handles ++;
619          }          }
# Line 631  static struct console_handle *console_ne Line 623  static struct console_handle *console_ne
623    
624          chp->in_use = 1;          chp->in_use = 1;
625          chp->machine_name = "";          chp->machine_name = "";
626          chp->name = strdup(name);          CHECK_ALLOCATION(chp->name = strdup(name));
         if (chp->name == NULL) {  
                 printf("console_new_handle(): out of memory\n");  
                 exit(1);  
         }  
627    
628          *handlep = found_free;          *handlep = found_free;
629          return chp;          return chp;
# Line 685  int console_start_slave(struct machine * Line 673  int console_start_slave(struct machine *
673                  chp->in_use_for_input = 0;                  chp->in_use_for_input = 0;
674          }          }
675    
676          if (machine->machine_name != NULL)          if (machine->machine_name != NULL) {
677                  chp->machine_name = strdup(machine->machine_name);                  CHECK_ALLOCATION(chp->machine_name =
678          else                      strdup(machine->machine_name));
679                  chp->machine_name = strdup("");          } else {
680                    CHECK_ALLOCATION(chp->machine_name = strdup(""));
681            }
682    
683          chp->name = strdup(consolename);          CHECK_ALLOCATION(chp->name = strdup(consolename));
684    
685          if (allow_slaves)          if (allow_slaves)
686                  chp->using_xterm = USING_XTERM_BUT_NOT_YET_OPEN;                  chp->using_xterm = USING_XTERM_BUT_NOT_YET_OPEN;
# Line 725  int console_start_slave_inputonly(struct Line 715  int console_start_slave_inputonly(struct
715          chp = console_new_handle(consolename, &handle);          chp = console_new_handle(consolename, &handle);
716          chp->inputonly = 1;          chp->inputonly = 1;
717          chp->in_use_for_input = use_for_input;          chp->in_use_for_input = use_for_input;
718          chp->machine_name = strdup(machine->name);          CHECK_ALLOCATION(chp->machine_name = strdup(machine->name));
719          chp->name = strdup(consolename);          CHECK_ALLOCATION(chp->name = strdup(consolename));
720    
721          return handle;          return handle;
722  }  }

Legend:
Removed from v.41  
changed lines
  Added in v.42

  ViewVC Help
Powered by ViewVC 1.1.26