From 992698454360751312fab9dedcd84a4ae7c53fc6 Mon Sep 17 00:00:00 2001 From: Matthew Brush Date: Mon, 4 Mar 2013 20:10:32 -0800 Subject: [PATCH] Remove redundant use of extern storage class specifier --- src/cfu.c | 12 +++---- src/cfu.h | 12 +++---- src/cfuconf.c | 18 +++++----- src/cfuconf.h | 18 +++++----- src/cfuhash.c | 78 +++++++++++++++++++++---------------------- src/cfuhash.h | 78 +++++++++++++++++++++---------------------- src/cfulist.c | 64 +++++++++++++++++------------------ src/cfulist.h | 64 +++++++++++++++++------------------ src/cfuopt.c | 14 ++++---- src/cfuopt.h | 10 +++--- src/cfustring.c | 36 ++++++++++---------- src/cfustring.h | 34 +++++++++---------- src/cfuthread_queue.c | 8 ++--- src/cfuthread_queue.h | 8 ++--- src/cfutime.c | 10 +++--- src/cfutime.h | 10 +++--- 16 files changed, 237 insertions(+), 237 deletions(-) diff --git a/src/cfu.c b/src/cfu.c index 49bf1e5..839833f 100644 --- a/src/cfu.c +++ b/src/cfu.c @@ -41,31 +41,31 @@ struct libcfu_item { libcfu_type type; }; -extern libcfu_type +libcfu_type cfu_get_type(void *item) { if (!item) return libcfu_t_none; return ((libcfu_item_t *)item)->type; } -extern int +int cfu_is_hash(void *item) { if (cfu_get_type(item) == libcfu_t_hash_table) return 1; return 0; } -extern int +int cfu_is_list(void *item) { if (cfu_get_type(item) == libcfu_t_list) return 1; return 0; } -extern int +int cfu_is_string(void *item) { if (cfu_get_type(item) == libcfu_t_string) return 1; return 0; } -extern int +int cfu_is_time(void *item) { if (cfu_get_type(item) == libcfu_t_time) return 1; return 0; @@ -79,7 +79,7 @@ cfu_is_timer(void *item) return 0; } -extern int +int cfu_is_conf(void *item) { if (cfu_get_type(item) == libcfu_t_conf) return 1; return 0; diff --git a/src/cfu.h b/src/cfu.h index 5207e55..269630e 100644 --- a/src/cfu.h +++ b/src/cfu.h @@ -63,13 +63,13 @@ typedef enum { libcfu_t_none = 0, libcfu_t_hash_table, libcfu_t_list, libcfu_t_s typedef struct libcfu_item libcfu_item_t; -extern libcfu_type cfu_get_type(void *item); -extern int cfu_is_hash(void *item); -extern int cfu_is_list(void *item); -extern int cfu_is_string(void *item); -extern int cfu_is_time(void *item); +libcfu_type cfu_get_type(void *item); +int cfu_is_hash(void *item); +int cfu_is_list(void *item); +int cfu_is_string(void *item); +int cfu_is_time(void *item); int cfu_is_timer(void *item); -extern int cfu_is_conf(void *item); +int cfu_is_conf(void *item); CFU_END_DECLS diff --git a/src/cfuconf.c b/src/cfuconf.c index f351074..4a3c964 100644 --- a/src/cfuconf.c +++ b/src/cfuconf.c @@ -132,7 +132,7 @@ _directive_free_fn(void *data) { cfulist_destroy_with_free_fn(list, _directive_free_val_list_fn); } -extern void +void cfuconf_destroy(cfuconf_t *conf) { if (conf->containers) { /* cfuhash_foreach(conf->containers, _container_free_foreach_fn, NULL); */ @@ -146,13 +146,13 @@ cfuconf_destroy(cfuconf_t *conf) { free(conf); } -extern cfuhash_table_t * +cfuhash_table_t * cfuconf_get_containers(cfuconf_t *conf) { if (!conf) return NULL; return conf->containers; } -extern cfuhash_table_t * +cfuhash_table_t * cfuconf_get_directives(cfuconf_t *conf) { if (!conf) return NULL; return conf->directives; @@ -188,7 +188,7 @@ _get_directive_last_val_list(cfuconf_t *conf, char *directive, cfulist_t **val_l } -extern int +int cfuconf_get_directive_one_arg(cfuconf_t *conf, char *directive, char **rvalue) { cfulist_t *val_list = NULL; void *val = NULL; @@ -205,12 +205,12 @@ cfuconf_get_directive_one_arg(cfuconf_t *conf, char *directive, char **rvalue) { return -1; } -extern int +int cfuconf_get_directive_two_args(cfuconf_t *conf, char *directive, char **rvalue, char **rvalue2) { return cfuconf_get_directive_n_args(conf, directive, 2, rvalue, rvalue2); } -extern int +int cfuconf_get_directive_n_args(cfuconf_t *conf, char *directive, size_t n, ...) { va_list ap; size_t i = 0; @@ -605,7 +605,7 @@ _cfuconf_parse_list(cfulist_t *lines, char **error) { return conf; } -extern int +int cfuconf_parse_file(char *file_path, cfuconf_t **ret_conf, char **error) { FILE *fp = NULL; cfulist_t *lines = NULL; @@ -630,7 +630,7 @@ cfuconf_parse_file(char *file_path, cfuconf_t **ret_conf, char **error) { return -1; } -extern int +int cfuconf_parse_buffer(char *buffer, cfuconf_t **ret_conf, char **error) { cfulist_t *lines = cfulist_new(); char **strings = NULL; @@ -811,7 +811,7 @@ print_conf(cfuconf_t *conf, size_t depth, FILE *fp) { free(ds); } -extern void +void cfuconf_pretty_print_conf(cfuconf_t *conf, FILE *fp, size_t indent_level) { print_conf(conf, indent_level, fp); } diff --git a/src/cfuconf.h b/src/cfuconf.h index be0e0d7..8bd6d42 100644 --- a/src/cfuconf.h +++ b/src/cfuconf.h @@ -82,34 +82,34 @@ typedef struct cfuconf cfuconf_t; * and error is not NULL, it will be set to an error message * (which must be free()'d by the caller). */ -extern int cfuconf_parse_file(char *file_path, cfuconf_t **conf, char **error); +int cfuconf_parse_file(char *file_path, cfuconf_t **conf, char **error); /* Same as cfuconf_parse_file(), except assume the contents of the * file are already in buffer. */ -extern int cfuconf_parse_buffer(char *buffer, cfuconf_t **conf, char **error); +int cfuconf_parse_buffer(char *buffer, cfuconf_t **conf, char **error); /* Free all resources used by the cfuconf_t structure */ -extern void cfuconf_destroy(cfuconf_t *conf); +void cfuconf_destroy(cfuconf_t *conf); /* Get a hash of containers at the top level of conf */ -extern cfuhash_table_t * cfuconf_get_containers(cfuconf_t *conf); +cfuhash_table_t * cfuconf_get_containers(cfuconf_t *conf); /* Get a hash of directives at the to level */ -extern cfuhash_table_t * cfuconf_get_directives(cfuconf_t *conf); +cfuhash_table_t * cfuconf_get_directives(cfuconf_t *conf); /* Get the value of the given directive, assuming there is only one argument */ -extern int cfuconf_get_directive_one_arg(cfuconf_t *conf, char *directive, char **rvalue); +int cfuconf_get_directive_one_arg(cfuconf_t *conf, char *directive, char **rvalue); /* Get the value of the given directive, assuming there are two arguments */ -extern int cfuconf_get_directive_two_args(cfuconf_t *conf, char *directive, char **rvalue, +int cfuconf_get_directive_two_args(cfuconf_t *conf, char *directive, char **rvalue, char **rvalue2); /* Get the value of the given directives, with n arguments */ -extern int cfuconf_get_directive_n_args(cfuconf_t *conf, char *directive, size_t n, ...); +int cfuconf_get_directive_n_args(cfuconf_t *conf, char *directive, size_t n, ...); /* Print out a representation of the parsed configuration */ -extern void cfuconf_pretty_print_conf(cfuconf_t *conf, FILE *fp, size_t indent_level); +void cfuconf_pretty_print_conf(cfuconf_t *conf, FILE *fp, size_t indent_level); CFU_END_DECLS diff --git a/src/cfuhash.c b/src/cfuhash.c index df40c56..57be201 100644 --- a/src/cfuhash.c +++ b/src/cfuhash.c @@ -201,29 +201,29 @@ _cfuhash_new(size_t size, u_int32_t flags) { return ht; } -extern cfuhash_table_t * +cfuhash_table_t * cfuhash_new(void) { return _cfuhash_new(8, CFUHASH_FROZEN_UNTIL_GROWS); } -extern cfuhash_table_t * +cfuhash_table_t * cfuhash_new_with_initial_size(size_t size) { if (size == 0) size = 8; return _cfuhash_new(size, CFUHASH_FROZEN_UNTIL_GROWS); } -extern cfuhash_table_t * +cfuhash_table_t * cfuhash_new_with_flags(u_int32_t flags) { return _cfuhash_new(8, CFUHASH_FROZEN_UNTIL_GROWS|flags); } -extern cfuhash_table_t * cfuhash_new_with_free_fn(cfuhash_free_fn_t ff) { +cfuhash_table_t * cfuhash_new_with_free_fn(cfuhash_free_fn_t ff) { cfuhash_table_t *ht = _cfuhash_new(8, CFUHASH_FROZEN_UNTIL_GROWS); cfuhash_set_free_function(ht, ff); return ht; } -extern int +int cfuhash_copy(cfuhash_table_t *src, cfuhash_table_t *dst) { size_t num_keys = 0; void **keys = NULL; @@ -247,7 +247,7 @@ cfuhash_copy(cfuhash_table_t *src, cfuhash_table_t *dst) { return 1; } -extern cfuhash_table_t * +cfuhash_table_t * cfuhash_merge(cfuhash_table_t *ht1, cfuhash_table_t *ht2, u_int32_t flags) { cfuhash_table_t *new_ht = NULL; @@ -260,27 +260,27 @@ cfuhash_merge(cfuhash_table_t *ht1, cfuhash_table_t *ht2, u_int32_t flags) { } /* returns the flags */ -extern u_int32_t +u_int32_t cfuhash_get_flags(cfuhash_table_t *ht) { return ht->flags; } /* sets the given flag and returns the old flags value */ -extern u_int32_t +u_int32_t cfuhash_set_flag(cfuhash_table_t *ht, u_int32_t new_flag) { u_int32_t flags = ht->flags; ht->flags = flags | new_flag; return flags; } -extern u_int32_t +u_int32_t cfuhash_clear_flag(cfuhash_table_t *ht, u_int32_t new_flag) { u_int32_t flags = ht->flags; ht->flags = flags & ~new_flag; return flags; } -extern int +int cfuhash_set_thresholds(cfuhash_table_t *ht, float low, float high) { float h = high < 0 ? ht->high : high; float l = low < 0 ? ht->low : low; @@ -294,7 +294,7 @@ cfuhash_set_thresholds(cfuhash_table_t *ht, float low, float high) { } /* Sets the hash function for the hash table ht. Pass NULL for hf to reset to the default */ -extern int +int cfuhash_set_hash_function(cfuhash_table_t *ht, cfuhash_function_t hf) { /* can't allow changing the hash function if the hash already contains entries */ if (ht->entries) return -1; @@ -303,7 +303,7 @@ cfuhash_set_hash_function(cfuhash_table_t *ht, cfuhash_function_t hf) { return 0; } -extern int +int cfuhash_set_free_function(cfuhash_table_t * ht, cfuhash_free_fn_t ff) { if (ff) ht->free_fn = ff; return 0; @@ -327,7 +327,7 @@ unlock_hash(cfuhash_table_t *ht) { #endif } -extern int +int cfuhash_lock(cfuhash_table_t *ht) { #ifdef HAVE_PTHREAD_H pthread_mutex_lock(&ht->mutex); @@ -335,7 +335,7 @@ cfuhash_lock(cfuhash_table_t *ht) { return 1; } -extern int +int cfuhash_unlock(cfuhash_table_t *ht) { #ifdef HAVE_PTHREAD_H pthread_mutex_unlock(&ht->mutex); @@ -381,7 +381,7 @@ hash_add_entry(cfuhash_table_t *ht, unsigned int hv, const void *key, size_t key Returns one if the entry was found, zero otherwise. If found, r is changed to point to the data in the entry. */ -extern int +int cfuhash_get_data(cfuhash_table_t *ht, const void *key, size_t key_size, void **r, size_t *data_size) { unsigned int hv = 0; @@ -417,7 +417,7 @@ cfuhash_get_data(cfuhash_table_t *ht, const void *key, size_t key_size, void **r /* Assumes the key is a null-terminated string, returns the data, or NULL if not found. Note that it is possible for the data itself to be NULL */ -extern void * +void * cfuhash_get(cfuhash_table_t *ht, const char *key) { void *r = NULL; int rv = 0; @@ -428,7 +428,7 @@ cfuhash_get(cfuhash_table_t *ht, const char *key) { } /* Returns 1 if an entry exists in the table for the given key, 0 otherwise */ -extern int +int cfuhash_exists_data(cfuhash_table_t *ht, const void *key, size_t key_size) { void *r = NULL; int rv = cfuhash_get_data(ht, key, key_size, &r, NULL); @@ -437,7 +437,7 @@ cfuhash_exists_data(cfuhash_table_t *ht, const void *key, size_t key_size) { } /* Same as cfuhash_exists_data(), except assumes key is a null-terminated string */ -extern int +int cfuhash_exists(cfuhash_table_t *ht, const char *key) { return cfuhash_exists_data(ht, (const void *)key, -1); } @@ -448,7 +448,7 @@ cfuhash_exists(cfuhash_table_t *ht, const char *key) { value is zero. If a new entry is created for the key, the function returns 1. */ -extern int +int cfuhash_put_data(cfuhash_table_t *ht, const void *key, size_t key_size, void *data, size_t data_size, void **r) { unsigned int hv = 0; @@ -499,7 +499,7 @@ cfuhash_put_data(cfuhash_table_t *ht, const void *key, size_t key_size, void *da null-terminated string, and the old value is returned if it existed, otherwise NULL is returned. */ -extern void * +void * cfuhash_put(cfuhash_table_t *ht, const char *key, void *data) { void *r = NULL; if (!cfuhash_put_data(ht, (const void *)key, -1, data, 0, &r)) { @@ -508,7 +508,7 @@ cfuhash_put(cfuhash_table_t *ht, const char *key, void *data) { return NULL; } -extern void +void cfuhash_clear(cfuhash_table_t *ht) { cfuhash_entry *he = NULL; cfuhash_entry *hep = NULL; @@ -538,7 +538,7 @@ cfuhash_clear(cfuhash_table_t *ht) { } -extern void * +void * cfuhash_delete_data(cfuhash_table_t *ht, const void *key, size_t key_size) { unsigned int hv = 0; cfuhash_entry *he = NULL; @@ -579,12 +579,12 @@ cfuhash_delete_data(cfuhash_table_t *ht, const void *key, size_t key_size) { return r; } -extern void * +void * cfuhash_delete(cfuhash_table_t *ht, const char *key) { return cfuhash_delete_data(ht, key, -1); } -extern void ** +void ** cfuhash_keys_data(cfuhash_table_t *ht, size_t *num_keys, size_t **key_sizes, int fast) { size_t *key_lengths = NULL; void **keys = NULL; @@ -630,12 +630,12 @@ cfuhash_keys_data(cfuhash_table_t *ht, size_t *num_keys, size_t **key_sizes, int return keys; } -extern void ** +void ** cfuhash_keys(cfuhash_table_t *ht, size_t *num_keys, int fast) { return cfuhash_keys_data(ht, num_keys, NULL, fast); } -extern int +int cfuhash_each_data(cfuhash_table_t *ht, void **key, size_t *key_size, void **data, size_t *data_size) { @@ -645,7 +645,7 @@ cfuhash_each_data(cfuhash_table_t *ht, void **key, size_t *key_size, void **data return cfuhash_next_data(ht, key, key_size, data, data_size); } -extern int +int cfuhash_next_data(cfuhash_table_t *ht, void **key, size_t *key_size, void **data, size_t *data_size) { @@ -687,7 +687,7 @@ _cfuhash_destroy_entry(cfuhash_table_t *ht, cfuhash_entry *he, cfuhash_free_fn_t free(he); } -extern size_t +size_t cfuhash_foreach_remove(cfuhash_table_t *ht, cfuhash_remove_fn_t r_fn, cfuhash_free_fn_t ff, void *arg) { cfuhash_entry *entry = NULL; @@ -732,7 +732,7 @@ cfuhash_foreach_remove(cfuhash_table_t *ht, cfuhash_remove_fn_t r_fn, cfuhash_fr return num_removed; } -extern size_t +size_t cfuhash_foreach(cfuhash_table_t *ht, cfuhash_foreach_fn_t fe_fn, void *arg) { cfuhash_entry *entry = NULL; size_t hv = 0; @@ -761,19 +761,19 @@ cfuhash_foreach(cfuhash_table_t *ht, cfuhash_foreach_fn_t fe_fn, void *arg) { return num_accessed; } -extern int +int cfuhash_each(cfuhash_table_t *ht, char **key, void **data) { size_t key_size = 0; return cfuhash_each_data(ht, (void **)key, &key_size, data, NULL); } -extern int +int cfuhash_next(cfuhash_table_t *ht, char **key, void **data) { size_t key_size = 0; return cfuhash_next_data(ht, (void **)key, &key_size, data, NULL); } -extern int +int cfuhash_destroy_with_free_fn(cfuhash_table_t *ht, cfuhash_free_fn_t ff) { size_t i; if (!ht) return 0; @@ -799,7 +799,7 @@ cfuhash_destroy_with_free_fn(cfuhash_table_t *ht, cfuhash_free_fn_t ff) { return 1; } -extern int +int cfuhash_destroy(cfuhash_table_t *ht) { return cfuhash_destroy_with_free_fn(ht, NULL); } @@ -818,7 +818,7 @@ _pretty_print_foreach(void *key, size_t key_size, void *data, size_t data_size, return 0; } -extern int +int cfuhash_pretty_print(cfuhash_table_t *ht, FILE *fp) { int rv = 0; _pretty_print_arg parg; @@ -836,7 +836,7 @@ cfuhash_pretty_print(cfuhash_table_t *ht, FILE *fp) { return rv; } -extern int +int cfuhash_rehash(cfuhash_table_t *ht) { size_t new_size, i; cfuhash_entry **new_buckets = NULL; @@ -869,19 +869,19 @@ cfuhash_rehash(cfuhash_table_t *ht) { return 1; } -extern size_t +size_t cfuhash_num_entries(cfuhash_table_t *ht) { if (!ht) return 0; return ht->entries; } -extern size_t +size_t cfuhash_num_buckets(cfuhash_table_t *ht) { if (!ht) return 0; return ht->num_buckets; } -extern size_t +size_t cfuhash_num_buckets_used(cfuhash_table_t *ht) { size_t i = 0; size_t count = 0; @@ -897,7 +897,7 @@ cfuhash_num_buckets_used(cfuhash_table_t *ht) { return count; } -extern char * +char * cfuhash_bencode_strings(cfuhash_table_t *ht) { cfustring_t *bencoded = cfustring_new_with_initial_size(16); char **keys = NULL; diff --git a/src/cfuhash.h b/src/cfuhash.h index 337b133..efeaf71 100644 --- a/src/cfuhash.h +++ b/src/cfuhash.h @@ -67,68 +67,68 @@ typedef int (*cfuhash_foreach_fn_t)(void *key, size_t key_size, void *data, size void *arg); /* Creates a new hash table. */ -extern cfuhash_table_t * cfuhash_new(void); +cfuhash_table_t * cfuhash_new(void); /* Creates a new hash table with the specified size (number of * buckets). */ -extern cfuhash_table_t * cfuhash_new_with_initial_size(size_t size); +cfuhash_table_t * cfuhash_new_with_initial_size(size_t size); /* Creates a new hash table with the specified flags. Pass zero * for flags if you want the defaults. */ -extern cfuhash_table_t * cfuhash_new_with_flags(u_int32_t flags); +cfuhash_table_t * cfuhash_new_with_flags(u_int32_t flags); /* Same as cfuhash_new() except automatically calls cfuhash_set_free_fn(). */ -extern cfuhash_table_t * cfuhash_new_with_free_fn(cfuhash_free_fn_t ff); +cfuhash_table_t * cfuhash_new_with_free_fn(cfuhash_free_fn_t ff); /* Copies entries in src to dst */ -extern int cfuhash_copy(cfuhash_table_t *src, cfuhash_table_t *dst); +int cfuhash_copy(cfuhash_table_t *src, cfuhash_table_t *dst); /* Returns a new hash containing entries from both hash tables. * For any entries with the same key, the one from ht2 wins. */ -extern cfuhash_table_t * cfuhash_merge(cfuhash_table_t *ht1, cfuhash_table_t *ht2, +cfuhash_table_t * cfuhash_merge(cfuhash_table_t *ht1, cfuhash_table_t *ht2, u_int32_t flags); /* Sets the hashing function to use when computing which bucket to add * entries to. It should return a 32-bit unsigned integer. By * default, Perl's hashing algorithm is used. */ -extern int cfuhash_set_hash_function(cfuhash_table_t *ht, cfuhash_function_t hf); +int cfuhash_set_hash_function(cfuhash_table_t *ht, cfuhash_function_t hf); /* Sets the thresholds for when to rehash. The ratio * num_entries/buckets is compared against low and high. If it is * below 'low' or above 'high', the hash will shrink or grow, * respectively, unless the flags say to do otherwise. */ -extern int cfuhash_set_thresholds(cfuhash_table_t *ht, float low, float high); +int cfuhash_set_thresholds(cfuhash_table_t *ht, float low, float high); /* Sets the function to use when removing an entry from the hash, * i.e., when replacing an existing entry, deleting an entry, or * clearing the hash. It is passed the value of the entry as a * void *. */ -extern int cfuhash_set_free_function(cfuhash_table_t * ht, cfuhash_free_fn_t ff); +int cfuhash_set_free_function(cfuhash_table_t * ht, cfuhash_free_fn_t ff); /* Returns the hash's flags. See below for flag definitions. */ -extern u_int32_t cfuhash_get_flags(cfuhash_table_t *ht); +u_int32_t cfuhash_get_flags(cfuhash_table_t *ht); /* Sets a flag. */ -extern u_int32_t cfuhash_set_flag(cfuhash_table_t *ht, u_int32_t flag); +u_int32_t cfuhash_set_flag(cfuhash_table_t *ht, u_int32_t flag); /* Clears a flag. */ -extern u_int32_t cfuhash_clear_flag(cfuhash_table_t *ht, u_int32_t new_flag); +u_int32_t cfuhash_clear_flag(cfuhash_table_t *ht, u_int32_t new_flag); /* Returns the value for the entry with given key. If key_size is -1, * key is assumed to be a null-terminated string. If data_size is not * NULL, the size of the value is placed into data_size. */ -extern int cfuhash_get_data(cfuhash_table_t *ht, const void *key, size_t key_size, +int cfuhash_get_data(cfuhash_table_t *ht, const void *key, size_t key_size, void **data, size_t *data_size); /* Returns 1 if an entry with the given key exists in the hash, 0 otherwise. */ -extern int cfuhash_exists_data(cfuhash_table_t *ht, const void *key, size_t key_size); +int cfuhash_exists_data(cfuhash_table_t *ht, const void *key, size_t key_size); /* Inserts the given data value into the hash and associates it with * key. If key_size is -1, key is assumed to be a null-terminated @@ -137,16 +137,16 @@ extern int cfuhash_exists_data(cfuhash_table_t *ht, const void *key, size_t key_ * data_size is zero, it will be returned as zero when the value is * requested. */ -extern int cfuhash_put_data(cfuhash_table_t *ht, const void *key, size_t key_size, void *data, +int cfuhash_put_data(cfuhash_table_t *ht, const void *key, size_t key_size, void *data, size_t data_size, void **r); /* Clears the hash table (deletes all entries). */ -extern void cfuhash_clear(cfuhash_table_t *ht); +void cfuhash_clear(cfuhash_table_t *ht); /* Deletes the entry in the hash associated with key. If the entry * existed, it's value will be returned. */ -extern void * cfuhash_delete_data(cfuhash_table_t *ht, const void *key, size_t key_size); +void * cfuhash_delete_data(cfuhash_table_t *ht, const void *key, size_t key_size); /* Returns all the keys from the hash. The number of keys is placed * into the value pointed to by num_keys. If key_sizes is not NULL, @@ -154,7 +154,7 @@ extern void * cfuhash_delete_data(cfuhash_table_t *ht, const void *key, size_t k * of the keys are returned. Otherwise, pointers to the real keys * will be returned. */ -extern void **cfuhash_keys_data(cfuhash_table_t *ht, size_t *num_keys, size_t **key_sizes, +void **cfuhash_keys_data(cfuhash_table_t *ht, size_t *num_keys, size_t **key_sizes, int fast); /* Initializes a loop over all the key/value pairs in the hash. It @@ -162,7 +162,7 @@ extern void **cfuhash_keys_data(cfuhash_table_t *ht, size_t *num_keys, size_t ** * returned if there are any entries in the hash. 0 is returned * otherwise. */ -extern int cfuhash_each_data(cfuhash_table_t *ht, void **key, size_t *key_size, void **data, +int cfuhash_each_data(cfuhash_table_t *ht, void **key, size_t *key_size, void **data, size_t *data_size); /* Gets the next key/value pair from the hash. You must initialize @@ -170,7 +170,7 @@ extern int cfuhash_each_data(cfuhash_table_t *ht, void **key, size_t *key_size, * If a entry is left to return, 1 is returned from the function. 0 * is returned if there are no more entries in the hash. */ -extern int cfuhash_next_data(cfuhash_table_t *ht, void **key, size_t *key_size, void **data, +int cfuhash_next_data(cfuhash_table_t *ht, void **key, size_t *key_size, void **data, size_t *data_size); /* Iterates over the key/value pairs in the hash, passing each one @@ -178,7 +178,7 @@ extern int cfuhash_next_data(cfuhash_table_t *ht, void **key, size_t *key_size, * If ff is not NULL, it is the passed the data to be freed. arg * is passed to r_fn. */ -extern size_t cfuhash_foreach_remove(cfuhash_table_t *ht, cfuhash_remove_fn_t r_fn, +size_t cfuhash_foreach_remove(cfuhash_table_t *ht, cfuhash_remove_fn_t r_fn, cfuhash_free_fn_t ff, void *arg); /* Iterates over the key/value pairs in the hash, passing each one @@ -187,38 +187,38 @@ extern size_t cfuhash_foreach_remove(cfuhash_table_t *ht, cfuhash_remove_fn_t r_ * know what you're doing. A non-zero return value from fe_fn() * stops the iteration. */ -extern size_t cfuhash_foreach(cfuhash_table_t *ht, cfuhash_foreach_fn_t fe_fn, void *arg); +size_t cfuhash_foreach(cfuhash_table_t *ht, cfuhash_foreach_fn_t fe_fn, void *arg); /* Frees all resources allocated by the hash. If ff is not NULL, it * is called for each hash entry with the value of the entry passed as * its only argument. If ff is not NULL, it overrides any function * set previously with cfuhash_set_free_function(). */ -extern int cfuhash_destroy(cfuhash_table_t *ht); +int cfuhash_destroy(cfuhash_table_t *ht); -extern int cfuhash_destroy_with_free_fn(cfuhash_table_t *ht, cfuhash_free_fn_t ff); +int cfuhash_destroy_with_free_fn(cfuhash_table_t *ht, cfuhash_free_fn_t ff); /* Rebuild the hash to better accomodate the number of entries. See * cfuhash_set_thresholds(). */ -extern int cfuhash_rehash(cfuhash_table_t *ht); +int cfuhash_rehash(cfuhash_table_t *ht); /* Returns the number entries in the hash. */ -extern size_t cfuhash_num_entries(cfuhash_table_t *ht); +size_t cfuhash_num_entries(cfuhash_table_t *ht); /* Returns the number of buckets allocated for the hash. */ -extern size_t cfuhash_num_buckets(cfuhash_table_t *ht); +size_t cfuhash_num_buckets(cfuhash_table_t *ht); /* Returns the number of buckets actually used out of the total number * allocated for the hash. */ -extern size_t cfuhash_num_buckets_used(cfuhash_table_t *ht); +size_t cfuhash_num_buckets_used(cfuhash_table_t *ht); /* Assumes all the keys and values are null-terminated strings and * returns a bencoded string representing the hash (see * http://www.bittorrent.com/protocol.html) */ -extern char * cfuhash_bencode_strings(cfuhash_table_t *ht); +char * cfuhash_bencode_strings(cfuhash_table_t *ht); /* Locks the hash. Use this with the each and next functions for * concurrency control. Note that the hash is locked automatically @@ -226,18 +226,18 @@ extern char * cfuhash_bencode_strings(cfuhash_table_t *ht); * try to insert something into it, you may get into a deadlock, * depending on your system defaults for how mutexes work. */ -extern int cfuhash_lock(cfuhash_table_t *ht); +int cfuhash_lock(cfuhash_table_t *ht); /* Unlocks the hash. Use this with the each an next functions for * concurrency control. The caveat for cfuhash_lcok() also applies to * this function. */ -extern int cfuhash_unlock(cfuhash_table_t *ht); +int cfuhash_unlock(cfuhash_table_t *ht); /* Pretty print the hash's key/value pairs to the stream fp. It is * assumed that all the keys and values are null-terminated strings. */ -extern int cfuhash_pretty_print(cfuhash_table_t *ht, FILE *fp); +int cfuhash_pretty_print(cfuhash_table_t *ht, FILE *fp); /* These are like the _data versions of these functions, with the * following exceptions: @@ -245,13 +245,13 @@ extern int cfuhash_pretty_print(cfuhash_table_t *ht, FILE *fp); * 2) They don't worry about the size of the data. * 3) Returned keys or values are the return value of the function. */ -extern void * cfuhash_get(cfuhash_table_t *ht, const char *key); -extern int cfuhash_exists(cfuhash_table_t *ht, const char *key); -extern void * cfuhash_put(cfuhash_table_t *ht, const char *key, void *data); -extern void * cfuhash_delete(cfuhash_table_t *ht, const char *key); -extern int cfuhash_each(cfuhash_table_t *ht, char **key, void **data); -extern int cfuhash_next(cfuhash_table_t *ht, char **key, void **data); -extern void **cfuhash_keys(cfuhash_table_t *ht, size_t *num_keys, int fast); +void * cfuhash_get(cfuhash_table_t *ht, const char *key); +int cfuhash_exists(cfuhash_table_t *ht, const char *key); +void * cfuhash_put(cfuhash_table_t *ht, const char *key, void *data); +void * cfuhash_delete(cfuhash_table_t *ht, const char *key); +int cfuhash_each(cfuhash_table_t *ht, char **key, void **data); +int cfuhash_next(cfuhash_table_t *ht, char **key, void **data); +void **cfuhash_keys(cfuhash_table_t *ht, size_t *num_keys, int fast); /* hash table flags */ diff --git a/src/cfulist.c b/src/cfulist.c index b9c5b71..4958fd4 100644 --- a/src/cfulist.c +++ b/src/cfulist.c @@ -71,7 +71,7 @@ struct cfulist { cfulist_free_fn_t free_fn; }; -extern cfulist_t * +cfulist_t * cfulist_new(void) { cfulist_t *list = calloc(1, sizeof(cfulist_t)); #ifdef HAVE_PTHREAD_H @@ -81,14 +81,14 @@ cfulist_new(void) { return list; } -extern cfulist_t * +cfulist_t * cfulist_new_with_free_fn(cfulist_free_fn_t free_fn) { cfulist_t *list = cfulist_new(); list->free_fn = free_fn; return list; } -extern size_t +size_t cfulist_num_entries(cfulist_t *list) { return list->num_entries; } @@ -112,7 +112,7 @@ new_list_entry() { return calloc(1, sizeof(cfulist_entry)); } -extern int +int cfulist_push_data(cfulist_t *list, void *data, size_t data_size) { cfulist_entry *entry = new_list_entry(); if (!entry) return 0; @@ -138,7 +138,7 @@ cfulist_push_data(cfulist_t *list, void *data, size_t data_size) { return 1; } -extern int +int cfulist_pop_data(cfulist_t *list, void **data, size_t *data_size) { if (!list) { *data = NULL; @@ -176,7 +176,7 @@ cfulist_pop_data(cfulist_t *list, void **data, size_t *data_size) { return 0; } -extern int +int cfulist_unshift_data(cfulist_t *list, void *data, size_t data_size) { cfulist_entry *entry = new_list_entry(); if (!entry) return 0; @@ -202,7 +202,7 @@ cfulist_unshift_data(cfulist_t *list, void *data, size_t data_size) { return 1; } -extern int +int cfulist_shift_data(cfulist_t *list, void **data, size_t *data_size) { int rv = 0; if (!list) { @@ -241,18 +241,18 @@ cfulist_shift_data(cfulist_t *list, void **data, size_t *data_size) { return rv; } -extern int +int cfulist_enqueue_data(cfulist_t *list, void *data, size_t data_size) { return cfulist_push_data(list, data, data_size); } -extern int +int cfulist_dequeue_data(cfulist_t *list, void **data, size_t *data_size) { return cfulist_shift_data(list, data, data_size); } -extern int +int cfulist_first_data(cfulist_t *list, void **data, size_t *data_size) { int rv = 0; if (!list) { @@ -274,7 +274,7 @@ cfulist_first_data(cfulist_t *list, void **data, size_t *data_size) { return rv; } -extern int +int cfulist_last_data(cfulist_t *list, void **data, size_t *data_size) { int rv = 0; if (!list) { @@ -296,7 +296,7 @@ cfulist_last_data(cfulist_t *list, void **data, size_t *data_size) { return rv; } -extern int +int cfulist_nth_data(cfulist_t *list, void **data, size_t *data_size, size_t n) { int rv = 0; size_t i = 0; @@ -324,20 +324,20 @@ cfulist_nth_data(cfulist_t *list, void **data, size_t *data_size, size_t n) { return rv; } -extern void +void cfulist_reset_each(cfulist_t *list) { if (!list) return; list->each_ptr = list->entries; } -extern int +int cfulist_each_data(cfulist_t *list, void **data, size_t *data_size) { if (!list) return 0; cfulist_reset_each(list); return cfulist_next_data(list, data, data_size); } -extern int +int cfulist_next_data(cfulist_t *list, void **data, size_t *data_size) { if (!list) return 0; *data = NULL; @@ -350,7 +350,7 @@ cfulist_next_data(cfulist_t *list, void **data, size_t *data_size) { return 0; } -extern size_t +size_t cfulist_foreach(cfulist_t *list, cfulist_foreach_fn_t fe_fn, void *arg) { cfulist_entry *entry = NULL; size_t num_processed = 0; @@ -384,7 +384,7 @@ _cfulist_map_foreach(void *data, size_t data_size, void *arg) { return 0; } -extern cfulist_t * +cfulist_t * cfulist_map(cfulist_t *list, cfulist_map_fn_t map_fn, void *arg) { cfulist_t *new_list = cfulist_new(); _cfulist_map_ds ds; @@ -398,12 +398,12 @@ cfulist_map(cfulist_t *list, cfulist_map_fn_t map_fn, void *arg) { /* For when you don't care about the data size */ -extern int +int cfulist_push(cfulist_t *list, void *data) { return cfulist_push_data(list, data, 0); } -extern void * +void * cfulist_pop(cfulist_t *list) { void *data = NULL; if (cfulist_pop_data(list, &data, NULL)) { @@ -412,12 +412,12 @@ cfulist_pop(cfulist_t *list) { return NULL; } -extern int +int cfulist_unshift(cfulist_t *list, void *data) { return cfulist_unshift_data(list, data, 0); } -extern void * +void * cfulist_shift(cfulist_t *list) { void *data = NULL; if (cfulist_shift_data(list, &data, NULL)) { @@ -426,24 +426,24 @@ cfulist_shift(cfulist_t *list) { return NULL; } -extern int +int cfulist_enqueue(cfulist_t *list, void *data) { return cfulist_push(list, data); } -extern void * +void * cfulist_dequeue(cfulist_t *list) { return cfulist_shift(list); } /* Dealing with strings */ -extern int +int cfulist_push_string(cfulist_t *list, char *data) { return cfulist_push_data(list, (void *)data, -1); } -extern char * +char * cfulist_pop_string(cfulist_t *list) { void *data = NULL; if (cfulist_pop_data(list, &data, NULL)) { @@ -452,12 +452,12 @@ cfulist_pop_string(cfulist_t *list) { return NULL; } -extern int +int cfulist_unshift_string(cfulist_t *list, char *data) { return cfulist_unshift_data(list, (void *)data, -1); } -extern char * +char * cfulist_shift_string(cfulist_t *list) { void *data = NULL; if (cfulist_shift_data(list, &data, NULL)) { @@ -466,12 +466,12 @@ cfulist_shift_string(cfulist_t *list) { return NULL; } -extern int +int cfulist_enqueue_string(cfulist_t *list, char *data) { return cfulist_push_string(list, data); } -extern char * +char * cfulist_dequeue_string(cfulist_t *list) { return cfulist_shift_string(list); } @@ -493,7 +493,7 @@ _join_foreach_fn(void *data, size_t data_size, void *arg) { return 0; } -extern char * +char * cfulist_join(cfulist_t *list, const char *delimiter) { _join_foreach_struct *arg = calloc(1, sizeof(_join_foreach_struct)); char *str = NULL; @@ -509,7 +509,7 @@ cfulist_join(cfulist_t *list, const char *delimiter) { return str; } -extern void +void cfulist_destroy(cfulist_t *list) { if (!list) return; @@ -536,7 +536,7 @@ cfulist_destroy(cfulist_t *list) { free(list); } -extern void +void cfulist_destroy_with_free_fn(cfulist_t *list, cfulist_free_fn_t free_fn) { if (!list) return; diff --git a/src/cfulist.h b/src/cfulist.h index 68b85ac..52e92ec 100644 --- a/src/cfulist.h +++ b/src/cfulist.h @@ -63,92 +63,92 @@ typedef void * (*cfulist_map_fn_t)(void *data, size_t data_size, void *arg, typedef void (*cfulist_free_fn_t)(void *data); /* Returns a new list. */ -extern cfulist_t * cfulist_new(void); +cfulist_t * cfulist_new(void); /* Same as cfulist_new(), but set a function to be called on each * element when the list is destroyed. */ -extern cfulist_t * cfulist_new_with_free_fn(cfulist_free_fn_t free_fn); +cfulist_t * cfulist_new_with_free_fn(cfulist_free_fn_t free_fn); /* Returns the number of entries in the list. */ -extern size_t cfulist_num_entries(cfulist_t *list); +size_t cfulist_num_entries(cfulist_t *list); /* Manipulating list entries */ /* Push a value onto the end of the list. */ -extern int cfulist_push_data(cfulist_t *list, void *data, size_t data_size); +int cfulist_push_data(cfulist_t *list, void *data, size_t data_size); /* Pop a value from the end of the list. */ -extern int cfulist_pop_data(cfulist_t *list, void **data, size_t *data_size); +int cfulist_pop_data(cfulist_t *list, void **data, size_t *data_size); /* Add a value at the beginning of the list. */ -extern int cfulist_unshift_data(cfulist_t *list, void *data, size_t data_size); +int cfulist_unshift_data(cfulist_t *list, void *data, size_t data_size); /* Shift a value off the beginning of the list. */ -extern int cfulist_shift_data(cfulist_t *list, void **data, size_t *data_size); +int cfulist_shift_data(cfulist_t *list, void **data, size_t *data_size); /* Add a value at the end of the queue (equivalent to push) */ -extern int cfulist_enqueue_data(cfulist_t *list, void *data, size_t data_size); +int cfulist_enqueue_data(cfulist_t *list, void *data, size_t data_size); /* Remove the value at the beginning of the list (equivalent to shift). */ -extern int cfulist_dequeue_data(cfulist_t *list, void **data, size_t *data_size); +int cfulist_dequeue_data(cfulist_t *list, void **data, size_t *data_size); /* Return the last entry from the list (without removing it from * the list). */ -extern int cfulist_first_data(cfulist_t *list, void **data, size_t *data_size); +int cfulist_first_data(cfulist_t *list, void **data, size_t *data_size); /* Return the last entry from the list (without removing it from * the list). */ -extern int cfulist_last_data(cfulist_t *list, void **data, size_t *data_size); +int cfulist_last_data(cfulist_t *list, void **data, size_t *data_size); /* Return the nth entry from the list (without removing it from * the list). n starts at zero. */ -extern int cfulist_nth_data(cfulist_t *list, void **data, size_t *data_size, size_t n); +int cfulist_nth_data(cfulist_t *list, void **data, size_t *data_size, size_t n); -extern void cfulist_reset_each(cfulist_t *list); -extern int cfulist_each_data(cfulist_t *list, void **data, size_t *data_size); -extern int cfulist_next_data(cfulist_t *list, void **data, size_t *data_size); +void cfulist_reset_each(cfulist_t *list); +int cfulist_each_data(cfulist_t *list, void **data, size_t *data_size); +int cfulist_next_data(cfulist_t *list, void **data, size_t *data_size); /* Calls fe_fn() for each element in the list. Also passes arg on * each call. If fe_fn() returns a non-zero value, the iteration * over the elements stops. */ -extern size_t cfulist_foreach(cfulist_t *list, cfulist_foreach_fn_t fe_fn, void *arg); +size_t cfulist_foreach(cfulist_t *list, cfulist_foreach_fn_t fe_fn, void *arg); /* Creates a new list from the list passed in. Calls map_fn() on * each element in the list. The return value is placed in the * corresponding position in the new list. */ -extern cfulist_t *cfulist_map(cfulist_t *list, cfulist_map_fn_t map_fn, void *arg); +cfulist_t *cfulist_map(cfulist_t *list, cfulist_map_fn_t map_fn, void *arg); /* Free all resources used by the list. */ -extern void cfulist_destroy(cfulist_t *list); -extern void cfulist_destroy_with_free_fn(cfulist_t *list, cfulist_free_fn_t free_fn); +void cfulist_destroy(cfulist_t *list); +void cfulist_destroy_with_free_fn(cfulist_t *list, cfulist_free_fn_t free_fn); /* When you don't care about the size of the data */ -extern int cfulist_push(cfulist_t *list, void *data); -extern void * cfulist_pop(cfulist_t *list); -extern int cfulist_unshift(cfulist_t *list, void *data); -extern void * cfulist_shift(cfulist_t *list); -extern int cfulist_enqueue(cfulist_t *list, void *data); -extern void *cfulist_dequeue(cfulist_t *list); +int cfulist_push(cfulist_t *list, void *data); +void * cfulist_pop(cfulist_t *list); +int cfulist_unshift(cfulist_t *list, void *data); +void * cfulist_shift(cfulist_t *list); +int cfulist_enqueue(cfulist_t *list, void *data); +void *cfulist_dequeue(cfulist_t *list); /* Strings -- assume data is a null-terminated string -- size is * calculated by strlen(data) + 1 */ -extern int cfulist_push_string(cfulist_t *list, char *data); -extern char * cfulist_pop_string(cfulist_t *list); -extern int cfulist_unshift_string(cfulist_t *list, char *data); -extern char * cfulist_shift_string(cfulist_t *list); -extern int cfulist_enqueue_string(cfulist_t *list, char *data); -extern char *cfulist_dequeue_string(cfulist_t *list); +int cfulist_push_string(cfulist_t *list, char *data); +char * cfulist_pop_string(cfulist_t *list); +int cfulist_unshift_string(cfulist_t *list, char *data); +char * cfulist_shift_string(cfulist_t *list); +int cfulist_enqueue_string(cfulist_t *list, char *data); +char *cfulist_dequeue_string(cfulist_t *list); -extern char *cfulist_join(cfulist_t *list, const char *delimiter); +char *cfulist_join(cfulist_t *list, const char *delimiter); CFU_END_DECLS diff --git a/src/cfuopt.c b/src/cfuopt.c index e8c3db9..1834d58 100644 --- a/src/cfuopt.c +++ b/src/cfuopt.c @@ -71,7 +71,7 @@ typedef struct cfuopt_list_entry { cfulist_t *param_names; } cfuopt_list_entry_t; -extern cfuopt_t * +cfuopt_t * cfuopt_new(void) { cfuopt_t *context = calloc(1, sizeof(cfuopt_t)); context->option_list = cfulist_new(); @@ -194,7 +194,7 @@ _add_to_option_map(void *data, size_t data_size, void *arg) { return 0; } -extern void +void cfuopt_add_entry(cfuopt_t *context, const char *opt_str, void *arg_data, const char *description, const char *arg_description) { cfuopt_list_entry_t *entry = calloc(1, sizeof(cfuopt_list_entry_t)); @@ -306,7 +306,7 @@ _update_extra(void *data, size_t data_size, void *arg) { return 0; } -extern void +void cfuopt_parse(cfuopt_t *context, int *argc, char ***argv, char **error) { int i = 0; char **args = *argv; @@ -419,7 +419,7 @@ _opt_list_free_fn(void *data) { free(data); } -extern void +void cfuopt_destroy(cfuopt_t *context) { if (!context) return; cfulist_destroy_with_free_fn(context->option_list, _opt_list_free_fn); @@ -469,7 +469,7 @@ _cfuopt_pretty_print_foreach(void *key, size_t key_size, void *data, size_t data return 0; } -extern void +void cfuopt_pretty_print(cfuopt_t *context) { cfuhash_foreach(context->option_map, _cfuopt_pretty_print_foreach, NULL); } @@ -479,7 +479,7 @@ _list_simple_free_fn(void *data) { free(data); } -extern void * +void * _param_map_fn(void *data, size_t data_size, void *arg, size_t *new_data_size) { char *name = (char *)data; size_t len = 0; @@ -598,7 +598,7 @@ _desc_list_free(void *data) { free(data); } -extern char * +char * cfuopt_get_help_str(cfuopt_t *context) { cfulist_t *desc_list = NULL; size_t max_width = 0; diff --git a/src/cfuopt.h b/src/cfuopt.h index dd4d89f..60cdc6e 100644 --- a/src/cfuopt.h +++ b/src/cfuopt.h @@ -45,24 +45,24 @@ CFU_BEGIN_DECLS typedef struct cfuopt_struct cfuopt_t; /* Returns a new options context */ -extern cfuopt_t *cfuopt_new(void); +cfuopt_t *cfuopt_new(void); /* Adds to the list of known options. */ -extern void cfuopt_add_entry(cfuopt_t *context, const char *opt_str, void *arg_data, +void cfuopt_add_entry(cfuopt_t *context, const char *opt_str, void *arg_data, const char *description, const char *arg_description); /* Parses the command line and modifies argc and argv to account for * left over arguments. */ -extern void cfuopt_parse(cfuopt_t *context, int *argc, char ***argv, char **error); +void cfuopt_parse(cfuopt_t *context, int *argc, char ***argv, char **error); /* Returns a help string built from the entries added with * cfuopt_add_entry(). */ -extern char * cfuopt_get_help_str(cfuopt_t *context); +char * cfuopt_get_help_str(cfuopt_t *context); /* Frees up resources used by the option parser. */ -extern void cfuopt_destroy(cfuopt_t *context); +void cfuopt_destroy(cfuopt_t *context); CFU_END_DECLS diff --git a/src/cfustring.c b/src/cfustring.c index 64ac86b..c02c846 100644 --- a/src/cfustring.c +++ b/src/cfustring.c @@ -61,12 +61,12 @@ struct cfustring { char *str; }; -extern cfustring_t * +cfustring_t * cfustring_new(void) { return cfustring_new_with_initial_size(0); } -extern cfustring_t * +cfustring_t * cfustring_new_with_initial_size(size_t initial_size) { cfustring_t *cfu_str = calloc(1, sizeof(cfustring_t)); cfu_str->type = libcfu_t_string; @@ -78,14 +78,14 @@ cfustring_new_with_initial_size(size_t initial_size) { return cfu_str; } -extern cfustring_t * +cfustring_t * cfustring_new_from_string(const char *string) { cfustring_t *cfu_str = cfustring_new(); cfustring_append(cfu_str, string); return cfu_str; } -extern int +int cfustring_dup(cfustring_t *cfu_str, const char *string) { if (!string) { cfu_str->max_size = 0; @@ -100,7 +100,7 @@ cfustring_dup(cfustring_t *cfu_str, const char *string) { return 1; } -extern int +int cfustring_clear(cfustring_t *cfu_str) { if (cfu_str->str) { cfu_str->str[0] = '\000'; @@ -109,7 +109,7 @@ cfustring_clear(cfustring_t *cfu_str) { return 1; } -extern int +int cfustring_append_n(cfustring_t *cfu_str, const char *string, size_t n) { size_t str_len = 0; if (!string) return 1; @@ -159,17 +159,17 @@ cfustring_append_n(cfustring_t *cfu_str, const char *string, size_t n) { return 1; } -extern int +int cfustring_append(cfustring_t *cfu_str, const char *string) { return cfustring_append_n(cfu_str, string, 0); } -extern char * +char * cfustring_get_buffer(cfustring_t *cfu_str) { return cfu_str->str; } -extern char * +char * cfustring_get_buffer_copy(cfustring_t *cfu_str) { char *buffer = NULL; if (!cfu_str->str) return NULL; @@ -200,12 +200,12 @@ _dup_str_n(const char *str, size_t n) { return ns; } -extern char * +char * cfustring_dup_c_str(const char *str) { return _dup_str(str); } -extern char * +char * cfustring_dup_c_str_n(const char *str, size_t n) { return _dup_str_n(str, n); } @@ -321,7 +321,7 @@ __cfustring_split_to_raw(cfustring_t *cfu_str, size_t *num_strings, size_t num_s return ret_strings; } -extern cfustring_t ** +cfustring_t ** cfustring_split(cfustring_t *cfu_str, size_t *num_strings, size_t limit, ...) { va_list ap; char **strings = NULL; @@ -354,7 +354,7 @@ cfustring_split(cfustring_t *cfu_str, size_t *num_strings, size_t limit, ...) { } -extern char ** +char ** cfustring_split_to_c_str(cfustring_t *cfu_str, size_t *num_strings, size_t limit, ...) { char **rv = NULL; va_list ap; @@ -376,7 +376,7 @@ cfustring_split_to_c_str(cfustring_t *cfu_str, size_t *num_strings, size_t limit return rv; } -extern char * +char * cfustring_sprintf_c_str(const char *fmt, ...) { va_list ap; char *str = NULL; @@ -391,7 +391,7 @@ cfustring_sprintf_c_str(const char *fmt, ...) { return str; } -extern size_t +size_t cfustring_sprintf(cfustring_t *cfu_str, const char *fmt, ...) { va_list ap; size_t rv = 0; @@ -454,7 +454,7 @@ _safe_strncpy(char **buf, size_t *buf_size, const char *src, size_t size) { return rv; } -extern size_t +size_t cfustring_vsprintf(cfustring_t *cfu_str, const char *fmt_in, va_list ap) { const char *ptr = NULL; const char *start = NULL; @@ -594,14 +594,14 @@ cfustring_vsprintf(cfustring_t *cfu_str, const char *fmt_in, va_list ap) { return byte_count; } -extern int +int cfustring_destroy(cfustring_t *cfu_str) { free(cfu_str->str); free(cfu_str); return 1; } -extern char ** +char ** cfustring_c_str_split(const char *c_str, size_t *num_strings, size_t limit, ...) { cfustring_t *cfu_str = cfustring_new_from_string(c_str); char **rv = NULL; diff --git a/src/cfustring.h b/src/cfustring.h index 8a49899..6d89055 100644 --- a/src/cfustring.h +++ b/src/cfustring.h @@ -47,70 +47,70 @@ CFU_BEGIN_DECLS typedef struct cfustring cfustring_t; /* Returns a new String. */ -extern cfustring_t * cfustring_new(void); +cfustring_t * cfustring_new(void); /* Returns a new String, but preallocates a buffer of the given size. */ -extern cfustring_t * cfustring_new_with_initial_size(size_t initial_size); +cfustring_t * cfustring_new_with_initial_size(size_t initial_size); /* Returns a new String initalized with the given string. */ -extern cfustring_t * cfustring_new_from_string(const char *string); +cfustring_t * cfustring_new_from_string(const char *string); /* Overwrite anything currently in cfu_str with string. */ -extern int cfustring_dup(cfustring_t *cfu_str, const char *string); +int cfustring_dup(cfustring_t *cfu_str, const char *string); /* Truncate the string. */ -extern int cfustring_clear(cfustring_t *cfu_str); +int cfustring_clear(cfustring_t *cfu_str); /* Append str to the end of the buffer in cfu_str. */ -extern int cfustring_append(cfustring_t *cfu_str, const char *str); +int cfustring_append(cfustring_t *cfu_str, const char *str); /* Get the buffer used to hold the string. Do not free() it, as it is * used directly by cfustring and will be destroyed when * cfustring_destroy() is called. */ -extern char * cfustring_get_buffer(cfustring_t *cfu_str); +char * cfustring_get_buffer(cfustring_t *cfu_str); /* Same as cfustring_get_buffer(), except return a copy of the string. * Caller is responsible for deallocating the buffer with free(). */ -extern char * cfustring_get_buffer_copy(cfustring_t *cfu_str); +char * cfustring_get_buffer_copy(cfustring_t *cfu_str); /* Split cfu_str on one or more delimiting strings, e.g., * cfustring_split(cfu_str, 2, 0, "\r\n", "\n"). Use a limit > 0 if * you want to only get back a certain number of strings and ignore * any extra delimiters. */ -extern cfustring_t ** cfustring_split(cfustring_t *cfu_str, size_t *num_strings, +cfustring_t ** cfustring_split(cfustring_t *cfu_str, size_t *num_strings, size_t limit, ...); /* Same as cfustring_split(), except return an array of C-strings. * Caller is responsible for deallocating the buffers. */ -extern char ** cfustring_split_to_c_str(cfustring_t *cfu_str, size_t *num_strings, +char ** cfustring_split_to_c_str(cfustring_t *cfu_str, size_t *num_strings, size_t limit, ...); /* Free all resources allocated by cfu_str. */ -extern int cfustring_destroy(cfustring_t *cfu_str); +int cfustring_destroy(cfustring_t *cfu_str); /* Duplicate the C string str. Caller must free with free(). */ -extern char * cfustring_dup_c_str(const char *str); +char * cfustring_dup_c_str(const char *str); /* Same as cfustring_dup_c_str(), but only copy at most n chars */ -extern char * cfustring_dup_c_str_n(const char *str, size_t n); +char * cfustring_dup_c_str_n(const char *str, size_t n); /* Like sprintf(), but writes to a self-extending string. */ -extern size_t cfustring_sprintf(cfustring_t *cfu_str, const char *fmt, ...); +size_t cfustring_sprintf(cfustring_t *cfu_str, const char *fmt, ...); /* Like vsprintf(), but writes to a self-extending string. */ -extern size_t cfustring_vsprintf(cfustring_t *cfu_str, const char *fmt, va_list ap); +size_t cfustring_vsprintf(cfustring_t *cfu_str, const char *fmt, va_list ap); /* Similar to sprintf(), but allocates a C string of the * appropriate size for you and returns it. */ -extern char * cfustring_sprintf_c_str(const char *fmt, ...); +char * cfustring_sprintf_c_str(const char *fmt, ...); /* Like cfustring_split_to_c_str(), but split a char * instead of a cfustring_t *. */ -extern char ** cfustring_c_str_split(const char *c_str, size_t *num_strings, size_t limit, ...); +char ** cfustring_c_str_split(const char *c_str, size_t *num_strings, size_t limit, ...); CFU_END_DECLS diff --git a/src/cfuthread_queue.c b/src/cfuthread_queue.c index 9845516..23c910e 100644 --- a/src/cfuthread_queue.c +++ b/src/cfuthread_queue.c @@ -110,7 +110,7 @@ _run_queue(void *arg) { } -extern cfuthread_queue_t * +cfuthread_queue_t * cfuthread_queue_new_with_cleanup(cfuthread_queue_fn_t fn, cfuthread_queue_init_t init_fn, void *init_arg, cfuthread_queue_cleanup_t cleanup_fn, void *cleanup_arg) { @@ -134,12 +134,12 @@ cfuthread_queue_new_with_cleanup(cfuthread_queue_fn_t fn, cfuthread_queue_init_t return tq; } -extern cfuthread_queue_t * +cfuthread_queue_t * cfuthread_queue_new(cfuthread_queue_fn_t fn) { return cfuthread_queue_new_with_cleanup(fn, NULL, NULL, NULL, NULL); } -extern void * +void * cfuthread_queue_make_request(cfuthread_queue_t * tq, void *data) { cfuthread_queue_entry *request = _new_cfuthread_entry(data); @@ -158,7 +158,7 @@ cfuthread_queue_make_request(cfuthread_queue_t * tq, void *data) { return data; } -extern void +void cfuthread_queue_destroy(cfuthread_queue_t *tq) { void *rv = NULL; diff --git a/src/cfuthread_queue.h b/src/cfuthread_queue.h index 577fea9..5441735 100644 --- a/src/cfuthread_queue.h +++ b/src/cfuthread_queue.h @@ -62,7 +62,7 @@ typedef void (*cfuthread_queue_cleanup_t)(void *arg); /* Creates a new thread queue structure that will run the given * function when a request is received. */ -extern cfuthread_queue_t * cfuthread_queue_new(cfuthread_queue_fn_t fn); +cfuthread_queue_t * cfuthread_queue_new(cfuthread_queue_fn_t fn); /* Same as cfuthread_queue_new(), but with an initialization * function that gets called with the argument init_arg when the @@ -70,7 +70,7 @@ extern cfuthread_queue_t * cfuthread_queue_new(cfuthread_queue_fn_t fn); * the argument cleanup_arg when the thread exits, e.g., when * cfuthread_queue_destroy() is called. */ -extern cfuthread_queue_t * cfuthread_queue_new_with_cleanup(cfuthread_queue_fn_t fn, +cfuthread_queue_t * cfuthread_queue_new_with_cleanup(cfuthread_queue_fn_t fn, cfuthread_queue_init_t init_fn, void *init_arg, cfuthread_queue_cleanup_t cleanup_fn, void *cleanup_arg); @@ -78,12 +78,12 @@ extern cfuthread_queue_t * cfuthread_queue_new_with_cleanup(cfuthread_queue_fn_t * function fn given to cfuthread_queue_new when it reaches the * front of the queue. */ -extern void * cfuthread_queue_make_request(cfuthread_queue_t * tq, void *data); +void * cfuthread_queue_make_request(cfuthread_queue_t * tq, void *data); /* Free up resources used by the queue, in addition to canceling * the thread. */ -extern void cfuthread_queue_destroy(cfuthread_queue_t *); +void cfuthread_queue_destroy(cfuthread_queue_t *); CFU_END_DECLS diff --git a/src/cfutime.c b/src/cfutime.c index cfd7c55..b1b03c9 100644 --- a/src/cfutime.c +++ b/src/cfutime.c @@ -50,30 +50,30 @@ typedef struct cfutime { struct timeval end_tv; } cfutime; -extern cfutime_t * +cfutime_t * cfutime_new(void) { cfutime_t *time = calloc(1, sizeof(cfutime)); time->type = libcfu_t_time; return time; } -extern void +void cfutime_begin(cfutime_t *time) { gettimeofday(&(time->begin_tv), NULL); } -extern void +void cfutime_end(cfutime_t *time) { gettimeofday(&(time->end_tv), NULL); } -extern double +double cfutime_elapsed(cfutime_t *time) { return (double)time->end_tv.tv_sec + ((double)time->end_tv.tv_usec)/1000000 - ((double)time->begin_tv.tv_sec + ((double)time->begin_tv.tv_usec)/1000000); } -extern void +void cfutime_free(cfutime_t *time) { free(time); } diff --git a/src/cfutime.h b/src/cfutime.h index d2fe82a..ed8d7dc 100644 --- a/src/cfutime.h +++ b/src/cfutime.h @@ -45,19 +45,19 @@ CFU_BEGIN_DECLS typedef struct cfutime cfutime_t; /* Return a new cfutime structure. */ -extern cfutime_t *cfutime_new(void); +cfutime_t *cfutime_new(void); /* Start the timer. */ -extern void cfutime_begin(cfutime_t *time); +void cfutime_begin(cfutime_t *time); /* Stop the timer. */ -extern void cfutime_end(cfutime_t *time); +void cfutime_end(cfutime_t *time); /* Return the number of seconds elapsed as a double. */ -extern double cfutime_elapsed(cfutime_t *time); +double cfutime_elapsed(cfutime_t *time); /* Deallocate resources allocated for time. */ -extern void cfutime_free(cfutime_t *time); +void cfutime_free(cfutime_t *time); CFU_END_DECLS