~ubuntu-branches/debian/sid/flickcurl/sid

« back to all changes in this revision

Viewing changes to src/flickcurl_internal.h

  • Committer: Package Import Robot
  • Author(s): Kumar Appaiah
  • Date: 2013-05-20 21:15:09 UTC
  • mfrom: (1.4.1) (15.1.1 experimental)
  • Revision ID: package-import@ubuntu.com-20130520211509-e701o5dlwa04aqiw
Tags: 1.24-1
New upstream release

Show diffs side-by-side

added added

removed removed

Lines of Context:
4
4
 *
5
5
 * All API calls and defines here many change in any release.
6
6
 *
7
 
 * Copyright (C) 2007-2009, David Beckett http://www.dajobe.org/
 
7
 * Copyright (C) 2007-2012, David Beckett http://www.dajobe.org/
8
8
 * 
9
9
 * This file is licensed under the following three licenses as alternatives:
10
10
 *   1. GNU Lesser General Public License (LGPL) V2.1 or any newer version
27
27
#include <curl/easy.h>
28
28
 
29
29
#include <mtwist_config.h>
30
 
 
31
 
#ifdef FLICKCURL_OAUTH
32
30
#include <mtwist.h>
33
 
#endif
34
31
 
35
32
#if defined (OFFLINE) && defined (CAPTURE)
36
33
#error "Cannot define both OFFLINE and CAPTURE"
110
107
 
111
108
/* flickcurl.c */
112
109
/* Prepare Flickr API request - GET or POST with URI parameters with auth */
113
 
int flickcurl_prepare(flickcurl *fc, const char* method, const char* parameters[][2], int count);
 
110
int flickcurl_prepare(flickcurl *fc, const char* method);
114
111
/* Prepare Flickr API request - GET or POST with URI parameters without auth */
115
 
int flickcurl_prepare_noauth(flickcurl *fc, const char* method, const char* parameters[][2], int count);
 
112
int flickcurl_prepare_noauth(flickcurl *fc, const char* method);
116
113
/* Prepare Flickr API request - POST with form-data parameters */
117
 
int flickcurl_prepare_upload(flickcurl *fc, const char* url, const char* upload_field, const char* upload_value, const char* parameters[][2], int count);
 
114
int flickcurl_prepare_upload(flickcurl *fc, const char* url, const char* upload_field, const char* upload_value);
118
115
 
119
116
/* Invoke Flickr API at URi prepared above and get back an XML document DOM */
120
117
xmlDocPtr flickcurl_invoke(flickcurl *fc);
156
153
 
157
154
char* flickcurl_call_get_one_string_field(flickcurl* fc, const char* key, const char* value, const char* method, const xmlChar* xpathExpr);
158
155
 
159
 
int flickcurl_append_photos_list_params(flickcurl_photos_list_params* list_params, const char* parameters[][2], int* count_p, const char** format_p);
 
156
int flickcurl_append_photos_list_params(flickcurl* fc, flickcurl_photos_list_params* list_params, const char** format_p);
 
157
 
 
158
void flickcurl_init_params(flickcurl *fc);
 
159
void flickcurl_add_param(flickcurl *fc, const char* key, const char* value);
 
160
void flickcurl_end_params(flickcurl *fc);
 
161
 
160
162
 
161
163
/* activity.c */
162
164
flickcurl_activity** flickcurl_build_activities(flickcurl* fc, xmlXPathContextPtr xpathCtx, const xmlChar* xpathExpr, int* activity_count_p);
256
258
/* video.c */
257
259
flickcurl_video* flickcurl_build_video(flickcurl* fc, xmlXPathContextPtr xpathCtx, const xmlChar* xpathExpr);
258
260
 
 
261
 
 
262
/* flickcurl_photos_search_params */
 
263
#define FLICKCURL_MAX_PARAM_COUNT 30
 
264
 
 
265
#define FLICKCURL_MAX_LIST_PARAM_COUNT 4
 
266
 
 
267
#define FLICKCURL_MAX_OAUTH_PARAM_COUNT 8
 
268
 
 
269
#define FLICKCURL_TOTAL_PARAM_COUNT (FLICKCURL_MAX_PARAM_COUNT + FLICKCURL_MAX_LIST_PARAM_COUNT + FLICKCURL_MAX_OAUTH_PARAM_COUNT + 1)
 
