macro definitions...
[svn/Prometheus-QoS/.git] / parsehosts.c
index 9ee2c2b003995e59c746cbe7789dd563f553817a..18418eddb6b9c587d6ec23925a71c6f8ed011c48 100644 (file)
@@ -10,6 +10,7 @@
 extern struct IP *ips, *ip, *sharedip, *networks;\r
 extern struct Group *groups, *group;\r
 extern struct Keyword *keyword, *defaultkeyword, *keywords;\r
 extern struct IP *ips, *ip, *sharedip, *networks;\r
 extern struct Group *groups, *group;\r
 extern struct Keyword *keyword, *defaultkeyword, *keywords;\r
+extern struct Macro *macro, *macros;\r
 extern int class_count;\r
 extern int ip_count;\r
 extern int found_lmsid;\r
 extern int class_count;\r
 extern int ip_count;\r
 extern int found_lmsid;\r
@@ -155,7 +156,7 @@ void parse_hosts(char *hosts)
 \r
  parse(hosts)\r
  {\r
 \r
  parse(hosts)\r
  {\r
-  str=_;\r
+  str = _;\r
 \r
   if(*str < '0' or *str > '9')\r
   {\r
 \r
   if(*str < '0' or *str > '9')\r
   {\r
@@ -163,6 +164,25 @@ void parse_hosts(char *hosts)
    continue;\r
   }\r
   \r
    continue;\r
   }\r
   \r
+  /* first, expand (rewrite) any predefined macros, if found*/\r
+  for_each(macro, macros)\r
+  {\r
+   substring = strstr(str, macro->rewrite_from);\r
+   if(substring);\r
+   {\r
+    int l1, l3;\r
+    *substring = 0;\r
+    substring += strlen(macro->rewrite_from);\r
+    l1 = strlen(str);\r
+    l3 = strlen(substring);\r
+    string(ptr, l1 + strlen(macro->rewrite_to) + l3);\r
+    strcpy(ptr, str);\r
+    strcat(ptr, macro->rewrite_to);\r
+    strcat(ptr, substring);\r
+    str = ptr;\r
+   }\r
+  }\r
+\r
   /* Does this IP share QoS class with some other ? */\r
   substring = strstr(str, "sharing-");\r
   if(substring)\r
   /* Does this IP share QoS class with some other ? */\r
   substring = strstr(str, "sharing-");\r
   if(substring)\r
This page took 0.130089 seconds and 4 git commands to generate.