/[gxemul]/trunk/src/emul_parse.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/emul_parse.c

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

revision 34 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: emul_parse.c,v 1.45 2006/12/30 13:30:52 debug Exp $   *  $Id: emul_parse.c,v 1.46 2007/06/15 17:02:38 debug Exp $
29   *   *
30   *  Set up an emulation by parsing a config file.   *  Set up an emulation by parsing a config file.
31   *   *
# Line 306  static void parse__emul(struct emul *e, Line 306  static void parse__emul(struct emul *e,
306                          free(e->name);                          free(e->name);
307                          e->name = NULL;                          e->name = NULL;
308                  }                  }
309                  e->name = strdup(tmp);                  CHECK_ALLOCATION(e->name = strdup(tmp));
                 if (e->name == NULL) {  
                         fprintf(stderr, "out of memory in parse__emul()\n");  
                         exit(1);  
                 }  
310                  debug("name: \"%s\"\n", e->name);                  debug("name: \"%s\"\n", e->name);
311                  return;                  return;
312          }          }
# Line 427  static void parse__net(struct emul *e, F Line 423  static void parse__net(struct emul *e, F
423                          fprintf(stderr, "too many remote networks\n");                          fprintf(stderr, "too many remote networks\n");
424                          exit(1);                          exit(1);
425                  }                  }
426                  cur_net_remote[cur_net_n_remote] = malloc(MAX_REMOTE_LEN);  
427                  if (cur_net_remote[cur_net_n_remote] == NULL) {                  CHECK_ALLOCATION(cur_net_remote[cur_net_n_remote] =
428                          fprintf(stderr, "out of memory\n");                      malloc(MAX_REMOTE_LEN));
                         exit(1);  
                 }  
429                  read_one_word(f, cur_net_remote[cur_net_n_remote],                  read_one_word(f, cur_net_remote[cur_net_n_remote],
430                      MAX_REMOTE_LEN, line, EXPECT_WORD);                      MAX_REMOTE_LEN, line, EXPECT_WORD);
431                  cur_net_n_remote ++;                  cur_net_n_remote ++;
# Line 469  static void parse__machine(struct emul * Line 463  static void parse__machine(struct emul *
463                          exit(1);                          exit(1);
464    
465                  if (cur_machine_cpu[0])                  if (cur_machine_cpu[0])
466                          m->cpu_name = strdup(cur_machine_cpu);                          CHECK_ALLOCATION(m->cpu_name = strdup(cur_machine_cpu));
467    
468                  if (!cur_machine_use_x11[0])                  if (!cur_machine_use_x11[0])
469                          strlcpy(cur_machine_use_x11, "no",                          strlcpy(cur_machine_use_x11, "no",
470                              sizeof(cur_machine_use_x11));                              sizeof(cur_machine_use_x11));
471                  m->use_x11 = parse_on_off(cur_machine_use_x11);                  m->x11_md.in_use = parse_on_off(cur_machine_use_x11);
472    
473                  if (!cur_machine_slowsi[0])                  if (!cur_machine_slowsi[0])
474                          strlcpy(cur_machine_slowsi, "no",                          strlcpy(cur_machine_slowsi, "no",
# Line 549  static void parse__machine(struct emul * Line 543  static void parse__machine(struct emul *
543                  m->physical_ram_in_mb = atoi(cur_machine_memory);                  m->physical_ram_in_mb = atoi(cur_machine_memory);
544    
545                  if (!cur_machine_x11_scaledown[0])                  if (!cur_machine_x11_scaledown[0])
546                          m->x11_scaledown = 1;                          m->x11_md.scaledown = 1;
547                  else {                  else {
548                          m->x11_scaledown = atoi(cur_machine_x11_scaledown);                          m->x11_md.scaledown = atoi(cur_machine_x11_scaledown);
549                          if (m->x11_scaledown < 0) {                          if (m->x11_md.scaledown < 0) {
550                                  m->x11_scaleup = 0 - m->x11_scaledown;                                  m->x11_md.scaleup = 0 - m->x11_md.scaledown;
551                                  m->x11_scaledown = 1;                                  m->x11_md.scaledown = 1;
552                          }                          }
553                          if (m->x11_scaledown < 1) {                          if (m->x11_md.scaledown < 1) {
554                                  fprintf(stderr, "Invalid scaledown value"                                  fprintf(stderr, "Invalid scaledown value"
555                                      " (%i)\n", m->x11_scaledown);                                      " (%i)\n", m->x11_md.scaledown);
556                                  exit(1);                                  exit(1);
557                          }                          }
558                  }                  }
# Line 575  static void parse__machine(struct emul * Line 569  static void parse__machine(struct emul *
569                          m->boot_string_argument = strdup(cur_machine_bootarg);                          m->boot_string_argument = strdup(cur_machine_bootarg);
570    
571                  for (i=0; i<cur_machine_n_x11_disp; i++) {                  for (i=0; i<cur_machine_n_x11_disp; i++) {
572                          m->x11_n_display_names ++;                          m->x11_md.n_display_names ++;
573                          m->x11_display_names = realloc(                          CHECK_ALLOCATION(m->x11_md.display_names = realloc(
574                              m->x11_display_names, m->x11_n_display_names                              m->x11_md.display_names, m->x11_md.n_display_names
575                              * sizeof(char *));                              * sizeof(char *)));
576                          if (m->x11_display_names == NULL) {                          CHECK_ALLOCATION(m->x11_md.display_names[
577                                  printf("out of memory\n");                              m->x11_md.n_display_names-1] =
578                                  exit(1);                              strdup(cur_machine_x11_disp[i]));
                         }  
                         m->x11_display_names[m->x11_n_display_names-1] =  
                             strdup(cur_machine_x11_disp[i]);  
                         if (m->x11_display_names  
                            [m->x11_n_display_names-1] == NULL) {  
                                 printf("out of memory\n");  
                                 exit(1);  
                         }  
579                          free(cur_machine_x11_disp[i]);                          free(cur_machine_x11_disp[i]);
580                          cur_machine_x11_disp[i] = NULL;                          cur_machine_x11_disp[i] = NULL;
581                  }                  }
# Line 640  static void parse__machine(struct emul * Line 626  static void parse__machine(struct emul *
626                          fprintf(stderr, "too many loads\n");                          fprintf(stderr, "too many loads\n");
627                          exit(1);                          exit(1);
628                  }                  }
629                  cur_machine_load[cur_machine_n_load] = malloc(MAX_LOAD_LEN);                  CHECK_ALLOCATION(cur_machine_load[cur_machine_n_load] =
630                  if (cur_machine_load[cur_machine_n_load] == NULL) {                      malloc(MAX_LOAD_LEN));
                         fprintf(stderr, "out of memory\n");  
                         exit(1);  
                 }  
