~ubuntu-branches/ubuntu/vivid/cctools/vivid

« back to all changes in this revision

Viewing changes to s3tools/src/s3c_util.h

  • Committer: Bazaar Package Importer
  • Author(s): Michael Hanke
  • Date: 2011-05-07 09:05:00 UTC
  • Revision ID: james.westby@ubuntu.com-20110507090500-lqpmdtwndor6e7os
Tags: upstream-3.3.2
ImportĀ upstreamĀ versionĀ 3.3.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
Copyright (C) 2010- The University of Notre Dame
 
3
This software is distributed under the GNU General Public License.
 
4
See the file COPYING for details.
 
5
*/
 
6
#ifndef S3C_UTIL_H_
 
7
#define S3C_UTIL_H_
 
8
 
 
9
#include <md5.h>
 
10
#include <time.h>
 
11
 
 
12
#define ACCESS_KEY_ID_LENGTH 21
 
13
#define ACCESS_KEY_LENGTH 41
 
14
#define AWS_CANONICAL_ID_LENGTH 65
 
15
#define MAX_KEY_LENGTH 1024
 
16
#define HEADER_LINE_MAX 10240
 
17
 
 
18
enum s3_header_type {
 
19
        S3_HEADER_CUSTOM,
 
20
        S3_HEADER_AMZ_ACL,
 
21
        S3_HEADER_AMZ_MFA
 
22
};
 
23
 
 
24
struct s3_header_object {
 
25
        int type;
 
26
        char *custom_type;
 
27
        char *value;
 
28
};
 
29
 
 
30
struct amz_metadata_object {
 
31
        char type[MAX_KEY_LENGTH];
 
32
        char value[MAX_KEY_LENGTH];
 
33
};
 
34
 
 
35
enum amz_base_perm {
 
36
        AMZ_PERM_PRIVATE,
 
37
        AMZ_PERM_PUBLIC_READ,
 
38
        AMZ_PERM_PUBLIC_WRITE,
 
39
        AMZ_PERM_AUTH_READ,
 
40
        AMZ_PERM_BUCKET_READ,
 
41
        AMZ_PERM_BUCKET_FULL
 
42
};
 
43
 
 
44
 
 
45
enum s3_message_type {
 
46
        S3_MESG_GET,
 
47
        S3_MESG_POST,
 
48
        S3_MESG_PUT,
 
49
        S3_MESG_DELETE,
 
50
        S3_MESG_HEAD,
 
51
        S3_MESG_COPY
 
52
};
 
53
 
 
54
struct s3_message {
 
55
        enum s3_message_type type;
 
56
        char *path;
 
57
        char *bucket;
 
58
        char *content_md5;
 
59
        char *content_type;
 
60
        time_t date;
 
61
        struct list* amz_headers;
 
62
        int expect;
 
63
 
 
64
        int content_length;
 
65
        char authorization[55];
 
66
};
 
67
 
 
68
struct s3_dirent_object {
 
69
        char key[MAX_KEY_LENGTH];
 
70
        time_t last_modified;
 
71
        char digest[MD5_DIGEST_LENGTH];
 
72
        int size;
 
73
        char owner[AWS_CANONICAL_ID_LENGTH];
 
74
        char *display_name;
 
75
        struct list *metadata;
 
76
};
 
77
 
 
78
int s3_set_endpoint(const char *target);
 
79
struct s3_header_object* s3_new_header_object(enum s3_header_type type, const char* custom_type, const char* value);
 
80
const char * s3_get_header(enum s3_header_type type, const char* custom_type);
 
81
int s3_header_comp(const void *a, const void *b);
 
82
int sign_message(struct s3_message* mesg, const char* user, const char * key);
 
83
int s3_message_to_string(struct s3_message *mesg, char** text);
 
84
 
 
85
#endif
 
86