comp.h 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. #ifndef HEADER_COMP_H
  2. # define HEADER_COMP_H
  3. # include <openssl/crypto.h>
  4. # ifdef OPENSSL_NO_COMP
  5. # error COMP is disabled.
  6. # endif
  7. #ifdef __cplusplus
  8. extern "C" {
  9. #endif
  10. typedef struct comp_ctx_st COMP_CTX;
  11. struct comp_method_st {
  12. int type; /* NID for compression library */
  13. const char *name; /* A text string to identify the library */
  14. int (*init) (COMP_CTX *ctx);
  15. void (*finish) (COMP_CTX *ctx);
  16. int (*compress) (COMP_CTX *ctx,
  17. unsigned char *out, unsigned int olen,
  18. unsigned char *in, unsigned int ilen);
  19. int (*expand) (COMP_CTX *ctx,
  20. unsigned char *out, unsigned int olen,
  21. unsigned char *in, unsigned int ilen);
  22. /*
  23. * The following two do NOTHING, but are kept for backward compatibility
  24. */
  25. long (*ctrl) (void);
  26. long (*callback_ctrl) (void);
  27. };
  28. struct comp_ctx_st {
  29. COMP_METHOD *meth;
  30. unsigned long compress_in;
  31. unsigned long compress_out;
  32. unsigned long expand_in;
  33. unsigned long expand_out;
  34. CRYPTO_EX_DATA ex_data;
  35. };
  36. COMP_CTX *COMP_CTX_new(COMP_METHOD *meth);
  37. void COMP_CTX_free(COMP_CTX *ctx);
  38. int COMP_compress_block(COMP_CTX *ctx, unsigned char *out, int olen,
  39. unsigned char *in, int ilen);
  40. int COMP_expand_block(COMP_CTX *ctx, unsigned char *out, int olen,
  41. unsigned char *in, int ilen);
  42. COMP_METHOD *COMP_rle(void);
  43. COMP_METHOD *COMP_zlib(void);
  44. void COMP_zlib_cleanup(void);
  45. # ifdef HEADER_BIO_H
  46. # ifdef ZLIB
  47. BIO_METHOD *BIO_f_zlib(void);
  48. # endif
  49. # endif
  50. /* BEGIN ERROR CODES */
  51. /*
  52. * The following lines are auto generated by the script mkerr.pl. Any changes
  53. * made after this point may be overwritten when the script is next run.
  54. */
  55. void ERR_load_COMP_strings(void);
  56. /* Error codes for the COMP functions. */
  57. /* Function codes. */
  58. # define COMP_F_BIO_ZLIB_FLUSH 99
  59. # define COMP_F_BIO_ZLIB_NEW 100
  60. # define COMP_F_BIO_ZLIB_READ 101
  61. # define COMP_F_BIO_ZLIB_WRITE 102
  62. /* Reason codes. */
  63. # define COMP_R_ZLIB_DEFLATE_ERROR 99
  64. # define COMP_R_ZLIB_INFLATE_ERROR 100
  65. # define COMP_R_ZLIB_NOT_SUPPORTED 101
  66. #ifdef __cplusplus
  67. }
  68. #endif
  69. #endif