Browse Source

Let getopt() print error messages about options.

This removes tsdecrypt's error message in favour of getopt
native errors. Our message was always 'Unknown parameter'
which was not correct (most of the time) and very misleading.
Georgi Chorbadzhiyski 9 years ago
parent
commit
8c14716e5c
1 changed files with 1 additions and 4 deletions
  1. 1
    4
      tsdecrypt.c

+ 1
- 4
tsdecrypt.c View File

306
 
306
 
307
 static void parse_options(struct ts *ts, int argc, char **argv) {
307
 static void parse_options(struct ts *ts, int argc, char **argv) {
308
 	int j, i, ca_err = 0, server_err = 1, input_addr_err = 0, output_addr_err = 0, ident_err = 0, port_set = 0;
308
 	int j, i, ca_err = 0, server_err = 1, input_addr_err = 0, output_addr_err = 0, ident_err = 0, port_set = 0;
309
-	opterr = 0; // Prevent printing of error messages for unknown options in getopt()
310
 	while ((j = getopt_long(argc, argv, short_options, long_options, NULL)) != -1) {
309
 	while ((j = getopt_long(argc, argv, short_options, long_options, NULL)) != -1) {
311
-		if (j == '?') {
312
-			fprintf(stderr, "ERROR: Unknown parameter '%s'.\n", argv[optind - 1]);
310
+		if (j == '?')
313
 			exit(EXIT_FAILURE);
311
 			exit(EXIT_FAILURE);
314
-		}
315
 		switch (j) {
312
 		switch (j) {
316
 			case 'i': // -- ident
313
 			case 'i': // -- ident
317
 				ts->ident = optarg;
314
 				ts->ident = optarg;

Loading…
Cancel
Save