]> git.proxmox.com Git - mirror_edk2.git/blobdiff - AppPkg/Applications/Python/Efi/getpath.c
edk2: Remove AppPkg, StdLib, StdLibPrivateInternalFiles
[mirror_edk2.git] / AppPkg / Applications / Python / Efi / getpath.c
diff --git a/AppPkg/Applications/Python/Efi/getpath.c b/AppPkg/Applications/Python/Efi/getpath.c
deleted file mode 100644 (file)
index 208bb7e..0000000
+++ /dev/null
@@ -1,719 +0,0 @@
-/** @file\r
-    Return the initial module search path.\r
-\r
-    Search in specified locations for the associated Python libraries.\r
-\r
-    Py_GetPath returns module_search_path.\r
-    Py_GetPrefix returns PREFIX\r
-    Py_GetExec_Prefix returns PREFIX\r
-    Py_GetProgramFullPath returns the full path to the python executable.\r
-\r
-    These are built dynamically so that the proper volume name can be prefixed\r
-    to the paths.\r
-\r
-    For the EDK II, UEFI, implementation of Python, PREFIX and EXEC_PREFIX\r
-    are set as follows:\r
-      PREFIX      = /Efi/StdLib\r
-      EXEC_PREFIX = PREFIX\r
-\r
-    The following final paths are assumed:\r
-      /Efi/Tools/Python.efi                     The Python executable.\r
-      /Efi/StdLib/lib/python.VERSION            The platform independent Python modules.\r
-      /Efi/StdLib/lib/python.VERSION/dynalib    Dynamically loadable Python extension modules.\r
-\r
-    Copyright (c) 2011 - 2012, Intel Corporation. All rights reserved.<BR>\r
-    SPDX-License-Identifier: BSD-2-Clause-Patent\r
-**/\r
-#include <Python.h>\r
-#include <osdefs.h>\r
-#include  <ctype.h>\r
-\r
-#ifdef __cplusplus\r
- extern "C" {\r
-#endif\r
-\r
-/* VERSION must be at least two characters long. */\r
-#ifndef VERSION\r
-  #define VERSION     "27"\r
-#endif\r
-\r
-#ifndef VPATH\r
-  #define VPATH       "."\r
-#endif\r
-\r
-/* Search path entry delimiter */\r
-#ifdef DELIM\r
-  #define sDELIM        ";"\r
-#endif\r
-\r
-#ifndef PREFIX\r
-  #define PREFIX      "/Efi/StdLib"\r
-#endif\r
-\r
-#ifndef EXEC_PREFIX\r
-  #define EXEC_PREFIX PREFIX\r
-#endif\r
-\r
-#ifndef   LIBPYTHON\r
-  #define   LIBPYTHON     "lib/python." VERSION\r
-#endif\r
-\r
-#ifndef PYTHONPATH\r
-  #ifdef HAVE_ENVIRONMENT_OPS\r
-    #define PYTHONPATH  PREFIX LIBPYTHON sDELIM \\r
-                        EXEC_PREFIX LIBPYTHON "/lib-dynload"\r
-  #else\r
-    #define PYTHONPATH  LIBPYTHON\r
-  #endif\r
-#endif\r
-\r
-#ifndef LANDMARK\r
-#define LANDMARK    "os.py"\r
-#endif\r
-\r
-static char   prefix[MAXPATHLEN+1];\r
-static char   exec_prefix[MAXPATHLEN+1];\r
-static char   progpath[MAXPATHLEN+1];\r
-static char  *module_search_path          = NULL;\r
-static char   lib_python[]                = LIBPYTHON;\r
-static char   volume_name[32]             = { 0 };\r
-\r
-/** Determine if "ch" is a separator character.\r
-\r
-    @param[in]  ch      The character to test.\r
-\r
-    @retval     TRUE    ch is a separator character.\r
-    @retval     FALSE   ch is NOT a separator character.\r
-**/\r
-static int\r
-is_sep(char ch)\r
-{\r
-#ifdef ALTSEP\r
-  return ch == SEP || ch == ALTSEP;\r
-#else\r
-  return ch == SEP;\r
-#endif\r
-}\r
-\r
-/** Reduce a path by its last element.\r
-\r
-    The last element (everything to the right of the last separator character)\r
-    in the path, dir, is removed from the path.  Parameter dir is modified in place.\r
-\r
-    @param[in,out]    dir   Pointer to the path to modify.\r
-**/\r
-static void\r
-reduce(char *dir)\r
-{\r
-    size_t i = strlen(dir);\r
-    while (i > 0 && !is_sep(dir[i]))\r
-        --i;\r
-    dir[i] = '\0';\r
-}\r
-\r
-#ifndef UEFI_C_SOURCE\r
-/** Does filename point to a file and not directory?\r
-\r
-    @param[in]    filename    The fully qualified path to the object to test.\r
-\r
-    @retval       0     Filename was not found, or is a directory.\r
-    @retval       1     Filename refers to a regular file.\r
-**/\r
-static int\r
-isfile(char *filename)\r
-{\r
-    struct stat buf;\r
-    if (stat(filename, &buf) != 0) {\r
-      return 0;\r
-    }\r
-    //if (!S_ISREG(buf.st_mode))\r
-    if (S_ISDIR(buf.st_mode)) {\r
-      return 0;\r
-    }\r
-    return 1;\r
-}\r
-\r
-/** Determine if filename refers to a Python module.\r
-\r
-    A Python module is indicated if the file exists, or if the file with\r
-    'o' or 'c' appended exists.\r
-\r
-    @param[in]    filename    The fully qualified path to the object to test.\r
-\r
-    @retval       0\r
-**/\r
-static int\r
-ismodule(char *filename)\r
-{\r
-  if (isfile(filename)) {\r
-    //if (Py_VerboseFlag) PySys_WriteStderr("%s[%d]: file = \"%s\"\n", __func__, __LINE__, filename);\r
-    return 1;\r
-  }\r
-\r
-    /* Check for the compiled version of prefix. */\r
-    if (strlen(filename) < MAXPATHLEN) {\r
-        strcat(filename, Py_OptimizeFlag ? "o" : "c");\r
-        if (isfile(filename)) {\r
-          return 1;\r
-        }\r
-    }\r
-    return 0;\r
-}\r
-\r
-/** Does filename point to a directory?\r
-\r
-    @param[in]    filename    The fully qualified path to the object to test.\r
-\r
-    @retval       0     Filename was not found, or is not a regular file.\r
-    @retval       1     Filename refers to a directory.\r
-**/\r
-static int\r
-isdir(char *filename)\r
-{\r
-    struct stat buf;\r
-\r
-    if (stat(filename, &buf) != 0)\r
-        return 0;\r
-\r
-    if (!S_ISDIR(buf.st_mode))\r
-        return 0;\r
-\r
-    return 1;\r
-}\r
-#endif  /* UEFI_C_SOURCE */\r
-\r
-/** Determine if a path is absolute, or not.\r
-    An absolute path consists of a volume name, "VOL:", followed by a rooted path,\r
-    "/path/elements".  If both of these components are present, the path is absolute.\r
-\r
-    Let P be a pointer to the path to test.\r
-    Let A be a pointer to the first ':' in P.\r
-    Let B be a pointer to the first '/' or '\\' in P.\r
-\r
-    If A and B are not NULL\r
-      If (A-P+1) == (B-P) then the path is absolute.\r
-    Otherwise, the path is NOT absolute.\r
-\r
-    @param[in]  path    The path to test.\r
-\r
-    @retval     -1      Path is absolute but lacking volume name.\r
-    @retval      0      Path is NOT absolute.\r
-    @retval      1      Path is absolute.\r
-*/\r
-static int\r
-is_absolute(char *path)\r
-{\r
-  char  *A;\r
-  char  *B;\r
-\r
-  A = strchr(path, ':');\r
-  B = strpbrk(path, "/\\");\r
-\r
-  if(B != NULL) {\r
-    if(A == NULL) {\r
-      if(B == path) {\r
-        return -1;\r
-      }\r
-    }\r
-    else {\r
-      if(((A - path) + 1) == (B - path)) {\r
-        return 1;\r
-      }\r
-    }\r
-  }\r
-  return 0;\r
-}\r
-\r
-\r
-/** Add a path component, by appending stuff to buffer.\r
-    buffer must have at least MAXPATHLEN + 1 bytes allocated, and contain a\r
-    NUL-terminated string with no more than MAXPATHLEN characters (not counting\r
-    the trailing NUL).  It's a fatal error if it contains a string longer than\r
-    that (callers must be careful!).  If these requirements are met, it's\r
-    guaranteed that buffer will still be a NUL-terminated string with no more\r
-    than MAXPATHLEN characters at exit.  If stuff is too long, only as much of\r
-    stuff as fits will be appended.\r
-\r
-    @param[in,out]    buffer    The path to be extended.\r
-    @param[in]        stuff     The stuff to join onto the path.\r
-*/\r
-static void\r
-joinpath(char *buffer, char *stuff)\r
-{\r
-  size_t n, k;\r
-\r
-  k = 0;\r
-  if (is_absolute(stuff) == 1) {\r
-    n = 0;\r
-  }\r
-  else {\r
-    n = strlen(buffer);\r
-    if(n == 0) {\r
-      strncpy(buffer, volume_name, MAXPATHLEN);\r
-      n = strlen(buffer);\r
-    }\r
-    /* We must not use an else clause here because we want to test n again.\r
-        volume_name may have been empty.\r
-    */\r
-    if (n > 0 && n < MAXPATHLEN) {\r
-      if(!is_sep(buffer[n-1])) {\r
-        buffer[n++] = SEP;\r
-      }\r
-      if(is_sep(stuff[0]))   ++stuff;\r
-    }\r
-  }\r
-  if (n > MAXPATHLEN)\r
-    Py_FatalError("buffer overflow in getpath.c's joinpath()");\r
-  k = strlen(stuff);\r
-  if (n + k > MAXPATHLEN)\r
-    k = MAXPATHLEN - n;\r
-  strncpy(buffer+n, stuff, k);\r
-  buffer[n+k] = '\0';\r
-}\r
-\r
-/** Is filename an executable file?\r
-\r
-    An executable file:\r
-      1) exists\r
-      2) is a file, not a directory\r
-      3) has a name ending with ".efi"\r
-      4) Only has a single '.' in the name.\r
-\r
-    If basename(filename) does not contain a '.', append ".efi" to filename\r
-    If filename ends in ".efi", it is executable, else it isn't.\r
-\r
-    This routine is used to when searching for the file named by argv[0].\r
-    As such, there is no need to search for extensions other than ".efi".\r
-\r
-    @param[in]    filename      The name of the file to test.  It may, or may not, have an extension.\r
-\r
-    @retval       0     filename already has a path other than ".efi", or it doesn't exist, or is a directory.\r
-    @retval       1     filename refers to an executable file.\r
-**/\r
-static int\r
-isxfile(char *filename)\r
-{\r
-    struct stat  buf;\r
-    char        *bn;\r
-    char        *newbn;\r
-    int          bnlen;\r
-\r
-    bn = basename(filename);            // Separate off the file name component\r
-    reduce(filename);                   // and isolate the path component\r
-    bnlen = strlen(bn);\r
-    newbn = strrchr(bn, '.');           // Does basename contain a period?\r
-    if(newbn == NULL) {                   // Does NOT contain a period.\r
-      newbn = &bn[bnlen];\r
-      strncpyX(newbn, ".efi", MAXPATHLEN - bnlen);    // append ".efi" to basename\r
-      bnlen += 4;\r
-    }\r
-    else if(strcmp(newbn, ".efi") != 0) {\r
-      return 0;                         // File can not be executable.\r
-    }\r
-    joinpath(filename, bn);             // Stitch path and file name back together\r
-\r
-    if (stat(filename, &buf) != 0) {    // Now, verify that file exists\r
-      return 0;\r
-    }\r
-    if(S_ISDIR(buf.st_mode)) {          // And it is not a directory.\r
-      return 0;\r
-    }\r
-\r
-    return 1;\r
-}\r
-\r
-/** Copy p into path, ensuring that the result is an absolute path.\r
-\r
-    copy_absolute requires that path be allocated at least\r
-    MAXPATHLEN + 1 bytes and that p be no more than MAXPATHLEN bytes.\r
-\r
-    @param[out]     path    Destination to receive the absolute path.\r
-    @param[in]      p       Path to be tested and possibly converted.\r
-**/\r
-static void\r
-copy_absolute(char *path, char *p)\r
-{\r
-  if (is_absolute(p) == 1)\r
-        strcpy(path, p);\r
-  else {\r
-    if (!getcwd(path, MAXPATHLEN)) {\r
-      /* unable to get the current directory */\r
-      if(volume_name[0] != 0) {\r
-        strcpy(path, volume_name);\r
-        joinpath(path, p);\r
-      }\r
-      else\r
-        strcpy(path, p);\r
-      return;\r
-    }\r
-    if (p[0] == '.' && is_sep(p[1]))\r
-        p += 2;\r
-    joinpath(path, p);\r
-  }\r
-}\r
-\r
-/** Modify path so that the result is an absolute path.\r
-    absolutize() requires that path be allocated at least MAXPATHLEN+1 bytes.\r
-\r
-    @param[in,out]    path    The path to be made absolute.\r
-*/\r
-static void\r
-absolutize(char *path)\r
-{\r
-    char buffer[MAXPATHLEN + 1];\r
-\r
-    if (is_absolute(path) == 1)\r
-        return;\r
-    copy_absolute(buffer, path);\r
-    strcpy(path, buffer);\r
-}\r
-\r
-/** Extract the volume name from a path.\r
-\r
-    @param[out]   Dest    Pointer to location in which to store the extracted volume name.\r
-    @param[in]    path    Pointer to the path to extract the volume name from.\r
-**/\r
-static void\r
-set_volume(char *Dest, char *path)\r
-{\r
-  size_t    VolLen;\r
-\r
-  if(is_absolute(path)) {\r
-    VolLen = strcspn(path, "/\\:");\r
-    if((VolLen != 0) && (path[VolLen] == ':')) {\r
-      (void) strncpyX(Dest, path, VolLen + 1);\r
-    }\r
-  }\r
-}\r
-\r
-\r
-/** Determine paths.\r
-\r
-    Two directories must be found, the platform independent directory\r
-    (prefix), containing the common .py and .pyc files, and the platform\r
-    dependent directory (exec_prefix), containing the shared library\r
-    modules.  Note that prefix and exec_prefix are the same directory\r
-    for UEFI installations.\r
-\r
-    Separate searches are carried out for prefix and exec_prefix.\r
-    Each search tries a number of different locations until a ``landmark''\r
-    file or directory is found.  If no prefix or exec_prefix is found, a\r
-    warning message is issued and the preprocessor defined PREFIX and\r
-    EXEC_PREFIX are used (even though they may not work); python carries on\r
-    as best as is possible, but some imports may fail.\r
-\r
-    Before any searches are done, the location of the executable is\r
-    determined.  If argv[0] has one or more slashes in it, it is used\r
-    unchanged.  Otherwise, it must have been invoked from the shell's path,\r
-    so we search %PATH% for the named executable and use that.  If the\r
-    executable was not found on %PATH% (or there was no %PATH% environment\r
-    variable), the original argv[0] string is used.\r
-\r
-    Finally, argv0_path is set to the directory containing the executable\r
-    (i.e. the last component is stripped).\r
-\r
-    With argv0_path in hand, we perform a number of steps.  The same steps\r
-    are performed for prefix and for exec_prefix, but with a different\r
-    landmark.\r
-\r
-    The prefix landmark will always be lib/python.VERSION/os.py and the\r
-    exec_prefix will always be lib/python.VERSION/dynaload, where VERSION\r
-    is Python's version number as defined at the beginning of this file.\r
-\r
-    First. See if the %PYTHONHOME% environment variable points to the\r
-    installed location of the Python libraries.  If %PYTHONHOME% is set, then\r
-    it points to prefix and exec_prefix.  %PYTHONHOME% can be a single\r
-    directory, which is used for both, or the prefix and exec_prefix\r
-    directories separated by the DELIM character.\r
-\r
-    Next. Search the directories pointed to by the preprocessor variables\r
-    PREFIX and EXEC_PREFIX.  These paths are prefixed with the volume name\r
-    extracted from argv0_path.  The volume names correspond to the UEFI\r
-    shell "map" names.\r
-\r
-    That's it!\r
-\r
-    Well, almost.  Once we have determined prefix and exec_prefix, the\r
-    preprocessor variable PYTHONPATH is used to construct a path.  Each\r
-    relative path on PYTHONPATH is prefixed with prefix.  Then the directory\r
-    containing the shared library modules is appended.  The environment\r
-    variable $PYTHONPATH is inserted in front of it all.  Finally, the\r
-    prefix and exec_prefix globals are tweaked so they reflect the values\r
-    expected by other code, by stripping the "lib/python$VERSION/..." stuff\r
-    off.  This seems to make more sense given that currently the only\r
-    known use of sys.prefix and sys.exec_prefix is for the ILU installation\r
-    process to find the installed Python tree.\r
-\r
-    The final, fully resolved, paths should look something like:\r
-      fs0:/Efi/Tools/python.efi\r
-      fs0:/Efi/StdLib/lib/python27\r
-      fs0:/Efi/StdLib/lib/python27/dynaload\r
-\r
-**/\r
-static void\r
-calculate_path(void)\r
-{\r
-    extern char *Py_GetProgramName(void);\r
-\r
-    static char delimiter[2] = {DELIM, '\0'};\r
-    static char separator[2] = {SEP, '\0'};\r
-    char *pythonpath = PYTHONPATH;\r
-    char *rtpypath = Py_GETENV("PYTHONPATH");\r
-    //char *home = Py_GetPythonHome();\r
-    char *path = getenv("PATH");\r
-    char *prog = Py_GetProgramName();\r
-    char argv0_path[MAXPATHLEN+1];\r
-    char zip_path[MAXPATHLEN+1];\r
-    char *buf;\r
-    size_t bufsz;\r
-    size_t prefixsz;\r
-    char *defpath;\r
-\r
-\r
-/* ###########################################################################\r
-      Determine path to the Python.efi binary.\r
-      Produces progpath, argv0_path, and volume_name.\r
-########################################################################### */\r
-\r
-    /* If there is no slash in the argv0 path, then we have to\r
-     * assume python is on the user's $PATH, since there's no\r
-     * other way to find a directory to start the search from.  If\r
-     * $PATH isn't exported, you lose.\r
-     */\r
-    if (strchr(prog, SEP))\r
-            strncpy(progpath, prog, MAXPATHLEN);\r
-    else if (path) {\r
-      while (1) {\r
-        char *delim = strchr(path, DELIM);\r
-\r
-        if (delim) {\r
-                size_t len = delim - path;\r
-                if (len > MAXPATHLEN)\r
-                        len = MAXPATHLEN;\r
-                strncpy(progpath, path, len);\r
-                *(progpath + len) = '\0';\r
-        }\r
-        else\r
-                strncpy(progpath, path, MAXPATHLEN);\r
-\r
-        joinpath(progpath, prog);\r
-        if (isxfile(progpath))\r
-                break;\r
-\r
-        if (!delim) {\r
-                progpath[0] = '\0';\r
-                break;\r
-        }\r
-        path = delim + 1;\r
-      }\r
-    }\r
-    else\r
-            progpath[0] = '\0';\r
-    if ( (!is_absolute(progpath)) && (progpath[0] != '\0') )\r
-            absolutize(progpath);\r
-    strncpy(argv0_path, progpath, MAXPATHLEN);\r
-    argv0_path[MAXPATHLEN] = '\0';\r
-    set_volume(volume_name, argv0_path);\r
-\r
-    reduce(argv0_path);\r
-    /* At this point, argv0_path is guaranteed to be less than\r
-       MAXPATHLEN bytes long.\r
-    */\r
-\r
-/* ###########################################################################\r
-      Build the FULL prefix string, including volume name.\r
-      This is the full path to the platform independent libraries.\r
-########################################################################### */\r
-\r
-        strncpy(prefix, volume_name, MAXPATHLEN);\r
-        joinpath(prefix, PREFIX);\r
-        joinpath(prefix, lib_python);\r
-\r
-/* ###########################################################################\r
-      Build the FULL path to the zipped-up Python library.\r
-########################################################################### */\r
-\r
-    strncpy(zip_path, prefix, MAXPATHLEN);\r
-    zip_path[MAXPATHLEN] = '\0';\r
-    reduce(zip_path);\r
-    joinpath(zip_path, "python00.zip");\r
-    bufsz = strlen(zip_path);   /* Replace "00" with version */\r
-    zip_path[bufsz - 6] = VERSION[0];\r
-    zip_path[bufsz - 5] = VERSION[1];\r
-\r
-/* ###########################################################################\r
-      Build the FULL path to dynamically loadable libraries.\r
-########################################################################### */\r
-\r
-        strncpy(exec_prefix, volume_name, MAXPATHLEN);\r
-        joinpath(exec_prefix, EXEC_PREFIX);\r
-        joinpath(exec_prefix, lib_python);\r
-        joinpath(exec_prefix, "lib-dynload");\r
-\r
-/* ###########################################################################\r
-      Build the module search path.\r
-########################################################################### */\r
-\r
-    /* Reduce prefix and exec_prefix to their essence,\r
-     * e.g. /usr/local/lib/python1.5 is reduced to /usr/local.\r
-     * If we're loading relative to the build directory,\r
-     * return the compiled-in defaults instead.\r
-     */\r
-    reduce(prefix);\r
-    reduce(prefix);\r
-    /* The prefix is the root directory, but reduce() chopped\r
-     * off the "/". */\r
-    if (!prefix[0]) {\r
-      strcpy(prefix, volume_name);\r
-    }\r
-    bufsz = strlen(prefix);\r
-    if(prefix[bufsz-1] == ':') {\r
-      prefix[bufsz] = SEP;\r
-      prefix[bufsz+1] = 0;\r
-    }\r
-\r
-    /* Calculate size of return buffer.\r
-     */\r
-    defpath = pythonpath;\r
-    bufsz = 0;\r
-\r
-    if (rtpypath)\r
-        bufsz += strlen(rtpypath) + 1;\r
-\r
-    prefixsz = strlen(prefix) + 1;\r
-\r
-    while (1) {\r
-        char *delim = strchr(defpath, DELIM);\r
-\r
-        if (is_absolute(defpath) == 0)\r
-            /* Paths are relative to prefix */\r
-            bufsz += prefixsz;\r
-\r
-        if (delim)\r
-            bufsz += delim - defpath + 1;\r
-        else {\r
-            bufsz += strlen(defpath) + 1;\r
-            break;\r
-        }\r
-        defpath = delim + 1;\r
-    }\r
-\r
-    bufsz += strlen(zip_path) + 1;\r
-    bufsz += strlen(exec_prefix) + 1;\r
-\r
-    /* This is the only malloc call in this file */\r
-    buf = (char *)PyMem_Malloc(bufsz);\r
-\r
-    if (buf == NULL) {\r
-        /* We can't exit, so print a warning and limp along */\r
-        fprintf(stderr, "Not enough memory for dynamic PYTHONPATH.\n");\r
-        fprintf(stderr, "Using default static PYTHONPATH.\n");\r
-        module_search_path = PYTHONPATH;\r
-    }\r
-    else {\r
-        /* Run-time value of $PYTHONPATH goes first */\r
-        if (rtpypath) {\r
-            strcpy(buf, rtpypath);\r
-            strcat(buf, delimiter);\r
-        }\r
-        else\r
-            buf[0] = '\0';\r
-\r
-        /* Next is the default zip path */\r
-        strcat(buf, zip_path);\r
-        strcat(buf, delimiter);\r
-\r
-        /* Next goes merge of compile-time $PYTHONPATH with\r
-         * dynamically located prefix.\r
-         */\r
-        defpath = pythonpath;\r
-        while (1) {\r
-            char *delim = strchr(defpath, DELIM);\r
-\r
-            if (is_absolute(defpath) != 1) {\r
-                strcat(buf, prefix);\r
-                strcat(buf, separator);\r
-            }\r
-\r
-            if (delim) {\r
-                size_t len = delim - defpath + 1;\r
-                size_t end = strlen(buf) + len;\r
-                strncat(buf, defpath, len);\r
-                *(buf + end) = '\0';\r
-            }\r
-            else {\r
-                strcat(buf, defpath);\r
-                break;\r
-            }\r
-            defpath = delim + 1;\r
-        }\r
-        strcat(buf, delimiter);\r
-\r
-        /* Finally, on goes the directory for dynamic-load modules */\r
-        strcat(buf, exec_prefix);\r
-\r
-        /* And publish the results */\r
-        module_search_path = buf;\r
-    }\r
-        /*  At this point, exec_prefix is set to VOL:/Efi/StdLib/lib/python.27/dynalib.\r
-            We want to get back to the root value, so we have to remove the final three\r
-            segments to get VOL:/Efi/StdLib.  Because we don't know what VOL is, and\r
-            EXEC_PREFIX is also indeterminate, we just remove the three final segments.\r
-        */\r
-        reduce(exec_prefix);\r
-        reduce(exec_prefix);\r
-        reduce(exec_prefix);\r
-        if (!exec_prefix[0]) {\r
-          strcpy(exec_prefix, volume_name);\r
-        }\r
-        bufsz = strlen(exec_prefix);\r
-        if(exec_prefix[bufsz-1] == ':') {\r
-          exec_prefix[bufsz] = SEP;\r
-          exec_prefix[bufsz+1] = 0;\r
-        }\r
-    if (Py_VerboseFlag) PySys_WriteStderr("%s[%d]: module_search_path = \"%s\"\n", __func__, __LINE__, module_search_path);\r
-    if (Py_VerboseFlag) PySys_WriteStderr("%s[%d]: prefix             = \"%s\"\n", __func__, __LINE__, prefix);\r
-    if (Py_VerboseFlag) PySys_WriteStderr("%s[%d]: exec_prefix        = \"%s\"\n", __func__, __LINE__, exec_prefix);\r
-    if (Py_VerboseFlag) PySys_WriteStderr("%s[%d]: progpath           = \"%s\"\n", __func__, __LINE__, progpath);\r
-}\r
-\r
-\r
-/* External interface */\r
-\r
-char *\r
-Py_GetPath(void)\r
-{\r
-    if (!module_search_path)\r
-        calculate_path();\r
-    return module_search_path;\r
-}\r
-\r
-char *\r
-Py_GetPrefix(void)\r
-{\r
-    if (!module_search_path)\r
-        calculate_path();\r
-    return prefix;\r
-}\r
-\r
-char *\r
-Py_GetExecPrefix(void)\r
-{\r
-    if (!module_search_path)\r
-        calculate_path();\r
-    return exec_prefix;\r
-}\r
-\r
-char *\r
-Py_GetProgramFullPath(void)\r
-{\r
-    if (!module_search_path)\r
-        calculate_path();\r
-    return progpath;\r
-}\r
-\r
-\r
-#ifdef __cplusplus\r
-}\r
-#endif\r
-\r