Exemplo n.º 1
0
void SemOS2WriteAccelTable( WResID *name, ResMemFlags flags, uint_32 codepage,
                                                FullAccelTableOS2 *acctable )
/****************************************************************************/
{
    ResLocation     loc;
    bool            error;
    int             err_code;

    if( !ErrorHasOccured ) {
        loc.start = SemStartResource();
        error = writeAccelTableEntries( acctable, CurrResFile.fid, codepage );
        if( error ) {
            err_code = LastWresErr();
            goto OutputWriteError;
        }
        loc.len = SemEndResource( loc.start );
        SemAddResourceFree( name, WResIDFromNum( OS2_RT_ACCELTABLE ), flags, loc );
    } else {
        RESFREE( name );
    }

    SemOS2FreeAccelTable( acctable );
    return;

OutputWriteError:
    RcError( ERR_WRITTING_RES_FILE, CurrResFile.filename, strerror( err_code ) );
    ErrorHasOccured = true;
    SemOS2FreeAccelTable( acctable );
    return;
}
Exemplo n.º 2
0
static RcStatus copyBitmap( BitmapFileHeader *head, WResFileID handle,
                            WResID *name, ResMemFlags flags, int *err_code )
/**************************************************************************/
{
    RcStatus            ret;
    char *              buffer;
    ResLocation         loc;
    WResFileOffset      pos;

    buffer = RCALLOC( BITMAP_BUFFER_SIZE );

    loc.start = SemStartResource();

    pos = RCTELL( handle );
    if( pos == -1 ) {
        ret = RS_READ_ERROR;
        *err_code = errno;
    } else {
        ret = CopyData( pos, head->Size - sizeof(BitmapFileHeader),
                          handle, buffer, BITMAP_BUFFER_SIZE, err_code );
    }

    loc.len = SemEndResource( loc.start );
    /* add the bitmap to the RES file directory */
    SemAddResourceFree( name, WResIDFromNum( (long)(pointer_int)RT_BITMAP ), flags, loc );

    RCFREE( buffer );

    return( ret );
} /* copyBitmap */
Exemplo n.º 3
0
void SemOS2WriteHelpSubTable( WResID * name, int numWords,
                                     ResMemFlags flags,
                                     FullHelpSubTableOS2 * helptable )
/********************************************************************/
{
    ResLocation     loc;
    bool            error;
    int             err_code;

    if( !ErrorHasOccured ) {
        loc.start = SemStartResource();
        if( helptable != NULL ) {
            helptable->numWords = numWords;
        }
        error = SemOS2WriteHelpSubTableEntries( helptable, CurrResFile.handle );
        if( error ) {
            err_code = LastWresErr();
            goto OutputWriteError;
        }
        loc.len = SemEndResource( loc.start );
        SemAddResourceFree( name, WResIDFromNum( OS2_RT_HELPSUBTABLE ), flags, loc );
    } else {
        RCFREE( name );
    }

    SemOS2FreeHelpSubTable( helptable );
    return;

OutputWriteError:
    RcError( ERR_WRITTING_RES_FILE, CurrResFile.filename, strerror( err_code ) );
    ErrorHasOccured = true;
    SemOS2FreeHelpSubTable( helptable );
    return;

}
Exemplo n.º 4
0
static bool writeCurDir( FullCurDir *dir, WResID *name, ResMemFlags flags,
                        int *err_code )
