]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
CLEANUP: compression: statify all algo-specific functions
authorWilly Tarreau <w@1wt.eu>
Sat, 28 Mar 2015 14:46:00 +0000 (15:46 +0100)
committerWilly Tarreau <w@1wt.eu>
Sat, 28 Mar 2015 14:46:00 +0000 (15:46 +0100)
There's no reason for exporting identity_* nor deflate_*, they're only
used in the same file. Mark them static, it will make it easier to add
other algorithms.

include/proto/compression.h
src/compression.c

index 5eeb5c7a8d686b3e8d40f7c8067822ab965d1fcd..e5ae8b615afb5fd96a94cb11d1d7e5f6407b9f0e 100644 (file)
@@ -35,24 +35,8 @@ int http_compression_buffer_init(struct session *s, struct buffer *in, struct bu
 int http_compression_buffer_add_data(struct session *s, struct buffer *in, struct buffer *out);
 int http_compression_buffer_end(struct session *s, struct buffer **in, struct buffer **out, int end);
 
-int identity_init(struct comp_ctx **comp_ctx, int level);
-int identity_add_data(struct comp_ctx *comp_ctx, const char *in_data, int in_len, struct buffer *out);
-int identity_flush(struct comp_ctx *comp_ctx, struct buffer *out, int flag);
-int identity_reset(struct comp_ctx *comp_ctx);
-int identity_end(struct comp_ctx **comp_ctx);
-
-
-
 #ifdef USE_ZLIB
 extern long zlib_used_memory;
-
-int deflate_init(struct comp_ctx **comp_ctx, int level);
-int deflate_add_data(struct comp_ctx *comp_ctx, const char *in_data, int in_len, struct buffer *out);
-int deflate_flush(struct comp_ctx *comp_ctx, struct buffer *out, int flag);
-int deflate_reset(struct comp_ctx *comp_ctx);
-int deflate_end(struct comp_ctx **comp_ctx);
-
-int gzip_init(struct comp_ctx **comp_ctx, int level);
 #endif /* USE_ZLIB */
 
 #endif /* _PROTO_COMP_H */
index 074902e4d63f800ed6db6aee489700fecca9e6e5..eadeb9d5f9b63a07764f11c8f2aaddc7a38c4998 100644 (file)
@@ -55,6 +55,21 @@ long zlib_used_memory = 0;
 unsigned int compress_min_idle = 0;
 static struct pool_head *pool_comp_ctx = NULL;
 
+static int identity_init(struct comp_ctx **comp_ctx, int level);
+static int identity_add_data(struct comp_ctx *comp_ctx, const char *in_data, int in_len, struct buffer *out);
+static int identity_flush(struct comp_ctx *comp_ctx, struct buffer *out, int flag);
+static int identity_reset(struct comp_ctx *comp_ctx);
+static int identity_end(struct comp_ctx **comp_ctx);
+
+#ifdef USE_ZLIB
+static int gzip_init(struct comp_ctx **comp_ctx, int level);
+static int deflate_init(struct comp_ctx **comp_ctx, int level);
+static int deflate_add_data(struct comp_ctx *comp_ctx, const char *in_data, int in_len, struct buffer *out);
+static int deflate_flush(struct comp_ctx *comp_ctx, struct buffer *out, int flag);
+static int deflate_reset(struct comp_ctx *comp_ctx);
+static int deflate_end(struct comp_ctx **comp_ctx);
+#endif /* USE_ZLIB */
+
 
 const struct comp_algo comp_algos[] =
 {
@@ -374,7 +389,7 @@ static inline int deinit_comp_ctx(struct comp_ctx **comp_ctx)
 /*
  * Init the identity algorithm
  */
-int identity_init(struct comp_ctx **comp_ctx, int level)
+static int identity_init(struct comp_ctx **comp_ctx, int level)
 {
        return 0;
 }
@@ -383,7 +398,7 @@ int identity_init(struct comp_ctx **comp_ctx, int level)
  * Process data
  *   Return size of consumed data or -1 on error
  */
-int identity_add_data(struct comp_ctx *comp_ctx, const char *in_data, int in_len, struct buffer *out)
+static int identity_add_data(struct comp_ctx *comp_ctx, const char *in_data, int in_len, struct buffer *out)
 {
        char *out_data = bi_end(out);
        int out_len = out->size - buffer_len(out);
@@ -398,12 +413,12 @@ int identity_add_data(struct comp_ctx *comp_ctx, const char *in_data, int in_len
        return in_len;
 }
 
-int identity_flush(struct comp_ctx *comp_ctx, struct buffer *out, int flag)
+static int identity_flush(struct comp_ctx *comp_ctx, struct buffer *out, int flag)
 {
        return 0;
 }
 
-int identity_reset(struct comp_ctx *comp_ctx)
+static int identity_reset(struct comp_ctx *comp_ctx)
 {
        return 0;
 }
@@ -411,7 +426,7 @@ int identity_reset(struct comp_ctx *comp_ctx)
 /*
  * Deinit the algorithm
  */
-int identity_end(struct comp_ctx **comp_ctx)
+static int identity_end(struct comp_ctx **comp_ctx)
 {
        return 0;
 }
@@ -506,7 +521,7 @@ static void free_zlib(void *opaque, void *ptr)
 /**************************
 ****  gzip algorithm   ****
 ***************************/
-int gzip_init(struct comp_ctx **comp_ctx, int level)
+static int gzip_init(struct comp_ctx **comp_ctx, int level)
 {
        z_stream *strm;
 
@@ -528,7 +543,7 @@ int gzip_init(struct comp_ctx **comp_ctx, int level)
 **** Deflate algorithm ****
 ***************************/
 
-int deflate_init(struct comp_ctx **comp_ctx, int level)
+static int deflate_init(struct comp_ctx **comp_ctx, int level)
 {
        z_stream *strm;
 
@@ -548,7 +563,7 @@ int deflate_init(struct comp_ctx **comp_ctx, int level)
 }
 
 /* Return the size of consumed data or -1 */
-int deflate_add_data(struct comp_ctx *comp_ctx, const char *in_data, int in_len, struct buffer *out)
+static int deflate_add_data(struct comp_ctx *comp_ctx, const char *in_data, int in_len, struct buffer *out)
 {
        int ret;
        z_stream *strm = &comp_ctx->strm;
@@ -577,7 +592,7 @@ int deflate_add_data(struct comp_ctx *comp_ctx, const char *in_data, int in_len,
        return in_len - strm->avail_in;
 }
 
-int deflate_flush(struct comp_ctx *comp_ctx, struct buffer *out, int flag)
+static int deflate_flush(struct comp_ctx *comp_ctx, struct buffer *out, int flag)
 {
        int ret;
        int out_len = 0;
@@ -611,7 +626,7 @@ int deflate_flush(struct comp_ctx *comp_ctx, struct buffer *out, int flag)
        return out_len;
 }
 
-int deflate_reset(struct comp_ctx *comp_ctx)
+static int deflate_reset(struct comp_ctx *comp_ctx)
 {
        z_stream *strm = &comp_ctx->strm;
 
@@ -620,7 +635,7 @@ int deflate_reset(struct comp_ctx *comp_ctx)
        return -1;
 }
 
-int deflate_end(struct comp_ctx **comp_ctx)
+static int deflate_end(struct comp_ctx **comp_ctx)
 {
        z_stream *strm = &(*comp_ctx)->strm;
        int ret;