aboutsummaryrefslogtreecommitdiffstats
path: root/src/serdi.c
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2016-03-16 16:21:20 -0400
committerDavid Robillard <d@drobilla.net>2021-03-07 15:32:23 -0500
commita29581d3ba664175c459e20e6c86be09707fde6e (patch)
treed11253ca88b09d7a768740b00332a4d780e3852d /src/serdi.c
parent6e856d3e7a9c3162b9af350d5cec8a3f6bb94ee2 (diff)
downloadserd-a29581d3ba664175c459e20e6c86be09707fde6e.tar.gz
serd-a29581d3ba664175c459e20e6c86be09707fde6e.tar.bz2
serd-a29581d3ba664175c459e20e6c86be09707fde6e.zip
Use char* for strings in public API
The constant casting just makes user code a mess, for no benefit.
Diffstat (limited to 'src/serdi.c')
-rw-r--r--src/serdi.c54
1 files changed, 26 insertions, 28 deletions
diff --git a/src/serdi.c b/src/serdi.c
index 0619c5fc..26577ef6 100644
--- a/src/serdi.c
+++ b/src/serdi.c
@@ -35,7 +35,6 @@
#include <errno.h>
#include <stdbool.h>
-#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -187,24 +186,24 @@ main(int argc, char** argv)
return print_usage(argv[0], true);
}
- FILE* in_fd = NULL;
- SerdSyntax input_syntax = (SerdSyntax)0;
- SerdSyntax output_syntax = (SerdSyntax)0;
- bool from_file = true;
- bool ascii = false;
- bool bulk_read = true;
- bool bulk_write = false;
- bool full_uris = false;
- bool lax = false;
- bool quiet = false;
- const uint8_t* in_name = NULL;
- const uint8_t* add_prefix = NULL;
- const uint8_t* chop_prefix = NULL;
- const uint8_t* root_uri = NULL;
- int a = 1;
+ FILE* in_fd = NULL;
+ SerdSyntax input_syntax = (SerdSyntax)0;
+ SerdSyntax output_syntax = (SerdSyntax)0;
+ bool from_file = true;
+ bool ascii = false;
+ bool bulk_read = true;
+ bool bulk_write = false;
+ bool full_uris = false;
+ bool lax = false;
+ bool quiet = false;
+ const char* in_name = NULL;
+ const char* add_prefix = NULL;
+ const char* chop_prefix = NULL;
+ const char* root_uri = NULL;
+ int a = 1;
for (; a < argc && argv[a][0] == '-'; ++a) {
if (argv[a][1] == '\0') {
- in_name = (const uint8_t*)"(stdin)";
+ in_name = (const char*)"(stdin)";
in_fd = stdin;
break;
}
@@ -226,7 +225,7 @@ main(int argc, char** argv)
} else if (argv[a][1] == 'v') {
return print_version();
} else if (argv[a][1] == 's') {
- in_name = (const uint8_t*)"(string)";
+ in_name = (const char*)"(string)";
from_file = false;
++a;
break;
@@ -251,19 +250,19 @@ main(int argc, char** argv)
return missing_arg(argv[0], 'p');
}
- add_prefix = (const uint8_t*)argv[a];
+ add_prefix = argv[a];
} else if (argv[a][1] == 'c') {
if (++a == argc) {
return missing_arg(argv[0], 'c');
}
- chop_prefix = (const uint8_t*)argv[a];
+ chop_prefix = argv[a];
} else if (argv[a][1] == 'r') {
if (++a == argc) {
return missing_arg(argv[0], 'r');
}
- root_uri = (const uint8_t*)argv[a];
+ root_uri = argv[a];
} else {
SERDI_ERRORF("invalid option -- '%s'\n", argv[a] + 1);
return print_usage(argv[0], true);
@@ -280,22 +279,22 @@ main(int argc, char** argv)
_setmode(_fileno(stdout), _O_BINARY);
#endif
- uint8_t* input_path = NULL;
- const uint8_t* input = (const uint8_t*)argv[a++];
+ char* input_path = NULL;
+ const char* input = (const char*)argv[a++];
if (from_file) {
in_name = in_name ? in_name : input;
if (!in_fd) {
- if (!strncmp((const char*)input, "file:", 5)) {
+ if (!strncmp(input, "file:", 5)) {
input_path = serd_file_uri_parse(input, NULL);
input = input_path;
}
- if (!input || !(in_fd = serd_fopen((const char*)input, "rb"))) {
+ if (!input || !(in_fd = serd_fopen(input, "rb"))) {
return 1;
}
}
}
- if (!input_syntax && !(input_syntax = guess_syntax((const char*)in_name))) {
+ if (!input_syntax && !(input_syntax = guess_syntax(in_name))) {
input_syntax = SERD_TRIG;
}
@@ -312,8 +311,7 @@ main(int argc, char** argv)
SerdURI 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 uint8_t*)argv[a], NULL, &base_uri);
+ base = serd_node_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);
}