void IRCArgumentParser::FillInfo() { // fill in info based on option _info.is_verbose = false; for (auto iarg = 1; iarg < _argc; iarg += 2) { const _TCHAR* content = nullptr; if (iarg + 1 < _argc) content = _argv[iarg + 1]; switch (_argv[iarg][1]) { case _T('h'): // host ip:port ParseHostName(content); break; case _T('u'): // username and nickname NameCopy(content, _info.username); NameCopy(content, _info.nickname); break; case _T('n'): // real name NameCopy(content, _info.realname); break; case _T('p'): // password NameCopy(content, _info.password); break; case _T('v'): // verbose iarg -= 1; _info.is_verbose = true; break; } } }
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 ) ); }
size_t DIPIMPENTRY( CueFile )( imp_image_handle *ii, imp_cue_handle *ic, char *buff, size_t buff_size ) /************************************************************************/ { char *name; file_walk_name wlk; size_t len; drmem_hdl stmts; drmem_hdl cu_tag; int i; mod_info *modinfo; DRSetDebug( ii->dwarf->handle ); /* must do at each call into dwarf */ modinfo = IMH2MODI( ii, ic->im ); stmts = modinfo->stmts; cu_tag = modinfo->cu_tag; if( stmts == DRMEM_HDL_NULL || cu_tag == DRMEM_HDL_NULL ) { DCStatus( DS_FAIL ); return( 0 ); } wlk.index = ic->fno; wlk.ret = NULL; wlk.num_dirs = 0; wlk.dirs = NULL; DRWalkLFiles( stmts, ACueFile, &wlk, ACueDir, &wlk ); name = wlk.ret; // Free directory and file table information for( i = 0; i < wlk.num_dirs; i++ ) { DCFree( wlk.dirs[i].name ); } DCFree( wlk.dirs ); if( name == NULL ) { DCStatus( DS_FAIL ); return( 0 ); } // If compilation unit has a DW_AT_comp_dir attribute, we need to // stuff that in front of the file pathname, unless that is absolute len = DRGetCompDirBuff( cu_tag, buff, buff_size ); if( ( len > 1 ) && IsRelPathname( name ) ) { // Ignore empty comp dirs len = NameCopy( buff, "/", buff_size, len ); } else { len = 0; } len = NameCopy( buff, name, buff_size, len ); DCFree( name ); return( len ); }
unsigned DIGENTRY DIPImpModName( imp_image_handle *ii, imp_mod_handle im, char *buff, unsigned max ) { ji_ptr name; unsigned len; name = GetPointer( ii->cc + offsetof( ClassClass, name ) ); len = GetString( name, NameBuff, sizeof( NameBuff ) ); NormalizeClassName( NameBuff, len ); return( NameCopy( buff, NameBuff, max, len ) ); }
unsigned DIGENTRY DIPImpModName( imp_image_handle *ii, imp_mod_handle im, char *buff, unsigned max ) { char *name; unsigned len; if( im == IMH_NOMOD || (name = IM2MODI( ii, im )->name) == NULL ) { DCStatus( DS_FAIL ); return( 0 ); } len = NameCopy( buff, name, max ); return( len ); }
size_t DIGENTRY DIPImpModName( imp_image_handle *ii, imp_mod_handle im, char *buff, size_t buff_size ) { char *name; size_t len; if( im == IMH_NOMOD || (name = IMH2MODI( ii, im )->name) == NULL ) { DCStatus( DS_FAIL ); return( 0 ); } len = NameCopy( buff, name, buff_size, 0 ); return( len ); }
unsigned DIPENTRY DIPImpCueFile( imp_image_handle *ii, imp_cue_handle *ic, char *buff, unsigned max ) { void *p; unsigned_16 name_len; cv_sst_src_module_file_table *fp; virt_mem offset; offset = ic->file; fp = VMBlock( ii, offset, sizeof( *fp ) ); if( fp == 0 ) return( 0 ); offset += offsetof( cv_sst_src_module_file_table, baseSrcLn ) + (fp->cSeg * (sizeof( unsigned_32 ) * 3)); p = VMBlock( ii, offset, sizeof( unsigned_16 ) ); if( p == NULL ) return( 0 ); /* Doc says the length is unsigned_16, cvpack says 8. */ name_len = *(unsigned_8 *)p; p = VMBlock( ii, offset + sizeof( unsigned_8 ), name_len ); if( p == NULL ) return( 0 ); return( NameCopy( buff, p, max, name_len ) ); }
unsigned DIGENTRY DIPImpSymName( imp_image_handle *ii, imp_sym_handle *is, location_context *lc, symbol_name sn, char *buff, unsigned max ) { unsigned len; ji_ptr sig; len = GetName( ii, is ); switch( is->kind ) { case JS_METHOD: if( sn == SN_DEMANGLED ) { sig = GetSignature( ii, is ); if( sig != 0 ) { len = Demangle( NameBuff, len, sig ); } } break; case JS_TYPE: case JS_PACKAGE: NormalizeClassName( NameBuff, len ); break; } return( NameCopy( buff, NameBuff, max, len ) ); }
unsigned DIGENTRY DIPImpTypeName( imp_image_handle *ii, imp_type_handle *it, unsigned num, symbol_type *tag, char *buff, unsigned buff_size ) { /* Given the imp_type_handle, copy the name of the type into 'buff'. Do not copy more than 'buff_size' - 1 characters into the buffer and append a trailing '\0' character. Return the real length of the type name (not including the trailing '\0' character) even if you had to truncate it to fit it into the buffer. If something went wrong and you can't get the type name, call DCStatus and return zero. NOTE: the client might pass in zero for 'buff_size'. In that case, just return the length of the module name and do not attempt to put anything into the buffer. Since there can be a "string" of typedef names associated with a type_handle, the 'num' parm indicates which one of the names the client wants returned. Zero is the first type name, one is the second, etc. Fill in '*tag' with ST_ENUM_TAG, ST_UNION_TAG, ST_STRUCT_TAG, ST_CLASS_TAG if the name is a enum, union, struct, or class tag name respectively. If not, set '*tag' to ST_NONE. If the type does not have a name, return zero. */ char *name = NULL; dr_handle dr_type; dr_typeinfo typeinfo; unsigned len; DRSetDebug( ii->dwarf->handle ); /* must do at each call into dwarf */ ++num; len = 0; dr_type = it->type; while( dr_type != DR_HANDLE_NUL ) { name = DRGetName( dr_type ); if( name != NULL ) { if( --num == 0 ) break; DCFree( name ); } dr_type = DRGetTypeAT( dr_type ); } if( num == 0 ) { DRGetTypeInfo( dr_type, &typeinfo ); switch( typeinfo.kind ) { case DR_TYPEK_ENUM: *tag = ST_ENUM_TAG; break; case DR_TYPEK_STRUCT: *tag = ST_STRUCT_TAG; break; case DR_TYPEK_UNION: *tag = ST_UNION_TAG; break; case DR_TYPEK_CLASS: *tag = ST_CLASS_TAG; break; default: *tag = ST_NONE; break; } len = NameCopy( buff, name, buff_size, 0 ); DCFree( name ); } return( len ); }
unsigned DIPENTRY DIPImpCueFile( imp_image_handle *ii, imp_cue_handle *ic, char *buff, unsigned max ) /********************************************************************/ { char *name; char *dir_path; file_walk_name wlk; unsigned len; unsigned dir_len; im_idx imx; dr_handle stmts; dr_handle cu_handle; int i; imx = ic->imx; DRSetDebug( ii->dwarf->handle ); /* must do at each call into dwarf */ stmts = ii->mod_map[imx].stmts; if( stmts == 0 ) { DCStatus( DS_FAIL ); return( 0 ); } cu_handle = ii->mod_map[imx].cu_tag; if( cu_handle == 0 ) { DCStatus( DS_FAIL ); return( 0 ); } wlk.index = ic->fno; wlk.ret = NULL; wlk.num_dirs = 0; wlk.dirs = NULL; DRWalkLFiles( stmts, ACueFile, &wlk, ACueDir, &wlk ); name = wlk.ret; // Free directory and file table information for( i = 0; i < wlk.num_dirs; i++) DCFree(wlk.dirs[i].name); DCFree(wlk.dirs); if( name == NULL ) { DCStatus( DS_FAIL ); return( 0 ); } // If compilation unit has a DW_AT_comp_dir attribute, we need to // stuff that in front of the file pathname, unless that is absolute dir_len = DRGetCompDirBuff( cu_handle, NULL, 0 ); if( (dir_len > 1) && IsRelPathname( name ) ) { // Ignore empty comp dirs if( max == 0 ) { len = NameCopy( buff, name, max ) + dir_len; } else { dir_path = DCAlloc( dir_len ); if( dir_path == NULL ) { DCStatus( DS_FAIL ); return( 0 ); } DRGetCompDirBuff( cu_handle, dir_path, dir_len ); len = NameCopy( buff, dir_path, max ); DCFree( dir_path ); if( max > len + 1 ) { len += NameCopy( buff + len, "/", 1 + 1 ); len += NameCopy( buff + len, name, max - len ); } } } else { len = NameCopy( buff, name, max ); } DCFree( name ); return( len ); }