| 1 |
|
| 2 |
|
| 3 |
use crate::Py_ssize_t; |
| 4 |
use libc::wchar_t; |
| 5 |
use std::ffi::{c_char, c_int, c_ulong}; |
| 6 |
|
| 7 |
#[repr(C)] |
| 8 |
#[derive(Copy, Clone, Debug, PartialEq, Eq)] |
| 9 |
pub enum _PyStatus_TYPE { |
| 10 |
_PyStatus_TYPE_OK = 0, |
| 11 |
_PyStatus_TYPE_ERROR = 1, |
| 12 |
_PyStatus_TYPE_EXIT = 2, |
| 13 |
} |
| 14 |
|
| 15 |
#[repr(C)] |
| 16 |
#[derive(Copy, Clone)] |
| 17 |
pub struct PyStatus { |
| 18 |
pub _type: _PyStatus_TYPE, |
| 19 |
pub func: *const c_char, |
| 20 |
pub err_msg: *const c_char, |
| 21 |
pub exitcode: c_int, |
| 22 |
} |
| 23 |
|
| 24 |
extern "C" { |
| 25 |
pub fn PyStatus_Ok() -> PyStatus; |
| 26 |
pub fn PyStatus_Error(err_msg: *const c_char) -> PyStatus; |
| 27 |
pub fn PyStatus_NoMemory() -> PyStatus; |
| 28 |
pub fn PyStatus_Exit(exitcode: c_int) -> PyStatus; |
| 29 |
pub fn PyStatus_IsError(err: PyStatus) -> c_int; |
| 30 |
pub fn PyStatus_IsExit(err: PyStatus) -> c_int; |
| 31 |
pub fn PyStatus_Exception(err: PyStatus) -> c_int; |
| 32 |
} |
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
#[repr(C)] |
| 37 |
#[derive(Copy, Clone)] |
| 38 |
pub struct PyWideStringList { |
| 39 |
pub length: Py_ssize_t, |
| 40 |
pub items: *mut *mut wchar_t, |
| 41 |
} |
| 42 |
|
| 43 |
extern "C" { |
| 44 |
pub fn PyWideStringList_Append(list: *mut PyWideStringList, item: *const wchar_t) -> PyStatus; |
| 45 |
pub fn PyWideStringList_Insert( |
| 46 |
list: *mut PyWideStringList, |
| 47 |
index: Py_ssize_t, |
| 48 |
item: *const wchar_t, |
| 49 |
) -> PyStatus; |
| 50 |
} |
| 51 |
|
| 52 |
|
| 53 |
|
| 54 |
#[repr(C)] |
| 55 |
#[derive(Copy, Clone)] |
| 56 |
pub struct PyPreConfig { |
| 57 |
pub _config_init: c_int, |
| 58 |
pub parse_argv: c_int, |
| 59 |
pub isolated: c_int, |
| 60 |
pub use_environment: c_int, |
| 61 |
pub configure_locale: c_int, |
| 62 |
pub coerce_c_locale: c_int, |
| 63 |
pub coerce_c_locale_warn: c_int, |
| 64 |
|
| 65 |
#[cfg(windows)] |
| 66 |
pub legacy_windows_fs_encoding: c_int, |
| 67 |
|
| 68 |
pub utf8_mode: c_int, |
| 69 |
pub dev_mode: c_int, |
| 70 |
pub allocator: c_int, |
| 71 |
} |
| 72 |
|
| 73 |
extern "C" { |
| 74 |
pub fn PyPreConfig_InitPythonConfig(config: *mut PyPreConfig); |
| 75 |
pub fn PyPreConfig_InitIsolatedConfig(config: *mut PyPreConfig); |
| 76 |
} |
| 77 |
|
| 78 |
|
| 79 |
|
| 80 |
#[repr(C)] |
| 81 |
#[derive(Copy, Clone)] |
| 82 |
pub struct PyConfig { |
| 83 |
pub _config_init: c_int, |
| 84 |
pub isolated: c_int, |
| 85 |
pub use_environment: c_int, |
| 86 |
pub dev_mode: c_int, |
| 87 |
pub install_signal_handlers: c_int, |
| 88 |
pub use_hash_seed: c_int, |
| 89 |
pub hash_seed: c_ulong, |
| 90 |
pub faulthandler: c_int, |
| 91 |
#[cfg(all(Py_3_9, not(Py_3_10)))] |
| 92 |
pub _use_peg_parser: c_int, |
| 93 |
pub tracemalloc: c_int, |
| 94 |
#[cfg(Py_3_12)] |
| 95 |
pub perf_profiling: c_int, |
| 96 |
#[cfg(Py_3_14)] |
| 97 |
pub remote_debug: c_int, |
| 98 |
pub import_time: c_int, |
| 99 |
#[cfg(Py_3_11)] |
| 100 |
pub code_debug_ranges: c_int, |
| 101 |
pub show_ref_count: c_int, |
| 102 |
#[cfg(not(Py_3_9))] |
| 103 |
pub show_alloc_count: c_int, |
| 104 |
pub dump_refs: c_int, |
| 105 |
#[cfg(Py_3_11)] |
| 106 |
pub dump_refs_file: *mut wchar_t, |
| 107 |
pub malloc_stats: c_int, |
| 108 |
pub filesystem_encoding: *mut wchar_t, |
| 109 |
pub filesystem_errors: *mut wchar_t, |
| 110 |
pub pycache_prefix: *mut wchar_t, |
| 111 |
pub parse_argv: c_int, |
| 112 |
#[cfg(Py_3_10)] |
| 113 |
pub orig_argv: PyWideStringList, |
| 114 |
pub argv: PyWideStringList, |
| 115 |
#[cfg(not(Py_3_10))] |
| 116 |
pub program_name: *mut wchar_t, |
| 117 |
pub xoptions: PyWideStringList, |
| 118 |
pub warnoptions: PyWideStringList, |
| 119 |
pub site_import: c_int, |
| 120 |
pub bytes_warning: c_int, |
| 121 |
#[cfg(Py_3_10)] |
| 122 |
pub warn_default_encoding: c_int, |
| 123 |
pub inspect: c_int, |
| 124 |
pub interactive: c_int, |
| 125 |
pub optimization_level: c_int, |
| 126 |
pub parser_debug: c_int, |
| 127 |
pub write_bytecode: c_int, |
| 128 |
pub verbose: c_int, |
| 129 |
pub quiet: c_int, |
| 130 |
pub user_site_directory: c_int, |
| 131 |
pub configure_c_stdio: c_int, |
| 132 |
pub buffered_stdio: c_int, |
| 133 |
pub stdio_encoding: *mut wchar_t, |
| 134 |
pub stdio_errors: *mut wchar_t, |
| 135 |
|
| 136 |
#[cfg(windows)] |
| 137 |
pub legacy_windows_stdio: c_int, |
| 138 |
|
| 139 |
pub check_hash_pycs_mode: *mut wchar_t, |
| 140 |
#[cfg(Py_3_11)] |
| 141 |
pub use_frozen_modules: c_int, |
| 142 |
#[cfg(Py_3_11)] |
| 143 |
pub safe_path: c_int, |
| 144 |
#[cfg(Py_3_12)] |
| 145 |
pub int_max_str_digits: c_int, |
| 146 |
#[cfg(Py_3_14)] |
| 147 |
pub thread_inherit_context: c_int, |
| 148 |
#[cfg(Py_3_14)] |
| 149 |
pub context_aware_warnings: c_int, |
| 150 |
#[cfg(all(Py_3_14, target_os = "macos"))] |
| 151 |
pub use_system_logger: c_int, |
| 152 |
#[cfg(Py_3_13)] |
| 153 |
pub cpu_count: c_int, |
| 154 |
#[cfg(Py_GIL_DISABLED)] |
| 155 |
pub enable_gil: c_int, |
| 156 |
#[cfg(all(Py_3_14, Py_GIL_DISABLED))] |
| 157 |
pub tlbc_enabled: c_int, |
| 158 |
pub pathconfig_warnings: c_int, |
| 159 |
#[cfg(Py_3_10)] |
| 160 |
pub program_name: *mut wchar_t, |
| 161 |
pub pythonpath_env: *mut wchar_t, |
| 162 |
pub home: *mut wchar_t, |
| 163 |
#[cfg(Py_3_10)] |
| 164 |
pub platlibdir: *mut wchar_t, |
| 165 |
|
| 166 |
pub module_search_paths_set: c_int, |
| 167 |
pub module_search_paths: PyWideStringList, |
| 168 |
#[cfg(Py_3_11)] |
| 169 |
pub stdlib_dir: *mut wchar_t, |
| 170 |
pub executable: *mut wchar_t, |
| 171 |
pub base_executable: *mut wchar_t, |
| 172 |
pub prefix: *mut wchar_t, |
| 173 |
pub base_prefix: *mut wchar_t, |
| 174 |
pub exec_prefix: *mut wchar_t, |
| 175 |
pub base_exec_prefix: *mut wchar_t, |
| 176 |
#[cfg(all(Py_3_9, not(Py_3_10)))] |
| 177 |
pub platlibdir: *mut wchar_t, |
| 178 |
pub skip_source_first_line: c_int, |
| 179 |
pub run_command: *mut wchar_t, |
| 180 |
pub run_module: *mut wchar_t, |
| 181 |
pub run_filename: *mut wchar_t, |
| 182 |
#[cfg(Py_3_13)] |
| 183 |
pub sys_path_0: *mut wchar_t, |
| 184 |
pub _install_importlib: c_int, |
| 185 |
pub _init_main: c_int, |
| 186 |
#[cfg(all(Py_3_9, not(Py_3_12)))] |
| 187 |
pub _isolated_interpreter: c_int, |
| 188 |
#[cfg(Py_3_11)] |
| 189 |
pub _is_python_build: c_int, |
| 190 |
#[cfg(all(Py_3_9, not(Py_3_10)))] |
| 191 |
pub _orig_argv: PyWideStringList, |
| 192 |
#[cfg(all(Py_3_13, py_sys_config = "Py_DEBUG"))] |
| 193 |
pub run_presite: *mut wchar_t, |
| 194 |
} |
| 195 |
|
| 196 |
extern "C" { |
| 197 |
pub fn PyConfig_InitPythonConfig(config: *mut PyConfig); |
| 198 |
pub fn PyConfig_InitIsolatedConfig(config: *mut PyConfig); |
| 199 |
pub fn PyConfig_Clear(config: *mut PyConfig); |
| 200 |
pub fn PyConfig_SetString( |
| 201 |
config: *mut PyConfig, |
| 202 |
config_str: *mut *mut wchar_t, |
| 203 |
str: *const wchar_t, |
| 204 |
) -> PyStatus; |
| 205 |
pub fn PyConfig_SetBytesString( |
| 206 |
config: *mut PyConfig, |
| 207 |
config_str: *mut *mut wchar_t, |
| 208 |
str: *const c_char, |
| 209 |
) -> PyStatus; |
| 210 |
pub fn PyConfig_Read(config: *mut PyConfig) -> PyStatus; |
| 211 |
pub fn PyConfig_SetBytesArgv( |
| 212 |
config: *mut PyConfig, |
| 213 |
argc: Py_ssize_t, |
| 214 |
argv: *mut *const c_char, |
| 215 |
) -> PyStatus; |
| 216 |
pub fn PyConfig_SetArgv( |
| 217 |
config: *mut PyConfig, |
| 218 |
argc: Py_ssize_t, |
| 219 |
argv: *mut *const wchar_t, |
| 220 |
) -> PyStatus; |
| 221 |
pub fn PyConfig_SetWideStringList( |
| 222 |
config: *mut PyConfig, |
| 223 |
list: *mut PyWideStringList, |
| 224 |
length: Py_ssize_t, |
| 225 |
items: *mut *mut wchar_t, |
| 226 |
) -> PyStatus; |
| 227 |
} |
| 228 |
|
| 229 |
|
| 230 |
|
| 231 |
extern "C" { |
| 232 |
pub fn Py_GetArgcArgv(argc: *mut c_int, argv: *mut *mut *mut wchar_t); |
| 233 |
} |