Skip to content

Commit

Permalink
[#468] Support BASE64 as a value
Browse files Browse the repository at this point in the history
  • Loading branch information
jesperpedersen committed Sep 21, 2024
1 parent 1ad9898 commit 4d2868e
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 11 deletions.
1 change: 1 addition & 0 deletions src/include/value.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ enum value_type {
ValueString,
ValueFloat,
ValueDouble,
ValueBASE64,
ValueJSON,
ValueDeque,
ValueART,
Expand Down
2 changes: 1 addition & 1 deletion src/libpgagroal/json.c
Original file line number Diff line number Diff line change
Expand Up @@ -564,6 +564,7 @@ type_allowed(enum value_type type)
case ValueUInt64:
case ValueBool:
case ValueString:
case ValueBASE64:
case ValueFloat:
case ValueDouble:
case ValueJSON:
Expand All @@ -584,4 +585,3 @@ array_to_string(struct json* array, int32_t format, char* tag, int indent)
{
return pgagroal_deque_to_string(array->elements, format, tag, indent);
}

20 changes: 10 additions & 10 deletions src/libpgagroal/value.c
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,9 @@ pgagroal_value_create(enum value_type type, uintptr_t data, struct value** value
case ValueString:
val->to_string = string_to_string_cb;
break;
case ValueBASE64:
val->to_string = string_to_string_cb;
break;
case ValueJSON:
val->to_string = json_to_string_cb;
break;
Expand All @@ -131,16 +134,13 @@ pgagroal_value_create(enum value_type type, uintptr_t data, struct value** value
{
case ValueString:
{
char* orig = NULL;
char* str = NULL;

orig = (char*) data;
if (orig != NULL)
{
str = pgagroal_append(str, orig);
}

val->data = (uintptr_t) str;
val->data = (uintptr_t)pgagroal_append(NULL, (char*)data);
val->destroy_data = free_destroy_cb;
break;
}
case ValueBASE64:
{
val->data = (uintptr_t)pgagroal_append(NULL, (char*)data);
val->destroy_data = free_destroy_cb;
break;
}
Expand Down

0 comments on commit 4d2868e

Please sign in to comment.