Esempio n. 1
0
void SemWriteMenu( WResID *name, ResMemFlags flags, FullMenu *menu,
                   uint_16 tokentype )
/********************************************************************/
{
    MenuHeader      head;
    ResLocation     loc;
    int             error = 0;
    int             err_code;
    uint_8          headerdata[ RES_HEADER_SIZE ];


    if(!ErrorHasOccured) {
        if( tokentype == Y_MENU ) {
            head.Version = 0;    /* currently these fields are both 0 */
            head.HeaderSize = 0;
            loc.start = SemStartResource();
            error = ResWriteMenuHeader( &head, CurrResFile.handle );
        } else if( tokentype == Y_MENU_EX ) {
            head.Version = RES_HEADER_VERSION;
            head.HeaderSize = RES_HEADER_SIZE;
            memset( headerdata, 0, head.HeaderSize );
            ResPadDWord( CurrResFile.handle );
            loc.start = SemStartResource();
            error = ResWriteMenuExHeader( &head, CurrResFile.handle, headerdata );
        } else {
            loc.start = 0;      // Is this valid?
        }
        if(error) {
            err_code = LastWresErr();
            goto OutputWriteError;
        }
        error = SemWriteSubMenu( menu, &err_code, tokentype );
        if( !error && CmdLineParms.MSResFormat &&
                      CmdLineParms.TargetOS == RC_TARGET_OS_WIN32 ) {
            error = ResPadDWord( CurrResFile.handle );
        }
        if(error) goto OutputWriteError;
        loc.len = SemEndResource( loc.start );
        SemAddResourceFree( name, WResIDFromNum( RT_MENU ), flags, loc );
    } else {
        RcMemFree( name );
    }

    SemFreeSubMenu( menu );
    return;


OutputWriteError:
    RcError( ERR_WRITTING_RES_FILE, CurrResFile.filename,
             strerror( err_code ) );
    ErrorHasOccured = TRUE;
    SemFreeSubMenu( menu );
    return;
}
Esempio n. 2
0
bool ResReadMenuExItem( MenuExItem *curritem, WResFileID handle )
/***************************************************************/
{
    bool               error;
    uint_32            type, state, id, helpId;
    uint_16            resInfo;

    state = 0;
    id = 0;
    resInfo = 0;

    // Store first structure members in temporary variables until
    // we know whether or not the item is a MenuExItemNormal or a
    // MenuExItemPopup

    error = ResReadUint32( &type, handle );
    if( !error ) {
        error = ResReadUint32( &state, handle );
    }
    if( !error ) {
        error = ResReadUint32( &id, handle );
    }
    if( !error ) {
        error = ResReadUint16( &resInfo, handle );
    }

    // Determine if this is a normal menu item or a popup menu item

    if( resInfo & MENUEX_POPUP ) {
        curritem->IsPopup = true;
        curritem->Item.ExPopup.Popup.ItemFlags = resInfo;
        curritem->Item.ExPopup.ExData.ItemId = id;
        curritem->Item.ExPopup.ExData.ItemType = type;
        curritem->Item.ExPopup.ExData.ItemState = state;
        curritem->Item.ExPopup.Popup.ItemText = ResRead32String( handle, NULL );

        // Careful! The string is DWORD aligned.
        ResPadDWord( handle );
        error = ResReadUint32( &helpId, handle );
        curritem->Item.ExPopup.ExData.HelpId = helpId;
    } else {
        curritem->IsPopup = false;
        curritem->Item.ExNormal.Normal.ItemFlags = resInfo;
        curritem->Item.ExNormal.Normal.ItemID = id;
        curritem->Item.ExNormal.Normal.ItemText = ResRead32String( handle, NULL );

        // Careful! The string is DWORD aligned.
        ResPadDWord( handle );
        curritem->Item.ExNormal.ExData.ItemType = type;
        curritem->Item.ExNormal.ExData.ItemState = state;
    }

    return( error );
}
Esempio n. 3
0
bool ResWriteMenuExItemNormal( const MenuItemNormal *curritem, const MenuExItemNormal *exdata,
                              bool use_unicode, WResFileID handle )
