Lines Matching full:search
379 *** SEARCH INFO ***
443 // if set, limits search to registry keys with the specified Company
452 allocSearchInfoBuffer(SearchInfo *search, int wcharCount) in allocSearchInfoBuffer() argument
461 buffer->next = search->_buffer; in allocSearchInfoBuffer()
462 search->_buffer = buffer; in allocSearchInfoBuffer()
468 freeSearchInfo(SearchInfo *search) in freeSearchInfo() argument
470 struct _SearchInfoBuffer *b = search->_buffer; in freeSearchInfo()
471 search->_buffer = NULL; in freeSearchInfo()
496 dumpSearchInfo(SearchInfo *search) in dumpSearchInfo() argument
507 #define DEBUG(s) debug(L"SearchInfo." DEBUGNAME(s) L": %s\n", (search->s) ? (search->s) : L"(null)") in dumpSearchInfo()
508 #define DEBUG_2(s, sl) _debugStringAndLength((search->s), (search->sl), L"SearchInfo." DEBUGNAME(s)) in dumpSearchInfo()
509 #define DEBUG_BOOL(s) debug(L"SearchInfo." DEBUGNAME(s) L": %s\n", (search->s) ? L"True" : L"False") in dumpSearchInfo()
592 parseCommandLine(SearchInfo *search) in parseCommandLine() argument
594 if (!search || !search->originalCmdLine) { in parseCommandLine()
598 const wchar_t *argv0End = findArgv0End(search->originalCmdLine, -1); in parseCommandLine()
601 search->restOfCmdLine = argv0End; // will be first space after argv0 in parseCommandLine()
602 while (--tail != search->originalCmdLine) { in parseCommandLine()
614 if (tail == search->originalCmdLine && tail[0] == L'"') { in parseCommandLine()
617 // Without special cases, we can now fill in the search struct in parseCommandLine()
619 search->executableLength = -1; in parseCommandLine()
625 search->executable = L"python.exe"; in parseCommandLine()
626 search->allowExecutableOverride = true; in parseCommandLine()
627 search->allowDefaults = true; in parseCommandLine()
629 search->executable = L"pythonw.exe"; in parseCommandLine()
630 search->allowExecutableOverride = true; in parseCommandLine()
631 search->allowDefaults = true; in parseCommandLine()
632 search->windowed = true; in parseCommandLine()
634 search->executable = L"python_d.exe"; in parseCommandLine()
635 search->allowExecutableOverride = true; in parseCommandLine()
636 search->allowDefaults = true; in parseCommandLine()
638 search->executable = L"pythonw_d.exe"; in parseCommandLine()
639 search->allowExecutableOverride = true; in parseCommandLine()
640 search->allowDefaults = true; in parseCommandLine()
641 search->windowed = true; in parseCommandLine()
643 search->executable = L"python.exe"; in parseCommandLine()
644 search->tag = &tail[6]; in parseCommandLine()
645 search->tagLength = tailLen - 6; in parseCommandLine()
646 search->allowExecutableOverride = true; in parseCommandLine()
647 search->oldStyleTag = true; in parseCommandLine()
648 search->allowPyvenvCfg = true; in parseCommandLine()
650 search->executable = L"pythonw.exe"; in parseCommandLine()
651 search->tag = &tail[7]; in parseCommandLine()
652 search->tagLength = tailLen - 7; in parseCommandLine()
653 search->allowExecutableOverride = true; in parseCommandLine()
654 search->oldStyleTag = true; in parseCommandLine()
655 search->allowPyvenvCfg = true; in parseCommandLine()
656 search->windowed = true; in parseCommandLine()
658 search->executable = tail; in parseCommandLine()
659 search->executableLength = tailLen; in parseCommandLine()
660 search->allowPyvenvCfg = true; in parseCommandLine()
667 const wchar_t *arg = search->restOfCmdLine; in parseCommandLine()
678 search->tag = arg; in parseCommandLine()
679 search->tagLength = argLen; in parseCommandLine()
680 search->oldStyleTag = true; in parseCommandLine()
681 search->restOfCmdLine = tail; in parseCommandLine()
687 search->company = argStart; in parseCommandLine()
688 search->companyLength = (int)(tagStart - argStart); in parseCommandLine()
689 search->tag = tagStart + 1; in parseCommandLine()
691 search->tag = argStart; in parseCommandLine()
693 search->tagLength = (int)(tail - search->tag); in parseCommandLine()
694 search->allowDefaults = false; in parseCommandLine()
695 search->restOfCmdLine = tail; in parseCommandLine()
697 search->list = true; in parseCommandLine()
698 search->restOfCmdLine = tail; in parseCommandLine()
700 search->listPaths = true; in parseCommandLine()
701 search->restOfCmdLine = tail; in parseCommandLine()
703 search->help = true; in parseCommandLine()
714 arg = search->restOfCmdLine; in parseCommandLine()
717 search->scriptFile = arg; in parseCommandLine()
719 ++search->scriptFile; in parseCommandLine()
724 search->scriptFileLength = (int)(arg - search->scriptFile); in parseCommandLine()
732 _decodeShebang(SearchInfo *search, const char *buffer, int bufferLength, bool onlyUtf8, wchar_t **d… in _decodeShebang() argument
744 wchar_t *b = allocSearchInfoBuffer(search, wideLen + 1); in _decodeShebang()
831 searchPath(SearchInfo *search, const wchar_t *shebang, int shebangLength) in searchPath() argument
868 debug(L"# Search PATH for %s\n", filename); in searchPath()
906 wchar_t *buf = allocSearchInfoBuffer(search, n + 1); in searchPath()
911 search->executablePath = buf; in searchPath()
912 search->executableArgs = &command[commandLength]; in searchPath()
913 search->executableArgsLength = shebangLength - commandLength; in searchPath()
957 _findCommand(SearchInfo *search, const wchar_t *command, int commandLength) in _findCommand() argument
966 wchar_t *path = allocSearchInfoBuffer(search, n + 1); in _findCommand()
971 search->executablePath = path; in _findCommand()
977 _useShebangAsExecutable(SearchInfo *search, const wchar_t *shebang, int shebangLength) in _useShebangAsExecutable() argument
1007 wcsncpy_s(script, MAXLEN, search->scriptFile, search->scriptFileLength) || in _useShebangAsExecutable()
1018 wchar_t *path = allocSearchInfoBuffer(search, n + 1); in _useShebangAsExecutable()
1023 search->executablePath = path; in _useShebangAsExecutable()
1025 search->executableArgs = &shebang[commandLength]; in _useShebangAsExecutable()
1026 search->executableArgsLength = shebangLength - commandLength; in _useShebangAsExecutable()
1033 checkShebang(SearchInfo *search) in checkShebang() argument
1037 if (search->tag || !search->scriptFile) { in checkShebang()
1041 if (search->scriptFileLength < 0) { in checkShebang()
1042 search->scriptFileLength = (int)wcsnlen_s(search->scriptFile, MAXLEN); in checkShebang()
1045 wchar_t *scriptFile = (wchar_t*)malloc(sizeof(wchar_t) * (search->scriptFileLength + 1)); in checkShebang()
1050 wcsncpy_s(scriptFile, search->scriptFileLength + 1, in checkShebang()
1051 search->scriptFile, search->scriptFileLength); in checkShebang()
1105 …int exitCode = _decodeShebang(search, start, (int)(b - start + (bytesRead == 0)), onlyUtf8, &sheba… in checkShebang()
1111 // Handle shebangs that we should search PATH for in checkShebang()
1113 exitCode = searchPath(search, shebang, shebangLength); in checkShebang()
1137 // Search for "python{command}" overrides. All templates end with in checkShebang()
1139 if (_findCommand(search, &command[-6], commandLength + 6)) { in checkShebang()
1140 search->executableArgs = &command[commandLength]; in checkShebang()
1141 search->executableArgsLength = shebangLength - commandLength; in checkShebang()
1143 commandLength + 6, &command[-6], search->executablePath); in checkShebang()
1147 search->tag = command; in checkShebang()
1148 search->tagLength = commandLength; in checkShebang()
1151 if (search->tagLength >= 4) { in checkShebang()
1152 const wchar_t *suffix = &search->tag[search->tagLength - 4]; in checkShebang()
1154 search->tagLength -= 4; in checkShebang()
1159 if (search->tagLength >= 2) { in checkShebang()
1160 const wchar_t *suffix = &search->tag[search->tagLength - 2]; in checkShebang()
1162 search->tagLength -= 2; in checkShebang()
1165 search->oldStyleTag = true; in checkShebang()
1166 search->lowPriorityTag = true; in checkShebang()
1167 search->executableArgs = &command[commandLength]; in checkShebang()
1168 search->executableArgsLength = shebangLength - commandLength; in checkShebang()
1169 if (search->tag && search->tagLength) { in checkShebang()
1171 commandLength, command, search->tagLength, search->tag); in checkShebang()
1190 if (_findCommand(search, shebang, commandLength)) { in checkShebang()
1191 search->executableArgs = &shebang[commandLength]; in checkShebang()
1192 search->executableArgsLength = shebangLength - commandLength; in checkShebang()
1194 commandLength, shebang, search->executablePath); in checkShebang()
1200 return _useShebangAsExecutable(search, shebang, shebangLength); in checkShebang()
1205 checkDefaults(SearchInfo *search) in checkDefaults() argument
1207 if (!search->allowDefaults) { in checkDefaults()
1212 if (search->tag && search->tagLength && !search->oldStyleTag) { in checkDefaults()
1220 if (!search->tag || !search->tagLength) { in checkDefaults()
1223 } else if (0 == wcsncmp(search->tag, L"3", search->tagLength)) { in checkDefaults()
1226 } else if (0 == wcsncmp(search->tag, L"2", search->tagLength)) { in checkDefaults()
1230 debug(L"# Cannot select defaults for tag '%.*s'\n", search->tagLength, search->tag); in checkDefaults()
1244 wchar_t *tag = allocSearchInfoBuffer(search, n + 1); in checkDefaults()
1251 search->tag = tag; in checkDefaults()
1252 search->tagLength = n; in checkDefaults()
1253 search->oldStyleTag = true; in checkDefaults()
1255 search->company = tag; in checkDefaults()
1256 search->companyLength = (int)(slash - tag); in checkDefaults()
1257 search->tag = slash + 1; in checkDefaults()
1258 search->tagLength = n - (search->companyLength + 1); in checkDefaults()
1259 search->oldStyleTag = false; in checkDefaults()
1263 search->lowPriorityTag = true; in checkDefaults()
1270 *** ENVIRONMENT SEARCH ***
1475 *** REGISTRY SEARCH ***
1542 _registryReadLegacyEnvironment(const SearchInfo *search, HKEY root, EnvironmentInfo *env, const wch… in _registryReadLegacyEnvironment() argument
1548 search->executable, in _registryReadLegacyEnvironment()
1549 search->executableLength in _registryReadLegacyEnvironment()
1555 if (search->windowed) { in _registryReadLegacyEnvironment()
1617 _registryReadEnvironment(const SearchInfo *search, HKEY root, EnvironmentInfo *env, const wchar_t *… in _registryReadEnvironment() argument
1628 return _registryReadLegacyEnvironment(search, root, env, fallbackArch); in _registryReadEnvironment()
1632 if (search->windowed) { in _registryReadEnvironment()
1672 _registrySearchTags(const SearchInfo *search, EnvironmentInfo **result, HKEY root, int sortKey, con… in _registrySearchTags() argument
1690 exitCode = _registryReadEnvironment(search, subkey, env, fallbackArch); in _registrySearchTags()
1711 registrySearch(const SearchInfo *search, EnvironmentInfo **result, HKEY root, int sortKey, const wc… in registrySearch() argument
1725 … if (search->limitToCompany && 0 != _compare(search->limitToCompany, -1, buffer, cchBuffer)) { in registrySearch()
1731 exitCode = _registrySearchTags(search, result, subkey, sortKey, buffer, fallbackArch); in registrySearch()
1740 *** APP PACKAGE SEARCH ***
1744 appxSearch(const SearchInfo *search, EnvironmentInfo **result, const wchar_t *packageFamilyName, co… in appxSearch() argument
1748 const wchar_t *exeName = search->executable; in appxSearch()
1749 if (!exeName || search->allowExecutableOverride) { in appxSearch()
1750 exeName = search->windowed ? L"pythonw.exe" : L"python.exe"; in appxSearch()
1815 explicitOverrideSearch(const SearchInfo *search, EnvironmentInfo **result) in explicitOverrideSearch() argument
1817 if (!search->executablePath) { in explicitOverrideSearch()
1826 int exitCode = copyWstr(&env->executablePath, search->executablePath); in explicitOverrideSearch()
1850 *** ACTIVE VIRTUAL ENVIRONMENT SEARCH ***
1854 virtualenvSearch(const SearchInfo *search, EnvironmentInfo **result) in virtualenvSearch() argument
1860 if (!n || !join(buffer, MAXLEN, L"Scripts") || !join(buffer, MAXLEN, search->executable)) { in virtualenvSearch()
1865 if (INVALID_FILE_ATTRIBUTES == attr && search->lowPriorityTag) { in virtualenvSearch()
1911 // Registry subkey to search
1913 // Registry hive to search
1991 collectEnvironments(const SearchInfo *search, EnvironmentInfo **result) in collectEnvironments() argument
2003 exitCode = explicitOverrideSearch(search, result); in collectEnvironments()
2008 exitCode = virtualenvSearch(search, result); in collectEnvironments()
2014 if (env && !(search->list || search->listPaths)) { in collectEnvironments()
2020 exitCode = registrySearch(search, result, root, info->sortKey, info->fallbackArch); in collectEnvironments()
2028 if (search->limitToCompany) { in collectEnvironments()
2029 debug(L"# Skipping APPX search due to PYLAUNCHER_LIMIT_TO_COMPANY\n"); in collectEnvironments()
2034 exitCode = appxSearch(search, result, info->familyName, info->tag, info->sortKey); in collectEnvironments()
2122 installEnvironment(const SearchInfo *search) in installEnvironment() argument
2125 if (!search->tag || !search->tagLength) { in installEnvironment()
2131 if (!search->oldStyleTag && in installEnvironment()
2132 search->company && search->companyLength && in installEnvironment()
2133 0 != _compare(search->company, search->companyLength, L"PythonCore", -1)) { in installEnvironment()
2134 debug(L"# Cannot install for company %.*s\n", search->companyLength, search->company); in installEnvironment()
2140 if (0 == _compare(search->tag, search->tagLength, info->tag, -1)) { in installEnvironment()
2194 _companyMatches(const SearchInfo *search, const EnvironmentInfo *env) in _companyMatches() argument
2196 if (!search->company || !search->companyLength) { in _companyMatches()
2199 return 0 == _compare(env->company, -1, search->company, search->companyLength); in _companyMatches()
2204 _tagMatches(const SearchInfo *search, const EnvironmentInfo *env, int searchTagLength) in _tagMatches() argument
2207 searchTagLength = search->tagLength; in _tagMatches()
2209 if (!search->tag || !searchTagLength) { in _tagMatches()
2212 return _startsWithSeparated(env->tag, -1, search->tag, searchTagLength, L".-"); in _tagMatches()
2227 _selectEnvironment(const SearchInfo *search, EnvironmentInfo *env, EnvironmentInfo **best) in _selectEnvironment() argument
2231 exitCode = _selectEnvironment(search, env->prev, best); in _selectEnvironment()
2239 if (env->highPriority && search->lowPriorityTag) { in _selectEnvironment()
2240 // This environment is marked high priority, and the search allows in _selectEnvironment()
2248 if (!search->oldStyleTag) { in _selectEnvironment()
2249 if (_companyMatches(search, env) && _tagMatches(search, env, -1)) { in _selectEnvironment()
2262 int tagLength = search->tagLength; in _selectEnvironment()
2265 if (0 == _compareArgument(&search->tag[tagLength - 3], 3, L"-64", 3)) { in _selectEnvironment()
2268 } else if (0 == _compareArgument(&search->tag[tagLength - 3], 3, L"-32", 3)) { in _selectEnvironment()
2274 if (_tagMatches(search, env, tagLength)) { in _selectEnvironment()
2292 selectEnvironment(const SearchInfo *search, EnvironmentInfo *root, EnvironmentInfo **best) in selectEnvironment() argument
2304 int exitCode = _selectEnvironment(search, root, &result); in selectEnvironment()
2438 calculateCommandLine(const SearchInfo *search, const EnvironmentInfo *launch, wchar_t *buffer, int … in calculateCommandLine() argument
2443 // Construct command line from a search override, or else the selected in calculateCommandLine()
2445 if (search->executablePath) { in calculateCommandLine()
2446 executablePath = search->executablePath; in calculateCommandLine()
2452 // only if the search allowed an override. in calculateCommandLine()
2453 // Otherwise, use the environment's installDir and the search's default in calculateCommandLine()
2455 if (executablePath && search->allowExecutableOverride) { in calculateCommandLine()
2470 } else if (!search->executable || !search->executableLength) { in calculateCommandLine()
2476 wcsncpy_s(executable, 256, search->executable, search->executableLength); in calculateCommandLine()
2505 if (!exitCode && search->executableArgs) { in calculateCommandLine()
2506 if (search->executableArgsLength < 0) { in calculateCommandLine()
2507 exitCode = wcscat_s(buffer, bufferLength, search->executableArgs); in calculateCommandLine()
2508 } else if (search->executableArgsLength > 0) { in calculateCommandLine()
2510 if (end < bufferLength - (search->executableArgsLength + 1)) { in calculateCommandLine()
2512 search->executableArgs, search->executableArgsLength); in calculateCommandLine()
2517 if (!exitCode && search->restOfCmdLine) { in calculateCommandLine()
2518 exitCode = wcscat_s(buffer, bufferLength, search->restOfCmdLine); in calculateCommandLine()
2557 launchEnvironment(const SearchInfo *search, const EnvironmentInfo *launch, wchar_t *launchCommand) in launchEnvironment() argument
2652 performSearch(SearchInfo *search, EnvironmentInfo **envs) in performSearch() argument
2655 int exitCode = parseCommandLine(search); in performSearch()
2662 exitCode = checkShebang(search); in performSearch()
2674 exitCode = checkDefaults(search); in performSearch()
2679 // If debugging is enabled, list our search criteria in performSearch()
2680 dumpSearchInfo(search); in performSearch()
2683 exitCode = collectEnvironments(search, envs); in performSearch()
2697 SearchInfo search = {0}; in process() local
2712 wchar_t *limitToCompany = allocSearchInfoBuffer(&search, len); in process()
2718 search.limitToCompany = limitToCompany; in process()
2726 search.originalCmdLine = GetCommandLineW(); in process()
2728 exitCode = performSearch(&search, &envs); in process()
2734 if (search.help) { in process()
2744 searchExitCode = selectEnvironment(&search, envs, &env); in process()
2747 if (search.list || search.listPaths) { in process()
2748 exitCode = listEnvironments(envs, stdout, search.listPaths, env); in process()
2765 exitCode = installEnvironment(&search); in process()
2769 exitCode = performSearch(&search, &envs); in process()
2773 exitCode = selectEnvironment(&search, envs, &env); in process()
2779 if (!isEnvVarSet(L"PYLAUNCHER_ALLOW_INSTALL") && search.oldStyleTag) { in process()
2799 …exitCode = calculateCommandLine(&search, env, launchCommand, sizeof(launchCommand) / sizeof(launch… in process()
2805 exitCode = launchEnvironment(&search, env, launchCommand); in process()
2808 freeSearchInfo(&search); in process()