/****************************************************************************/
{
    bool                error;
    FullCurDirEntry *   entry;
    ResLocation         loc;

    loc.start = SemStartResource();
    error = ResWriteIconCurDirHeader( &(dir->Header), CurrResFile.handle );

    for( entry = dir->Head; !error && entry != NULL; entry = entry->Next ) {
        error = ResWriteCurDirEntry( &(entry->Entry.Res), CurrResFile.handle );
    }

    if( !error ) {
        loc.len = SemEndResource( loc.start );
#ifdef PREPROC_BUG
        SemAddResourceFree( name, WResIDFromNum( (long)(pointer_int)RT_GROUP_CURSOR ),
                         flags, loc );
#else
        SemAddResourceFree( name, WResIDFromNum( (long)12 ),
                         flags, loc );
#endif
    } else {
        *err_code = LastWresErr();
    }

    return( error );
}
Exemplo 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] );
        }
        RESFREE( curnode );
        curnode = nextnode;
    }
    if( call_startend ) {
        if( CmdLineParms.MSResFormat
          && CmdLineParms.TargetOS == RC_TARGET_OS_WIN32 ) {
            ResWritePadDWord( CurrResFile.fid );
        }
        resLoc.len = SemEndResource( resLoc.start );
    }

    return( resLoc );
}
Exemplo n.º 6
0
static RcStatus copyFont( FontInfo * info, WResFileID handle, WResID * name,
                                ResMemFlags flags, int *err_code )
/************************************************************************/
{
    RcStatus            ret;
    char *              buffer;
    ResLocation         loc;
    long                pos;

    buffer = RCALLOC( FONT_BUFFER_SIZE );

    loc.start = SemStartResource();

    if( ResWriteFontInfo( info, CurrResFile.handle ) ) {
        ret = RS_WRITE_ERROR;
        *err_code = LastWresErr();
    } else {
        pos = RCTELL( handle );
        if( pos == -1 ) {
            ret = RS_READ_ERROR;
            *err_code = errno;
        } else {
            ret = SemCopyDataUntilEOF( pos, handle, buffer,
                                         FONT_BUFFER_SIZE, err_code );
        }
    }

    loc.len = SemEndResource( loc.start );
    /* add the font to the RES file directory */
    SemAddResourceFree( name, WResIDFromNum( (long)RT_FONT ), flags, loc );

    RCFREE( buffer );

    return( ret );
} /* copyFont */
Exemplo n.º 7
0
extern void SemOS2AddDlgincResource( WResID *name, char *filename )
/*****************************************************************/
{
    ResLocation loc;
    int         error, err_code;

    loc.start = SemStartResource();
    error = ResWriteString( filename, FALSE, CurrResFile.handle );
    if( error ) {
        err_code = LastWresErr();
        goto OutputWriteError;
    }
    loc.len = SemEndResource( loc.start );
    SemAddResourceFree( name, WResIDFromNum( OS2_RT_DLGINCLUDE ),
                        MEMFLAG_DISCARDABLE | MEMFLAG_MOVEABLE | MEMFLAG_PURE,
                        loc );
    RcMemFree( filename );
    return;

OutputWriteError:
    RcError( ERR_WRITTING_RES_FILE, CurrResFile.filename,
             strerror( err_code ) );
    ErrorHasOccured = TRUE;
    RcMemFree( filename );
    return;
}
Exemplo n.º 8
0
void SemOS2WriteMenu( WResID *name, ResMemFlags flags, FullMenuOS2 *menu,
                   YYTOKENTYPE tokentype, uint_32 codepage )
/***********************************************************************/
{
    ResLocation     loc;
    int             error;
    int             err_code;

    tokentype = tokentype;

    if( !ErrorHasOccured ) {
        loc.start = SemStartResource();
        error = SemOS2WriteSubMenu( menu, &err_code, codepage );
        if( error ) {
            err_code = LastWresErr();
            goto OutputWriteError;
        }
        loc.len = SemEndResource( loc.start );
        SemAddResourceFree( name, WResIDFromNum( OS2_RT_MENU ), flags, loc );
    } else {
        RCFREE( name );
    }

    SemOS2FreeSubMenu( menu );
    return;

OutputWriteError:
    RcError( ERR_WRITTING_RES_FILE, CurrResFile.filename, strerror( err_code ) );
    ErrorHasOccured = TRUE;
    SemOS2FreeSubMenu( menu );
    return;
}
Exemplo n.º 9
0
extern void SemOS2WriteHelpTable( WResID * name, ResMemFlags flags,
                                   FullHelpTableOS2 * helptable )
