#include #include #include #include #include #include #include #include #include #include "commands.h" static void usage(int argc, char **argv, char *message, ...) { if (message) { va_list args; va_start(args, message); vfprintf(stderr, message, args); fprintf(stderr, "\n"); va_end(args); } fprintf(stderr, "usage: %1$s print ...\n" " %1$s capture ...\n", argv[0]); exit(1); } static struct { char *name; int (*fun)(int, char **); } commands[] = { { "print", tabby_command_print }, { "capture", tabby_command_capture }, { NULL, NULL } }; int main(int argc, char **argv) { int i; if (argc < 2) { usage(argc, argv, "No command specified"); } for (i=0; commands[i].name; i++) { if (strcmp(argv[1], commands[i].name) == 0) { return commands[i].fun(argc, argv); } } usage(argc, argv, "Unknown command '%s'", argv[1]); return 0; }