static void AddBitmapResource( WResID * name, ResMemFlags flags, const char * filename ) /**************************************************************/ { BitmapFileHeader head; WResFileID handle; RcStatus ret; int err_code; handle = RcIoOpenInput( filename, O_RDONLY | O_BINARY ); if( handle == NIL_HANDLE) goto FILE_OPEN_ERROR; ret = readBitmapFileHeader( handle, &head, &err_code ); if( ret != RS_OK ) goto READ_HEADER_ERROR; if( head.Type != BITMAP_MAGIC ) goto NOT_BITMAP_ERROR; ret = copyBitmap( &head, handle, name, flags, &err_code ); if( ret != RS_OK ) goto COPY_BITMAP_ERROR; RCCLOSE( handle ); return; FILE_OPEN_ERROR: RcError( ERR_CANT_OPEN_FILE, filename, strerror( errno ) ); ErrorHasOccured = true; RCFREE( name ); return; READ_HEADER_ERROR: ReportCopyError( ret, ERR_READING_BITMAP, filename, err_code ); ErrorHasOccured = true; RCFREE( name ); RCCLOSE( handle ); return; NOT_BITMAP_ERROR: RcError( ERR_NOT_BITMAP_FILE, filename ); ErrorHasOccured = true; RCFREE( name ); RCCLOSE( handle ); return; COPY_BITMAP_ERROR: ReportCopyError( ret, ERR_READING_BITMAP, filename, err_code ); ErrorHasOccured = true; RCCLOSE( handle ); return; }
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 ); }
static void AddFontResources( WResID * name, ResMemFlags flags, const char * filename ) /**************************************************************/ { FontInfo info; char * devicename; char * facename; WResFileID handle; RcStatus ret; int err_code; ReadStrErrInfo readstr_err; if( name->IsName ) { RcError( ERR_FONT_NAME ); return; } handle = RcIoOpenInput( filename, O_RDONLY | O_BINARY ); if( handle == NIL_HANDLE) goto FILE_OPEN_ERROR; ret = readFontInfo( handle, &info, &err_code ); if( ret != RS_OK) goto READ_HEADER_ERROR; ret = copyFont( &info, handle, name, flags, &err_code ); if( ret != RS_OK ) goto COPY_FONT_ERROR; devicename = readString( handle, info.dfDevice, &readstr_err ); if( devicename == NULL ) { ret = readstr_err.status; err_code = readstr_err.err_code; goto READ_HEADER_ERROR; } facename = readString( handle, info.dfFace, &readstr_err ); if( facename == NULL ) { ret = readstr_err.status; err_code = readstr_err.err_code; RCFREE( devicename ); goto READ_HEADER_ERROR; } AddFontToDir( &info, devicename, facename, name ); RCFREE( devicename ); RCFREE( facename ); RCCLOSE( handle ); return; FILE_OPEN_ERROR: RcError( ERR_CANT_OPEN_FILE, filename, strerror( errno ) ); ErrorHasOccured = true; RCFREE( name ); return; READ_HEADER_ERROR: ReportCopyError( ret, ERR_READING_FONT, filename, err_code ); ErrorHasOccured = true; RCFREE( name ); RCCLOSE( handle ); return; COPY_FONT_ERROR: ReportCopyError( ret, ERR_READING_FONT, filename, err_code ); ErrorHasOccured = true; RCCLOSE( handle ); return; }
static void AddCursorResource( WResID * name, ResMemFlags flags, ResMemFlags group_flags, const char * filename ) /********************************************************************/ { WResFileID handle; RcStatus ret; bool error; FullCurDir dir; int err_code; handle = RcIoOpenInput( filename, O_RDONLY | O_BINARY ); if( handle == NIL_HANDLE) goto FILE_OPEN_ERROR; dir.Head = NULL; dir.Tail = NULL; ret = readCurFileDir( handle, &dir, &err_code ); if( ret != RS_OK) goto READ_DIR_ERROR; ret = copyCursors( &dir, handle, flags, &err_code ); if( ret != RS_OK ) goto COPY_CURSORS_ERROR; error = writeCurDir( &dir, name, group_flags, &err_code ); if( error) goto WRITE_DIR_ERROR; FreeCurDir( &dir ); RCCLOSE( handle ); return; FILE_OPEN_ERROR: RcError( ERR_CANT_OPEN_FILE, filename, strerror( errno ) ); ErrorHasOccured = true; RCFREE( name ); return; READ_DIR_ERROR: if( ret == RS_INVALID_RESOURCE ) { RcError( ERR_NOT_CURSOR_FILE, filename ); } else { ReportCopyError( ret, ERR_READING_CURSOR, filename, err_code ); } ErrorHasOccured = true; RCFREE( name ); FreeCurDir( &dir ); RCCLOSE( handle ); return; WRITE_DIR_ERROR: RcError( ERR_WRITTING_RES_FILE, CurrResFile.filename, strerror( err_code ) ); ErrorHasOccured = true; FreeCurDir( &dir ); RCCLOSE( handle ); return; COPY_CURSORS_ERROR: ReportCopyError( ret, ERR_READING_CURSOR, filename, err_code ); ErrorHasOccured = true; RCFREE( name ); FreeCurDir( &dir ); RCCLOSE( handle ); return; } /* AddCursorResource */
static void AddIconResource( WResID * name, ResMemFlags flags, ResMemFlags group_flags, const char * filename ) /****************************************************************/ { WResFileID fid; RcStatus ret; bool error; FullIconDir dir; int err_code; fid = RcIoOpenInput( filename, false ); if( fid == WRES_NIL_HANDLE) goto FILE_OPEN_ERROR; dir.Head = NULL; dir.Tail = NULL; ret = readIcoFileDir( fid, &dir, &err_code ); if( ret != RS_OK ) goto READ_DIR_ERROR; ret = copyIcons( &dir, fid, flags, &err_code ); if( ret != RS_OK ) goto COPY_ICONS_ERROR; error = writeIconDir( &dir, name, group_flags, &err_code ); if( error) goto WRITE_DIR_ERROR; FreeIconDir( &dir ); RESCLOSE( fid ); return; FILE_OPEN_ERROR: RcError( ERR_CANT_OPEN_FILE, filename, strerror( errno ) ); ErrorHasOccured = true; RESFREE( name ); return; READ_DIR_ERROR: if( ret == RS_INVALID_RESOURCE ) { RcError( ERR_NOT_ICON_FILE, filename ); } else { ReportCopyError( ret, ERR_READING_ICON, filename, err_code ); } ErrorHasOccured = true; RESFREE( name ); FreeIconDir( &dir ); RESCLOSE( fid ); return; WRITE_DIR_ERROR: RcError( ERR_WRITTING_RES_FILE, CurrResFile.filename, strerror( err_code ) ); ErrorHasOccured = true; FreeIconDir( &dir ); RESCLOSE( fid ); return; COPY_ICONS_ERROR: ReportCopyError( ret, ERR_READING_ICON, filename, err_code ); ErrorHasOccured = true; RESFREE( name ); FreeIconDir( &dir ); RESCLOSE( fid ); return; } /* AddIconResource */
static void AddFontResources( WResID * name, ResMemFlags flags, char * filename ) /**************************************************************/ { FontInfo info; char * devicename; char * facename; int handle; int error; int err_code; ReadStrErrInfo readstr_err; if (name->IsName) { RcError( ERR_FONT_NAME ); return; } handle = RcIoOpenInput( filename, O_RDONLY | O_BINARY ); if (handle == -1) goto FILE_OPEN_ERROR; error = readFontInfo( handle, &info, &err_code ); if( error != RS_OK) goto READ_HEADER_ERROR; error = copyFont( &info, handle, name, flags, &err_code ); if( error != RS_OK ) goto COPY_FONT_ERROR; devicename = readString( handle, info.dfDevice, &readstr_err ); if( devicename == NULL ) { error = readstr_err.status; err_code = readstr_err.err_code; goto READ_HEADER_ERROR; } facename = readString( handle, info.dfFace, &readstr_err ); if (facename == NULL) { error = readstr_err.status; err_code = readstr_err.err_code; RcMemFree( devicename ); goto READ_HEADER_ERROR; } AddFontToDir( &info, devicename, facename, name ); RcMemFree( devicename ); RcMemFree( facename ); RcClose( handle ); return; FILE_OPEN_ERROR: RcError( ERR_CANT_OPEN_FILE, filename, strerror( errno ) ); ErrorHasOccured = TRUE; RcMemFree( name ); return; READ_HEADER_ERROR: ReportCopyError( error, ERR_READING_FONT, filename, err_code ); ErrorHasOccured = TRUE; RcMemFree( name ); RcClose( handle ); return; COPY_FONT_ERROR: ReportCopyError( error, ERR_READING_FONT, filename, err_code ); ErrorHasOccured = TRUE; RcClose( handle ); return; }