示例#1
0
void SemAddResource2( WResID * name, WResID * type, ResMemFlags flags,
                ResLocation loc, char *filename )
/******************************************************************/
{
    int                 error;
    int                 duplicate;
    char *              namestr;
    WResLangType        *lang;

    if( resourceHasLang ) {
        lang = &resourceLang;
        resourceHasLang = FALSE;
    } else {
        lang = &curLang;
    }
    // Windows 95 is currently unable to load an exe that contains a resource
    // with numeric type or numeric identifier greater than 0x7FFF
    // so we warn the user
    if( CmdLineParms.TargetOS == RC_TARGET_OS_WIN32 ) {
        if( !type->IsName && type->ID.Num > 0x7FFF ) {
            namestr = WResIDToStr( name );
            RcWarning( ERR_TYPE_GT_7FFF, namestr );
            RcMemFree( namestr );
        }
        if( !name->IsName && name->ID.Num > 0x7FFF ) {
            namestr = WResIDToStr( name );
            RcWarning( ERR_NAME_GT_7FFF, namestr );
            RcMemFree( namestr );
        }
    }
    error = WResAddResource( type, name, flags, loc.start, loc.len,
                        CurrResFile.dir, lang, &duplicate );

    if (duplicate) {
        if( filename == NULL ) {
            ReportDupResource( name, type, NULL, NULL, TRUE );
        } else {
            ReportDupResource( name, type, filename, CmdLineParms.InFileName,
                               TRUE );
        }
        /* The resource has already been written but we can't add it to */
        /* directory. This will make the .RES file larger but will otherwise */
        /* not affect it since there will be no references to the resource in */
        /* the directory. */
    } else if (error) {
        RcError( ERR_OUT_OF_MEMORY );
        ErrorHasOccured = TRUE;
    }

    if (!CurrResFile.IsWatcomRes) {
        if (!duplicate) {
            copyMSFormatRes( name, type, flags, loc, lang );
        }
        /* erase the temporary file */
        remove( MSFormatTmpFile );
        UnregisterTmpFile( MSFormatTmpFile );
        MSFormatTmpFile[0] = '\0';
    }
}
示例#2
0
static void CheckAccelFlags( AccelFlags * flags, unsigned long idval )
/********************************************************************/
{
    if( !( *flags & ACCEL_VIRTKEY ) ) {
        if( *flags & ACCEL_SHIFT ) {
            *flags &= ~ACCEL_SHIFT;
            RcWarning( ERR_ACCEL_KEYWORD_IGNORED, "SHIFT", idval );
        }
        if( *flags & ACCEL_CONTROL ) {
            *flags &= ~ACCEL_CONTROL;
            RcWarning( ERR_ACCEL_KEYWORD_IGNORED, "CONTROL", idval );
        }
    }
}
示例#3
0
void SemWriteRawDataItem( RawDataItem item )
/******************************************/
{
    uint_16     num16;
    uint_32     num32;
    bool        error;

    if( item.IsString ) {
        int     len = item.StrLen;

        if( item.WriteNull ) {
            ++len;
        }
        if( ResWriteStringLen( item.Item.String, item.LongItem, CurrResFile.handle, len ) ) {
            RcError( ERR_WRITTING_RES_FILE, CurrResFile.filename, LastWresErrStr() );
            ErrorHasOccured = true;
        }
        if( item.TmpStr ) {
            RCFREE( item.Item.String );
        }
    } else {
        if( !item.LongItem ) {
            if( (int_32)item.Item.Num < 0 ) {
                if( (int_32)item.Item.Num < SHRT_MIN ) {
                    RcWarning( ERR_RAW_DATA_TOO_SMALL, item.Item.Num, SHRT_MIN );
                }
            } else {
                if( item.Item.Num > USHRT_MAX ) {
                    RcWarning( ERR_RAW_DATA_TOO_BIG, item.Item.Num, USHRT_MAX );
                }
            }
        }
        if( !ErrorHasOccured ) {
            if( !item.LongItem ) {
                num16 = item.Item.Num;
                error = ResWriteUint16( &(num16), CurrResFile.handle );
            } else {
                num32 = item.Item.Num;
                error = ResWriteUint32( &(num32), CurrResFile.handle );
            }
            if( error ) {
                RcError( ERR_WRITTING_RES_FILE, CurrResFile.filename, LastWresErrStr() );
                ErrorHasOccured = true;
            }
        }
    }
}
示例#4
0
void SemSetGlobalLanguage( WResLangType *newlang ) {
/*******************************************************************/
    if( CmdLineParms.TargetOS == RC_TARGET_OS_WIN32 ) {
        curLang = *newlang;
    } else {
        RcWarning( ERR_NT_KEYWORD, SemTokenToString( Y_LANGUAGE ) );
    }
}
示例#5
0
void SemSetResourceLanguage( WResLangType *newlang, int from_parser ) {
/**********************************************************************/
    if( CmdLineParms.TargetOS == RC_TARGET_OS_WIN32 ) {
         resourceHasLang = TRUE;
         resourceLang = *newlang;
    } else if( from_parser ) {
        RcWarning( ERR_NT_KEYWORD,  SemTokenToString( Y_LANGUAGE ) );
    }
}
示例#6
0
void SemWINSetResourceLanguage( const WResLangType *newlang, bool from_parser )
/*****************************************************************************/
{
    if( CmdLineParms.TargetOS == RC_TARGET_OS_WIN32 ) {
        resourceHasLang = true;
        resourceLang = *newlang;
    } else if( from_parser ) {
        RcWarning( ERR_NT_KEYWORD,  SemWINTokenToString( Y_LANGUAGE ) );
    }
}
示例#7
0
static void CheckAccelFlags( uint_16 * flags, unsigned long idval )
/********************************************************************/
{
    /* CHAR is the default */
    if( !( *flags & OS2_ACCEL_VIRTUALKEY ) && !( *flags & OS2_ACCEL_CHAR ) )
        *flags |= OS2_ACCEL_CHAR;
#if 0
    if( !( *flags & OS2_ACCEL_VIRTUALKEY ) ) {
        if( *flags & OS2_ACCEL_SHIFT ) {
            *flags &= ~OS2_ACCEL_SHIFT;
            RcWarning( ERR_ACCEL_KEYWORD_IGNORED, "SHIFT", idval );
        }
        if( *flags & OS2_ACCEL_CONTROL ) {
            *flags &= ~OS2_ACCEL_CONTROL;
            RcWarning( ERR_ACCEL_KEYWORD_IGNORED, "CONTROL", idval );
        }
    }
#endif
}
示例#8
0
static void AddDiagOption( DialogBoxHeader *head, FullDialogOptions *opt )
/************************************************************************/
{
    switch( opt->token ) {
    case Y_STYLE:
        head->Style |= opt->Opt.Style;
        break;
    case Y_MENU:
        if( head->MenuName != NULL ) {
            RcMemFree( head->MenuName );
        }
        head->MenuName = opt->Opt.Name;
        break;
    case Y_CLASS:
        if( head->ClassName != NULL ) {
            RcMemFree( head->ClassName );
        }
        head->ClassName = opt->Opt.Name;
        break;
    case Y_FONT:
        head->Style |= DS_SETFONT;
        head->PointSize = opt->Opt.Font.PointSize;
        if( head->FontName != NULL ) {
            RcMemFree( head->FontName );
        }
        head->FontName = opt->Opt.Font.FontName;
        break;
    case Y_CAPTION:
        head->Style |= WS_CAPTION;
        if( head->Caption != NULL ) {
            RcMemFree( head->Caption );
        }
        head->Caption = opt->Opt.Str;
        break;
    case Y_EXSTYLE:
        RcWarning( ERR_NT_KEYWORD, SemTokenToString( opt->token ) );
        break;
    }
} /* AddDiagOptions */
示例#9
0
void SemWINUnsupported( YYTOKENTYPE token )
/*****************************************/
{
    RcWarning( ERR_UNSUPPORTED, SemWINTokenToString( token ) );
}
示例#10
0
static bool copyWINBody( void )
{
    NEExeInfo *         tmp;
    uint_16             sect2mask = 0;
    uint_16             sect2bits = 0;
    uint_16             shift_count;
    long                gangloadstart;
    long                gangloadlen;
    CpSegRc             copy_segs_ret;
    bool                use_gangload = false;

    tmp = &Pass2Info.TmpFile.u.NEInfo;

    switch( CmdLineParms.SegmentSorting ) {
    case SEG_SORT_NONE:     /* all segments in section 2 */
        sect2mask = 0;
        sect2bits = 0;
        use_gangload = false;
        Pass2Info.TmpFile.u.NEInfo.WinHead.align = Pass2Info.OldFile.u.NEInfo.WinHead.align;
        tmp->Res.Dir.ResShiftCount = computeShiftCount();
        break;
    case SEG_SORT_PRELOAD_ONLY:  /* all load on call segments in section 2 */
        sect2mask = SEG_PRELOAD;
        sect2bits = 0;
        use_gangload = true;
        checkShiftCount();
        break;
    case SEG_SORT_MANY:     /* only load on call, discardable, code segments */
                            /* in section 2 */
        sect2mask = SEG_DATA | SEG_PRELOAD | SEG_DISCARD;
        sect2bits = SEG_DISCARD;

        /* set the entry segment to be preload */
        {
            segment_record *    seg;        /* these two are here because a */
            uint_16             entry_seg;  /* 71 character field reference */
                                            /* is hard to read */
            seg = Pass2Info.OldFile.u.NEInfo.Seg.Segments;
            entry_seg = Pass2Info.OldFile.u.NEInfo.WinHead.entrynum;
            seg[entry_seg].info |= SEG_PRELOAD;
        }

        use_gangload = true;
        checkShiftCount();
        break;
    default:
        break;
    }

    /* third arg to Copy???? is false --> copy section one */
    gangloadstart = RCTELL( Pass2Info.TmpFile.Handle );
    gangloadstart += AlignAmount( gangloadstart, tmp->Res.Dir.ResShiftCount );
    copy_segs_ret = CopyWINSegments( sect2mask, sect2bits, false );
    switch( copy_segs_ret ) {
    case CPSEG_SEG_TOO_BIG:
        if( use_gangload ) {
            RcWarning( ERR_NO_GANGLOAD );
            use_gangload = false;
        }
        break;
    case CPSEG_ERROR:
        return( true );
    case CPSEG_OK:
    default:
        break;
    }
    if( ! CmdLineParms.NoResFile ) {
        if( CopyWINResources( sect2mask, sect2bits, false ) != RS_OK ) {
            return( true );
        }
    }
    gangloadlen = RCTELL( Pass2Info.TmpFile.Handle ) - gangloadstart;

    /* third arg to Copy???? is true  --> copy section two */
    copy_segs_ret = CopyWINSegments( sect2mask, sect2bits, true );
    if( copy_segs_ret == CPSEG_ERROR ) {
        return( true );
    }
    if( !CmdLineParms.NoResFile ) {
        if( CopyWINResources( sect2mask, sect2bits, true ) != RS_OK ) {
            return( true );
        }
    }

    if( use_gangload ) {
        shift_count = tmp->WinHead.align;
        tmp->WinHead.gangstart = gangloadstart >> shift_count;
        tmp->WinHead.ganglength = gangloadlen >> shift_count;
        tmp->WinHead.otherflags |= WIN_GANGLOAD_PRESENT;
    } else {
示例#11
0
void SemUnsupported( uint_8 token ) {
/***********************************/

    RcWarning( ERR_UNSUPPORTED, SemTokenToString( token ) );
}
示例#12
0
extern FullDialogBoxControl *SemNewDiagCtrl( uint_8 token,
                                FullDiagCtrlOptions opts )
/********************************************************/
{
    FullDialogBoxControl    *newctrl;
    uint_32                 style_mask; /* for the style of the control */
    uint_32                 style_value;
    uint_32                 defstyle_hi = 0;
    uint_32                 defstyle_lo = 0;
    uint_32                 style_hi;
    uint_32                 style_lo;
    uint_16                 class = 0;
    uint_16                 tmp_mask;
    ControlClass            *cont_class;

    switch( token ) {
    case Y_LTEXT:
        class = CLASS_STATIC;
        defstyle_hi = DEF_LTEXT_HI;
        defstyle_lo = DEF_LTEXT_LO;
        break;
    case Y_RTEXT:
        class = CLASS_STATIC;
        defstyle_hi = DEF_RTEXT_HI;
        defstyle_lo = DEF_RTEXT_LO;
        break;
    case Y_CTEXT:
        class = CLASS_STATIC;
        defstyle_hi = DEF_CTEXT_HI;
        defstyle_lo = DEF_CTEXT_LO;
        break;
    case Y_CHECKBOX:
        class = CLASS_BUTTON;
        defstyle_hi = DEF_CHECKBOX_HI;
        defstyle_lo = DEF_CHECKBOX_LO;
        break;
    case Y_PUSHBUTTON:
        class = CLASS_BUTTON;
        defstyle_hi = DEF_PUSHBUTTON_HI;
        defstyle_lo = DEF_PUSHBUTTON_LO;
        break;
    case Y_LISTBOX:
        class = CLASS_LISTBOX;
        defstyle_hi = DEF_LISTBOX_HI;
        defstyle_lo = DEF_LISTBOX_LO;
        break;
    case Y_GROUPBOX:
        class = CLASS_BUTTON;
        defstyle_hi = DEF_GROUPBOX_HI;
        defstyle_lo = DEF_GROUPBOX_LO;
        break;
    case Y_DEFPUSHBUTTON:
        class = CLASS_BUTTON;
        defstyle_hi = DEF_DEFPUSHBUTTON_HI;
        defstyle_lo = DEF_DEFPUSHBUTTON_LO;
        break;
    case Y_RADIOBUTTON:
        class = CLASS_BUTTON;
        defstyle_hi = DEF_RADIOBUTTON_HI;
        defstyle_lo = DEF_RADIOBUTTON_LO;
        break;
    case Y_EDITTEXT:
        class = CLASS_EDIT;
        defstyle_hi = DEF_EDITTEXT_HI;
        defstyle_lo = DEF_EDITTEXT_LO;
        break;
    case Y_COMBOBOX:
        class = CLASS_COMBOBOX;
        defstyle_hi = DEF_COMBOBOX_HI;
        defstyle_lo = DEF_COMBOBOX_LO;
        break;
    case Y_ICON:
        class = CLASS_STATIC;
        defstyle_hi = DEF_ICON_HI;
        defstyle_lo = DEF_ICON_LO;
        break;
    case Y_SCROLLBAR:
        class = CLASS_SCROLLBAR;
        defstyle_hi = DEF_SCROLLBAR_HI;
        defstyle_lo = DEF_SCROLLBAR_LO;
        break;
    case Y_AUTO3STATE:
        if( CmdLineParms.TargetOS == RC_TARGET_OS_WIN32 ) {
            class = CLASS_BUTTON;
            defstyle_hi = DEF_AUTO3STATE_HI;
            defstyle_lo = DEF_AUTO3STATE_LO;
        } else {
            RcWarning( ERR_NT_KEYWORD, SemTokenToString( token ) );
            return( NULL );
        }
        break;
    case Y_AUTOCHECKBOX:
        if( CmdLineParms.TargetOS == RC_TARGET_OS_WIN32 ) {
            class = CLASS_BUTTON;
            defstyle_hi = DEF_AUTOCHECKBOX_HI;
            defstyle_lo = DEF_AUTOCHECKBOX_LO;
        } else {