mirror of
https://gitlab.freedesktop.org/wayland/wayland.git
synced 2025-10-29 05:40:16 -04:00
scanner: support help and --help
wayland-scanner without arguments prints out usage. With help or --help it waits for stdin to supply something which isn't quite as informative as printing out the help. This patch also moves the strcmp for args up to have all of them in one location.
This commit is contained in:
parent
7db9d248ce
commit
a4ac7a6786
1 changed files with 23 additions and 6 deletions
|
|
@ -1158,9 +1158,22 @@ int main(int argc, char *argv[])
|
|||
struct protocol protocol;
|
||||
int len;
|
||||
void *buf;
|
||||
enum {
|
||||
CLIENT_HEADER,
|
||||
SERVER_HEADER,
|
||||
CODE,
|
||||
} mode;
|
||||
|
||||
if (argc != 2)
|
||||
usage(EXIT_FAILURE);
|
||||
else if (strcmp(argv[1], "help") == 0 || strcmp(argv[1], "--help") == 0)
|
||||
usage(EXIT_SUCCESS);
|
||||
else if (strcmp(argv[1], "client-header") == 0)
|
||||
mode = CLIENT_HEADER;
|
||||
else if (strcmp(argv[1], "server-header") == 0)
|
||||
mode = SERVER_HEADER;
|
||||
else if (strcmp(argv[1], "code") == 0)
|
||||
mode = CODE;
|
||||
|
||||
wl_list_init(&protocol.interface_list);
|
||||
protocol.type_index = 0;
|
||||
|
|
@ -1193,12 +1206,16 @@ int main(int argc, char *argv[])
|
|||
|
||||
XML_ParserFree(ctx.parser);
|
||||
|
||||
if (strcmp(argv[1], "client-header") == 0) {
|
||||
emit_header(&protocol, 0);
|
||||
} else if (strcmp(argv[1], "server-header") == 0) {
|
||||
emit_header(&protocol, 1);
|
||||
} else if (strcmp(argv[1], "code") == 0) {
|
||||
emit_code(&protocol);
|
||||
switch(mode) {
|
||||
case CLIENT_HEADER:
|
||||
emit_header(&protocol, 0);
|
||||
break;
|
||||
case SERVER_HEADER:
|
||||
emit_header(&protocol, 1);
|
||||
break;
|
||||
case CODE:
|
||||
emit_code(&protocol);
|
||||
break;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue