28 #include "usbip_common.h"
31 static int usbip_help(
int argc,
char *argv[]);
32 static int usbip_version(
int argc,
char *argv[]);
34 static const char usbip_version_string[] = PACKAGE_STRING;
36 static const char usbip_usage_string[] =
37 "usbip [--debug] [--log] [version]\n"
38 " [help] <command> <args>\n";
40 static void usbip_usage(
void)
42 printf(
"usage: %s", usbip_usage_string);
68 .help =
"Attach a remote USB device",
74 .help =
"Detach a remote USB device",
80 .help =
"List exportable or local USB devices",
98 static int usbip_help(
int argc,
char *argv[])
104 if (argc > 1 && argv++) {
115 for (cmd = cmds; cmd->
name !=
NULL; cmd++)
123 static int usbip_version(
int argc,
char *argv[])
132 static int run_command(
const struct command *cmd,
int argc,
char *argv[])
134 dbg(
"running command: `%s'", cmd->
name);
135 return cmd->
fn(argc, argv);
138 int main(
int argc,
char *argv[])
140 static const struct option opts[] = {
141 {
"debug", no_argument,
NULL,
'd' },
142 {
"log", no_argument,
NULL,
'l' },
153 opt = getopt_long(argc, argv,
"+d", opts,
NULL);
164 openlog(
"", LOG_PID, LOG_USER);
167 printf(
"usbip: invalid option\n");
177 if (!
strcmp(cmds[i].name, cmd)) {
181 rc = run_command(&cmds[i], argc, argv);
189 return (rc > -1 ? EXIT_SUCCESS : EXIT_FAILURE);