addr.c, linux.h, yaid.h: Move things out of the address-type list macro.
[yaid] / linux.c
diff --git a/linux.c b/linux.c
index 7ff1abc..15db30b 100644 (file)
--- a/linux.c
+++ b/linux.c
@@ -35,12 +35,12 @@ struct addrops_sys {
   int (*parseaddr)(char **, union addr *);
 };
 
+#define PROCFILE_IPV4 "/proc/net/tcp"
+
 static int parseaddr_ipv4(char **pp, union addr *a)
   { a->ipv4.s_addr = strtoul(*pp, pp, 16); return (0); }
 
-const struct addrops_sys addrops_sys_ipv4 = {
-  "/proc/net/tcp", parseaddr_ipv4
-};
+#define PROCFILE_IPV6 "/proc/net/tcp6"
 
 static int parseaddr_ipv6(char **pp, union addr *a)
 {
@@ -65,9 +65,12 @@ static int parseaddr_ipv6(char **pp, union addr *a)
   return (0);
 }
 
-const struct addrops_sys addrops_sys_ipv6 = {
-  "/proc/net/tcp6", parseaddr_ipv6
-};
+#define DEFOPSYS(ty, TY)                                               \
+  const struct addrops_sys addrops_sys_##ty = {                                \
+    PROCFILE_##TY, parseaddr_##ty                                      \
+  };
+ADDRTYPES(DEFOPSYS)
+#undef DEFOPSYS
 
 /*----- Main code ---------------------------------------------------------*/