diff options
author | Daniel Stenberg <daniel@haxx.se> | 2016-06-21 19:31:24 +0200 |
---|---|---|
committer | Daniel Stenberg <daniel@haxx.se> | 2016-06-22 10:28:41 +0200 |
commit | 80388edefca58f8199cdfde077efb7f6d91e60fa (patch) | |
tree | 75a7c62086c38a4f85a4c27c82cac7d98afccbf8 | |
parent | 434f8d0389f2969b393ff81ead713b7600502f27 (diff) |
typedefs: use the full structs in internal code...
... and save the typedef'ed names for headers and external APIs.
-rw-r--r-- | lib/easy.c | 37 | ||||
-rw-r--r-- | lib/easyif.h | 4 | ||||
-rw-r--r-- | lib/escape.c | 11 | ||||
-rw-r--r-- | lib/http2.c | 2 | ||||
-rw-r--r-- | lib/multi.c | 35 | ||||
-rw-r--r-- | lib/share.c | 9 | ||||
-rw-r--r-- | lib/ssh.c | 2 |
7 files changed, 51 insertions, 49 deletions
diff --git a/lib/easy.c b/lib/easy.c index 78ca0fa58..91c1382f8 100644 --- a/lib/easy.c +++ b/lib/easy.c @@ -365,7 +365,7 @@ void curl_global_cleanup(void) * curl_easy_init() is the external interface to alloc, setup and init an * easy handle that is returned. If anything goes wrong, NULL is returned. */ -CURL *curl_easy_init(void) +struct Curl_easy *curl_easy_init(void) { CURLcode result; struct Curl_easy *data; @@ -396,7 +396,7 @@ CURL *curl_easy_init(void) */ #undef curl_easy_setopt -CURLcode curl_easy_setopt(CURL *data, CURLoption tag, ...) +CURLcode curl_easy_setopt(struct Curl_easy *data, CURLoption tag, ...) { va_list arg; CURLcode result; @@ -433,7 +433,7 @@ struct events { * updated. */ -static int events_timer(CURLM *multi, /* multi handle */ +static int events_timer(struct Curl_multi *multi, /* multi handle */ long timeout_ms, /* see above */ void *userp) /* private callback pointer */ { @@ -488,7 +488,7 @@ static short socketcb2poll(int pollmask) * Callback that gets called with information about socket activity to * monitor. */ -static int events_socket(CURL *easy, /* easy handle */ +static int events_socket(struct Curl_easy *easy, /* easy handle */ curl_socket_t s, /* socket */ int what, /* see above */ void *userp, /* private callback @@ -566,7 +566,7 @@ static int events_socket(CURL *easy, /* easy handle */ * * Do the multi handle setups that only event-based transfers need. */ -static void events_setup(CURLM *multi, struct events *ev) +static void events_setup(struct Curl_multi *multi, struct events *ev) { /* timer callback */ curl_multi_setopt(multi, CURLMOPT_TIMERFUNCTION, events_timer); @@ -670,7 +670,7 @@ static CURLcode wait_or_timeout(struct Curl_multi *multi, struct events *ev) * * Runs a transfer in a blocking manner using the events-based API */ -static CURLcode easy_events(CURLM *multi) +static CURLcode easy_events(struct Curl_multi *multi) { struct events evs= {2, FALSE, 0, NULL, 0}; @@ -684,7 +684,7 @@ static CURLcode easy_events(CURLM *multi) #define easy_events(x) CURLE_NOT_BUILT_IN #endif -static CURLcode easy_transfer(CURLM *multi) +static CURLcode easy_transfer(struct Curl_multi *multi) { bool done = FALSE; CURLMcode mcode = CURLM_OK; @@ -766,7 +766,7 @@ static CURLcode easy_transfer(CURLM *multi) */ static CURLcode easy_perform(struct Curl_easy *data, bool events) { - CURLM *multi; + struct Curl_multi *multi; CURLMcode mcode; CURLcode result = CURLE_OK; SIGPIPE_VARIABLE(pipe_st); @@ -826,7 +826,7 @@ static CURLcode easy_perform(struct Curl_easy *data, bool events) * curl_easy_perform() is the external interface that performs a blocking * transfer as previously setup. */ -CURLcode curl_easy_perform(CURL *data) +CURLcode curl_easy_perform(struct Curl_easy *data) { return easy_perform(data, FALSE); } @@ -836,7 +836,7 @@ CURLcode curl_easy_perform(CURL *data) * curl_easy_perform_ev() is the external interface that performs a blocking * transfer using the event-based API internally. */ -CURLcode curl_easy_perform_ev(CURL *data) +CURLcode curl_easy_perform_ev(struct Curl_easy *data) { return easy_perform(data, TRUE); } @@ -847,7 +847,7 @@ CURLcode curl_easy_perform_ev(CURL *data) * curl_easy_cleanup() is the external interface to cleaning/freeing the given * easy handle. */ -void curl_easy_cleanup(CURL *data) +void curl_easy_cleanup(struct Curl_easy *data) { SIGPIPE_VARIABLE(pipe_st); @@ -864,7 +864,7 @@ void curl_easy_cleanup(CURL *data) * information from a performed transfer and similar. */ #undef curl_easy_getinfo -CURLcode curl_easy_getinfo(CURL *data, CURLINFO info, ...) +CURLcode curl_easy_getinfo(struct Curl_easy *data, CURLINFO info, ...) { va_list arg; void *paramp; @@ -884,7 +884,7 @@ CURLcode curl_easy_getinfo(CURL *data, CURLINFO info, ...) * given input easy handle. The returned handle will be a new working handle * with all options set exactly as the input source handle. */ -CURL *curl_easy_duphandle(CURL *data) +struct Curl_easy *curl_easy_duphandle(struct Curl_easy *data) { struct Curl_easy *outcurl = calloc(1, sizeof(struct Curl_easy)); if(NULL == outcurl) @@ -977,7 +977,7 @@ CURL *curl_easy_duphandle(CURL *data) * curl_easy_reset() is an external interface that allows an app to re- * initialize a session handle to the default values. */ -void curl_easy_reset(CURL *data) +void curl_easy_reset(struct Curl_easy *data) { Curl_safefree(data->state.pathbuffer); @@ -1007,7 +1007,7 @@ void curl_easy_reset(CURL *data) * * Action is a bitmask consisting of CURLPAUSE_* bits in curl/curl.h */ -CURLcode curl_easy_pause(CURL *data, int action) +CURLcode curl_easy_pause(struct Curl_easy *data, int action) { struct SingleRequest *k = &data->req; CURLcode result = CURLE_OK; @@ -1076,7 +1076,8 @@ static CURLcode easy_connection(struct Curl_easy *data, * curl_easy_perform() with CURLOPT_CONNECT_ONLY option. * Returns CURLE_OK on success, error code on error. */ -CURLcode curl_easy_recv(CURL *data, void *buffer, size_t buflen, size_t *n) +CURLcode curl_easy_recv(struct Curl_easy *data, void *buffer, size_t buflen, + size_t *n) { curl_socket_t sfd; CURLcode result; @@ -1102,8 +1103,8 @@ CURLcode curl_easy_recv(CURL *data, void *buffer, size_t buflen, size_t *n) * Sends data over the connected socket. Use after successful * curl_easy_perform() with CURLOPT_CONNECT_ONLY option. */ -CURLcode curl_easy_send(CURL *data, const void *buffer, size_t buflen, - size_t *n) +CURLcode curl_easy_send(struct Curl_easy *data, const void *buffer, + size_t buflen, size_t *n) { curl_socket_t sfd; CURLcode result; diff --git a/lib/easyif.h b/lib/easyif.h index 65333494c..f6132cc70 100644 --- a/lib/easyif.h +++ b/lib/easyif.h @@ -7,7 +7,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2013, Daniel Stenberg, <daniel@haxx.se>, et al. + * Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -26,7 +26,7 @@ * Prototypes for library-wide functions provided by easy.c */ #ifdef CURLDEBUG -CURL_EXTERN CURLcode curl_easy_perform_ev(CURL *easy); +CURL_EXTERN CURLcode curl_easy_perform_ev(struct Curl_easy *easy); #endif #endif /* HEADER_CURL_EASYIF_H */ diff --git a/lib/escape.c b/lib/escape.c index be752b416..04230b4ca 100644 --- a/lib/escape.c +++ b/lib/escape.c @@ -75,7 +75,8 @@ char *curl_unescape(const char *string, int length) return curl_easy_unescape(NULL, string, length, NULL); } -char *curl_easy_escape(CURL *handle, const char *string, int inlength) +char *curl_easy_escape(struct Curl_easy *data, const char *string, + int inlength) { size_t alloc = (inlength?(size_t)inlength:strlen(string))+1; char *ns; @@ -112,7 +113,7 @@ char *curl_easy_escape(CURL *handle, const char *string, int inlength) } } - result = Curl_convert_to_network(handle, &in, 1); + result = Curl_convert_to_network(data, &in, 1); if(result) { /* Curl_convert_to_network calls failf if unsuccessful */ free(ns); @@ -206,13 +207,13 @@ CURLcode Curl_urldecode(struct Curl_easy *data, * If length == 0, the length is assumed to be strlen(string). * If olen == NULL, no output length is stored. */ -char *curl_easy_unescape(CURL *handle, const char *string, int length, - int *olen) +char *curl_easy_unescape(struct Curl_easy *data, const char *string, + int length, int *olen) { char *str = NULL; size_t inputlen = length; size_t outputlen; - CURLcode res = Curl_urldecode(handle, string, inputlen, &str, &outputlen, + CURLcode res = Curl_urldecode(data, string, inputlen, &str, &outputlen, FALSE); if(res) return NULL; diff --git a/lib/http2.c b/lib/http2.c index d7fae0401..efc082dd5 100644 --- a/lib/http2.c +++ b/lib/http2.c @@ -335,7 +335,7 @@ char *curl_pushheader_byname(struct curl_pushheaders *h, const char *header) return NULL; } -static CURL *duphandle(struct Curl_easy *data) +static struct Curl_easy *duphandle(struct Curl_easy *data) { struct Curl_easy *second = curl_easy_duphandle(data); if(second) { diff --git a/lib/multi.c b/lib/multi.c index a0dfac71a..9ee352353 100644 --- a/lib/multi.c +++ b/lib/multi.c @@ -61,7 +61,7 @@ #define CURL_MULTI_HANDLE 0x000bab1e #define GOOD_MULTI_HANDLE(x) \ - ((x) && (((struct Curl_multi *)(x))->type == CURL_MULTI_HANDLE)) + ((x) && (x)->type == CURL_MULTI_HANDLE) static void singlesocket(struct Curl_multi *multi, struct Curl_easy *data); @@ -334,7 +334,7 @@ struct Curl_multi *Curl_multi_handle(int hashsize, /* socket hash */ /* -1 means it not set by user, use the default value */ multi->maxconnects = -1; - return (CURLM *) multi; + return multi; error: @@ -350,13 +350,14 @@ struct Curl_multi *Curl_multi_handle(int hashsize, /* socket hash */ return NULL; } -CURLM *curl_multi_init(void) +struct Curl_multi *curl_multi_init(void) { return Curl_multi_handle(CURL_SOCKET_HASH_TABLE_SIZE, CURL_CONNECTION_HASH_SIZE); } -CURLMcode curl_multi_add_handle(CURLM *multi, CURL *data) +CURLMcode curl_multi_add_handle(struct Curl_multi *multi, + struct Curl_easy *data) { struct curl_llist *timeoutlist; @@ -642,7 +643,8 @@ static CURLcode multi_done(struct connectdata **connp, return result; } -CURLMcode curl_multi_remove_handle(CURLM *multi, CURL *data) +CURLMcode curl_multi_remove_handle(struct Curl_multi *multi, + struct Curl_easy *data) { struct Curl_easy *easy = data; bool premature; @@ -904,7 +906,7 @@ static int multi_getsock(struct Curl_easy *data, } -CURLMcode curl_multi_fdset(CURLM *multi, +CURLMcode curl_multi_fdset(struct Curl_multi *multi, fd_set *read_fd_set, fd_set *write_fd_set, fd_set *exc_fd_set, int *max_fd) { @@ -953,7 +955,7 @@ CURLMcode curl_multi_fdset(CURLM *multi, return CURLM_OK; } -CURLMcode curl_multi_wait(CURLM *multi, +CURLMcode curl_multi_wait(struct Curl_multi *multi, struct curl_waitfd extra_fds[], unsigned int extra_nfds, int timeout_ms, @@ -2094,7 +2096,7 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi, } -CURLMcode curl_multi_perform(CURLM *multi, int *running_handles) +CURLMcode curl_multi_perform(struct Curl_multi *multi, int *running_handles) { struct Curl_easy *data; CURLMcode returncode=CURLM_OK; @@ -2163,7 +2165,7 @@ static void close_all_connections(struct Curl_multi *multi) } } -CURLMcode curl_multi_cleanup(CURLM *multi) +CURLMcode curl_multi_cleanup(struct Curl_multi *multi) { struct Curl_easy *data; struct Curl_easy *nextdata; @@ -2237,7 +2239,7 @@ CURLMcode curl_multi_cleanup(CURLM *multi) * beyond. The current design is fully O(1). */ -CURLMsg *curl_multi_info_read(CURLM *multi, int *msgs_in_queue) +CURLMsg *curl_multi_info_read(struct Curl_multi *multi, int *msgs_in_queue) { struct Curl_message *msg; @@ -2628,7 +2630,7 @@ static CURLMcode multi_socket(struct Curl_multi *multi, } #undef curl_multi_setopt -CURLMcode curl_multi_setopt(CURLM *multi, +CURLMcode curl_multi_setopt(struct Curl_multi *multi, CURLMoption option, ...) { CURLMcode res = CURLM_OK; @@ -2698,7 +2700,7 @@ CURLMcode curl_multi_setopt(CURLM *multi, /* we define curl_multi_socket() in the public multi.h header */ #undef curl_multi_socket -CURLMcode curl_multi_socket(CURLM *multi, curl_socket_t s, +CURLMcode curl_multi_socket(struct Curl_multi *multi, curl_socket_t s, int *running_handles) { CURLMcode result = multi_socket(multi, FALSE, s, 0, running_handles); @@ -2707,7 +2709,7 @@ CURLMcode curl_multi_socket(CURLM *multi, curl_socket_t s, return result; } -CURLMcode curl_multi_socket_action(CURLM *multi, curl_socket_t s, +CURLMcode curl_multi_socket_action(struct Curl_multi *multi, curl_socket_t s, int ev_bitmask, int *running_handles) { CURLMcode result = multi_socket(multi, FALSE, s, @@ -2717,7 +2719,7 @@ CURLMcode curl_multi_socket_action(CURLM *multi, curl_socket_t s, return result; } -CURLMcode curl_multi_socket_all(CURLM *multi, int *running_handles) +CURLMcode curl_multi_socket_all(struct Curl_multi *multi, int *running_handles) { CURLMcode result = multi_socket(multi, TRUE, CURL_SOCKET_BAD, 0, @@ -2762,7 +2764,7 @@ static CURLMcode multi_timeout(struct Curl_multi *multi, return CURLM_OK; } -CURLMcode curl_multi_timeout(CURLM *multi, +CURLMcode curl_multi_timeout(struct Curl_multi *multi, long *timeout_ms) { /* First, make some basic checks that the CURLM handle is a good handle */ @@ -3000,7 +3002,8 @@ void Curl_expire_latest(struct Curl_easy *data, long milli) Curl_expire(data, milli); } -CURLMcode curl_multi_assign(CURLM *multi, curl_socket_t s, void *hashp) +CURLMcode curl_multi_assign(struct Curl_multi *multi, curl_socket_t s, + void *hashp) { struct Curl_sh_entry *there = NULL; diff --git a/lib/share.c b/lib/share.c index f12feefcd..5b3957fcf 100644 --- a/lib/share.c +++ b/lib/share.c @@ -31,7 +31,7 @@ /* The last #include file should be: */ #include "memdebug.h" -CURLSH * +struct Curl_share * curl_share_init(void) { struct Curl_share *share = calloc(1, sizeof(struct Curl_share)); @@ -49,9 +49,8 @@ curl_share_init(void) #undef curl_share_setopt CURLSHcode -curl_share_setopt(CURLSH *sh, CURLSHoption option, ...) +curl_share_setopt(struct Curl_share *share, CURLSHoption option, ...) { - struct Curl_share *share = (struct Curl_share *)sh; va_list param; int type; curl_lock_function lockfunc; @@ -172,10 +171,8 @@ curl_share_setopt(CURLSH *sh, CURLSHoption option, ...) } CURLSHcode -curl_share_cleanup(CURLSH *sh) +curl_share_cleanup(struct Curl_share *share) { - struct Curl_share *share = (struct Curl_share *)sh; - if(share == NULL) return CURLSHE_INVALID; @@ -473,7 +473,7 @@ static CURLcode ssh_getworkingpath(struct connectdata *conn, } #ifdef HAVE_LIBSSH2_KNOWNHOST_API -static int sshkeycallback(CURL *easy, +static int sshkeycallback(struct Curl_easy *easy, const struct curl_khkey *knownkey, /* known */ const struct curl_khkey *foundkey, /* found */ enum curl_khmatch match, |