Statistics
| Branch: | Revision:

janus-gateway / cmdline.c @ 5e9e29e0

History | View | Annotate | Download (23.4 KB)

1 be35facb meetecho
/*
2
  File autogenerated by gengetopt version 2.22.5
3
  generated with the following command:
4
  gengetopt --set-package=janus --set-version=0.0.1 
5

6
  The developers of gengetopt consider the fixed text that goes in all
7
  gengetopt output files to be in the public domain:
8
  we make no copyright claims on it.
9
*/
10
11
/* If we use autoconf.  */
12
#ifdef HAVE_CONFIG_H
13
#include "config.h"
14
#endif
15
16
#include <stdio.h>
17
#include <stdlib.h>
18
#include <string.h>
19
20
#ifndef FIX_UNUSED
21
#define FIX_UNUSED(X) (void) (X) /* avoid warnings for unused params */
22
#endif
23
24
#include <getopt.h>
25
26
#include "cmdline.h"
27
28
const char *gengetopt_args_info_purpose = "";
29
30
const char *gengetopt_args_info_usage = "Usage: janus [OPTIONS]...";
31
32
const char *gengetopt_args_info_description = "";
33
34
const char *gengetopt_args_info_help[] = {
35
  "  -h, --help                    Print help and exit",
36
  "  -V, --version                 Print version and exit",
37
  "  -i, --interface=ipaddress     Interface to use (will be the public IP)",
38
  "  -p, --port=portnumber         Web server HTTP port (default=8088)",
39
  "  -s, --secure-port=portnumber  Web server HTTPS port (default=no HTTPS)",
40
  "  -n, --no-http                 Disable insecure HTTP web server  (default=off)",
41
  "  -b, --base-path=basepath      Base path to bind to in the web server \n                                  (default=/janus) ",
42
  "  -P, --plugins-folder=path     Plugins folder (default=./plugins)",
43
  "  -C, --config=path             Configuration file to use",
44
  "  -F, --configs-folder=path     Configuration files folder (default=./conf)",
45
  "  -c, --cert-pem=filename       HTTPS/DTLS certificate",
46
  "  -k, --cert-key=filename       HTTPS/DTLS certificate key",
47 5e9e29e0 meetecho
  "  -S, --stun-server=ip:port     STUN server(:port) to use, if needed (e.g., \n                                  gateway behind NAT, default=none)",
48
  "  -e, --public-ip=ipaddress     Public address of the machine, to use in SDP",
49
  "  -r, --rtp-port-range=min-max  Port range to use for RTP/RTCP",
50 be35facb meetecho
    0
51
};
52
53
typedef enum {ARG_NO
54
  , ARG_FLAG
55
  , ARG_STRING
56
  , ARG_INT
57
} cmdline_parser_arg_type;
58
59
static
60
void clear_given (struct gengetopt_args_info *args_info);
61
static
62
void clear_args (struct gengetopt_args_info *args_info);
63
64
static int
65
cmdline_parser_internal (int argc, char **argv, struct gengetopt_args_info *args_info,
66
                        struct cmdline_parser_params *params, const char *additional_error);