/*******************************************************************************************/
{
    bool        error;
    uint_16     tmp16;
    uint_32     tmp32;

    if( curritem->ItemFlags & MENUEX_POPUP ) {
        WRES_ERROR( WRS_BAD_PARAMETER );
        error = true;
    } else {
        error = ResWriteUint32( &(exdata->ItemType), handle );
        if( !error ) {
            error = ResWriteUint32( &(exdata->ItemState), handle );
        }
        if( !error ) {
            tmp32 = curritem->ItemID;
            error = ResWriteUint32( &tmp32, handle );
        }
        if( !error ) {
            tmp16 = curritem->ItemFlags;
            error = ResWriteUint16( &tmp16, handle );
        }
        if( !error ) {
            error = ResWriteString( curritem->ItemText, use_unicode, handle );
        }
        if( !error ) {
            error = ResPadDWord( handle );
        }
    }

    return( error );
}
Esempio n. 4
0
static bool SemWriteVerBlock( FullVerBlock * block, WResFileID handle, int *err_code )
/************************************************************************************/
{
    bool        error;
    uint_8      os;

    if( CmdLineParms.TargetOS == RC_TARGET_OS_WIN32 ) {
        os = WRES_OS_WIN32;
    } else {
        os = WRES_OS_WIN16;
    }
    error = ResWriteVerBlockHeader( &block->Head, block->UseUnicode, os, handle );
    *err_code = LastWresErr();
    if( !error && block->Value != NULL ) {
        error = semWriteVerValueList( block->Value, block->UseUnicode, handle, err_code );
        if( !error ) {
            error = ResPadDWord( handle );
            *err_code = LastWresErr();
        }
    }
    if( !error && block->Nest != NULL ) {
        error = SemWriteVerBlockNest( block->Nest, handle, err_code );
    }

    return( error );
}
Esempio n. 5
0
ResLocation SemFlushDataElemList( DataElemList *head, bool call_startend )
/************************************************************************/
{
    DataElemList    *curnode;
    DataElemList    *nextnode;
    ResLocation     resLoc;
    int             i;

    curnode = head;
    nextnode = head;
    resLoc.len = 0;
    if( call_startend ) {
        resLoc.start = SemStartResource();
    } else {
        resLoc.start = 0;
    }
    while( nextnode != NULL ) {
        nextnode = curnode->next;
        for( i = 0; i < curnode->count; i++ ) {
            SemWriteRawDataItem( curnode->data[i] );
        }
        RCFREE( curnode );
        curnode = nextnode;
    }
    if( call_startend ) {
        if( CmdLineParms.MSResFormat
          && CmdLineParms.TargetOS == RC_TARGET_OS_WIN32 ) {
            ResPadDWord( CurrResFile.handle );
        }
        resLoc.len = SemEndResource( resLoc.start );
    }

    return( resLoc );
}
Esempio n. 6
0
int MResWriteResourceHeader( MResResourceHeader *currhead, int handle, char iswin32 )
/***********************************************************************************/
{
    int         error;
    uint_32     headersize;
    uint_16     tmp16;
    uint_32     tmp32;

    if( !iswin32 ) {
        error = ResWriteNameOrOrdinal( currhead->Type, FALSE, handle );
        if (!error) {
            error = ResWriteNameOrOrdinal( currhead->Name, FALSE, handle );
        }
        if (!error) {
            tmp16 = currhead->MemoryFlags;
            error = ResWriteUint16( &tmp16, handle );
        }
        if (!error) {
            tmp32 = currhead->Size;
            error = ResWriteUint32( &tmp32, handle );
        }
    } else {
        tmp32 = currhead->Size;
        error = ResWriteUint32( &tmp32, handle );
        if( !error ) {
            headersize = MResFindHeaderSize( currhead, TRUE );
            error = ResWriteUint32( &headersize, handle  );
        }
        if( !error ) {
            error = ResWriteNameOrOrdinal( currhead->Type, TRUE, handle );
        }
        if( !error ) {
            error = ResWriteNameOrOrdinal( currhead->Name, TRUE, handle );
        }
        if( !error ) {
            error = ResPadDWord( handle );
        }
        if( !error ) {
            tmp32 = currhead->DataVersion;
            error = ResWriteUint32( &tmp32, handle );
        }
        if( !error ) {
            tmp16 = currhead->MemoryFlags;
            error = ResWriteUint16( &tmp16, handle );
        }
        if( !error ) {
            tmp16 = currhead->LanguageId;
            error = ResWriteUint16( &tmp16, handle );
        }
        if( !error ) {
            tmp32 = currhead->Version;
            error = ResWriteUint32( &tmp32, handle );
        }
        if( !error ) {
            tmp32 = currhead->Characteristics;
            error = ResWriteUint32( &tmp32, handle );
        }
    }

    return( error );
} /* MResWriteResourceHeader */
Esempio n. 7
0
void SemWINWriteVerInfo( WResID * name, ResMemFlags flags,
                        VerFixedInfo * info, FullVerBlockNest * nest )
