cpython/Python/preconfig.c

#include "Python.h"
#include "pycore_fileutils.h"     // DECODE_LOCALE_ERR
#include "pycore_getopt.h"        // _PyOS_GetOpt()
#include "pycore_initconfig.h"    // _PyArgv
#include "pycore_pylifecycle.h"   // _Py_LegacyLocaleDetected()
#include "pycore_pymem.h"         // _PyMem_GetAllocatorName()
#include "pycore_runtime.h"       // _PyRuntime_Initialize()

#include <locale.h>               // setlocale()
#include <stdlib.h>               // getenv()


/* Forward declarations */
static void
preconfig_copy(PyPreConfig *config, const PyPreConfig *config2);


/* --- File system encoding/errors -------------------------------- */

const char *Py_FileSystemDefaultEncoding =;
int Py_HasFileSystemDefaultEncoding =;
const char *Py_FileSystemDefaultEncodeErrors =;
int _Py_HasFileSystemDefaultEncodeErrors =;

void
_Py_ClearFileSystemEncoding(void)
{}


/* Set Py_FileSystemDefaultEncoding and Py_FileSystemDefaultEncodeErrors
   global configuration variables to PyConfig.filesystem_encoding and
   PyConfig.filesystem_errors (encoded to UTF-8).

   Function called by _PyUnicode_InitEncodings(). */
int
_Py_SetFileSystemEncoding(const char *encoding, const char *errors)
{}


/* --- _PyArgv ---------------------------------------------------- */

/* Decode bytes_argv using Py_DecodeLocale() */
PyStatus
_PyArgv_AsWstrList(const _PyArgv *args, PyWideStringList *list)
{}


/* --- _PyPreCmdline ------------------------------------------------- */

void
_PyPreCmdline_Clear(_PyPreCmdline *cmdline)
{}


PyStatus
_PyPreCmdline_SetArgv(_PyPreCmdline *cmdline, const _PyArgv *args)
{}


static void
precmdline_get_preconfig(_PyPreCmdline *cmdline, const PyPreConfig *config)
{}


static void
precmdline_set_preconfig(const _PyPreCmdline *cmdline, PyPreConfig *config)
{}


PyStatus
_PyPreCmdline_SetConfig(const _PyPreCmdline *cmdline, PyConfig *config)
{}


/* Parse the command line arguments */
static PyStatus
precmdline_parse_cmdline(_PyPreCmdline *cmdline)
{}


PyStatus
_PyPreCmdline_Read(_PyPreCmdline *cmdline, const PyPreConfig *preconfig)
{}


/* --- PyPreConfig ----------------------------------------------- */


void
_PyPreConfig_InitCompatConfig(PyPreConfig *config)
{}


void
PyPreConfig_InitPythonConfig(PyPreConfig *config)
{}


void
PyPreConfig_InitIsolatedConfig(PyPreConfig *config)
{}


PyStatus
_PyPreConfig_InitFromPreConfig(PyPreConfig *config,
                               const PyPreConfig *config2)
{}


void
_PyPreConfig_InitFromConfig(PyPreConfig *preconfig, const PyConfig *config)
{}


static void
preconfig_copy(PyPreConfig *config, const PyPreConfig *config2)
{}


PyObject*
_PyPreConfig_AsDict(const PyPreConfig *config)
{}


void
_PyPreConfig_GetConfig(PyPreConfig *preconfig, const PyConfig *config)
{}


static void
preconfig_get_global_vars(PyPreConfig *config)
{}


static void
preconfig_set_global_vars(const PyPreConfig *config)
{}


const char*
_Py_GetEnv(int use_environment, const char *name)
{}


int
_Py_str_to_int(const char *str, int *result)
{}


void
_Py_get_env_flag(int use_environment, int *flag, const char *name)
{}


const wchar_t*
_Py_get_xoption(const PyWideStringList *xoptions, const wchar_t *name)
{}


static PyStatus
preconfig_init_utf8_mode(PyPreConfig *config, const _PyPreCmdline *cmdline)
{}


static void
preconfig_init_coerce_c_locale(PyPreConfig *config)
{}


static PyStatus
preconfig_init_allocator(PyPreConfig *config)
{}


static PyStatus
preconfig_read(PyPreConfig *config, _PyPreCmdline *cmdline)
{}


/* Read the configuration from:

   - command line arguments
   - environment variables
   - Py_xxx global configuration variables
   - the LC_CTYPE locale */
PyStatus
_PyPreConfig_Read(PyPreConfig *config, const _PyArgv *args)
{}


/* Write the pre-configuration:

   - set the memory allocators
   - set Py_xxx global configuration variables
   - set the LC_CTYPE locale (coerce C locale, PEP 538) and set the UTF-8 mode
     (PEP 540)

   The applied configuration is written into _PyRuntime.preconfig.
   If the C locale cannot be coerced, set coerce_c_locale to 0.

   Do nothing if called after Py_Initialize(): ignore the new
   pre-configuration. */
PyStatus
_PyPreConfig_Write(const PyPreConfig *src_config)
{}