Skip to content

Commit

Permalink
Fix printing of unsigned long long in a platform independant manner
Browse files Browse the repository at this point in the history
  • Loading branch information
DenverM80 committed Jul 11, 2017
1 parent 939308b commit 13c7823
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
15 changes: 12 additions & 3 deletions src/ds3_init_requests.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,15 @@
#include "ds3_request.h"
#include "ds3_net.h"

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

#define STRING_BUFFER_SIZE 32

static char* _get_ds3_bucket_acl_permission_str(ds3_bucket_acl_permission input) {
Expand Down Expand Up @@ -854,21 +863,21 @@ 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[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[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[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
8 changes: 6 additions & 2 deletions src/ds3_requests.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,12 @@
#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


Expand Down Expand Up @@ -427,6 +430,7 @@ 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];
memset(size_buff, 0, sizeof(size_buff));
g_snprintf(size_buff, STRING_BUFFER_SIZE, "%" PRIu64, obj->length);

object_node = xmlNewNode(NULL, (xmlChar*) "Object");
Expand Down

0 comments on commit 13c7823

Please sign in to comment.