Where Online Learning is simpler!
The C and C++ Include Header Files
cat -n /usr/include/python3.14/internal/pycore_fileutils.h
1 #ifndef Py_INTERNAL_FILEUTILS_H 2 #define Py_INTERNAL_FILEUTILS_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 <locale.h> // struct lconv 12 #include "pycore_interp_structs.h" // _Py_error_handler 13 14 15 /* A routine to check if a file descriptor can be select()-ed. */ 16 #ifdef _MSC_VER 17 /* On Windows, any socket fd can be select()-ed, no matter how high */ 18 #define _PyIsSelectable_fd(FD) (1) 19 #else 20 #define _PyIsSelectable_fd(FD) ((unsigned int)(FD) < (unsigned int)FD_SETSIZE) 21 #endif 22 23 // Export for '_testinternalcapi' shared extension 24 PyAPI_FUNC(_Py_error_handler) _Py_GetErrorHandler(const char *errors); 25 26 // Export for '_testinternalcapi' shared extension 27 PyAPI_FUNC(int) _Py_DecodeLocaleEx( 28 const char *arg, 29 wchar_t **wstr, 30 size_t *wlen, 31 const char **reason, 32 int current_locale, 33 _Py_error_handler errors); 34 35 // Export for '_testinternalcapi' shared extension 36 PyAPI_FUNC(int) _Py_EncodeLocaleEx( 37 const wchar_t *text, 38 char **str, 39 size_t *error_pos, 40 const char **reason, 41 int current_locale, 42 _Py_error_handler errors); 43 44 extern char* _Py_EncodeLocaleRaw( 45 const wchar_t *text, 46 size_t *error_pos); 47 48 extern PyObject* _Py_device_encoding(int); 49 50 #if defined(MS_WINDOWS) || defined(__APPLE__) 51 /* On Windows, the count parameter of read() is an int (bpo-9015, bpo-9611). 52 On macOS 10.13, read() and write() with more than INT_MAX bytes 53 fail with EINVAL (bpo-24658). */ 54 # define _PY_READ_MAX INT_MAX 55 # define _PY_WRITE_MAX INT_MAX 56 #else 57 /* write() should truncate the input to PY_SSIZE_T_MAX bytes, 58 but it's safer to do it ourself to have a portable behaviour */ 59 # define _PY_READ_MAX PY_SSIZE_T_MAX 60 # define _PY_WRITE_MAX PY_SSIZE_T_MAX 61 #endif 62 63 #ifdef MS_WINDOWS 64 struct _Py_stat_struct { 65 uint64_t st_dev; 66 uint64_t st_ino; 67 unsigned short st_mode; 68 int st_nlink; 69 int st_uid; 70 int st_gid; 71 unsigned long st_rdev; 72 __int64 st_size; 73 time_t st_atime; 74 int st_atime_nsec; 75 time_t st_mtime; 76 int st_mtime_nsec; 77 time_t st_ctime; 78 int st_ctime_nsec; 79 time_t st_birthtime; 80 int st_birthtime_nsec; 81 unsigned long st_file_attributes; 82 unsigned long st_reparse_tag; 83 uint64_t st_ino_high; 84 }; 85 #else 86 # define _Py_stat_struct stat 87 #endif 88 89 // Export for 'mmap' shared extension 90 PyAPI_FUNC(int) _Py_fstat( 91 int fd, 92 struct _Py_stat_struct *status); 93 94 // Export for 'mmap' shared extension 95 PyAPI_FUNC(int) _Py_fstat_noraise( 96 int fd, 97 struct _Py_stat_struct *status); 98 99 // Export for '_tkinter' shared extension 100 PyAPI_FUNC(int) _Py_stat( 101 PyObject *path, 102 struct stat *status); 103 104 // Export for 'select' shared extension (Solaris newDevPollObject()) 105 PyAPI_FUNC(int) _Py_open( 106 const char *pathname, 107 int flags); 108 109 // Export for '_posixsubprocess' shared extension 110 PyAPI_FUNC(int) _Py_open_noraise( 111 const char *pathname, 112 int flags); 113 114 extern FILE* _Py_wfopen( 115 const wchar_t *path, 116 const wchar_t *mode); 117 118 extern Py_ssize_t _Py_read( 119 int fd, 120 void *buf, 121 size_t count); 122 123 // Export for 'select' shared extension (Solaris devpoll_flush()) 124 PyAPI_FUNC(Py_ssize_t) _Py_write( 125 int fd, 126 const void *buf, 127 size_t count); 128 129 // Export for '_posixsubprocess' shared extension 130 PyAPI_FUNC(Py_ssize_t) _Py_write_noraise( 131 int fd, 132 const void *buf, 133 size_t count); 134 135 #ifdef HAVE_READLINK 136 extern int _Py_wreadlink( 137 const wchar_t *path, 138 wchar_t *buf, 139 /* Number of characters of 'buf' buffer 140 including the trailing NUL character */ 141 size_t buflen); 142 #endif 143 144 #ifdef HAVE_REALPATH 145 extern wchar_t* _Py_wrealpath( 146 const wchar_t *path, 147 wchar_t *resolved_path, 148 /* Number of characters of 'resolved_path' buffer 149 including the trailing NUL character */ 150 size_t resolved_path_len); 151 #endif 152 153 extern wchar_t* _Py_wgetcwd( 154 wchar_t *buf, 155 /* Number of characters of 'buf' buffer 156 including the trailing NUL character */ 157 size_t buflen); 158 159 extern int _Py_get_inheritable(int fd); 160 161 // Export for '_socket' shared extension 162 PyAPI_FUNC(int) _Py_set_inheritable(int fd, int inheritable, 163 int *atomic_flag_works); 164 165 // Export for '_posixsubprocess' shared extension 166 PyAPI_FUNC(int) _Py_set_inheritable_async_safe(int fd, int inheritable, 167 int *atomic_flag_works); 168 169 // Export for '_socket' shared extension 170 PyAPI_FUNC(int) _Py_dup(int fd); 171 172 extern int _Py_get_blocking(int fd); 173 174 extern int _Py_set_blocking(int fd, int blocking); 175 176 #ifdef MS_WINDOWS 177 extern void* _Py_get_osfhandle_noraise(int fd); 178 179 // Export for '_testconsole' shared extension 180 PyAPI_FUNC(void*) _Py_get_osfhandle(int fd); 181 182 extern int _Py_open_osfhandle_noraise(void *handle, int flags); 183 184 extern int _Py_open_osfhandle(void *handle, int flags); 185 #endif /* MS_WINDOWS */ 186 187 // This is used after getting NULL back from Py_DecodeLocale(). 188 #define DECODE_LOCALE_ERR(NAME, LEN) \ 189 ((LEN) == (size_t)-2) \ 190 ? _PyStatus_ERR("cannot decode " NAME) \ 191 : _PyStatus_NO_MEMORY() 192 193 extern int _Py_HasFileSystemDefaultEncodeErrors; 194 195 extern int _Py_DecodeUTF8Ex( 196 const char *arg, 197 Py_ssize_t arglen, 198 wchar_t **wstr, 199 size_t *wlen, 200 const char **reason, 201 _Py_error_handler errors); 202 203 extern int _Py_EncodeUTF8Ex( 204 const wchar_t *text, 205 char **str, 206 size_t *error_pos, 207 const char **reason, 208 int raw_malloc, 209 _Py_error_handler errors); 210 211 extern wchar_t* _Py_DecodeUTF8_surrogateescape( 212 const char *arg, 213 Py_ssize_t arglen, 214 size_t *wlen); 215 216 extern int 217 _Py_wstat(const wchar_t *, struct stat *); 218 219 extern int _Py_GetForceASCII(void); 220 221 /* Reset "force ASCII" mode (if it was initialized). 222 223 This function should be called when Python changes the LC_CTYPE locale, 224 so the "force ASCII" mode can be detected again on the new locale 225 encoding. */ 226 extern void _Py_ResetForceASCII(void); 227 228 229 extern int _Py_GetLocaleconvNumeric( 230 struct lconv *lc, 231 PyObject **decimal_point, 232 PyObject **thousands_sep); 233 234 // Export for '_posixsubprocess' (on macOS) 235 PyAPI_FUNC(void) _Py_closerange(int first, int last); 236 237 extern wchar_t* _Py_GetLocaleEncoding(void); 238 extern PyObject* _Py_GetLocaleEncodingObject(void); 239 240 #ifdef HAVE_NON_UNICODE_WCHAR_T_REPRESENTATION 241 extern int _Py_LocaleUsesNonUnicodeWchar(void); 242 243 extern wchar_t* _Py_DecodeNonUnicodeWchar( 244 const wchar_t* native, 245 Py_ssize_t size); 246 247 extern int _Py_EncodeNonUnicodeWchar_InPlace( 248 wchar_t* unicode, 249 Py_ssize_t size); 250 #endif 251 252 extern int _Py_isabs(const wchar_t *path); 253 extern int _Py_abspath(const wchar_t *path, wchar_t **abspath_p); 254 #ifdef MS_WINDOWS 255 extern int _PyOS_getfullpathname(const wchar_t *path, wchar_t **abspath_p); 256 #endif 257 extern wchar_t* _Py_join_relfile(const wchar_t *dirname, 258 const wchar_t *relfile); 259 extern int _Py_add_relfile(wchar_t *dirname, 260 const wchar_t *relfile, 261 size_t bufsize); 262 extern size_t _Py_find_basename(const wchar_t *filename); 263 264 // Export for '_testinternalcapi' shared extension 265 PyAPI_FUNC(wchar_t*) _Py_normpath(wchar_t *path, Py_ssize_t size); 266 267 extern wchar_t *_Py_normpath_and_size(wchar_t *path, Py_ssize_t size, Py_ssize_t *length); 268 269 // The Windows Games API family does not provide these functions 270 // so provide our own implementations. Remove them in case they get added 271 // to the Games API family 272 #if defined(MS_WINDOWS_GAMES) && !defined(MS_WINDOWS_DESKTOP) 273 #include <winerror.h> // HRESULT 274 275 extern HRESULT PathCchSkipRoot(const wchar_t *pszPath, const wchar_t **ppszRootEnd); 276 #endif /* defined(MS_WINDOWS_GAMES) && !defined(MS_WINDOWS_DESKTOP) */ 277 278 extern void _Py_skiproot(const wchar_t *path, Py_ssize_t size, Py_ssize_t *drvsize, Py_ssize_t *rootsize); 279 280 // Macros to protect CRT calls against instant termination when passed an 281 // invalid parameter (bpo-23524). IPH stands for Invalid Parameter Handler. 282 // Usage: 283 // 284 // _Py_BEGIN_SUPPRESS_IPH 285 // ... 286 // _Py_END_SUPPRESS_IPH 287 #if defined _MSC_VER && _MSC_VER >= 1900 288 289 # include <stdlib.h> // _set_thread_local_invalid_parameter_handler() 290 291 extern _invalid_parameter_handler _Py_silent_invalid_parameter_handler; 292 # define _Py_BEGIN_SUPPRESS_IPH \ 293 { _invalid_parameter_handler _Py_old_handler = \ 294 _set_thread_local_invalid_parameter_handler(_Py_silent_invalid_parameter_handler); 295 # define _Py_END_SUPPRESS_IPH \ 296 _set_thread_local_invalid_parameter_handler(_Py_old_handler); } 297 #else 298 # define _Py_BEGIN_SUPPRESS_IPH 299 # define _Py_END_SUPPRESS_IPH 300 #endif /* _MSC_VER >= 1900 */ 301 302 // Export for 'select' shared extension (Argument Clinic code) 303 PyAPI_FUNC(int) _PyLong_FileDescriptor_Converter(PyObject *, void *); 304 305 // Export for test_peg_generator 306 PyAPI_FUNC(char*) _Py_UniversalNewlineFgetsWithSize(char *, int, FILE*, PyObject *, size_t*); 307 308 extern int _PyFile_Flush(PyObject *); 309 310 #ifndef MS_WINDOWS 311 extern int _Py_GetTicksPerSecond(long *ticks_per_second); 312 #endif 313 314 // Export for '_testcapi' shared extension 315 PyAPI_FUNC(int) _Py_IsValidFD(int fd); 316 317 #ifdef __cplusplus 318 } 319 #endif 320 #endif /* !Py_INTERNAL_FILEUTILS_H */