summaryrefslogtreecommitdiffstats
path: root/include/internal/json_enc.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/internal/json_enc.h')
-rw-r--r--include/internal/json_enc.h81
1 files changed, 41 insertions, 40 deletions
diff --git a/include/internal/json_enc.h b/include/internal/json_enc.h
index b5ee8361e0..9c13d0622d 100644
--- a/include/internal/json_enc.h
+++ b/include/internal/json_enc.h
@@ -7,8 +7,8 @@
* https://www.openssl.org/source/license.html
*/
-#ifndef JSON_ENC_H
-# define JSON_ENC_H
+#ifndef OSSL_JSON_ENC_H
+# define OSSL_JSON_ENC_H
# include <openssl/bio.h>
@@ -26,7 +26,7 @@ struct json_write_buf {
size_t alloc, cur;
};
-typedef struct json_enc_st {
+typedef struct ossl_json_enc_st {
uint32_t flags;
/* error: 1 if an error has occurred. */
/* state: current state. */
@@ -37,7 +37,7 @@ typedef struct json_enc_st {
unsigned char stack_small[16];
struct json_write_buf wbuf;
size_t stack_end_byte, stack_bytes;
-} JSON_ENC;
+} OSSL_JSON_ENC;
/*
* ossl_json_init
@@ -45,28 +45,29 @@ typedef struct json_enc_st {
*
* Initialises a JSON encoder.
*
- * If the flag JSON_FLAG_SEQ is passed, the output is in JSON-SEQ. The caller
- * should use the encoder as though it is encoding members of a JSON array (but
- * without calling ossl_json_array_begin() or ossl_json_array_end()). Each
- * top-level JSON item (e.g. JSON object) encoded will be separated correctly as
- * per the JSON-SEQ format.
+ * If the flag OSSL_JSON_FLAG_SEQ is passed, the output is in JSON-SEQ. The
+ * caller should use the encoder as though it is encoding members of a JSON
+ * array (but without calling ossl_json_array_begin() or ossl_json_array_end()).
+ * Each top-level JSON item (e.g. JSON object) encoded will be separated
+ * correctly as per the JSON-SEQ format.
*
- * If the flag JSON_FLAG_SEQ is not passed, the output is in JSON format.
- * Generally the caller should encode only a single output item (e.g.
- * a JSON object).
+ * If the flag OSSL_JSON_FLAG_SEQ is not passed, the output is in JSON format.
+ * Generally the caller should encode only a single output item (e.g. a JSON
+ * object).
*
- * By default, JSON output is maximally compact. If JSON_FLAG_PRETTY is set,
- * JSON/JSON-SEQ output is spaced for optimal human readability.
+ * By default, JSON output is maximally compact. If OSSL_JSON_FLAG_PRETTY is
+ * set, JSON/JSON-SEQ output is spaced for optimal human readability.
*
- * If JSON_FLAG_IJSON is set, integers outside the range `[-2**53 + 1, 2**53 -
- * 1]` are automatically converted to decimal strings before serialization.
+ * If OSSL_JSON_FLAG_IJSON is set, integers outside the range `[-2**53 + 1,
+ * 2**53 - 1]` are automatically converted to decimal strings before
+ * serialization.
*/
-#define JSON_FLAG_NONE 0
-#define JSON_FLAG_SEQ (1U << 0)
-#define JSON_FLAG_PRETTY (1U << 1)
-#define JSON_FLAG_IJSON (1U << 2)
+#define OSSL_JSON_FLAG_NONE 0
+#define OSSL_JSON_FLAG_SEQ (1U << 0)
+#define OSSL_JSON_FLAG_PRETTY (1U << 1)
+#define OSSL_JSON_FLAG_IJSON (1U << 2)
-int ossl_json_init(JSON_ENC *json, BIO *bio, uint32_t flags);
+int ossl_json_init(OSSL_JSON_ENC *json, BIO *bio, uint32_t flags);
/*
* ossl_json_cleanup
@@ -74,7 +75,7 @@ int ossl_json_init(JSON_ENC *json, BIO *bio, uint32_t flags);
*
* Destroys a JSON encoder.
*/
-void ossl_json_cleanup(JSON_ENC *json);
+void ossl_json_cleanup(OSSL_JSON_ENC *json);
/*
* ossl_json_reset
@@ -92,7 +93,7 @@ void ossl_json_cleanup(JSON_ENC *json);
*
* Automatically calls ossl_json_flush().
*/
-int ossl_json_reset(JSON_ENC *json);
+int ossl_json_reset(OSSL_JSON_ENC *json);
/*
* ossl_json_flush
@@ -103,7 +104,7 @@ int ossl_json_reset(JSON_ENC *json);
* autonomously as buffers are filled, but the caller must use this function
* to guarantee all data has been flushed.
*/
-int ossl_json_flush(JSON_ENC *json);
+int ossl_json_flush(OSSL_JSON_ENC *json);
/*
* ossl_json_flush_cleanup
@@ -113,7 +114,7 @@ int ossl_json_flush(JSON_ENC *json);
* ossl_json_cleanup regardless of the result. The result of the flush call is
* returned.
*/
-int ossl_json_flush_cleanup(JSON_ENC *json);
+int ossl_json_flush_cleanup(OSSL_JSON_ENC *json);
/*
* ossl_json_set_sink
@@ -121,7 +122,7 @@ int ossl_json_flush_cleanup(JSON_ENC *json);
*
* Changes the sink used by the JSON encoder.
*/
-int ossl_json_set_sink(JSON_ENC *json, BIO *bio);
+int ossl_json_set_sink(OSSL_JSON_ENC *json, BIO *bio);
/*
* ossl_json_in_error
@@ -143,7 +144,7 @@ int ossl_json_set_sink(JSON_ENC *json, BIO *bio);
* flushing. It is expected that errors will ordinarily be either caller errors
* (programming errors) or BIO errors.
*/
-int ossl_json_in_error(JSON_ENC *json);
+int ossl_json_in_error(OSSL_JSON_ENC *json);
/*
* JSON Builder Calls
@@ -172,54 +173,54 @@ int ossl_json_in_error(JSON_ENC *json);
*/
/* Begin a new JSON object. */
-void ossl_json_object_begin(JSON_ENC *json);
+void ossl_json_object_begin(OSSL_JSON_ENC *json);
/* End a JSON obejct. Must be matched with a call to ossl_json_object_begin(). */
-void ossl_json_object_end(JSON_ENC *json);
+void ossl_json_object_end(OSSL_JSON_ENC *json);
/* Begin a new JSON array. */
-void ossl_json_array_begin(JSON_ENC *json);
+void ossl_json_array_begin(OSSL_JSON_ENC *json);
/* End a JSON array. Must be matched with a call to ossl_json_array_end(). */
-void ossl_json_array_end(JSON_ENC *json);
+void ossl_json_array_end(OSSL_JSON_ENC *json);
/*
* Encode a JSON key within an object. Pass a zero-terminated string, which can
* be freed immediately following the call to this function.
*/
-void ossl_json_key(JSON_ENC *json, const char *key);
+void ossl_json_key(OSSL_JSON_ENC *json, const char *key);
/* Encode a JSON 'null' value. */
-void ossl_json_null(JSON_ENC *json);
+void ossl_json_null(OSSL_JSON_ENC *json);
/* Encode a JSON boolean value. */
-void ossl_json_bool(JSON_ENC *json, int value);
+void ossl_json_bool(OSSL_JSON_ENC *json, int value);
/* Encode a JSON integer from a uint64_t. */
-void ossl_json_u64(JSON_ENC *json, uint64_t value);
+void ossl_json_u64(OSSL_JSON_ENC *json, uint64_t value);
/* Encode a JSON integer from an int64_t. */
-void ossl_json_i64(JSON_ENC *json, int64_t value);
+void ossl_json_i64(OSSL_JSON_ENC *json, int64_t value);
/* Encode a JSON number from a 64-bit floating point value. */
-void ossl_json_f64(JSON_ENC *json, double value);
+void ossl_json_f64(OSSL_JSON_ENC *json, double value);
/*
* Encode a JSON UTF-8 string from a zero-terminated string. The string passed
* can be freed immediately following the call to this function.
*/
-void ossl_json_str(JSON_ENC *json, const char *str);
+void ossl_json_str(OSSL_JSON_ENC *json, const char *str);
/*
* Encode a JSON UTF-8 string from a string with the given length. The string
* passed can be freed immediately following the call to this function.
*/
-void ossl_json_str_len(JSON_ENC *json, const char *str, size_t str_len);
+void ossl_json_str_len(OSSL_JSON_ENC *json, const char *str, size_t str_len);
/*
* Encode binary data as a lowercase hex string. data_len is the data length in
* bytes.
*/
-void ossl_json_str_hex(JSON_ENC *json, const void *data, size_t data_len);
+void ossl_json_str_hex(OSSL_JSON_ENC *json, const void *data, size_t data_len);
#endif