Skip to content

Commit

Permalink
Add k5_json_array_fmt and use it in export_cred.c
Browse files Browse the repository at this point in the history
Add a template-based array constructor for convenient marshalling of
structured values as JSON array values.  Use it to simplify
export_cred.c.
  • Loading branch information
greghudson committed Feb 13, 2013
1 parent 61116eb commit 80f53c8
Show file tree
Hide file tree
Showing 5 changed files with 412 additions and 261 deletions.
18 changes: 18 additions & 0 deletions src/include/k5-json.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,9 @@ typedef struct k5_json_null_st *k5_json_null;

int k5_json_null_create(k5_json_null *null_out);

/* Create a null value as a k5_json_value, for polymorphic convenience. */
int k5_json_null_create_val(k5_json_value *val_out);

/*
* Boolean
*/
Expand All @@ -135,6 +138,21 @@ void k5_json_array_set(k5_json_array array, size_t idx, k5_json_value val);
* reference count. The caller must check idx against the array length. */
k5_json_value k5_json_array_get(k5_json_array array, size_t idx);

/*
* Create an array from a template and a variable argument list. template
* characters are:
* v: a k5_json_value argument is read, retained, and stored
* n: no argument is read; a null value is stored
* b: an int argument is read and stored as a boolean value
* i: an int argument is read and stored as a number value
* L: a long long argument is read and stored as a number value
* s: a const char * argument is read and stored as a null or string value
* B: const void * and size_t arguments are read and stored as a base64
* string value
*/
int
k5_json_array_fmt(k5_json_array *array_out, const char *template, ...);

/*
* Object
*/
Expand Down
Loading

0 comments on commit 80f53c8

Please sign in to comment.