#ifndef _OAUTH_H
00028 #define _OAUTH_H 1
00029
00030 #ifndef DOXYGEN_IGNORE
00031 // liboauth version
00032 #define LIBOAUTH_VERSION "0.8.9"
00033 #define LIBOAUTH_VERSION_00001
00027 #ifndef _OAUTH_H
00028 #define _OAUTH_H 1
00029
00030 #ifndef DOXYGEN_IGNORE
00031 // liboauth version
00032 #define LIBOAUTH_VERSION "0.8.9"
00033 #define LIBOAUTH_VERSION_MAJOR 0
00034 #define LIBOAUTH_VERSION_MINOR 8
00035 #define LIBOAUTH_VERSION_MICRO 9
00036
00037 //interface revision number
00038 //http://www.gnu.org/software/libtool/manual/html_node/Updating-version-info.html
00039 #define LIBOAUTH_CUR 7
00040 #define LIBOAUTH_REV 0
00041 #define LIBOAUTH_AGE 7
00042 #endif
00043
00044 #ifdef __GNUC__
00045 # define OA_GCC_VERSION_AT_LEAST(x,y) (__GNUC__ > x || __GNUC__ == x && __GNUC_MINOR__ >= y)
00046 #else
00047 # define OA_GCC_VERSION_AT_LEAST(x,y) 0
00048 #endif
00049
00050 #ifndef attribute_deprecated
00051 #if OA_GCC_VERSION_AT_LEAST(3,1)
00052 # define attribute_deprecated __attribute__((deprecated))
00053 #else
00054 # define attribute_deprecated
00055 #endif
00056 #endif
00057
00061 typedef enum {
00062 OA_HMAC=0,
00063 OA_RSA,
00064 OA_PLAINTEXT
00065 } OAuthMethod;
00066
00075 char *oauth_encode_base64(int size, const unsigned char *src);
00076
00087 int oauth_decode_base64(unsigned char *dest, const char *src);
00088
00097 char *oauth_url_escape(const char *string);
00098
00107 char *oauth_url_unescape(const char *string, size_t *olen);
00108
00109
00121 char *oauth_sign_hmac_sha1 (const char *m, const char *k);
00122
00133 char *oauth_sign_hmac_sha1_raw (const char *m, const size_t ml, const char *k, const size_t kl);
00134
00144 char *oauth_sign_plaintext (const char *m, const char *k);
00145
00154 char *oauth_sign_rsa_sha1 (const char *m, const char *k);
00155
00167 int oauth_verify_rsa_sha1 (const char *m, const char *c, const char *s);
00168
00181 char *oauth_catenc(int len, ...);
00182
00196 int oauth_split_url_parameters(const char *url, char ***argv);
00197
00212 int oauth_split_post_paramters(const char *url, char ***argv, short qesc);
00213
00223 char *oauth_serialize_url (int argc, int start, char **argv);
00224
00238 char *oauth_serialize_url_sep (int argc, int start, char **argv, char *sep, int mod);
00239
00251 char *oauth_serialize_url_parameters (int argc, char **argv);
00252
00260 char *oauth_gen_nonce();
00261
00268 int oauth_cmpstringp(const void *p1, const void *p2);
00269
00270
00279 int oauth_param_exists(char **argv, int argc, char *key);
00280
00288 void oauth_add_param_to_array(int *argcp, char ***argvp, const char *addparam);
00289
00296 void oauth_free_array(int *argcp, char ***argvp);
00297
00310 int oauth_time_indepenent_equals_n(const char* a, const char* b, size_t len_a, size_t len_b);
00311
00322 int oauth_time_indepenent_equals(const char* a, const char* b);
00323
00356 char *oauth_sign_url2 (const char *url, char **postargs,
00357 OAuthMethod method,
00358 const char *http_method, //< HTTP request method
00359 const char *c_key, //< consumer key - posted plain text
00360 const char *c_secret, //< consumer secret - used as 1st part of secret-key
00361 const char *t_key, //< token key - posted plain text in URL
00362 const char *t_secret //< token secret - used as 2st part of secret-key
00363 );
00364
00368 char *oauth_sign_url (const char *url, char **postargs,
00369 OAuthMethod method,
00370 const char *c_key, //< consumer key - posted plain text
00371 const char *c_secret, //< consumer secret - used as 1st part of secret-key
00372 const char *t_key, //< token key - posted plain text in URL
00373 const char *t_secret //< token secret - used as 2st part of secret-key
00374 ) attribute_deprecated;
00375
00376
00414 void oauth_sign_array2_process (int *argcp, char***argvp,
00415 char **postargs,
00416 OAuthMethod method,
00417 const char *http_method, //< HTTP request method
00418 const char *c_key, //< consumer key - posted plain text
00419 const char *c_secret, //< consumer secret - used as 1st part of secret-key
00420 const char *t_key, //< token key - posted plain text in URL
00421 const char *t_secret //< token secret - used as 2st part of secret-key
00422 );
00423
00452 char *oauth_sign_array2 (int *argcp, char***argvp,
00453 char **postargs,
00454 OAuthMethod method,
00455 const char *http_method, //< HTTP request method
00456 const char *c_key, //< consumer key - posted plain text
00457 const char *c_secret, //< consumer secret - used as 1st part of secret-key
00458 const char *t_key, //< token key - posted plain text in URL
00459 const char *t_secret //< token secret - used as 2st part of secret-key
00460 );
00461
00465 char *oauth_sign_array (int *argcp, char***argvp,
00466 char **postargs,
00467 OAuthMethod method,
00468 const char *c_key, //< consumer key - posted plain text
00469 const char *c_secret, //< consumer secret - used as 1st part of secret-key
00470 const char *t_key, //< token key - posted plain text in URL
00471 const char *t_secret //< token secret - used as 2st part of secret-key
00472 ) attribute_deprecated;
00473
00474
00487 char *oauth_body_hash_file(char *filename);
00488
00504 char *oauth_body_hash_data(size_t length, const char *data);
00505
00517 char *oauth_body_hash_encode(size_t len, unsigned char *digest);
00518
00522 char *oauth_sign_xmpp (const char *xml,
00523 OAuthMethod method,
00524 const char *c_secret, //< consumer secret - used as 1st part of secret-key
00525 const char *t_secret //< token secret - used as 2st part of secret-key
00526 );
00527
00555 char *oauth_http_get (const char *u, const char *q);
00556
00577 char *oauth_http_get2 (const char *u, const char *q, const char *customheader);
00578
00579
00609 char *oauth_http_post (const char *u, const char *p);
00610
00629 char *oauth_http_post2 (const char *u, const char *p, const char *customheader);
00630
00631
00646 char *oauth_post_file (const char *u, const char *fn, size_t len, const char *customheader);
00647
00662 char *oauth_post_data (const char *u, const char *data, size_t len, const char *customheader);
00663
00685 char *oauth_post_data_with_callback (const char *u,
00686 const char *data,
00687 size_t len,
00688 const char *customheader,
00689 void (*callback)(void*,int,size_t,size_t),
00690 void *callback_data);
00691
00709 char *oauth_send_data (const char *u,
00710 const char *data,
00711 size_t len,
00712 const char *customheader,
00713 const char *httpMethod);
00714
00737 char *oauth_send_data_with_callback (const char *u,
00738 const char *data,
00739 size_t len,
00740 const char *customheader,
00741 void (*callback)(void*,int,size_t,size_t),
00742 void *callback_data,
00743 const char *httpMethod);
00744
00745 #endif
00746 /* vi:set ts=8 sts=2 sw=2: */
0
00034 #define LIBOAUTH_VERSION_MINOR 8
00035 #define LIBOAUTH_VERSION_MICRO 9
00036
00037 //interface revision number
00038 //http://www.gnu.org/software/libtool/manual/html_node/Updating-version-info.html
00039 #define LIBOAUTH_CUR 7
00040 #define LIBOAUTH_REV 0
00041 #define LIBOAUTH_AGE 7
00042 #endif
00043
00044 #ifdef __GNUC__
00045 # define OA_GCC_VERSION_AT_LEAST(x,y) (__GNUC__ > x || __GNUC__ == x && __GNUC_MINOR__ >= y)
00046 #else
00047 # define OA_GCC_VERSION_AT_LEAST(x,y) 0
00048 #endif
00049
00050 #ifndef attribute_deprecated
00051 #if OA_GCC_VERSION_AT_LEAST(3,1)
00052 # define attribute_deprecated __attribute__((deprecated))
00053 #else
00054 # define attribute_deprecated
00055 #endif
00056 #endif
00057
00061 typedef enum {
00062 OA_HMAC=0,
00063 OA_RSA,
00064 OA_PLAINTEXT
00065 } OAuthMethod;
00066
00075 char *oauth_encode_base64(int size, const unsigned char *src);
00076
00087 int oauth_decode_base64(unsigned char *dest, const char *src);
00088
00097 char *oauth_url_escape(const char *string);
00098
00107 char *oauth_url_unescape(const char *string, size_t *olen);
00108
00109
00121 char *oauth_sign_hmac_sha1 (const char *m, const char *k);
00122
00133 char *oauth_sign_hmac_sha1_raw (const char *m, const size_t ml, const char *k, const size_t kl);
00134
00144 char *oauth_sign_plaintext (const char *m, const char *k);
00145
00154 char *oauth_sign_rsa_sha1 (const char *m, const char *k);
00155
00167 int oauth_verify_rsa_sha1 (const char *m, const char *c, const char *s);
00168
00181 char *oauth_catenc(int len, ...);
00182
00196 int oauth_split_url_parameters(const char *url, char ***argv);
00197
00212 int oauth_split_post_paramters(const char *url, char ***argv, short qesc);
00213
00223 char *oauth_serialize_url (int argc, int start, char **argv);
00224
00238 char *oauth_serialize_url_sep (int argc, int start, char **argv, char *sep, int mod);
00239
00251 char *oauth_serialize_url_parameters (int argc, char **argv);
00252
00260 char *oauth_gen_nonce();
00261
00268 int oauth_cmpstringp(const void *p1, const void *p2);
00269
00270
00279 int oauth_param_exists(char **argv, int argc, char *key);
00280
00288 void oauth_add_param_to_array(int *argcp, char ***argvp, const char *addparam);
00289
00296 void oauth_free_array(int *argcp, char ***argvp);
00297
00310 int oauth_time_indepenent_equals_n(const char* a, const char* b, size_t len_a, size_t len_b);
00311
00322 int oauth_time_indepenent_equals(const char* a, const char* b);
00323
00356 char *oauth_sign_url2 (const char *url, char **postargs,
00357 OAuthMethod method,
00358 const char *http_method, //< HTTP request method
00359 const char *c_key, //< consumer key - posted plain text
00360 const char *c_secret, //< consumer secret - used as 1st part of secret-key
00361 const char *t_key, //< token key - posted plain text in URL
00362 const char *t_secret //< token secret - used as 2st part of secret-key
00363 );
00364
00368 char *oauth_sign_url (const char *url, char **postargs,
00369 OAuthMethod method,
00370 const char *c_key, //< consumer key - posted plain text
00371 const char *c_secret, //< consumer secret - used as 1st part of secret-key
00372 const char *t_key, //< token key - posted plain text in URL
00373 const char *t_secret //< token secret - used as 2st part of secret-key
00374 ) attribute_deprecated;
00375
00376
00414 void oauth_sign_array2_process (int *argcp, char***argvp,
00415 char **postargs,
00416 OAuthMethod method,
00417 const char *http_method, //< HTTP request method
00418 const char *c_key, //< consumer key - posted plain text
00419 const char *c_secret, //< consumer secret - used as 1st part of secret-key
00420 const char *t_key, //< token key - posted plain text in URL
00421 const char *t_secret //< token secret - used as 2st part of secret-key
00422 );
00423
00452 char *oauth_sign_array2 (int *argcp, char***argvp,
00453 char **postargs,
00454 OAuthMethod method,
00455 const char *http_method, //< HTTP request method
00456 const char *c_key, //< consumer key - posted plain text
00457 const char *c_secret, //< consumer secret - used as 1st part of secret-key
00458 const char *t_key, //< token key - posted plain text in URL
00459 const char *t_secret //< token secret - used as 2st part of secret-key
00460 );
00461
00465 char *oauth_sign_array (int *argcp, char***argvp,
00466 char **postargs,
00467 OAuthMethod method,
00468 const char *c_key, //< consumer key - posted plain text
00469 const char *c_secret, //< consumer secret - used as 1st part of secret-key
00470 const char *t_key, //< token key - posted plain text in URL
00471 const char *t_secret //< token secret - used as 2st part of secret-key
00472 ) attribute_deprecated;
00473
00474
00487 char *oauth_body_hash_file(char *filename);
00488
00504 char *oauth_body_hash_data(size_t length, const char *data);
00505
00517 char *oauth_body_hash_encode(size_t len, unsigned char *digest);
00518
00522 char *oauth_sign_xmpp (const char *xml,
00523 OAuthMethod method,
00524 const char *c_secret, //< consumer secret - used as 1st part of secret-key
00525 const char *t_secret //< token secret - used as 2st part of secret-key
00526 );
00527
00555 char *oauth_http_get (const char *u, const char *q);
00556
00577 char *oauth_http_get2 (const char *u, const char *q, const char *customheader);
00578
00579
00609 char *oauth_http_post (const char *u, const char *p);
00610
00629 char *oauth_http_post2 (const char *u, const char *p, const char *customheader);
00630
00631
00646 char *oauth_post_file (const char *u, const char *fn, size_t len, const char *customheader);
00647
00662 char *oauth_post_data (const char *u, const char *data, size_t len, const char *customheader);
00663
00685 char *oauth_post_data_with_callback (const char *u,
00686 const char *data,
00687 size_t len,
00688 const char *customheader,
00689 void (*callback)(void*,int,size_t,size_t),
00690 void *callback_data);
00691
00709 char *oauth_send_data (const char *u,
00710 const char *data,
00711 size_t len,
00712 const char *customheader,
00713 const char *httpMethod);
00714
00737 char *oauth_send_data_with_callback (const char *u,
00738 const char *data,
00739 size_t len,
00740 const char *customheader,
00741 void (*callback)(void*,int,size_t,size_t),
00742 void *callback_data,
00743 const char *httpMethod);
00744
00745 #endif
00746 /* vi:set ts=8 sts=2 sw=2: */
twitter_oauth.h
最新推荐文章于 2024-08-16 16:54:11 发布