#include "sgen-gc.h"
#define PROTOCOL_HEADER_CHECK 0xde7ec7ab1ec0de
+/*
+ * The version needs to be bumped every time we introduce breaking changes (like
+ * adding new protocol entries or various format changes). The latest protocol grepper
+ * should be able to handle all the previous versions, while an old grepper will
+ * be able to tell if it cannot handle the format.
+ */
#define PROTOCOL_HEADER_VERSION 1
/* Special indices returned by MATCH_INDEX. */
return FALSE;
if (type == PROTOCOL_ID (binary_protocol_header)) {
PROTOCOL_STRUCT (binary_protocol_header) * str = (PROTOCOL_STRUCT (binary_protocol_header) *) data;
- if (str->check == PROTOCOL_HEADER_CHECK && str->ptr_size == BINPROT_SIZEOF_VOID_P)
+ if (str->check == PROTOCOL_HEADER_CHECK && str->ptr_size == BINPROT_SIZEOF_VOID_P) {
+ if (str->version > PROTOCOL_HEADER_VERSION) {
+ fprintf (stderr, "The file contains a newer version %d. We support up to %d. Please update.\n", str->version, PROTOCOL_HEADER_VERSION);
+ exit (1);
+ }
return TRUE;
+ }
}
return FALSE;
#else