[PATCH wayland v3] Add support for direct file reading and writing in wayland-scanner.
Bill Spitzak
spitzak at gmail.com
Tue Mar 3 12:50:08 PST 2015
This is my suggested alteration of the patch to allow 3 arguments, there
is a * in front of my changed or added lines:
>> - if (argc != 2)
* + if (argc < 2 || argc > 4)
>> usage(EXIT_FAILURE);
>> else if (strcmp(argv[1], "help") == 0 || strcmp(argv[1], "--help") == 0)
>> usage(EXIT_SUCCESS);
>> @@ -1273,6 +1275,20 @@ int main(int argc, char *argv[])
>> else
>> usage(EXIT_FAILURE);
>>
>> + if (argc == 4) {
>> + input = fopen(argv[2], "r");
>> + if (input == NULL) {
>> + fprintf(stderr, "Could not open input file: %s\n",
>> + strerror(errno));
>> + exit(EXIT_FAILURE);
>> + }
* + }
* + if (argc > 2) {
>> + if (freopen(argv[3], "w", stdout) == NULL) {
>> + fprintf(stderr, "Could not open output file: %s\n",
>> + strerror(errno));
>> + exit(EXIT_FAILURE);
>> + }
The dashes are not a big deal and not worth adding.
Note there are no actual switches to this program, instead it's action
is controlled by it's first argument, which does not have a dash in
front of it. It's more like part of the command name. Since there are no
switches I don't see an option parsing library being useful.
More information about the wayland-devel
mailing list