From c1e514e03ab7de4399ca12c9ae988b0707a99f8b Mon Sep 17 00:00:00 2001
From: Jan Breuer <jan.breuer@jaybee.cz>
Date: 周二, 15 9月 2015 03:13:35 +0800
Subject: [PATCH] Resolve #46: Detect missing parameter

---
 libscpi/src/parser.c |   21 +++++++++++++++++++++
 1 files changed, 21 insertions(+), 0 deletions(-)

diff --git a/libscpi/src/parser.c b/libscpi/src/parser.c
index c307a37..9032c9c 100644
--- a/libscpi/src/parser.c
+++ b/libscpi/src/parser.c
@@ -1093,3 +1093,24 @@
 scpi_bool_t SCPI_CommandNumbers(scpi_t * context, int32_t * numbers, size_t len) {
     return matchCommand (context->param_list.cmd->pattern,  context->param_list.cmd_raw.data, context->param_list.cmd_raw.length, numbers, len);
 }
+
+/**
+ * If SCPI_Parameter() returns FALSE, this function can detect, if the parameter
+ * is just missing (TRUE) or if there was an error during processing of the command (FALSE)
+ * @param parameter
+ * @return
+ */
+scpi_bool_t SCPI_ParamIsValid(scpi_parameter_t * parameter)
+{
+    return parameter->type == SCPI_TOKEN_UNKNOWN ? FALSE : TRUE;
+}
+
+/**
+ * Returns TRUE if there was an error during parameter handling
+ * @param context
+ * @return
+ */
+scpi_bool_t SCPI_ParamErrorOccurred(scpi_t * context)
+{
+    return context->cmd_error;
+}

--
Gitblit v1.9.1