2 * @brief OAuth.net implementation in POSIX-C.
4 * @author Robin Gareus <robin@gareus.org>
6 * Copyright 2007-2014 Robin Gareus <robin@gareus.org>
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:
15 * The above copyright notice and this permission notice shall be included in
16 * all copies or substantial portions of the Software.
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
30 #ifndef DOXYGEN_IGNORE
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
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
44 # define OA_GCC_VERSION_AT_LEAST(x, y) (__GNUC__ > x || __GNUC__ == x && __GNUC_MINOR__ >= y)
46 # define OA_GCC_VERSION_AT_LEAST(x, y) 0
49 #ifndef attribute_deprecated
50 #if OA_GCC_VERSION_AT_LEAST(3, 1)
51 # define attribute_deprecated __attribute__((deprecated))
53 # define attribute_deprecated
57 #endif /* doxygen ignore */
64 * signature method to used for signing the request.
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)
73 * Base64 encode and return size data in 'src'. The caller must free the
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
80 char *oauth_encode_base64(int size, const unsigned char *src);
83 * Decode the base64 encoded string 'src' into the memory pointed to by
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.
92 int oauth_decode_base64(unsigned char *dest, const char *src);
95 * Escape 'string' according to RFC3986 and
96 * http://oauth.net/core/1.0/#encoding_parameters.
98 * @param string The data to be encoded
99 * @return encoded string otherwise NULL
100 * The caller must free the returned string.
102 char *oauth_url_escape(const char *string);
105 * Parse RFC3986 encoded 'string' back to unescaped version.
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.
112 char *oauth_url_unescape(const char *string, size_t *olen);
115 * returns base64 encoded HMAC-SHA1 signature for
116 * given message and key.
117 * both data and key need to be urlencoded.
119 * the returned string needs to be freed by the caller
121 * @param m message to be signed
122 * @param k key used for signing
123 * @return signature string.
125 char *oauth_sign_hmac_sha1(const char *m, const char *k);
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).
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.
137 char *oauth_sign_hmac_sha1_raw(const char *m, const size_t ml, const char *k, const size_t kl);
140 * returns plaintext signature for the given key.
142 * the returned string needs to be freed by the caller
144 * @param m message to be signed
145 * @param k key used for signing
146 * @return signature string
148 char *oauth_sign_plaintext(const char *m, const char *k);
151 * returns RSA-SHA1 signature for given data.
152 * the returned signature needs to be freed by the caller.
154 * @param m message to be signed
155 * @param k private-key PKCS and Base64-encoded
156 * @return base64 encoded signature string.
158 char *oauth_sign_rsa_sha1(const char *m, const char *k);
161 * verify RSA-SHA1 signature.
163 * returns the output of EVP_VerifyFinal() for a given message,
164 * cert/pubkey and signature.
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
171 int oauth_verify_rsa_sha1(const char *m, const char *c, const char *s);
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 *)
179 * @param len the number of arguments to follow this parameter
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.
185 char *oauth_catenc(int len, ...);
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)
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
198 * @return number of parameter(s) in array.
200 int oauth_split_url_parameters(const char *url, char ***argv);
203 * splits the given url into a parameter array.
204 * (see \ref oauth_serialize_url and \ref oauth_serialize_url_parameters for the reverse)
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
211 * @param qesc use query parameter escape (vs post-param-escape) - if set
212 * to 1 all '+' are treated as spaces ' '
214 * @return number of parameter(s) in array.
216 int oauth_split_post_paramters(const char *url, char ***argv, short qesc);
219 * build a url query string from an array.
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.
227 char *oauth_serialize_url(int argc, int start, char **argv);
230 * encode query parameters from an array.
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.
242 char *oauth_serialize_url_sep(int argc, int start, char **argv, char *sep, int mod);
245 * build a query parameter string from an array.
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.
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.
255 char *oauth_serialize_url_parameters(int argc, char **argv);
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
262 * @return zero terminated random string.
264 char *oauth_gen_nonce();
267 * string compare function for oauth parameters.
269 * used with qsort. needed to normalize request parameters.
270 * see http://oauth.net/core/1.0/#anchor14
272 int oauth_cmpstringp(const void *p1, const void *p2);
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.
281 * @return FALSE (0) if array does not contain a parameter with given key, TRUE (1) otherwise.
283 int oauth_param_exists(char **argv, int argc, char *key);
286 * add query parameter to array
288 * @param argcp pointer to array length int
289 * @param argvp pointer to array values
290 * @param addparam parameter to add (eg. "foo=bar")
292 void oauth_add_param_to_array(int *argcp, char ***argvp, const char *addparam);
297 * @param argcp pointer to array length int
298 * @param argvp pointer to array values to be xfree()d
300 void oauth_free_array(int *argcp, char ***argvp);
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/ )
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
312 * returns 0 (false) if strings are not equal, and 1 (true) if strings are equal.
314 int oauth_time_independent_equals_n(const char* a, const char* b, size_t len_a, size_t len_b);
317 * @deprecated Use oauth_time_independent_equals_n() instead.
319 int oauth_time_indepenent_equals_n(const char* a, const char* b, size_t len_a, size_t len_b) attribute_deprecated;
322 * compare two strings in constant-time.
323 * wrapper to \ref oauth_time_independent_equals_n
324 * which calls strlen() for each argument.
326 * @param a string to compare
327 * @param b string to compare
329 * returns 0 (false) if strings are not equal, and 1 (true) if strings are equal.
331 int oauth_time_independent_equals(const char* a, const char* b);
334 * @deprecated Use oauth_time_independent_equals() instead.
336 int oauth_time_indepenent_equals(const char* a, const char* b) attribute_deprecated;
339 * calculate OAuth-signature for a given HTTP request URL, parameters and oauth-tokens.
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.
346 * both, the return value and (if given) 'postargs' need to be freed
349 * @param url The request URL to be signed. append all GET or POST
350 * query-parameters separated by either '?' or '&' to this parameter.
352 * @param postargs This parameter points to an area where the return value
353 * is stored. If 'postargs' is NULL, no value is stored.
355 * @param method specify the signature method to use. It is of type
356 * \ref OAuthMethod and most likely \ref OA_HMAC.
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.
362 * @param c_key consumer key
363 * @param c_secret consumer secret
364 * @param t_key token key
365 * @param t_secret token secret
367 * @return the signed url or NULL if an error occurred.
370 char *oauth_sign_url2(const char *url, char **postargs,
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
379 * @deprecated Use oauth_sign_url2() instead.
381 char *oauth_sign_url(const char *url, char **postargs,
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;
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.
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.
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.
409 * @param postargs This parameter points to an area where the return value
410 * is stored. If 'postargs' is NULL, no value is stored.
412 * @param method specify the signature method to use. It is of type
413 * \ref OAuthMethod and most likely \ref OA_HMAC.
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.
419 * @param c_key consumer key
420 * @param c_secret consumer secret
421 * @param t_key token key
422 * @param t_secret token secret
427 void oauth_sign_array2_process(int *argcp, char***argvp,
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
437 * same as /ref oauth_sign_url
438 * with the url already split into parameter array
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.
447 * @param postargs This parameter points to an area where the return value
448 * is stored. If 'postargs' is NULL, no value is stored.
450 * @param method specify the signature method to use. It is of type
451 * \ref OAuthMethod and most likely \ref OA_HMAC.
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.
457 * @param c_key consumer key
458 * @param c_secret consumer secret
459 * @param t_key token key
460 * @param t_secret token secret
462 * @return the signed url or NULL if an error occurred.
464 char *oauth_sign_array2(int *argcp, char***argvp,
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
475 * @deprecated Use oauth_sign_array2() instead.
477 char *oauth_sign_array(int *argcp, char***argvp,
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;
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.
493 * http://oauth.googlecode.com/svn/spec/ext/body_hash/1.0/oauth-bodyhash.html
495 * @param filename the filename to calculate the hash for
497 * @return URL oauth_body_hash parameter string
499 char *oauth_body_hash_file(char *filename);
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.
509 * http://oauth.googlecode.com/svn/spec/ext/body_hash/1.0/oauth-bodyhash.html
511 * @param length length of the data parameter in bytes
512 * @param data to calculate the hash for
514 * @return URL oauth_body_hash parameter string
516 char *oauth_body_hash_data(size_t length, const char *data);
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.
524 * @param len length of the digest to encode
525 * @param digest hash value to encode
527 * @return URL oauth_body_hash parameter string
529 char *oauth_body_hash_encode(size_t len, unsigned char *digest);
534 char *oauth_sign_xmpp(const char *xml,
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
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)
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.
550 * bash & wget example:
551 * <tt>export OAUTH_HTTP_CMD="wget -q -U 'liboauth-agent/0.1' '%u' "</tt>
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..
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.
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.
566 * @deprecated use libcurl - http://curl.haxx.se/libcurl/c/
568 char *oauth_http_get(const char *u, const char *q) attribute_deprecated;
571 * do a HTTP GET request, wait for it to finish
572 * and return the content of the reply.
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.
579 * If liboauth is compiled <b>without</b> libcurl this function
580 * always returns NULL.
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.
589 * @deprecated use libcurl - http://curl.haxx.se/libcurl/c/
591 char *oauth_http_get2(const char *u, const char *q, const char *customheader) attribute_deprecated;
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)
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
606 * bash & wget example:
607 * <tt>export OAUTH_HTTP_CMD="wget -q -U 'liboauth-agent/0.1' --post-data='%p' '%u' "</tt>
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.
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..
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.
623 * @deprecated use libcurl - http://curl.haxx.se/libcurl/c/
625 char *oauth_http_post(const char *u, const char *p) attribute_deprecated;
628 * do a HTTP POST request, wait for it to finish
629 * and return the content of the reply.
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.
636 * If liboauth is compiled <b>without</b> libcurl this function
637 * always returns NULL.
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.
645 * @deprecated use libcurl - http://curl.haxx.se/libcurl/c/
647 char *oauth_http_post2(const char *u, const char *p, const char *customheader) attribute_deprecated;
651 * http post raw data from file.
652 * the returned string needs to be freed by the caller
655 * see dislaimer: /ref oauth_http_post
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
664 * @deprecated use libcurl - http://curl.haxx.se/libcurl/c/
666 char *oauth_post_file(const char *u, const char *fn, const size_t len, const char *customheader) attribute_deprecated;
670 * the returned string needs to be freed by the caller
673 * see dislaimer: /ref oauth_http_post
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
682 * @deprecated use libcurl - http://curl.haxx.se/libcurl/c/
684 char *oauth_post_data(const char *u, const char *data, size_t len, const char *customheader) attribute_deprecated;
687 * http post raw data, with callback.
688 * the returned string needs to be freed by the caller
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
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
707 * @deprecated use libcurl - http://curl.haxx.se/libcurl/c/
709 char *oauth_post_data_with_callback(const char *u,
712 const char *customheader,
713 void (*callback)(void*, int, size_t, size_t),
714 void *callback_data) attribute_deprecated;
717 * http send raw data. similar to /ref oauth_http_post but provides
718 * for specifying the HTTP request method.
720 * the returned string needs to be freed by the caller
723 * see dislaimer: /ref oauth_http_post
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
733 * @deprecated use libcurl - http://curl.haxx.se/libcurl/c/
735 char *oauth_send_data(const char *u,
738 const char *customheader,
739 const char *httpMethod) attribute_deprecated;
742 * http post raw data, with callback.
743 * the returned string needs to be freed by the caller
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
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
763 * @deprecated use libcurl - http://curl.haxx.se/libcurl/c/
765 char *oauth_send_data_with_callback(const char *u,
768 const char *customheader,
769 void (*callback)(void*, int, size_t,size_t),
771 const char *httpMethod) attribute_deprecated;
775 #endif /* __cplusplus */
778 /* vi:set ts=8 sts=2 sw=2: */