blob: 1871f8c8da7bf0227e28119c25e9c6b55af9f7c5 [file] [log] [blame]
Willy Tarreau2ac57182012-04-19 15:24:50 +02001#include <stdio.h>
2#include <stdlib.h>
3#include <string.h>
Willy Tarreau38ceb552021-04-02 10:33:38 +02004#include <haproxy/arg.h>
Willy Tarreau2ac57182012-04-19 15:24:50 +02005
6int main(int argc, char **argv)
7{
8 int nbargs, err_arg, mask;
9 struct arg *argp;
10 char *err_msg = NULL;
11 const char *err_ptr = NULL;
12
13 if (argc < 2) {
14 printf("Usage: %s arg_list [arg_mask]\n"
15 " mask defaults to 0x86543290\n"
16 " eg: %s 10k,+20,Host,1.2.3.4,24,::5.6.7.8,120s\n", *argv, *argv);
17 return 1;
18 }
19
20 mask = ARG7(0,SIZE,SINT,STR,IPV4,MSK4,IPV6,TIME);
21 if (argc >= 3)
22 mask = atoll(argv[2]);
23
24 printf("Using mask=0x%08x\n", mask);
25 nbargs = make_arg_list(argv[1], strlen(argv[1]), mask,
Willy Tarreau38ceb552021-04-02 10:33:38 +020026 &argp, &err_msg, &err_ptr, &err_arg, NULL);
Willy Tarreau2ac57182012-04-19 15:24:50 +020027
28 printf("nbargs=%d\n", nbargs);
29 if (nbargs < 0) {
30 printf("err_msg=%s\n", err_msg); free(err_msg);
31 printf("err_ptr=%s (str+%d)\n", err_ptr, err_ptr - argv[1]);
32 printf("err_arg=%d\n", err_arg);
33 return 1;
34 }
35
36 if (nbargs > 0) {
37 int arg;
38
39 for (arg = 0; arg < nbargs; arg++)
40 printf("arg %d: type=%d, int=0x%08x\n",
Willy Tarreau38ceb552021-04-02 10:33:38 +020041 arg, argp[arg].type, *(int*)&argp[arg].data.sint);
Willy Tarreau2ac57182012-04-19 15:24:50 +020042 }
43 return 0;
44}