Imported Upstream version 2.6.0p2
[debian/amanda] / device-src / s3-device.h
1 /*
2  * Copyright (c) 2005 Zmanda, Inc.  All Rights Reserved.
3  * 
4  * This library is free software; you can redistribute it and/or modify it
5  * under the terms of the GNU Lesser General Public License version 2.1 as 
6  * published by the Free Software Foundation.
7  * 
8  * This library is distributed in the hope that it will be useful, but
9  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
10  * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
11  * License for more details.
12  * 
13  * You should have received a copy of the GNU Lesser General Public License
14  * along with this library; if not, write to the Free Software Foundation,
15  * Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA.
16  * 
17  * Contact information: Zmanda Inc., 505 N Mathlida Ave, Suite 120
18  * Sunnyvale, CA 94085, USA, or: http://www.zmanda.com
19  */
20
21 #ifndef __S3_DEVICE_H__
22 #define __S3_DEVICE_H__
23 #include <glib.h>
24 #include <curl/curl.h>
25 #include <glib-object.h>
26 #include "s3.h"
27
28 /*
29  * Constants
30  */
31
32 /*
33  * Type checking and casting macros
34  */
35 #define TYPE_S3_DEVICE  (s3_device_get_type())
36 #define S3_DEVICE(obj)  G_TYPE_CHECK_INSTANCE_CAST((obj), s3_device_get_type(), S3Device)
37 #define S3_DEVICE_CONST(obj)    G_TYPE_CHECK_INSTANCE_CAST((obj), s3_device_get_type(), S3Device const)
38 #define S3_DEVICE_CLASS(klass)  G_TYPE_CHECK_CLASS_CAST((klass), s3_device_get_type(), S3DeviceClass)
39 #define IS_S3_DEVICE(obj)       G_TYPE_CHECK_INSTANCE_TYPE((obj), s3_device_get_type ())
40
41 #define S3_DEVICE_GET_CLASS(obj)        G_TYPE_INSTANCE_GET_CLASS((obj), s3_device_get_type(), S3DeviceClass)
42
43 /*
44  * Main object structure
45  */
46 typedef struct _S3MetadataFile S3MetadataFile;
47
48 #ifndef __TYPEDEF_S3_DEVICE__
49 #define __TYPEDEF_S3_DEVICE__
50 typedef struct _S3Device S3Device;
51 #endif
52 struct _S3Device {
53     Device __parent__;
54     
55     /* The "easy" curl handle we use to access Amazon S3 */
56     S3Handle *s3;
57
58     /* S3 access information */
59     char *bucket;
60     char *prefix;
61
62     /* The S3 access information. */
63     char *secret_key;
64     char *access_key;
65 #ifdef WANT_DEVPAY
66     char *user_token;
67 #endif
68
69     /* a cache for unsuccessful reads (where we get the file but the caller
70      * doesn't have space for it or doesn't want it), where we expect the
71      * next call will request the same file.
72      */
73     char *cached_buf;
74     char *cached_key;
75     int cached_size;
76
77     /* Produce verbose output? */
78     gboolean verbose;
79     /* Set to FALSE once s3_device_open_device is finished. */
80     gboolean initializing;
81 };
82
83 /*
84  * Class definition
85  */
86 typedef struct _S3DeviceClass S3DeviceClass;
87 struct _S3DeviceClass {
88     DeviceClass __parent__;
89 };
90
91
92 /*
93  * Public methods
94  */
95 GType   s3_device_get_type      (void);
96 void    s3_device_register    (void);
97
98 #endif