+/**
+ * Parse a string representation of a boolean-like value into a gboolean.
+ * Similar to sr_parse_boolstring but rejects strings which do not represent
+ * a boolean-like value.
+ *
+ * @param str String to convert.
+ * @param ret Pointer to a gboolean where the result of the conversion will be
+ * stored.
+ *
+ * @return SR_OK on success, SR_ERR on failure.
+ */
+static int parse_strict_bool(const char *str, gboolean *ret)
+{
+ if (!str)
+ return SR_ERR_ARG;
+
+ if (!g_strcmp0(str, "1") ||
+ !g_ascii_strncasecmp(str, "y", 1) ||
+ !g_ascii_strncasecmp(str, "t", 1) ||
+ !g_ascii_strncasecmp(str, "yes", 3) ||
+ !g_ascii_strncasecmp(str, "true", 4) ||
+ !g_ascii_strncasecmp(str, "on", 2)) {
+ *ret = TRUE;
+ return SR_OK;
+ } else if (!g_strcmp0(str, "0") ||
+ !g_ascii_strncasecmp(str, "n", 1) ||
+ !g_ascii_strncasecmp(str, "f", 1) ||
+ !g_ascii_strncasecmp(str, "no", 2) ||
+ !g_ascii_strncasecmp(str, "false", 5) ||
+ !g_ascii_strncasecmp(str, "off", 3)) {
+ *ret = FALSE;
+ return SR_OK;
+ }
+
+ return SR_ERR;
+}
+
+/**
+ * Open SCPI device.
+ *
+ * @param scpi Previously initialized SCPI device structure.
+ *
+ * @return SR_OK on success, SR_ERR on failure.
+ */
+SR_PRIV int sr_scpi_open(struct sr_scpi_dev_inst *scpi)
+{
+ return scpi->open(scpi->priv);
+}
+
+/**
+ * Add an event source for an SCPI device.
+ *
+ * @param scpi Previously initialized SCPI device structure.
+ * @param events Events to check for.
+ * @param timeout Max time to wait before the callback is called, ignored if 0.
+ * @param cb Callback function to add. Must not be NULL.
+ * @param cb_data Data for the callback function. Can be NULL.
+ *
+ * @return SR_OK upon success, SR_ERR_ARG upon invalid arguments, or
+ * SR_ERR_MALLOC upon memory allocation errors.
+ */
+SR_PRIV int sr_scpi_source_add(struct sr_scpi_dev_inst *scpi, int events,
+ int timeout, sr_receive_data_callback_t cb, void *cb_data)
+{
+ return scpi->source_add(scpi->priv, events, timeout, cb, cb_data);
+}
+
+/**
+ * Remove event source for an SCPI device.
+ *
+ * @param scpi Previously initialized SCPI device structure.
+ *
+ * @return SR_OK upon success, SR_ERR_ARG upon invalid arguments, or
+ * SR_ERR_MALLOC upon memory allocation errors, SR_ERR_BUG upon
+ * internal errors.
+ */
+SR_PRIV int sr_scpi_source_remove(struct sr_scpi_dev_inst *scpi)
+{
+ return scpi->source_remove(scpi->priv);
+}
+