static ptr s_GetRegistry(wchar_t *s) { HKEY key, result; wchar_t *subkey, *last; DWORD rc, type, size; ptr ans; SplitRegistryKey("get-registry", s, &key, &subkey, &last); /* open the key */ if (last == subkey) { rc = RegOpenKeyExW(key, L"", 0, KEY_QUERY_VALUE, &result); } else { *last = '\0'; /* Truncate subkey at backslash */ rc = RegOpenKeyExW(key, subkey, 0, KEY_QUERY_VALUE, &result); *last++ = '\\'; /* Restore backslash */ } if (rc != ERROR_SUCCESS) return Sfalse; /* Get the size of the value */ rc = RegQueryValueExW(result, last, NULL, &type, NULL, &size); if (rc != ERROR_SUCCESS) { RegCloseKey(result); return Sfalse; } /* Allocate a Scheme bytevector of the proper size */ ans = S_bytevector(size); /* Load up the bytevector */ rc = RegQueryValueExW(result, last, NULL, &type, &BVIT(ans,0), &size); RegCloseKey(result); if (rc != ERROR_SUCCESS) return Sfalse; /* discard unwanted terminating null character, if present */ if (((type == REG_SZ) || (type == REG_EXPAND_SZ)) && (size >= 2) && (*(wchar_t*)(&BVIT(ans, size-2)) == 0)) BYTEVECTOR_TYPE(ans) = ((size-2) << bytevector_length_offset) | type_bytevector; return ans; }
static void main_init() { ptr tc = get_thread_context(); ptr p; INT i; /* force thread inline allocation to go through find_room until ready */ AP(tc) = (ptr)0; EAP(tc) = (ptr)0; REAL_EAP(tc) = (ptr)0; /* set up dummy CP so locking in read/write/Scall won't choke */ CP(tc) = Svoid; CODERANGESTOFLUSH(tc) = Snil; if (S_boot_time) S_G.protect_next = 0; S_segment_init(); S_alloc_init(); S_thread_init(); S_intern_init(); S_gc_init(); S_number_init(); S_schsig_init(); S_new_io_init(); S_print_init(); S_stats_init(); S_foreign_init(); S_prim_init(); S_prim5_init(); S_fasl_init(); S_machine_init(); S_flushcache_init(); /* must come after S_machine_init(); */ #ifdef FEATURE_EXPEDITOR S_expeditor_init(); #endif /* FEATURE_EXPEDITOR */ if (!S_boot_time) return; FXLENGTHBV(tc) = p = S_bytevector(256); for (i = 0; i < 256; i += 1) { BVIT(p, i) = (iptr)FIX(i & 0x80 ? 8 : i & 0x40 ? 7 : i & 0x20 ? 6 : i & 0x10 ? 5 : i & 0x08 ? 4 : i & 0x04 ? 3 : i & 0x02 ? 2 : i & 0x01 ? 1 : 0); } FXFIRSTBITSETBV(tc) = p = S_bytevector(256); for (i = 0; i < 256; i += 1) { BVIT(p, i) = (iptr)FIX(i & 0x01 ? 0 : i & 0x02 ? 1 : i & 0x04 ? 2 : i & 0x08 ? 3 : i & 0x10 ? 4 : i & 0x20 ? 5 : i & 0x40 ? 6 : i & 0x80 ? 7 : 0); } NULLIMMUTABLEVECTOR(tc) = S_null_immutable_vector(); NULLIMMUTABLEFXVECTOR(tc) = S_null_immutable_fxvector(); NULLIMMUTABLEBYTEVECTOR(tc) = S_null_immutable_bytevector(); NULLIMMUTABLESTRING(tc) = S_null_immutable_string(); PARAMETERS(tc) = S_G.null_vector; for (i = 0 ; i < virtual_register_count ; i += 1) { VIRTREG(tc, i) = FIX(0); } p = S_code(tc, type_code, size_rp_header); CODERELOC(p) = S_relocation_table(0); CODENAME(p) = Sfalse; CODEARITYMASK(p) = FIX(0); CODEFREE(p) = 0; CODEINFO(p) = Sfalse; CODEPINFOS(p) = Snil; RPHEADERFRAMESIZE(&CODEIT(p, 0)) = 0; RPHEADERLIVEMASK(&CODEIT(p, 0)) = 0; RPHEADERTOPLINK(&CODEIT(p, 0)) = (uptr)&RPHEADERTOPLINK(&CODEIT(p, 0)) - (uptr)p; S_protect(&S_G.dummy_code_object); S_G.dummy_code_object = p; S_protect(&S_G.error_invoke_code_object); S_G.error_invoke_code_object = Snil; S_protect(&S_G.invoke_code_object); S_G.invoke_code_object = Snil; S_protect(&S_G.active_threads_id); S_G.active_threads_id = S_intern((const unsigned char *)"$active-threads"); S_set_symbol_value(S_G.active_threads_id, FIX(0)); S_protect(&S_G.heap_reserve_ratio_id); S_G.heap_reserve_ratio_id = S_intern((const unsigned char *)"$heap-reserve-ratio"); SETSYMVAL(S_G.heap_reserve_ratio_id, Sflonum(default_heap_reserve_ratio)); S_protect(&S_G.scheme_version_id); S_G.scheme_version_id = S_intern((const unsigned char *)"$scheme-version"); S_protect(&S_G.make_load_binary_id); S_G.make_load_binary_id = S_intern((const unsigned char *)"$make-load-binary"); S_protect(&S_G.load_binary); S_G.load_binary = Sfalse; }