Kevin Wolf <kw...@redhat.com> writes: > Am 27.02.2017 um 12:20 hat Markus Armbruster geschrieben: >> Signed-off-by: Markus Armbruster <arm...@redhat.com> >> --- >> include/qapi/util.h | 2 ++ >> qapi/qapi-util.c | 47 +++++++++++++++++++++++++++++++++++++++++++++++ >> tests/test-qapi-util.c | 34 ++++++++++++++++++++++++++++++++++ >> 3 files changed, 83 insertions(+) >> >> diff --git a/include/qapi/util.h b/include/qapi/util.h >> index 7ad26c0..7436ed8 100644 >> --- a/include/qapi/util.h >> +++ b/include/qapi/util.h >> @@ -14,4 +14,6 @@ >> int qapi_enum_parse(const char * const lookup[], const char *buf, >> int max, int def, Error **errp); >> >> +int parse_qapi_name(const char *name, bool complete); >> + >> #endif >> diff --git a/qapi/qapi-util.c b/qapi/qapi-util.c >> index 818730a..53b27e2 100644 >> --- a/qapi/qapi-util.c >> +++ b/qapi/qapi-util.c >> @@ -33,3 +33,50 @@ int qapi_enum_parse(const char * const lookup[], const >> char *buf, >> error_setg(errp, "invalid parameter value: %s", buf); >> return def; >> } >> + >> +/* >> + * Parse a valid QAPI name from @str. >> + * A valid name consists of letters, digits, hyphen and underscore. >> + * It may be prefixed by __RFQDN_ (downstream extension), where RFQDN >> + * may contain only letters, digits and hyphen. > > And '.' according to the code below.
Of course. Fixing the comment... >> + * The special exception for enumeration names is not implemented. >> + * See docs/qapi-code-gen.txt for more on QAPI naming rules. >> + * Keep this consistent with scripts/qapi.py! >> + * If @complete, the parse fails unless it consumes @str completely. >> + * Return its length on success, -1 on failure. >> + */ > > Kevin