You are viewing a plain text version of this content. The canonical link for it is here.
Posted to test-cvs@httpd.apache.org by ja...@apache.org on 2003/09/08 01:41:57 UTC
cvs commit: httpd-test/flood config.h.in flood.c
jacekp 2003/09/07 16:41:57
Modified: flood config.h.in flood.c
Log:
Added configversion attribute (root element <flood>) which ties config file structure with
certain flood version and warns user if there is a conflict.
Revision Changes Path
1.29 +3 -0 httpd-test/flood/config.h.in
Index: config.h.in
===================================================================
RCS file: /home/cvs/httpd-test/flood/config.h.in,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -r1.28 -r1.29
--- config.h.in 7 Sep 2003 22:56:53 -0000 1.28
+++ config.h.in 7 Sep 2003 23:41:57 -0000 1.29
@@ -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"
@@ -52,6 +54,7 @@
#define XML_ELEM_DELIM "."
#define FLOOD_VERSION "1.1-dev"
+#define CONFIG_VERSION "1"
#define CRLF "\r\n"
1.11 +48 -0 httpd-test/flood/flood.c
Index: flood.c
===================================================================
RCS file: /home/cvs/httpd-test/flood/flood.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- flood.c 3 Feb 2003 17:10:56 -0000 1.10
+++ flood.c 7 Sep 2003 23:41:57 -0000 1.11
@@ -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;
@@ -169,6 +213,10 @@
apr_strerror(stat, (char*) &buf, 256);
apr_file_printf(local_stderr, "Error running test profile: %s.\n",
(char*)&buf);
+ exit(-1);
+ }
+
+ if ((stat = check_versions(config)) != APR_SUCCESS) {
exit(-1);
}