unsigned DIGENTRY DIPImpModName( imp_image_handle *ii, imp_mod_handle im, char *buff, unsigned buff_size ) { cv_directory_entry *cde; cv_sst_module *mp; const char *name; const char *start; const char *end; unsigned len; if( im == IMH_GBL ) { return( NameCopy( buff, GBL_NAME, buff_size, sizeof( GBL_NAME ) - 1 ) ); } cde = FindDirEntry( ii, im, sstModule ); mp = VMBlock( ii, cde->lfo, cde->cb ); if( mp == NULL ) return( 0 ); name = (char *)&mp->SegInfo[mp->cSeg]; len = *(unsigned_8 *)name; ++name; start = name; end = name + len; for( ; len != 0; ) { if( IS_PATH_CHAR( *name ) ) { start = name + 1; end = name + len; } if( *name == EXT_CHAR ) end = name; ++name; --len; } return( NameCopy( buff, start, buff_size, end - start ) ); }
search_result DIPENTRY DIPImpAddrCue( imp_image_handle *ii, imp_mod_handle im, address addr, imp_cue_handle *ic ) { cv_directory_entry *cde; cv_sst_src_module_header *hdr; unsigned_32 *files; virt_mem file_base; unsigned num_files; unsigned file_idx; addr_off best_offset; unsigned file_tab_size; search_result rc; cde = FindDirEntry( ii, im, sstSrcModule ); if( cde == NULL ) return( SR_NONE ); hdr = VMBlock( ii, cde->lfo, sizeof( *hdr ) ); if( hdr == NULL ) return( SR_NONE ); ic->im = im; num_files = hdr->cFile; file_tab_size = num_files * sizeof( unsigned_32 ); hdr = VMBlock( ii, cde->lfo, sizeof( *hdr ) + file_tab_size ); files = __alloca( file_tab_size ); memcpy( files, &hdr->baseSrcFile[0], file_tab_size ); best_offset = (addr_off)-1UL; for( file_idx = 0; file_idx < num_files; ++file_idx ) { file_base = files[file_idx] + cde->lfo; rc = SearchFile( ii, addr, ic, file_base, cde, &best_offset ); if( rc != SR_FAIL ) return( rc ); /* see comment in SearchFile above */ } if( best_offset == (addr_off)-1UL ) return( SR_NONE ); return( SR_CLOSEST ); }
search_result DIPENTRY DIPImpLineCue( imp_image_handle *ii, imp_mod_handle im, cue_file_id file, unsigned long line, unsigned column, imp_cue_handle *ic ) { cv_directory_entry *cde; cv_sst_src_module_header *hdr; cv_sst_src_module_file_table *fp; cv_sst_src_module_line_number *lp; unsigned_32 *line_off; unsigned num_segs; unsigned seg_idx; unsigned long best_line; virt_mem line_base; virt_mem num_base; unsigned num_pairs; unsigned pair; unsigned_16 *line_number; column = column; cde = FindDirEntry( ii, im, sstSrcModule ); if( cde == NULL ) return( SR_NONE ); if( file == 0 ) { hdr = VMBlock( ii, cde->lfo, sizeof( *hdr ) ); if( hdr == NULL ) return( SR_NONE ); file = hdr->baseSrcFile[0] + cde->lfo; } ic->im = im; ic->file = file; fp = VMBlock( ii, file, sizeof( *fp ) ); if( fp == NULL ) return( SR_NONE ); num_segs = fp->cSeg; fp = VMBlock( ii, file, sizeof( *fp ) + num_segs * sizeof( unsigned_32 ) ); if( fp == NULL ) return( SR_NONE ); /* make a copy of the line/offset table so that we don't have to worry about the VM system throwing it out */ line_off = __alloca( num_segs * sizeof( unsigned_32 ) ); memcpy( line_off, &fp->baseSrcLn[0], num_segs * sizeof( unsigned_32 ) ); best_line = -1UL; for( seg_idx = 0; seg_idx < num_segs; ++seg_idx ) { line_base = line_off[seg_idx] + cde->lfo; lp = VMBlock( ii, line_base, sizeof( *lp ) ); if( lp == NULL ) return( SR_NONE ); num_pairs = lp->cPair; num_base = line_base + offsetof( cv_sst_src_module_line_number, offset ) + (unsigned long)num_pairs * sizeof( unsigned_32 ); for( pair = 0; pair < num_pairs; ++pair ) { line_number = VMBlock( ii, num_base, sizeof( *line_number ) ); if( *line_number >= line && *line_number < best_line ) { best_line = *line_number; ic->line = line_base; ic->pair = pair; if( best_line == line ) return( SR_EXACT ); } num_base += sizeof( *line_number ); } } if( best_line == -1UL ) return( SR_NONE ); return( SR_CLOSEST ); }
dip_status DIPENTRY DIPImpCueAdjust( imp_image_handle *ii, imp_cue_handle *ic, int adj, imp_cue_handle *aic ) { cv_directory_entry *cde; dip_status status; dip_status ok; cde = FindDirEntry( ii, ic->im, sstSrcModule ); if( cde == NULL ) { DCStatus( DS_ERR|DS_INFO_INVALID ); return( DS_ERR|DS_INFO_INVALID ); } *aic = *ic; ok = DS_OK; while( adj > 0 ) { status = AdjForward( ii, cde->lfo, aic ); if( status & DS_ERR ) return( status ); if( status != DS_OK ) ok = status; --adj; } while( adj < 0 ) { status = AdjBackward( ii, cde->lfo, aic ); if( status & DS_ERR ) return( status ); if( status != DS_OK ) ok = status; ++adj; } return( ok ); }
// FindDirEntry status_t Tree::FindDirEntry(uint32 dirID, uint32 objectID, const char *name, DirItem *foundItem, int32 *entryIndex) { status_t error = (name && foundItem && entryIndex ? InitCheck() : B_BAD_VALUE); if (error == B_OK) { error = FindDirEntry(dirID, objectID, name, strlen(name), foundItem, entryIndex); } return error; }
dip_status DIPIMPENTRY( LoadInfo )( dig_fhandle fid, imp_image_handle *ii ) { dip_status ds; unsigned long off; unsigned long size; cv_directory_entry *cde; cv_sst_global_types_header *hdr; memset( ii, 0, sizeof( *ii ) ); ds = FindCV( fid, &off, &size ); if( ds != DS_OK ) return( ds ); ii->sym_fid = fid; ii->bias = off; ds = VMInit( ii, size ); if( ds != DS_OK ) return( ds ); ii->next_image = ImageList; ImageList = ii; ds = LoadDirectory( ii, off + CV_SIG_SIZE ); if( ds != DS_OK ) { DCStatus( ds ); Cleanup( ii ); return( ds ); } ds = LoadMapping( ii ); if( ds != DS_OK ) { DCStatus( ds ); Cleanup( ii ); return( ds ); } cde = FindDirEntry( ii, IMH_GBL, sstGlobalTypes ); if( cde != NULL ) { hdr = VMBlock( ii, cde->lfo, sizeof( *hdr ) ); if( hdr == NULL ) { Cleanup( ii ); return( DS_ERR|DS_FAIL ); } ii->types_base = cde->lfo + offsetof(cv_sst_global_types_header, offType ) + hdr->cType * sizeof( hdr->offType[0] ); } ds = SetMADType( ii ); if( ds != DS_OK ) { DCStatus( ds ); Cleanup( ii ); return( ds ); } return( DS_OK ); }
void fsaFile::SetAnalysisDateTime(fsaDate *pD, fsaTime *pT) { fsaDirEntry *pDir; INT32 n = 1; size_t nCopy = 0; // number of bytes to copy, 4 for date, 3 for time, 7 for both size_t nOffset = 4; // offset into fsaDirEntry raw data to copy bytes, 4 for date, 7 for time w/o date size_t nRawOffset = 0; // offset into pDateTimeRaw to copy time, 4 if date is used, 0 otherwise UINT8 pDateTimeRaw[7]; UINT8 *pRawData; if(pD != NULL) { // set up date INT16 nYear = pD->year; if(!ByteOrder::LocalBigEndian()) { ByteOrder::reverse(&nYear); } memcpy(pDateTimeRaw,&nYear,2); pDateTimeRaw[2] = pD->month; pDateTimeRaw[3] = pD->day; nRawOffset = 4; nCopy = 4; } else { nOffset = 7; } if(pT != NULL) { // set up time nCopy += 3; pDateTimeRaw[nRawOffset++] = pT->hour; pDateTimeRaw[nRawOffset++] = pT->minute; pDateTimeRaw[nRawOffset++] = pT->second; } if (nCopy) { while (pDir = FindDirEntry("STAT",n)) { pRawData = (UINT8 *)pDir->GetDataRaw(); memcpy(&pRawData[nOffset],pDateTimeRaw,nCopy); n++; } } }
address DIGENTRY DIPImpModAddr( imp_image_handle *ii, imp_mod_handle im ) { cv_sst_module *mp; cv_directory_entry *cde; address addr; cde = FindDirEntry( ii, im, sstModule ); if( cde == NULL ) return( NilAddr ); mp = VMBlock( ii, cde->lfo, cde->cb ); if( mp == NULL ) return( NilAddr ); if( mp->cSeg == 0 ) return( NilAddr ); addr.mach.segment = mp->SegInfo[0].Seg; addr.mach.offset = mp->SegInfo[0].offset; MapLogical( ii, &addr ); return( addr ); }
dip_status DIGENTRY DIPImpModInfo( imp_image_handle *ii, imp_mod_handle im, handle_kind hk ) { static const unsigned DmndType[] = { 0, 0, //sstGlobalTypes, sstSrcModule, sstAlignSym }; unsigned type; cv_directory_entry *cde; type = DmndType[hk]; if( type == 0 ) return( DS_FAIL ); cde = FindDirEntry( ii, im, type ); if( cde == NULL ) return( DS_FAIL ); if( cde->cb == 0 ) return( DS_FAIL ); return( DS_OK ); }
cs_compile *GetCompInfo( imp_image_handle *ii, imp_mod_handle im ) { cv_directory_entry *cde; virt_mem vm; s_compile *rec; long left; cde = FindDirEntry( ii, im, sstAlignSym ); if( cde == NULL ) return( NULL ); vm = cde->lfo + sizeof( unsigned_32 ); left = cde->cb - sizeof( unsigned_32 ); for( ;; ) { if( left <= 0 ) return( NULL ); rec = VMRecord( ii, vm ); if( rec->common.code == S_COMPILE ) return( &rec->f ); vm += rec->common.length + sizeof( rec->common.length ); left -= rec->common.length + sizeof( rec->common.length ); } }
static dip_status LoadMapping( imp_image_handle *ii ) { cv_directory_entry *cde; cv_sst_seg_map *map; size_t size; cde = FindDirEntry( ii, IMH_GBL, sstSegMap ); if( cde == NULL ) return( DS_ERR|DS_INFO_INVALID ); map = VMBlock( ii, cde->lfo, cde->cb ); if( map == NULL ) return( DS_ERR|DS_FAIL ); size = map->cSegLog * sizeof( map->segdesc[0] ); ii->mapping = DCAlloc( size ); if( ii->mapping == NULL ) return( DS_ERR|DS_NO_MEM ); map = VMBlock( ii, cde->lfo, cde->cb ); /* malloc might have unloaded */ memcpy( ii->mapping, &map->segdesc[0], size ); ii->map_count = map->cSegLog; return( DS_OK ); }
walk_result DIPENTRY DIPImpWalkFileList( imp_image_handle *ii, imp_mod_handle im, IMP_CUE_WKR *wk, imp_cue_handle *ic, void *d ) { cv_directory_entry *cde; cv_sst_src_module_header *hdr; cv_sst_src_module_file_table *fp; unsigned_32 *file_off; unsigned file_tab_size; unsigned file_tab_count; unsigned i; walk_result wr; if( im == MH_GBL ) return( WR_CONTINUE ); cde = FindDirEntry( ii, im, sstSrcModule ); if( cde == NULL ) return( WR_CONTINUE ); hdr = VMBlock( ii, cde->lfo, sizeof( *hdr ) ); if( hdr == NULL ) return( WR_FAIL ); file_tab_count = hdr->cFile; file_tab_size = file_tab_count * sizeof( unsigned_32 ); hdr = VMBlock( ii, cde->lfo, sizeof( *hdr ) + file_tab_size ); /* Make a copy of the file table offset so that we don't have to worry about the VM system throwing it out. */ file_off = __alloca( file_tab_size ); memcpy( file_off, &hdr->baseSrcFile[0], file_tab_size ); ic->im = im; for( i = 0; i < file_tab_count; ++i ) { ic->pair = 0; ic->file = cde->lfo + file_off[i]; fp = VMBlock( ii, ic->file, sizeof( *fp ) ); if( fp == NULL ) return( WR_FAIL ); ic->line = cde->lfo + fp->baseSrcLn[0]; wr = wk( ii, ic, d ); if( wr != WR_CONTINUE ) return( wr ); } return( WR_CONTINUE ); }
// FindEntry status_t Volume::FindEntry(const VNode *rootDir, const char *path, VNode *foundNode) { // Note: does not resolve links. PRINT(("Volume::FindEntry(`%s')\n", path)); status_t error = (rootDir && path && foundNode ? B_OK : B_BAD_VALUE); if (error == B_OK && (path[0] == '\0' || path[0] == '/')) error = B_ENTRY_NOT_FOUND; // start at the given root dir if (error == B_OK) *foundNode = *rootDir; // resolve until we hit the end of the string while (error == B_OK && path[0] != '\0') { PRINT((" remaining path: `%s'\n", path)); int32 len = strlen(path); // find the first `/' const char *componentNameEnd = strchr(path, '/'); if (!componentNameEnd) componentNameEnd = path + len; // get the name of the first component int32 componentLen = componentNameEnd - path; if (componentLen >= B_FILE_NAME_LENGTH) return B_NAME_TOO_LONG; char component[B_FILE_NAME_LENGTH]; strncpy(component, path, componentLen); component[componentLen] = '\0'; // get the component PRINT((" looking for dir entry: `%s'\n", component)); error = FindDirEntry(foundNode, component, foundNode); // skip trailing `/'s if (error == B_OK) { path = componentNameEnd; while (*path == '/') path++; } } PRINT(("Volume::FindEntry(`%s') done: %s\n", path, strerror(error))); return error; }