aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/serd/node.h46
-rw-r--r--include/serd/string.h2
-rw-r--r--src/env.c6
-rw-r--r--src/node.c46
-rw-r--r--src/serdi.c4
-rw-r--r--test/test_node.c6
-rw-r--r--test/test_uri.c23
7 files changed, 67 insertions, 66 deletions
diff --git a/include/serd/node.h b/include/serd/node.h
index 8f85a8d7..91550312 100644
--- a/include/serd/node.h
+++ b/include/serd/node.h
@@ -117,17 +117,21 @@ serd_node_from_substring(SerdNodeType type,
const char* SERD_NULLABLE str,
size_t len);
-/// Simple wrapper for serd_node_new_uri() to resolve a URI node
+/**
+ Create a new URI node from a node.
+*/
SERD_API SerdNode
-serd_node_new_uri_from_node(const SerdNode* SERD_NONNULL uri_node,
- const SerdURIView* SERD_NULLABLE base,
- SerdURIView* SERD_NULLABLE out);
+serd_new_uri_from_node(const SerdNode* SERD_NONNULL uri_node,
+ const SerdURIView* SERD_NULLABLE base,
+ SerdURIView* SERD_NULLABLE out);
-/// Simple wrapper for serd_node_new_uri() to resolve a URI string
+/**
+ Create a new URI node from a string.
+*/
SERD_API SerdNode
-serd_node_new_uri_from_string(const char* SERD_NULLABLE str,
- const SerdURIView* SERD_NULLABLE base,
- SerdURIView* SERD_NULLABLE out);
+serd_new_uri_from_string(const char* SERD_NULLABLE str,
+ const SerdURIView* SERD_NULLABLE base,
+ SerdURIView* SERD_NULLABLE out);
/**
Create a new file URI node from a file system path and optional hostname.
@@ -139,9 +143,9 @@ serd_node_new_uri_from_string(const char* SERD_NULLABLE str,
If `out` is not NULL, it will be set to the parsed URI.
*/
SERD_API SerdNode
-serd_node_new_file_uri(const char* SERD_NONNULL path,
- const char* SERD_NULLABLE hostname,
- SerdURIView* SERD_NULLABLE out);
+serd_new_file_uri(const char* SERD_NONNULL path,
+ const char* SERD_NULLABLE hostname,
+ SerdURIView* SERD_NULLABLE out);
/**
Create a new node by serialising `uri` into a new string.
@@ -154,9 +158,9 @@ serd_node_new_file_uri(const char* SERD_NONNULL path,
memory owned by the new returned node).
*/
SERD_API SerdNode
-serd_node_new_uri(const SerdURIView* SERD_NONNULL uri,
- const SerdURIView* SERD_NULLABLE base,
- SerdURIView* SERD_NULLABLE out);
+serd_new_uri(const SerdURIView* SERD_NONNULL uri,
+ const SerdURIView* SERD_NULLABLE base,
+ SerdURIView* SERD_NULLABLE out);
/**
Create a new node by serialising `uri` into a new relative URI.
@@ -171,10 +175,10 @@ serd_node_new_uri(const SerdURIView* SERD_NONNULL uri,
memory owned by the new returned node).
*/
SERD_API SerdNode
-serd_node_new_relative_uri(const SerdURIView* SERD_NONNULL uri,
- const SerdURIView* SERD_NULLABLE base,
- const SerdURIView* SERD_NULLABLE root,
- SerdURIView* SERD_NULLABLE out);
+serd_new_relative_uri(const SerdURIView* SERD_NONNULL uri,
+ const SerdURIView* SERD_NULLABLE base,
+ const SerdURIView* SERD_NULLABLE root,
+ SerdURIView* SERD_NULLABLE out);
/**
Create a new node by serialising `d` into an xsd:decimal string.
@@ -192,11 +196,11 @@ serd_node_new_relative_uri(const SerdURIView* SERD_NONNULL uri,
@param frac_digits The maximum number of digits after the decimal place.
*/
SERD_API SerdNode
-serd_node_new_decimal(double d, unsigned frac_digits);
+serd_new_decimal(double d, unsigned frac_digits);
/// Create a new node by serialising `i` into an xsd:integer string
SERD_API SerdNode
-serd_node_new_integer(int64_t i);
+serd_new_integer(int64_t i);
/**
Create a node by serialising `buf` into an xsd:base64Binary string.
@@ -209,7 +213,7 @@ serd_node_new_integer(int64_t i);
@param wrap_lines Wrap lines at 76 characters to conform to RFC 2045.
*/
SERD_API SerdNode
-serd_node_new_blob(const void* SERD_NONNULL buf, size_t size, bool wrap_lines);
+serd_new_blob(const void* SERD_NONNULL buf, size_t size, bool wrap_lines);
/**
Make a deep copy of `node`.
diff --git a/include/serd/string.h b/include/serd/string.h
index 373dfdf0..7652b05f 100644
--- a/include/serd/string.h
+++ b/include/serd/string.h
@@ -42,7 +42,7 @@ serd_strtod(const char* SERD_NONNULL str,
Decode a base64 string.
This function can be used to deserialise a blob node created with
- serd_node_new_blob().
+ serd_new_blob().
@param str Base64 string to decode.
@param len The length of `str`.
diff --git a/src/env.c b/src/env.c
index 31958e22..d11a5bab 100644
--- a/src/env.c
+++ b/src/env.c
@@ -78,7 +78,7 @@ serd_env_set_base_uri(SerdEnv* const env, const SerdNode* const uri)
// Resolve base URI and create a new node and URI for it
SerdURIView base_uri;
SerdNode base_uri_node =
- serd_node_new_uri_from_node(uri, &env->base_uri, &base_uri);
+ serd_new_uri_from_node(uri, &env->base_uri, &base_uri);
// Replace the current base URI
serd_node_free(&env->base_uri_node);
@@ -144,7 +144,7 @@ serd_env_set_prefix(SerdEnv* const env,
// Resolve relative URI and create a new node and URI for it
SerdURIView abs_uri;
SerdNode abs_uri_node =
- serd_node_new_uri_from_node(uri, &env->base_uri, &abs_uri);
+ serd_new_uri_from_node(uri, &env->base_uri, &abs_uri);
// Set prefix to resolved (absolute) URI
serd_env_add(env, name, &abs_uri_node);
@@ -230,7 +230,7 @@ serd_env_expand_node(const SerdEnv* const env, const SerdNode* const node)
break;
case SERD_URI: {
SerdURIView ignored;
- return serd_node_new_uri_from_node(node, &env->base_uri, &ignored);
+ return serd_new_uri_from_node(node, &env->base_uri, &ignored);
}
case SERD_CURIE: {
SerdStringView prefix;
diff --git a/src/node.c b/src/node.c
index 803f2c9b..db814233 100644
--- a/src/node.c
+++ b/src/node.c
@@ -107,28 +107,28 @@ serd_node_equals(const SerdNode* const a, const SerdNode* const b)
}
SerdNode
-serd_node_new_uri_from_node(const SerdNode* const uri_node,
- const SerdURIView* const base,
- SerdURIView* const out)
+serd_new_uri_from_node(const SerdNode* const uri_node,
+ const SerdURIView* const base,
+ SerdURIView* const out)
{
return (uri_node->type == SERD_URI && uri_node->buf)
- ? serd_node_new_uri_from_string(uri_node->buf, base, out)
+ ? serd_new_uri_from_string(uri_node->buf, base, out)
: SERD_NODE_NULL;
}
SerdNode
-serd_node_new_uri_from_string(const char* const str,
- const SerdURIView* const base,
- SerdURIView* const out)
+serd_new_uri_from_string(const char* const str,
+ const SerdURIView* const base,
+ SerdURIView* const out)
{
if (!str || str[0] == '\0') {
// Empty URI => Base URI, or nothing if no base is given
- return base ? serd_node_new_uri(base, NULL, out) : SERD_NODE_NULL;
+ return base ? serd_new_uri(base, NULL, out) : SERD_NODE_NULL;
}
SerdURIView uri;
serd_uri_parse(str, &uri);
- return serd_node_new_uri(&uri, base, out); // Resolve/Serialise
+ return serd_new_uri(&uri, base, out); // Resolve/Serialise
}
static bool
@@ -178,9 +178,9 @@ is_dir_sep(const char c)
}
SerdNode
-serd_node_new_file_uri(const char* const path,
- const char* const hostname,
- SerdURIView* const out)
+serd_new_file_uri(const char* const path,
+ const char* const hostname,
+ SerdURIView* const out)
{
const size_t path_len = strlen(path);
const size_t hostname_len = hostname ? strlen(hostname) : 0;
@@ -229,9 +229,9 @@ serd_node_new_file_uri(const char* const path,
}
SerdNode
-serd_node_new_uri(const SerdURIView* const uri,
- const SerdURIView* const base,
- SerdURIView* const out)
+serd_new_uri(const SerdURIView* const uri,
+ const SerdURIView* const base,
+ SerdURIView* const out)
{
SerdURIView abs_uri = *uri;
if (base) {
@@ -255,10 +255,10 @@ serd_node_new_uri(const SerdURIView* const uri,
}
SerdNode
-serd_node_new_relative_uri(const SerdURIView* const uri,
- const SerdURIView* const base,
- const SerdURIView* const root,
- SerdURIView* const out)
+serd_new_relative_uri(const SerdURIView* const uri,
+ const SerdURIView* const base,
+ const SerdURIView* const root,
+ SerdURIView* const out)
{
const size_t uri_len = serd_uri_string_length(uri);
const size_t base_len = serd_uri_string_length(base);
@@ -286,7 +286,7 @@ serd_digits(const double abs)
}
SerdNode
-serd_node_new_decimal(const double d, const unsigned frac_digits)
+serd_new_decimal(const double d, const unsigned frac_digits)
{
if (isnan(d) || isinf(d)) {
return SERD_NODE_NULL;
@@ -341,7 +341,7 @@ serd_node_new_decimal(const double d, const unsigned frac_digits)
}
SerdNode
-serd_node_new_integer(const int64_t i)
+serd_new_integer(const int64_t i)
{
uint64_t abs_i = (uint64_t)((i < 0) ? -i : i);
const unsigned digits = serd_digits((double)abs_i);
@@ -366,9 +366,7 @@ serd_node_new_integer(const int64_t i)
}
SerdNode
-serd_node_new_blob(const void* const buf,
- const size_t size,
- const bool wrap_lines)
+serd_new_blob(const void* const buf, const size_t size, const bool wrap_lines)
{
const size_t len = serd_base64_get_length(size, wrap_lines);
char* const str = (char*)calloc(len + 2, 1);
diff --git a/src/serdi.c b/src/serdi.c
index baa19a36..81ca35c5 100644
--- a/src/serdi.c
+++ b/src/serdi.c
@@ -334,9 +334,9 @@ main(int argc, char** argv)
SerdURIView base_uri = SERD_URI_NULL;
SerdNode base = SERD_NODE_NULL;
if (a < argc) { // Base URI given on command line
- base = serd_node_new_uri_from_string((const char*)argv[a], NULL, &base_uri);
+ base = serd_new_uri_from_string((const char*)argv[a], NULL, &base_uri);
} else if (from_file && in_fd != stdin) { // Use input file URI
- base = serd_node_new_file_uri(input, NULL, &base_uri);
+ base = serd_new_file_uri(input, NULL, &base_uri);
}
FILE* const out_fd = stdout;
diff --git a/test/test_node.c b/test/test_node.c
index a1473e7a..21ef6feb 100644
--- a/test/test_node.c
+++ b/test/test_node.c
@@ -80,7 +80,7 @@ test_double_to_node(void)
NULL};
for (size_t i = 0; i < sizeof(dbl_test_nums) / sizeof(double); ++i) {
- SerdNode node = serd_node_new_decimal(dbl_test_nums[i], 8);
+ SerdNode node = serd_new_decimal(dbl_test_nums[i], 8);
const bool pass = (node.buf && dbl_test_strs[i])
? !strcmp(node.buf, dbl_test_strs[i])
: (node.buf == dbl_test_strs[i]);
@@ -102,7 +102,7 @@ test_integer_to_node(void)
"0", "0", "-23", "23", "-12340", "1000", "-1000"};
for (size_t i = 0; i < N_TEST_NUMS; ++i) {
- SerdNode node = serd_node_new_integer(int_test_nums[i]);
+ SerdNode node = serd_new_integer(int_test_nums[i]);
assert(!strcmp(node.buf, int_test_strs[i]));
assert(node.n_bytes == strlen(node.buf));
serd_node_free(&node);
@@ -120,7 +120,7 @@ test_blob_to_node(void)
data[i] = (uint8_t)((size + i) % 256);
}
- SerdNode blob = serd_node_new_blob(data, size, size % 5);
+ SerdNode blob = serd_new_blob(data, size, size % 5);
assert(blob.n_bytes == strlen(blob.buf));
diff --git a/test/test_uri.c b/test/test_uri.c
index 65e12490..d3ba5514 100644
--- a/test/test_uri.c
+++ b/test/test_uri.c
@@ -44,7 +44,7 @@ test_file_uri(const char* const hostname,
expected_path = path;
}
- SerdNode node = serd_node_new_file_uri(path, hostname, 0);
+ SerdNode node = serd_new_file_uri(path, hostname, 0);
char* out_hostname = NULL;
char* out_path = serd_file_uri_parse(node.buf, &out_hostname);
assert(!strcmp(node.buf, expected_uri));
@@ -114,14 +114,14 @@ test_uri_parsing(void)
static void
test_uri_from_string(void)
{
- SerdNode nonsense = serd_node_new_uri_from_string(NULL, NULL, NULL);
+ SerdNode nonsense = serd_new_uri_from_string(NULL, NULL, NULL);
assert(nonsense.type == SERD_NOTHING);
SerdURIView base_uri;
SerdNode base =
- serd_node_new_uri_from_string("http://example.org/", NULL, &base_uri);
- SerdNode nil = serd_node_new_uri_from_string(NULL, &base_uri, NULL);
- SerdNode nil2 = serd_node_new_uri_from_string("", &base_uri, NULL);
+ serd_new_uri_from_string("http://example.org/", NULL, &base_uri);
+ SerdNode nil = serd_new_uri_from_string(NULL, &base_uri, NULL);
+ SerdNode nil2 = serd_new_uri_from_string("", &base_uri, NULL);
assert(nil.type == SERD_URI);
assert(!strcmp(nil.buf, base.buf));
assert(nil2.type == SERD_URI);
@@ -154,19 +154,18 @@ check_relative_uri(const char* const uri_string,
SerdURIView base = SERD_URI_NULL;
SerdURIView result = SERD_URI_NULL;
- SerdNode uri_node = serd_node_new_uri_from_string(uri_string, NULL, &uri);
- SerdNode base_node = serd_node_new_uri_from_string(base_string, NULL, &base);
+ SerdNode uri_node = serd_new_uri_from_string(uri_string, NULL, &uri);
+ SerdNode base_node = serd_new_uri_from_string(base_string, NULL, &base);
SerdNode result_node = SERD_NODE_NULL;
if (root_string) {
- SerdURIView root = SERD_URI_NULL;
- SerdNode root_node =
- serd_node_new_uri_from_string(root_string, NULL, &root);
+ SerdURIView root = SERD_URI_NULL;
+ SerdNode root_node = serd_new_uri_from_string(root_string, NULL, &root);
- result_node = serd_node_new_relative_uri(&uri, &base, &root, &result);
+ result_node = serd_new_relative_uri(&uri, &base, &root, &result);
serd_node_free(&root_node);
} else {
- result_node = serd_node_new_relative_uri(&uri, &base, NULL, &result);
+ result_node = serd_new_relative_uri(&uri, &base, NULL, &result);
}
assert(!strcmp((const char*)result_node.buf, expected_string));