~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/pbms/src/pbmslib.h

  • Committer: Stewart Smith
  • Date: 2010-07-20 16:36:01 UTC
  • mfrom: (1638.7.6)
  • mto: (1638.9.6) (1685.1.5 build)
  • mto: This revision was merged to the branch mainline in revision 1688.
  • Revision ID: stewart@flamingspork.com-20100720163601-252o9fljtutp1gxa
Merged bug600635-table-proto-default-null-false into varchar-text-keylength-in-proto-as-characters-not-bytes.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* Copyright (c) 2008 PrimeBase Technologies GmbH, Germany
 
2
 *
 
3
 *  PrimeBase Media Stream (PBMS)
 
4
 *
 
5
 * This program is free software; you can redistribute it and/or modify
 
6
 * it under the terms of the GNU Lesser General Public License as published by
 
7
 * the Free Software Foundation; either version 2 of the License, or
 
8
 * (at your option) any later version.
 
9
 *
 
10
 * This program is distributed in the hope that it will be useful,
 
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
13
 * GNU Lesser General Public License for more details.
 
14
 *
 
15
 * You should have received a copy of the GNU Lesser General Public License
 
16
 * along with this program; if not, write to the Free Software
 
17
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 
18
 *
 
19
 * 2008-09-10   Barry Leslie
 
20
 *
 
21
 * H&G2JCtL
 
22
 */
 
23
#ifndef __PBMSLIB_H__
 
24
#define __PBMSLIB_H__
 
25
 
 
26
#ifdef __cplusplus
 