67
68
69
static char *
70
gengetopt_strdup (const char *s);
71
72
static
73
void clear_given (struct gengetopt_args_info *args_info)
74
{
75
  args_info->help_given = 0 ;
76
  args_info->version_given = 0 ;
77
  args_info->interface_given = 0 ;
78
  args_info->port_given = 0 ;
79
  args_info->secure_port_given = 0 ;
80
  args_info->no_http_given = 0 ;
81
  args_info->base_path_given = 0 ;
82
  args_info->plugins_folder_given = 0 ;
83
  args_info->config_given = 0 ;
84
  args_info->configs_folder_given = 0 ;
85
  args_info->cert_pem_given = 0 ;
86
  args_info->cert_key_given = 0 ;
87
  args_info->stun_server_given = 0 ;
88 5e9e29e0 meetecho
  args_info->public_ip_given = 0 ;
89
  args_info->rtp_port_range_given = 0 ;
90 be35facb meetecho
}
91
92
static
93
void clear_args (struct gengetopt_args_info *args_info)
94
{
95
  FIX_UNUSED (args_info);
96
  args_info->interface_arg = NULL;
97
  args_info->interface_orig = NULL;
98
  args_info->port_orig = NULL;
99
  args_info->secure_port_orig = NULL;
100
  args_info->no_http_flag = 0;
101
  args_info->base_path_arg = NULL;
102
  args_info->base_path_orig = NULL;
103
  args_info->plugins_folder_arg = NULL;
104
  args_info->plugins_folder_orig = NULL;
105
  args_info->config_arg = NULL;
106
  args_info->config_orig = NULL;
107
  args_info->configs_folder_arg = NULL;
108
  args_info->configs_folder_orig = NULL;
109
  args_info->cert_pem_arg = NULL;
110
  args_info->cert_pem_orig = NULL;
111
  args_info->cert_key_arg = NULL;
112
  args_info->cert_key_orig = NULL;
113
  args_info->stun_server_arg = NULL;
114
  args_info->stun_server_orig = NULL;
115 5e9e29e0 meetecho
  args_info->public_ip_arg = NULL;
116
  args_info->public_ip_orig = NULL;
117
  args_info->rtp_port_range_arg = NULL;
118
  args_info->rtp_port_range_orig = NULL;
119 be35facb meetecho
  
120
}
121
122
static
123
void init_args_info(struct gengetopt_args_info *args_info)
124
{
125
126
127
  args_info->help_help = gengetopt_args_info_help[0] ;
128
  args_info->version_help = gengetopt_args_info_help[1] ;
129
  args_info->interface_help = gengetopt_args_info_help[2] ;
130
  args_info->port_help = gengetopt_args_info_help[3] ;
131
  args_info->secure_port_help = gengetopt_args_info_help[4] ;
132
  args_info->no_http_help = gengetopt_args_info_help[5] ;
133
  args_info->base_path_help = gengetopt_args_info_help[6] ;
134
  args_info->plugins_folder_help = gengetopt_args_info_help[7] ;
135
  args_info->config_help = gengetopt_args_info_help[8] ;
136
  args_info->configs_folder_help = gengetopt_args_info_help[9] ;
137
  args_info->cert_pem_help = gengetopt_args_info_help[10] ;
138
  args_info->cert_key_help = gengetopt_args_info_help[11] ;
139
  args_info->stun_server_help = gengetopt_args_info_help[12] ;
140 5e9e29e0 meetecho
  args_info->public_ip_help = gengetopt_args_info_help[13] ;
141
  args_info->rtp_port_range_help = gengetopt_args_info_help[14] ;
142 be35facb meetecho
  
143
}
144
145
void
146
cmdline_parser_print_version (void)
147
{
148
  printf ("%s %s\n",
149
     (strlen(CMDLINE_PARSER_PACKAGE_NAME) ? CMDLINE_PARSER_PACKAGE_NAME : CMDLINE_PARSER_PACKAGE),
150
     CMDLINE_PARSER_VERSION);
151
}
152
153
static void print_help_common(void) {
154
  cmdline_parser_print_version ();
155
156
  if (strlen(gengetopt_args_info_purpose) > 0)
157
    printf("\n%s\n", gengetopt_args_info_purpose);
158
159
  if (strlen(gengetopt_args_info_usage) > 0)
160
    printf("\n%s\n", gengetopt_args_info_usage);
161
162
  printf("\n");
163
164
  if (strlen(gengetopt_args_info_description) > 0)
165
    printf("%s\n\n", gengetopt_args_info_description);
166
}
167
168
void
169
cmdline_parser_print_help (void)
170
{
171
  int i = 0;
172
  print_help_common();
173
  while (gengetopt_args_info_help[i])
174
    printf("%s\n", gengetopt_args_info_help[i++]);
175
}
176
177
void
178
cmdline_parser_init (struct gengetopt_args_info *args_info)
179
{
180
  clear_given (args_info);
181
  clear_args (args_info);
182
  init_args_info (args_info);
183
}
184
185
void
186
cmdline_parser_params_init(struct cmdline_parser_params *params)
187
{
188
  if (params)
189
    { 
190
      params->override = 0;
191
      params->initialize = 1;
192
      params->check_required = 1;
193
      params->check_ambiguity = 0;
194
      params->print_errors = 1;
195
    }
196
}
197
198
struct cmdline_parser_params *
199
cmdline_parser_params_create(void)
200
{
201
  struct cmdline_parser_params *params = 
202
    (struct cmdline_parser_params *)malloc(sizeof(struct cmdline_parser_params));
203
  cmdline_parser_params_init(params);  
204
  return params;
205
}
206
207
static void
208
free_string_field (char **s)
209
{
210
  if (*s)
211
    {
212
      free (*s);
213
      *s = 0;
214
    }
215
}
216
217
218
static void
219
cmdline_parser_release (struct gengetopt_args_info *args_info)
220
{
221
222
  free_string_field (&(args_info->interface_arg));
223
  free_string_field (&(args_info->interface_orig));
224
  free_string_field (&(args_info->port_orig));
225
  free_string_field (&(args_info->secure_port_orig));
226
  free_string_field (&(args_info->base_path_arg));
227
  free_string_field (&(args_info->base_path_orig));
228
  free_string_field (&(args_info->plugins_folder_arg));
229
  free_string_field (&(args_info->plugins_folder_orig));
230
  free_string_field (&(args_info->config_arg));
231
  free_string_field (&(args_info->config_orig));
232
  free_string_field (&(args_info->configs_folder_arg));
233
  free_string_field (&(args_info->configs_folder_orig));
234
  free_string_field (&(args_info->cert_pem_arg));
235
  free_string_field (&(args_info->cert_pem_orig));
236
  free_string_field (&(args_info->cert_key_arg));
237
  free_string_field (&(args_info->cert_key_orig));
238
  free_string_field (&(args_info->stun_server_arg));
239
  free_string_field (&(args_info->stun_server_orig));
240 5e9e29e0 meetecho
  free_string_field (&(args_info->public_ip_arg));
241
  free_string_field (&(args_info->public_ip_orig));
242
  free_string_field (&(args_info->rtp_port_range_arg));
243
  free_string_field (&(args_info->rtp_port_range_orig));
244 be35facb meetecho
  
245
  
246
247
  clear_given (args_info);
248
}
249
250
251
static void
252
write_into_file(FILE *outfile, const char *opt, const char *arg, const char *values[])
253
{
254
  FIX_UNUSED (values);
255
  if (arg) {
256
    fprintf(outfile, "%s=\"%s\"\n", opt, arg);
257
  } else {
258
    fprintf(outfile, "%s\n", opt);
259
  }
260
}
261
262
263
int
264
cmdline_parser_dump(FILE *outfile, struct gengetopt_args_info *args_info)
265
{
266
  int i = 0;
267
268
  if (!outfile)
269
    {
270
      fprintf (stderr, "%s: cannot dump options to stream\n", CMDLINE_PARSER_PACKAGE);
271
      return EXIT_FAILURE;
272
    }
273
274
  if (args_info->help_given)
275
    write_into_file(outfile, "help", 0, 0 );
276
  if (args_info->version_given)
277
    write_into_file(outfile, "version", 0, 0 );
278
  if (args_info->interface_given)
279
    write_into_file(outfile, "interface", args_info->interface_orig, 0);
280
  if (args_info->port_given)
281
    write_into_file(outfile, "port", args_info->port_orig, 0);
282
  if (args_info->secure_port_given)
283
    write_into_file(outfile, "secure-port", args_info->secure_port_orig, 0);
284
  if (args_info->no_http_given)
285
    write_into_file(outfile, "no-http", 0, 0 );
286
  if (args_info->base_path_given)
287
    write_into_file(outfile, "base-path", args_info->base_path_orig, 0);
288
  if (args_info->plugins_folder_given)
289
    write_into_file(outfile, "plugins-folder", args_info->plugins_folder_orig, 0);
290
  if (args_info->config_given)
291
    write_into_file(outfile, "config", args_info->config_orig, 0);
292
  if (args_info->configs_folder_given)
293
    write_into_file(outfile, "configs-folder", args_info->configs_folder_orig, 0);
294
  if (args_info->cert_pem_given)
295
    write_into_file(outfile, "cert-pem", args_info->cert_pem_orig, 0);
296
  if (args_info->cert_key_given)
297
    write_into_file(outfile, "cert-key", args_info->cert_key_orig, 0);
298
  if (args_info->stun_server_given)
299
    write_into_file(outfile, "stun-server", args_info->stun_server_orig, 0);
300 5e9e29e0 meetecho
  if (args_info->public_ip_given)
301
    write_into_file(outfile, "public-ip", args_info->public_ip_orig, 0);
302
  if (args_info->rtp_port_range_given)
303
    write_into_file(outfile, "rtp-port-range", args_info->rtp_port_range_orig, 0);
304 be35facb meetecho
  
305
306
  i = EXIT_SUCCESS;
307
  return i;
308
}
309
310
int
311
cmdline_parser_file_save(const char *filename, struct gengetopt_args_info *args_info)
312
{
313
  FILE *outfile;
314
  int i = 0;
315
316
  outfile = fopen(filename, "w");
317
318
  if (!outfile)
319
    {
320
      fprintf (stderr, "%s: cannot open file for writing: %s\n", CMDLINE_PARSER_PACKAGE, filename);
321
      return EXIT_FAILURE;
322
    }
323
324
  i = cmdline_parser_dump(outfile, args_info);
325
  fclose (outfile);
326
327
  return i;
328
}
329
330
void
331
cmdline_parser_free (struct gengetopt_args_info *args_info)
332
{
333
  cmdline_parser_release (args_info);
334
}
335
336
/** @brief replacement of strdup, which is not standard */
337
char *
338
gengetopt_strdup (const char *s)
339
{
340
  char *result = 0;
341
  if (!s)
342
    return result;
343
344
  result = (char*)malloc(strlen(s) + 1);
345
  if (result == (char*)0)
346
    return (char*)0;
347
  strcpy(result, s);
348
  return result;
349
}
350
351
int
352
cmdline_parser (int argc, char **argv, struct gengetopt_args_info *args_info)
353
{
354
  return cmdline_parser2 (argc, argv, args_info, 0, 1, 1);
355
}
356
357
int
358
cmdline_parser_ext (int argc, char **argv, struct gengetopt_args_info *args_info,
359
                   struct cmdline_parser_params *params)
