Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:06:48

0001 #ifndef Py_CODECREGISTRY_H
0002 #define Py_CODECREGISTRY_H
0003 #ifdef __cplusplus
0004 extern "C" {
0005 #endif
0006 
0007 /* ------------------------------------------------------------------------
0008 
0009    Python Codec Registry and support functions
0010 
0011 
0012 Written by Marc-Andre Lemburg (mal@lemburg.com).
0013 
0014 Copyright (c) Corporation for National Research Initiatives.
0015 
0016    ------------------------------------------------------------------------ */
0017 
0018 /* Register a new codec search function.
0019 
0020    As side effect, this tries to load the encodings package, if not
0021    yet done, to make sure that it is always first in the list of
0022    search functions.
0023 
0024    The search_function's refcount is incremented by this function. */
0025 
0026 PyAPI_FUNC(int) PyCodec_Register(
0027        PyObject *search_function
0028        );
0029 
0030 /* Unregister a codec search function and clear the registry's cache.
0031    If the search function is not registered, do nothing.
0032    Return 0 on success. Raise an exception and return -1 on error. */
0033 
0034 PyAPI_FUNC(int) PyCodec_Unregister(
0035        PyObject *search_function
0036        );
0037 
0038 /* Codec registry lookup API.
0039 
0040    Looks up the given encoding and returns a CodecInfo object with
0041    function attributes which implement the different aspects of
0042    processing the encoding.
0043 
0044    The encoding string is looked up converted to all lower-case
0045    characters. This makes encodings looked up through this mechanism
0046    effectively case-insensitive.
0047 
0048    If no codec is found, a KeyError is set and NULL returned.
0049 
0050    As side effect, this tries to load the encodings package, if not
0051    yet done. This is part of the lazy load strategy for the encodings
0052    package.
0053 
0054  */
0055 
0056 #ifndef Py_LIMITED_API
0057 PyAPI_FUNC(PyObject *) _PyCodec_Lookup(
0058        const char *encoding
0059        );
0060 
0061 PyAPI_FUNC(int) _PyCodec_Forget(
0062        const char *encoding
0063        );
0064 #endif
0065 
0066 /* Codec registry encoding check API.
0067 
0068    Returns 1/0 depending on whether there is a registered codec for
0069    the given encoding.
0070 
0071 */
0072 
0073 PyAPI_FUNC(int) PyCodec_KnownEncoding(
0074        const char *encoding
0075        );
0076 
0077 /* Generic codec based encoding API.
0078 
0079    object is passed through the encoder function found for the given
0080    encoding using the error handling method defined by errors. errors
0081    may be NULL to use the default method defined for the codec.
0082 
0083    Raises a LookupError in case no encoder can be found.
0084 
0085  */
0086 
0087 PyAPI_FUNC(PyObject *) PyCodec_Encode(
0088        PyObject *object,
0089        const char *encoding,
0090        const char *errors
0091        );
0092 
0093 /* Generic codec based decoding API.
0094 
0095    object is passed through the decoder function found for the given
0096    encoding using the error handling method defined by errors. errors
0097    may be NULL to use the default method defined for the codec.
0098 
0099    Raises a LookupError in case no encoder can be found.
0100 
0101  */
0102 
0103 PyAPI_FUNC(PyObject *) PyCodec_Decode(
0104        PyObject *object,
0105        const char *encoding,
0106        const char *errors
0107        );
0108 
0109 #ifndef Py_LIMITED_API
0110 /* Text codec specific encoding and decoding API.
0111 
0112    Checks the encoding against a list of codecs which do not
0113    implement a str<->bytes encoding before attempting the
0114    operation.
0115 
0116    Please note that these APIs are internal and should not
0117    be used in Python C extensions.
0118 
0119    XXX (ncoghlan): should we make these, or something like them, public
0120    in Python 3.5+?
0121 
0122  */
0123 PyAPI_FUNC(PyObject *) _PyCodec_LookupTextEncoding(
0124        const char *encoding,
0125        const char *alternate_command
0126        );
0127 
0128 PyAPI_FUNC(PyObject *) _PyCodec_EncodeText(
0129        PyObject *object,
0130        const char *encoding,
0131        const char *errors
0132        );
0133 
0134 PyAPI_FUNC(PyObject *) _PyCodec_DecodeText(
0135        PyObject *object,
0136        const char *encoding,
0137        const char *errors
0138        );
0139 
0140 /* These two aren't actually text encoding specific, but _io.TextIOWrapper
0141  * is the only current API consumer.
0142  */
0143 PyAPI_FUNC(PyObject *) _PyCodecInfo_GetIncrementalDecoder(
0144        PyObject *codec_info,
0145        const char *errors
0146        );
0147 
0148 PyAPI_FUNC(PyObject *) _PyCodecInfo_GetIncrementalEncoder(
0149        PyObject *codec_info,
0150        const char *errors
0151        );
0152 #endif
0153 
0154 
0155 
0156 /* --- Codec Lookup APIs --------------------------------------------------
0157 
0158    All APIs return a codec object with incremented refcount and are
0159    based on _PyCodec_Lookup().  The same comments w/r to the encoding
0160    name also apply to these APIs.
0161 
0162 */
0163 
0164 /* Get an encoder function for the given encoding. */
0165 
0166 PyAPI_FUNC(PyObject *) PyCodec_Encoder(
0167        const char *encoding
0168        );
0169 
0170 /* Get a decoder function for the given encoding. */
0171 
0172 PyAPI_FUNC(PyObject *) PyCodec_Decoder(
0173        const char *encoding
0174        );
0175 
0176 /* Get an IncrementalEncoder object for the given encoding. */
0177 
0178 PyAPI_FUNC(PyObject *) PyCodec_IncrementalEncoder(
0179        const char *encoding,
0180        const char *errors
0181        );
0182 
0183 /* Get an IncrementalDecoder object function for the given encoding. */
0184 
0185 PyAPI_FUNC(PyObject *) PyCodec_IncrementalDecoder(
0186        const char *encoding,
0187        const char *errors
0188        );
0189 
0190 /* Get a StreamReader factory function for the given encoding. */
0191 
0192 PyAPI_FUNC(PyObject *) PyCodec_StreamReader(
0193        const char *encoding,
0194        PyObject *stream,
0195        const char *errors
0196        );
0197 
0198 /* Get a StreamWriter factory function for the given encoding. */
0199 
0200 PyAPI_FUNC(PyObject *) PyCodec_StreamWriter(
0201        const char *encoding,
0202        PyObject *stream,
0203        const char *errors
0204        );
0205 
0206 /* Unicode encoding error handling callback registry API */
0207 
0208 /* Register the error handling callback function error under the given
0209    name. This function will be called by the codec when it encounters
0210    unencodable characters/undecodable bytes and doesn't know the
0211    callback name, when name is specified as the error parameter
0212    in the call to the encode/decode function.
0213    Return 0 on success, -1 on error */
0214 PyAPI_FUNC(int) PyCodec_RegisterError(const char *name, PyObject *error);
0215 
0216 /* Lookup the error handling callback function registered under the given
0217    name. As a special case NULL can be passed, in which case
0218    the error handling callback for "strict" will be returned. */
0219 PyAPI_FUNC(PyObject *) PyCodec_LookupError(const char *name);
0220 
0221 /* raise exc as an exception */
0222 PyAPI_FUNC(PyObject *) PyCodec_StrictErrors(PyObject *exc);
0223 
0224 /* ignore the unicode error, skipping the faulty input */
0225 PyAPI_FUNC(PyObject *) PyCodec_IgnoreErrors(PyObject *exc);
0226 
0227 /* replace the unicode encode error with ? or U+FFFD */
0228 PyAPI_FUNC(PyObject *) PyCodec_ReplaceErrors(PyObject *exc);
0229 
0230 /* replace the unicode encode error with XML character references */
0231 PyAPI_FUNC(PyObject *) PyCodec_XMLCharRefReplaceErrors(PyObject *exc);
0232 
0233 /* replace the unicode encode error with backslash escapes (\x, \u and \U) */
0234 PyAPI_FUNC(PyObject *) PyCodec_BackslashReplaceErrors(PyObject *exc);
0235 
0236 #if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03050000
0237 /* replace the unicode encode error with backslash escapes (\N, \x, \u and \U) */
0238 PyAPI_FUNC(PyObject *) PyCodec_NameReplaceErrors(PyObject *exc);
0239 #endif
0240 
0241 #ifndef Py_LIMITED_API
0242 PyAPI_DATA(const char *) Py_hexdigits;
0243 #endif
0244 
0245 #ifdef __cplusplus
0246 }
0247 #endif
0248 #endif /* !Py_CODECREGISTRY_H */