270
 
259
271
struct flickcurl_chunk_s {
260
272
  char* content;
261
273
  size_t size;
265
277
typedef struct flickcurl_chunk_s flickcurl_chunk;
266
278
 
267
279
 
268
 
#ifdef FLICKCURL_OAUTH
269
280
typedef struct {
270
281
  /* client credentials */
271
282
  char* client_key; /* AKA consumer key or the Flickr API key */
287
298
  size_t token_len;
288
299
  char* token_secret;
289
300
  size_t token_secret_len;
 
301
 
 
302
  /* username and user_nsid */
 
303
  char* username;
 
304
  size_t username_len;
 
305
  char* user_nsid;
 
306
  size_t user_nsid_len;
290
307
  
291
308
  /* callback URI or NULL for "oob" */
292
309
  const char* callback; /* always shared */
306
323
  unsigned char* data;
307
324
  size_t data_len;
308
325
} flickcurl_oauth_data;
309
 
#endif  
310
326
 
311
327
 
312
328
struct flickcurl_s {
353
369
   * operations can be done (in most cases).
354
370
   */
355
371
 
356
 
  /* Flickr shared secret - flickcurl_set_shared_secret() */
 
372
  /* Flickr legacy auth token secret - flickcurl_set_shared_secret() */
357
373
  char* secret;
358
374
 
359
 
  /* Flickr application/api key  - flickcurl_set_api_key() */
 
375
  /* Flickr application/api key  - flickcurl_set_api_key() 
 
376
   *
 
377
   * Not owned freed here - a pointer into od.client_key
 
378
   *
 
379
   * FIXME: remove at some point
 
380
   */
360
381
  char* api_key;
361
382
 
362
 
  /* Flickr authentication token - flickcurl_set_auth_token() */
 
383
  /* Flickr legacy auth token - flickcurl_set_auth_token() */
363
384
  char* auth_token;
364
385
 
365
386
  /* API call must be signed even if 'auth_token' is NULL - flickcurl_set_sign()
430
451
  /* OAuth access token Web Service URI */
431
452
  char *oauth_access_token_uri;
432
453
 
433
 
#if FLICKCURL_OAUTH
434
454
  /*  Used for OAuth nonce generation */
435
455
  mtwist* mt;
436
456
 
437
457
  flickcurl_oauth_data od;
438
 
#endif
 
458
 
 
459
  const char *parameters[FLICKCURL_TOTAL_PARAM_COUNT][2];
 
460
  int count;
439
461
};
440
462
 
441
463
struct flickcurl_serializer_s
449
471
void flickcurl_serializer_terminate(void);
450
472
 
451
473
 
452
 
#ifdef FLICKCURL_OAUTH
453
 
 
454
474
/* sha1.c */
455
475
#define SHA1_DIGEST_LENGTH 20
456
476
unsigned char* flickcurl_hmac_sha1(const void *data, size_t data_len, const void *key, size_t key_len);
457
477
 
458
478
 
 
479
/* legacy-auth.c */
 
480
int flickcurl_legacy_prepare_common(flickcurl *fc, const char* url, const char* method, const char* upload_field, const char* upload_value, int parameters_in_url, int need_auth);
 
481
 
459
482
/* oauth.c */
460
 
 
461
 
#define FLICKCURL_MAX_OAUTH_PARAM_COUNT 8
462
 
 
463
 
 
464
483
void flickcurl_oauth_free(flickcurl_oauth_data* od);
465
484
char* flickcurl_oauth_compute_signature(flickcurl_oauth_data* od, size_t* len_p);
466
 
int flickcurl_oauth_prepare_common(flickcurl *fc, const char* url, const char* method, const char* upload_field, const char* upload_value, const char* parameters[][2], int count, int parameters_in_url, int need_auth);
467
 
int flickcurl_oauth_request_token(flickcurl* fc);
468
 
char* flickcurl_oauth_get_authorize_uri(flickcurl* fc);
469
 
int flickcurl_oauth_access_token(flickcurl* fc, const char* verifier);
470
 
#endif
 
485
int flickcurl_oauth_prepare_common(flickcurl *fc, const char* url, const char* method, const char* upload_field, const char* upload_value, int parameters_in_url, int need_auth);