631                  read_one_word(f, cur_machine_load[cur_machine_n_load],                  read_one_word(f, cur_machine_load[cur_machine_n_load],
632                      MAX_LOAD_LEN, line, EXPECT_WORD);                      MAX_LOAD_LEN, line, EXPECT_WORD);
633                  cur_machine_n_load ++;                  cur_machine_n_load ++;
# Line 660  static void parse__machine(struct emul * Line 643  static void parse__machine(struct emul *
643                          fprintf(stderr, "too many disks\n");                          fprintf(stderr, "too many disks\n");
644                          exit(1);                          exit(1);
645                  }                  }
646                  cur_machine_disk[cur_machine_n_disk] = malloc(MAX_DISK_LEN);                  CHECK_ALLOCATION(cur_machine_disk[cur_machine_n_disk] =
647                  if (cur_machine_disk[cur_machine_n_disk] == NULL) {                      malloc(MAX_DISK_LEN));
                         fprintf(stderr, "out of memory\n");  
                         exit(1);  
                 }  
648                  read_one_word(f, cur_machine_disk[cur_machine_n_disk],                  read_one_word(f, cur_machine_disk[cur_machine_n_disk],
649                      MAX_DISK_LEN, line, EXPECT_WORD);                      MAX_DISK_LEN, line, EXPECT_WORD);
650                  cur_machine_n_disk ++;                  cur_machine_n_disk ++;
# Line 680  static void parse__machine(struct emul * Line 660  static void parse__machine(struct emul *
660                          fprintf(stderr, "too many devices\n");                          fprintf(stderr, "too many devices\n");
661                          exit(1);                          exit(1);
662                  }                  }
663                  cur_machine_device[cur_machine_n_device] =                  CHECK_ALLOCATION(cur_machine_device[cur_machine_n_device] =
664                      malloc(MAX_DEVICE_LEN);                      malloc(MAX_DEVICE_LEN));
                 if (cur_machine_device[cur_machine_n_device] == NULL) {  
                         fprintf(stderr, "out of memory\n");  
                         exit(1);  
                 }  
665                  read_one_word(f, cur_machine_device[cur_machine_n_device],                  read_one_word(f, cur_machine_device[cur_machine_n_device],
666                      MAX_DEVICE_LEN, line, EXPECT_WORD);                      MAX_DEVICE_LEN, line, EXPECT_WORD);
667                  cur_machine_n_device ++;                  cur_machine_n_device ++;
# Line 701  static void parse__machine(struct emul * Line 677  static void parse__machine(struct emul *
677                          fprintf(stderr, "too many x11 displays\n");                          fprintf(stderr, "too many x11 displays\n");
678                          exit(1);                          exit(1);
679                  }                  }
680                  cur_machine_x11_disp[cur_machine_n_x11_disp] =                  CHECK_ALLOCATION(cur_machine_x11_disp[cur_machine_n_x11_disp] =
681                      malloc(MAX_X11_DISP_LEN);                      malloc(MAX_X11_DISP_LEN));
                 if (cur_machine_x11_disp[cur_machine_n_x11_disp] == NULL) {  
                         fprintf(stderr, "out of memory\n");  
                         exit(1);  
                 }  
682                  read_one_word(f, cur_machine_x11_disp[cur_machine_n_x11_disp],                  read_one_word(f, cur_machine_x11_disp[cur_machine_n_x11_disp],
683                      MAX_X11_DISP_LEN, line, EXPECT_WORD);                      MAX_X11_DISP_LEN, line, EXPECT_WORD);
684                  cur_machine_n_x11_disp ++;                  cur_machine_n_x11_disp ++;

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

  ViewVC Help
Powered by ViewVC 1.1.26