/********************************************************************/
{
    WResLangType    lang;
    VerBlockHeader  root;
    ResLocation     loc;
    int             padding;
    bool            error;
    bool            use_unicode;
    uint_8          os;
    int             err_code;

    if( CmdLineParms.TargetOS == RC_TARGET_OS_WIN32 ) {
        use_unicode = true;
        os = WRES_OS_WIN32;
    } else {
        use_unicode = false;
        os = WRES_OS_WIN16;
    }
    root.Key = "VS_VERSION_INFO";
    root.ValSize = sizeof(VerFixedInfo);
    root.Type = 0;
    padding = RES_PADDING( root.ValSize, sizeof(uint_32) );
    root.Size = ResSizeVerBlockHeader( &root, use_unicode, os )
                    + root.ValSize + padding + CalcNestSize( nest );
    /* pad the start of the resource so that padding within the resource */
    /* is easier */
    error = ResPadDWord( CurrResFile.handle );
    if( error ) {
        err_code = LastWresErr();
        goto OutputWriteError;
    }

    if( !ErrorHasOccured ) {
        loc.start = SemStartResource();

        error = ResWriteVerBlockHeader( &root, use_unicode, os,
                                        CurrResFile.handle);
        if( error ) {
            err_code = LastWresErr();
            goto OutputWriteError;
        }

        error = ResWriteVerFixedInfo( info, CurrResFile.handle );
        if( error ) {
            err_code = LastWresErr();
            goto OutputWriteError;
        }

        if( ResSeek( CurrResFile.handle, padding, SEEK_CUR ) == -1 )  {
            err_code = LastWresErr();
            goto OutputWriteError;
        }

        error = SemWriteVerBlockNest( nest, CurrResFile.handle, &err_code );
        if( error)
            goto OutputWriteError;

        loc.len = SemEndResource( loc.start );

        /* version info resources must be language neutral */

        lang.lang = DEF_LANG;
        lang.sublang = DEF_SUBLANG;
        SemWINSetResourceLanguage( &lang, false );
        SemAddResourceFree( name, WResIDFromNum( RT_VERSIONINFO ), flags, loc );
    } else {
        RCFREE( name );
    }

    RCFREE( info );
    FreeVerBlockNest( nest );

    return;

OutputWriteError:
    RcError( ERR_WRITTING_RES_FILE, CurrResFile.filename,
                strerror( err_code )  );
    ErrorHasOccured = true;
    RCFREE( info );
    FreeVerBlockNest( nest );
    return;
}
Esempio n. 8
0
extern M32ResResourceHeader *M32ResReadResourceHeader( WResFileID handle )
/************************************************************************/
{
    M32ResResourceHeader     *newhead;
    int                       error = FALSE;
    uint_16                   tmp16;
    uint_32                   tmp32;

    newhead = WRESALLOC( sizeof( M32ResResourceHeader ) );
    if( newhead == NULL ) {
        error = TRUE;
        WRES_ERROR( WRS_MALLOC_FAILED );
    }
    newhead->head16 = WRESALLOC( sizeof( MResResourceHeader ) );
    if( newhead->head16 == NULL ) {
        error = TRUE;
        WRES_ERROR( WRS_MALLOC_FAILED );
    }
    if( !error ) {
        error = ResPadDWord( handle );
    }
    if( !error ) {
        error = ResReadUint32( &tmp32, handle );
        newhead->head16->Size = tmp32;
    }
    if( !error ) {
        error = ResReadUint32( &(newhead->HeaderSize), handle );
    }
    if( !error ) {
        newhead->head16->Type = ResRead32NameOrOrdinal( handle );
        error = (newhead->head16->Type == NULL );
    }
    if( !error ) {
        newhead->head16->Name = ResRead32NameOrOrdinal( handle );
        error = (newhead->head16->Name == NULL );
    }
    if( !error ) {
        error = ResPadDWord( handle );
    }
    if( !error ) {
        error = ResReadUint32( &tmp32, handle );
        newhead->head16->DataVersion = tmp32;
    }
    if( !error ) {
        error = ResReadUint16( &tmp16, handle );
        newhead->head16->MemoryFlags = tmp16;
    }
    if( !error ) {
        error = ResReadUint16( &tmp16, handle );
        newhead->head16->LanguageId = tmp16;
    }
    if( !error ) {
        error = ResReadUint32( &tmp32, handle );
        newhead->head16->Version = tmp32;
    }
    if( !error ) {
        error = ResReadUint32( &tmp32, handle );
        newhead->head16->Characteristics = tmp32;
    }
    if( error && newhead != NULL ) {
        WRESFREE( newhead->head16 );
        WRESFREE( newhead );
        newhead = NULL;
    }

    return( newhead );
}