/******************************************************************/
{
    ResLocation     loc;
    int             error;
    int             err_code;

    if( !ErrorHasOccured ) {
        loc.start = SemStartResource();
        error = SemOS2WriteHelpTableEntries( helptable, CurrResFile.handle );
        if(error) {
            err_code = LastWresErr();
            goto OutputWriteError;
        }
        loc.len = SemEndResource( loc.start );
        SemAddResourceFree( name, WResIDFromNum( OS2_RT_HELPTABLE ), flags, loc );
    } else {
        RcMemFree( name );
    }

    SemOS2FreeHelpTable( helptable );
    return;

OutputWriteError:
    RcError( ERR_WRITTING_RES_FILE, CurrResFile.filename,
             strerror( err_code ) );
    ErrorHasOccured = TRUE;
    SemOS2FreeHelpTable( helptable );
    return;

}
Exemplo n.º 10
0
ResLocation SemCopyRawFile( const char *filename )
/************************************************/
{
    WResFileID      fid;
    RcStatus        ret;
    char            *buffer;
    char            full_filename[_MAX_PATH];
    ResLocation     loc;
    int             err_code;
    WResFileOffset  pos;

    buffer = RESALLOC( BUFFER_SIZE );

    if( RcFindResource( filename, full_filename ) == -1 ) {
        RcError( ERR_CANT_FIND_FILE, filename );
        goto HANDLE_ERROR;
    }

    if( AddDependency( full_filename ) )
        goto HANDLE_ERROR;

    fid = RcIoOpenInput( full_filename, false );
    if( fid == WRES_NIL_HANDLE ) {
        RcError( ERR_CANT_OPEN_FILE, filename, strerror( errno ) );
        goto HANDLE_ERROR;
    }

    loc.start = SemStartResource();

    pos = RESTELL( fid );
    if( pos == -1 ) {
        RcError( ERR_READING_DATA, full_filename, strerror( errno ) );
        RESCLOSE( fid );
        goto HANDLE_ERROR;
    } else {
        ret = SemCopyDataUntilEOF( pos, fid, buffer, BUFFER_SIZE, &err_code );
        if( ret != RS_OK ) {
            ReportCopyError( ret, ERR_READING_DATA, full_filename, err_code );
            RESCLOSE( fid );
            goto HANDLE_ERROR;
        }
    }

    loc.len = SemEndResource( loc.start );

    RESCLOSE( fid );

    RESFREE( buffer );

    return( loc );


HANDLE_ERROR:
    ErrorHasOccured = true;
    loc.start = 0;
    loc.len = 0;
    RESFREE( buffer );
    return( loc );
}
Exemplo n.º 11
0
/* The OS/2 dialog templates present us with a problem because the
   template items contain a number of offsets that are not known until
   the template is processed; this means we cannot just start spitting
   the data into a file. Instead we build an in-memory image of the
   resource (the size must be < 64K) and then dump the entire resource
   into the file - which certainly shouldn't hurt performance either.
*/
extern void SemOS2WriteDialogTemplate( WResID *name, ResMemFlags flags,
                                       uint_32 codepage,
                                       FullDiagCtrlListOS2 *ctrls )