360
{
361
  int result;
362
  result = cmdline_parser_internal (argc, argv, args_info, params, 0);
363
364
  if (result == EXIT_FAILURE)
365
    {
366
      cmdline_parser_free (args_info);
367
      exit (EXIT_FAILURE);
368
    }
369
  
370
  return result;
371
}
372
373
int
374
cmdline_parser2 (int argc, char **argv, struct gengetopt_args_info *args_info, int override, int initialize, int check_required)
375
{
376
  int result;
377
  struct cmdline_parser_params params;
378
  
379
  params.override = override;
380
  params.initialize = initialize;
381
  params.check_required = check_required;
382
  params.check_ambiguity = 0;
383
  params.print_errors = 1;
384
385
  result = cmdline_parser_internal (argc, argv, args_info, &params, 0);
386
387
  if (result == EXIT_FAILURE)
388
    {
389
      cmdline_parser_free (args_info);
390
      exit (EXIT_FAILURE);
391
    }
392
  
393
  return result;
394
}
395
396
int
397
cmdline_parser_required (struct gengetopt_args_info *args_info, const char *prog_name)
398
{
399
  FIX_UNUSED (args_info);
400
  FIX_UNUSED (prog_name);
401
  return EXIT_SUCCESS;
402
}
403
404
405
static char *package_name = 0;
406
407
/**
408
 * @brief updates an option
409
 * @param field the generic pointer to the field to update
410
 * @param orig_field the pointer to the orig field
411
 * @param field_given the pointer to the number of occurrence of this option
412
 * @param prev_given the pointer to the number of occurrence already seen
413
 * @param value the argument for this option (if null no arg was specified)
414
 * @param possible_values the possible values for this option (if specified)
415
 * @param default_value the default value (in case the option only accepts fixed values)
416
 * @param arg_type the type of this option
417
 * @param check_ambiguity @see cmdline_parser_params.check_ambiguity
418
 * @param override @see cmdline_parser_params.override
419
 * @param no_free whether to free a possible previous value
420
 * @param multiple_option whether this is a multiple option
421
 * @param long_opt the corresponding long option
422
 * @param short_opt the corresponding short option (or '-' if none)
423
 * @param additional_error possible further error specification
424
 */
