Where Online Learning is simpler!
The C and C++ Include Header Files
cat -n /usr/include/python3.14/internal/pycore_initconfig.h
1 #ifndef Py_INTERNAL_CORECONFIG_H 2 #define Py_INTERNAL_CORECONFIG_H 3 #ifdef __cplusplus 4 extern "C" { 5 #endif 6 7 #ifndef Py_BUILD_CORE 8 # error "this header requires Py_BUILD_CORE define" 9 #endif 10 11 #include "pycore_typedefs.h" // _PyRuntimeState 12 13 /* --- PyStatus ----------------------------------------------- */ 14 15 /* Almost all errors causing Python initialization to fail */ 16 #ifdef _MSC_VER 17 /* Visual Studio 2015 doesn't implement C99 __func__ in C */ 18 # define _PyStatus_GET_FUNC() __FUNCTION__ 19 #else 20 # define _PyStatus_GET_FUNC() __func__ 21 #endif 22 23 #define _PyStatus_OK() \ 24 (PyStatus){._type = _PyStatus_TYPE_OK} 25 /* other fields are set to 0 */ 26 #define _PyStatus_ERR(ERR_MSG) \ 27 (PyStatus){ \ 28 ._type = _PyStatus_TYPE_ERROR, \ 29 .func = _PyStatus_GET_FUNC(), \ 30 .err_msg = (ERR_MSG)} 31 /* other fields are set to 0 */ 32 #define _PyStatus_NO_MEMORY_ERRMSG "memory allocation failed" 33 #define _PyStatus_NO_MEMORY() _PyStatus_ERR(_PyStatus_NO_MEMORY_ERRMSG) 34 #define _PyStatus_EXIT(EXITCODE) \ 35 (PyStatus){ \ 36 ._type = _PyStatus_TYPE_EXIT, \ 37 .exitcode = (EXITCODE)} 38 #define _PyStatus_IS_ERROR(err) \ 39 ((err)._type == _PyStatus_TYPE_ERROR) 40 #define _PyStatus_IS_EXIT(err) \ 41 ((err)._type == _PyStatus_TYPE_EXIT) 42 #define _PyStatus_EXCEPTION(err) \ 43 ((err)._type != _PyStatus_TYPE_OK) 44 #define _PyStatus_UPDATE_FUNC(err) \ 45 do { (err).func = _PyStatus_GET_FUNC(); } while (0) 46 47 // Export for '_testinternalcapi' shared extension 48 PyAPI_FUNC(void) _PyErr_SetFromPyStatus(PyStatus status); 49 50 51 /* --- PyWideStringList ------------------------------------------------ */ 52 53 #define _PyWideStringList_INIT (PyWideStringList){.length = 0, .items = NULL} 54 55 #ifndef NDEBUG 56 extern int _PyWideStringList_CheckConsistency(const PyWideStringList *list); 57 #endif 58 extern void _PyWideStringList_Clear(PyWideStringList *list); 59 extern int _PyWideStringList_Copy(PyWideStringList *list, 60 const PyWideStringList *list2); 61 extern PyStatus _PyWideStringList_Extend(PyWideStringList *list, 62 const PyWideStringList *list2); 63 extern PyObject* _PyWideStringList_AsList(const PyWideStringList *list); 64 65 66 /* --- _PyArgv ---------------------------------------------------- */ 67 68 typedef struct _PyArgv { 69 Py_ssize_t argc; 70 int use_bytes_argv; 71 char * const *bytes_argv; 72 wchar_t * const *wchar_argv; 73 } _PyArgv; 74 75 extern PyStatus _PyArgv_AsWstrList(const _PyArgv *args, 76 PyWideStringList *list); 77 78 79 /* --- Helper functions ------------------------------------------- */ 80 81 extern int _Py_str_to_int( 82 const char *str, 83 int *result); 84 extern const wchar_t* _Py_get_xoption( 85 const PyWideStringList *xoptions, 86 const wchar_t *name); 87 extern const char* _Py_GetEnv( 88 int use_environment, 89 const char *name); 90 extern void _Py_get_env_flag( 91 int use_environment, 92 int *flag, 93 const char *name); 94 95 /* Py_GetArgcArgv() helper */ 96 extern void _Py_ClearArgcArgv(void); 97 98 99 /* --- _PyPreCmdline ------------------------------------------------- */ 100 101 typedef struct { 102 PyWideStringList argv; 103 PyWideStringList xoptions; /* "-X value" option */ 104 int isolated; /* -I option */ 105 int use_environment; /* -E option */ 106 int dev_mode; /* -X dev and PYTHONDEVMODE */ 107 int warn_default_encoding; /* -X warn_default_encoding and PYTHONWARNDEFAULTENCODING */ 108 } _PyPreCmdline; 109 110 #define _PyPreCmdline_INIT \ 111 (_PyPreCmdline){ \ 112 .use_environment = -1, \ 113 .isolated = -1, \ 114 .dev_mode = -1} 115 /* Note: _PyPreCmdline_INIT sets other fields to 0/NULL */ 116 117 extern void _PyPreCmdline_Clear(_PyPreCmdline *cmdline); 118 extern PyStatus _PyPreCmdline_SetArgv(_PyPreCmdline *cmdline, 119 const _PyArgv *args); 120 extern PyStatus _PyPreCmdline_SetConfig( 121 const _PyPreCmdline *cmdline, 122 PyConfig *config); 123 extern PyStatus _PyPreCmdline_Read(_PyPreCmdline *cmdline, 124 const PyPreConfig *preconfig); 125 126 127 /* --- PyPreConfig ----------------------------------------------- */ 128 129 // Export for '_testembed' program 130 PyAPI_FUNC(void) _PyPreConfig_InitCompatConfig(PyPreConfig *preconfig); 131 132 extern void _PyPreConfig_InitFromConfig( 133 PyPreConfig *preconfig, 134 const PyConfig *config); 135 extern PyStatus _PyPreConfig_InitFromPreConfig( 136 PyPreConfig *preconfig, 137 const PyPreConfig *config2); 138 extern PyObject* _PyPreConfig_AsDict(const PyPreConfig *preconfig); 139 extern void _PyPreConfig_GetConfig(PyPreConfig *preconfig, 140 const PyConfig *config); 141 extern PyStatus _PyPreConfig_Read(PyPreConfig *preconfig, 142 const _PyArgv *args); 143 extern PyStatus _PyPreConfig_Write(const PyPreConfig *preconfig); 144 145 146 /* --- PyConfig ---------------------------------------------- */ 147 148 typedef enum { 149 /* Py_Initialize() API: backward compatibility with Python 3.6 and 3.7 */ 150 _PyConfig_INIT_COMPAT = 1, 151 _PyConfig_INIT_PYTHON = 2, 152 _PyConfig_INIT_ISOLATED = 3 153 } _PyConfigInitEnum; 154 155 typedef enum { 156 /* In free threaded builds, this means that the GIL is disabled at startup, 157 but may be enabled by loading an incompatible extension module. */ 158 _PyConfig_GIL_DEFAULT = -1, 159 160 /* The GIL has been forced off or on, and will not be affected by module loading. */ 161 _PyConfig_GIL_DISABLE = 0, 162 _PyConfig_GIL_ENABLE = 1, 163 } _PyConfigGILEnum; 164 165 // Export for '_testembed' program 166 PyAPI_FUNC(void) _PyConfig_InitCompatConfig(PyConfig *config); 167 168 extern PyStatus _PyConfig_Copy( 169 PyConfig *config, 170 const PyConfig *config2); 171 extern PyStatus _PyConfig_InitPathConfig( 172 PyConfig *config, 173 int compute_path_config); 174 extern PyStatus _PyConfig_InitImportConfig(PyConfig *config); 175 extern PyStatus _PyConfig_Read(PyConfig *config, int compute_path_config); 176 extern PyStatus _PyConfig_Write(const PyConfig *config, 177 _PyRuntimeState *runtime); 178 extern PyStatus _PyConfig_SetPyArgv( 179 PyConfig *config, 180 const _PyArgv *args); 181 extern PyObject* _PyConfig_CreateXOptionsDict(const PyConfig *config); 182 183 extern void _Py_DumpPathConfig(PyThreadState *tstate); 184 185 186 /* --- Function used for testing ---------------------------------- */ 187 188 // Export these functions for '_testinternalcapi' shared extension 189 PyAPI_FUNC(PyObject*) _PyConfig_AsDict(const PyConfig *config); 190 PyAPI_FUNC(int) _PyConfig_FromDict(PyConfig *config, PyObject *dict); 191 PyAPI_FUNC(PyObject*) _Py_Get_Getpath_CodeObject(void); 192 PyAPI_FUNC(PyObject*) _Py_GetConfigsAsDict(void); 193 194 #ifdef __cplusplus 195 } 196 #endif 197 #endif /* !Py_INTERNAL_CORECONFIG_H */