/*********************************************************************/
{
    ResLocation              loc;
    int                      err_code;
    int                      error;
    int                      size;
    DialogHeaderOS2          *head = NULL;
    char                     *tmpl;
    char                     *ptr;

    size = sizeof( DialogHeaderOS2 ) + SemOS2CalcControlSize( ctrls );
    if( size > 65536 ) {
        // TODO: Error, template is too big
    }

    tmpl = RcMemMalloc( size );

    head = (DialogHeaderOS2 *)tmpl;
    InitOS2DialogBoxHeader( head, codepage );
    head->Size = size;
    ptr = tmpl + sizeof( DialogHeaderOS2 );

    // Create the DLGTITEM array in memory
    ptr = SemOS2BuildTemplateArray( ptr, ctrls );

    // Dump all other data into memory and update the offsets
    SemOS2DumpTemplateData( tmpl, ptr, ctrls );

    // Write the resource to file
    loc.start = SemStartResource();

    error = ResOS2WriteDlgTemplate( tmpl, size, CurrResFile.handle );
    if( error ) {
        err_code = LastWresErr();
        goto OutputWriteError;
    }

    RcMemFree( tmpl );

    loc.len = SemEndResource( loc.start );
    SemAddResourceFree( name, WResIDFromNum( OS2_RT_DIALOG ), flags, loc );

    SemOS2FreeDiagCtrlList( ctrls );

    return;

OutputWriteError:
    RcError( ERR_WRITTING_RES_FILE, CurrResFile.filename,
                strerror( err_code )  );
    ErrorHasOccured = TRUE;
    SemOS2FreeDiagCtrlList( ctrls );
    return;
} /* SemOS2WriteDialogTemplate */
Exemplo n.º 12
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;
}
Exemplo n.º 13
0
static RcStatus copyCursors( FullCurDir * dir, WResFileID handle,
                             ResMemFlags flags, int *err_code )
