86 if (_currently_loading) {
91 _currently_loading =
true;
95 for (pi = _implicit_pages.begin(); pi != _implicit_pages.end(); ++pi) {
98 _implicit_pages.clear();
103 uint64_t blob_offset;
106 uint16_t num_pointers;
110 const void *module_table;
111 const char *prc_data;
112 const char *default_prc_dir;
113 const char *prc_dir_envvars;
114 const char *prc_path_envvars;
115 const char *prc_patterns;
116 const char *prc_encrypted_patterns;
117 const char *prc_encryption_key;
118 const char *prc_executable_patterns;
119 const char *prc_executable_args_envvar;
120 const char *main_dir;
121 const char *log_filename;
124 const BlobInfo *blobinfo = (
const BlobInfo *)GetProcAddress(GetModuleHandle(NULL),
"blobinfo");
125#elif defined(RTLD_MAIN_ONLY)
126 const BlobInfo *blobinfo = (
const BlobInfo *)dlsym(RTLD_MAIN_ONLY,
"blobinfo");
130 const BlobInfo *blobinfo = (
const BlobInfo *)dlsym(dlopen(NULL, RTLD_NOW),
"blobinfo");
132 if (blobinfo ==
nullptr) {
137 }
else if (blobinfo->version == 0 || blobinfo->num_pointers < 10) {
141 if (blobinfo !=
nullptr) {
142 if (blobinfo->num_pointers >= 11 && blobinfo->main_dir !=
nullptr) {
153 _prc_patterns.clear();
155 string prc_patterns = PRC_PATTERNS;
156 if (blobinfo !=
nullptr && blobinfo->prc_patterns !=
nullptr) {
157 prc_patterns = blobinfo->prc_patterns;
159 if (!prc_patterns.empty()) {
160 vector_string pat_list;
162 _prc_patterns.reserve(pat_list.size());
163 for (
size_t i = 0; i < pat_list.size(); ++i) {
170 _prc_patterns.push_back(glob);
175 _prc_encrypted_patterns.clear();
177 string prc_encrypted_patterns = PRC_ENCRYPTED_PATTERNS;
178 if (blobinfo !=
nullptr && blobinfo->prc_encrypted_patterns !=
nullptr) {
179 prc_encrypted_patterns = blobinfo->prc_encrypted_patterns;
181 if (!prc_encrypted_patterns.empty()) {
182 vector_string pat_list;
184 _prc_encrypted_patterns.reserve(pat_list.size());
185 for (
size_t i = 0; i < pat_list.size(); ++i) {
190 _prc_encrypted_patterns.push_back(glob);
195 _prc_executable_patterns.clear();
197 string prc_executable_patterns = PRC_EXECUTABLE_PATTERNS;
198 if (blobinfo !=
nullptr && blobinfo->prc_executable_patterns !=
nullptr) {
199 prc_executable_patterns = blobinfo->prc_executable_patterns;
201 if (!prc_executable_patterns.empty()) {
202 vector_string pat_list;
204 _prc_executable_patterns.reserve(pat_list.size());
205 for (
size_t i = 0; i < pat_list.size(); ++i) {
210 _prc_executable_patterns.push_back(glob);
215 _search_path.
clear();
220 string prc_dir_envvars = PRC_DIR_ENVVARS;
221 if (blobinfo !=
nullptr && blobinfo->prc_dir_envvars !=
nullptr) {
222 prc_dir_envvars = blobinfo->prc_dir_envvars;
224 if (!prc_dir_envvars.empty()) {
225 vector_string prc_dir_envvar_list;
227 for (
size_t i = 0; i < prc_dir_envvar_list.size(); ++i) {
229 if (!prc_dir.empty()) {
230 Filename prc_dir_filename = Filename::from_os_specific(prc_dir);
232 if (scan_auto_prc_dir(prc_dir_filename)) {
242 string prc_path_envvars = PRC_PATH_ENVVARS;
243 if (blobinfo !=
nullptr && blobinfo->prc_path_envvars !=
nullptr) {
244 prc_path_envvars = blobinfo->prc_path_envvars;
246 if (!prc_path_envvars.empty()) {
247 vector_string prc_path_envvar_list;
249 for (
size_t i = 0; i < prc_path_envvar_list.size(); ++i) {
252 while (p < path.length()) {
253 size_t q = path.find_first_of(DEFAULT_PATHSEP, p);
254 if (q == string::npos) {
257 Filename prc_dir_filename = Filename::from_os_specific(path.substr(p, q - p));
259 if (scan_auto_prc_dir(prc_dir_filename)) {
276 string prc_path2_envvars = PRC_PATH2_ENVVARS;
277 if (!prc_path2_envvars.empty() && blobinfo ==
nullptr) {
278 vector_string prc_path_envvar_list;
280 for (
size_t i = 0; i < prc_path_envvar_list.size(); ++i) {
283 while (p < path.length()) {
284 size_t q = path.find_first_of(
' ', p);
285 if (q == string::npos) {
288 Filename prc_dir_filename = path.substr(p, q - p);
289 if (scan_auto_prc_dir(prc_dir_filename)) {
300 string default_prc_dir = DEFAULT_PRC_DIR;
301 if (blobinfo !=
nullptr && blobinfo->default_prc_dir !=
nullptr) {
302 default_prc_dir = blobinfo->default_prc_dir;
304 if (!default_prc_dir.empty()) {
306 Filename prc_dir_filename = default_prc_dir;
307 if (scan_auto_prc_dir(prc_dir_filename)) {
315 ConfigFiles config_files;
319 std::set<Filename> unique_dirnames;
328 if (unique_dirnames.insert(canonical).second) {
337 vector_string::reverse_iterator fi;
338 for (fi = files.rbegin(); fi != files.rend(); ++fi) {
340 Globs::const_iterator gi;
341 for (gi = _prc_patterns.begin();
342 gi != _prc_patterns.end();
344 if ((*gi).matches(*fi)) {
345 file_flags |= FF_read;
349 for (gi = _prc_encrypted_patterns.begin();
350 gi != _prc_encrypted_patterns.end();
352 if ((*gi).matches(*fi)) {
353 file_flags |= FF_read | FF_decrypt;
357 for (gi = _prc_executable_patterns.begin();
358 gi != _prc_executable_patterns.end();
360 if ((*gi).matches(*fi)) {
361 file_flags |= FF_execute;
365 if (file_flags != 0) {
367 file._file_flags = file_flags;
368 file._filename =
Filename(directory, (*fi));
369 config_files.push_back(file);
379 if (blobinfo !=
nullptr && blobinfo->prc_data !=
nullptr) {
382 _implicit_pages.push_back(page);
383 _pages_sorted =
false;
385 std::istringstream in(blobinfo->prc_data);
393 ConfigFiles::reverse_iterator ci;
394 for (ci = config_files.rbegin(); ci != config_files.rend(); ++ci) {
395 const ConfigFile &file = (*ci);
398 if ((file._file_flags & FF_execute) != 0 &&
403 string envvar = PRC_EXECUTABLE_ARGS_ENVVAR;
404 if (blobinfo !=
nullptr && blobinfo->prc_executable_args_envvar !=
nullptr) {
405 envvar = blobinfo->prc_executable_args_envvar;
407 if (!envvar.empty()) {
418 _implicit_pages.push_back(page);
419 _pages_sorted =
false;
423 }
else if ((file._file_flags & FF_decrypt) != 0) {
430 <<
"Unable to read " << filename <<
"\n";
434 _implicit_pages.push_back(page);
435 _pages_sorted =
false;
437 if (blobinfo !=
nullptr && blobinfo->prc_encryption_key !=
nullptr) {
444 }
else if ((file._file_flags & FF_read) != 0) {
451 <<
"Unable to read " << filename <<
"\n";
455 _implicit_pages.push_back(page);
456 _pages_sorted =
false;
463 if (!_loaded_implicit) {
464 config_initialized();
465 _loaded_implicit =
true;
468 _currently_loading =
false;
471#ifdef USE_PANDAFILESTREAM
475 (
"newline-mode", PandaFileStreamBuf::NM_native,
476 PRC_DESC(
"Controls how newlines are written by Panda applications writing "
477 "to a text file. The default, \"native\", means to write newlines "
478 "appropriate to the current platform. You may also specify \"binary\", "
479 "to avoid molesting the file data, or one of \"msdos\", \"unix\", "
481 PandaFileStreamBuf::_newline_mode = newline_mode;
488 (
"show-dll-error-dialog",
false,
489 PRC_DESC(
"Set this true to enable the Windows system dialog that pops "
490 "up when a DLL fails to load, or false to disable it. It is "
491 "normally false, but it may be useful to set it true to debug "
492 "why a DLL is not loading. (Note that this actually disables "
493 "*all* critical error messages, and that it's a global setting "
494 "that some other libraries might un-set.)"));
495 if (show_dll_error_dialog) {
498 SetErrorMode(SEM_FAILCRITICALERRORS);
bool read_encrypted_prc(std::istream &in, const std::string &password)
Automatically decrypts and reads the stream, given the indicated password.
bool read_prc(std::istream &in)
Reads the contents of a complete prc file, as returned by the indicated istream, into the current pag...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.