MCPcopy Create free account
hub / github.com/FirebirdSQL/firebird / API_ROUTINE gds__validate_lib_path

Function API_ROUTINE gds__validate_lib_path

src/yvalve/gds.cpp:2602–2669  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2600
2601
2602BOOLEAN API_ROUTINE gds__validate_lib_path(const TEXT* module,
2603 const TEXT* ib_env_var,
2604 TEXT* resolved_module,
2605 SLONG length)
2606{
2607/**************************************
2608 *
2609 * g d s _ $ v a l i d a t e _ l i b _ p a t h ( n o n - V M S )
2610 *
2611 **************************************
2612 *
2613 * Functional description
2614 * Find the external library path variable.
2615 * Validate that the path to the library module name
2616 * in the path specified. If the external lib path
2617 * is not defined then accept any path, and return
2618 * TRUE. If the module is in the path then return TRUE
2619 * else, if the module is not in the path return FALSE.
2620 *
2621 **************************************/
2622 Firebird::string ib_ext_lib_path;
2623 if (!fb_utils::readenv(ib_env_var, ib_ext_lib_path))
2624 {
2625 fb_utils::copy_terminate(resolved_module, module, length);
2626 return TRUE; // The variable is not defined. Return TRUE
2627 }
2628
2629 TEXT abs_module[MAXPATHLEN];
2630 if (EXPAND_PATH(module, abs_module))
2631 {
2632 // Extract the path from the absolute module name
2633 const TEXT* q = NULL;
2634 for (const TEXT* mp = abs_module; *mp; mp++)
2635 {
2636 if ((*mp == '\\') || (*mp == '/'))
2637 q = mp;
2638 }
2639
2640 TEXT abs_module_path[MAXPATHLEN];
2641 memset(abs_module_path, 0, MAXPATHLEN);
2642 strncpy(abs_module_path, abs_module, q - abs_module);
2643
2644 // Check to see if the module path is in the lib path
2645 // if it is return TRUE. If it does not find it, then
2646 // the module path is not valid so return FALSE
2647
2648 TEXT abs_path[MAXPATHLEN];
2649 TEXT path[MAXPATHLEN];
2650
2651 // Warning: ib_ext_lib_path.length() is not coherent since strtok is applied to it.
2652 const TEXT* token = strtok(ib_ext_lib_path.begin(), ";");
2653 while (token != NULL)
2654 {
2655 fb_utils::copy_terminate(path, token, sizeof(path));
2656 // make sure that there is no traing slash on the path
2657 TEXT* p = path + strlen(path);
2658 if ((p != path) && ((p[-1] == '/') || (p[-1] == '\\')))
2659 p[-1] = 0;

Callers

nothing calls this directly

Calls 3

readenvFunction · 0.85
copy_terminateFunction · 0.50
beginMethod · 0.45

Tested by

no test coverage detected