/***********************************************************************/
/* This function uses the same size of buffers to copy info as for icons */
{
    RcStatus            ret = RS_OK; // should this be RS_PARAM_ERROR ??
    char *              buffer;
    FullCurDirEntry *   entry;
    CurFileDirEntry     fileentry;
    CurHotspot          hotspot;
    BitmapInfoHeader    dibhead;
    ResLocation         loc;

    buffer = RCALLOC( BUFFER_SIZE );

    for( entry = dir->Head; entry != NULL; entry = entry->Next ) {
        /* copy the cursor */
        loc.start = SemStartResource();

        hotspot.X = entry->Entry.Cur.XHotspot;
        hotspot.Y = entry->Entry.Cur.YHotspot;
        if( ResWriteCurHotspot( &hotspot, CurrResFile.handle ) ) {
            ret = RS_WRITE_ERROR;
            *err_code = LastWresErr();
            break;
        }

        /* NOTE: the dibhead structure is filled in as a result of this call */
        ret = copyOneCursor( &(entry->Entry.Cur), handle, buffer,
                        BUFFER_SIZE, &(dibhead), err_code );
        if( ret != RS_OK )
            break;

        loc.len = SemEndResource( loc.start );
        /* add the cursor to the RES file directory */
        SemAddResourceFree( WResIDFromNum( CurrResFile.NextCurOrIcon ),
                WResIDFromNum( (long)(pointer_int)RT_CURSOR ), flags, loc );
        /* change the reference in the cursor directory */
        fileentry = entry->Entry.Cur;
        entry->IsCurFileEntry = false;
        entry->Entry.Res.Width = dibhead.Width;
        entry->Entry.Res.Height = dibhead.Height;
        entry->Entry.Res.Planes = dibhead.Planes;
        entry->Entry.Res.BitCount = dibhead.BitCount;
        /* the hotspot data is now part of the components */
        entry->Entry.Res.Length = fileentry.Length + sizeof(CurHotspot);
        entry->Entry.Res.CurID = CurrResFile.NextCurOrIcon;
        CurrResFile.NextCurOrIcon += 1;
    }

    RCFREE( buffer );

    return( ret );
} /* copyCursors */
Exemplo n.º 14
0
static bool Pass1InitRes( void )
/******************************/
{
    WResID        null_id;
    ResMemFlags   null_memflags;
    ResLocation   null_loc;

    memset( &CurrResFile, 0, sizeof( CurrResFile ) );

    /* open the temporary file */
    CurrResFile.filename = "Temporary file 0 (res)";
    CurrResFile.fp = ResOpenFileTmp( NULL );
    if( CurrResFile.fp == NULL ) {
        RcError( ERR_OPENING_TMP, CurrResFile.filename, LastWresErrStr() );
        return( true );
    }

    /* initialize the directory */
    CurrResFile.dir = WResInitDir();
    if( CurrResFile.dir == NULL ) {
        RcError( ERR_OUT_OF_MEMORY );
        ResCloseFile( CurrResFile.fp );
        CurrResFile.fp = NULL;
        return( true );
    }

    if( CmdLineParms.TargetOS == RC_TARGET_OS_WIN16 ) {
        WResSetTargetOS( CurrResFile.dir, WRES_OS_WIN16 );
    } else if( CmdLineParms.TargetOS == RC_TARGET_OS_WIN32 ) {
        WResSetTargetOS( CurrResFile.dir, WRES_OS_WIN32 );
    } else {
        WResSetTargetOS( CurrResFile.dir, WRES_OS_OS2 );
    }

    if( CmdLineParms.MSResFormat ) {
        CurrResFile.IsWatcomRes = false;
        /* write null header here if it is win32 */
        if( CmdLineParms.TargetOS == RC_TARGET_OS_WIN32 ) {
            null_loc.start = SemStartResource();
            null_loc.len = SemEndResource( null_loc.start );
            null_id.IsName = false;
            null_id.ID.Num = 0;
            null_memflags = 0;
            SemAddResource( &null_id, &null_id, null_memflags, null_loc );
        }
    } else {
        CurrResFile.IsWatcomRes = true;
        WResFileInit( CurrResFile.fp );
    }
    CurrResFile.NextCurOrIcon = 1;
    return( false );
} /* Pass1InitRes */
Exemplo n.º 15
0
void SemOS2WriteFontDir( void )
/*****************************/
{
    FullFontDirEntry *  currentry;
    ResLocation         loc;
    bool                error;

    if( CurrResFile.FontDir == NULL ) {
        return;
    }

    loc.start = SemStartResource();

    error = ResWriteUint16( &(CurrResFile.FontDir->NumOfFonts),
                        CurrResFile.handle );
    if( error)
        goto OUTPUT_WRITE_ERROR;

    for( currentry = CurrResFile.FontDir->Head; currentry != NULL;
                currentry = currentry->Next ) {
        error = ResWriteFontDirEntry( &(currentry->Entry), CurrResFile.handle );
        if( error ) {
            goto OUTPUT_WRITE_ERROR;
        }
    }

    loc.len = SemEndResource( loc.start );

    SemAddResourceFree( WResIDFromStr( FONT_DIR_NAME ),
                WResIDFromNum( (long)RT_FONTDIR ), FONT_DIR_FLAGS, loc );

    FreeFontDir( CurrResFile.FontDir );
    CurrResFile.FontDir = NULL;

    return;


OUTPUT_WRITE_ERROR:
    RcError( ERR_WRITTING_RES_FILE, CurrResFile.filename, LastWresErrStr() );
    ErrorHasOccured = true;
    FreeFontDir( CurrResFile.FontDir );
    CurrResFile.FontDir = NULL;
    return;
}
Exemplo n.º 16
0
extern void SemOS2WriteStringTable( FullStringTable *currtable, WResID *type )
/****************************************************************************/
/* write the table identified by currtable as a table of type type and then */
/* free the memory that it occupied */
{
    FullStringTableBlock    *currblock;
    FullStringTable         *tofree;
    WResID                  *name;
    int                     error;
    ResLocation             loc;

    while( currtable != NULL ) {
        for( currblock = currtable->Head; currblock != NULL;
                    currblock = currblock->Next ) {
            loc.start = SemStartResource();

            error = ResOS2WriteStringTableBlock( &(currblock->Block),
                                                 CurrResFile.handle,
                                                 currblock->codePage );
            if( error) {
                RcError( ERR_WRITTING_RES_FILE, CurrResFile.filename,
                         LastWresErrStr() );
                ErrorHasOccured = TRUE;
                SemOS2FreeStringTable( currtable );
                return;
            }


            loc.len = SemEndResource( loc.start );
            /* +1 because WResID's can't be 0 */
            name = WResIDFromNum( currblock->BlockNum + 1 );
            SemAddResource( name, type, currblock->Flags, loc );
            RcMemFree( name );
        }

        tofree = currtable;
        currtable = currtable->next;
        SemOS2FreeStringTable( tofree );
    }
    RcMemFree( type );
    return;
}
Exemplo n.º 17
0
static bool copyAResource( WResFileID fid, WResDirWindow *wind,
                            char *buffer, const char *filename )
