]> sigrok.org Git - libsigrok.git/blobdiff - src/input/chronovu_la8.c
input: add confidence (detection strength) to format_match()
[libsigrok.git] / src / input / chronovu_la8.c
index 07d94a719de1aec68add953c832801c110b9f305..6607f3a7e11fba56452223edfebf565bfc7bbce0 100644 (file)
@@ -37,16 +37,23 @@ struct context {
        uint64_t samplerate;
 };
 
-static int format_match(GHashTable *metadata)
+static int format_match(GHashTable *metadata, unsigned int *confidence)
 {
        int size;
 
+       /*
+        * In the absence of a reliable condition like magic strings,
+        * we can only guess based on the file size. Since this is
+        * rather weak a condition, signal "little confidence" and
+        * optionally give precedence to better matches.
+        */
        size = GPOINTER_TO_INT(g_hash_table_lookup(metadata,
                        GINT_TO_POINTER(SR_INPUT_META_FILESIZE)));
-       if (size == CHRONOVU_LA8_FILESIZE)
-               return SR_OK;
+       if (size != CHRONOVU_LA8_FILESIZE)
+               return SR_ERR;
+       *confidence = 100;
 
-       return SR_ERR;
+       return SR_OK;
 }
 
 static int init(struct sr_input *in, GHashTable *options)