From 2de1d8494990ba00848c5270873ca0d085c8bc62 Mon Sep 17 00:00:00 2001 From: chtsanti Date: Mon, 13 Mar 2017 11:05:21 +0000 Subject: [PATCH 001/108] branching c-icap 0.5.x release git-svn-id: https://svn.code.sf.net/p/c-icap/code/c-icap-server/branches/c_icap_0_5_x@1278 950cb5d8-81e4-40ab-8cb8-c719d5138fe1 From 31b7785c05e840df7ce1def4869f6f4988e5f52e Mon Sep 17 00:00:00 2001 From: chtsanti Date: Mon, 13 Mar 2017 11:35:00 +0000 Subject: [PATCH 002/108] marking c-icap 0.5.0 release git-svn-id: https://svn.code.sf.net/p/c-icap/code/c-icap-server/branches/c_icap_0_5_x@1279 950cb5d8-81e4-40ab-8cb8-c719d5138fe1 --- configure.ac | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/configure.ac b/configure.ac index dde0ac9f..722d5174 100644 --- a/configure.ac +++ b/configure.ac @@ -1,9 +1,9 @@ dnl Process this file with autoconf to produce a configure script. -AC_INIT(c_icap,m4_normalize(m4_include([VERSION.m4]))) -dnl AC_INIT(c_icap,030606rc1) -CICAPLIB_VERSION=0:1:0 +dnl AC_INIT(c_icap,m4_normalize(m4_include([VERSION.m4]))) +AC_INIT(c_icap,0.5.0) +CICAPLIB_VERSION=5:0:0 AC_SUBST(CICAPLIB_VERSION) dnl CICAPLIB_VERSION is the libtool current[:revision[:age]] version info dnl libtool directions about version info From 517a52356b4818c949d3261828278893c8979038 Mon Sep 17 00:00:00 2001 From: chtsanti Date: Mon, 20 Mar 2017 20:21:15 +0000 Subject: [PATCH 003/108] documentation fixes git-svn-id: https://svn.code.sf.net/p/c-icap/code/c-icap-server/branches/c_icap_0_5_x@1281 950cb5d8-81e4-40ab-8cb8-c719d5138fe1 --- c-icap.conf.in | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/c-icap.conf.in b/c-icap.conf.in index 1afab31a..ef2df53d 100644 --- a/c-icap.conf.in +++ b/c-icap.conf.in @@ -131,8 +131,8 @@ MaxRequestsPerChild 0 # None Port 1344 -# TAG: SSLPort -# Format: SSLPort [address:]port [tls-method=method] [cert=path_to_pem_cert] [key=path_to_pem_key] [client_ca=path_to_pem_file] [ciphers=ciph1:ciph2...] [tls_options=[!]Opt1|[!]Opt2|...] +# TAG: TlsPort +# Format: TlsPort [address:]port [tls-method=method] [cert=path_to_pem_cert] [key=path_to_pem_key] [client_ca=path_to_pem_file] [ciphers=ciph1:ciph2...] [tls_options=[!]Opt1|[!]Opt2|...] # Description: # The port number that the c-icap server uses to listen for TLS/SSL # requests. Options: @@ -182,16 +182,16 @@ Port 1344 # Default: # None -# TAG: SslPassphrase -# Format: SslPassphrase /path/to/script +# TAG: TlsPassphrase +# Format: TlsPassphrase /path/to/script # Description: -# Path to the script to run to get the passphrases of SSL certificates +# Path to the script to run to get the passphrases of TLS certificates # keys. The c-icap will pass as arguments the IP address and port number # to the script. # Default: # No value # Example: -# SslPassphrase /use/local/c-icap/scripts/cert-passphrase.sh +# TlsPassphrase /use/local/c-icap/scripts/cert-passphrase.sh # TAG: User # Format: User username From ef31dc4d6a1cf77cdabec11445102356f5e1d310 Mon Sep 17 00:00:00 2001 From: chtsanti Date: Mon, 20 Mar 2017 20:30:16 +0000 Subject: [PATCH 004/108] mark c-icap-0.5.1 release git-svn-id: https://svn.code.sf.net/p/c-icap/code/c-icap-server/branches/c_icap_0_5_x@1282 950cb5d8-81e4-40ab-8cb8-c719d5138fe1 --- configure.ac | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/configure.ac b/configure.ac index 722d5174..5c72d1bd 100644 --- a/configure.ac +++ b/configure.ac @@ -2,8 +2,8 @@ dnl Process this file with autoconf to produce a configure script. dnl AC_INIT(c_icap,m4_normalize(m4_include([VERSION.m4]))) -AC_INIT(c_icap,0.5.0) -CICAPLIB_VERSION=5:0:0 +AC_INIT(c_icap,0.5.1) +CICAPLIB_VERSION=5:1:0 AC_SUBST(CICAPLIB_VERSION) dnl CICAPLIB_VERSION is the libtool current[:revision[:age]] version info dnl libtool directions about version info From 4788a4f788a417fae1aa0ad25f7d06466d2fa5bc Mon Sep 17 00:00:00 2001 From: chtsanti Date: Mon, 27 Mar 2017 07:57:10 +0000 Subject: [PATCH 005/108] ci_headers_value? functions should remove spaces at the start of the returned header value git-svn-id: https://svn.code.sf.net/p/c-icap/code/c-icap-server/branches/c_icap_0_5_x@1287 950cb5d8-81e4-40ab-8cb8-c719d5138fe1 --- header.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/header.c b/header.c index 03eb468d..9bf6e73b 100644 --- a/header.c +++ b/header.c @@ -349,10 +349,15 @@ static const char *do_header_search(ci_headers_list_t * h, const char *header, c continue; if (strncasecmp(check_head, header, header_size) == 0) { lval = check_head + header_size + 1; - if (value) + if (value) { + while (lval <= h_end && (*lval == ' ' || *lval == '\t')) + ++(lval); *value = lval; + } if (end) { *end = (i < h->used -1) ? (h->headers[i + 1] - 1) : (h->buf + h->bufused - 1); + if (*end < lval) /*parse error in headers ?*/ + return NULL; while ((*end > lval) && (**end == '\0' || **end == '\r' || **end == '\n')) --(*end); } return check_head; From e957344563deef4fae526875b090a315197fb8e1 Mon Sep 17 00:00:00 2001 From: chtsanti Date: Mon, 27 Mar 2017 07:58:05 +0000 Subject: [PATCH 006/108] Bug fix: c-icap crashes when converting ci_simple_file_t to a memory object Using ci_simple_file_to_const_string or ci_simple_file_to_membuf may result to c-icap crash due to uninitialised ci_simple_file_t members. git-svn-id: https://svn.code.sf.net/p/c-icap/code/c-icap-server/branches/c_icap_0_5_x@1288 950cb5d8-81e4-40ab-8cb8-c719d5138fe1 --- body.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/body.c b/body.c index a627d023..61161ff1 100644 --- a/body.c +++ b/body.c @@ -595,6 +595,10 @@ ci_simple_file_t *ci_simple_file_new(ci_off_t maxsize) body->bytes_in = 0; body->bytes_out = 0; body->attributes = NULL; +#if defined(USE_POSIX_MAPPED_FILES) + body->mmap_addr = NULL; + body->mmap_size = 0; +#endif return body; } From 92b9ac57e0c50f8f0289741f85eefb2213c85ded Mon Sep 17 00:00:00 2001 From: chtsanti Date: Mon, 27 Mar 2017 08:18:18 +0000 Subject: [PATCH 007/108] Document forceUnload=off option for Service/Module cfg parameter git-svn-id: https://svn.code.sf.net/p/c-icap/code/c-icap-server/branches/c_icap_0_5_x@1290 950cb5d8-81e4-40ab-8cb8-c719d5138fe1 --- c-icap.conf.in | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/c-icap.conf.in b/c-icap.conf.in index ef2df53d..5651cc4d 100644 --- a/c-icap.conf.in +++ b/c-icap.conf.in @@ -627,24 +627,36 @@ AccessLog @prefix@/var/log/access.log # Logger sys_logger # TAG: Module -# Format: Module Type ModuleFile +# Format: Module Type ModuleFile [forceUnload=off] # Description: # Load an external module/plugin to c-icap. -# ModuleFile is the filename of the module. If no full path given then c-icap -# searche in path defined by the ModulesDir configuration parameter. +# ModuleFile is the filename of the module. If no full path given then +# the c-icap uses the path defined by the ModulesDir configuration +# parameter. # Type is the type of the external module and can be one of the following: -# - "logger" for modules implement a logger -# - "common" for general purpose modules +# "logger" for modules implement a logger +# "common" for general purpose modules +# forceUnload=off +# Forces c-icap to not unload services/modules loaded as external +# dynamic libraries on shutdown or reconfigure. +# This option may required when the services/modules are using +# c++, or they are linked with c++ libraries. # Default: # # Example: # Module logger sys_logger.so # TAG: Service -# Format: Service aName ServiceFile +# Format: Service aName ServiceFile [forceUnload=off] # Description: # It loads the service ServiceFile. The argument aName used # as alias name for the service +# forceUnload=off +# Forces c-icap to not unload services/modules loaded as external +# dynamic libraries on shutdown or reconfigure. +# This option may required when the services/modules are using +# c++, or they are linked with c++ libraries. + # Default: # # Example: From f1923dc3b7929ef3f53c99cb1b9b0a50a0c600eb Mon Sep 17 00:00:00 2001 From: chtsanti Date: Mon, 27 Mar 2017 08:29:44 +0000 Subject: [PATCH 008/108] mark c-icap-0.5.2 release git-svn-id: https://svn.code.sf.net/p/c-icap/code/c-icap-server/branches/c_icap_0_5_x@1294 950cb5d8-81e4-40ab-8cb8-c719d5138fe1 --- configure.ac | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/configure.ac b/configure.ac index 5c72d1bd..4e51c933 100644 --- a/configure.ac +++ b/configure.ac @@ -2,8 +2,8 @@ dnl Process this file with autoconf to produce a configure script. dnl AC_INIT(c_icap,m4_normalize(m4_include([VERSION.m4]))) -AC_INIT(c_icap,0.5.1) -CICAPLIB_VERSION=5:1:0 +AC_INIT(c_icap,0.5.2) +CICAPLIB_VERSION=5:2:0 AC_SUBST(CICAPLIB_VERSION) dnl CICAPLIB_VERSION is the libtool current[:revision[:age]] version info dnl libtool directions about version info From 8f6acd6a7ff19cfdb9f6966bd52fce6a61ee88d4 Mon Sep 17 00:00:00 2001 From: chtsanti Date: Sun, 16 Jul 2017 15:36:28 +0000 Subject: [PATCH 009/108] Grab wrong cafile and capath values of TlsPort from config due to typo Author: jne100@sourceforge.net git-svn-id: https://svn.code.sf.net/p/c-icap/code/c-icap-server/branches/c_icap_0_5_x@1297 950cb5d8-81e4-40ab-8cb8-c719d5138fe1 --- openssl/net_io_ssl.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/openssl/net_io_ssl.c b/openssl/net_io_ssl.c index 8d36ed1c..7a1fa3bb 100644 --- a/openssl/net_io_ssl.c +++ b/openssl/net_io_ssl.c @@ -129,9 +129,9 @@ int icap_port_tls_option(const char *opt, ci_port_t *conf, const char *config_di } else if (strncmp(opt, "client_ca=", 10) == 0) { conf->tls_client_ca_certs = path_dup(opt + 10, config_dir); } else if (strncmp(opt, "cafile=", 7) == 0) { - conf->tls_cafile = path_dup(opt + 10, config_dir); + conf->tls_cafile = path_dup(opt + 7, config_dir); } else if (strncmp(opt, "capath=", 7) == 0) { - conf->tls_capath = path_dup(opt + 10, config_dir); + conf->tls_capath = path_dup(opt + 7, config_dir); } else if (strncmp(opt, "ciphers=", 8) == 0) { conf->tls_ciphers = strdup(opt + 8); } else if (strncmp(opt, "tls-options=", 12) == 0) { From 1ff5deb3a406fc097c453f954da5efa30e78713a Mon Sep 17 00:00:00 2001 From: chtsanti Date: Mon, 16 Oct 2017 09:28:52 +0000 Subject: [PATCH 010/108] Fixes to compile with OpenSSL-1.1.0 Still some work required to remove depedencies from deprecated openSSL API functions git-svn-id: https://svn.code.sf.net/p/c-icap/code/c-icap-server/branches/c_icap_0_5_x@1305 950cb5d8-81e4-40ab-8cb8-c719d5138fe1 --- configure.ac | 42 +++++++++++++++++++++++++++++++++--------- openssl/net_io_ssl.c | 7 +------ utils/Makefile.am | 6 +++--- 3 files changed, 37 insertions(+), 18 deletions(-) diff --git a/configure.ac b/configure.ac index 4e51c933..b78c6d36 100644 --- a/configure.ac +++ b/configure.ac @@ -275,21 +275,43 @@ case "$withval" in [ openssl=yes] ) +OPENSSL_ADD_LDADD="" +OPENSSL_ADD_FLAG="" if test a"$openssl" != "ano"; then + OLDCFLAGS=$CFLAGS + OLDLDFLAGS=$LDFLAGS + OLDLIBS=$LIBS if test a"$openssl" != "ayes"; then - OLDCFLAGS=$CFLAGS - OLDLDFLAGS=$LDFLAGS CFLAGS="$CFLAGS -I$openssl/include" LDFLAGS="$LDFLAGS -L$openssl/lib" - AC_CHECK_LIB(ssl,SSL_library_init,[OPENSSL_ADD_LDADD="-L$openssl/lib -lssl -lcrypto";OPENSSL_ADD_FLAG="-I$openssl/include";AC_DEFINE(HAVE_OPENSSL,1,[Define HAVE_OPENSSL if openssl is installed])],[openssl=no],-lcrypto) - CFLAGS=$OLDCFLAGS - LDFLAGS=$OLDLDFLAGS - AC_SUBST(OPENSSL_ADD_LDADD) - AC_SUBST(OPENSSL_ADD_FLAG) + OPENSSL_ADD_LDADD="-L$openssl/lib -lssl -lcrypto" + OPENSSL_ADD_FLAG="-I$openssl/include" + echo -n "checking for OpenSSL library under $openssl... " else - AC_CHECK_LIB(ssl,SSL_library_init,[OPENSSL_ADD_LDADD=" -lssl -lcrypto"; AC_DEFINE(HAVE_OPENSSL,1,[Define HAVE_OPENSSL if openssl is installed])],[openssl=no]) - AC_SUBST(OPENSSL_ADD_LDADD) + OPENSSL_ADD_LDADD="-lssl -lcrypto" + echo -n "checking for OpenSSL library... " fi + LIBS="$OPENSSL_ADD_LDADD $OLDLIBS" + + AC_LINK_IFELSE( + [AC_LANG_SOURCE( + [ + #include + int main(int argc, char *argv[]) + { + int ret = SSL_library_init(); + return ret; + } + ]) + ], + [echo "yes";][AC_DEFINE(HAVE_OPENSSL,1,[Define HAVE_OPENSSL if openssl is installed])], + [openssl=no; echo "no"] + ) + + + CFLAGS=$OLDCFLAGS + LDFLAGS=$OLDLDFLAGS + LIBS=$OLDLIBS fi USE_OPENSSL="1" @@ -298,6 +320,8 @@ if test a"$openssl" = "ano"; then USE_OPENSSL="0" fi AC_SUBST(USE_OPENSSL) +AC_SUBST(OPENSSL_ADD_LDADD) +AC_SUBST(OPENSSL_ADD_FLAG) AC_CHECK_LIB(dl,dlopen,DL_ADD_FLAG=" -ldl") AC_SUBST(DL_ADD_FLAG) diff --git a/openssl/net_io_ssl.c b/openssl/net_io_ssl.c index 7a1fa3bb..8cfe11a1 100644 --- a/openssl/net_io_ssl.c +++ b/openssl/net_io_ssl.c @@ -167,7 +167,7 @@ static int set_linger(int sock, int secs_to_linger) static int openssl_verify_cert_cb (int ok, X509_STORE_CTX *ctx) { if (ok == 0) { - ci_debug_printf(1, "Peer cert verification failed: %s\n", X509_verify_cert_error_string(ctx->error)); + ci_debug_printf(1, "Peer cert verification failed: %s\n", X509_verify_cert_error_string(X509_STORE_CTX_get_error(ctx))); return 0; } return 1; @@ -229,11 +229,6 @@ static const SSL_METHOD* get_tls_method(const char* method_str, int b_for_server return (b_for_server) ? SSLv3_server_method() : SSLv3_client_method(); } #endif -#ifndef OPENSSL_NO_SSL2 - else if ( 0 == strcmp(method_str, "SSLv2")) { - return (b_for_server) ? SSLv2_server_method() : SSLv2_client_method(); - } -#endif ci_debug_printf(1, "TLS/SSL method string \"%s\" not available.\n", method_str); return NULL; diff --git a/utils/Makefile.am b/utils/Makefile.am index 78f8f2c1..140d5ef1 100644 --- a/utils/Makefile.am +++ b/utils/Makefile.am @@ -16,13 +16,13 @@ endif #other ..... c_icap_client_SOURCES = c-icap-client.c c_icap_client_CFLAGS= -I../include/ -c_icap_client_LDADD= ../libicapapi.la @THREADS_LDADD@ @DL_ADD_FLAG@ @OPENSSL_ADD_LDADD@ -c_icap_client_LDFLAGS = -rdynamic -rpath @libdir@ @THREADS_LDFLAGS@ @OPENSSL_ADD_FLAG@ +c_icap_client_LDADD= ../libicapapi.la @THREADS_LDADD@ @DL_ADD_FLAG@ +c_icap_client_LDFLAGS = -rdynamic -rpath @libdir@ @THREADS_LDFLAGS@ c_icap_mkbdb_SOURCES = c-icap-mkbdb.c c_icap_mkbdb_CFLAGS= -I../include/ @BDB_ADD_FLAG@ c_icap_mkbdb_LDADD= ../libicapapi.la @THREADS_LDADD@ @DL_ADD_FLAG@ @BDB_ADD_LDADD@ -c_icap_mkbdb_LDFLAGS = -rdynamic -rpath @libdir@ @THREADS_LDFLAGS@ +c_icap_mkbdb_LDFLAGS = -rdynamic -rpath @libdir@ @THREADS_LDFLAGS@ c_icap_stretch_SOURCES = c-icap-stretch.c c_icap_stretch_CFLAGS= -I../include/ From 30add9ef64eeb2d981aa8ab850f86ced86e7573b Mon Sep 17 00:00:00 2001 From: chtsanti Date: Mon, 16 Oct 2017 09:30:11 +0000 Subject: [PATCH 011/108] Bug #96: missing call to setgroups Calling setgroups to set supplementary group IDs required before before call setgid. git-svn-id: https://svn.code.sf.net/p/c-icap/code/c-icap-server/branches/c_icap_0_5_x@1306 950cb5d8-81e4-40ab-8cb8-c719d5138fe1 --- configure.ac | 2 ++ os/unix/proc_utils.c | 9 ++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index b78c6d36..87d9c684 100644 --- a/configure.ac +++ b/configure.ac @@ -755,6 +755,8 @@ AC_CHECK_FUNCS(strncasestr, AC_DEFINE(HAVE_STRNCASESTR,1,[Define HAVE_STRNCASESTR if strncasestr exists]) ) +AC_CHECK_FUNCS(setgroups) + AC_FUNC_STRERROR_R USE_POLL="0" diff --git a/os/unix/proc_utils.c b/os/unix/proc_utils.c index 6413b7d2..a5f20b4f 100644 --- a/os/unix/proc_utils.c +++ b/os/unix/proc_utils.c @@ -112,10 +112,17 @@ int set_running_permissions(char *user, char *group) gid); return 0; } +#if HAVE_SETGROUPS + if (setgroups(1, &gid) != 0) { + ci_debug_printf(1, "setggroups to %d failed!!!!\n", gid); + perror("setgroups failure"); + return 0; + } +#endif if (setgid(gid) != 0) { ci_debug_printf(1, "setgid to %d failed!!!!\n", gid); - perror("Wtat is this; "); + perror("setgid failure"); return 0; } } From 6b23419527060472fd33fc7f0d7a35acd1fdce2e Mon Sep 17 00:00:00 2001 From: chtsanti Date: Mon, 16 Oct 2017 09:31:51 +0000 Subject: [PATCH 012/108] avoid buffer overrun while printing strings using c_debug_printf git-svn-id: https://svn.code.sf.net/p/c-icap/code/c-icap-server/branches/c_icap_0_5_x@1307 950cb5d8-81e4-40ab-8cb8-c719d5138fe1 --- request.c | 2 +- request_common.c | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/request.c b/request.c index 0b2e9c02..e257d9ec 100644 --- a/request.c +++ b/request.c @@ -1650,7 +1650,7 @@ int process_request(ci_request_t * req) res = do_request(req); if (req->pstrblock_read_len) { - ci_debug_printf(5, "There are unparsed data od size %d: \"%s\"\n. Move to connection buffer\n", req->pstrblock_read_len, req->pstrblock_read); + ci_debug_printf(5, "There are unparsed data od size %d: \"%.*s\"\n. Move to connection buffer\n", req->pstrblock_read_len, (req->pstrblock_read_len < 64 ? req->pstrblock_read_len : 64), req->pstrblock_read); } if (res<0 && req->request_header->bufused == 0) /*Did not read anything*/ diff --git a/request_common.c b/request_common.c index 87bcb1b4..0bcc37ba 100644 --- a/request_common.c +++ b/request_common.c @@ -1223,10 +1223,11 @@ static int client_parse_incoming_data(ci_request_t * req, void *data_dest, do { if ((ret = parse_chunk_data(req, &buf)) == CI_ERROR) { ci_debug_printf(1, - "Error parsing chunks, current chunk len: %d, read: %d, readlen: %d, str: %s\n", + "Error parsing chunks, current chunk len: %d, read: %d, readlen: %d, str: %.*s\n", req->current_chunk_len, req->chunk_bytes_read, req->pstrblock_read_len, + (req->pstrblock_read_len < 64 ? req->pstrblock_read_len : 64), req->pstrblock_read); return CI_ERROR; } From 4fae02fe5d88214b35761132ca8a0223e682f753 Mon Sep 17 00:00:00 2001 From: chtsanti Date: Mon, 16 Oct 2017 09:58:39 +0000 Subject: [PATCH 013/108] Define the ci_simple_file_to_const_string function even if USE_POSIX_MAPPED_FILES is not defined In the case the USE_POSIX_MAPPED_FILES is nof defined just return NULL. git-svn-id: https://svn.code.sf.net/p/c-icap/code/c-icap-server/branches/c_icap_0_5_x@1308 950cb5d8-81e4-40ab-8cb8-c719d5138fe1 --- body.c | 9 +++++---- include/body.h | 2 -- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/body.c b/body.c index 61161ff1..3ff4d42c 100644 --- a/body.c +++ b/body.c @@ -818,10 +818,9 @@ int ci_simple_file_truncate(ci_simple_file_t *body, ci_off_t new_size) return 1; } -#if defined(USE_POSIX_MAPPED_FILES) - const char * ci_simple_file_to_const_string(ci_simple_file_t *body) { +#if defined(USE_POSIX_MAPPED_FILES) ci_off_t map_size; char *addr = NULL; if (!(body->flags & CI_FILE_HAS_EOF)) { @@ -841,6 +840,10 @@ const char * ci_simple_file_to_const_string(ci_simple_file_t *body) body->mmap_size = map_size; } return body->mmap_addr; +#else + ci_debug_printf( 1, "ci_simple_file_to_const_string: Requires posix mapped files to work, which is not supported."); + return NULL; +#endif } #define CI_MEMBUF_SF_FLAGS (CI_MEMBUF_CONST | CI_MEMBUF_RO | CI_MEMBUF_NULL_TERMINATED) @@ -854,8 +857,6 @@ ci_membuf_t *ci_simple_file_to_membuf(ci_simple_file_t *body, unsigned int flags return ci_membuf_from_content(body->mmap_addr, body->mmap_size, body->endpos, CI_MEMBUF_CONST | CI_MEMBUF_RO | CI_MEMBUF_NULL_TERMINATED | CI_MEMBUF_HAS_EOF); } -#endif - /*******************************************************************/ /*ring memory buffer implementation */ diff --git a/include/body.h b/include/body.h index eb9c57ce..b680ae38 100644 --- a/include/body.h +++ b/include/body.h @@ -139,13 +139,11 @@ CI_DECLARE_FUNC(int) ci_simple_file_write(ci_simple_file_t *body, CI_DECLARE_FUNC(int) ci_simple_file_read(ci_simple_file_t *body,char *buf,int len); CI_DECLARE_FUNC(int) ci_simple_file_truncate(ci_simple_file_t *body, ci_off_t new_size); -#if defined(USE_POSIX_MAPPED_FILES) /*Currently it is just creates a MAP_PRIVATE memory. Only CI_MEMBUF_CONST flag is supported. */ CI_DECLARE_FUNC(ci_membuf_t *) ci_simple_file_to_membuf(ci_simple_file_t *body, unsigned int flags); CI_DECLARE_FUNC(const char *) ci_simple_file_to_const_string(ci_simple_file_t *body); -#endif #define ci_simple_file_lock_all(body) (body->flags|=CI_FILE_USELOCK,body->unlocked=0) #define ci_simple_file_unlock(body, len) (body->unlocked = ((body->readpos) > len ? (body->readpos) : len)) From 8ea5d36e0e51443f81faf2d1e51fb7a851d86a72 Mon Sep 17 00:00:00 2001 From: chtsanti Date: Mon, 16 Oct 2017 09:59:28 +0000 Subject: [PATCH 014/108] Fix c-icap statistics web page The info module does not return all statistics to the client because of a wrongly terminated ci_membuf structure git-svn-id: https://svn.code.sf.net/p/c-icap/code/c-icap-server/branches/c_icap_0_5_x@1309 950cb5d8-81e4-40ab-8cb8-c719d5138fe1 --- info.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/info.c b/info.c index 468332ac..850e767b 100644 --- a/info.c +++ b/info.c @@ -402,8 +402,9 @@ int build_statistics(struct info_req_data *info_data) ci_membuf_write(info_data->body,buf, sz, 0); } } - ci_membuf_write(info_data->body,tmpl->statsEnd, strlen(tmpl->statsEnd), 1); + ci_membuf_write(info_data->body,tmpl->statsEnd, strlen(tmpl->statsEnd), 0); } + ci_membuf_write(info_data->body, NULL, 0, 1); return 1; } From 08761af4cf83967881a189ffbb27d210d21e19be Mon Sep 17 00:00:00 2001 From: chtsanti Date: Sat, 21 Oct 2017 07:00:54 +0000 Subject: [PATCH 015/108] Clean up formatting Author: "Trever L. Adams" git-svn-id: https://svn.code.sf.net/p/c-icap/code/c-icap-server/branches/c_icap_0_5_x@1312 950cb5d8-81e4-40ab-8cb8-c719d5138fe1 --- COPYING | 2 +- Makefile.am | 6 +- README | 22 +- RECONF | 2 +- access.c | 4 +- acl.c | 68 +- array.c | 12 +- body.c | 38 +- c-icap-config.in | 2 +- c-icap.conf.in | 52 +- c-icap.dox | 1120 ++++++++++++++++----------------- c-icap.magic | 8 +- cache.c | 22 +- configure.ac | 50 +- contrib/get_file.pl | 6 +- debug.c | 6 +- decode.c | 20 +- default_acl.c | 8 +- docs/man/c-icap-mkbdb.8.in | 28 +- docs/man/c-icap-stretch.8.in | 2 +- docs/man/c-icap.8.in | 16 +- filetype.c | 8 +- hash.c | 14 +- header.c | 12 +- http_auth.c | 16 +- include/body.h | 18 +- include/c-icap-conf.h.in | 8 +- include/cache.h | 2 +- include/cfg_param.h | 2 +- include/filetype.h | 12 +- include/header.h | 6 +- include/net_io.h | 16 +- include/proc_threads_queues.h | 2 +- include/request.h | 12 +- include/service.h | 4 +- include/simple_api.h | 6 +- info.c | 8 +- log.c | 6 +- lookup_file_table.c | 110 ++-- lookup_table.c | 14 +- makefile.w32 | 16 +- mem.c | 40 +- modules/Makefile.am | 6 +- modules/bdb_tables.c | 12 +- modules/dnsbl_tables.c | 4 +- modules/ldap_module.c | 22 +- modules/memcached.c | 6 +- modules/shared_cache.c | 2 +- modules/sys_logger.c | 2 +- mpmt_server.c | 4 +- openssl/net_io_ssl.c | 2 +- os/unix/net_io.c | 32 +- os/win32/net_io.c | 18 +- request.c | 2 +- request_common.c | 78 +-- service.c | 12 +- services/echo/Makefile.am | 2 +- services/ex-206/Makefile.am | 2 +- simple_api.c | 8 +- stats.c | 30 +- tests/Makefile.am | 4 +- tests/test_arrays.c | 2 +- tests/test_cache.c | 6 +- tests/test_lists.c | 12 +- tests/test_tables.c | 4 +- txtTemplate.c | 6 +- txt_format.c | 60 +- types_ops.c | 84 +-- utils/c-icap-mkbdb.c | 54 +- utils/c-icap-stretch.c | 26 +- winnt_server.c | 18 +- 71 files changed, 1173 insertions(+), 1173 deletions(-) diff --git a/COPYING b/COPYING index 5ab7695a..602bfc94 100644 --- a/COPYING +++ b/COPYING @@ -146,7 +146,7 @@ such a program is covered only if its contents constitute a work based on the Library (independent of the use of the Library in a tool for writing it). Whether that is true depends on what the Library does and what the program that uses the Library does. - + 1. You may copy and distribute verbatim copies of the Library's complete source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an diff --git a/Makefile.am b/Makefile.am index aad2e93a..d6e78876 100644 --- a/Makefile.am +++ b/Makefile.am @@ -51,7 +51,7 @@ libicapapi_la_LIBADD = @ZLIB_ADD_LDADD@ @BZLIB_ADD_LDADD@ @PCRE_ADD_LDADD@ @DL_A libicapapi_la_LDFLAGS= -shared -version-info @CICAPLIB_VERSION@ @THREADS_LDFLAGS@ -#c_icap the main server +#c_icap the main server c_icap_DEPENDENCIES=libicapapi.la c_icap_CFLAGS= $(INVISIBILITY_CFLAG) -Iinclude/ \ -DCONFDIR=\"$(CONFIGDIR)\" -DMODSDIR=\"$(MODULESDIR)\" \ @@ -93,7 +93,7 @@ do_subst=sed -e 's%[@]SYSCONFDIR[@]%$(CONFIGDIR)%g' \ CLEANFILES = c-icap-config c-icap-libicapapi-config -# The c-icap.conf, c-icap-config, and c-icap-libicapapi-config must rebuild +# The c-icap.conf, c-icap-config, and c-icap-libicapapi-config must rebuild # on every new configure run. The include/c-icap-conf.h is rebuild when # configure runs so it is a good test. c-icap.conf: c-icap.conf.in include/c-icap-conf.h @@ -116,7 +116,7 @@ install-data-local: c-icap.conf $(INSTALL) c-icap.magic $(DESTDIR)$(CONFIGDIR)/c-icap.magic.default if test ! -f $(DESTDIR)$(CONFIGDIR)/c-icap.conf; then $(INSTALL) c-icap.conf $(DESTDIR)$(CONFIGDIR)/c-icap.conf; fi if test ! -f $(DESTDIR)$(CONFIGDIR)/c-icap.magic; then $(INSTALL) c-icap.magic $(DESTDIR)$(CONFIGDIR)/c-icap.magic; fi - $(mkinstalldirs) $(DESTDIR)$(LOGDIR); + $(mkinstalldirs) $(DESTDIR)$(LOGDIR); $(mkinstalldirs) $(DESTDIR)$(SOCKDIR); chgrp nogroup $(DESTDIR)$(LOGDIR) || echo -e "*********\nWARNING! Can not set group for the log dir $(DESTDIR)$(LOGDIR)\n*********\n" chmod 775 $(DESTDIR)$(LOGDIR) diff --git a/README b/README index 4cdf6715..b720e7f5 100644 --- a/README +++ b/README @@ -1,32 +1,32 @@ -This is NOT a real release. Must considered just as a stable snapshot -from cvs repository. Read the INSTALL.txt file and web pages at +This is NOT a real release. Must considered just as a stable snapshot +from cvs repository. Read the INSTALL.txt file and web pages at http://c-icap.sourceforge.net/ for information about how to configure. COMMENTS: -*c-icap is more tested in Linux systems. However compiles and runs at least -in FreeBSD 6.x and possibly in other platforms. At regular times I am -testing it also in solaris 10. I was not able to check this release due +*c-icap is more tested in Linux systems. However compiles and runs at least +in FreeBSD 6.x and possibly in other platforms. At regular times I am +testing it also in solaris 10. I was not able to check this release due to a problem in my solaris machine. I will do it soon... -*ipv6 support for Linux and Solaris looks that works OK but it is not +*ipv6 support for Linux and Solaris looks that works OK but it is not enough tested. *Although I was able to compile c-icap with IPv6 support in FreeBSD 5.x-6.x -it was not possible for me to make it to work. Maybe becouse of bugs in +it was not possible for me to make it to work. Maybe becouse of bugs in implementation maybe becouse of my inability to correctly setup the ipv6 in FreeBSD. NEW FEATURES: -* ServiceAlias: They are useful in the case the icap client has hardcoded -the service name. As an example in the default config file there is the +* ServiceAlias: They are useful in the case the icap client has hardcoded +the service name. As an example in the default config file there is the avscan service alias which can used by samba vscan-icap module. -* You can send commands to the c-icap server from command line using the +* You can send commands to the c-icap server from command line using the following syndax: echo -n command_name > /var/run/c-icap.ctl Currently the following commands are implemented: "stop": The c-icap will shutdown - "reconfigure": The service will reread the config file without the need + "reconfigure": The service will reread the config file without the need for stop and restart the c-icap server. The services will be reinitialized "relog": This command causes c_icap to close and reopen the log files. diff --git a/RECONF b/RECONF index 61477532..2820b679 100644 --- a/RECONF +++ b/RECONF @@ -1,5 +1,5 @@ echo trunk-`svnversion | cut -d ':' -f 2` > VERSION.m4 -autoreconf -f -i -v +autoreconf -f -i -v #aclocal #autoconf ##autoheader diff --git a/access.c b/access.c index 5e5f3add..5027fd46 100644 --- a/access.c +++ b/access.c @@ -91,9 +91,9 @@ int access_check_request(ci_request_t * req) res = check_request(req); - ci_debug_printf(9,"Access control: %s\n", (res==CI_ACCESS_ALLOW? + ci_debug_printf(9,"Access control: %s\n", (res == CI_ACCESS_ALLOW? "ALLOW": - (res==CI_ACCESS_DENY?"DENY":"UNKNOWN"))); + (res == CI_ACCESS_DENY?"DENY":"UNKNOWN"))); return res; } diff --git a/acl.c b/acl.c index 9ace7b0d..b5fec4be 100644 --- a/acl.c +++ b/acl.c @@ -102,49 +102,49 @@ void free_http_req_method(ci_request_t *req, void *param); void *get_data_type(ci_request_t *req, char *param); void free_data_type(ci_request_t *req,void *param); -ci_acl_type_t acl_user= { +ci_acl_type_t acl_user = { "user", get_user, NULL, &ci_str_ops }; -ci_acl_type_t acl_service= { +ci_acl_type_t acl_service = { "service", get_service, NULL, &ci_str_ops }; -ci_acl_type_t acl_req_type= { +ci_acl_type_t acl_req_type = { "type", get_reqtype, NULL, &ci_str_ops }; -ci_acl_type_t acl_tcp_port= { +ci_acl_type_t acl_tcp_port = { "port", get_port, NULL, &ci_int32_ops }; -ci_acl_type_t acl_tcp_src= { +ci_acl_type_t acl_tcp_src = { "src", get_client_ip, NULL, &ci_ip_sockaddr_ops }; -ci_acl_type_t acl_tcp_srvip= { +ci_acl_type_t acl_tcp_srvip = { "srvip", get_srv_ip, NULL, &ci_ip_sockaddr_ops }; -ci_acl_type_t acl_tcp_xclientip= { +ci_acl_type_t acl_tcp_xclientip = { "http_client_ip", get_http_client_ip, NULL, @@ -202,14 +202,14 @@ ci_acl_type_t acl_http_resp_line = { }; #endif -ci_acl_type_t acl_http_req_method= { +ci_acl_type_t acl_http_req_method = { "http_req_method", get_http_req_method, free_http_req_method, &ci_str_ops }; -ci_acl_type_t acl_data_type= { +ci_acl_type_t acl_data_type = { "data_type", get_data_type, free_data_type, @@ -258,7 +258,7 @@ static const ci_type_ops_t acl_cmp_uint64_ops = { void free_cmp_uint64_data(ci_request_t *req,void *param); void *get_content_length(ci_request_t *req, char *param); -static ci_acl_type_t acl_content_length= { +static ci_acl_type_t acl_content_length = { "content_length", get_content_length, free_cmp_uint64_data, @@ -298,7 +298,7 @@ static const ci_type_ops_t acl_time_ops = { /*The acl type*/ void free_time_data(ci_request_t *req,void *param); void *get_time_data(ci_request_t *req, char *param); -static ci_acl_type_t acl_time= { +static ci_acl_type_t acl_time = { "time", get_time_data, free_time_data, @@ -492,7 +492,7 @@ ci_access_entry_t *ci_access_entry_new(ci_access_entry_t **list, int type) *list = access_entry; } else { cur = *list; - while (cur->next!=NULL) + while (cur->next != NULL) cur = cur->next; cur->next = access_entry; } @@ -593,10 +593,10 @@ ci_acl_spec_t * ci_acl_spec_new(const char *name, const char *type, const char spec->data = NULL; spec->next = NULL; - if (spec_list!=NULL) { - if (*spec_list!=NULL) { + if (spec_list != NULL) { + if (*spec_list != NULL) { cur = *spec_list; - while (cur->next!=NULL) + while (cur->next != NULL) cur = cur->next; cur->next = spec; } else @@ -626,7 +626,7 @@ ci_acl_data_t *ci_acl_spec_new_data(ci_acl_spec_t *spec, const char *val) } new_data->data = data; new_data->next = NULL; - if ((list=spec->data) != NULL) { + if ((list = spec->data) != NULL) { while (list->next != NULL) list = list->next; list->next = new_data; @@ -642,7 +642,7 @@ ci_acl_spec_t *ci_acl_spec_search(ci_acl_spec_t *list, const char *name) if (!list || !name) return NULL; spec = list; - while (spec!= NULL) { + while (spec != NULL) { ci_debug_printf(9,"Checking name:%s with specname %s\n", name, spec->name); if (strcmp(spec->name, name) == 0 ) { return spec; @@ -671,8 +671,8 @@ void ci_acl_spec_list_release(ci_acl_spec_t *spec) { ci_acl_spec_t *cur; while (spec) { - cur=spec; - spec=spec->next; + cur = spec; + spec = spec->next; ci_acl_spec_release(cur); } } @@ -726,8 +726,8 @@ int ci_acl_typelist_add(struct ci_acl_type_list *list, const ci_acl_type_t *type const ci_acl_type_t *ci_acl_typelist_search(struct ci_acl_type_list *list,const char *name) { int i; - for (i=0; iacl_type_list_num; i++) { - if (strcmp(list->acl_type_list[i].name,name)==0) + for (i = 0; i < list->acl_type_list_num; i++) { + if (strcmp(list->acl_type_list[i].name,name) == 0) return (const ci_acl_type_t *)&list->acl_type_list[i]; } return NULL; @@ -754,16 +754,16 @@ int ci_acl_typelist_reset(struct ci_acl_type_list *list) int spec_data_check(const ci_acl_spec_t *spec, const void *req_raw_data) { // int (*comp)(void *req_spec, void *acl_spec); - struct ci_acl_data *spec_data=spec->data; + struct ci_acl_data *spec_data = spec->data; const ci_type_ops_t *ops = spec->type->type; ci_debug_printf(9,"Check request with ci_acl_spec_t:%s\n", spec->name); - while (spec_data!=NULL) { + while (spec_data != NULL) { if (ops->equal(spec_data->data, (void *)req_raw_data)) { ci_debug_printf(9,"The ci_acl_spec_t:%s matches\n", spec->name); return 1; } - spec_data=spec_data->next; + spec_data = spec_data->next; } return 0; } @@ -776,7 +776,7 @@ int request_match_specslist(ci_request_t *req, const struct ci_specs_list *spec_ void *test_data; ret = 1; - while (spec_list!=NULL) { + while (spec_list != NULL) { spec = spec_list->spec; negate = spec_list->negate; type = spec->type; @@ -787,9 +787,9 @@ int request_match_specslist(ci_request_t *req, const struct ci_specs_list *spec_ } check_result = spec_data_check(spec, test_data); - if (check_result==0 && negate==0) + if (check_result == 0 && negate == 0) ret = 0; - else if (check_result!=0 && negate!=0) + else if (check_result != 0 && negate != 0) ret = 0; if (type->free_test_data) @@ -798,7 +798,7 @@ int request_match_specslist(ci_request_t *req, const struct ci_specs_list *spec_ if (ret == 0) return 0; - spec_list=spec_list->next; + spec_list = spec_list->next; } return 1; } @@ -816,7 +816,7 @@ int ci_access_entry_match_request(ci_access_entry_t *access_entry, ci_request_t if (spec_list && spec_list->spec && request_match_specslist(req, spec_list)) return access_entry->type; - access_entry=access_entry->next; + access_entry = access_entry->next; } return CI_ACCESS_UNKNOWN; } @@ -897,11 +897,11 @@ int ci_acl_add_data(const char *name, const char *type, const char *data) } s = acl_type; - if ((s=strchr(s,'{')) != NULL) { - *s='\0'; - param=s+1; - if ((s=strchr(param,'}')) != NULL) - *s= '\0'; + if ((s = strchr(s,'{')) != NULL) { + *s = '\0'; + param = s+1; + if ((s = strchr(param,'}')) != NULL) + *s = '\0'; } if ((spec = ci_acl_spec_search(specs_list, name)) != NULL) { diff --git a/array.c b/array.c index 58ad7e97..2d70e417 100644 --- a/array.c +++ b/array.c @@ -105,7 +105,7 @@ const ci_array_item_t * ci_array_add(ci_array_t *array, const char *name, const const void * ci_array_search(ci_array_t *array, const char *name) { int i; - for (i=0; i < array->count; i++) { + for (i = 0; i < array->count; i++) { if (strcmp(array->items[i].name, name) == 0) { return array->items[i].value; } @@ -116,7 +116,7 @@ const void * ci_array_search(ci_array_t *array, const char *name) void ci_array_iterate(const ci_array_t *array, void *data, int (*fn)(void *data, const char *name, const void *)) { int i, ret = 0; - for (i=0; i < array->count && ret == 0; i++) { + for (i = 0; i < array->count && ret == 0; i++) { ret = (*fn)(data, array->items[i].name, array->items[i].value); } } @@ -328,7 +328,7 @@ const void * ci_dyn_array_search(ci_dyn_array_t *array, const char *name) void ci_dyn_array_iterate(const ci_dyn_array_t *array, void *data, int (*fn)(void *data, const char *name, const void *value)) { int i, ret = 0; - for (i=0; i < array->count && ret == 0; i++) + for (i = 0; i < array->count && ret == 0; i++) ret = (*fn)(data, array->items[i]->name, array->items[i]->value); } @@ -451,7 +451,7 @@ void * ci_vector_pop(ci_vector_t *vector) void ci_vector_iterate(const ci_vector_t *vector, void *data, int (*fn)(void *data, const void *)) { int i, ret = 0; - for (i=0; vector->items[i] != NULL && ret == 0; i++) + for (i = 0; vector->items[i] != NULL && ret == 0; i++) ret = (*fn)(data, vector->items[i]); } @@ -465,7 +465,7 @@ void ci_str_vector_iterate(const ci_str_vector_t *vector, void *data, int (*fn)( const char * ci_str_vector_search(ci_str_vector_t *vector, const char *item) { int i; - for (i=0; vector->items[i] != NULL; i++) { + for (i = 0; vector->items[i] != NULL; i++) { if (strcmp(vector->items[i], item) == 0) return vector->items[i]; } @@ -777,7 +777,7 @@ void ci_list_sort2(ci_list_t *list, int (*cmp_func)(const void *obj1, const void currentSorted = &sortedHead; while (!(*currentSorted == NULL || cmp_func(currentHead->item, (*currentSorted)->item, list->obj_size) < 0)) currentSorted = &(*currentSorted)->next; - currentHead->next = *currentSorted; + currentHead->next = *currentSorted; *currentSorted = currentHead; if ((*currentSorted)->next == NULL) sortedTail = (*currentSorted); diff --git a/body.c b/body.c index 3ff4d42c..07786a12 100644 --- a/body.c +++ b/body.c @@ -171,13 +171,13 @@ int ci_membuf_write(struct ci_membuf *b, const char *data, int len, int iseof) int terminate = b->flags & CI_MEMBUF_NULL_TERMINATED; if ((b->flags & CI_MEMBUF_RO) || (b->flags & CI_MEMBUF_CONST)) { - ci_debug_printf( 1, "ci_membuf_write: can not write: buffer is read-only!\n"); + ci_debug_printf(1, "ci_membuf_write: can not write: buffer is read-only!\n"); return 0; } if ((b->flags & CI_MEMBUF_HAS_EOF)) { if (len > 0) { - ci_debug_printf( 1, "Cannot write to membuf: the eof flag is set!\n"); + ci_debug_printf(1, "Cannot write to membuf: the eof flag is set!\n"); } return 0; } @@ -196,7 +196,7 @@ int ci_membuf_write(struct ci_membuf *b, const char *data, int len, int iseof) newsize = b->bufsize + INCSTEP; newbuf = ci_buffer_realloc(b->buf, newsize); if (newbuf == NULL) { - ci_debug_printf( 1, "ci_membuf_write: Failed to grow membuf for new data!\n"); + ci_debug_printf(1, "ci_membuf_write: Failed to grow membuf for new data!\n"); if (remains >= 0) { if (remains) memcpy(b->buf + b->endpos, data, remains); @@ -206,7 +206,7 @@ int ci_membuf_write(struct ci_membuf *b, const char *data, int len, int iseof) } else b->endpos = b->bufsize; } else { - ci_debug_printf( 1, "ci_membuf_write: Failed to NULL terminate membuf!\n"); + ci_debug_printf(1, "ci_membuf_write: Failed to NULL terminate membuf!\n"); } return remains; } @@ -288,7 +288,7 @@ int do_write(int fd, const void *buf, size_t count) errno = 0; do { bytes = write(fd, buf, count); - } while ( bytes < 0 && errno == EINTR); + } while (bytes < 0 && errno == EINTR); return bytes; } @@ -299,7 +299,7 @@ int do_read(int fd, void *buf, size_t count) errno = 0; do { bytes = read(fd, buf, count); - } while ( bytes < 0 && errno == EINTR); + } while (bytes < 0 && errno == EINTR); return bytes; } @@ -316,7 +316,7 @@ int do_open(const char *pathname, int flags) errno = 0; do { fd = open(pathname, flags, F_PERM); - } while ( fd < 0 && errno == EINTR); + } while (fd < 0 && errno == EINTR); return fd; } @@ -500,11 +500,11 @@ int ci_cached_file_write(ci_cached_file_t * body, const char *buf, int len, int return -1; } ret = do_write(body->fd, body->buf, body->endpos); - if ( ret>=0 && do_write(body->fd, buf, len) >=0 ) { + if (ret >= 0 && do_write(body->fd, buf, len) >= 0) { body->endpos += len; return len; } else { - ci_debug_printf( 1, "Cannot write to cachefile: %s\n", strerror( errno ) ); + ci_debug_printf(1, "Cannot write to cachefile: %s\n", strerror(errno)); return CI_ERROR; } } /* if remainsflags & CI_FILE_HAS_EOF) { if (len > 0) { - ci_debug_printf( 1, "Cannot write to file: '%s', the eof flag is set!\n", body->filename); + ci_debug_printf(1, "Cannot write to file: '%s', the eof flag is set!\n", body->filename); } return 0; } @@ -711,7 +711,7 @@ int ci_simple_file_write(ci_simple_file_t * body, const char *buf, int len, int wsize = min(body->readpos-body->endpos-1, len); } else if (body->max_store_size && body->endpos >= body->max_store_size) { /*If we are going to entre ring mode. If we are using locking we can not enter ring mode.*/ - if (body->readpos!=0 && (body->flags & CI_FILE_USELOCK)==0) { + if (body->readpos != 0 && (body->flags & CI_FILE_USELOCK) == 0) { body->endpos = 0; if (!(body->flags & CI_FILE_RING_MODE)) { body->flags |= CI_FILE_RING_MODE; @@ -732,7 +732,7 @@ int ci_simple_file_write(ci_simple_file_t * body, const char *buf, int len, int lseek(body->fd, body->endpos, SEEK_SET); if ((ret = do_write(body->fd, buf, wsize)) < 0) { - ci_debug_printf( 1, "Cannot write to file: %s\n", strerror( errno ) ); + ci_debug_printf(1, "Cannot write to file: %s\n", strerror(errno)); } else { body->endpos += ret; body->bytes_in += ret; @@ -824,7 +824,7 @@ const char * ci_simple_file_to_const_string(ci_simple_file_t *body) ci_off_t map_size; char *addr = NULL; if (!(body->flags & CI_FILE_HAS_EOF)) { - ci_debug_printf( 1, "mmap to file: '%s' failed, the eof flag is not set!\n", body->filename); + ci_debug_printf(1, "mmap to file: '%s' failed, the eof flag is not set!\n", body->filename); return NULL; } @@ -849,7 +849,7 @@ const char * ci_simple_file_to_const_string(ci_simple_file_t *body) #define CI_MEMBUF_SF_FLAGS (CI_MEMBUF_CONST | CI_MEMBUF_RO | CI_MEMBUF_NULL_TERMINATED) ci_membuf_t *ci_simple_file_to_membuf(ci_simple_file_t *body, unsigned int flags) { - assert((CI_MEMBUF_SF_FLAGS & flags) ==flags); + assert((CI_MEMBUF_SF_FLAGS & flags) == flags); assert(flags & CI_MEMBUF_CONST); void *addr = (void *)ci_simple_file_to_const_string(body); if (!addr) @@ -872,7 +872,7 @@ struct ci_ring_buf *ci_ring_buf_new(int size) return NULL; } - buf->end_buf=buf->buf+size-1; + buf->end_buf = buf->buf+size-1; buf->read_pos = buf->buf; buf->write_pos = buf->buf; buf->full = 0; @@ -887,7 +887,7 @@ void ci_ring_buf_destroy(struct ci_ring_buf *buf) int ci_ring_buf_is_empty(struct ci_ring_buf *buf) { - return (buf->read_pos==buf->write_pos) && (buf->full==0); + return (buf->read_pos == buf->write_pos) && (buf->full == 0); } int ci_ring_buf_write_block(struct ci_ring_buf *buf, char **wb, int *len) @@ -916,7 +916,7 @@ int ci_ring_buf_read_block(struct ci_ring_buf *buf, char **rb, int *len) } else if (buf->read_pos >= buf->write_pos) { *rb = buf->read_pos; *len = buf->end_buf - buf->read_pos +1; - return (buf->read_pos!=buf->buf? 1:0); + return (buf->read_pos != buf->buf? 1:0); } else { /*buf->read_pos < buf->write_pos*/ *rb = buf->read_pos; *len = buf->write_pos - buf->read_pos; @@ -963,7 +963,7 @@ int ci_ring_buf_write(struct ci_ring_buf *buf, const char *data,int size) data += wb_len; written += wb_len; } - } while ((ret!=0) && (size>0)); + } while ((ret != 0) && (size > 0)); return written; } @@ -983,6 +983,6 @@ int ci_ring_buf_read(struct ci_ring_buf *buf, char *data,int size) data += rb_len; data_read += rb_len; } - } while ((ret!=0) && (size>0 )); + } while ((ret != 0) && (size > 0)); return data_read; } diff --git a/c-icap-config.in b/c-icap-config.in index f3768773..7342579f 100644 --- a/c-icap-config.in +++ b/c-icap-config.in @@ -21,7 +21,7 @@ LIBS=@MODULES_LIBADD@ LDFLAGS="" -usage() +usage() { cat <a: Http Client IP Address. Only supported if the proxy +# %>a: Http Client IP Address. Only supported if the proxy # client supports the "X-Client-IP" header # %