int WResLoadResourceX( PHANDLE_INFO hinfo, lpcstr idType, lpcstr idResource, lpstr *lpszBuffer, size_t *bufferSize ) /*************************************************************************/ { WResID *resource_type; WResID *resource_id; int rc; if( IS_INTRESOURCE( idResource ) ) { resource_id = WResIDFromNum( (uint_16)RESOURCE2INT( idResource ) ); } else { resource_id = WResIDFromStrF( idResource ); } if( IS_INTRESOURCE( idType ) ) { resource_type = WResIDFromNum( (uint_16)RESOURCE2INT( idType ) ); } else { resource_type = WResIDFromStrF( idType ); } rc = WResLoadResource2( MainDir, hinfo, resource_type, resource_id, lpszBuffer, bufferSize ); if( resource_type != NULL ) WResIDFree( resource_type ); if( resource_id != NULL ) WResIDFree( resource_id ); return( rc ); }
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 ); }
Bool WREGetAndAddIconImage( BYTE *data, WResDir dir, ICONDIRENTRY *id, int ord ) { BYTE *icon; int dup; WResID *tname; WResID *rname; WResLangType lang; Bool ok; dup = FALSE; lang.lang = DEF_LANG; lang.sublang = DEF_SUBLANG; tname = NULL; rname = NULL; ok = ( data && dir && id && id->dwBytesInRes ); if ( ok ) { icon = (BYTE *)WREMemAlloc( id->dwBytesInRes ); ok = ( icon != NULL ); } if( ok ) { memcpy( icon, data + id->dwImageOffset, id->dwBytesInRes ); tname = WResIDFromNum( (uint_16)RT_ICON ); ok = ( tname != NULL ); } if( ok ) { rname = WResIDFromNum( ord ); ok = ( rname != NULL ); } if ( ok ) { ok = !WResAddResource( tname, rname, DEF_MEMFLAGS, 0, id->dwBytesInRes, dir, &lang, &dup ); } if( ok ) { ok = WRFindAndSetData( dir, tname, rname, &lang, icon ); } if( !ok ) { if( icon != NULL ) { WREMemFree( icon ); } } if( tname != NULL ) { WREMemFree( tname ); } if( rname != NULL ) { WREMemFree( rname ); } return( ok ); }
bool WRAPI WRGetAndAddIconImage( BYTE *data, WResDir dir, ICONDIRENTRY *id, int ord ) { BYTE *icon; bool dup; WResID *tname; WResID *rname; WResLangType lang; bool ok; dup = false; lang.lang = DEF_LANG; lang.sublang = DEF_SUBLANG; tname = NULL; rname = NULL; ok = (data != NULL && dir != NULL && id != NULL && id->dwBytesInRes != 0); if( ok ) { icon = (BYTE *)MemAlloc( id->dwBytesInRes ); ok = (icon != NULL); } if( ok ) { memcpy( icon, data + id->dwImageOffset, id->dwBytesInRes ); tname = WResIDFromNum( RESOURCE2INT( RT_ICON ) ); ok = (tname != NULL); } if( ok ) { rname = WResIDFromNum( ord ); ok = (rname != NULL); } if( ok ) { ok = !WResAddResource( tname, rname, DEF_MEMFLAGS, 0, id->dwBytesInRes, dir, &lang, &dup ); } if( ok ) { ok = WRFindAndSetData( dir, tname, rname, &lang, icon ); } if( !ok ) { if( icon != NULL ) { MemFree( icon ); } } if( tname != NULL ) { MemFree( tname ); } if( rname != NULL ) { MemFree( rname ); } return( ok ); }
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 */
static bool ScanOptionsArg( const char * arg ) { bool contok; int predeftype; contok = true; switch (*arg) { case '\0': puts( "Error: no option specifed after option character" ); contok = false; break; case 'n': arg++; if (*arg != '=') { puts( "Missing = after option n" ); contok = false; } else { arg++; if (isdigit( *arg )) { CmdLineParms.Name = WResIDFromNum( atoi( arg ) ); } else { CmdLineParms.Name = WResIDFromStr( arg ); } } break; case 't': arg++; if (*arg != '=') { puts( "Missing = after option t" ); contok = false; } else { arg++; if (isdigit( *arg )) { CmdLineParms.Type = WResIDFromNum( atoi( arg ) ); } else { predeftype = CheckPredefType( arg ); if (predeftype == 0) { CmdLineParms.Type = WResIDFromStr( arg ); } else { CmdLineParms.Type = WResIDFromNum( predeftype ); } } } break; default: /* option that could have others with it */ contok = ScanMultiOptArg( arg ) && contok; break; } return( contok ); }
static void WriteOS2Tables( void ) /********************************/ { if( CurrResFile.StringTable != NULL ) { SemOS2WriteStringTable( CurrResFile.StringTable, WResIDFromNum( OS2_RT_STRING ) ); } if( CurrResFile.ErrorTable != NULL ) { SemOS2WriteStringTable( CurrResFile.ErrorTable, WResIDFromNum( OS2_RT_MESSAGE ) ); } if( CurrResFile.FontDir != NULL ) { SemOS2WriteFontDir(); } }
static void WriteTables( void ) /*****************************/ { if( CurrResFile.StringTable != NULL ) { SemWriteStringTable( CurrResFile.StringTable, WResIDFromNum( (long)RT_STRING ) ); } if( CurrResFile.ErrorTable != NULL ) { SemWriteStringTable( CurrResFile.ErrorTable, WResIDFromNum( (long)RT_ERRTABLE ) ); } if( CurrResFile.FontDir != NULL ) { SemWriteFontDir(); } }
static void WriteWINTables( void ) /********************************/ { if( CurrResFile.StringTable != NULL ) { SemWINWriteStringTable( CurrResFile.StringTable, WResIDFromNum( RESOURCE2INT( RT_STRING ) ) ); } if( CurrResFile.ErrorTable != NULL ) { SemWINWriteStringTable( CurrResFile.ErrorTable, WResIDFromNum( RESOURCE2INT( RT_ERRTABLE ) ) ); } if( CurrResFile.FontDir != NULL ) { SemWINWriteFontDir(); } }
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; }
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 */
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; }
int WRLoadBitmapFile( WRInfo *info ) { int ok; int file_handle; long int file_length; char fn[_MAX_FNAME]; WResID *type; WResID *name; WResLangType def_lang; file_handle = -1; def_lang.sublang = DEF_LANG; def_lang.lang = DEF_SUBLANG; ok = ( info != NULL ); if( ok ) { ok = ( ( file_handle = ResOpenFileRO( info->file_name ) ) != -1 ); } if( ok ) { file_length = filelength( file_handle ); ok = ( ( file_length != 0 ) && ( file_length != -1 ) ); } if( ok ) { type = WResIDFromNum( (long)RT_BITMAP ); ok = ( type != NULL ); } if( ok ) { _splitpath( info->file_name, NULL, NULL, fn, NULL ); name = WResIDFromStr( fn ); ok = ( name != NULL ); } if( ok ) { ok = ( ( info->dir = WResInitDir() ) != NULL ); } if( ok ) { ok = !WResAddResource( type, name, 0, sizeof(BITMAPFILEHEADER), file_length - sizeof(BITMAPFILEHEADER), info->dir, &def_lang, NULL ); } if( file_handle != -1 ) { ResCloseFile( file_handle ); } if( name ) { WRMemFree( name ); } if( type ) { WRMemFree( type ); } return( ok ); }
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; }
WResID *WGetWResIDFromEdit( HWND edit, bool *mod ) { WResID *rp; uint_16 ordID; char *cp; char *ep; rp = NULL; cp = WGetStrFromEdit( edit, mod ); /* find out if the edit field has changed */ if( mod == NULL || *mod ) { if( cp == NULL ) { return( NULL ); } ordID = (uint_16)strtoul( cp, &ep, 0 ); if( *ep == '\0' ) { rp = WResIDFromNum( ordID ); } else { rp = WResIDFromStr( cp ); } } if( cp != NULL ) { WRMemFree( cp ); } return( rp ); }
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; }
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; }
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 */
static WResID * ConvertNameOrOrdToID( ResNameOrOrdinal * name ) /*************************************************************/ { if (name->ord.fFlag == 0xff) { return( WResIDFromNum( name->ord.wOrdinalID ) ); } else { return( WResIDFromStr( name->name ) ); } }
/* 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 */
bool WRHandleWinNTNameEntry( WResFileID file, WResDir *dir, WResID *type, resource_dir_entry *rd_entry, bool is_name ) { WResLangType def_lang; resource_entry res_entry; uint_32 offset; WResID *name; bool add_now; bool ok; def_lang.lang = DEF_LANG; def_lang.sublang = DEF_SUBLANG; /* verify the id_name */ if ( ((rd_entry->id_name & PE_RESOURCE_MASK_ON) && !is_name) || (!(rd_entry->id_name & PE_RESOURCE_MASK_ON) && is_name) ) { WRDisplayErrorMsg( WR_BADIDDISCARDNAME ); return( FALSE ); } if( is_name ) { name = WRGetUniCodeWResID( file, PE_RESOURCE_MASK & rd_entry->id_name ); } else { name = WResIDFromNum( rd_entry->id_name ); } ok = (name != NULL); if( ok ) { /* is the entry_rva is a subdir */ if( rd_entry->entry_rva & PE_RESOURCE_MASK_ON ) { add_now = false; ok = WRHandleWinNTLangIDDir( file, dir, type, name, rd_entry->entry_rva & PE_RESOURCE_MASK ); } else { /* will this to happen often ???? */ add_now = true; offset = WR_MAP_RES_RVA( rd_entry->entry_rva ); ok = WRReadResourceEntry( file, offset, &res_entry ); } } if( ok ) { if( add_now ) { offset = WR_MAP_RES_RVA( res_entry.data_rva ); ok = !WResAddResource( type, name, 0, offset, res_entry.size, *dir, &def_lang, NULL ); } } if( name != NULL ) { WResIDFree( name ); } return( ok ); }
DepInfo *WResGetAutoDep( const char *fname ) { WResFileID handle; WResDir dir; bool dup_discarded; WResID *name; WResID *type; WResDirWindow window; WResLangInfo *info; DepInfo *ret; WResFileSSize numread; ret = NULL; handle = ResOpenFileRO( fname ); if( handle != WRES_NIL_HANDLE ) { if( WResIsWResFile( handle ) && (dir = WResInitDir()) != NULL ) { if( !WResReadDir( handle, dir, &dup_discarded ) ) { name = WResIDFromStr( DEP_LIST_NAME ); type = WResIDFromNum( DEP_LIST_TYPE ); if( name != NULL && type != NULL ) { window = WResFindResource( type, name, dir, NULL ); if( WResIsEmptyWindow( window ) ) { WRES_ERROR( WRS_RES_NOT_FOUND ); } else { info = WResGetLangInfo( window ); if( WRESSEEK( handle, info->Offset, SEEK_SET ) == -1 ) { WRES_ERROR( WRS_SEEK_FAILED ); } else { ret = WRESALLOC( info->Length ); if( ret == NULL ) { WRES_ERROR( WRS_MALLOC_FAILED ); } else { numread = WRESREAD( handle, ret, info->Length ); if( numread != (WResFileSSize)info->Length ) { WRES_ERROR( WRESIOERR( handle, numread ) ? WRS_READ_FAILED : WRS_READ_INCOMPLETE ); ret = NULL; } } } } } if( name != NULL ) { WResIDFree( name ); } if( type != NULL ) { WResIDFree( type ); } } WResFreeDir( dir ); } ResCloseFile( handle ); } return( ret ); }
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; }
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 */
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; }
void SemWINAddMessageTable( WResID *name, ScanString *filename ) { /****************************************************************/ ResLocation start; if( CmdLineParms.TargetOS == RC_TARGET_OS_WIN32 ) { start = SemCopyRawFile( filename->string ); RCFREE( filename->string ); RCFREE( filename ); SemAddResourceFree( name, WResIDFromNum( (long)(pointer_int)RT_MESSAGETABLE ), MEMFLAG_MOVEABLE | MEMFLAG_PURE, start ); } else { RcError( ERR_NT_KEYWORD, SemWINTokenToString( Y_MESSAGETABLE ) ); ErrorHasOccured = true; RCFREE( name ); RCFREE( filename->string ); RCFREE( filename ); } }
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; }
bool WRHandleWinNTTypeEntry( WResFileID file, WResDir *dir, resource_dir_entry *rd_entry, int is_name ) { WResID *type; bool ok; /* verify the id_name */ if( ((rd_entry->id_name & PE_RESOURCE_MASK_ON) && !is_name) || (!(rd_entry->id_name & PE_RESOURCE_MASK_ON) && is_name) ) { WRDisplayErrorMsg( WR_BADIDDISCARDTYPE ); return( FALSE ); } if( is_name ) { type = WRGetUniCodeWResID( file, PE_RESOURCE_MASK & rd_entry->id_name ); } else { type = WResIDFromNum( rd_entry->id_name ); } ok = (type != NULL); if( ok ) { /* verify that entry_rva is a subdir */ ok = ((rd_entry->entry_rva & PE_RESOURCE_MASK_ON) != 0); if( !ok ) { WRDisplayErrorMsg( WR_BADRVADISCARDTYPE ); } } if( ok ) { ok = WRHandleWinNTNameDir( file, dir, type, rd_entry->entry_rva & PE_RESOURCE_MASK ); } if( type != NULL ) { WResIDFree( type ); } return( ok ); }
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 ); }
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 ); }