diff options
author | David Robillard <d@drobilla.net> | 2021-08-08 20:45:55 -0400 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2023-12-02 18:49:08 -0500 |
commit | ed12fd8066ed47c1ee675a69dfed21751313f197 (patch) | |
tree | 4ef4ae0b70f2b281f8d8c3aefd35cb224e105ac3 /tools/console.c | |
parent | 816a9532765b2184c5f127494b95bdb9103bc960 (diff) | |
download | serd-ed12fd8066ed47c1ee675a69dfed21751313f197.tar.gz serd-ed12fd8066ed47c1ee675a69dfed21751313f197.tar.bz2 serd-ed12fd8066ed47c1ee675a69dfed21751313f197.zip |
Factor out serd_choose_syntax()
Diffstat (limited to 'tools/console.c')
-rw-r--r-- | tools/console.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/tools/console.c b/tools/console.c index f07573fa..d0e6aaef 100644 --- a/tools/console.c +++ b/tools/console.c @@ -63,6 +63,25 @@ serd_set_base_uri_from_path(SerdEnv* const env, const char* const path) return SERD_SUCCESS; } +SerdSyntax +serd_choose_syntax(const SerdSyntax requested, const char* const filename) +{ + if (requested) { + return requested; + } + + const SerdSyntax guessed = serd_guess_syntax(filename); + if (guessed != SERD_SYNTAX_EMPTY) { + return guessed; + } + + fprintf(stderr, + "warning: unable to determine syntax of \"%s\", trying TriG\n", + filename); + + return SERD_TRIG; +} + /// Wrapper for getc that is compatible with SerdReadFunc but faster than fread static size_t serd_file_read_byte(void* buf, size_t size, size_t nmemb, void* stream) |