Skip to content
Snippets Groups Projects
Commit 264b770d authored by Andrea Shepard's avatar Andrea Shepard
Browse files

Implement h_query_backend_by_name()

parent e6815331
No related branches found
No related tags found
No related merge requests found
...@@ -295,6 +295,29 @@ static char * h_get_backend_text_with_no_params(HAllocator *mm__, ...@@ -295,6 +295,29 @@ static char * h_get_backend_text_with_no_params(HAllocator *mm__,
return text; return text;
} }
/* Query a backend by short name; return PB_INVALID if no match */
HParserBackend h_query_backend_by_name(const char *name) {
HParserBackend result = PB_INVALID, i;
if (name != NULL) {
/* Okay, iterate over the backends PB_MIN <= i <= PB_MAX and check */
i = PB_MIN;
do {
if (i != PB_INVALID) {
if (backends[i]->backend_short_name != NULL) {
if (strcmp(name, backends[i]->backend_short_name) == 0) {
result = i;
}
}
}
++i;
} while (i <= PB_MAX && result == PB_INVALID);
}
return result;
}
char * h_get_description_with_no_params(HAllocator *mm__, char * h_get_description_with_no_params(HAllocator *mm__,
HParserBackend be, void *params) { HParserBackend be, void *params) {
return h_get_backend_text_with_no_params(mm__, be, 1); return h_get_backend_text_with_no_params(mm__, be, 1);
......
...@@ -340,6 +340,13 @@ const char * h_get_descriptive_text_for_backend(HParserBackend be); ...@@ -340,6 +340,13 @@ const char * h_get_descriptive_text_for_backend(HParserBackend be);
HAMMER_FN_DECL(char *, h_get_descriptive_text_for_backend_with_params, HAMMER_FN_DECL(char *, h_get_descriptive_text_for_backend_with_params,
HParserBackendWithParams *be_with_params); HParserBackendWithParams *be_with_params);
/**
* Look up an HParserBackend by name; this should round-trip with
* h_get_name_for_backend().
*/
HParserBackend h_query_backend_by_name(const char *name);
/** /**
* Top-level function to call a parser that has been built over some * Top-level function to call a parser that has been built over some
* piece of input (of known size). * piece of input (of known size).
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment