Subversion Repositories SvarDOS

Rev

Rev 2089 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 2089 Rev 2090
Line 535... Line 535...
535
  return(1);
535
  return(1);
536
}
536
}
537
 
537
 
538
 
538
 
539
int main(int argc, char **argv) {
539
int main(int argc, char **argv) {
540
  FILE *fd, *fdc;
540
  FILE *fd;
541
  int ecode = 0;
541
  int ecode = 0;
542
  int i, output_format = C_OUTPUT;
542
  int i, output_format = C_OUTPUT;
-
 
543
  int mvcomp_enabled = 0;
543
  unsigned short biggest_langsz = 0;
544
  unsigned short biggest_langsz = 0;
544
  struct svl_lang *lang = NULL, *reflang = NULL;
545
  struct svl_lang *lang = NULL, *reflang = NULL;
545
 
546
 
546
  if (argc < 2) {
547
  if (argc < 2) {
547
    puts("tlumacz ver " SVARLANGVER " - this tool is part of the SvarLANG project.");
548
    puts("tlumacz ver " SVARLANGVER " - this tool is part of the SvarLANG project.");
548
    puts("converts a set of CATS-style translations in files EN.TXT, PL.TXT, etc");
549
    puts("converts a set of CATS-style translations in files EN.TXT, PL.TXT, etc");
549
    puts("into a single resource file (OUT.LNG).");
550
    puts("into a single resource file (OUT.LNG).");
550
    puts("");
551
    puts("");
551
    puts("usage: tlumacz [/c|/asm|/nasm] en fr pl ...");
552
    puts("usage: tlumacz [/c | /asm | /nasm] [/comp] en fr pl ...");
552
    return(1);
553
    return(1);
553
  }
554
  }
554
 
555
 
555
  fd = fopen("out.lng", "wb");
556
  fd = fopen("out.lng", "wb");
556
  if (fd == NULL) {
557
  if (fd == NULL) {
557
    fprintf(stderr, "ERROR: FAILED TO CREATE OR OPEN OUT.LNG");
558
    fprintf(stderr, "ERROR: FAILED TO CREATE OR OPEN OUT.LNG");
558
    return(1);
559
    return(1);
559
  }
560
  }
560
  fdc = fopen("outc.lng", "wb");
-
 
561
  if (fd == NULL) {
-
 
562
    fclose(fd);
-
 
563
    puts("ERR: failed to open or create OUTC.LNG");
-
 
564
    return(1);
-
 
565
  }
-
 
566
 
561
 
567
  /* write lang blocks */
562
  /* write lang blocks */
568
  for (i = 1; i < argc; i++) {
563
  for (i = 1; i < argc; i++) {
569
    unsigned short sz;
564
    unsigned short sz;
570
    char id[3];
565
    char id[3];
571
 
566
 
572
    if (!strcmp(argv[i], "/c")) {
567
    if (!strcmp(argv[i], "/c")) {
573
      output_format = C_OUTPUT;
568
      output_format = C_OUTPUT;
574
      continue;
569
      continue;
575
    }
-
 
576
    else if (!strcmp(argv[i], "/asm")) {
570
    } else if (!strcmp(argv[i], "/asm")) {
577
      output_format = ASM_OUTPUT;
571
      output_format = ASM_OUTPUT;
578
      continue;
572
      continue;
579
    } else if(!strcmp(argv[i], "/nasm")) {
573
    } else if(!strcmp(argv[i], "/nasm")) {
580
      output_format = NASM_OUTPUT;
574
      output_format = NASM_OUTPUT;
581
      continue;
575
      continue;
-
 
576
    } else if(!strcmp(argv[i], "/comp")) {
-
 
577
      mvcomp_enabled = 1;
-
 
578
      continue;
582
    }
579
    }
583
 
580
 
584
    if (strlen(argv[i]) != 2) {
581
    if (strlen(argv[i]) != 2) {
585
      fprintf(stderr, "INVALID LANG SPECIFIED: %s\r\n", argv[i]);
582
      fprintf(stderr, "INVALID LANG SPECIFIED: %s\r\n", argv[i]);
586
      ecode = 1;
583
      ecode = 1;
Line 606... Line 603...
606
      if (sz > biggest_langsz) biggest_langsz = sz;
603
      if (sz > biggest_langsz) biggest_langsz = sz;
607
    }
604
    }
608
    svl_compact_lang(lang);
605
    svl_compact_lang(lang);
609
 
606
 
610
    /* write header if first (reference) language */
607
    /* write header if first (reference) language */
611
    if (i == 1) {
608
    if (!reflang) {
612
      if (!svl_write_header(lang->num_strings, fd)) {
609
      if (!svl_write_header(lang->num_strings, fd)) {
613
        fprintf(stderr, "ERROR WRITING TO OUTPUT FILE\r\n");
610
        fprintf(stderr, "ERROR WRITING TO OUTPUT FILE\r\n");
614
        ecode = 1;
611
        ecode = 1;
615
        goto exit_main;
612
        goto exit_main;
616
      }
613
      }
617
      if (!svl_write_header(lang->num_strings, fdc)) {
-
 
618
        fprintf(stderr, "ERROR WRITING TO OUTPUT (COMPRESSED) FILE\r\n");
-
 
619
        ecode = 1;
-
 
620
        break;
-
 
621
      }
-
 
622
    }
614
    }
623
 
615
 
624
    /* write lang ID to file, followed string table size, and then
616
    /* write lang ID to file, followed string table size, and then
625
       the dictionary and string table for current language */
617
       the dictionary and string table for current language */
626
    if (!svl_write_lang(lang, fd, 0)) { /* UNCOMPRESSED */
618
    if (!svl_write_lang(lang, fd, mvcomp_enabled)) {
627
      fprintf(stderr, "ERROR WRITING TO OUTPUT FILE\r\n");
619
      fprintf(stderr, "ERROR WRITING TO OUTPUT FILE\r\n");
628
      ecode = 1;
620
      ecode = 1;
629
      goto exit_main;
621
      goto exit_main;
630
    }
622
    }
631
 
623
 
632
    /* write lang ID to file, followed string table size, and then
-
 
633
       the dictionary and string table for current language */
-
 
634
    if (!svl_write_lang(lang, fdc, 1)) { /* COMPRESSED */
-
 
635
      fprintf(stderr, "ERROR WRITING TO OUTPUT (COMPRESSED) FILE\r\n");
-
 
636
      ecode = 1;
-
 
637
      goto exit_main;
-
 
638
    }
-
 
639
 
-
 
640
    /* remember reference data for other languages */
624
    /* remember reference data for other languages */
641
    if (!reflang) {
625
    if (!reflang) {
642
      reflang = lang;
626
      reflang = lang;
643
    } else {
627
    } else {
644
      svl_lang_free(lang);
628
      svl_lang_free(lang);