Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,18 @@
#include "ds3_request.h"
#include "ds3_net.h"

//The max size of an uint32_t should be 10 characters + NULL
static const char UNSIGNED_LONG_BASE_10[] = "4294967296";
static const unsigned int UNSIGNED_LONG_BASE_10_STR_LEN = sizeof(UNSIGNED_LONG_BASE_10) + 1;
//The max size of an uint64_t should be 20 characters + NULL
static const char UNSIGNED_LONG_LONG_BASE_10[] = "18446744073709551615";
static const unsigned int UNSIGNED_LONG_LONG_BASE_10_STR_LEN = sizeof(UNSIGNED_LONG_LONG_BASE_10) + 1;
#ifdef _WIN32
#include <io.h>
#ifndef PRIu64
#define PRIu64 "I64u"
#endif
#else
#include <inttypes.h>
#endif

//The max size of an uint32_t is 10 characters + NULL
//The max size of an uint64_t is 20 characters + NULL
#define STRING_BUFFER_SIZE 32

<#-- ********************************************* -->
<#-- Generate "_get_enum_str()" -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,17 @@
#include "ds3_utils.h"

#ifdef _WIN32
#include <io.h>
#include <io.h>
#ifndef PRIu64
#define PRIu64 "I64u"
#endif
#else
#include <inttypes.h>
#include <inttypes.h>
#endif


//The max size of an uint32_t should be 10 characters + NULL
static const char UNSIGNED_LONG_BASE_10[] = "4294967296";
static const unsigned int UNSIGNED_LONG_BASE_10_STR_LEN = sizeof(UNSIGNED_LONG_BASE_10) + 1;
//The max size of an uint64_t should be 20 characters + NULL
static const char UNSIGNED_LONG_LONG_BASE_10[] = "18446744073709551615";
static const unsigned int UNSIGNED_LONG_LONG_BASE_10_STR_LEN = sizeof(UNSIGNED_LONG_LONG_BASE_10) + 1;

//The max size of an uint32_t is 10 characters + NULL
//The max size of an uint64_t is 20 characters + NULL
#define STRING_BUFFER_SIZE 32

<#include "metadata.ftl"/>
<#include "xml_helpers.ftl"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ static ds3_error* _get_request_xml_nodes(
}

static xmlDocPtr _generate_xml_bulk_objects_list(const ds3_bulk_object_list_response* obj_list, object_list_type list_type, ds3_job_chunk_client_processing_order_guarantee order) {
char size_buff[UNSIGNED_LONG_LONG_BASE_10_STR_LEN];
char size_buff[STRING_BUFFER_SIZE];
xmlDocPtr doc;
ds3_bulk_object_response* obj;
xmlNodePtr objects_node, object_node;
Expand All @@ -93,7 +93,8 @@ static xmlDocPtr _generate_xml_bulk_objects_list(const ds3_bulk_object_list_resp

for (obj_index = 0; obj_index < obj_list->num_objects; obj_index++) {
obj = obj_list->objects[obj_index];
g_snprintf(size_buff, sizeof(char) * UNSIGNED_LONG_LONG_BASE_10_STR_LEN, "%" PRIu64, obj->length);
memset(size_buff, 0, sizeof(size_buff));
g_snprintf(size_buff, STRING_BUFFER_SIZE, "%" PRIu64, obj->length);

object_node = xmlNewNode(NULL, (xmlChar*) "Object");
xmlAddChild(objects_node, object_node);
Expand All @@ -110,7 +111,7 @@ static xmlDocPtr _generate_xml_bulk_objects_list(const ds3_bulk_object_list_resp
}

static xmlDocPtr _generate_xml_complete_mpu(const ds3_complete_multipart_upload_response* mpu_list) {
char size_buff[UNSIGNED_LONG_LONG_BASE_10_STR_LEN];
char size_buff[STRING_BUFFER_SIZE];
xmlDocPtr doc;
ds3_multipart_upload_part_response* part;
xmlNodePtr parts_node, part_node;
Expand All @@ -126,7 +127,7 @@ static xmlDocPtr _generate_xml_complete_mpu(const ds3_complete_multipart_upload_
part_node = xmlNewNode(NULL, (xmlChar*) "Part");
xmlAddChild(parts_node, part_node);

g_snprintf(size_buff, sizeof(char) * UNSIGNED_LONG_LONG_BASE_10_STR_LEN, "%d", part->part_number);
g_snprintf(size_buff, STRING_BUFFER_SIZE, "%d", part->part_number);
xmlNewTextChild(part_node, NULL, (xmlChar*) "PartNumber", (xmlChar*) size_buff);

xmlNewTextChild(part_node, NULL, (xmlChar*) "ETag", (xmlChar*) part->etag->value);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,23 +101,23 @@ static void _set_query_param_flag(const ds3_request* _request, const char* key,
}

static void _set_query_param_uint64_t(const ds3_request* _request, const char* key, uint64_t value) {
char string_buffer[UNSIGNED_LONG_LONG_BASE_10_STR_LEN];
char string_buffer[STRING_BUFFER_SIZE];
memset(string_buffer, 0, sizeof(string_buffer));
snprintf(string_buffer, sizeof(string_buffer), "%" PRIu64, value);
g_snprintf(string_buffer, sizeof(string_buffer), "%" PRIu64, value);
_set_query_param(_request, key, string_buffer);
}

static void _set_query_param_int(const ds3_request* _request, const char* key, int value) {
char string_buffer[UNSIGNED_LONG_BASE_10_STR_LEN];
char string_buffer[STRING_BUFFER_SIZE];
memset(string_buffer, 0, sizeof(string_buffer));
snprintf(string_buffer, sizeof(string_buffer), "%d", value);
g_snprintf(string_buffer, sizeof(string_buffer), "%d", value);
_set_query_param(_request, key, string_buffer);
}

static void _set_query_param_float(const ds3_request* _request, const char* key, float value) {
char string_buffer[UNSIGNED_LONG_BASE_10_STR_LEN];
char string_buffer[STRING_BUFFER_SIZE];
memset(string_buffer, 0, sizeof(string_buffer));
snprintf(string_buffer, sizeof(string_buffer), "%f", value);
g_snprintf(string_buffer, sizeof(string_buffer), "%f", value);
_set_query_param(_request, key, string_buffer);
}

Expand Down