/[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 6 by dpavlin, Mon Oct 8 16:18:11 2007 UTC revision 20 by dpavlin, Mon Oct 8 16:19:23 2007 UTC
# Line 25  Line 25 
25   *  SUCH DAMAGE.   *  SUCH DAMAGE.
26   *   *
27   *   *
28   *  $Id: console.c,v 1.8 2005/05/29 17:51:45 debug Exp $   *  $Id: console.c,v 1.10 2005/11/23 02:17:00 debug Exp $
29   *   *
30   *  Generic console support functions.   *  Generic console support functions.
31   *   *
# Line 186  static void start_xterm(int handle) Line 186  static void start_xterm(int handle)
186          a[4] = console_handles[handle].name;          a[4] = console_handles[handle].name;
187          a[5] = "-e";          a[5] = "-e";
188          a[6] = progname;          a[6] = progname;
189          a[7] = malloc(50);          a[7] = malloc(80);
190          sprintf(a[7], "-WW@S%i,%i", filedes[0], filedesB[1]);          snprintf(a[7], 80, "-WW@S%i,%i", filedes[0], filedesB[1]);
191          a[8] = NULL;          a[8] = NULL;
192    
193          p = fork();          p = fork();
# Line 641  static struct console_handle *console_ne Line 641  static struct console_handle *console_ne
641  int console_start_slave(struct machine *machine, char *consolename)  int console_start_slave(struct machine *machine, char *consolename)
642  {  {
643          int handle;          int handle;
644            size_t mlen;
645          struct console_handle *chp;          struct console_handle *chp;
646    
647          if (machine == NULL || consolename == NULL) {          if (machine == NULL || consolename == NULL) {
# Line 650  int console_start_slave(struct machine * Line 651  int console_start_slave(struct machine *
651    
652          chp = console_new_handle(consolename, &handle);          chp = console_new_handle(consolename, &handle);
653    
654          chp->name = malloc(strlen(machine->name) + strlen(consolename) + 100);          mlen = strlen(machine->name) + strlen(consolename) + 40;
655            chp->name = malloc(mlen);
656          if (chp->name == NULL) {          if (chp->name == NULL) {
657                  printf("out of memory\n");                  printf("out of memory\n");
658                  exit(1);                  exit(1);
659          }          }
660          sprintf(chp->name, "GXemul: '%s' %s", machine->name, consolename);          snprintf(chp->name, mlen, "GXemul: '%s' %s",
661                machine->name, consolename);
662    
663  #if 0  #if 0
664          if (!machine->use_x11) {          if (!machine->use_x11) {
# Line 684  int console_start_slave_inputonly(struct Line 687  int console_start_slave_inputonly(struct
687  {  {
688          struct console_handle *chp;          struct console_handle *chp;
689          int handle;          int handle;
690            size_t mlen;
691    
692          if (machine == NULL || consolename == NULL) {          if (machine == NULL || consolename == NULL) {
693                  printf("console_start_slave(): NULL ptr\n");                  printf("console_start_slave(): NULL ptr\n");
# Line 693  int console_start_slave_inputonly(struct Line 697  int console_start_slave_inputonly(struct
697          chp = console_new_handle(consolename, &handle);          chp = console_new_handle(consolename, &handle);
698          chp->inputonly = 1;          chp->inputonly = 1;
699    
700          chp->name = malloc(strlen(machine->name) + strlen(consolename) + 100);          mlen = strlen(machine->name) + strlen(consolename) + 40;
701            chp->name = malloc(mlen);
702          if (chp->name == NULL) {          if (chp->name == NULL) {
703                  printf("out of memory\n");                  printf("out of memory\n");
704                  exit(1);                  exit(1);
705          }          }
706          sprintf(chp->name, "GXemul: '%s' %s", machine->name, consolename);          snprintf(chp->name, mlen, "GXemul: '%s' %s",
707                machine->name, consolename);
708    
709          return handle;          return handle;
710  }  }
# Line 768  void console_allow_slaves(int allow) Line 774  void console_allow_slaves(int allow)
774  }  }
775    
776    
777    /*
778     *  console_are_slaves_allowed():
779     *
780     *  Returns the value of allow_slaves.
781     */
782    int console_are_slaves_allowed(void)
783    {
784            return allow_slaves;
785    }
786    
787    
788    /*
789     *  console_warn_if_slaves_are_needed():
790     *
791     *  Prints a warning if slave xterms are needed (i.e. there is more than one
792     *  console handle in use), but they are not currently allowed.
793     */
794    void console_warn_if_slaves_are_needed(void)
795    {
796            int i, n = 0;
797            for (i=MAIN_CONSOLE+1; i<n_console_handles; i++)
798                    if (console_handles[i].in_use &&
799                        !console_handles[i].using_xterm)
800                            n ++;
801    
802            if (!allow_slaves && n > 1) {
803                    fatal("#\n#  WARNING! More than one console output is in use,"
804                        "\n#  but xterm slaves are not enabled. Behaviour will\n"
805                        "#  be undefined.  (Use -x to enable slave xterms.)\n#\n");
806                    for (i=MAIN_CONSOLE+1; i<n_console_handles; i++)
807                            if (console_handles[i].in_use &&
808                                !console_handles[i].using_xterm)
809                                    fatal("#  console handle %i: '%s'\n",
810                                        i, console_handles[i].name);
811                    fatal("#\n");
812            }
813    }
814    
815    
816  /*  /*
817   *  console_init():   *  console_init():
818   *   *

Legend:
Removed from v.6  
changed lines
  Added in v.20

  ViewVC Help
Powered by ViewVC 1.1.26