cmdline: parse() method does not return token_len anymore
[libcmdline.git] / src / lib / cmdline_parse_ipaddr.c
index cb41562..bcd12a4 100644 (file)
 #include "cmdline_parse.h"
 #include "cmdline_parse_ipaddr.h"
 
-struct cmdline_token_ops cmdline_token_ipaddr_ops = {
-       .parse = cmdline_parse_ipaddr,
-       .complete_get_nb = NULL,
-       .complete_get_elt = NULL,
-       .get_help = cmdline_get_help_ipaddr,
-};
-
 #define INADDRSZ 4
 #define IN6ADDRSZ 16
 
@@ -289,7 +282,7 @@ inet_pton6(const char *src, unsigned char *dst)
        return (1);
 }
 
-int
+static int
 cmdline_parse_ipaddr(cmdline_parse_token_hdr_t *tk, const char *buf, void *res,
                     unsigned ressize)
 {
@@ -329,19 +322,20 @@ cmdline_parse_ipaddr(cmdline_parse_token_hdr_t *tk, const char *buf, void *res,
        if ((tk2->ipaddr_data.flags & CMDLINE_IPADDR_V4) &&
            my_inet_pton(AF_INET, ip_str, &ipaddr->addr.ipv4) == 1) {
                ipaddr->family = AF_INET;
-               return token_len;
+               return 0;
        }
        if ((tk2->ipaddr_data.flags & CMDLINE_IPADDR_V6) &&
            my_inet_pton(AF_INET6, ip_str, &ipaddr->addr.ipv6) == 1) {
                ipaddr->family = AF_INET6;
-               return token_len;
+               return 0;
        }
        return -1;
 
 }
 
-int cmdline_get_help_ipaddr(cmdline_parse_token_hdr_t *tk, char *dstbuf,
-                           unsigned int size)
+static int
+cmdline_help_ipaddr(cmdline_parse_token_hdr_t *tk, char *dstbuf,
+                   unsigned int size)
 {
        struct cmdline_token_ipaddr *tk2 = (struct cmdline_token_ipaddr *)tk;
 
@@ -370,3 +364,12 @@ int cmdline_get_help_ipaddr(cmdline_parse_token_hdr_t *tk, char *dstbuf,
        }
        return 0;
 }
+
+struct cmdline_token_ops cmdline_token_ipaddr_ops = {
+       .parse = cmdline_parse_ipaddr,
+       .complete_start = NULL,
+       .complete_iterate = NULL,
+       .complete_end = NULL,
+       .help = cmdline_help_ipaddr,
+};
+