static bool CreatePreprocFile( void ) { int hdl; bool error; int ch; char ch1; int len; error = FALSE; hdl = RcOpen( CmdLineParms.OutResFileName, O_WRONLY | O_TEXT | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH ); if( hdl == -1 ) { RcError( ERR_CANT_OPEN_FILE, CmdLineParms.OutResFileName, strerror( errno ) ); error = TRUE; } else { ch = RcIoGetChar(); while( ch != RC_EOF ) { ch1 = (char) ch; len = RcWrite( hdl, &ch1, 1 ); if( len != 1 ) { RcError( ERR_WRITTING_FILE, CmdLineParms.OutResFileName, strerror( errno ) ); error = TRUE; } ch = RcIoGetChar(); } } if( hdl != -1 ) RcClose( hdl ); return( error ); }
static int openNewExeFileInfo( char *filename, ExeFileInfo *info ) /******************************************************************/ { info->Handle = RcOpen( filename, O_RDWR|O_CREAT|O_TRUNC|O_BINARY, PMODE_RW ); if( info->Handle == NIL_HANDLE ) { RcError( ERR_OPENING_TMP, filename, strerror( errno ) ); return( FALSE ); } RegisterTmpFile( filename ); info->IsOpen = TRUE; info->DebugOffset = 0; info->name = filename; return( TRUE ); } /* openNewExeFileInfo */
RcStatus OpenTable( char *fname, char *path ) { int fp; RcStatus status; status = RS_OK; _searchenv( fname, "PATH", path ); if( path[0] == '\0' ) return( RS_FILE_NOT_FOUND ); fp = RcOpen( path, O_RDONLY | O_BINARY ); if( fp == -1 ) { status = RS_OPEN_ERROR; } if( status == RS_OK ) status = readDBHeader( fp ); if( status == RS_OK ) status = readDBRanges( fp ); if( status == RS_OK ) status = readDBIndex( fp ); if( status == RS_OK ) status = readDBTable( fp ); if( status != RS_OPEN_ERROR ) RcClose( fp ); if( status == RS_OK ) { ConvToUnicode = DBStringToUnicode; } return( status ); }
static int openExeFileInfoRO( char *filename, ExeFileInfo *info ) /***************************************************************/ { RcStatus status; exe_pe_header *pehdr; info->Handle = RcOpen( filename, O_RDONLY|O_BINARY ); if( info->Handle == NIL_HANDLE ) { RcError( ERR_CANT_OPEN_FILE, filename, strerror( errno ) ); return( FALSE ); } info->IsOpen = TRUE; info->Type = FindNEPELXHeader( info->Handle, &info->WinHeadOffset ); info->name = filename; switch( info->Type ) { case EXE_TYPE_NE_WIN: case EXE_TYPE_NE_OS2: status = SeekRead( info->Handle, info->WinHeadOffset, &info->u.NEInfo.WinHead, sizeof( os2_exe_header ) ); if( status != RS_OK ) { RcError( ERR_NOT_VALID_EXE, filename ); return( FALSE ); } else { info->DebugOffset = info->WinHeadOffset + sizeof( os2_exe_header ); } break; case EXE_TYPE_PE: pehdr = &info->u.PEInfo.WinHeadData; info->u.PEInfo.WinHead = pehdr; status = SeekRead( info->Handle, info->WinHeadOffset, &PE32( *pehdr ), sizeof( pe_header ) ); if( status != RS_OK ) { RcError( ERR_NOT_VALID_EXE, filename ); return( FALSE ); } if( IS_PE64( *pehdr ) ) { status = SeekRead( info->Handle, info->WinHeadOffset, &PE64( *pehdr ), sizeof( pe_header64 ) ); if( status != RS_OK ) { RcError( ERR_NOT_VALID_EXE, filename ); return( FALSE ); } info->DebugOffset = info->WinHeadOffset + sizeof( pe_header64 ); } else { info->DebugOffset = info->WinHeadOffset + sizeof( pe_header ); } break; case EXE_TYPE_LX: status = SeekRead( info->Handle, info->WinHeadOffset, &info->u.LXInfo.OS2Head, sizeof( os2_flat_header ) ); if( status != RS_OK ) { RcError( ERR_NOT_VALID_EXE, filename ); return( FALSE ); } else { info->DebugOffset = info->WinHeadOffset + sizeof( os2_flat_header ); } break; default: RcError( ERR_NOT_VALID_EXE, filename ); return( FALSE ); break; } RcSeek( info->Handle, 0, SEEK_SET ); return( TRUE ); } /* openExeFileInfoRO */