Once again, but this time CONFIG_VERSION is apr_int64_t, and attribute name is "configversion" to make things clear for the end user. If there's no configversion attribute, then flood assumes "0", which covers flood 0.4 config file format. Incoming flood 1.1 release will use "1" as configversion. As soon, as this patch get's accepted, I'll update config versions in example/ directory and documentation.
regards, Jacek Prucia
diff -urN flood.orig/config.h.in flood/config.h.in --- flood.orig/config.h.in 2003-08-24 12:22:04.000000000 +0200 +++ flood/config.h.in 2003-08-24 23:58:10.000000000 +0200 @@ -8,6 +8,8 @@ #define FLOOD_STRLEN_MAX 256 /* XML symbolic roots to the various objects we define. */ +#define XML_FLOOD "flood" +#define XML_FLOOD_CONFIG_VERSION "configversion" #define XML_SEED "seed" #define XML_URLLIST "urllist" #define XML_URLLIST_SEQUENCE "sequence" @@ -51,6 +53,7 @@ #define XML_ELEM_DELIM "." #define FLOOD_VERSION "1.1-dev" +#define CONFIG_VERSION "1" #define CRLF "\r\n" diff -urN flood.orig/flood.c flood/flood.c --- flood.orig/flood.c 2003-08-24 12:22:04.000000000 +0200 +++ flood/flood.c 2003-08-25 00:01:17.000000000 +0200 @@ -127,6 +127,50 @@ return APR_SUCCESS; } +/* check if config file version matches flood config file version */ +static apr_status_t check_versions(config_t *config) +{ + apr_status_t stat; + char *endptr = NULL; + apr_int64_t flood_version = 0; + apr_int64_t config_version = 0; + struct apr_xml_elem *root_elem; + + /* we assume that CONFIG_VERSION is sane */ + flood_version = apr_strtoi64(CONFIG_VERSION, NULL, 0); + + /* get the root element */ + if ((stat = retrieve_root_xml_elem(&root_elem, config)) != APR_SUCCESS) { + return stat; + } + + if (root_elem->attr) { + apr_xml_attr *attr = root_elem->attr; + while (attr) { + if (!strncasecmp(attr->name, XML_FLOOD_CONFIG_VERSION, + FLOOD_STRLEN_MAX)) { + config_version = apr_strtoi64(attr->value, &endptr, 0); + if (*endptr != '\0') { + apr_file_printf(local_stderr, + "invalid config version '%s'.\n", + attr->value); + return APR_EGENERAL; + } + } + attr = attr->next; + } + } + + if (config_version != flood_version) { + apr_file_printf(local_stderr, + "your config file version '%lli' doesn't match flood config file version '%lli'.\n", + config_version, flood_version); + } + + return APR_SUCCESS; + +} + int main(int argc, char** argv) { apr_status_t stat; @@ -172,6 +216,10 @@ exit(-1); } + if ((stat = check_versions(config)) != APR_SUCCESS) { + exit(-1); + } + if ((stat = run_farm(config, "Bingo", local_pool)) != APR_SUCCESS) { char buf[256]; apr_strerror(stat, (char*) &buf, 256);