/****************************************************************/
{
    ResLocation         loc;
    WResLangInfo        *langinfo;
    WResTypeInfo        *typeinfo;
    WResResInfo         *resinfo;
//    RcStatus            rc;
    int                 err_code;

    langinfo = WResGetLangInfo( *wind );
    resinfo = WResGetResInfo( *wind );
    typeinfo = WResGetTypeInfo( *wind );
    loc.start = SemStartResource();
    /* rc = */ CopyData( langinfo->Offset, langinfo->Length, fid, buffer, BUFFER_SIZE, &err_code );
    loc.len = SemEndResource( loc.start );
    SemAddResource2( &resinfo->ResName, &typeinfo->TypeName, langinfo->MemoryFlags, loc, filename );
    return( false );
}
Exemplo n.º 18
0
static RcStatus copyIcons( FullIconDir * dir, WResFileID handle,
                            ResMemFlags flags, int *err_code )
/**************************************************************/
{
    RcStatus            ret;
    char *              buffer;
    FullIconDirEntry *  entry;
    BitmapInfoHeader    dibhead;
    ResLocation         loc;

    ret = RS_OK;
    buffer = RCALLOC( BUFFER_SIZE );

    for( entry = dir->Head; entry != NULL; entry = entry->Next ) {
        /* copy the icon */
        loc.start = SemStartResource();

        /* NOTE: the dibhead structure is filled in as a result of this call */
        ret = copyOneIcon( &(entry->Entry.Ico), handle, buffer, BUFFER_SIZE, &(dibhead), err_code );
        if( ret != RS_OK )
            break;

        loc.len = SemEndResource( loc.start );
        /* add the icon to the RES file directory */
        SemAddResourceFree( WResIDFromNum( CurrResFile.NextCurOrIcon ),
                WResIDFromNum( (long)(pointer_int)RT_ICON ), flags, loc );
        /* change the reference in the ICON directory */
        entry->IsIcoFileEntry = false;
        entry->Entry.Res.IconID = CurrResFile.NextCurOrIcon;
        entry->Entry.Res.Info.Planes = dibhead.Planes;
        entry->Entry.Res.Info.BitCount = dibhead.BitCount;
        CurrResFile.NextCurOrIcon += 1;
    }

    RCFREE( buffer );

    return( ret );
} /* copyIcons */
Exemplo n.º 19
0
void SemWriteToolBar( WResID *name, ToolBar *toolbar,
                      unsigned long item1, unsigned long item2,
                      ResMemFlags flags ) {

    ResLocation              loc;
    unsigned                 cnt;
    ToolBarItems            *cur;

    if(!ErrorHasOccured) {
        loc.start = SemStartResource();
        cnt = ( toolbar->nodecnt - 1 ) * TB_ITEM_CNT;
        cnt += toolbar->last->cnt;
        ResWriteToolBarHeader( CurrResFile.handle, item1, item2, cnt );
        cur = &toolbar->first;
        while( cur != NULL ) {
            ResWriteToolBarItems( CurrResFile.handle, cur->items, cur->cnt );
            cur = cur->next;
        }
        loc.len = SemEndResource( loc.start );
        SemAddResourceFree( name, WResIDFromNum( RT_TOOLBAR ), flags, loc );
    }
    semFreeToolBar( toolbar );
}
Exemplo n.º 20
0
static bool writeCurDir( FullCurDir *dir, WResID *name, ResMemFlags flags,
                        int *err_code )
