fix coding rule
[platform/upstream/liboauth.git] / src / oauth.h
1 /**
2  *  @brief OAuth.net implementation in POSIX-C.
3  *  @file oauth.h
4  *  @author Robin Gareus <robin@gareus.org>
5  *
6  * Copyright 2007-2014 Robin Gareus <robin@gareus.org>
7  *
8  * Permission is hereby granted, free of charge, to any person obtaining a copy
9  * of this software and associated documentation files (the "Software"), to deal
10  * in the Software without restriction, including without limitation the rights
11  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12  * copies of the Software, and to permit persons to whom the Software is
13  * furnished to do so, subject to the following conditions:
14  * 
15  * The above copyright notice and this permission notice shall be included in
16  * all copies or substantial portions of the Software.
17  * 
18  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24  * THE SOFTWARE.
25  *
26  */
27 #ifndef _OAUTH_H
28 #define _OAUTH_H      1
29
30 #ifndef DOXYGEN_IGNORE
31 // liboauth version
32 #define LIBOAUTH_VERSION "1.0.3"
33 #define LIBOAUTH_VERSION_MAJOR  1
34 #define LIBOAUTH_VERSION_MINOR  0
35 #define LIBOAUTH_VERSION_MICRO  3
36
37 //interface revision number
38 //http://www.gnu.org/software/libtool/manual/html_node/Updating-version-info.html
39 #define LIBOAUTH_CUR  8
40 #define LIBOAUTH_REV  7
41 #define LIBOAUTH_AGE  8
42
43 #ifdef __GNUC__
44 #    define OA_GCC_VERSION_AT_LEAST(x, y) (__GNUC__ > x || __GNUC__ == x && __GNUC_MINOR__ >= y)
45 #else
46 #    define OA_GCC_VERSION_AT_LEAST(x, y) 0
47 #endif
48
49 #ifndef attribute_deprecated
50 #if OA_GCC_VERSION_AT_LEAST(3, 1)
51 #    define attribute_deprecated __attribute__((deprecated))
52 #else
53 #    define attribute_deprecated
54 #endif
55 #endif
56
57 #endif /* doxygen ignore */
58
59 #ifdef __cplusplus
60 extern "C" {
61 #endif
62
63 /** \enum OAuthMethod
64  * signature method to used for signing the request.
65  */ 
66 typedef enum {
67     OA_HMAC = 0, ///< use HMAC-SHA1 request signing method
68     OA_RSA, ///< use RSA signature
69     OA_PLAINTEXT ///< use plain text signature (for testing only)
70   } OAuthMethod;
71
72 /**
73  * Base64 encode and return size data in 'src'. The caller must free the
74  * returned string.
75  *
76  * @param size The size of the data in src
77  * @param src The data to be base64 encode
78  * @return encoded string otherwise NULL
79  */
80 char *oauth_encode_base64(int size, const unsigned char *src);
81
82 /**
83  * Decode the base64 encoded string 'src' into the memory pointed to by
84  * 'dest'. 
85  *
86  * @param dest Pointer to memory for holding the decoded string.
87  * Must be large enough to receive the decoded string.
88  * @param src A base64 encoded string.
89  * @return the length of the decoded string if decode
90  * succeeded otherwise 0.
91  */
92 int oauth_decode_base64(unsigned char *dest, const char *src);
93
94 /**
95  * Escape 'string' according to RFC3986 and
96  * http://oauth.net/core/1.0/#encoding_parameters.
97  *
98  * @param string The data to be encoded
99  * @return encoded string otherwise NULL
100  * The caller must free the returned string.
101  */
102 char *oauth_url_escape(const char *string);
103
104 /**
105  * Parse RFC3986 encoded 'string' back to  unescaped version.
106  *
107  * @param string The data to be unescaped
108  * @param olen unless NULL the length of the returned string is stored there.
109  * @return decoded string or NULL
110  * The caller must free the returned string.
111  */
112 char *oauth_url_unescape(const char *string, size_t *olen);
113
114 /**
115  * returns base64 encoded HMAC-SHA1 signature for
116  * given message and key.
117  * both data and key need to be urlencoded.
118  *
119  * the returned string needs to be freed by the caller
120  *
121  * @param m message to be signed
122  * @param k key used for signing
123  * @return signature string.
124  */
125 char *oauth_sign_hmac_sha1(const char *m, const char *k);
126
127 /**
128  * same as \ref oauth_sign_hmac_sha1 but allows one
129  * to specify length of message and key (in case they contain null chars).
130  *
131  * @param m message to be signed
132  * @param ml length of message
133  * @param k key used for signing
134  * @param kl length of key
135  * @return signature string.
136  */
137 char *oauth_sign_hmac_sha1_raw(const char *m, const size_t ml, const char *k, const size_t kl);
138
139 /**
140  * returns plaintext signature for the given key.
141  *
142  * the returned string needs to be freed by the caller
143  *
144  * @param m message to be signed
145  * @param k key used for signing
146  * @return signature string
147  */
148 char *oauth_sign_plaintext(const char *m, const char *k);
149
150 /**
151  * returns RSA-SHA1 signature for given data.
152  * the returned signature needs to be freed by the caller.
153  *
154  * @param m message to be signed
155  * @param k private-key PKCS and Base64-encoded 
156  * @return base64 encoded signature string.
157  */
158 char *oauth_sign_rsa_sha1(const char *m, const char *k);
159
160 /**
161  * verify RSA-SHA1 signature.
162  *
163  * returns the output of EVP_VerifyFinal() for a given message,
164  * cert/pubkey and signature.
165  *
166  * @param m message to be verified
167  * @param c public-key or x509 certificate
168  * @param s base64 encoded signature
169  * @return 1 for a correct signature, 0 for failure and -1 if some other error occurred
170  */
171 int oauth_verify_rsa_sha1(const char *m, const char *c, const char *s);
172
173 /**
174  * url-escape strings and concatenate with '&' separator.
175  * The number of strings to be concatenated must be
176  * given as first argument.
177  * all arguments thereafter must be of type (char *) 
178  *
179  * @param len the number of arguments to follow this parameter
180  *
181  * @return pointer to memory holding the concatenated 
182  * strings - needs to be xfree(d) by the caller. or NULL
183  * in case we ran out of memory.
184  */
185 char *oauth_catenc(int len, ...);
186
187 /**
188  * splits the given url into a parameter array. 
189  * (see \ref oauth_serialize_url and \ref oauth_serialize_url_parameters for the reverse)
190  * (see \ref oauth_split_post_paramters for a more generic version)
191  *
192  * @param url the url or query-string to parse; may be NULL
193  * @param argv pointer to a (char *) array where the results are stored.
194  *  The array is re-allocated to match the number of parameters and each 
195  *  parameter-string is allocated with strdup. - The memory needs to be freed
196  *  by the caller.
197  * 
198  * @return number of parameter(s) in array.
199  */
200 int oauth_split_url_parameters(const char *url, char ***argv);
201
202 /**
203  * splits the given url into a parameter array. 
204  * (see \ref oauth_serialize_url and \ref oauth_serialize_url_parameters for the reverse)
205  *
206  * @param url the url or query-string to parse. 
207  * @param argv pointer to a (char *) array where the results are stored.
208  *  The array is re-allocated to match the number of parameters and each 
209  *  parameter-string is allocated with strdup. - The memory needs to be freed
210  *  by the caller.
211  * @param qesc  use query parameter escape (vs post-param-escape) - if set
212  *        to 1 all '+' are treated as spaces ' '
213  * 
214  * @return number of parameter(s) in array.
215  */
216 int oauth_split_post_paramters(const char *url, char ***argv, short qesc);
217
218 /**
219  * build a url query string from an array.
220  *
221  * @param argc  the total number of elements in the array
222  * @param start element in the array at which to start concatenating.
223  * @param argv  parameter-array to concatenate.
224  * @return url string needs to be freed by the caller.
225  *
226  */
227 char *oauth_serialize_url(int argc, int start, char **argv);
228
229 /**
230  * encode query parameters from an array.
231  *
232  * @param argc the total number of elements in the array
233  * @param start element in the array at which to start concatenating.
234  * @param argv parameter-array to concatenate.
235  * @param sep separator for parameters (usually "&") 
236  * @param mod - bitwise modifiers: 
237  *   1: skip all values that start with "oauth_"
238  *   2: skip all values that don't start with "oauth_"
239  *   4: double quotation marks are added around values (use with sep ", " for HTTP Authorization header).
240  * @return url string needs to be freed by the caller.
241  */
242 char *oauth_serialize_url_sep(int argc, int start, char **argv, char *sep, int mod);
243
244 /**
245  * build a query parameter string from an array.
246  *
247  * This function is a shortcut for \ref oauth_serialize_url (argc, 1, argv). 
248  * It strips the leading host/path, which is usually the first 
249  * element when using oauth_split_url_parameters on an URL.
250  *
251  * @param argc the total number of elements in the array
252  * @param argv parameter-array to concatenate.
253  * @return url string needs to be freed by the caller.
254  */
255 char *oauth_serialize_url_parameters(int argc, char **argv);
256  
257 /**
258  * generate a random string between 15 and 32 chars length
259  * and return a pointer to it. The value needs to be freed by the
260  * caller
261  *
262  * @return zero terminated random string.
263  */
264 char *oauth_gen_nonce();
265
266 /**
267  * string compare function for oauth parameters.
268  *
269  * used with qsort. needed to normalize request parameters.
270  * see http://oauth.net/core/1.0/#anchor14
271  */
272 int oauth_cmpstringp(const void *p1, const void *p2);
273
274
275 /**
276  * search array for parameter key.
277  * @param argv length of array to search
278  * @param argc parameter array to search
279  * @param key key of parameter to check.
280  *
281  * @return FALSE (0) if array does not contain a parameter with given key, TRUE (1) otherwise.
282  */
283 int oauth_param_exists(char **argv, int argc, char *key);
284
285 /**
286  * add query parameter to array
287  *
288  * @param argcp pointer to array length int
289  * @param argvp pointer to array values 
290  * @param addparam parameter to add (eg. "foo=bar")
291  */
292 void oauth_add_param_to_array(int *argcp, char ***argvp, const char *addparam);
293
294 /**
295  * free array args
296  *
297  * @param argcp pointer to array length int
298  * @param argvp pointer to array values to be xfree()d
299  */
300 void oauth_free_array(int *argcp, char ***argvp);
301
302 /**
303  * compare two strings in constant-time (as to not let an
304  * attacker guess how many leading chars are correct:
305  * http://rdist.root.org/2010/01/07/timing-independent-array-comparison/ )
306  *
307  * @param a string to compare 
308  * @param b string to compare
309  * @param len_a length of string a
310  * @param len_b length of string b
311  *
312  * returns 0 (false) if strings are not equal, and 1 (true) if strings are equal.
313  */
314 int oauth_time_independent_equals_n(const char* a, const char* b, size_t len_a, size_t len_b);
315
316 /**
317  * @deprecated Use oauth_time_independent_equals_n() instead.
318  */
319 int oauth_time_indepenent_equals_n(const char* a, const char* b, size_t len_a, size_t len_b) attribute_deprecated;
320
321 /**
322  * compare two strings in constant-time.
323  * wrapper to \ref oauth_time_independent_equals_n 
324  * which calls strlen() for each argument.
325  *
326  * @param a string to compare 
327  * @param b string to compare
328  *
329  * returns 0 (false) if strings are not equal, and 1 (true) if strings are equal.
330  */
331 int oauth_time_independent_equals(const char* a, const char* b);
332
333 /**
334  * @deprecated Use oauth_time_independent_equals() instead.
335  */
336 int oauth_time_indepenent_equals(const char* a, const char* b) attribute_deprecated;
337
338 /**
339  * calculate OAuth-signature for a given HTTP request URL, parameters and oauth-tokens.
340  *
341  * if 'postargs' is NULL a "GET" request is signed and the 
342  * signed URL is returned. Else this fn will modify 'postargs' 
343  * to point to memory that contains the signed POST-variables 
344  * and returns the base URL.
345  *
346  * both, the return value and (if given) 'postargs' need to be freed
347  * by the caller.
348  *
349  * @param url The request URL to be signed. append all GET or POST 
350  * query-parameters separated by either '?' or '&' to this parameter.
351  *
352  * @param postargs This parameter points to an area where the return value
353  * is stored. If 'postargs' is NULL, no value is stored.
354  *
355  * @param method specify the signature method to use. It is of type 
356  * \ref OAuthMethod and most likely \ref OA_HMAC.
357  *
358  * @param http_method The HTTP request method to use (ie "GET", "PUT",..)
359  * If NULL is given as 'http_method' this defaults to "GET" when 
360  * 'postargs' is also NULL and when postargs is not NULL "POST" is used.
361  *
362  * @param c_key consumer key
363  * @param c_secret consumer secret
364  * @param t_key token key
365  * @param t_secret token secret
366  *
367  * @return the signed url or NULL if an error occurred.
368  *
369  */
370 char *oauth_sign_url2(const char *url, char **postargs,
371   OAuthMethod method,
372   const char *http_method, //< HTTP request method
373   const char *c_key, //< consumer key - posted plain text
374   const char *c_secret, //< consumer secret - used as 1st part of secret-key
375   const char *t_key, //< token key - posted plain text in URL
376   const char *t_secret); //< token secret - used as 2st part of secret-key
377
378 /**
379  * @deprecated Use oauth_sign_url2() instead.
380  */
381 char *oauth_sign_url(const char *url, char **postargs,
382   OAuthMethod method,
383   const char *c_key, //< consumer key - posted plain text
384   const char *c_secret, //< consumer secret - used as 1st part of secret-key
385   const char *t_key, //< token key - posted plain text in URL
386   const char *t_secret) //< token secret - used as 2st part of secret-key
387   attribute_deprecated;
388
389
390 /**
391  * the back-end behind by /ref oauth_sign_array2.
392  * however it does not serialize the signed URL again.
393  * The user needs to call /ref oauth_serialize_url (oA)
394  * and /ref oauth_free_array to do so.
395  *
396  * This allows one to split parts of the URL to be used for
397  * OAuth HTTP Authorization header:
398  * see http://oauth.net/core/1.0a/#consumer_req_param
399  * the oauthtest2 example code does so.
400  * 
401  *
402  * @param argcp pointer to array length int
403  * @param argvp pointer to array values  
404  * (argv[0]="http://example.org:80/" argv[1]="first=QueryParamater" ..
405  *  the array is modified: fi. oauth_ parameters are added)
406  *  These arrays can be generated with /ref oauth_split_url_parameters
407  *  or /ref oauth_split_post_paramters.
408  *
409  * @param postargs This parameter points to an area where the return value
410  * is stored. If 'postargs' is NULL, no value is stored.
411  *
412  * @param method specify the signature method to use. It is of type 
413  * \ref OAuthMethod and most likely \ref OA_HMAC.
414  *
415  * @param http_method The HTTP request method to use (ie "GET", "PUT",..)
416  * If NULL is given as 'http_method' this defaults to "GET" when 
417  * 'postargs' is also NULL and when postargs is not NULL "POST" is used.
418  *
419  * @param c_key consumer key
420  * @param c_secret consumer secret
421  * @param t_key token key
422  * @param t_secret token secret
423  *
424  * @return void
425  *
426  */
427 void oauth_sign_array2_process(int *argcp, char***argvp,
428   char **postargs,
429   OAuthMethod method,
430   const char *http_method, //< HTTP request method
431   const char *c_key, //< consumer key - posted plain text
432   const char *c_secret, //< consumer secret - used as 1st part of secret-key
433   const char *t_key, //< token key - posted plain text in URL
434   const char *t_secret); //< token secret - used as 2st part of secret-key
435
436 /**
437  * same as /ref oauth_sign_url
438  * with the url already split into parameter array 
439  *
440  * @param argcp pointer to array length int
441  * @param argvp pointer to array values  
442  * (argv[0]="http://example.org:80/" argv[1]="first=QueryParamater" ..
443  *  the array is modified: fi. oauth_ parameters are added)
444  *  These arrays can be generated with /ref oauth_split_url_parameters
445  *  or /ref oauth_split_post_paramters.
446  *
447  * @param postargs This parameter points to an area where the return value
448  * is stored. If 'postargs' is NULL, no value is stored.
449  *
450  * @param method specify the signature method to use. It is of type 
451  * \ref OAuthMethod and most likely \ref OA_HMAC.
452  *
453  * @param http_method The HTTP request method to use (ie "GET", "PUT",..)
454  * If NULL is given as 'http_method' this defaults to "GET" when 
455  * 'postargs' is also NULL and when postargs is not NULL "POST" is used.
456  *
457  * @param c_key consumer key
458  * @param c_secret consumer secret
459  * @param t_key token key
460  * @param t_secret token secret
461  *
462  * @return the signed url or NULL if an error occurred.
463  */
464 char *oauth_sign_array2(int *argcp, char***argvp,
465   char **postargs,
466   OAuthMethod method,
467   const char *http_method, //< HTTP request method
468   const char *c_key, //< consumer key - posted plain text
469   const char *c_secret, //< consumer secret - used as 1st part of secret-key
470   const char *t_key, //< token key - posted plain text in URL
471   const char *t_secret); //< token secret - used as 2st part of secret-key
472
473
474 /**
475  * @deprecated Use oauth_sign_array2() instead.
476  */
477 char *oauth_sign_array(int *argcp, char***argvp,
478   char **postargs,
479   OAuthMethod method,
480   const char *c_key, //< consumer key - posted plain text
481   const char *c_secret, //< consumer secret - used as 1st part of secret-key
482   const char *t_key, //< token key - posted plain text in URL
483   const char *t_secret)  //< token secret - used as 2st part of secret-key
484   attribute_deprecated;
485
486
487 /** 
488  * calculate body hash (sha1sum) of given file and return
489  * a oauth_body_hash=xxxx parameter to be added to the request.
490  * The returned string needs to be freed by the calling function.
491  *
492  * see
493  * http://oauth.googlecode.com/svn/spec/ext/body_hash/1.0/oauth-bodyhash.html
494  * 
495  * @param filename the filename to calculate the hash for
496  *
497  * @return URL oauth_body_hash parameter string
498  */
499 char *oauth_body_hash_file(char *filename);
500
501 /** 
502  * calculate body hash (sha1sum) of given data and return
503  * a oauth_body_hash=xxxx parameter to be added to the request.
504  * The returned string needs to be freed by the calling function.
505  * The returned string is not yet url-escaped and suitable to be 
506  * passed as argument to \ref oauth_catenc.
507  *
508  * see
509  * http://oauth.googlecode.com/svn/spec/ext/body_hash/1.0/oauth-bodyhash.html
510  * 
511  * @param length length of the data parameter in bytes
512  * @param data to calculate the hash for
513  *
514  * @return URL oauth_body_hash parameter string
515  */
516 char *oauth_body_hash_data(size_t length, const char *data);
517
518 /**
519  * base64 encode digest, free it and return a URL parameter
520  * with the oauth_body_hash. The returned hash needs to be freed by the
521  * calling function. The returned string is not yet url-escaped and 
522  * thus suitable to be passed to \ref oauth_catenc.
523  *
524  * @param len length of the digest to encode
525  * @param digest hash value to encode
526  *
527  * @return URL oauth_body_hash parameter string
528  */
529 char *oauth_body_hash_encode(size_t len, unsigned char *digest);
530
531 /**
532  * xep-0235 - TODO
533  */
534 char *oauth_sign_xmpp(const char *xml,
535   OAuthMethod method,
536   const char *c_secret, //< consumer secret - used as 1st part of secret-key
537   const char *t_secret); //< token secret - used as 2st part of secret-key
538
539 /**
540  * do a HTTP GET request, wait for it to finish 
541  * and return the content of the reply.
542  * (requires libcurl or a command-line HTTP client)
543  *
544  * If compiled <b>without</b> libcurl this function calls
545  * a command-line executable defined in the environment variable
546  * OAUTH_HTTP_GET_CMD - it defaults to 
547  * <tt>curl -sA 'liboauth-agent/0.1' '%%u'</tt>
548  * where %%u is replaced with the URL and query parameters.
549  *
550  * bash & wget example:
551  * <tt>export OAUTH_HTTP_CMD="wget -q -U 'liboauth-agent/0.1' '%u' "</tt>
552  *
553  * WARNING: this is a tentative function. it's convenient and handy for testing
554  * or developing OAuth code. But don't rely on this function
555  * to become a stable part of this API. It does not do 
556  * much error checking or handling for one thing..
557  *
558  * NOTE: \a u and \a q are just concatenated with a '?' in between,
559  * unless \a q is NULL. in which case only \a u will be used.
560  *
561  * @param u base url to get
562  * @param q query string to send along with the HTTP request or NULL.
563  * @return  In case of an error NULL is returned; otherwise a pointer to the
564  * replied content from HTTP server. latter needs to be freed by caller.
565  *
566  * @deprecated use libcurl - http://curl.haxx.se/libcurl/c/
567  */
568 char *oauth_http_get(const char *u, const char *q) attribute_deprecated;
569
570 /**
571  * do a HTTP GET request, wait for it to finish 
572  * and return the content of the reply.
573  *
574  * (requires libcurl)
575  *
576  * This is equivalent to /ref oauth_http_get but allows one
577  * to specifiy a custom HTTP header andhas no support for commandline-curl.
578  *
579  * If liboauth is compiled <b>without</b> libcurl this function
580  * always returns NULL.
581  *
582  * @param u base url to get
583  * @param q query string to send along with the HTTP request or NULL.
584  * @param customheader specify custom HTTP header (or NULL for none)
585  * Multiple header elements can be passed separating them with "\r\n"
586  * @return  In case of an error NULL is returned; otherwise a pointer to the
587  * replied content from HTTP server. latter needs to be freed by caller.
588  *
589  * @deprecated use libcurl - http://curl.haxx.se/libcurl/c/
590  */
591 char *oauth_http_get2(const char *u, const char *q, const char *customheader) attribute_deprecated;
592
593
594 /**
595  * do a HTTP POST request, wait for it to finish 
596  * and return the content of the reply.
597  * (requires libcurl or a command-line HTTP client)
598  *
599  * If compiled <b>without</b> libcurl this function calls
600  * a command-line executable defined in the environment variable
601  * OAUTH_HTTP_CMD - it defaults to 
602  * <tt>curl -sA 'liboauth-agent/0.1' -d '%%p' '%%u'</tt>
603  * where %%p is replaced with the postargs and %%u is replaced with 
604  * the URL. 
605  *
606  * bash & wget example:
607  * <tt>export OAUTH_HTTP_CMD="wget -q -U 'liboauth-agent/0.1' --post-data='%p' '%u' "</tt>
608  *
609  * NOTE: This function uses the curl's default HTTP-POST Content-Type:
610  * application/x-www-form-urlencoded which is the only option allowed
611  * by oauth core 1.0 spec. Experimental code can use the Environment variable
612  * to transmit custom HTTP headers or parameters.
613  *
614  * WARNING: this is a tentative function. it's convenient and handy for testing
615  * or developing OAuth code. But don't rely on this function
616  * to become a stable part of this API. It does not do 
617  * much error checking for one thing..
618  *
619  * @param u url to query
620  * @param p postargs to send along with the HTTP request.
621  * @return replied content from HTTP server. needs to be freed by caller.
622  *
623  * @deprecated use libcurl - http://curl.haxx.se/libcurl/c/
624  */
625 char *oauth_http_post(const char *u, const char *p) attribute_deprecated;
626
627 /**
628  * do a HTTP POST request, wait for it to finish 
629  * and return the content of the reply.
630  * (requires libcurl)
631  *
632  * It's equivalent to /ref oauth_http_post, but offers
633  * the possibility to specify a custom HTTP header and
634  * has no support for commandline-curl.
635  *
636  * If liboauth is compiled <b>without</b> libcurl this function
637  * always returns NULL.
638  *
639  * @param u url to query
640  * @param p postargs to send along with the HTTP request.
641  * @param customheader specify custom HTTP header (or NULL for none)
642  * Multiple header elements can be passed separating them with "\r\n"
643  * @return replied content from HTTP server. needs to be freed by caller.
644  *
645  * @deprecated use libcurl - http://curl.haxx.se/libcurl/c/
646  */
647 char *oauth_http_post2(const char *u, const char *p, const char *customheader) attribute_deprecated;
648
649
650 /**
651  * http post raw data from file.
652  * the returned string needs to be freed by the caller
653  * (requires libcurl)
654  *
655  * see dislaimer: /ref oauth_http_post
656  *
657  * @param u url to retrieve
658  * @param fn filename of the file to post along
659  * @param len length of the file in bytes. set to '0' for autodetection
660  * @param customheader specify custom HTTP header (or NULL for default).
661  * Multiple header elements can be passed separating them with "\r\n"
662  * @return returned HTTP reply or NULL on error
663  *
664  * @deprecated use libcurl - http://curl.haxx.se/libcurl/c/
665  */
666 char *oauth_post_file(const char *u, const char *fn, const size_t len, const char *customheader) attribute_deprecated;
667
668 /**
669  * http post raw data
670  * the returned string needs to be freed by the caller
671  * (requires libcurl)
672  *
673  * see dislaimer: /ref oauth_http_post
674  *
675  * @param u url to retrieve
676  * @param data data to post
677  * @param len length of the data in bytes. 
678  * @param customheader specify custom HTTP header (or NULL for default)
679  * Multiple header elements can be passed separating them with "\r\n"
680  * @return returned HTTP reply or NULL on error
681  *
682  * @deprecated use libcurl - http://curl.haxx.se/libcurl/c/
683  */
684 char *oauth_post_data(const char *u, const char *data, size_t len, const char *customheader) attribute_deprecated;
685
686 /**
687  * http post raw data, with callback.
688  * the returned string needs to be freed by the caller
689  * (requires libcurl)
690  *
691  * Invokes the callback - in no particular order - when HTTP-request status updates occur.
692  * The callback is called with:
693  *   void * callback_data: supplied on function call.
694  *   int type: 0=data received, 1=data sent.
695  *   size_t size: amount of data received or amount of data sent so far
696  *   size_t totalsize: original amount of data to send, or amount of data received
697  *
698  * @param u url to retrieve
699  * @param data data to post along
700  * @param len length of the file in bytes. set to '0' for autodetection
701  * @param customheader specify custom HTTP header (or NULL for default)
702  * Multiple header elements can be passed separating them with "\r\n"
703  * @param callback specify the callback function
704  * @param callback_data specify data to pass to the callback function
705  * @return returned HTTP reply or NULL on error
706  *
707  * @deprecated use libcurl - http://curl.haxx.se/libcurl/c/
708  */
709 char *oauth_post_data_with_callback(const char *u,
710                                           const char *data,
711                                           size_t len,
712                                           const char *customheader,
713                                           void (*callback)(void*, int, size_t, size_t),
714                                           void *callback_data) attribute_deprecated;
715
716 /**
717  * http send raw data. similar to /ref oauth_http_post but provides
718  * for specifying the HTTP request method.
719  *
720  * the returned string needs to be freed by the caller
721  * (requires libcurl)
722  *
723  * see dislaimer: /ref oauth_http_post
724  *
725  * @param u url to retrieve
726  * @param data data to post
727  * @param len length of the data in bytes. 
728  * @param customheader specify custom HTTP header (or NULL for default)
729  * Multiple header elements can be passed separating them with "\r\n"
730  * @param httpMethod specify http verb ("GET"/"POST"/"PUT"/"DELETE") to be used. if httpMethod is NULL, a POST is executed.
731  * @return returned HTTP reply or NULL on error
732  *
733  * @deprecated use libcurl - http://curl.haxx.se/libcurl/c/
734  */
735 char *oauth_send_data(const char *u,
736                        const char *data,
737                        size_t len,
738                        const char *customheader,
739                        const char *httpMethod) attribute_deprecated;
740
741 /**
742  * http post raw data, with callback.
743  * the returned string needs to be freed by the caller
744  * (requires libcurl)
745  *
746  * Invokes the callback - in no particular order - when HTTP-request status updates occur.
747  * The callback is called with:
748  *   void * callback_data: supplied on function call.
749  *   int type: 0=data received, 1=data sent.
750  *   size_t size: amount of data received or amount of data sent so far
751  *   size_t totalsize: original amount of data to send, or amount of data received
752  *
753  * @param u url to retrieve
754  * @param data data to post along
755  * @param len length of the file in bytes. set to '0' for autodetection
756  * @param customheader specify custom HTTP header (or NULL for default)
757  * Multiple header elements can be passed separating them with "\r\n"
758  * @param callback specify the callback function
759  * @param callback_data specify data to pass to the callback function
760  * @param httpMethod specify http verb ("GET"/"POST"/"PUT"/"DELETE") to be used.
761  * @return returned HTTP reply or NULL on error
762  *
763  * @deprecated use libcurl - http://curl.haxx.se/libcurl/c/
764  */
765 char *oauth_send_data_with_callback(const char *u,
766                                           const char *data,
767                                           size_t len,
768                                           const char *customheader,
769                                           void (*callback)(void*, int, size_t,size_t),
770                                           void *callback_data,
771                                           const char *httpMethod) attribute_deprecated;
772
773 #ifdef __cplusplus
774 }       /* extern "C" */
775 #endif  /* __cplusplus */
776
777 #endif
778 /* vi:set ts=8 sts=2 sw=2: */