425
static
426
int update_arg(void *field, char **orig_field,
427
               unsigned int *field_given, unsigned int *prev_given, 
428
               char *value, const char *possible_values[],
429
               const char *default_value,
430
               cmdline_parser_arg_type arg_type,
431
               int check_ambiguity, int override,
432
               int no_free, int multiple_option,
433
               const char *long_opt, char short_opt,
434
               const char *additional_error)
435
{
436
  char *stop_char = 0;
437
  const char *val = value;
438
  int found;
439
  char **string_field;
440
  FIX_UNUSED (field);
441
442
  stop_char = 0;
443
  found = 0;
444
445
  if (!multiple_option && prev_given && (*prev_given || (check_ambiguity && *field_given)))
446
    {
447
      if (short_opt != '-')
448
        fprintf (stderr, "%s: `--%s' (`-%c') option given more than once%s\n", 
449
               package_name, long_opt, short_opt,
450
               (additional_error ? additional_error : ""));
451
      else
452
        fprintf (stderr, "%s: `--%s' option given more than once%s\n", 
453
               package_name, long_opt,
454
               (additional_error ? additional_error : ""));
455
      return 1; /* failure */
456
    }
457
458
  FIX_UNUSED (default_value);
459
    
460
  if (field_given && *field_given && ! override)
461
    return 0;
462
  if (prev_given)
463
    (*prev_given)++;
464
  if (field_given)
465
    (*field_given)++;
466
  if (possible_values)
467
    val = possible_values[found];
468
469
  switch(arg_type) {
470
  case ARG_FLAG:
471
    *((int *)field) = !*((int *)field);
472
    break;
473
  case ARG_INT:
474
    if (val) *((int *)field) = strtol (val, &stop_char, 0);
475
    break;
476
  case ARG_STRING:
477
    if (val) {
478
      string_field = (char **)field;
479
      if (!no_free && *string_field)
480
        free (*string_field); /* free previous string */
481
      *string_field = gengetopt_strdup (val);
482
    }
483
    break;
484
  default:
485
    break;
486
  };
487
488
  /* check numeric conversion */
489
  switch(arg_type) {
490
  case ARG_INT:
491
    if (val && !(stop_char && *stop_char == '\0')) {
492
      fprintf(stderr, "%s: invalid numeric value: %s\n", package_name, val);
493
      return 1; /* failure */
494
    }
495
    break;
496
  default:
497
    ;
498
  };
499
500
  /* store the original value */
501
  switch(arg_type) {
502
  case ARG_NO:
503
  case ARG_FLAG:
504
    break;
505
  default:
506
    if (value && orig_field) {
507
      if (no_free) {
508
        *orig_field = value;
509
      } else {
510
        if (*orig_field)
511
          free (*orig_field); /* free previous string */
512
        *orig_field = gengetopt_strdup (value);
513
      }
514
    }
515
  };
516
517
  return 0; /* OK */
518
}
519
520
521
int
522
cmdline_parser_internal (
523
  int argc, char **argv, struct gengetopt_args_info *args_info,
524
                        struct cmdline_parser_params *params, const char *additional_error)
