00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #pragma once
00024 #ifndef __PBMSLIB_H__
00025 #define __PBMSLIB_H__
00026
00027 #ifdef __cplusplus
00028 extern "C" {
00029 #endif
00030
00031 #define MS_STANDARD_STORAGE 0 // BLOB data is stored in the repository.
00032 #define MS_CLOUD_STORAGE 1 // BLOB data is in S3 cloud storage.
00033
00034
00035 #define MS_CHECKSUM_TAG "PBMS_CHECKSUM"
00036 #define MS_ALIAS_TAG "PBMS_BLOB_ALIAS"
00037 #define MS_BLOB_INFO_REQUEST "PBMS_RETURN_HEADER_ONLY"
00038 #define MS_PING_REQUEST "PBMS_PING_CONNECTION"
00039 #define MS_BLOB_SIZE "PBMS_BLOB_SIZE"
00040 #define MS_LAST_ACCESS "PBMS_LAST_ACCESS"
00041 #define MS_ACCESS_COUNT "PBMS_ACCESS_COUNT"
00042 #define MS_CREATION_TIME "PBMS_CREATION_TIME"
00043 #define MS_BLOB_TYPE "PBMS_BLOB_TYPE"
00044
00045 #define MS_REQUEST_SIZE "PBMS_REQUEST_SIZE" // The number of bytes of BLOB data the client requests.
00046 #define MS_REQUEST_OFFSET "PBMS_REQUEST_OFFSET" // The offset into the BLOB that the client requests the data from.
00047
00048 #define MS_CLOUD_SERVER "PBMS_CLOUD_SERVER"
00049 #define MS_CLOUD_BUCKET "PBMS_CLOUD_BUCKET"
00050 #define MS_CLOUD_OBJECT_KEY "PBMS_CLOUD_OBJECT_KEY"
00051 #define MS_CLOUD_KEY "PBMS_CLOUD_KEY"
00052 #define MS_BLOB_SIGNATURE "PBMS_BLOB_SIGNATURE"
00053 #define MS_BLOB_DATE "PBMS_BLOB_DATE" // The date used when creating the signature.
00054
00055 #define MS_META_NAME_SIZE 32
00056 #define MS_META_VALUE_SIZE 1024
00057 #define MS_BLOB_ALIAS_SIZE MS_META_VALUE_SIZE
00058 #define MS_BLOB_URL_SIZE 200
00059
00060 #ifndef PBMS_PORT
00061 #define DEFAULT_PBMS_PORT 8080
00062 #else
00063 #define DEFAULT_PBMS_PORT PBMS_PORT
00064 #endif
00065
00066
00067 typedef void *PBMS;
00068
00069 typedef unsigned char pbms_bool;
00070
00071
00072 enum pbms_option
00073 {
00074 PBMS_OPTION_KEEP_ALIVE,
00075 PBMS_OPTION_TRANSMITION_TIMEOUT,
00076 PBMS_OPTION_HOST,
00077 PBMS_OPTION_PORT,
00078 PBMS_OPTION_DATABASE
00079 };
00080
00081 typedef size_t (* PBMS_READ_CALLBACK_FUNC) (void *caller_data, char *buffer, size_t size, pbms_bool reset);
00082 typedef size_t (* PBMS_WRITE_CALLBACK_FUNC) (void *caller_data, const char *buffer, size_t size, pbms_bool reset);
00083
00084 pbms_bool pbms_library_init();
00085 void pbms_library_end();
00086 PBMS pbms_connect(const char* host, unsigned int port, const char *database);
00087
00088
00089 void pbms_close(PBMS pbms);
00090 pbms_bool pbms_set_option(PBMS pbms, enum pbms_option option, const void *in_value);
00091 pbms_bool pbms_get_option(PBMS pbms, enum pbms_option option, void *out_value);
00092 int pbms_errno(PBMS pbms);
00093 const char *pbms_error(PBMS pbms);
00094 pbms_bool pbms_is_blob_reference(PBMS pbms, const char *ref);
00095 pbms_bool pbms_get_blob_size(PBMS pbms, const char *ref, size_t *size);
00096
00097
00098 pbms_bool pbms_add_metadata(PBMS pbms, const char *name, const char *value);
00099 void pbms_clear_metadata(PBMS pbms, const char *name);
00100 unsigned int pbms_reset_metadata(PBMS pbms);
00101 pbms_bool pbms_next_metadata(PBMS pbms, char *name, char *value, size_t *v_size);
00102 pbms_bool pbms_get_metadata_value(PBMS pbms, const char *name, char *buffer, size_t *size);
00103
00104 pbms_bool pbms_get_md5_digest(PBMS pbms, char *md5_digest);
00105
00106 pbms_bool pbms_put_data(PBMS pbms, const char *table, const char *checksum, char *ref, size_t size, const unsigned char *buffer);
00107 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);
00108
00109 pbms_bool pbms_get_data(PBMS pbms, const char *ref, unsigned char *buffer, size_t buffer_size);
00110 pbms_bool pbms_get_data_cb(PBMS pbms, const char *ref, PBMS_WRITE_CALLBACK_FUNC cb, void *caller_data);
00111
00112 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);
00113 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);
00114
00115 pbms_bool pbms_get_info(PBMS pbms, const char *ref);
00116
00117 #ifdef __cplusplus
00118 }
00119 #endif
00120 #endif // __PBMSLIB_H__