Counter Strike : Global Offensive Source Code
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

167 lines
4.9 KiB

  1. #ifndef Py_CODECREGISTRY_H
  2. #define Py_CODECREGISTRY_H
  3. #ifdef __cplusplus
  4. extern "C" {
  5. #endif
  6. /* ------------------------------------------------------------------------
  7. Python Codec Registry and support functions
  8. Written by Marc-Andre Lemburg (mal@lemburg.com).
  9. Copyright (c) Corporation for National Research Initiatives.
  10. ------------------------------------------------------------------------ */
  11. /* Register a new codec search function.
  12. As side effect, this tries to load the encodings package, if not
  13. yet done, to make sure that it is always first in the list of
  14. search functions.
  15. The search_function's refcount is incremented by this function. */
  16. PyAPI_FUNC(int) PyCodec_Register(
  17. PyObject *search_function
  18. );
  19. /* Codec register lookup API.
  20. Looks up the given encoding and returns a CodecInfo object with
  21. function attributes which implement the different aspects of
  22. processing the encoding.
  23. The encoding string is looked up converted to all lower-case
  24. characters. This makes encodings looked up through this mechanism
  25. effectively case-insensitive.
  26. If no codec is found, a KeyError is set and NULL returned.
  27. As side effect, this tries to load the encodings package, if not
  28. yet done. This is part of the lazy load strategy for the encodings
  29. package.
  30. */
  31. PyAPI_FUNC(PyObject *) _PyCodec_Lookup(
  32. const char *encoding
  33. );
  34. /* Generic codec based encoding API.
  35. object is passed through the encoder function found for the given
  36. encoding using the error handling method defined by errors. errors
  37. may be NULL to use the default method defined for the codec.
  38. Raises a LookupError in case no encoder can be found.
  39. */
  40. PyAPI_FUNC(PyObject *) PyCodec_Encode(
  41. PyObject *object,
  42. const char *encoding,
  43. const char *errors
  44. );
  45. /* Generic codec based decoding API.
  46. object is passed through the decoder function found for the given
  47. encoding using the error handling method defined by errors. errors
  48. may be NULL to use the default method defined for the codec.
  49. Raises a LookupError in case no encoder can be found.
  50. */
  51. PyAPI_FUNC(PyObject *) PyCodec_Decode(
  52. PyObject *object,
  53. const char *encoding,
  54. const char *errors
  55. );
  56. /* --- Codec Lookup APIs --------------------------------------------------
  57. All APIs return a codec object with incremented refcount and are
  58. based on _PyCodec_Lookup(). The same comments w/r to the encoding
  59. name also apply to these APIs.
  60. */
  61. /* Get an encoder function for the given encoding. */
  62. PyAPI_FUNC(PyObject *) PyCodec_Encoder(
  63. const char *encoding
  64. );
  65. /* Get a decoder function for the given encoding. */
  66. PyAPI_FUNC(PyObject *) PyCodec_Decoder(
  67. const char *encoding
  68. );
  69. /* Get a IncrementalEncoder object for the given encoding. */
  70. PyAPI_FUNC(PyObject *) PyCodec_IncrementalEncoder(
  71. const char *encoding,
  72. const char *errors
  73. );
  74. /* Get a IncrementalDecoder object function for the given encoding. */
  75. PyAPI_FUNC(PyObject *) PyCodec_IncrementalDecoder(
  76. const char *encoding,
  77. const char *errors
  78. );
  79. /* Get a StreamReader factory function for the given encoding. */
  80. PyAPI_FUNC(PyObject *) PyCodec_StreamReader(
  81. const char *encoding,
  82. PyObject *stream,
  83. const char *errors
  84. );
  85. /* Get a StreamWriter factory function for the given encoding. */
  86. PyAPI_FUNC(PyObject *) PyCodec_StreamWriter(
  87. const char *encoding,
  88. PyObject *stream,
  89. const char *errors
  90. );
  91. /* Unicode encoding error handling callback registry API */
  92. /* Register the error handling callback function error under the name
  93. name. This function will be called by the codec when it encounters
  94. unencodable characters/undecodable bytes and doesn't know the
  95. callback name, when name is specified as the error parameter
  96. in the call to the encode/decode function.
  97. Return 0 on success, -1 on error */
  98. PyAPI_FUNC(int) PyCodec_RegisterError(const char *name, PyObject *error);
  99. /* Lookup the error handling callback function registered under the
  100. name error. As a special case NULL can be passed, in which case
  101. the error handling callback for "strict" will be returned. */
  102. PyAPI_FUNC(PyObject *) PyCodec_LookupError(const char *name);
  103. /* raise exc as an exception */
  104. PyAPI_FUNC(PyObject *) PyCodec_StrictErrors(PyObject *exc);
  105. /* ignore the unicode error, skipping the faulty input */
  106. PyAPI_FUNC(PyObject *) PyCodec_IgnoreErrors(PyObject *exc);
  107. /* replace the unicode error with ? or U+FFFD */
  108. PyAPI_FUNC(PyObject *) PyCodec_ReplaceErrors(PyObject *exc);
  109. /* replace the unicode encode error with XML character references */
  110. PyAPI_FUNC(PyObject *) PyCodec_XMLCharRefReplaceErrors(PyObject *exc);
  111. /* replace the unicode encode error with backslash escapes (\x, \u and \U) */
  112. PyAPI_FUNC(PyObject *) PyCodec_BackslashReplaceErrors(PyObject *exc);
  113. #ifdef __cplusplus
  114. }
  115. #endif
  116. #endif /* !Py_CODECREGISTRY_H */