-
Notifications
You must be signed in to change notification settings - Fork 2
/
flick.h
90 lines (69 loc) · 1.66 KB
/
flick.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#ifndef __FLICK_H
#define __FLICK_H
/* Flickr related URL format's. */
#define FLICKR_AUTH_STRING "http://api.flickr.com/services/rest/?api_key=%s&auth_token=%s&api_sig=%s&%s"
#define FLICKR_SIGNATURE_STRING "%sapi_key%sauth_token%s%s"
/*
* return type constants.
*/
#define FLICKR_STATUS_OK 1
#define FLICKR_STATUS_ERR 0
typedef struct {
int args_len;
int nr_iterations;
} table_stat;
/*
* macro to convert signature length
* into api call argument length.
*/
#define SIG2ARG(s) \
s.args_len + (s.nr_iterations * 2) - 1
/*
* For user credentials.
* 0. Auth Token
* 1. API Key
* 2. Key Secret
*/
typedef struct {
short on_off;
apr_hash_t *user;
} user_cred;
typedef struct {
char *auth_token;
char *api_key;
char *secret;
} api_key_secret;
/*
* following is used by the request
* handler.
*/
typedef struct {
char *api_response; /* 'api_response' is not controlled by apache's */
apr_size_t size; /* MM pool. So we need to de-allocate it using */
} mem_chunk; /* free() */
typedef struct {
char *my_uri;
int uri_len;
/* extracted from uri */
char *page;
char *user;
char *api_call;
/* curl fetched data */
mem_chunk mem;
char *raw_args;
char *raw_signature;
int offset_t;
int iterations;
/* credentials of the user requested */
api_key_secret *creds;
} page_data;
/* macros for accessing page data */
#define APINAM(pg) pg->api_call
#define SECRET(pg) pg->creds->secret
#define APIKEY(pg) pg->creds->api_key
#define AUTHTKN(pg) pg->creds->auth_token
#define RAWSIGN(pg) pg->raw_signature
#define SIGOFFT(pg) RAWSIGN(pg) + pg->offset_t
#define RAWARGS(pg) pg->raw_args
#define ARGOFFT(pg) RAWARGS(pg) + pg->offset_t
#endif