27
extern "C" {
 
28
#endif
 
29
 
 
30
#define MS_STANDARD_STORAGE             0       // BLOB data is stored in the repository.
 
31
#define MS_CLOUD_STORAGE                1       // BLOB data is in S3 cloud storage.
 
32
 
 
33
/*<DRIZZLE>*/
 
34
#define MS_CHECKSUM_TAG       "PBMS_CHECKSUM"
 
35
#define MS_ALIAS_TAG          "PBMS_BLOB_ALIAS"
 
36
#define MS_BLOB_INFO_REQUEST    "PBMS_RETURN_HEADER_ONLY"
 
37
#define MS_PING_REQUEST       "PBMS_PING_CONNECTION"
 
38
#define MS_BLOB_SIZE          "PBMS_BLOB_SIZE"
 
39
#define MS_LAST_ACCESS        "PBMS_LAST_ACCESS"
 
40
#define MS_ACCESS_COUNT       "PBMS_ACCESS_COUNT"
 
41
#define MS_CREATION_TIME      "PBMS_CREATION_TIME"
 
42
#define MS_BLOB_TYPE          "PBMS_BLOB_TYPE"
 
43
 
 
44
#define MS_REQUEST_SIZE       "PBMS_REQUEST_SIZE"     // The number of bytes of BLOB data the client requests.
 
45
#define MS_REQUEST_OFFSET     "PBMS_REQUEST_OFFSET"   // The offset into the BLOB that the client requests the data from.
 
46
 
 
47
#define MS_CLOUD_SERVER       "PBMS_CLOUD_SERVER"
 
48
#define MS_CLOUD_BUCKET       "PBMS_CLOUD_BUCKET"
 
49
#define MS_CLOUD_OBJECT_KEY             "PBMS_CLOUD_OBJECT_KEY"
 
50
#define MS_CLOUD_KEY          "PBMS_CLOUD_KEY"
 
51
#define MS_BLOB_SIGNATURE     "PBMS_BLOB_SIGNATURE"
 
52
#define MS_BLOB_DATE          "PBMS_BLOB_DATE"  // The date used when creating the signature.
 
53
 
 
54
#define MS_META_NAME_SIZE               32
 
55
#define MS_META_VALUE_SIZE              1024
 
56
#define MS_BLOB_ALIAS_SIZE              MS_META_VALUE_SIZE
 
57
#define MS_BLOB_URL_SIZE                200
 
58
 
 
59
#ifndef PBMS_PORT
 
60
#define DEFAULT_PBMS_PORT 8080
 
61
#else
 
62
#define DEFAULT_PBMS_PORT PBMS_PORT
 
63
#endif
 
64
 
 
65
/* PBMS handle types. */
 
66
typedef void *PBMS;                             // A connection handle.
 
67
 
 
68
typedef unsigned char pbms_bool;
 
69
 
 
70
/* options for pbms_set_option() and pbms_get_option() */
 
71
enum pbms_option                                                /*: Parameter type      |       Information                                                                                                                                                                                                             */
 
72
{
 
73
  PBMS_OPTION_KEEP_ALIVE,                               /*: unsigned int*       |       A boolean value indicating if the keep_alive flag should be set on HTTP requests.(Defalt = false)       */
 
74
  PBMS_OPTION_TRANSMITION_TIMEOUT,              /*: unsigned int*       |       If greater than zero this sets a limit to how long a blob transfer can take.  (Defalt = 0)                                              */
 
75
  PBMS_OPTION_HOST,                                             /*: (const char *)*     |       The connection's Media Stream server host IP address. (Read Only)                                                                                               */
 
76
  PBMS_OPTION_PORT,                                             /*: unsigned int*       |       The connection's Media Stream server host port number. (Read Only)                                                                                              */
 
77
  PBMS_OPTION_DATABASE                                  /*: (const char *)*     |       The connection's associated database.                                                                                                                                                   */
 
78
};
 
79
 
 
80
typedef size_t (* PBMS_READ_CALLBACK_FUNC) (void *caller_data, char *buffer, size_t size, pbms_bool reset);
 
81
typedef size_t (* PBMS_WRITE_CALLBACK_FUNC) (void *caller_data, const char *buffer, size_t size, pbms_bool reset);
 
82
 
 
83
pbms_bool pbms_library_init();
 
84
void    pbms_library_end();
 
85
PBMS pbms_connect(const char* host, unsigned int port, const char *database);
 
86
 
 
87
 
 
88
void pbms_close(PBMS pbms);
 
89
pbms_bool pbms_set_option(PBMS pbms, enum pbms_option option, const void *in_value);
 
90
pbms_bool pbms_get_option(PBMS pbms, enum pbms_option option, void *out_value);
 
91
int pbms_errno(PBMS pbms);
 
92
const char *pbms_error(PBMS pbms);
 
93
pbms_bool pbms_is_blob_reference(PBMS pbms, const char *ref);
 
94
pbms_bool pbms_get_blob_size(PBMS pbms, const char *ref, size_t *size);
 
95
 
 
96
/* Metadata related functions. */
 
97
pbms_bool pbms_add_metadata(PBMS pbms, const char *name, const char *value);
 
98
void pbms_clear_metadata(PBMS pbms, const char *name);  //If name is NULL all metadata associaed with the connection is removed.
 
99
unsigned int pbms_reset_metadata(PBMS pbms);                    //Resets the metadata cursor for downloaded metadata.
 
100
pbms_bool pbms_next_metadata(PBMS pbms, char *name, char *value, size_t *v_size);
 
101
pbms_bool pbms_get_metadata_value(PBMS pbms, const char *name, char *buffer, size_t *size);
 
102
 
 
103
pbms_bool pbms_get_md5_digest(PBMS pbms, char *md5_digest); 
 
104
 
 
105
pbms_bool pbms_put_data(PBMS pbms, const char *table, const char *checksum, char *ref, size_t size, const unsigned char *buffer);
 
106
pbms_bool pbms_put_data_cb(PBMS pbms, const char *table, const char *checksum, char *ref, size_t size, PBMS_READ_CALLBACK_FUNC cb, void *caller_data);
 
107
 
 
108
pbms_bool pbms_get_data(PBMS pbms, const char *ref, unsigned char *buffer, size_t buffer_size);
 
109
pbms_bool pbms_get_data_cb(PBMS pbms, const char *ref, PBMS_WRITE_CALLBACK_FUNC cb, void *caller_data);
 
110
 
 
111
pbms_bool pbms_get_data_range(PBMS pbms, const char *ref, size_t start_offset, size_t end_offset, unsigned char *buffer, size_t buffer_size, size_t *data_size);
 
112
pbms_bool pbms_get_data_range_cb(PBMS pbms, const char *ref, size_t start_offset, size_t end_offset, PBMS_WRITE_CALLBACK_FUNC cb, void *caller_data);
 
113
 
 
114
pbms_bool pbms_get_info(PBMS pbms, const char *ref);
 
115
 
 
116
#ifdef __cplusplus
 
117
}
 
118
#endif
 
119
#endif // __PBMSLIB_H__