2 * Copyright (C) 2014 John Crispin <blogic@openwrt.org>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License version 2.1
6 * as published by the Free Software Foundation
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
19 static LIST_HEAD(backends
);
22 register_backend(struct backend
*b
)
24 list_add(&b
->list
, &backends
);
28 find_backend(char *name
)
32 list_for_each_entry(b
, &backends
, list
)
33 if (!strcmp(name
, b
->name
))
43 list_for_each_entry(b
, &backends
, list
) {
47 fprintf(stderr
, "-> %s\n", b
->name
);
48 for (i
= 0; i
< b
->num_handlers
; i
++)
49 if (b
->handlers
[i
].desc
)
50 fprintf(stderr
, "--> %s\n", b
->handlers
[i
].name
);
55 main(int argc
, char **argv
)
59 if (argc
> 1) list_for_each_entry(b
, &backends
, list
) {
64 if (strcmp(argv
[1], b
->name
))
67 for (i
= 0; i
< b
->num_handlers
; i
++)
68 if (!strcmp(argv
[2], b
->handlers
[i
].name
))
69 return b
->handlers
[i
].cli(argc
- 2, &argv
[2]);
72 return b
->cli(argc
- 1, &argv
[1]);