Ignore:
Timestamp:
Apr 16, 2001, 7:12:53 PM (24 years ago)
Author:
sandervl
Message:

updates

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tools/wrc/writeres.c

    r3426 r5523  
    1212#include <string.h>
    1313#include <assert.h>
    14 #include <time.h>
    15 
     14
     15#include "wine/unicode.h"
    1616#include "wrc.h"
    1717#include "writeres.h"
     
    2626#endif
    2727
    28 #define MASM 1
    2928#ifdef MASM
    3029    #define DIRECTIVE_BYTE  "db"
    31     #define DIRECTIVE_WORD "dw"
     30    #define DIRECTIVE_SHORT "dw"
    3231    #define DIRECTIVE_LONG  "dd"
    3332    #define DIRECTIVE_ALIGN "align"
     
    4039    #define COMMENT_LINE    ";"
    4140    #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
     42static 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"
    4747        "\n"
    4848        "\t.386p\n"
     
    5252        ;
    5353
    54 char s_file_tail_str[] =
     54static char s_file_tail_str[] =
    5555        "\tend\n"
    56         ";/* <eof> */\n"
     56        "; <eof> */\n"
    5757        "\n"
    5858        ;
     
    6060#else
    6161    #define DIRECTIVE_BYTE  ".byte"
    62     #define DIRECTIVE_WORD  ".word"
     62    #define DIRECTIVE_SHORT ".short"
    6363    #define DIRECTIVE_LONG  ".long"
    6464    #define DIRECTIVE_ALIGN ".align"
     
    7272    #define OR              "|"
    7373
    74 char s_file_head_str[] =
     74static char s_file_head_str[] =
    7575        "/* This file is generated with wrc version " WRC_FULLVERSION ". Do not edit! */\n"
    7676        "/* Source : %s */\n"
     
    8282        ;
    8383
    84 char s_file_tail_str[] =
     84static char s_file_tail_str[] =
    8585        "/* <eof> */\n"
    8686        "\n"
     
    8989#endif
    9090
    91 char s_file_autoreg_str[] =
     91
     92static char s_file_autoreg_str[] =
    9293        "\t.text\n"
    9394        ".LAuto_Register:\n"
     
    104105#else
    105106        "\t.section .ctors,\"aw\"\n"
    106         "\t.long\t.LAuto_Register\n\n"
     107        "\t"DIRECTIVE_LONG"\t.LAuto_Register\n\n"
    107108#endif
    108109        ;
    109110
    110 char h_file_head_str[] =
     111static char h_file_head_str[] =
    111112        "/*\n"
    112113        " * This file is generated with wrc version " WRC_FULLVERSION ". Do not edit!\n"
     
    123124        ;
    124125
    125 char h_file_tail_str[] =
     126static char h_file_tail_str[] =
    126127        "#endif\n"
    127128        "/* <eof> */\n\n"
     
    139140
    140141static int direntries;          /* win32 only: Total number of unique resources */
    141 
    142 time_t now;
    143142
    144143/*
     
    226225*/
    227226#define BYTESPERLINE    8
    228 void write_s_res(FILE *fp, res_t *res)
     227static void write_s_res(FILE *fp, res_t *res)
    229228{
    230229        int idx = res->dataidx;
     
    236235        for(i = 0 ; i < lines; i++)
    237236        {
    238                 fprintf(fp, "\t%s\t", DIRECTIVE_BYTE);
     237                fprintf(fp, "\t"DIRECTIVE_BYTE"\t");
    239238                for(j = 0; j < BYTESPERLINE; j++, idx++)
    240239                {
    241                         fprintf(fp, BYTEFRMT"%s", res->data[idx] & 0xff,
     240                        fprintf(fp, ""BYTEFRMT"%s", res->data[idx] & 0xff,
    242241                                        j == BYTESPERLINE-1 ? "" : ", ");
    243242                }
     
    246245        if(rest)
    247246        {
    248                 fprintf(fp, "\t%s\t", DIRECTIVE_BYTE);
     247                fprintf(fp, "\t"DIRECTIVE_BYTE"\t");
    249248                for(j = 0; j < rest; j++, idx++)
    250249                {
    251                         fprintf(fp, BYTEFRMT"%s", res->data[idx] & 0xff,
     250                        fprintf(fp, ""BYTEFRMT"%s", res->data[idx] & 0xff,
    252251                                        j == rest-1 ? "" : ", ");
    253252                }
     
    255254        }
    256255}
     256#undef BYTESPERLINE
    257257
    258258/*
     
    266266 *****************************************************************************
    267267*/
    268 void write_name_str(FILE *fp, name_id_t *nid)
     268static void write_name_str(FILE *fp, name_id_t *nid)
    269269{
    270270        res_t res;
     
    281281                res.data = (char *)xmalloc(res.size + 1);
    282282                res.data[0] = (char)res.size;
    283                 res.size++;     /* We need to write the lenth byte as well */
     283                res.size++;     /* We need to write the length byte as well */
    284284                strcpy(res.data+1, nid->name.s_name->str.cstr);
    285285                write_s_res(fp, &res);
     
    312312        else  if(win32 && nid->name.s_name->type == str_unicode)
    313313        {
    314                 res.size = wstrlen(nid->name.s_name->str.wstr);
     314                res.size = strlenW(nid->name.s_name->str.wstr);
    315315                if(res.size > 65534)
    316316                        error("Can't write strings larger than 65534 bytes");
     
    320320                res.data = (char *)xmalloc((res.size + 1) * 2);
    321321                ((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);
    323323                res.size *= 2; /* Function writes bytes, not shorts... */
    324324                res.size += 2; /* We need to write the length word as well */
     
    331331                                nid->name.s_name->type);
    332332        }
    333 }
    334 
    335 /*
    336  *****************************************************************************
    337  * Function     : compare_name_id
    338  * 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_char
    354                 && 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_unicode
    359                 && 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                 else
    364                 {
    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         else
    373                 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 */
    377333}
    378334
     
    387343 *****************************************************************************
    388344*/
    389 res_count_t *find_counter(name_id_t *type)
     345static res_count_t *find_counter(name_id_t *type)
    390346{
    391347        int i;
     
    414370#define RCT(v)  (*((resource_t **)(v)))
    415371/* qsort sorting function */
    416 int sort_name_id(const void *e1, const void *e2)
     372static int sort_name_id(const void *e1, const void *e2)
    417373{
    418374        return compare_name_id(RCT(e1)->name, RCT(e2)->name);
    419375}
    420376
    421 int sort_language(const void *e1, const void *e2)
     377static int sort_language(const void *e1, const void *e2)
    422378{
    423379        assert((RCT(e1)->lan) != NULL);
     
    429385#undef RCT
    430386#define RCT(v)  ((res_count_t *)(v))
    431 int sort_type(const void *e1, const void *e2)
     387static int sort_type(const void *e1, const void *e2)
    432388{
    433389        return compare_name_id(&(RCT(e1)->type), &(RCT(e2)->type));
     
    435391#undef RCT
    436392
    437 void count_resources(resource_t *top)
     393static void count_resources(resource_t *top)
    438394{
    439395        resource_t *rsc;
     
    605561 *****************************************************************************
    606562 * Function     : write_pe_segment
    607  * Syntax       : void write_pe_segment(FILE *fp, resource_t *top)
     563 * Syntax       : void write_pe_segment(FILE *fp)
    608564 * Input        :
    609565 * Output       :
     
    612568 *****************************************************************************
    613569*/
    614 void write_pe_segment(FILE *fp, resource_t *top)
     570static void write_pe_segment(FILE *fp)
    615571{
    616572        int i;
    617573
    618         fprintf(fp, "\t%s\t4\n", DIRECTIVE_ALIGN);
     574        fprintf(fp, "\t"DIRECTIVE_ALIGN"\t4\n");
    619575        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);
    621577        /* Flags */
    622         fprintf(fp, "\t%s\t0\n", DIRECTIVE_LONG);
     578        fprintf(fp, "\t"DIRECTIVE_LONG"\t0\n");
    623579        /* 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);
    625581        /* 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? */
    627583        /* # 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);
    629585
    630586        /* Write the type level of the tree */
     
    638594                /* TypeId */
    639595                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);
    641597                else
    642598                {
    643599                        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,
    646602                                name,
    647603                                prefix,
    648                                 _PEResTab, OR, HEXBIT31);
     604                                _PEResTab);
    649605                }
    650606                /* Offset */
    651607                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,
    654610                        prefix,
    655                         _PEResTab, OR, HEXBIT31);
     611                        _PEResTab);
    656612        }
    657613
     
    668624
    669625                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);
    676632                for(j = 0; j < rcp->count32; j++)
    677633                {
     
    679635                        /* NameId */
    680636                        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);
    682638                        else
    683639                        {
    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,
    686642                                        rsc->c_name,
    687643                                        prefix,
    688                                         _PEResTab, OR, HEXBIT31);
    689                         }
    690                         /* Maybe FIXME: Unescape the tree (ommit 0x80000000) and
     644                                        _PEResTab);
     645                        }
     646                        /* Maybe FIXME: Unescape the tree (ommit "HEXBIT31") and
    691647                         * put the offset to the resource data entry.
    692648                         * ?? Is unescaping worth while ??
     
    694650                        /* Offset */
    695651                        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,
    698654                                namelabel,
    699655                                prefix,
    700                                 _PEResTab, OR, HEXBIT31);
     656                                _PEResTab);
    701657                }
    702658                free(typelabel);
     
    721677
    722678                        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);
    729685
    730686                        for(k = 0; k < r32cp->count; k++)
     
    733689                                assert(rsc->lan != NULL);
    734690                                /* 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);
    736692                                /* 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,
    739695                                        namelabel,
    740696                                        rsc->lan ? MAKELANGID(rsc->lan->id, rsc->lan->sub) : 0,
     
    749705        /* Write the resource table itself */
    750706        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);
    752708        direntries = 0;
    753709
     
    775731                                assert(rsc->lan != NULL);
    776732
    777                                 fprintf(fp, "%sL%s_%s_%d:\n",
    778                                         LOCAL_PREFIX, typelabel,
     733                                fprintf(fp, ""LOCAL_PREFIX"L%s_%s_%d:\n",
     734                                        typelabel,
    779735                                        namelabel,
    780736                                        rsc->lan ? MAKELANGID(rsc->lan->id, rsc->lan->sub) : 0);
    781737
    782738                                /* 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,
    785741                                        rsc->c_name,
    786742                                        prefix,
    787743                                        _PEResTab);
    788744                                /* 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);
    791747                                /* CodePage */
    792                                 fprintf(fp, "\t%s\t%ld\n", DIRECTIVE_LONG, codepage);
     748                                fprintf(fp, "\t"DIRECTIVE_LONG"\t%ld\n", codepage);
    793749                                /* Reserved */
    794                                 fprintf(fp, "\t%s\t0\n", DIRECTIVE_LONG);
     750                                fprintf(fp, "\t"DIRECTIVE_LONG"\t0\n");
    795751
    796752                                direntries++;
     
    805761 *****************************************************************************
    806762 * Function     : write_ne_segment
    807  * Syntax       : void write_ne_segment(FILE *fp, resource_t *top)
     763 * Syntax       : void write_ne_segment(FILE *fp)
    808764 * Input        :
    809765 * Output       :
     
    812768 *****************************************************************************
    813769*/
    814 void write_ne_segment(FILE *fp, resource_t *top)
     770static void write_ne_segment(FILE *fp)
    815771{
    816772        int i, j;
    817773
    818         fprintf(fp, "\t%s\t4\n", DIRECTIVE_ALIGN);
     774        fprintf(fp, "\t"DIRECTIVE_ALIGN"\t4\n");
    819775        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);
    821777
    822778        /* AlignmentShift */
    823         fprintf(fp, "\t%s\t%d\n", DIRECTIVE_WORD, alignment_pwr);
     779        fprintf(fp, "\t"DIRECTIVE_SHORT"\t%d\n", alignment_pwr);
    824780
    825781        /* TypeInfo */
     
    830786                /* TypeId */
    831787                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);
    833789                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,
    836792                                rcp->type.name.s_name->str.cstr,
    837793                                prefix,
    838794                                _NEResTab);
    839795                /* ResourceCount */
    840                 fprintf(fp, "\t%s\t%d\n", DIRECTIVE_WORD, rcp->count);
     796                fprintf(fp, "\t"DIRECTIVE_SHORT"\t%d\n", rcp->count);
    841797                /* Reserved */
    842                 fprintf(fp, "\t%s\t0\n", DIRECTIVE_LONG);
     798                fprintf(fp, "\t"DIRECTIVE_LONG"\t0\n");
    843799                /* NameInfo */
    844800                for(j = 0; j < rcp->count; j++)
     
    853809 */
    854810                        /* 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,
    857813                                rcp->rscarray[j]->c_name,
    858814                                prefix,
     
    860816                                alignment_pwr);
    861817                        /* 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);
    864820                        /* 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);
    866822                        /* Id */
    867823                        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);
    869825                        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,
    872828                                rcp->rscarray[j]->c_name,
    873829                                prefix,
    874830                                _NEResTab);
    875831                        /* Handle and Usage */
    876                         fprintf(fp, "\t%s\t0, 0\n", DIRECTIVE_WORD);
     832                        fprintf(fp, "\t"DIRECTIVE_SHORT"\t0, 0\n");
    877833                }
    878834        }
    879835        /* EndTypes */
    880         fprintf(fp, "\t%s\t0\n", DIRECTIVE_WORD);
     836        fprintf(fp, "\t"DIRECTIVE_SHORT"\t0\n");
    881837}
    882838
     
    884840 *****************************************************************************
    885841 * Function     : write_rsc_names
    886  * Syntax       : void write_rsc_names(FILE *fp, resource_t *top)
     842 * Syntax       : void write_rsc_names(FILE *fp)
    887843 * Input        :
    888844 * Output       :
     
    891847 *****************************************************************************
    892848*/
    893 void write_rsc_names(FILE *fp, resource_t *top)
     849static void write_rsc_names(FILE *fp)
    894850{
    895851        int i, j;
     
    935891                        res_count_t *rcp = &rcarray[i];
    936892
     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                        }
    937900                        for(j = 0; j < rcp->count; j++)
    938901                        {
    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                                 }
    946902                                if(rcp->rscarray[j]->name->type == name_str)
    947903                                {
     
    957913                /* This is to end the NE resource table */
    958914                if(create_dir)
    959                         fprintf(fp, "\t%s\t0\n", DIRECTIVE_BYTE);
     915                        fprintf(fp, "\t"DIRECTIVE_BYTE"\t0\n");
    960916        }
    961917
     
    989945        {
    990946                char *s, *p;
    991                 now = time(NULL);
    992947                s = ctime(&now);
    993948                p = strchr(s, '\n');
     
    1004959        {
    1005960                if(win32)
    1006                         write_pe_segment(fo, top);
     961                        write_pe_segment(fo);
    1007962                else
    1008                         write_ne_segment(fo, top);
     963                        write_ne_segment(fo);
    1009964        }
    1010965
    1011966        /* Dump the names */
    1012         write_rsc_names(fo, top);
     967        write_rsc_names(fo);
    1013968
    1014969        if(create_dir)
    1015                 fprintf(fo, "%sLResTabEnd:\n", LOCAL_PREFIX);
     970                fprintf(fo, LOCAL_PREFIX"LResTabEnd:\n");
    1016971       
    1017972        if(!indirect_only)
     
    1019974                /* Write the resource data */
    1020975#ifdef MASM
    1021                 fprintf(fo, "\n;/* Resource binary data */\n\n");
     976                fprintf(fo, "\n; Resource binary data */\n\n");
    1022977#else
    1023978                fprintf(fo, "\n/* Resource binary data */\n\n");
     
    1028983                                continue;
    1029984
    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);
    1031986                        fprintf(fo, "%s%s_data:\n", prefix, rsc->c_name);
    1032987                        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);
    1034989
    1035990                        write_s_res(fo, rsc->binres);
     
    1041996                {
    1042997                        /* 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");
    1044999                        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);
    10461001                        fprintf(fo, "%s_ResourceTable:\n", prefix);
    10471002                        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);
    10501005                        fprintf(fo, "%s_NumberOfResources:\n", prefix);
    10511006                        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);
    10541009                        fprintf(fo, "%s_ResourceSectionSize:\n", prefix);
    10551010                        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);
    10581013                        if(win32)
    10591014                        {
    10601015                                fprintf(fo, "%s_ResourcesEntries:\n", prefix);
    10611016                                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);
    10641019                        }
    10651020                }
     
    10701025                /* Write the indirection structures */
    10711026                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");
    10731028                for(rsc = top; rsc; rsc = rsc->next)
    10741029                {
     
    11121067                        fprintf(fo, "%s%s:\n", prefix, rsc->c_name);
    11131068                        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",
    11171071                                rsc->name->type == name_ord ? rsc->name->name.i_name : 0,
    11181072                                rsc->name->type == name_ord ? "0" : prefix,
     
    11331087                /* Write the indirection table */
    11341088                fprintf(fo, "/* Resource indirection table */\n\n");
    1135                 fprintf(fo, "\t%s\t4\n", DIRECTIVE_ALIGN);
     1089                fprintf(fo, "\t"DIRECTIVE_ALIGN"\t4\n");
    11361090                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);
    11381092                for(rsc = top; rsc; rsc = rsc->next)
    11391093                {
    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");
    11431097                fprintf(fo, "\n");
    11441098        }
     
    11811135        }
    11821136
    1183         time(&now);
    11841137        fprintf(fo, h_file_head_str, input_name ? input_name : "stdin",
    11851138                cmdline, ctime(&now), (long)now, (long)now);
     
    12361189}
    12371190
    1238 
Note: See TracChangeset for help on using the changeset viewer.