From c70c6fe970d182bca6725f4fe904f9b451d7e66e Mon Sep 17 00:00:00 2001 From: jkjo92 Date: Thu, 21 Sep 2017 15:42:29 +0900 Subject: [PATCH] fix coding rule Change-Id: I341dd1005b4ea0ae434ea0f28b8f71cba29da152 Signed-off-by: jkjo92 --- src/oauth.h | 118 ++++++++++++++++++++++++++++------------------------------ src/xmalloc.h | 8 ++-- 2 files changed, 61 insertions(+), 65 deletions(-) diff --git a/src/oauth.h b/src/oauth.h index bb6dc3c..691f1c8 100755 --- a/src/oauth.h +++ b/src/oauth.h @@ -25,7 +25,7 @@ * */ #ifndef _OAUTH_H -#define _OAUTH_H 1 +#define _OAUTH_H 1 #ifndef DOXYGEN_IGNORE // liboauth version @@ -41,13 +41,13 @@ #define LIBOAUTH_AGE 8 #ifdef __GNUC__ -# define OA_GCC_VERSION_AT_LEAST(x,y) (__GNUC__ > x || __GNUC__ == x && __GNUC_MINOR__ >= y) +# define OA_GCC_VERSION_AT_LEAST(x, y) (__GNUC__ > x || __GNUC__ == x && __GNUC_MINOR__ >= y) #else -# define OA_GCC_VERSION_AT_LEAST(x,y) 0 +# define OA_GCC_VERSION_AT_LEAST(x, y) 0 #endif #ifndef attribute_deprecated -#if OA_GCC_VERSION_AT_LEAST(3,1) +#if OA_GCC_VERSION_AT_LEAST(3, 1) # define attribute_deprecated __attribute__((deprecated)) #else # define attribute_deprecated @@ -63,9 +63,9 @@ extern "C" { /** \enum OAuthMethod * signature method to used for signing the request. */ -typedef enum { - OA_HMAC=0, ///< use HMAC-SHA1 request signing method - OA_RSA, ///< use RSA signature +typedef enum { + OA_HMAC = 0, ///< use HMAC-SHA1 request signing method + OA_RSA, ///< use RSA signature OA_PLAINTEXT ///< use plain text signature (for testing only) } OAuthMethod; @@ -110,7 +110,6 @@ char *oauth_url_escape(const char *string); * The caller must free the returned string. */ char *oauth_url_unescape(const char *string, size_t *olen); - /** * returns base64 encoded HMAC-SHA1 signature for @@ -123,7 +122,7 @@ char *oauth_url_unescape(const char *string, size_t *olen); * @param k key used for signing * @return signature string. */ -char *oauth_sign_hmac_sha1 (const char *m, const char *k); +char *oauth_sign_hmac_sha1(const char *m, const char *k); /** * same as \ref oauth_sign_hmac_sha1 but allows one @@ -135,7 +134,7 @@ char *oauth_sign_hmac_sha1 (const char *m, const char *k); * @param kl length of key * @return signature string. */ -char *oauth_sign_hmac_sha1_raw (const char *m, const size_t ml, const char *k, const size_t kl); +char *oauth_sign_hmac_sha1_raw(const char *m, const size_t ml, const char *k, const size_t kl); /** * returns plaintext signature for the given key. @@ -146,7 +145,7 @@ char *oauth_sign_hmac_sha1_raw (const char *m, const size_t ml, const char *k, c * @param k key used for signing * @return signature string */ -char *oauth_sign_plaintext (const char *m, const char *k); +char *oauth_sign_plaintext(const char *m, const char *k); /** * returns RSA-SHA1 signature for given data. @@ -156,7 +155,7 @@ char *oauth_sign_plaintext (const char *m, const char *k); * @param k private-key PKCS and Base64-encoded * @return base64 encoded signature string. */ -char *oauth_sign_rsa_sha1 (const char *m, const char *k); +char *oauth_sign_rsa_sha1(const char *m, const char *k); /** * verify RSA-SHA1 signature. @@ -169,7 +168,7 @@ char *oauth_sign_rsa_sha1 (const char *m, const char *k); * @param s base64 encoded signature * @return 1 for a correct signature, 0 for failure and -1 if some other error occurred */ -int oauth_verify_rsa_sha1 (const char *m, const char *c, const char *s); +int oauth_verify_rsa_sha1(const char *m, const char *c, const char *s); /** * url-escape strings and concatenate with '&' separator. @@ -225,7 +224,7 @@ int oauth_split_post_paramters(const char *url, char ***argv, short qesc); * @return url string needs to be freed by the caller. * */ -char *oauth_serialize_url (int argc, int start, char **argv); +char *oauth_serialize_url(int argc, int start, char **argv); /** * encode query parameters from an array. @@ -240,7 +239,7 @@ char *oauth_serialize_url (int argc, int start, char **argv); * 4: double quotation marks are added around values (use with sep ", " for HTTP Authorization header). * @return url string needs to be freed by the caller. */ -char *oauth_serialize_url_sep (int argc, int start, char **argv, char *sep, int mod); +char *oauth_serialize_url_sep(int argc, int start, char **argv, char *sep, int mod); /** * build a query parameter string from an array. @@ -253,7 +252,7 @@ char *oauth_serialize_url_sep (int argc, int start, char **argv, char *sep, int * @param argv parameter-array to concatenate. * @return url string needs to be freed by the caller. */ -char *oauth_serialize_url_parameters (int argc, char **argv); +char *oauth_serialize_url_parameters(int argc, char **argv); /** * generate a random string between 15 and 32 chars length @@ -368,25 +367,24 @@ int oauth_time_indepenent_equals(const char* a, const char* b) attribute_depreca * @return the signed url or NULL if an error occurred. * */ -char *oauth_sign_url2 (const char *url, char **postargs, - OAuthMethod method, +char *oauth_sign_url2(const char *url, char **postargs, + OAuthMethod method, const char *http_method, //< HTTP request method const char *c_key, //< consumer key - posted plain text - const char *c_secret, //< consumer secret - used as 1st part of secret-key + const char *c_secret, //< consumer secret - used as 1st part of secret-key const char *t_key, //< token key - posted plain text in URL - const char *t_secret //< token secret - used as 2st part of secret-key - ); + const char *t_secret); //< token secret - used as 2st part of secret-key /** * @deprecated Use oauth_sign_url2() instead. */ -char *oauth_sign_url (const char *url, char **postargs, - OAuthMethod method, +char *oauth_sign_url(const char *url, char **postargs, + OAuthMethod method, const char *c_key, //< consumer key - posted plain text - const char *c_secret, //< consumer secret - used as 1st part of secret-key + const char *c_secret, //< consumer secret - used as 1st part of secret-key const char *t_key, //< token key - posted plain text in URL - const char *t_secret //< token secret - used as 2st part of secret-key - ) attribute_deprecated; + const char *t_secret) //< token secret - used as 2st part of secret-key + attribute_deprecated; /** @@ -426,15 +424,14 @@ char *oauth_sign_url (const char *url, char **postargs, * @return void * */ -void oauth_sign_array2_process (int *argcp, char***argvp, +void oauth_sign_array2_process(int *argcp, char***argvp, char **postargs, - OAuthMethod method, + OAuthMethod method, const char *http_method, //< HTTP request method const char *c_key, //< consumer key - posted plain text - const char *c_secret, //< consumer secret - used as 1st part of secret-key + const char *c_secret, //< consumer secret - used as 1st part of secret-key const char *t_key, //< token key - posted plain text in URL - const char *t_secret //< token secret - used as 2st part of secret-key - ); + const char *t_secret); //< token secret - used as 2st part of secret-key /** * same as /ref oauth_sign_url @@ -464,27 +461,27 @@ void oauth_sign_array2_process (int *argcp, char***argvp, * * @return the signed url or NULL if an error occurred. */ -char *oauth_sign_array2 (int *argcp, char***argvp, +char *oauth_sign_array2(int *argcp, char***argvp, char **postargs, - OAuthMethod method, + OAuthMethod method, const char *http_method, //< HTTP request method const char *c_key, //< consumer key - posted plain text - const char *c_secret, //< consumer secret - used as 1st part of secret-key + const char *c_secret, //< consumer secret - used as 1st part of secret-key const char *t_key, //< token key - posted plain text in URL - const char *t_secret //< token secret - used as 2st part of secret-key - ); + const char *t_secret); //< token secret - used as 2st part of secret-key + /** * @deprecated Use oauth_sign_array2() instead. */ -char *oauth_sign_array (int *argcp, char***argvp, +char *oauth_sign_array(int *argcp, char***argvp, char **postargs, - OAuthMethod method, + OAuthMethod method, const char *c_key, //< consumer key - posted plain text - const char *c_secret, //< consumer secret - used as 1st part of secret-key + const char *c_secret, //< consumer secret - used as 1st part of secret-key const char *t_key, //< token key - posted plain text in URL - const char *t_secret //< token secret - used as 2st part of secret-key - ) attribute_deprecated; + const char *t_secret) //< token secret - used as 2st part of secret-key + attribute_deprecated; /** @@ -534,11 +531,10 @@ char *oauth_body_hash_encode(size_t len, unsigned char *digest); /** * xep-0235 - TODO */ -char *oauth_sign_xmpp (const char *xml, - OAuthMethod method, - const char *c_secret, //< consumer secret - used as 1st part of secret-key - const char *t_secret //< token secret - used as 2st part of secret-key - ); +char *oauth_sign_xmpp(const char *xml, + OAuthMethod method, + const char *c_secret, //< consumer secret - used as 1st part of secret-key + const char *t_secret); //< token secret - used as 2st part of secret-key /** * do a HTTP GET request, wait for it to finish @@ -569,7 +565,7 @@ char *oauth_sign_xmpp (const char *xml, * * @deprecated use libcurl - http://curl.haxx.se/libcurl/c/ */ -char *oauth_http_get (const char *u, const char *q) attribute_deprecated; +char *oauth_http_get(const char *u, const char *q) attribute_deprecated; /** * do a HTTP GET request, wait for it to finish @@ -592,7 +588,7 @@ char *oauth_http_get (const char *u, const char *q) attribute_deprecated; * * @deprecated use libcurl - http://curl.haxx.se/libcurl/c/ */ -char *oauth_http_get2 (const char *u, const char *q, const char *customheader) attribute_deprecated; +char *oauth_http_get2(const char *u, const char *q, const char *customheader) attribute_deprecated; /** @@ -626,7 +622,7 @@ char *oauth_http_get2 (const char *u, const char *q, const char *customheader) a * * @deprecated use libcurl - http://curl.haxx.se/libcurl/c/ */ -char *oauth_http_post (const char *u, const char *p) attribute_deprecated; +char *oauth_http_post(const char *u, const char *p) attribute_deprecated; /** * do a HTTP POST request, wait for it to finish @@ -648,7 +644,7 @@ char *oauth_http_post (const char *u, const char *p) attribute_deprecated; * * @deprecated use libcurl - http://curl.haxx.se/libcurl/c/ */ -char *oauth_http_post2 (const char *u, const char *p, const char *customheader) attribute_deprecated; +char *oauth_http_post2(const char *u, const char *p, const char *customheader) attribute_deprecated; /** @@ -667,7 +663,7 @@ char *oauth_http_post2 (const char *u, const char *p, const char *customheader) * * @deprecated use libcurl - http://curl.haxx.se/libcurl/c/ */ -char *oauth_post_file (const char *u, const char *fn, const size_t len, const char *customheader) attribute_deprecated; +char *oauth_post_file(const char *u, const char *fn, const size_t len, const char *customheader) attribute_deprecated; /** * http post raw data @@ -685,7 +681,7 @@ char *oauth_post_file (const char *u, const char *fn, const size_t len, const ch * * @deprecated use libcurl - http://curl.haxx.se/libcurl/c/ */ -char *oauth_post_data (const char *u, const char *data, size_t len, const char *customheader) attribute_deprecated; +char *oauth_post_data(const char *u, const char *data, size_t len, const char *customheader) attribute_deprecated; /** * http post raw data, with callback. @@ -710,11 +706,11 @@ char *oauth_post_data (const char *u, const char *data, size_t len, const char * * * @deprecated use libcurl - http://curl.haxx.se/libcurl/c/ */ -char *oauth_post_data_with_callback (const char *u, - const char *data, - size_t len, +char *oauth_post_data_with_callback(const char *u, + const char *data, + size_t len, const char *customheader, - void (*callback)(void*,int,size_t,size_t), + void (*callback)(void*, int, size_t, size_t), void *callback_data) attribute_deprecated; /** @@ -736,7 +732,7 @@ char *oauth_post_data_with_callback (const char *u, * * @deprecated use libcurl - http://curl.haxx.se/libcurl/c/ */ -char *oauth_send_data (const char *u, +char *oauth_send_data(const char *u, const char *data, size_t len, const char *customheader, @@ -766,11 +762,11 @@ char *oauth_send_data (const char *u, * * @deprecated use libcurl - http://curl.haxx.se/libcurl/c/ */ -char *oauth_send_data_with_callback (const char *u, - const char *data, - size_t len, +char *oauth_send_data_with_callback(const char *u, + const char *data, + size_t len, const char *customheader, - void (*callback)(void*,int,size_t,size_t), + void (*callback)(void*, int, size_t,size_t), void *callback_data, const char *httpMethod) attribute_deprecated; diff --git a/src/xmalloc.h b/src/xmalloc.h index 6471371..9b9bf77 100755 --- a/src/xmalloc.h +++ b/src/xmalloc.h @@ -2,10 +2,10 @@ #define _OAUTH_XMALLOC_H 1 /* Prototypes for functions defined in xmalloc.c */ -void *xmalloc (size_t size); -void *xcalloc (size_t nmemb, size_t size); -void *xrealloc (void *ptr, size_t size); -char *xstrdup (const char *s); +void *xmalloc(size_t size); +void *xcalloc(size_t nmemb, size_t size); +void *xrealloc(void *ptr, size_t size); +char *xstrdup(const char *s); void xfree(void *ptr); #endif -- 2.7.4