X-Git-Url: http://sigrok.org/gitweb/?a=blobdiff_plain;ds=inline;f=src%2Fbackend.c;h=49ea9cd52088708e3a02a014f4bdb6fdc98953a6;hb=d50725e0126a5d52d97e7ea49e37c66c15108156;hp=f650fe1206edb36bcf0eb0b023b036c84b0902ab;hpb=155b680da482cea2381becb73c51cfb838bff31e;p=libsigrok.git
diff --git a/src/backend.c b/src/backend.c
index f650fe12..49ea9cd5 100644
--- a/src/backend.c
+++ b/src/backend.c
@@ -55,7 +55,7 @@
*
* @section sec_mailinglists Mailing lists
*
- * There are two mailing lists for sigrok/libsigrok: sigrok-devel and sigrok-commits.
+ * There is one mailing list for sigrok/libsigrok: sigrok-devel.
*
* @section sec_irc IRC
*
@@ -215,7 +215,7 @@ static int sanity_check_all_drivers(void)
static int sanity_check_all_input_modules(void)
{
int i, errors, ret = SR_OK;
- struct sr_input_format **inputs;
+ const struct sr_input_module **inputs;
const char *d;
sr_spew("Sanity-checking all input modules.");
@@ -230,20 +230,24 @@ static int sanity_check_all_input_modules(void)
sr_err("No ID in module %d ('%s').", i, d);
errors++;
}
- if (!inputs[i]->description) {
- sr_err("No description in module %d ('%s').", i, d);
+ if (!inputs[i]->name) {
+ sr_err("No name in module %d ('%s').", i, d);
errors++;
}
- if (!inputs[i]->format_match) {
- sr_err("No format_match in module %d ('%s').", i, d);
+ if (!inputs[i]->desc) {
+ sr_err("No description in module %d ('%s').", i, d);
errors++;
}
if (!inputs[i]->init) {
sr_err("No init in module %d ('%s').", i, d);
errors++;
}
- if (!inputs[i]->loadfile) {
- sr_err("No loadfile in module %d ('%s').", i, d);
+ if (!inputs[i]->receive) {
+ sr_err("No receive in module %d ('%s').", i, d);
+ errors++;
+ }
+ if (!inputs[i]->end) {
+ sr_err("No end in module %d ('%s').", i, d);
errors++;
}
@@ -265,7 +269,7 @@ static int sanity_check_all_input_modules(void)
static int sanity_check_all_output_modules(void)
{
int i, errors, ret = SR_OK;
- struct sr_output_format **outputs;
+ const struct sr_output_module **outputs;
const char *d;
sr_spew("Sanity-checking all output modules.");
@@ -280,7 +284,11 @@ static int sanity_check_all_output_modules(void)
sr_err("No ID in module %d ('%s').", i, d);
errors++;
}
- if (!outputs[i]->description) {
+ if (!outputs[i]->name) {
+ sr_err("No name in module %d ('%s').", i, d);
+ errors++;
+ }
+ if (!outputs[i]->desc) {
sr_err("No description in module '%s'.", d);
errors++;
}
@@ -298,6 +306,55 @@ static int sanity_check_all_output_modules(void)
return ret;
}
+/**
+ * Sanity-check all libsigrok transform modules.
+ *
+ * @retval SR_OK All modules are OK
+ * @retval SR_ERR One or more modules have issues.
+ */
+static int sanity_check_all_transform_modules(void)
+{
+ int i, errors, ret = SR_OK;
+ const struct sr_transform_module **transforms;
+ const char *d;
+
+ sr_spew("Sanity-checking all transform modules.");
+
+ transforms = sr_transform_list();
+ for (i = 0; transforms[i]; i++) {
+ errors = 0;
+
+ d = (transforms[i]->id) ? transforms[i]->id : "NULL";
+
+ if (!transforms[i]->id) {
+ sr_err("No ID in module %d ('%s').", i, d);
+ errors++;
+ }
+ if (!transforms[i]->name) {
+ sr_err("No name in module %d ('%s').", i, d);
+ errors++;
+ }
+ if (!transforms[i]->desc) {
+ sr_err("No description in module '%s'.", d);
+ errors++;
+ }
+ /* Note: options() is optional. */
+ /* Note: init() is optional. */
+ if (!transforms[i]->receive) {
+ sr_err("No receive in module '%s'.", d);
+ errors++;
+ }
+ /* Note: cleanup() is optional. */
+
+ if (errors == 0)
+ continue;
+
+ ret = SR_ERR;
+ }
+
+ return ret;
+}
+
/**
* Initialize libsigrok.
*
@@ -339,14 +396,14 @@ SR_API int sr_init(struct sr_context **ctx)
return ret;
}
- /* + 1 to handle when struct sr_context has no members. */
- context = g_try_malloc0(sizeof(struct sr_context) + 1);
-
- if (!context) {
- ret = SR_ERR_MALLOC;
- goto done;
+ if (sanity_check_all_transform_modules() < 0) {
+ sr_err("Internal transform module error(s), aborting.");
+ return ret;
}
+ /* + 1 to handle when struct sr_context has no members. */
+ context = g_malloc0(sizeof(struct sr_context) + 1);
+
#ifdef HAVE_LIBUSB_1_0
ret = libusb_init(&context->libusb_ctx);
if (LIBUSB_SUCCESS != ret) {