|
| 1 | +/* |
| 2 | + * Copyright (c) 2013 William Pitcock <[email protected]>. |
| 3 | + * |
| 4 | + * Permission to use, copy, modify, and/or distribute this software for any |
| 5 | + * purpose with or without fee is hereby granted, provided that the above |
| 6 | + * copyright notice and this permission notice appear in all copies. |
| 7 | + * |
| 8 | + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
| 9 | + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
| 10 | + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
| 11 | + * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, |
| 12 | + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
| 13 | + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
| 14 | + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
| 15 | + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, |
| 16 | + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING |
| 17 | + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
| 18 | + * POSSIBILITY OF SUCH DAMAGE. |
| 19 | + */ |
| 20 | + |
| 21 | +#include <stdio.h> |
| 22 | +#include <stdlib.h> |
| 23 | + |
| 24 | +#include "tool-applet.h" |
| 25 | + |
| 26 | +static tool_applet_t tool_applets[] = { |
| 27 | + {NULL, NULL} |
| 28 | +}; |
| 29 | + |
| 30 | +static inline tool_applet_t *tool_applet_find(const char *name) |
| 31 | +{ |
| 32 | + tool_applet_t *iter; |
| 33 | + |
| 34 | + for (iter = tool_applets; iter->name != NULL; iter++) |
| 35 | + { |
| 36 | + if (!strcmp(iter->name, name)) |
| 37 | + return iter; |
| 38 | + } |
| 39 | + |
| 40 | + return NULL; |
| 41 | +} |
| 42 | + |
| 43 | +int main(int argc, const char *argv[]) |
| 44 | +{ |
| 45 | + tool_applet_t *tool; |
| 46 | + |
| 47 | + if (argv[1] == NULL) |
| 48 | + argv[1] = "usage"; |
| 49 | + |
| 50 | + tool = tool_applet_find(argv[1]); |
| 51 | + if (tool == NULL) |
| 52 | + { |
| 53 | + fprintf(stderr, "%s: not implemented\n", argv[1]); |
| 54 | + return EXIT_FAILURE; |
| 55 | + } |
| 56 | + |
| 57 | + return tool->main(argc - 1, argv + 1); |
| 58 | +} |
0 commit comments