525
{
526
  int c;        /* Character of the parsed option.  */
527
528
  int error = 0;
529
  struct gengetopt_args_info local_args_info;
530
  
531
  int override;
532
  int initialize;
533
  int check_required;
534
  int check_ambiguity;
535
  
536
  package_name = argv[0];
537
  
538
  override = params->override;
539
  initialize = params->initialize;
540
  check_required = params->check_required;
541
  check_ambiguity = params->check_ambiguity;
542
543
  if (initialize)
544
    cmdline_parser_init (args_info);
545
546
  cmdline_parser_init (&local_args_info);
547
548
  optarg = 0;
549
  optind = 0;
550
  opterr = params->print_errors;
551
  optopt = '?';
552
553
  while (1)
554
    {
555
      int option_index = 0;
556
557
      static struct option long_options[] = {
558
        { "help",        0, NULL, 'h' },
559
        { "version",        0, NULL, 'V' },
560
        { "interface",        1, NULL, 'i' },
561
        { "port",        1, NULL, 'p' },
562
        { "secure-port",        1, NULL, 's' },
563
        { "no-http",        0, NULL, 'n' },
564
        { "base-path",        1, NULL, 'b' },
565
        { "plugins-folder",        1, NULL, 'P' },
566
        { "config",        1, NULL, 'C' },
567
        { "configs-folder",        1, NULL, 'F' },
568
        { "cert-pem",        1, NULL, 'c' },
569
        { "cert-key",        1, NULL, 'k' },
570
        { "stun-server",        1, NULL, 'S' },
571 5e9e29e0 meetecho
        { "public-ip",        1, NULL, 'e' },
572
        { "rtp-port-range",        1, NULL, 'r' },
573 be35facb meetecho
        { 0,  0, 0, 0 }
574
      };
575
576 5e9e29e0 meetecho
      c = getopt_long (argc, argv, "hVi:p:s:nb:P:C:F:c:k:S:e:r:", long_options, &option_index);
577 be35facb meetecho
578
      if (c == -1) break;        /* Exit from `while (1)' loop.  */
579
580
      switch (c)
581
        {
582
        case 'h':        /* Print help and exit.  */
583
          cmdline_parser_print_help ();
584
          cmdline_parser_free (&local_args_info);
585
          exit (EXIT_SUCCESS);
586
587
        case 'V':        /* Print version and exit.  */
588
          cmdline_parser_print_version ();
589
          cmdline_parser_free (&local_args_info);
590
          exit (EXIT_SUCCESS);
591
592
        case 'i':        /* Interface to use (will be the public IP).  */
593
        
594
        
595
          if (update_arg( (void *)&(args_info->interface_arg), 
596
               &(args_info->interface_orig), &(args_info->interface_given),
597
              &(local_args_info.interface_given), optarg, 0, 0, ARG_STRING,
598
              check_ambiguity, override, 0, 0,
599
              "interface", 'i',
600
              additional_error))
601
            goto failure;
602
        
603
          break;
604
        case 'p':        /* Web server HTTP port (default=8088).  */
605
        
606
        
607
          if (update_arg( (void *)&(args_info->port_arg), 
608
               &(args_info->port_orig), &(args_info->port_given),
609
              &(local_args_info.port_given), optarg, 0, 0, ARG_INT,
610
              check_ambiguity, override, 0, 0,
611
              "port", 'p',
612
              additional_error))
613
            goto failure;
614
        
615
          break;
616
        case 's':        /* Web server HTTPS port (default=no HTTPS).  */
617
        
618
        
619
          if (update_arg( (void *)&(args_info->secure_port_arg), 
620
               &(args_info->secure_port_orig), &(args_info->secure_port_given),
621
              &(local_args_info.secure_port_given), optarg, 0, 0, ARG_INT,
622
              check_ambiguity, override, 0, 0,
623
              "secure-port", 's',
624
              additional_error))
625
            goto failure;
626
        
627
          break;
628
        case 'n':        /* Disable insecure HTTP web server.  */
629
        
630
        
631
          if (update_arg((void *)&(args_info->no_http_flag), 0, &(args_info->no_http_given),
632
              &(local_args_info.no_http_given), optarg, 0, 0, ARG_FLAG,
633
              check_ambiguity, override, 1, 0, "no-http", 'n',
634
              additional_error))
635
            goto failure;
636
        
637
          break;
638
        case 'b':        /* Base path to bind to in the web server (default=/janus) .  */
639
        
640
        
641
          if (update_arg( (void *)&(args_info->base_path_arg), 
642
               &(args_info->base_path_orig), &(args_info->base_path_given),
643
              &(local_args_info.base_path_given), optarg, 0, 0, ARG_STRING,
644
              check_ambiguity, override, 0, 0,
645
              "base-path", 'b',
646
              additional_error))
647
            goto failure;
648
        
649
          break;
650
        case 'P':        /* Plugins folder (default=./plugins).  */
651
        
652
        
653
          if (update_arg( (void *)&(args_info->plugins_folder_arg), 
654
               &(args_info->plugins_folder_orig), &(args_info->plugins_folder_given),
655
              &(local_args_info.plugins_folder_given), optarg, 0, 0, ARG_STRING,
656
              check_ambiguity, override, 0, 0,
657
              "plugins-folder", 'P',
658
              additional_error))
659
            goto failure;
660
        
661
          break;
662
        case 'C':        /* Configuration file to use.  */
663
        
664
        
665
          if (update_arg( (void *)&(args_info->config_arg), 
666
               &(args_info->config_orig), &(args_info->config_given),
667
              &(local_args_info.config_given), optarg, 0, 0, ARG_STRING,
668
              check_ambiguity, override, 0, 0,
669
              "config", 'C',
670
              additional_error))
671
            goto failure;
672
        
673
          break;
674
        case 'F':        /* Configuration files folder (default=./conf).  */
675
        
676
        
677
          if (update_arg( (void *)&(args_info->configs_folder_arg), 
678
               &(args_info->configs_folder_orig), &(args_info->configs_folder_given),
679
              &(local_args_info.configs_folder_given), optarg, 0, 0, ARG_STRING,
680
              check_ambiguity, override, 0, 0,
681
              "configs-folder", 'F',
682
              additional_error))
683
            goto failure;
684
        
685
          break;
686
        case 'c':        /* HTTPS/DTLS certificate.  */
687
        
688
        
689
          if (update_arg( (void *)&(args_info->cert_pem_arg), 
690
               &(args_info->cert_pem_orig), &(args_info->cert_pem_given),
691
              &(local_args_info.cert_pem_given), optarg, 0, 0, ARG_STRING,
692
              check_ambiguity, override, 0, 0,
693
              "cert-pem", 'c',
694
              additional_error))
695
            goto failure;
696
        
697
          break;
698
        case 'k':        /* HTTPS/DTLS certificate key.  */
699
        
700
        
701
          if (update_arg( (void *)&(args_info->cert_key_arg), 
702
               &(args_info->cert_key_orig), &(args_info->cert_key_given),
703
              &(local_args_info.cert_key_given), optarg, 0, 0, ARG_STRING,
704
              check_ambiguity, override, 0, 0,
705
              "cert-key", 'k',
706
              additional_error))
707
            goto failure;
708
        
709
          break;
710
        case 'S':        /* STUN server(:port) to use, if needed (e.g., gateway behind NAT, default=none).  */
711
        
712
        
713
          if (update_arg( (void *)&(args_info->stun_server_arg), 
714
               &(args_info->stun_server_orig), &(args_info->stun_server_given),
715
              &(local_args_info.stun_server_given), optarg, 0, 0, ARG_STRING,
716
              check_ambiguity, override, 0, 0,
717
              "stun-server", 'S',
718
              additional_error))
719
            goto failure;
720
        
721
          break;
722 5e9e29e0 meetecho
        case 'e':        /* Public address of the machine, to use in SDP.  */
723
        
724
        
725
          if (update_arg( (void *)&(args_info->public_ip_arg), 
726
               &(args_info->public_ip_orig), &(args_info->public_ip_given),
727
              &(local_args_info.public_ip_given), optarg, 0, 0, ARG_STRING,
728
              check_ambiguity, override, 0, 0,
729
              "public-ip", 'e',
730
              additional_error))
731
            goto failure;
732
        
733
          break;
734
        case 'r':        /* Port range to use for RTP/RTCP.  */
735
        
736
        
737
          if (update_arg( (void *)&(args_info->rtp_port_range_arg), 
738
               &(args_info->rtp_port_range_orig), &(args_info->rtp_port_range_given),
739
              &(local_args_info.rtp_port_range_given), optarg, 0, 0, ARG_STRING,
740
              check_ambiguity, override, 0, 0,
741
              "rtp-port-range", 'r',
742
              additional_error))
743
            goto failure;
744
        
745
          break;
746 be35facb meetecho
747
        case 0:        /* Long option with no short option */
748
        case '?':        /* Invalid option.  */
749
          /* `getopt_long' already printed an error message.  */
750
          goto failure;
751
752
        default:        /* bug: option not considered.  */
753
          fprintf (stderr, "%s: option unknown: %c%s\n", CMDLINE_PARSER_PACKAGE, c, (additional_error ? additional_error : ""));
754
          abort ();
755
        } /* switch */
756
    } /* while */
757
758
759
760
761
  cmdline_parser_release (&local_args_info);
762
763
  if ( error )
764
    return (EXIT_FAILURE);
765
766
  return 0;
767
768
failure:
769
  
770
  cmdline_parser_release (&local_args_info);
771
  return (EXIT_FAILURE);
772
}