2 * Copyright 1998-2016 The OpenSSL Project Authors. All Rights Reserved.
4 * Licensed under the OpenSSL license (the "License"). You may not use
5 * this file except in compliance with the License. You can obtain a copy
6 * in the file LICENSE in the source distribution or at
7 * https://www.openssl.org/source/license.html
13 #include <openssl/objects.h>
14 #include <openssl/comp.h>
17 COMP_CTX *COMP_CTX_new(COMP_METHOD *meth)
21 if ((ret = OPENSSL_zalloc(sizeof(*ret))) == NULL)
24 if ((ret->meth->init != NULL) && !ret->meth->init(ret)) {
31 const COMP_METHOD *COMP_CTX_get_method(const COMP_CTX *ctx)
36 int COMP_get_type(const COMP_METHOD *meth)
41 const char *COMP_get_name(const COMP_METHOD *meth)
46 void COMP_CTX_free(COMP_CTX *ctx)
51 if (ctx->meth->finish != NULL)
52 ctx->meth->finish(ctx);
57 int COMP_compress_block(COMP_CTX *ctx, unsigned char *out, int olen,
58 unsigned char *in, int ilen)
61 if (ctx->meth->compress == NULL) {
64 ret = ctx->meth->compress(ctx, out, olen, in, ilen);
66 ctx->compress_in += ilen;
67 ctx->compress_out += ret;
72 int COMP_expand_block(COMP_CTX *ctx, unsigned char *out, int olen,
73 unsigned char *in, int ilen)
77 if (ctx->meth->expand == NULL) {
80 ret = ctx->meth->expand(ctx, out, olen, in, ilen);
82 ctx->expand_in += ilen;
83 ctx->expand_out += ret;
88 int COMP_CTX_get_type(const COMP_CTX* comp)
90 return comp->meth ? comp->meth->type : NID_undef;