WS_DLL_LOCAL
gint wtap_num_encap_types = sizeof(encap_table_base) / sizeof(struct encap_type_info);
static GArray* encap_table_arr = NULL;
-static const struct encap_type_info* encap_table = NULL;
+
+#define encap_table_entry(encap) \
+ g_array_index(encap_table_arr, struct encap_type_info, encap)
static void wtap_init_encap_types(void) {
encap_table_arr = g_array_new(FALSE,TRUE,sizeof(struct encap_type_info));
g_array_append_vals(encap_table_arr,encap_table_base,wtap_num_encap_types);
-
- encap_table = (struct encap_type_info *)encap_table_arr->data;
}
int wtap_get_num_encap_types(void) {
g_array_append_val(encap_table_arr,e);
- encap_table = (struct encap_type_info *)encap_table_arr->data;
-
return wtap_num_encap_types++;
}
else if (encap == WTAP_ENCAP_PER_PACKET)
return "Per packet";
else
- return encap_table[encap].name;
+ return encap_table_entry(encap).name;
}
/* Name to use in, say, a command-line flag specifying the type. */
else if (encap == WTAP_ENCAP_PER_PACKET)
return "per-packet";
else
- return encap_table[encap].short_name;
+ return encap_table_entry(encap).short_name;
}
/* Translate a short name to a capture file type. */
int encap;
for (encap = 0; encap < WTAP_NUM_ENCAP_TYPES; encap++) {
- if (encap_table[encap].short_name != NULL &&
- strcmp(short_name, encap_table[encap].short_name) == 0)
+ if (encap_table_entry(encap).short_name != NULL &&
+ strcmp(short_name, encap_table_entry(encap).short_name) == 0)
return encap;
}
return -1; /* no such encapsulation type */