- Lauri
>From 1f99e0087cd35a1f6704c80e4c77ad4f807fe887 Mon Sep 17 00:00:00 2001 From: Lauri Kasanen <[email protected]> Date: Mon, 21 May 2012 19:17:52 +0300 Subject: [PATCH 2/8] plugins: General cleanup, make possible functions static
Signed-off-by: Lauri Kasanen <[email protected]> --- plugins/auth/auth.c | 4 +--- plugins/auth/base64.c | 2 ++ plugins/auth/base64.h | 7 +++++++ plugins/auth/conf.c | 4 ++-- plugins/cheetah/cheetah.c | 2 +- plugins/cheetah/loop.c | 1 + plugins/dirlisting/dirlisting.c | 26 +++++++++++++------------- plugins/logger/logger.c | 15 ++++++--------- plugins/logger/logger.h | 5 ----- plugins/logger/pointers.h | 7 ++++++- plugins/mandril/mandril.c | 8 ++++---- plugins/palm/palm.c | 12 ++++++------ plugins/palm/palm.h | 1 - plugins/palm/protocol.c | 2 +- plugins/patas/connection.c | 1 + plugins/patas/patas.c | 12 ++++++------ plugins/patas/patas.h | 3 --- 17 files changed, 57 insertions(+), 55 deletions(-) diff --git a/plugins/auth/auth.c b/plugins/auth/auth.c index 5bae229..c1c537d 100644 --- a/plugins/auth/auth.c +++ b/plugins/auth/auth.c @@ -36,9 +36,7 @@ MONKEY_PLUGIN("auth", /* shortname */ VERSION, /* version */ MK_PLUGIN_STAGE_30); /* hooks */ -struct mk_config *conf; - -int mk_auth_validate_user(struct users_file *users, +static int mk_auth_validate_user(struct users_file *users, const char *credentials, unsigned int len) { int sep; diff --git a/plugins/auth/base64.c b/plugins/auth/base64.c index bc6bf30..f3d3c79 100644 --- a/plugins/auth/base64.c +++ b/plugins/auth/base64.c @@ -9,6 +9,8 @@ #include <stdlib.h> #include <string.h> +#include "base64.h" + static const unsigned char base64_table[65] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; diff --git a/plugins/auth/base64.h b/plugins/auth/base64.h index 1ad79ab..45001d4 100644 --- a/plugins/auth/base64.h +++ b/plugins/auth/base64.h @@ -1,4 +1,11 @@ +#ifndef AUTH_BASE64_H +#define AUTH_BASE64_H + + unsigned char * base64_encode(const unsigned char *src, size_t len, size_t *out_len); unsigned char *base64_decode(const unsigned char *src, size_t len, size_t *out_len); + + +#endif diff --git a/plugins/auth/conf.c b/plugins/auth/conf.c index 078c895..2aef40f 100644 --- a/plugins/auth/conf.c +++ b/plugins/auth/conf.c @@ -21,9 +21,9 @@ #include <string.h> #include "MKPlugin.h" -#include "sha1.h" #include "base64.h" #include "auth.h" +#include "conf.h" /* * Register a users file into the main list, if the users @@ -31,7 +31,7 @@ * otherwise add the node to the list and return the node * created. */ -struct users_file *mk_auth_conf_add_users(char *users_path) +static struct users_file *mk_auth_conf_add_users(char *users_path) { struct file_info finfo; struct mk_list *head; diff --git a/plugins/cheetah/cheetah.c b/plugins/cheetah/cheetah.c index 9ed4714..d2ff019 100644 --- a/plugins/cheetah/cheetah.c +++ b/plugins/cheetah/cheetah.c @@ -48,7 +48,7 @@ void mk_cheetah_welcome_msg() CHEETAH_FLUSH(); } -void mk_cheetah_config(char *path) +static void mk_cheetah_config(char *path) { unsigned long len; char *listen = NULL; diff --git a/plugins/cheetah/loop.c b/plugins/cheetah/loop.c index 9f40ca2..902b130 100644 --- a/plugins/cheetah/loop.c +++ b/plugins/cheetah/loop.c @@ -32,6 +32,7 @@ #include "cheetah.h" #include "cutils.h" #include "cmd.h" +#include "loop.h" void mk_cheetah_loop_stdin() { diff --git a/plugins/dirlisting/dirlisting.c b/plugins/dirlisting/dirlisting.c index 694ac0a..da5b64e 100644 --- a/plugins/dirlisting/dirlisting.c +++ b/plugins/dirlisting/dirlisting.c @@ -68,7 +68,7 @@ MONKEY_PLUGIN("dirlisting", /* shortname */ */ /* Function wrote by Max (Felipe Astroza), thanks! */ -char *mk_dirhtml_human_readable_size(off_t size) +static char *mk_dirhtml_human_readable_size(off_t size) { unsigned long u = 1024, i, len; char *buf = NULL; @@ -93,7 +93,7 @@ char *mk_dirhtml_human_readable_size(off_t size) return buf; } -struct mk_f_list *mk_dirhtml_create_element(char *file, +static struct mk_f_list *mk_dirhtml_create_element(char *file, unsigned char type, char *full_path, unsigned long *list_len) @@ -135,7 +135,7 @@ struct mk_f_list *mk_dirhtml_create_element(char *file, return entry; } -struct mk_f_list *mk_dirhtml_create_list(DIR * dir, char *path, +static struct mk_f_list *mk_dirhtml_create_list(DIR * dir, char *path, unsigned long *list_len) { unsigned long len; @@ -318,7 +318,7 @@ int mk_dirhtml_theme_debug(struct dirhtml_template **st_tpl) /* Search which tag exists first in content : * ex: %_html_title_% */ -int mk_dirhtml_theme_match_tag(char *content, char *tpl[]) +static int mk_dirhtml_theme_match_tag(char *content, char *tpl[]) { int i, len, match; @@ -334,7 +334,7 @@ int mk_dirhtml_theme_match_tag(char *content, char *tpl[]) } /* return the number of valid tags found in text string */ -int mk_dirhtml_content_count_tags(char *content, char *tpl[]) +static int mk_dirhtml_content_count_tags(char *content, char *tpl[]) { int pos = 0, count = 0; int len, tpl_idx; @@ -470,7 +470,7 @@ struct dirhtml_template *mk_dirhtml_template_list_add(struct dirhtml_template ** return (struct dirhtml_template *) node; } -int mk_dirhtml_tag_get_id(char *tpl_tags[], char *tag) +static int mk_dirhtml_tag_get_id(char *tpl_tags[], char *tag) { int i; for (i = 0; tpl_tags[i]; i++) { @@ -482,7 +482,7 @@ int mk_dirhtml_tag_get_id(char *tpl_tags[], char *tag) return -1; } -int mk_dirhtml_template_len(struct dirhtml_template *tpl) +static int mk_dirhtml_template_len(struct dirhtml_template *tpl) { int len = 0; struct dirhtml_template *aux; @@ -496,7 +496,7 @@ int mk_dirhtml_template_len(struct dirhtml_template *tpl) return len; } -struct mk_iov *mk_dirhtml_theme_compose(struct dirhtml_template *template, +static struct mk_iov *mk_dirhtml_theme_compose(struct dirhtml_template *template, struct dirhtml_value *values, int is_chunked) { @@ -589,7 +589,7 @@ struct dirhtml_value *mk_dirhtml_tag_assign(struct dirhtml_value **values, return (struct dirhtml_value *) aux; } -void mk_dirhtml_tag_free_list(struct dirhtml_value **list) +static void mk_dirhtml_tag_free_list(struct dirhtml_value **list) { struct dirhtml_value *prev=0, *target; @@ -631,7 +631,7 @@ char *mk_dirhtml_load_file(char *filename) return (char *) data; } -int mk_dirhtml_entry_cmp(const void *a, const void *b) +static int mk_dirhtml_entry_cmp(const void *a, const void *b) { struct mk_f_list *const *f_a = a; struct mk_f_list *const *f_b = b; @@ -639,7 +639,7 @@ int mk_dirhtml_entry_cmp(const void *a, const void *b) return strcmp((*f_a)->name, (*f_b)->name); } -int mk_dirhtml_send(int fd, struct session_request *sr, struct mk_iov *data) +static int mk_dirhtml_send(int fd, struct session_request *sr, struct mk_iov *data) { int n; unsigned long len; @@ -656,7 +656,7 @@ int mk_dirhtml_send(int fd, struct session_request *sr, struct mk_iov *data) return n; } -int mk_dirhtml_send_chunked_end(int fd) +static int mk_dirhtml_send_chunked_end(int fd) { char *_end = "0\r\n\r\n"; int len = 5; @@ -664,7 +664,7 @@ int mk_dirhtml_send_chunked_end(int fd) return mk_api->socket_send(fd, _end, len); } -void mk_dirhtml_free_list(struct mk_f_list **toc, unsigned long len) +static void mk_dirhtml_free_list(struct mk_f_list **toc, unsigned long len) { int i; struct mk_f_list *entry; diff --git a/plugins/logger/logger.c b/plugins/logger/logger.c index e412059..9c476e3 100644 --- a/plugins/logger/logger.c +++ b/plugins/logger/logger.c @@ -33,9 +33,6 @@ #include <pthread.h> #include <unistd.h> -/* Monkey Plugin Interface */ -#include "MKPlugin.h" - /* Local Headers */ #include "logger.h" #include "pointers.h" @@ -70,7 +67,7 @@ static struct status_response response_codes[] = { }; -char *mk_logger_match_by_fd(int fd) +static char *mk_logger_match_by_fd(int fd) { struct mk_list *head; struct log_target *entry; @@ -89,7 +86,7 @@ char *mk_logger_match_by_fd(int fd) return NULL; } -struct log_target *mk_logger_match_by_host(struct host *host) +static struct log_target *mk_logger_match_by_host(struct host *host) { struct mk_list *head; struct log_target *entry; @@ -104,12 +101,12 @@ struct log_target *mk_logger_match_by_host(struct host *host) return NULL; } -struct iov *mk_logger_get_cache() +static struct iov *mk_logger_get_cache() { return pthread_getspecific(_mkp_data); } -void *mk_logger_worker_init(void *args) +static void *mk_logger_worker_init(void *args) { int efd, max_events = mk_api->config->nhosts; int i, bytes, err; @@ -231,7 +228,7 @@ void *mk_logger_worker_init(void *args) } } -int mk_logger_read_config(char *path) +static int mk_logger_read_config(char *path) { int timeout; char *logfilename = NULL; @@ -275,7 +272,7 @@ int mk_logger_read_config(char *path) return 0; } -void mk_logger_print_details(void) +static void mk_logger_print_details(void) { time_t now; struct tm *current; diff --git a/plugins/logger/logger.h b/plugins/logger/logger.h index 0189a61..1c64404 100644 --- a/plugins/logger/logger.h +++ b/plugins/logger/logger.h @@ -59,10 +59,5 @@ struct mk_list targets_list; //struct log_target *lt; -/* Global Monkey core API */ -struct plugin_api *mk_api; - -void *mk_logger_worker_init(void *args); -void mk_logger_target_add(int fd, char *target); #endif diff --git a/plugins/logger/pointers.h b/plugins/logger/pointers.h index 862d540..a644364 100644 --- a/plugins/logger/pointers.h +++ b/plugins/logger/pointers.h @@ -19,7 +19,10 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -#include "memory.h" +#ifndef MK_LOGGER_POINTERS_H +#define MK_LOGGER_POINTERS_H + +#include <memory.h> /* Request error messages for log file */ #define ERROR_MSG_400 "[error 400] Bad Request" @@ -57,3 +60,5 @@ mk_pointer mk_logger_iov_empty; /* functions */ void mk_logger_init_pointers(); + +#endif diff --git a/plugins/mandril/mandril.c b/plugins/mandril/mandril.c index 249bb69..6f4a149 100644 --- a/plugins/mandril/mandril.c +++ b/plugins/mandril/mandril.c @@ -38,10 +38,10 @@ MONKEY_PLUGIN("mandril", /* shortname */ VERSION, /* version */ MK_PLUGIN_STAGE_10 | MK_PLUGIN_STAGE_20); /* hooks */ -struct mk_config *conf; +static struct mk_config *conf; /* Read database configuration parameters */ -int mk_security_conf(char *confdir) +static int mk_security_conf(char *confdir) { int n; int ret = 0; @@ -150,7 +150,7 @@ int mk_security_conf(char *confdir) return ret; } -int mk_security_check_ip(int socket) +static int mk_security_check_ip(int socket) { int network; struct mk_secure_ip_t *entry; @@ -188,7 +188,7 @@ int mk_security_check_ip(int socket) } /* Check if the incoming URL is restricted for some rule */ -int mk_security_check_url(int socket, mk_pointer url) +static int mk_security_check_url(int socket, mk_pointer url) { int n; struct mk_list *head; diff --git a/plugins/palm/palm.c b/plugins/palm/palm.c index 582c1b6..f42776e 100644 --- a/plugins/palm/palm.c +++ b/plugins/palm/palm.c @@ -40,7 +40,7 @@ MONKEY_PLUGIN("palm", /* shortname */ MK_PLUGIN_CORE_THCTX | MK_PLUGIN_STAGE_30); /* hooks */ /* Read database configuration parameters */ -int mk_palm_conf(char *confdir) +static int mk_palm_conf(char *confdir) { int ret = 0; unsigned long len; @@ -98,7 +98,7 @@ int mk_palm_conf(char *confdir) return ret; } -struct mk_palm *mk_palm_get_handler(mk_pointer * file) +static struct mk_palm *mk_palm_get_handler(mk_pointer * file) { struct mk_palm *p; int j, len, extlen; @@ -126,7 +126,7 @@ struct mk_palm *mk_palm_get_handler(mk_pointer * file) return NULL; } -int mk_palm_send_headers(struct mk_palm_request *pr) +static int mk_palm_send_headers(struct mk_palm_request *pr) { int n; struct client_session *cs = pr->cs; @@ -355,7 +355,7 @@ int mk_palm_send_request(struct client_session *cs, struct session_request *sr) return pr->bytes_sent; } -int mk_palm_write(int socket, char *buffer, int len, int is_chunked) +static int mk_palm_write(int socket, char *buffer, int len, int is_chunked) { int n; int chunk_len; @@ -385,7 +385,7 @@ int mk_palm_write(int socket, char *buffer, int len, int is_chunked) return n; } -int mk_palm_send_end_chunk(int socket, struct mk_palm_request *pr) +static int mk_palm_send_end_chunk(int socket, struct mk_palm_request *pr) { int n=0; @@ -399,7 +399,7 @@ int mk_palm_send_end_chunk(int socket, struct mk_palm_request *pr) * present, if so, it modifies the header struct response * and return the offset position */ -int mk_palm_cgi_status(char *data, struct session_request *sr) +static int mk_palm_cgi_status(char *data, struct session_request *sr) { int status; int status_len = 3; diff --git a/plugins/palm/palm.h b/plugins/palm/palm.h index 44ced44..a06fee9 100644 --- a/plugins/palm/palm.h +++ b/plugins/palm/palm.h @@ -38,7 +38,6 @@ struct mk_palm struct mk_palm *next; }; -pthread_key_t _mkp_data; pthread_key_t cache_ip_str; struct plugin_api *mk_api; diff --git a/plugins/palm/protocol.c b/plugins/palm/protocol.c index 358e82b..a690245 100644 --- a/plugins/palm/protocol.c +++ b/plugins/palm/protocol.c @@ -37,7 +37,7 @@ static void prot_add_header(struct mk_iov *iov, mk_pointer header, mk_pointer va mk_iov_crlf, MK_IOV_NOT_FREE_BUF); } -struct mk_iov *prot_template() +static struct mk_iov *prot_template() { struct mk_iov *iov; diff --git a/plugins/patas/connection.c b/plugins/patas/connection.c index 4040170..59ff601 100644 --- a/plugins/patas/connection.c +++ b/plugins/patas/connection.c @@ -24,6 +24,7 @@ #include "MKPlugin.h" #include "patas.h" +#include "connection.h" struct mk_patas_conx *mk_patas_connection_create(int socket_remote, int socket_node, struct mk_patas_node *node) diff --git a/plugins/patas/patas.c b/plugins/patas/patas.c index 92aa2fd..ca989be 100644 --- a/plugins/patas/patas.c +++ b/plugins/patas/patas.c @@ -46,19 +46,19 @@ MONKEY_PLUGIN("patas", /* shortname */ MK_PLUGIN_CORE_THCTX | MK_PLUGIN_STAGE_30); /* hook for thread context call */ /* get thread connections list */ -struct mk_list *mk_patas_conx_get() +static struct mk_list *mk_patas_conx_get() { return pthread_getspecific(_mkp_data); } /* set thread connections list */ -void mk_patas_conx_set(struct mk_list *list) +static void mk_patas_conx_set(struct mk_list *list) { pthread_setspecific(_mkp_data, (void *) list); } /* invoked in thread context */ -void mk_patas_conx_init() +static void mk_patas_conx_init() { struct mk_list *thread_conx_list; @@ -70,7 +70,7 @@ void mk_patas_conx_init() mk_patas_conx_set(thread_conx_list); } -int mk_patas_validate_node(const char *host, int port) +static int mk_patas_validate_node(const char *host, int port) { int i, j; char local_addr[16], node_addr[16]; @@ -107,7 +107,7 @@ int mk_patas_validate_node(const char *host, int port) } /* Read configuration parameters */ -int mk_patas_conf(char *confdir) +static int mk_patas_conf(char *confdir) { int res; int val_port; @@ -383,7 +383,7 @@ int _mkp_event_read(int socket) return MK_PLUGIN_RET_EVENT_OWNED; } -int hangup(int socket) +static int hangup(int socket) { /* * Determinate actions to take depending on which diff --git a/plugins/patas/patas.h b/plugins/patas/patas.h index 66e790e..febe596 100644 --- a/plugins/patas/patas.h +++ b/plugins/patas/patas.h @@ -62,9 +62,6 @@ struct mk_patas_conx { struct mk_list _head; }; -/* Thread key to hold mk_patas_conx nodes */ -pthread_key_t _mkp_data; - struct plugin_api *mk_api; struct mk_config *conf; -- 1.7.2.1
_______________________________________________ Monkey mailing list [email protected] http://lists.monkey-project.com/listinfo/monkey
