Lines Matching full:search

372  ***                              SEARCH INFO                               ***
436 // if set, limits search to registry keys with the specified Company
445 allocSearchInfoBuffer(SearchInfo *search, int wcharCount) in allocSearchInfoBuffer() argument
454 buffer->next = search->_buffer; in allocSearchInfoBuffer()
455 search->_buffer = buffer; in allocSearchInfoBuffer()
461 freeSearchInfo(SearchInfo *search) in freeSearchInfo() argument
463 struct _SearchInfoBuffer *b = search->_buffer; in freeSearchInfo()
464 search->_buffer = NULL; in freeSearchInfo()
489 dumpSearchInfo(SearchInfo *search) in dumpSearchInfo() argument
496 #define DEBUG(s) debug(DEBUGNAME(#s) L": %s\n", (search->s) ? (search->s) : L"(null)") in dumpSearchInfo()
497 #define DEBUG_2(s, sl) _debugStringAndLength((search->s), (search->sl), DEBUGNAME(#s)) in dumpSearchInfo()
498 #define DEBUG_BOOL(s) debug(DEBUGNAME(#s) L": %s\n", (search->s) ? L"True" : L"False") in dumpSearchInfo()
566 parseCommandLine(SearchInfo *search) in parseCommandLine() argument
568 if (!search || !search->originalCmdLine) { in parseCommandLine()
572 const wchar_t *argv0End = findArgv0End(search->originalCmdLine, -1); in parseCommandLine()
575 search->restOfCmdLine = argv0End; // will be first space after argv0 in parseCommandLine()
576 while (--tail != search->originalCmdLine) { in parseCommandLine()
588 if (tail == search->originalCmdLine && tail[0] == L'"') { in parseCommandLine()
591 // Without special cases, we can now fill in the search struct in parseCommandLine()
593 search->executableLength = -1; in parseCommandLine()
599 search->executable = L"python.exe"; in parseCommandLine()
600 search->allowExecutableOverride = true; in parseCommandLine()
601 search->allowDefaults = true; in parseCommandLine()
603 search->executable = L"pythonw.exe"; in parseCommandLine()
604 search->allowExecutableOverride = true; in parseCommandLine()
605 search->allowDefaults = true; in parseCommandLine()
606 search->windowed = true; in parseCommandLine()
608 search->executable = L"python_d.exe"; in parseCommandLine()
609 search->allowExecutableOverride = true; in parseCommandLine()
610 search->allowDefaults = true; in parseCommandLine()
612 search->executable = L"pythonw_d.exe"; in parseCommandLine()
613 search->allowExecutableOverride = true; in parseCommandLine()
614 search->allowDefaults = true; in parseCommandLine()
615 search->windowed = true; in parseCommandLine()
617 search->executable = L"python.exe"; in parseCommandLine()
618 search->tag = &tail[6]; in parseCommandLine()
619 search->tagLength = tailLen - 6; in parseCommandLine()
620 search->allowExecutableOverride = true; in parseCommandLine()
621 search->oldStyleTag = true; in parseCommandLine()
622 search->allowPyvenvCfg = true; in parseCommandLine()
624 search->executable = L"pythonw.exe"; in parseCommandLine()
625 search->tag = &tail[7]; in parseCommandLine()
626 search->tagLength = tailLen - 7; in parseCommandLine()
627 search->allowExecutableOverride = true; in parseCommandLine()
628 search->oldStyleTag = true; in parseCommandLine()
629 search->allowPyvenvCfg = true; in parseCommandLine()
630 search->windowed = true; in parseCommandLine()
632 search->executable = tail; in parseCommandLine()
633 search->executableLength = tailLen; in parseCommandLine()
634 search->allowPyvenvCfg = true; in parseCommandLine()
641 const wchar_t *arg = search->restOfCmdLine; in parseCommandLine()
652 search->tag = arg; in parseCommandLine()
653 search->tagLength = argLen; in parseCommandLine()
654 search->oldStyleTag = true; in parseCommandLine()
655 search->restOfCmdLine = tail; in parseCommandLine()
661 search->company = argStart; in parseCommandLine()
662 search->companyLength = (int)(tagStart - argStart); in parseCommandLine()
663 search->tag = tagStart + 1; in parseCommandLine()
665 search->tag = argStart; in parseCommandLine()
667 search->tagLength = (int)(tail - search->tag); in parseCommandLine()
668 search->allowDefaults = false; in parseCommandLine()
669 search->restOfCmdLine = tail; in parseCommandLine()
671 search->list = true; in parseCommandLine()
672 search->restOfCmdLine = tail; in parseCommandLine()
674 search->listPaths = true; in parseCommandLine()
675 search->restOfCmdLine = tail; in parseCommandLine()
677 search->help = true; in parseCommandLine()
688 arg = search->restOfCmdLine; in parseCommandLine()
691 search->scriptFile = arg; in parseCommandLine()
693 ++search->scriptFile; in parseCommandLine()
698 search->scriptFileLength = (int)(arg - search->scriptFile); in parseCommandLine()
706 _decodeShebang(SearchInfo *search, const char *buffer, int bufferLength, bool onlyUtf8, wchar_t **d… in _decodeShebang() argument
718 wchar_t *b = allocSearchInfoBuffer(search, wideLen + 1); in _decodeShebang()
756 searchPath(SearchInfo *search, const wchar_t *shebang, int shebangLength) in searchPath() argument
824 wchar_t *buf = allocSearchInfoBuffer(search, n + 1); in searchPath()
829 search->executablePath = buf; in searchPath()
830 search->executableArgs = &command[commandLength]; in searchPath()
831 search->executableArgsLength = shebangLength - commandLength; in searchPath()
875 _findCommand(SearchInfo *search, const wchar_t *command, int commandLength) in _findCommand() argument
884 wchar_t *path = allocSearchInfoBuffer(search, n + 1); in _findCommand()
889 search->executablePath = path; in _findCommand()
895 _useShebangAsExecutable(SearchInfo *search, const wchar_t *shebang, int shebangLength) in _useShebangAsExecutable() argument
925 wcsncpy_s(script, MAXLEN, search->scriptFile, search->scriptFileLength) || in _useShebangAsExecutable()
936 wchar_t *path = allocSearchInfoBuffer(search, n + 1); in _useShebangAsExecutable()
941 search->executablePath = path; in _useShebangAsExecutable()
943 search->executableArgs = &shebang[commandLength]; in _useShebangAsExecutable()
944 search->executableArgsLength = shebangLength - commandLength; in _useShebangAsExecutable()
951 checkShebang(SearchInfo *search) in checkShebang() argument
955 if (search->tag || !search->scriptFile) { in checkShebang()
959 if (search->scriptFileLength < 0) { in checkShebang()
960 search->scriptFileLength = (int)wcsnlen_s(search->scriptFile, MAXLEN); in checkShebang()
963 wchar_t *scriptFile = (wchar_t*)malloc(sizeof(wchar_t) * (search->scriptFileLength + 1)); in checkShebang()
968 wcsncpy_s(scriptFile, search->scriptFileLength + 1, in checkShebang()
969 search->scriptFile, search->scriptFileLength); in checkShebang()
1023 …int exitCode = _decodeShebang(search, start, (int)(b - start + (bytesRead == 0)), onlyUtf8, &sheba… in checkShebang()
1029 // Handle shebangs that we should search PATH for in checkShebang()
1030 exitCode = searchPath(search, shebang, shebangLength); in checkShebang()
1052 // Search for "python{command}" overrides. All templates end with in checkShebang()
1054 if (_findCommand(search, &command[-6], commandLength + 6)) { in checkShebang()
1055 search->executableArgs = &command[commandLength]; in checkShebang()
1056 search->executableArgsLength = shebangLength - commandLength; in checkShebang()
1058 commandLength + 6, &command[-6], search->executablePath); in checkShebang()
1062 search->tag = command; in checkShebang()
1063 search->tagLength = commandLength; in checkShebang()
1066 if (search->tagLength > 4) { in checkShebang()
1067 const wchar_t *suffix = &search->tag[search->tagLength - 4]; in checkShebang()
1069 search->tagLength -= 4; in checkShebang()
1074 if (search->tagLength > 2) { in checkShebang()
1075 const wchar_t *suffix = &search->tag[search->tagLength - 2]; in checkShebang()
1077 search->tagLength -= 2; in checkShebang()
1080 search->oldStyleTag = true; in checkShebang()
1081 search->executableArgs = &command[commandLength]; in checkShebang()
1082 search->executableArgsLength = shebangLength - commandLength; in checkShebang()
1083 if (search->tag && search->tagLength) { in checkShebang()
1085 commandLength, command, search->tagLength, search->tag); in checkShebang()
1099 if (_findCommand(search, shebang, commandLength)) { in checkShebang()
1100 search->executableArgs = &shebang[commandLength]; in checkShebang()
1101 search->executableArgsLength = shebangLength - commandLength; in checkShebang()
1103 commandLength, shebang, search->executablePath); in checkShebang()
1109 return _useShebangAsExecutable(search, shebang, shebangLength); in checkShebang()
1114 checkDefaults(SearchInfo *search) in checkDefaults() argument
1116 if (!search->allowDefaults) { in checkDefaults()
1121 if (search->tag && search->tagLength && !search->oldStyleTag) { in checkDefaults()
1129 if (!search->tag || !search->tagLength) { in checkDefaults()
1132 } else if (0 == wcsncmp(search->tag, L"3", search->tagLength)) { in checkDefaults()
1135 } else if (0 == wcsncmp(search->tag, L"2", search->tagLength)) { in checkDefaults()
1139 debug(L"# Cannot select defaults for tag '%.*s'\n", search->tagLength, search->tag); in checkDefaults()
1153 wchar_t *tag = allocSearchInfoBuffer(search, n + 1); in checkDefaults()
1160 search->tag = tag; in checkDefaults()
1161 search->tagLength = n; in checkDefaults()
1162 search->oldStyleTag = true; in checkDefaults()
1164 search->company = tag; in checkDefaults()
1165 search->companyLength = (int)(slash - tag); in checkDefaults()
1166 search->tag = slash + 1; in checkDefaults()
1167 search->tagLength = n - (search->companyLength + 1); in checkDefaults()
1168 search->oldStyleTag = false; in checkDefaults()
1172 search->lowPriorityTag = true; in checkDefaults()
1179 *** ENVIRONMENT SEARCH ***
1384 *** REGISTRY SEARCH ***
1451 _registryReadLegacyEnvironment(const SearchInfo *search, HKEY root, EnvironmentInfo *env, const wch… in _registryReadLegacyEnvironment() argument
1457 search->executable, in _registryReadLegacyEnvironment()
1458 search->executableLength in _registryReadLegacyEnvironment()
1464 if (search->windowed) { in _registryReadLegacyEnvironment()
1525 _registryReadEnvironment(const SearchInfo *search, HKEY root, EnvironmentInfo *env, const wchar_t *… in _registryReadEnvironment() argument
1536 return _registryReadLegacyEnvironment(search, root, env, fallbackArch); in _registryReadEnvironment()
1540 if (search->windowed) { in _registryReadEnvironment()
1580 _registrySearchTags(const SearchInfo *search, EnvironmentInfo **result, HKEY root, int sortKey, con… in _registrySearchTags() argument
1598 exitCode = _registryReadEnvironment(search, subkey, env, fallbackArch); in _registrySearchTags()
1619 registrySearch(const SearchInfo *search, EnvironmentInfo **result, HKEY root, int sortKey, const wc… in registrySearch() argument
1633 … if (search->limitToCompany && 0 != _compare(search->limitToCompany, -1, buffer, cchBuffer)) { in registrySearch()
1639 exitCode = _registrySearchTags(search, result, subkey, sortKey, buffer, fallbackArch); in registrySearch()
1648 *** APP PACKAGE SEARCH ***
1652 appxSearch(const SearchInfo *search, EnvironmentInfo **result, const wchar_t *packageFamilyName, co… in appxSearch() argument
1656 const wchar_t *exeName = search->executable; in appxSearch()
1657 if (!exeName || search->allowExecutableOverride) { in appxSearch()
1658 exeName = search->windowed ? L"pythonw.exe" : L"python.exe"; in appxSearch()
1715 explicitOverrideSearch(const SearchInfo *search, EnvironmentInfo **result) in explicitOverrideSearch() argument
1717 if (!search->executablePath) { in explicitOverrideSearch()
1726 int exitCode = copyWstr(&env->executablePath, search->executablePath); in explicitOverrideSearch()
1750 *** ACTIVE VIRTUAL ENVIRONMENT SEARCH ***
1754 virtualenvSearch(const SearchInfo *search, EnvironmentInfo **result) in virtualenvSearch() argument
1760 if (!n || !join(buffer, MAXLEN, L"Scripts") || !join(buffer, MAXLEN, search->executable)) { in virtualenvSearch()
1803 // Registry subkey to search
1805 // Registry hive to search
1879 collectEnvironments(const SearchInfo *search, EnvironmentInfo **result) in collectEnvironments() argument
1890 exitCode = explicitOverrideSearch(search, result); in collectEnvironments()
1895 exitCode = virtualenvSearch(search, result); in collectEnvironments()
1901 if (env && !(search->list || search->listPaths)) { in collectEnvironments()
1907 exitCode = registrySearch(search, result, root, info->sortKey, info->fallbackArch); in collectEnvironments()
1915 if (search->limitToCompany) { in collectEnvironments()
1916 debug(L"# Skipping APPX search due to PYLAUNCHER_LIMIT_TO_COMPANY\n"); in collectEnvironments()
1921 exitCode = appxSearch(search, result, info->familyName, info->tag, info->sortKey); in collectEnvironments()
2007 installEnvironment(const SearchInfo *search) in installEnvironment() argument
2010 if (!search->tag || !search->tagLength) { in installEnvironment()
2016 if (!search->oldStyleTag && in installEnvironment()
2017 search->company && search->companyLength && in installEnvironment()
2018 0 != _compare(search->company, search->companyLength, L"PythonCore", -1)) { in installEnvironment()
2019 debug(L"# Cannot install for company %.*s\n", search->companyLength, search->company); in installEnvironment()
2025 if (0 == _compare(search->tag, search->tagLength, info->tag, -1)) { in installEnvironment()
2079 _companyMatches(const SearchInfo *search, const EnvironmentInfo *env) in _companyMatches() argument
2081 if (!search->company || !search->companyLength) { in _companyMatches()
2084 return 0 == _compare(env->company, -1, search->company, search->companyLength); in _companyMatches()
2089 _tagMatches(const SearchInfo *search, const EnvironmentInfo *env, int searchTagLength) in _tagMatches() argument
2092 searchTagLength = search->tagLength; in _tagMatches()
2094 if (!search->tag || !searchTagLength) { in _tagMatches()
2097 return _startsWithSeparated(env->tag, -1, search->tag, searchTagLength, L".-"); in _tagMatches()
2112 _selectEnvironment(const SearchInfo *search, EnvironmentInfo *env, EnvironmentInfo **best) in _selectEnvironment() argument
2116 exitCode = _selectEnvironment(search, env->prev, best); in _selectEnvironment()
2124 if (env->highPriority && search->lowPriorityTag) { in _selectEnvironment()
2125 // This environment is marked high priority, and the search allows in _selectEnvironment()
2133 if (!search->oldStyleTag) { in _selectEnvironment()
2134 if (_companyMatches(search, env) && _tagMatches(search, env, -1)) { in _selectEnvironment()
2147 int tagLength = search->tagLength; in _selectEnvironment()
2150 if (0 == _compareArgument(&search->tag[tagLength - 3], 3, L"-64", 3)) { in _selectEnvironment()
2153 } else if (0 == _compareArgument(&search->tag[tagLength - 3], 3, L"-32", 3)) { in _selectEnvironment()
2159 if (_tagMatches(search, env, tagLength)) { in _selectEnvironment()
2177 selectEnvironment(const SearchInfo *search, EnvironmentInfo *root, EnvironmentInfo **best) in selectEnvironment() argument
2188 int exitCode = _selectEnvironment(search, root, &result); in selectEnvironment()
2322 calculateCommandLine(const SearchInfo *search, const EnvironmentInfo *launch, wchar_t *buffer, int … in calculateCommandLine() argument
2327 // Construct command line from a search override, or else the selected in calculateCommandLine()
2329 if (search->executablePath) { in calculateCommandLine()
2330 executablePath = search->executablePath; in calculateCommandLine()
2336 // only if the search allowed an override. in calculateCommandLine()
2337 // Otherwise, use the environment's installDir and the search's default in calculateCommandLine()
2339 if (executablePath && search->allowExecutableOverride) { in calculateCommandLine()
2354 } else if (!search->executable || !search->executableLength) { in calculateCommandLine()
2360 wcsncpy_s(executable, 256, search->executable, search->executableLength); in calculateCommandLine()
2389 if (!exitCode && search->executableArgs) { in calculateCommandLine()
2390 if (search->executableArgsLength < 0) { in calculateCommandLine()
2391 exitCode = wcscat_s(buffer, bufferLength, search->executableArgs); in calculateCommandLine()
2392 } else if (search->executableArgsLength > 0) { in calculateCommandLine()
2394 if (end < bufferLength - (search->executableArgsLength + 1)) { in calculateCommandLine()
2396 search->executableArgs, search->executableArgsLength); in calculateCommandLine()
2401 if (!exitCode && search->restOfCmdLine) { in calculateCommandLine()
2402 exitCode = wcscat_s(buffer, bufferLength, search->restOfCmdLine); in calculateCommandLine()
2441 launchEnvironment(const SearchInfo *search, const EnvironmentInfo *launch, wchar_t *launchCommand) in launchEnvironment() argument
2537 performSearch(SearchInfo *search, EnvironmentInfo **envs) in performSearch() argument
2540 int exitCode = parseCommandLine(search); in performSearch()
2547 exitCode = checkShebang(search); in performSearch()
2559 exitCode = checkDefaults(search); in performSearch()
2564 // If debugging is enabled, list our search criteria in performSearch()
2565 dumpSearchInfo(search); in performSearch()
2568 exitCode = collectEnvironments(search, envs); in performSearch()
2582 SearchInfo search = {0}; in process() local
2597 wchar_t *limitToCompany = allocSearchInfoBuffer(&search, len); in process()
2598 search.limitToCompany = limitToCompany; in process()
2606 search.originalCmdLine = GetCommandLineW(); in process()
2608 exitCode = performSearch(&search, &envs); in process()
2614 if (search.help) { in process()
2624 searchExitCode = selectEnvironment(&search, envs, &env); in process()
2627 if (search.list || search.listPaths) { in process()
2628 exitCode = listEnvironments(envs, stdout, search.listPaths, env); in process()
2645 exitCode = installEnvironment(&search); in process()
2649 exitCode = performSearch(&search, &envs); in process()
2653 exitCode = selectEnvironment(&search, envs, &env); in process()
2659 if (!isEnvVarSet(L"PYLAUNCHER_ALLOW_INSTALL") && search.oldStyleTag) { in process()
2679 …exitCode = calculateCommandLine(&search, env, launchCommand, sizeof(launchCommand) / sizeof(launch… in process()
2685 exitCode = launchEnvironment(&search, env, launchCommand); in process()
2688 freeSearchInfo(&search); in process()