/****************************************************************************/
{
    bool                error;
    FullCurDirEntry *   entry;
    ResLocation         loc;

    loc.start = SemStartResource();
    error = ResWriteIconCurDirHeader( &(dir->Header), CurrResFile.fid );

    for( entry = dir->Head; !error && entry != NULL; entry = entry->Next ) {
        error = ResWriteCurDirEntry( &(entry->Entry.Res), CurrResFile.fid );
    }

    if( !error ) {
        loc.len = SemEndResource( loc.start );
        SemAddResourceFree( name, WResIDFromNum( RESOURCE2INT( RT_GROUP_CURSOR ) ), flags, loc );
    } else {
        *err_code = LastWresErr();
    }

    return( error );
}
Exemplo n.º 21
0
static int Pass1InitRes( void )
/*****************************/
{
    WResID        null_id;
    ResMemFlags   null_memflags;
    ResLocation   null_loc;

    /* put the temporary file in the same location as the output file */
    CurrResFile.filename = CurrResFile.namebuf;
#ifdef USE_TEMPFILE
    MakeTmpInSameDir( CmdLineParms.OutResFileName, CurrResFile.filename,
                    "res" );
#else
    strcpy( CurrResFile.filename, CmdLineParms.OutResFileName );
#endif

    /* initialize the directory */
    CurrResFile.dir = WResInitDir();
    if( CurrResFile.dir == NULL ) {
        RcError( ERR_OUT_OF_MEMORY );
        CurrResFile.IsOpen = false;
        return( TRUE );
    }

    if( CmdLineParms.TargetOS == RC_TARGET_OS_WIN16 ) {
        WResSetTargetOS( CurrResFile.dir, WRES_OS_WIN16 );
    } else if( CmdLineParms.TargetOS == RC_TARGET_OS_WIN32 ) {
        WResSetTargetOS( CurrResFile.dir, WRES_OS_WIN32 );
    } else {
        WResSetTargetOS( CurrResFile.dir, WRES_OS_OS2 );
    }

    /* open the temporary file */
    if( CmdLineParms.MSResFormat ) {
        CurrResFile.IsWatcomRes = FALSE;
        CurrResFile.handle = MResOpenNewFile( CurrResFile.filename );

    /* write null header here if it is win32 */
        if( CmdLineParms.TargetOS == RC_TARGET_OS_WIN32 &&
                                     CmdLineParms.MSResFormat ) {
            null_loc.start = SemStartResource();
            null_loc.len = SemEndResource( null_loc.start );
            null_id.IsName = FALSE;
            null_id.ID.Num = 0;
            null_memflags = 0;
            SemAddResource( &null_id, &null_id, null_memflags, null_loc );
        }
    } else {
        CurrResFile.IsWatcomRes = TRUE;
        CurrResFile.handle = WResOpenNewFile( CurrResFile.filename );
    }
    if( CurrResFile.handle == NIL_HANDLE ) {
        RcError( ERR_OPENING_TMP, CurrResFile.filename, LastWresErrStr() );
        CurrResFile.IsOpen = false;
        return( TRUE );
    }
    RegisterTmpFile( CurrResFile.filename );

    CurrResFile.IsOpen = true;
    CurrResFile.StringTable = NULL;
    CurrResFile.ErrorTable = NULL;
    CurrResFile.FontDir = NULL;
    CurrResFile.NextCurOrIcon = 1;
    return( FALSE );
} /* Pass1InitRes */
Exemplo n.º 22
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;
}