aboutsummaryrefslogtreecommitdiffstats
path: root/wiretap/file_access.c
diff options
context:
space:
mode:
authorGuy Harris <gharris@sonic.net>2021-02-23 19:10:35 -0800
committerGuy Harris <gharris@sonic.net>2021-02-23 20:39:16 -0800
commited86f51e49e2b1ca64525bd14698528a50f3bbb4 (patch)
tree65f5a140a7b0c13265184c50a9c974b5de2f83a2 /wiretap/file_access.c
parent4cdc6ee5730ca32702d62b5959a3146ce9591596 (diff)
wiretap: rename wtap_register_file_type_subtypes().
It only registers one file type/subtype, so rename it to wtap_register_file_type_subtype(). That will also force plugins to be recompiled; that will produce compile errors for some plugins that didn't change to match the new contents of the file_type_subtype_info structure. Also check to make sure that the registered file type/subtype supports at least one type of block; a file type/subtype that doesn't return *any* blocks and doesn't permit *any* block types to be written is not very useful. That should also catch most if not all other plugins that didn't change to match the new contents of the file_type_subtype_info structure. Don't make errors registering a file type/subtype fatal; just complain, don't register the bogus file type/subtype, and drive on.
Diffstat (limited to 'wiretap/file_access.c')
-rw-r--r--wiretap/file_access.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/wiretap/file_access.c b/wiretap/file_access.c
index 3b7307c683..48b1aa9d1f 100644
--- a/wiretap/file_access.c
+++ b/wiretap/file_access.c
@@ -1314,7 +1314,7 @@ wtap_init_file_type_subtypes(void)
* with that name is already registered.
*/
int
-wtap_register_file_type_subtypes(const struct file_type_subtype_info* fi)
+wtap_register_file_type_subtype(const struct file_type_subtype_info* fi)
{
struct file_type_subtype_info* finfo;
guint file_type_subtype;
@@ -1323,7 +1323,16 @@ wtap_register_file_type_subtypes(const struct file_type_subtype_info* fi)
* Check for required fields (description and name).
*/
if (!fi || !fi->description || !fi->name) {
- g_error("no file type info");
+ g_warning("no file type info");
+ return -1;
+ }
+
+ /*
+ * There must be at least one block type that this file
+ * type/subtype supports.
+ */
+ if (fi->num_supported_blocks == 0 || fi->supported_blocks == NULL) {
+ g_warning("no blocks supported by file type \"%s\"", fi->name);
return -1;
}
@@ -1334,7 +1343,7 @@ wtap_register_file_type_subtypes(const struct file_type_subtype_info* fi)
/*
* Yes. You don't get to replace an existing handler.
*/
- g_error("file type \"%s\" is already registered", fi->name);
+ g_warning("file type \"%s\" is already registered", fi->name);
return -1;
}