[PATCH wayland 1/3] scanner: support help and --help

Kristian Høgsberg hoegsberg at gmail.com
Wed Aug 7 16:26:26 PDT 2013


On Wed, Aug 07, 2013 at 11:05:57AM +1000, Peter Hutterer wrote:
> 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.

These three patches look good, all applied.

Kristian

> ---
>  src/scanner.c | 29 +++++++++++++++++++++++------
>  1 file changed, 23 insertions(+), 6 deletions(-)
> 
> diff --git a/src/scanner.c b/src/scanner.c
> index 4aa70d1..ace6633 100644
> --- a/src/scanner.c
> +++ b/src/scanner.c
> @@ -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;
> -- 
> 1.8.2.1
> 
> _______________________________________________
> wayland-devel mailing list
> wayland-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/wayland-devel


More information about the wayland-devel mailing list