int PathArray::GetMultiPath(void *multi_path, int max_len, const void *separator, const void *escape_char) { void *buf = multi_path; void *FMT_STRSTR_V = IS_WINNT_V ? (void *)L"%s%s" : (void *)"%s%s"; int sep_len = strlenV(separator); int total_len = 0; int escape_val = escape_char ? GetChar(escape_char, 0) : 0; for (int i=0; i < num; i++) { BOOL is_escape = escape_val && strchrV(pathArray[i]->path, escape_val); int need_len = pathArray[i]->len + 1 + (is_escape ? 2 : 0) + (i ? sep_len : 0); if (max_len - total_len < need_len) { SetChar(multi_path, total_len, 0); return -1; } if (i) { memcpy(MakeAddr(buf, total_len), separator, sep_len * CHAR_LEN_V); total_len += sep_len; } if (is_escape) { SetChar(buf, total_len, '"'); total_len++; } memcpy(MakeAddr(buf, total_len), pathArray[i]->path, pathArray[i]->len * CHAR_LEN_V); total_len += pathArray[i]->len; if (is_escape) { SetChar(buf, total_len, '"'); total_len++; } } SetChar(multi_path, total_len, 0); return total_len; }
BOOL TMakeVirtualStorePathV(void *org_path, void *buf) { if (!IsWinVista()) return FALSE; if (!TIsVirtualizedDirV(org_path) || !TSHGetSpecialFolderPathV(NULL, buf, CSIDL_LOCAL_APPDATA, FALSE) || GetChar(org_path, 1) != ':' || GetChar(org_path, 2) != '\\') { strcpyV(buf, org_path); return FALSE; } sprintfV(MakeAddr(buf, strlenV(buf)), L"\\VirtualStore%s", MakeAddr(org_path, 2)); return TRUE; }
HWND ShowHelpV(HWND hOwner, void *help_dir, void *help_file, void *section) { #if defined(ENABLE_HTML_HELP) static HWND (WINAPI *pHtmlHelpV)(HWND, void *, UINT, DWORD_PTR) = NULL; if (pHtmlHelpV == NULL) { DWORD cookie=0; HMODULE hHtmlHelp = TLoadLibrary("hhctrl.ocx"); if (hHtmlHelp) pHtmlHelpV = (HWND (WINAPI *)(HWND, void *, UINT, DWORD_PTR)) ::GetProcAddress(hHtmlHelp, IS_WINNT_V ? "HtmlHelpW" : "HtmlHelpA"); if (pHtmlHelpV) pHtmlHelpV(NULL, NULL, HH_INITIALIZE, (DWORD)&cookie); } if (pHtmlHelpV) { WCHAR path[MAX_PATH]; MakePathV(path, help_dir, help_file); if (section) strcpyV(MakeAddr(path, strlenV(path)), section); return pHtmlHelpV(hOwner, path, HH_DISPLAY_TOC, 0); } #endif return NULL; }
void MakeMemoryAddr( bool pops, memory_expr def_seg, address *val ) { if( ExprSP->flags & SF_LOCATION ) { ExprSP->flags &= ~(SF_LOCATION|SF_IMP_ADDR); ExprSP->v.addr = ExprSP->v.loc.e[0].u.addr; ExprSP->info.kind = TK_ADDRESS; ExprSP->info.modifier = TM_FAR; } switch( ExprSP->info.kind ) { case TK_ADDRESS: case TK_POINTER: if( (ExprSP->info.modifier & TM_MOD_MASK) != TM_NEAR ) break; /* fall through */ default: DefAddr( def_seg, val ); AddrFix( val ); //NYI: lost address abstraction PushInt( val->mach.segment ); SwapStack( 1 ); MakeAddr(); } *val = ExprSP->v.addr; AddrFloat( val ); if( pops ) PopEntry(); }
BOOL ConvertToX86Dir(void *target) { WCHAR buf[MAX_PATH]; WCHAR buf86[MAX_PATH]; int len; if (!TSHGetSpecialFolderPathV(NULL, buf, CSIDL_PROGRAM_FILES, FALSE)) return FALSE; len = strlenV(buf); SetChar(buf, len++, '\\'); SetChar(buf, len, 0); if (strnicmpV(buf, target, len)) return FALSE; if (!TSHGetSpecialFolderPathV(NULL, buf86, CSIDL_PROGRAM_FILESX86, FALSE)) return FALSE; MakePathV(buf, buf86, MakeAddr(target, len)); strcpyV(target, buf); return TRUE; }
/*========================================================================= 拡張 strtok() "" に出くわすと、"" の中身を取り出す token の前後に空白があれば取り除く それ以外は、strtok_r() と同じ =========================================================================*/ void *strtok_pathV(void *str, const void *sep, void **p, BOOL remove_quote) { const void *quote=QUOTE_V, *org_sep = sep; if (str) *p = str; else str = *p; if (!*p) return NULL; // 頭だし while (GetChar(str, 0) && (strchrV(sep, GetChar(str, 0)) || GetChar(str, 0) == ' ')) str = MakeAddr(str, 1); if (GetChar(str, 0) == 0) return NULL; // 終端検出 void *in = str, *out = str; for ( ; GetChar(in, 0); in = MakeAddr(in, 1)) { BOOL is_set = FALSE; if (sep == org_sep) { // 通常 mode if (strchrV(sep, GetChar(in, 0))) { break; } else if (GetChar(in, 0) == '"') { if (!remove_quote) { is_set = TRUE; } sep = quote; // quote mode に遷移 } else { is_set = TRUE; } } else { // quote mode if (GetChar(in, 0) == '"') { sep = org_sep; // 通常 mode に遷移 if (!remove_quote) { is_set = TRUE; } } else { is_set = TRUE; } } if (is_set) { SetChar(out, 0, GetChar(in, 0)); out = MakeAddr(out, 1); } } *p = GetChar(in, 0) ? MakeAddr(in, 1) : NULL; SetChar(out, 0, 0); // 末尾の空白を取り除く for (out = MakeAddr(out, -1); out >= str && GetChar(out, 0) == ' '; out = MakeAddr(out, -1)) SetChar(out, 0, 0); return str; }
static unsigned MechDo( unsigned select, unsigned parm ) { unsigned long size; unsigned result = 0; DIPHDL( type, th ); dip_type_info info; mad_type_info mti; switch( select ) { case 0: DoAssign(); break; case 1: DoMul(); break; case 2: DoDiv(); break; case 3: DoMod(); break; case 4: DoMinus(); break; case 5: DoShift(); break; case 6: DoAnd(); break; case 7: DoXor(); break; case 8: DoOr(); break; case 9: DoAddr(); break; case 10: ClassToTypeInfo( parm, &info ); DoPoints( info.kind ); break; case 11: DoField(); break; case 12: DoCall( Num, parm ); break; case 13: DoConvert(); break; case 14: DoPlus(); break; case 15: MakeAddr(); break; case 16: result = TstEQ( parm ); break; case 17: result = TstLT( parm ); break; case 18: result = TstTrue( parm ); break; case 19: result = TstExist( parm ); break; case 20: size = ExprSP->info.size; PopEntry(); PushNum( size ); break; case 21: TypeBase( ExprSP->th, th, NULL, NULL ); PopEntry(); PushType( th ); break; case 22: GetMADTypeDefault( MTK_ADDRESS, &mti ); size = (mti.b.bits - mti.a.seg.bits) / BITS_PER_BYTE; if( parm ) { size += sizeof( addr_seg ); TypePointer( ExprSP->th, TM_FAR, size, th ); } else { TypePointer( ExprSP->th, TM_NEAR, size, th ); } PopEntry(); PushType( th ); break; case 23: result = UserType( th ); if( result ) { PopEntry(); PushType( th ); } break; case 24: DoMakeComplex(); break; case 25: DoStringConcat(); break; case 26: DoLConvert(); break; case 27: DoPlusScaled(); break; case 28: DoMinusScaled(); break; case 29: DoPoints( TI_KIND_EXTRACT( parm ) ); break; case 30: info.kind = TK_POINTER; info.size = TI_SIZE_EXTRACT( parm ); info.modifier = TI_MOD_EXTRACT( parm ); FillInDefaults( &info ); TypePointer( ExprSP->th, info.modifier, info.size, th ); PopEntry(); PushType( th ); break; case 31: if( parm ) { /* file scope */ if( ExprSP->flags & SF_NAME ) { ExprSP->v.li.file_scope = TRUE; } else { Error( ERR_LOC, LIT( ERR_WANT_NAME ) ); } } else { /* in a namespace */ DoScope(); } break; } return( result ); }
static ssl_value MechDo( unsigned select, ssl_value parm ) { unsigned long size; ssl_value result; DIPHDL( type, th ); dig_type_info ti; mad_type_info mti; result = 0; switch( select ) { case 0: DoAssign(); break; case 1: DoMul(); break; case 2: DoDiv(); break; case 3: DoMod(); break; case 4: DoMinus(); break; case 5: DoShift(); break; case 6: DoAnd(); break; case 7: DoXor(); break; case 8: DoOr(); break; case 9: DoAddr(); break; case 10: ClassToTypeInfo( parm, &ti ); DoPoints( ti.kind ); break; case 11: DoField(); break; case 12: DoCall( Num, SSL2BOOL( parm ) ); break; case 13: DoConvert(); break; case 14: DoPlus(); break; case 15: MakeAddr(); break; case 16: result = ( TstEQ( SSL2INT( parm ) ) != 0 ); break; case 17: result = ( TstLT( SSL2INT( parm ) ) != 0 ); break; case 18: result = ( TstTrue( SSL2INT( parm ) ) != 0 ); break; case 19: result = ( TstExist( SSL2INT( parm ) ) != 0 ); break; case 20: size = ExprSP->ti.size; PopEntry(); PushNum( size ); break; case 21: DIPTypeBase( ExprSP->th, th, NULL, NULL ); PopEntry(); PushType( th ); break; case 22: GetMADTypeDefault( MTK_ADDRESS, &mti ); size = BITS2BYTES( mti.b.bits - mti.a.seg.bits ); if( parm ) { size += sizeof( addr_seg ); DIPTypePointer( ExprSP->th, TM_FAR, size, th ); } else { DIPTypePointer( ExprSP->th, TM_NEAR, size, th ); } PopEntry(); PushType( th ); break; case 23: result = UserType( th ); if( result ) { PopEntry(); PushType( th ); } break; case 24: DoMakeComplex(); break; case 25: DoStringConcat(); break; case 26: DoLConvert(); break; case 27: DoPlusScaled(); break; case 28: DoMinusScaled(); break; case 29: DoPoints( TI_KIND_EXTRACT( parm ) ); break; case 30: ti.kind = TK_POINTER; ti.size = TI_SIZE_EXTRACT( parm ); ti.modifier = TI_MOD_EXTRACT( parm ); ti.deref = false; FillInDefaults( &ti ); DIPTypePointer( ExprSP->th, ti.modifier, ti.size, th ); PopEntry(); PushType( th ); break; case 31: if( SSL2BOOL( parm ) ) { /* file scope */ if( ExprSP->flags & SF_NAME ) { ExprSP->v.li.file_scope = true; } else { Error( ERR_LOC, LIT_ENG( ERR_WANT_NAME ) ); } } else { /* in a namespace */ DoScope(); } break; } return( result ); }