From 4758bdc8a35c3604f8b6dd72b3d49e7bc5ff9b1e Mon Sep 17 00:00:00 2001 From: Jan Breuer <jan.breuer@jaybee.cz> Date: 周日, 19 4月 2015 05:51:20 +0800 Subject: [PATCH] Add test for command tree traversal --- libscpi/src/parser.c | 24 +++++++++++++++++++----- 1 files changed, 19 insertions(+), 5 deletions(-) diff --git a/libscpi/src/parser.c b/libscpi/src/parser.c index b4f79ac..5940432 100644 --- a/libscpi/src/parser.c +++ b/libscpi/src/parser.c @@ -546,8 +546,8 @@ /** * Parse string parameter * @param context - * @param value - * @param len + * @param value Pointer to string buffer where pointer to non-null terminated string will be returned + * @param len Length of returned non-null terminated string * @param mandatory * @return */ @@ -577,8 +577,8 @@ /** * Parse text parameter (can be inside "") * @param context - * @param value - * @param len + * @param value Pointer to string buffer where pointer to non-null terminated string will be returned + * @param len Length of returned non-null terminated string * @param mandatory * @return */ @@ -593,8 +593,10 @@ return FALSE; } + paramSkipWhitespace(context); if (locateText(context->paramlist.parameters, context->paramlist.length, value, &length)) { - paramSkipBytes(context, length); + paramSkipBytes(context, length + 2); + paramSkipWhitespace(context); if (len) { *len = length; } @@ -675,3 +677,15 @@ return FALSE; } +scpi_bool_t SCPI_IsCmd(scpi_t * context, const char * cmd) { + if (! context->paramlist.cmd) { + return FALSE; + } + + const char * pattern = context->paramlist.cmd->pattern; + return matchCommand (pattern, cmd, strlen (cmd)); +} + +scpi_bool_t SCPI_Match(const char * pattern, const char * value, size_t len) { + return matchCommand (pattern, value, len); +} -- Gitblit v1.9.1