- meta = g_hash_table_new(NULL, NULL);
- for (m = 0; m < sizeof(imod->metadata); m++) {
- mitem = imod->metadata[m] & ~SR_INPUT_META_REQUIRED;
- if (mitem == SR_INPUT_META_FILENAME)
- g_hash_table_insert(meta, GINT_TO_POINTER(mitem),
- (gpointer)filename);
- else if (mitem == SR_INPUT_META_FILESIZE)
- g_hash_table_insert(meta, GINT_TO_POINTER(mitem),
- GINT_TO_POINTER(st.st_size));
- else if (mitem == SR_INPUT_META_HEADER) {
- buf = g_string_sized_new(128);
- if ((fd = open(filename, O_RDONLY)) < 0) {
- sr_err("%s", strerror(errno));
- return NULL;
- }
- size = read(fd, buf->str, 128);
- buf->len = size;
- close(fd);
- if (size <= 0) {
- g_string_free(buf, TRUE);
- sr_err("%s", strerror(errno));
- return NULL;
- }
- g_hash_table_insert(meta, GINT_TO_POINTER(mitem), buf);
- g_string_free(buf, TRUE);
- }
- }
- if (g_hash_table_size(meta) == 0) {
- /* No metadata for this module, so there's no way it
- * can match. */
- g_hash_table_destroy(meta);
+ sr_dbg("Trying module %s.", imod->id);
+
+ ret = imod->format_match(meta, &conf);
+ if (ret == SR_ERR) {
+ /* Module didn't recognize this buffer. */
+ continue;
+ } else if (ret != SR_OK) {
+ /* Module recognized this buffer, but cannot handle it. */