Changeset 5523 for trunk/tools/wrc/writeres.c
- Timestamp:
- Apr 16, 2001, 7:12:53 PM (24 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tools/wrc/writeres.c
r3426 r5523 12 12 #include <string.h> 13 13 #include <assert.h> 14 #include <time.h> 15 14 15 #include "wine/unicode.h" 16 16 #include "wrc.h" 17 17 #include "writeres.h" … … 26 26 #endif 27 27 28 #define MASM 129 28 #ifdef MASM 30 29 #define DIRECTIVE_BYTE "db" 31 #define DIRECTIVE_ WORD"dw"30 #define DIRECTIVE_SHORT "dw" 32 31 #define DIRECTIVE_LONG "dd" 33 32 #define DIRECTIVE_ALIGN "align" … … 40 39 #define COMMENT_LINE ";" 41 40 #define OR "or" 42 char s_file_head_str[] = 43 ";/* This file is generated with wrc version " WRC_FULLVERSION ". Do not edit! */\n" 44 ";/* Source : %s */\n" 45 ";/* Cmdline: %s */\n" 46 ";/* Date : %s */\n" 41 42 static char s_file_head_str[] = 43 "; This file is generated with wrc version " WRC_FULLVERSION ". Do not edit! */\n" 44 "; Source : %s */\n" 45 "; Cmdline: %s */\n" 46 "; Date : %s */\n" 47 47 "\n" 48 48 "\t.386p\n" … … 52 52 ; 53 53 54 char s_file_tail_str[] =54 static char s_file_tail_str[] = 55 55 "\tend\n" 56 "; /*<eof> */\n"56 "; <eof> */\n" 57 57 "\n" 58 58 ; … … 60 60 #else 61 61 #define DIRECTIVE_BYTE ".byte" 62 #define DIRECTIVE_ WORD ".word"62 #define DIRECTIVE_SHORT ".short" 63 63 #define DIRECTIVE_LONG ".long" 64 64 #define DIRECTIVE_ALIGN ".align" … … 72 72 #define OR "|" 73 73 74 char s_file_head_str[] =74 static char s_file_head_str[] = 75 75 "/* This file is generated with wrc version " WRC_FULLVERSION ". Do not edit! */\n" 76 76 "/* Source : %s */\n" … … 82 82 ; 83 83 84 char s_file_tail_str[] =84 static char s_file_tail_str[] = 85 85 "/* <eof> */\n" 86 86 "\n" … … 89 89 #endif 90 90 91 char s_file_autoreg_str[] = 91 92 static char s_file_autoreg_str[] = 92 93 "\t.text\n" 93 94 ".LAuto_Register:\n" … … 104 105 #else 105 106 "\t.section .ctors,\"aw\"\n" 106 "\t .long\t.LAuto_Register\n\n"107 "\t"DIRECTIVE_LONG"\t.LAuto_Register\n\n" 107 108 #endif 108 109 ; 109 110 110 char h_file_head_str[] =111 static char h_file_head_str[] = 111 112 "/*\n" 112 113 " * This file is generated with wrc version " WRC_FULLVERSION ". Do not edit!\n" … … 123 124 ; 124 125 125 char h_file_tail_str[] =126 static char h_file_tail_str[] = 126 127 "#endif\n" 127 128 "/* <eof> */\n\n" … … 139 140 140 141 static int direntries; /* win32 only: Total number of unique resources */ 141 142 time_t now;143 142 144 143 /* … … 226 225 */ 227 226 #define BYTESPERLINE 8 228 void write_s_res(FILE *fp, res_t *res)227 static void write_s_res(FILE *fp, res_t *res) 229 228 { 230 229 int idx = res->dataidx; … … 236 235 for(i = 0 ; i < lines; i++) 237 236 { 238 fprintf(fp, "\t %s\t", DIRECTIVE_BYTE);237 fprintf(fp, "\t"DIRECTIVE_BYTE"\t"); 239 238 for(j = 0; j < BYTESPERLINE; j++, idx++) 240 239 { 241 fprintf(fp, BYTEFRMT"%s", res->data[idx] & 0xff,240 fprintf(fp, ""BYTEFRMT"%s", res->data[idx] & 0xff, 242 241 j == BYTESPERLINE-1 ? "" : ", "); 243 242 } … … 246 245 if(rest) 247 246 { 248 fprintf(fp, "\t %s\t", DIRECTIVE_BYTE);247 fprintf(fp, "\t"DIRECTIVE_BYTE"\t"); 249 248 for(j = 0; j < rest; j++, idx++) 250 249 { 251 fprintf(fp, BYTEFRMT"%s", res->data[idx] & 0xff,250 fprintf(fp, ""BYTEFRMT"%s", res->data[idx] & 0xff, 252 251 j == rest-1 ? "" : ", "); 253 252 } … … 255 254 } 256 255 } 256 #undef BYTESPERLINE 257 257 258 258 /* … … 266 266 ***************************************************************************** 267 267 */ 268 void write_name_str(FILE *fp, name_id_t *nid)268 static void write_name_str(FILE *fp, name_id_t *nid) 269 269 { 270 270 res_t res; … … 281 281 res.data = (char *)xmalloc(res.size + 1); 282 282 res.data[0] = (char)res.size; 283 res.size++; /* We need to write the len th byte as well */283 res.size++; /* We need to write the length byte as well */ 284 284 strcpy(res.data+1, nid->name.s_name->str.cstr); 285 285 write_s_res(fp, &res); … … 312 312 else if(win32 && nid->name.s_name->type == str_unicode) 313 313 { 314 res.size = wstrlen(nid->name.s_name->str.wstr);314 res.size = strlenW(nid->name.s_name->str.wstr); 315 315 if(res.size > 65534) 316 316 error("Can't write strings larger than 65534 bytes"); … … 320 320 res.data = (char *)xmalloc((res.size + 1) * 2); 321 321 ((short *)res.data)[0] = (short)res.size; 322 wstrcpy((short*)(res.data+2), nid->name.s_name->str.wstr);322 strcpyW((WCHAR *)(res.data+2), nid->name.s_name->str.wstr); 323 323 res.size *= 2; /* Function writes bytes, not shorts... */ 324 324 res.size += 2; /* We need to write the length word as well */ … … 331 331 nid->name.s_name->type); 332 332 } 333 }334 335 /*336 *****************************************************************************337 * Function : compare_name_id338 * Syntax : int compare_name_id(name_id_t *n1, name_id_t *n2)339 * Input :340 * Output :341 * Description :342 * Remarks :343 *****************************************************************************344 */345 int compare_name_id(name_id_t *n1, name_id_t *n2)346 {347 if(n1->type == name_ord && n2->type == name_ord)348 {349 return n1->name.i_name - n2->name.i_name;350 }351 else if(n1->type == name_str && n2->type == name_str)352 {353 if(n1->name.s_name->type == str_char354 && n2->name.s_name->type == str_char)355 {356 return strcasecmp(n1->name.s_name->str.cstr, n2->name.s_name->str.cstr);357 }358 else if(n1->name.s_name->type == str_unicode359 && n2->name.s_name->type == str_unicode)360 {361 return wstricmp(n1->name.s_name->str.wstr, n2->name.s_name->str.wstr);362 }363 else364 {365 internal_error(__FILE__, __LINE__, "Can't yet compare strings of mixed type");366 }367 }368 else if(n1->type == name_ord && n2->type == name_str)369 return 1;370 else if(n1->type == name_str && n2->type == name_ord)371 return -1;372 else373 internal_error(__FILE__, __LINE__, "Comparing name-ids with unknown types (%d, %d)",374 n1->type, n2->type);375 376 return 0; /* Keep the compiler happy */377 333 } 378 334 … … 387 343 ***************************************************************************** 388 344 */ 389 res_count_t *find_counter(name_id_t *type)345 static res_count_t *find_counter(name_id_t *type) 390 346 { 391 347 int i; … … 414 370 #define RCT(v) (*((resource_t **)(v))) 415 371 /* qsort sorting function */ 416 int sort_name_id(const void *e1, const void *e2)372 static int sort_name_id(const void *e1, const void *e2) 417 373 { 418 374 return compare_name_id(RCT(e1)->name, RCT(e2)->name); 419 375 } 420 376 421 int sort_language(const void *e1, const void *e2)377 static int sort_language(const void *e1, const void *e2) 422 378 { 423 379 assert((RCT(e1)->lan) != NULL); … … 429 385 #undef RCT 430 386 #define RCT(v) ((res_count_t *)(v)) 431 int sort_type(const void *e1, const void *e2)387 static int sort_type(const void *e1, const void *e2) 432 388 { 433 389 return compare_name_id(&(RCT(e1)->type), &(RCT(e2)->type)); … … 435 391 #undef RCT 436 392 437 void count_resources(resource_t *top)393 static void count_resources(resource_t *top) 438 394 { 439 395 resource_t *rsc; … … 605 561 ***************************************************************************** 606 562 * Function : write_pe_segment 607 * Syntax : void write_pe_segment(FILE *fp , resource_t *top)563 * Syntax : void write_pe_segment(FILE *fp) 608 564 * Input : 609 565 * Output : … … 612 568 ***************************************************************************** 613 569 */ 614 void write_pe_segment(FILE *fp, resource_t *top)570 static void write_pe_segment(FILE *fp) 615 571 { 616 572 int i; 617 573 618 fprintf(fp, "\t %s\t4\n", DIRECTIVE_ALIGN);574 fprintf(fp, "\t"DIRECTIVE_ALIGN"\t4\n"); 619 575 fprintf(fp, "%s%s:\n", prefix, _PEResTab); 620 fprintf(fp, "\t %s\t%s%s\n", DIRECTIVE_GLOBAL, prefix, _PEResTab);576 fprintf(fp, "\t"DIRECTIVE_GLOBAL"\t%s%s\n", prefix, _PEResTab); 621 577 /* Flags */ 622 fprintf(fp, "\t %s\t0\n", DIRECTIVE_LONG);578 fprintf(fp, "\t"DIRECTIVE_LONG"\t0\n"); 623 579 /* Time/Date stamp */ 624 fprintf(fp, "\t %s\t"LONGFRMT"\n", DIRECTIVE_LONG, (long)now);580 fprintf(fp, "\t"DIRECTIVE_LONG"\t"LONGFRMT"\n", (long)now); 625 581 /* Version */ 626 fprintf(fp, "\t %s\t0\n", DIRECTIVE_LONG); /* FIXME: must version be filled out? */582 fprintf(fp, "\t"DIRECTIVE_LONG"\t0\n"); /* FIXME: must version be filled out? */ 627 583 /* # of id entries, # of name entries */ 628 fprintf(fp, "\t %s\t%d, %d\n", DIRECTIVE_WORD, n_name_entries, n_id_entries);584 fprintf(fp, "\t"DIRECTIVE_SHORT"\t%d, %d\n", n_name_entries, n_id_entries); 629 585 630 586 /* Write the type level of the tree */ … … 638 594 /* TypeId */ 639 595 if(rcp->type.type == name_ord) 640 fprintf(fp, "\t %s\t%d\n", DIRECTIVE_LONG, rcp->type.name.i_name);596 fprintf(fp, "\t"DIRECTIVE_LONG"\t%d\n", rcp->type.name.i_name); 641 597 else 642 598 { 643 599 char *name = prep_nid_for_label(&(rcp->type)); 644 fprintf(fp, "\t %s\t(%s_%s_typename - %s%s) %s %s\n",645 DIRECTIVE_LONG,prefix,600 fprintf(fp, "\t"DIRECTIVE_LONG"\t(%s_%s_typename - %s%s) "OR" "HEXBIT31"\n", 601 prefix, 646 602 name, 647 603 prefix, 648 _PEResTab , OR, HEXBIT31);604 _PEResTab); 649 605 } 650 606 /* Offset */ 651 607 label = prep_nid_for_label(&(rcp->type)); 652 fprintf(fp, "\t %s\t(%sL%s - %s%s) %s %s\n",653 DIRECTIVE_LONG, LOCAL_PREFIX,label,608 fprintf(fp, "\t"DIRECTIVE_LONG"\t("LOCAL_PREFIX"L%s - %s%s) "OR" "HEXBIT31"\n", 609 label, 654 610 prefix, 655 _PEResTab , OR, HEXBIT31);611 _PEResTab); 656 612 } 657 613 … … 668 624 669 625 typelabel = xstrdup(prep_nid_for_label(&(rcp->type))); 670 fprintf(fp, " %sL%s:\n", LOCAL_PREFIX, typelabel);671 672 fprintf(fp, "\t %s\t0\n", DIRECTIVE_LONG); /* Flags */673 fprintf(fp, "\t %s\t"LONGFRMT"\n", DIRECTIVE_LONG, (long)now); /* TimeDate */674 fprintf(fp, "\t %s\t0\n", DIRECTIVE_LONG); /* FIXME: must version be filled out? */675 fprintf(fp, "\t %s\t%d, %d\n", DIRECTIVE_WORD, rcp->n_name_entries, rcp->n_id_entries);626 fprintf(fp, ""LOCAL_PREFIX"L%s:\n", typelabel); 627 628 fprintf(fp, "\t"DIRECTIVE_LONG"\t0\n"); /* Flags */ 629 fprintf(fp, "\t"DIRECTIVE_LONG"\t"LONGFRMT"\n", (long)now); /* TimeDate */ 630 fprintf(fp, "\t"DIRECTIVE_LONG"\t0\n"); /* FIXME: must version be filled out? */ 631 fprintf(fp, "\t"DIRECTIVE_SHORT"\t%d, %d\n", rcp->n_name_entries, rcp->n_id_entries); 676 632 for(j = 0; j < rcp->count32; j++) 677 633 { … … 679 635 /* NameId */ 680 636 if(rsc->name->type == name_ord) 681 fprintf(fp, "\t %s\t%d\n", DIRECTIVE_LONG, rsc->name->name.i_name);637 fprintf(fp, "\t"DIRECTIVE_LONG"\t%d\n", rsc->name->name.i_name); 682 638 else 683 639 { 684 fprintf(fp, "\t %s\t(%s%s_name - %s%s) %s %s\n",685 DIRECTIVE_LONG,prefix,640 fprintf(fp, "\t"DIRECTIVE_LONG"\t(%s%s_name - %s%s) "OR" "HEXBIT31"\n", 641 prefix, 686 642 rsc->c_name, 687 643 prefix, 688 _PEResTab , OR, HEXBIT31);689 } 690 /* Maybe FIXME: Unescape the tree (ommit 0x80000000) and644 _PEResTab); 645 } 646 /* Maybe FIXME: Unescape the tree (ommit "HEXBIT31") and 691 647 * put the offset to the resource data entry. 692 648 * ?? Is unescaping worth while ?? … … 694 650 /* Offset */ 695 651 namelabel = prep_nid_for_label(rsc->name); 696 fprintf(fp, "\t %s\t(%sL%s_%s - %s%s) %s %s\n",697 DIRECTIVE_LONG, LOCAL_PREFIX,typelabel,652 fprintf(fp, "\t"DIRECTIVE_LONG"\t("LOCAL_PREFIX"L%s_%s - %s%s) "OR" "HEXBIT31"\n", 653 typelabel, 698 654 namelabel, 699 655 prefix, 700 _PEResTab , OR, HEXBIT31);656 _PEResTab); 701 657 } 702 658 free(typelabel); … … 721 677 722 678 namelabel = xstrdup(prep_nid_for_label(r32cp->rsc[0]->name)); 723 fprintf(fp, " %sL%s_%s:\n", LOCAL_PREFIX, typelabel, namelabel);724 725 fprintf(fp, "\t %s\t0\n", DIRECTIVE_LONG); /* Flags */726 fprintf(fp, "\t %s\t"LONGFRMT"\n", DIRECTIVE_LONG, (long)now); /* TimeDate */727 fprintf(fp, "\t %s\t0\n", DIRECTIVE_LONG); /* FIXME: must version be filled out? */728 fprintf(fp, "\t %s\t0, %d\n", DIRECTIVE_WORD, r32cp->count);679 fprintf(fp, ""LOCAL_PREFIX"L%s_%s:\n", typelabel, namelabel); 680 681 fprintf(fp, "\t"DIRECTIVE_LONG"\t0\n"); /* Flags */ 682 fprintf(fp, "\t"DIRECTIVE_LONG"\t"LONGFRMT"\n", (long)now); /* TimeDate */ 683 fprintf(fp, "\t"DIRECTIVE_LONG"\t0\n"); /* FIXME: must version be filled out? */ 684 fprintf(fp, "\t"DIRECTIVE_SHORT"\t0, %d\n", r32cp->count); 729 685 730 686 for(k = 0; k < r32cp->count; k++) … … 733 689 assert(rsc->lan != NULL); 734 690 /* LanguageId */ 735 fprintf(fp, "\t %s\t"LONGFRMT"\n", DIRECTIVE_LONG, rsc->lan ? MAKELANGID(rsc->lan->id, rsc->lan->sub) : 0);691 fprintf(fp, "\t"DIRECTIVE_LONG"\t"LONGFRMT"\n", rsc->lan ? MAKELANGID(rsc->lan->id, rsc->lan->sub) : 0); 736 692 /* Offset */ 737 fprintf(fp, "\t %s\t%sL%s_%s_%d - %s%s\n",738 DIRECTIVE_LONG, LOCAL_PREFIX,typelabel,693 fprintf(fp, "\t"DIRECTIVE_LONG"\t"LOCAL_PREFIX"L%s_%s_%d - %s%s\n", 694 typelabel, 739 695 namelabel, 740 696 rsc->lan ? MAKELANGID(rsc->lan->id, rsc->lan->sub) : 0, … … 749 705 /* Write the resource table itself */ 750 706 fprintf(fp, "%s_ResourceDirectory:\n", prefix); 751 fprintf(fp, "\t %s\t%s_ResourceDirectory\n", DIRECTIVE_GLOBAL, prefix);707 fprintf(fp, "\t"DIRECTIVE_GLOBAL"\t%s_ResourceDirectory\n", prefix); 752 708 direntries = 0; 753 709 … … 775 731 assert(rsc->lan != NULL); 776 732 777 fprintf(fp, " %sL%s_%s_%d:\n",778 LOCAL_PREFIX,typelabel,733 fprintf(fp, ""LOCAL_PREFIX"L%s_%s_%d:\n", 734 typelabel, 779 735 namelabel, 780 736 rsc->lan ? MAKELANGID(rsc->lan->id, rsc->lan->sub) : 0); 781 737 782 738 /* Data RVA */ 783 fprintf(fp, "\t %s\t%s%s_data - %s%s\n",784 DIRECTIVE_LONG,prefix,739 fprintf(fp, "\t"DIRECTIVE_LONG"\t%s%s_data - %s%s\n", 740 prefix, 785 741 rsc->c_name, 786 742 prefix, 787 743 _PEResTab); 788 744 /* Size */ 789 fprintf(fp, "\t %s\t%d\n",790 DIRECTIVE_LONG,rsc->binres->size - rsc->binres->dataidx);745 fprintf(fp, "\t"DIRECTIVE_LONG"\t%d\n", 746 rsc->binres->size - rsc->binres->dataidx); 791 747 /* CodePage */ 792 fprintf(fp, "\t %s\t%ld\n", DIRECTIVE_LONG, codepage);748 fprintf(fp, "\t"DIRECTIVE_LONG"\t%ld\n", codepage); 793 749 /* Reserved */ 794 fprintf(fp, "\t %s\t0\n", DIRECTIVE_LONG);750 fprintf(fp, "\t"DIRECTIVE_LONG"\t0\n"); 795 751 796 752 direntries++; … … 805 761 ***************************************************************************** 806 762 * Function : write_ne_segment 807 * Syntax : void write_ne_segment(FILE *fp , resource_t *top)763 * Syntax : void write_ne_segment(FILE *fp) 808 764 * Input : 809 765 * Output : … … 812 768 ***************************************************************************** 813 769 */ 814 void write_ne_segment(FILE *fp, resource_t *top)770 static void write_ne_segment(FILE *fp) 815 771 { 816 772 int i, j; 817 773 818 fprintf(fp, "\t %s\t4\n", DIRECTIVE_ALIGN);774 fprintf(fp, "\t"DIRECTIVE_ALIGN"\t4\n"); 819 775 fprintf(fp, "%s%s:\n", prefix, _NEResTab); 820 fprintf(fp, "\t %s\t%s%s\n", DIRECTIVE_GLOBAL, prefix, _NEResTab);776 fprintf(fp, "\t"DIRECTIVE_GLOBAL"\t%s%s\n", prefix, _NEResTab); 821 777 822 778 /* AlignmentShift */ 823 fprintf(fp, "\t %s\t%d\n", DIRECTIVE_WORD, alignment_pwr);779 fprintf(fp, "\t"DIRECTIVE_SHORT"\t%d\n", alignment_pwr); 824 780 825 781 /* TypeInfo */ … … 830 786 /* TypeId */ 831 787 if(rcp->type.type == name_ord) 832 fprintf(fp, "\t %s\t"SHORTFRMT"\n", DIRECTIVE_WORD, rcp->type.name.i_name | 0x8000);788 fprintf(fp, "\t"DIRECTIVE_SHORT"\t"SHORTFRMT"\n", rcp->type.name.i_name | 0x8000); 833 789 else 834 fprintf(fp, "\t %s\t%s_%s_typename - %s%s\n",835 DIRECTIVE_WORD,prefix,790 fprintf(fp, "\t"DIRECTIVE_SHORT"\t%s_%s_typename - %s%s\n", 791 prefix, 836 792 rcp->type.name.s_name->str.cstr, 837 793 prefix, 838 794 _NEResTab); 839 795 /* ResourceCount */ 840 fprintf(fp, "\t %s\t%d\n", DIRECTIVE_WORD, rcp->count);796 fprintf(fp, "\t"DIRECTIVE_SHORT"\t%d\n", rcp->count); 841 797 /* Reserved */ 842 fprintf(fp, "\t %s\t0\n", DIRECTIVE_LONG);798 fprintf(fp, "\t"DIRECTIVE_LONG"\t0\n"); 843 799 /* NameInfo */ 844 800 for(j = 0; j < rcp->count; j++) … … 853 809 */ 854 810 /* Offset */ 855 fprintf(fp, "\t %s\t(%s%s_data - %s%s) >> %d\n",856 DIRECTIVE_WORD,prefix,811 fprintf(fp, "\t"DIRECTIVE_SHORT"\t(%s%s_data - %s%s) >> %d\n", 812 prefix, 857 813 rcp->rscarray[j]->c_name, 858 814 prefix, … … 860 816 alignment_pwr); 861 817 /* Length */ 862 fprintf(fp, "\t %s\t%d\n",863 DIRECTIVE_WORD, rcp->rscarray[j]->binres->size - rcp->rscarray[j]->binres->dataidx);818 fprintf(fp, "\t"DIRECTIVE_SHORT"\t%d\n", 819 (rcp->rscarray[j]->binres->size - rcp->rscarray[j]->binres->dataidx + alignment - 1) >> alignment_pwr); 864 820 /* Flags */ 865 fprintf(fp, "\t %s\t"SHORTFRMT"\n", DIRECTIVE_WORD, (WORD)rcp->rscarray[j]->memopt);821 fprintf(fp, "\t"DIRECTIVE_SHORT"\t"SHORTFRMT"\n", (WORD)rcp->rscarray[j]->memopt); 866 822 /* Id */ 867 823 if(rcp->rscarray[j]->name->type == name_ord) 868 fprintf(fp, "\t %s\t"SHORTFRMT"\n", DIRECTIVE_WORD, rcp->rscarray[j]->name->name.i_name | 0x8000);824 fprintf(fp, "\t"DIRECTIVE_SHORT"\t"SHORTFRMT"\n", rcp->rscarray[j]->name->name.i_name | 0x8000); 869 825 else 870 fprintf(fp, "\t %s\t%s%s_name - %s%s\n",871 DIRECTIVE_WORD,prefix,826 fprintf(fp, "\t"DIRECTIVE_SHORT"\t%s%s_name - %s%s\n", 827 prefix, 872 828 rcp->rscarray[j]->c_name, 873 829 prefix, 874 830 _NEResTab); 875 831 /* Handle and Usage */ 876 fprintf(fp, "\t %s\t0, 0\n", DIRECTIVE_WORD);832 fprintf(fp, "\t"DIRECTIVE_SHORT"\t0, 0\n"); 877 833 } 878 834 } 879 835 /* EndTypes */ 880 fprintf(fp, "\t %s\t0\n", DIRECTIVE_WORD);836 fprintf(fp, "\t"DIRECTIVE_SHORT"\t0\n"); 881 837 } 882 838 … … 884 840 ***************************************************************************** 885 841 * Function : write_rsc_names 886 * Syntax : void write_rsc_names(FILE *fp , resource_t *top)842 * Syntax : void write_rsc_names(FILE *fp) 887 843 * Input : 888 844 * Output : … … 891 847 ***************************************************************************** 892 848 */ 893 void write_rsc_names(FILE *fp, resource_t *top)849 static void write_rsc_names(FILE *fp) 894 850 { 895 851 int i, j; … … 935 891 res_count_t *rcp = &rcarray[i]; 936 892 893 if(rcp->type.type == name_str) 894 { 895 fprintf(fp, "%s_%s_typename:\n", 896 prefix, 897 rcp->type.name.s_name->str.cstr); 898 write_name_str(fp, &(rcp->type)); 899 } 937 900 for(j = 0; j < rcp->count; j++) 938 901 { 939 if(rcp->type.type == name_str)940 {941 fprintf(fp, "%s_%s_typename:\n",942 prefix,943 rcp->type.name.s_name->str.cstr);944 write_name_str(fp, &(rcp->type));945 }946 902 if(rcp->rscarray[j]->name->type == name_str) 947 903 { … … 957 913 /* This is to end the NE resource table */ 958 914 if(create_dir) 959 fprintf(fp, "\t %s\t0\n", DIRECTIVE_BYTE);915 fprintf(fp, "\t"DIRECTIVE_BYTE"\t0\n"); 960 916 } 961 917 … … 989 945 { 990 946 char *s, *p; 991 now = time(NULL);992 947 s = ctime(&now); 993 948 p = strchr(s, '\n'); … … 1004 959 { 1005 960 if(win32) 1006 write_pe_segment(fo , top);961 write_pe_segment(fo); 1007 962 else 1008 write_ne_segment(fo , top);963 write_ne_segment(fo); 1009 964 } 1010 965 1011 966 /* Dump the names */ 1012 write_rsc_names(fo , top);967 write_rsc_names(fo); 1013 968 1014 969 if(create_dir) 1015 fprintf(fo, "%sLResTabEnd:\n", LOCAL_PREFIX);970 fprintf(fo, LOCAL_PREFIX"LResTabEnd:\n"); 1016 971 1017 972 if(!indirect_only) … … 1019 974 /* Write the resource data */ 1020 975 #ifdef MASM 1021 fprintf(fo, "\n; /*Resource binary data */\n\n");976 fprintf(fo, "\n; Resource binary data */\n\n"); 1022 977 #else 1023 978 fprintf(fo, "\n/* Resource binary data */\n\n"); … … 1028 983 continue; 1029 984 1030 fprintf(fo, "\t %s\t%d\n", DIRECTIVE_ALIGN, win32 ? 4 : alignment);985 fprintf(fo, "\t"DIRECTIVE_ALIGN"\t%d\n", win32 ? 4 : alignment); 1031 986 fprintf(fo, "%s%s_data:\n", prefix, rsc->c_name); 1032 987 if(global) 1033 fprintf(fo, "\t %s\t%s%s_data\n", DIRECTIVE_GLOBAL, prefix, rsc->c_name);988 fprintf(fo, "\t"DIRECTIVE_GLOBAL"\t%s%s_data\n", prefix, rsc->c_name); 1034 989 1035 990 write_s_res(fo, rsc->binres); … … 1041 996 { 1042 997 /* Add a resource descriptor for built-in and elf-dlls */ 1043 fprintf(fo, "\t %s\t4\n", DIRECTIVE_ALIGN);998 fprintf(fo, "\t"DIRECTIVE_ALIGN"\t4\n"); 1044 999 fprintf(fo, "%s_ResourceDescriptor:\n", prefix); 1045 fprintf(fo, "\t %s\t%s_ResourceDescriptor\n", DIRECTIVE_GLOBAL, prefix);1000 fprintf(fo, "\t"DIRECTIVE_GLOBAL"\t%s_ResourceDescriptor\n", prefix); 1046 1001 fprintf(fo, "%s_ResourceTable:\n", prefix); 1047 1002 if(global) 1048 fprintf(fo, "\t %s\t%s_ResourceTable\n", DIRECTIVE_GLOBAL, prefix);1049 fprintf(fo, "\t %s\t%s%s\n", DIRECTIVE_LONG, prefix, win32 ? _PEResTab : _NEResTab);1003 fprintf(fo, "\t"DIRECTIVE_GLOBAL"\t%s_ResourceTable\n", prefix); 1004 fprintf(fo, "\t"DIRECTIVE_LONG"\t%s%s\n", prefix, win32 ? _PEResTab : _NEResTab); 1050 1005 fprintf(fo, "%s_NumberOfResources:\n", prefix); 1051 1006 if(global) 1052 fprintf(fo, "\t %s\t%s_NumberOfResources\n", DIRECTIVE_GLOBAL, prefix);1053 fprintf(fo, "\t %s\t%d\n", DIRECTIVE_LONG, direntries);1007 fprintf(fo, "\t"DIRECTIVE_GLOBAL"\t%s_NumberOfResources\n", prefix); 1008 fprintf(fo, "\t"DIRECTIVE_LONG"\t%d\n", direntries); 1054 1009 fprintf(fo, "%s_ResourceSectionSize:\n", prefix); 1055 1010 if(global) 1056 fprintf(fo, "\t %s\t%s_ResourceSectionSize\n", DIRECTIVE_GLOBAL, prefix);1057 fprintf(fo, "\t %s\t%sLResTabEnd - %s%s\n", DIRECTIVE_LONG, LOCAL_PREFIX, prefix, win32 ? _PEResTab : _NEResTab);1011 fprintf(fo, "\t"DIRECTIVE_GLOBAL"\t%s_ResourceSectionSize\n", prefix); 1012 fprintf(fo, "\t"DIRECTIVE_LONG"\t"LOCAL_PREFIX"LResTabEnd - %s%s\n", prefix, win32 ? _PEResTab : _NEResTab); 1058 1013 if(win32) 1059 1014 { 1060 1015 fprintf(fo, "%s_ResourcesEntries:\n", prefix); 1061 1016 if(global) 1062 fprintf(fo, "\t %s\t%s_ResourcesEntries\n", DIRECTIVE_GLOBAL, prefix);1063 fprintf(fo, "\t %s\t%s_ResourceDirectory\n", DIRECTIVE_LONG, prefix);1017 fprintf(fo, "\t"DIRECTIVE_GLOBAL"\t%s_ResourcesEntries\n", prefix); 1018 fprintf(fo, "\t"DIRECTIVE_LONG"\t%s_ResourceDirectory\n", prefix); 1064 1019 } 1065 1020 } … … 1070 1025 /* Write the indirection structures */ 1071 1026 fprintf(fo, "\n/* Resource indirection structures */\n\n"); 1072 fprintf(fo, "\t %s\t4\n", DIRECTIVE_ALIGN);1027 fprintf(fo, "\t"DIRECTIVE_ALIGN"\t4\n"); 1073 1028 for(rsc = top; rsc; rsc = rsc->next) 1074 1029 { … … 1112 1067 fprintf(fo, "%s%s:\n", prefix, rsc->c_name); 1113 1068 if(global) 1114 fprintf(fo, "\t%s\t%s%s\n", DIRECTIVE_GLOBAL, prefix, rsc->c_name); 1115 fprintf(fo, "\t%s\t%d, %s%s%s, %d, %s%s%s%s, %s%s_data, %d\n", 1116 DIRECTIVE_LONG, 1069 fprintf(fo, "\t"DIRECTIVE_GLOBAL"\t%s%s\n", prefix, rsc->c_name); 1070 fprintf(fo, "\t"DIRECTIVE_LONG"\t%d, %s%s%s, %d, %s%s%s%s, %s%s_data, %d\n", 1117 1071 rsc->name->type == name_ord ? rsc->name->name.i_name : 0, 1118 1072 rsc->name->type == name_ord ? "0" : prefix, … … 1133 1087 /* Write the indirection table */ 1134 1088 fprintf(fo, "/* Resource indirection table */\n\n"); 1135 fprintf(fo, "\t %s\t4\n", DIRECTIVE_ALIGN);1089 fprintf(fo, "\t"DIRECTIVE_ALIGN"\t4\n"); 1136 1090 fprintf(fo, "%s%s:\n", prefix, _ResTable); 1137 fprintf(fo, "\t %s\t%s%s\n", DIRECTIVE_GLOBAL, prefix, _ResTable);1091 fprintf(fo, "\t"DIRECTIVE_GLOBAL"\t%s%s\n", prefix, _ResTable); 1138 1092 for(rsc = top; rsc; rsc = rsc->next) 1139 1093 { 1140 fprintf(fo, "\t %s\t%s%s\n", DIRECTIVE_LONG, prefix, rsc->c_name);1141 } 1142 fprintf(fo, "\t %s\t0\n", DIRECTIVE_LONG);1094 fprintf(fo, "\t"DIRECTIVE_LONG"\t%s%s\n", prefix, rsc->c_name); 1095 } 1096 fprintf(fo, "\t"DIRECTIVE_LONG"\t0\n"); 1143 1097 fprintf(fo, "\n"); 1144 1098 } … … 1181 1135 } 1182 1136 1183 time(&now);1184 1137 fprintf(fo, h_file_head_str, input_name ? input_name : "stdin", 1185 1138 cmdline, ctime(&now), (long)now, (long)now); … … 1236 1189 } 1237 1190 1238
Note:
See TracChangeset
for help on using the changeset viewer.