summaryrefslogtreecommitdiffstats
path: root/storage/maria/libmarias3/src/marias3.c
diff options
context:
space:
mode:
Diffstat (limited to 'storage/maria/libmarias3/src/marias3.c')
-rw-r--r--storage/maria/libmarias3/src/marias3.c50
1 files changed, 40 insertions, 10 deletions
diff --git a/storage/maria/libmarias3/src/marias3.c b/storage/maria/libmarias3/src/marias3.c
index 74d7233a..b146da55 100644
--- a/storage/maria/libmarias3/src/marias3.c
+++ b/storage/maria/libmarias3/src/marias3.c
@@ -52,7 +52,7 @@ static void locking_function(int mode, int n, const char *file, int line)
pthread_mutex_unlock(&(mutex_buf[n]));
}
-static int curl_needs_openssl_locking()
+static int curl_needs_openssl_locking(void)
{
curl_version_info_data *data = curl_version_info(CURLVERSION_NOW);
@@ -214,6 +214,8 @@ ms3_st *ms3_init(const char *s3key, const char *s3secret,
ms3->list_container.start = NULL;
ms3->list_container.pool_list = NULL;
ms3->list_container.pool_free = 0;
+ ms3->read_cb= 0;
+ ms3->user_data= 0;
ms3->iam_role = NULL;
ms3->role_key = NULL;
@@ -354,14 +356,16 @@ const char *ms3_server_error(ms3_st *ms3)
return ms3->last_error;
}
-void ms3_debug(void)
+void ms3_debug(int debug_state)
{
bool state = ms3debug_get();
- ms3debug_set(!state);
-
- if (state)
+ if (state != (bool) debug_state)
{
- ms3debug("enabling debug");
+ ms3debug_set((bool) debug_state);
+ if (debug_state)
+ {
+ ms3debug("enabling debug");
+ }
}
}
@@ -449,15 +453,23 @@ uint8_t ms3_get(ms3_st *ms3, const char *bucket, const char *key,
buf.data = NULL;
buf.length = 0;
- if (!ms3 || !bucket || !key || key[0] == '\0' || !data || !length)
+ if (!ms3 || !bucket || !key || key[0] == '\0')
+ {
+ return MS3_ERR_PARAMETER;
+ }
+ else if (!ms3->read_cb && (!data || !length))
{
return MS3_ERR_PARAMETER;
}
res = execute_request(ms3, MS3_CMD_GET, bucket, key, NULL, NULL, NULL, NULL, 0,
NULL, &buf);
- *data = buf.data;
- *length = buf.length;
+ if (!ms3->read_cb)
+ {
+ *data = buf.data;
+ *length = buf.length;
+ }
+
return res;
}
@@ -617,7 +629,7 @@ uint8_t ms3_set_option(ms3_st *ms3, ms3_set_option_t option, void *value)
return MS3_ERR_PARAMETER;
}
- ms3->list_version = protocol_version;
+ ms3->protocol_version = protocol_version;
break;
}
@@ -634,6 +646,24 @@ uint8_t ms3_set_option(ms3_st *ms3, ms3_set_option_t option, void *value)
ms3->port = port_number;
break;
}
+
+ case MS3_OPT_READ_CB:
+ {
+ if (!value)
+ {
+ return MS3_ERR_PARAMETER;
+ }
+
+ ms3->read_cb = value;
+ break;
+ }
+
+ case MS3_OPT_USER_DATA:
+ {
+ ms3->user_data = value;
+ break;
+ }
+
default:
return MS3_ERR_PARAMETER;
}