Add missing binaty and statis library
[jabaws.git] / binaries / src / ViennaRNA / Progs / RNAparconv_cmdl.c
1 /*
2   File autogenerated by gengetopt version 2.22.5
3   generated with the following command:
4   gengetopt -i RNAparconv.ggo --file-name=RNAparconv_cmdl --include-getopt --default-optional --unamed-opts --func-name=RNAparconv_cmdline_parser --arg-struct-name=RNAparconv_args_info
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
25 #include "RNAparconv_cmdl.h"
26
27 const char *RNAparconv_args_info_purpose = "Convert energy parameter files from ViennaRNA 1.8.4 to 2.0 format";
28
29 const char *RNAparconv_args_info_usage = "Usage: RNAparconv [options] [<input file>] [<output file>]\n";
30
31 const char *RNAparconv_args_info_description = "Converts energy parameter files from \"old\" ViennaRNAPackage 1.8.4 format to \nthe new format used since ViennaRNAPackage 2.0.\nThe Program reads a valid energy parameter file or valid energy parameters from \nstdin and prints the converted energy parameters to stdout or a specified \noutput file. Per default, the converted output file contains the whole set of \nenergy parameters used throughout ViennaRNAPackage 1.8.4. The user can specify \nsets of energy parameters that should not be included in the output.\n";
32
33 const char *RNAparconv_args_info_full_help[] = {
34   "  -h, --help               Print help and exit",
35   "      --full-help          Print help, including hidden options, and exit",
36   "  -V, --version            Print version and exit",
37   "  -o, --output=filename    Specify an output file name. If argument is missing \n                             the converted energy parameters are printed to \n                             'stdout'.\n\n",
38   "  -i, --input=filename     Specify an input file name. If argument is missing \n                             the energy parameter input can be supplied via \n                             'stdin'.\n\n",
39   "      --vanilla            Print just as much as needed to represent the given \n                             energy parameters data set.\n                             This option overrides all other output settings!\n\n                               (default=off)",
40   "      --dump               Just dump Vienna 1.8.4 energy parameters in format \n                             used since 2.0.\n                             This option skips any energy parameter input!\n\n                               (default=off)",
41   "      --silent             Print just energy parameters and appropriate comment \n                             lines but suppress all other output\n\n                               (default=off)",
42   "      --without-HairpinE   Do not print converted hairpin energies and \n                             enthalpies\n\n                               (default=off)",
43   "      --without-StackE     Do not print converted stacking energies and \n                             enthalpies\n\n                               (default=off)",
44   "      --without-IntE       Do not print converted interior loop energies, \n                             enthalpies and asymetry factors\n\n                               (default=off)",
45   "      --without-BulgeE     Do not print converted bulge loop energies and \n                             enthalpies\n\n                               (default=off)",
46   "      --without-MultiE     Do not print converted multi loop energies and \n                             enthalpies\n\n                               (default=off)",
47   "      --without-MismatchE  Do not print converted exterior loop mismatch \n                             energies and enthalpies\n\n                               (default=off)",
48   "      --without-MismatchH  Do not print converted hairpin mismatch energies and \n                             enthalpies\n\n                               (default=off)",
49   "      --without-MismatchI  Do not print converted interior loop mismatch \n                             energies and enthalpies\n\n                               (default=off)",
50   "      --without-MismatchM  Do not print converted multi loop mismatch energies \n                             and enthalpies\n\n                               (default=off)",
51   "      --without-Dangle5    Do not print converted 5' dangle energies and \n                             enthalpies\n\n                               (default=off)",
52   "      --without-Dangle3    Do not print converted 3' dangle energies and \n                             enthalpies\n\n                               (default=off)",
53   "      --without-Misc       Do not print converted Misc energies and enthalpies \n                             (TerminalAU, DuplexInit, lxc)\n\n                               (default=off)",
54   "\nIf in doubt our program is right, nature is at fault.\nComments should be sent to rna@tbi.univie.ac.at.\n",
55     0
56 };
57
58 static void
59 init_help_array(void)
60 {
61   RNAparconv_args_info_help[0] = RNAparconv_args_info_full_help[0];
62   RNAparconv_args_info_help[1] = RNAparconv_args_info_full_help[1];
63   RNAparconv_args_info_help[2] = RNAparconv_args_info_full_help[2];
64   RNAparconv_args_info_help[3] = RNAparconv_args_info_full_help[3];
65   RNAparconv_args_info_help[4] = RNAparconv_args_info_full_help[4];
66   RNAparconv_args_info_help[5] = RNAparconv_args_info_full_help[5];
67   RNAparconv_args_info_help[6] = RNAparconv_args_info_full_help[6];
68   RNAparconv_args_info_help[7] = RNAparconv_args_info_full_help[7];
69   RNAparconv_args_info_help[8] = RNAparconv_args_info_full_help[20];
70   RNAparconv_args_info_help[9] = 0; 
71   
72 }
73
74 const char *RNAparconv_args_info_help[10];
75
76 typedef enum {ARG_NO
77   , ARG_FLAG
78   , ARG_STRING
79 } RNAparconv_cmdline_parser_arg_type;
80
81 static
82 void clear_given (struct RNAparconv_args_info *args_info);
83 static
84 void clear_args (struct RNAparconv_args_info *args_info);
85
86 static int
87 RNAparconv_cmdline_parser_internal (int argc, char **argv, struct RNAparconv_args_info *args_info,
88                         struct RNAparconv_cmdline_parser_params *params, const char *additional_error);
89
90
91 static char *
92 gengetopt_strdup (const char *s);
93
94 static
95 void clear_given (struct RNAparconv_args_info *args_info)
96 {
97   args_info->help_given = 0 ;
98   args_info->full_help_given = 0 ;
99   args_info->version_given = 0 ;
100   args_info->output_given = 0 ;
101   args_info->input_given = 0 ;
102   args_info->vanilla_given = 0 ;
103   args_info->dump_given = 0 ;
104   args_info->silent_given = 0 ;
105   args_info->without_HairpinE_given = 0 ;
106   args_info->without_StackE_given = 0 ;
107   args_info->without_IntE_given = 0 ;
108   args_info->without_BulgeE_given = 0 ;
109   args_info->without_MultiE_given = 0 ;
110   args_info->without_MismatchE_given = 0 ;
111   args_info->without_MismatchH_given = 0 ;
112   args_info->without_MismatchI_given = 0 ;
113   args_info->without_MismatchM_given = 0 ;
114   args_info->without_Dangle5_given = 0 ;
115   args_info->without_Dangle3_given = 0 ;
116   args_info->without_Misc_given = 0 ;
117 }
118
119 static
120 void clear_args (struct RNAparconv_args_info *args_info)
121 {
122   FIX_UNUSED (args_info);
123   args_info->output_arg = NULL;
124   args_info->output_orig = NULL;
125   args_info->input_arg = NULL;
126   args_info->input_orig = NULL;
127   args_info->vanilla_flag = 0;
128   args_info->dump_flag = 0;
129   args_info->silent_flag = 0;
130   args_info->without_HairpinE_flag = 0;
131   args_info->without_StackE_flag = 0;
132   args_info->without_IntE_flag = 0;
133   args_info->without_BulgeE_flag = 0;
134   args_info->without_MultiE_flag = 0;
135   args_info->without_MismatchE_flag = 0;
136   args_info->without_MismatchH_flag = 0;
137   args_info->without_MismatchI_flag = 0;
138   args_info->without_MismatchM_flag = 0;
139   args_info->without_Dangle5_flag = 0;
140   args_info->without_Dangle3_flag = 0;
141   args_info->without_Misc_flag = 0;
142   
143 }
144
145 static
146 void init_args_info(struct RNAparconv_args_info *args_info)
147 {
148
149   init_help_array(); 
150   args_info->help_help = RNAparconv_args_info_full_help[0] ;
151   args_info->full_help_help = RNAparconv_args_info_full_help[1] ;
152   args_info->version_help = RNAparconv_args_info_full_help[2] ;
153   args_info->output_help = RNAparconv_args_info_full_help[3] ;
154   args_info->input_help = RNAparconv_args_info_full_help[4] ;
155   args_info->vanilla_help = RNAparconv_args_info_full_help[5] ;
156   args_info->dump_help = RNAparconv_args_info_full_help[6] ;
157   args_info->silent_help = RNAparconv_args_info_full_help[7] ;
158   args_info->without_HairpinE_help = RNAparconv_args_info_full_help[8] ;
159   args_info->without_StackE_help = RNAparconv_args_info_full_help[9] ;
160   args_info->without_IntE_help = RNAparconv_args_info_full_help[10] ;
161   args_info->without_BulgeE_help = RNAparconv_args_info_full_help[11] ;
162   args_info->without_MultiE_help = RNAparconv_args_info_full_help[12] ;
163   args_info->without_MismatchE_help = RNAparconv_args_info_full_help[13] ;
164   args_info->without_MismatchH_help = RNAparconv_args_info_full_help[14] ;
165   args_info->without_MismatchI_help = RNAparconv_args_info_full_help[15] ;
166   args_info->without_MismatchM_help = RNAparconv_args_info_full_help[16] ;
167   args_info->without_Dangle5_help = RNAparconv_args_info_full_help[17] ;
168   args_info->without_Dangle3_help = RNAparconv_args_info_full_help[18] ;
169   args_info->without_Misc_help = RNAparconv_args_info_full_help[19] ;
170   
171 }
172
173 void
174 RNAparconv_cmdline_parser_print_version (void)
175 {
176   printf ("%s %s\n",
177      (strlen(RNAPARCONV_CMDLINE_PARSER_PACKAGE_NAME) ? RNAPARCONV_CMDLINE_PARSER_PACKAGE_NAME : RNAPARCONV_CMDLINE_PARSER_PACKAGE),
178      RNAPARCONV_CMDLINE_PARSER_VERSION);
179 }
180
181 static void print_help_common(void) {
182   RNAparconv_cmdline_parser_print_version ();
183
184   if (strlen(RNAparconv_args_info_purpose) > 0)
185     printf("\n%s\n", RNAparconv_args_info_purpose);
186
187   if (strlen(RNAparconv_args_info_usage) > 0)
188     printf("\n%s\n", RNAparconv_args_info_usage);
189
190   printf("\n");
191
192   if (strlen(RNAparconv_args_info_description) > 0)
193     printf("%s\n\n", RNAparconv_args_info_description);
194 }
195
196 void
197 RNAparconv_cmdline_parser_print_help (void)
198 {
199   int i = 0;
200   print_help_common();
201   while (RNAparconv_args_info_help[i])
202     printf("%s\n", RNAparconv_args_info_help[i++]);
203 }
204
205 void
206 RNAparconv_cmdline_parser_print_full_help (void)
207 {
208   int i = 0;
209   print_help_common();
210   while (RNAparconv_args_info_full_help[i])
211     printf("%s\n", RNAparconv_args_info_full_help[i++]);
212 }
213
214 void
215 RNAparconv_cmdline_parser_init (struct RNAparconv_args_info *args_info)
216 {
217   clear_given (args_info);
218   clear_args (args_info);
219   init_args_info (args_info);
220
221   args_info->inputs = 0;
222   args_info->inputs_num = 0;
223 }
224
225 void
226 RNAparconv_cmdline_parser_params_init(struct RNAparconv_cmdline_parser_params *params)
227 {
228   if (params)
229     { 
230       params->override = 0;
231       params->initialize = 1;
232       params->check_required = 1;
233       params->check_ambiguity = 0;
234       params->print_errors = 1;
235     }
236 }
237
238 struct RNAparconv_cmdline_parser_params *
239 RNAparconv_cmdline_parser_params_create(void)
240 {
241   struct RNAparconv_cmdline_parser_params *params = 
242     (struct RNAparconv_cmdline_parser_params *)malloc(sizeof(struct RNAparconv_cmdline_parser_params));
243   RNAparconv_cmdline_parser_params_init(params);  
244   return params;
245 }
246
247 static void
248 free_string_field (char **s)
249 {
250   if (*s)
251     {
252       free (*s);
253       *s = 0;
254     }
255 }
256
257
258 static void
259 RNAparconv_cmdline_parser_release (struct RNAparconv_args_info *args_info)
260 {
261   unsigned int i;
262   free_string_field (&(args_info->output_arg));
263   free_string_field (&(args_info->output_orig));
264   free_string_field (&(args_info->input_arg));
265   free_string_field (&(args_info->input_orig));
266   
267   
268   for (i = 0; i < args_info->inputs_num; ++i)
269     free (args_info->inputs [i]);
270
271   if (args_info->inputs_num)
272     free (args_info->inputs);
273
274   clear_given (args_info);
275 }
276
277
278 static void
279 write_into_file(FILE *outfile, const char *opt, const char *arg, const char *values[])
280 {
281   FIX_UNUSED (values);
282   if (arg) {
283     fprintf(outfile, "%s=\"%s\"\n", opt, arg);
284   } else {
285     fprintf(outfile, "%s\n", opt);
286   }
287 }
288
289
290 int
291 RNAparconv_cmdline_parser_dump(FILE *outfile, struct RNAparconv_args_info *args_info)
292 {
293   int i = 0;
294
295   if (!outfile)
296     {
297       fprintf (stderr, "%s: cannot dump options to stream\n", RNAPARCONV_CMDLINE_PARSER_PACKAGE);
298       return EXIT_FAILURE;
299     }
300
301   if (args_info->help_given)
302     write_into_file(outfile, "help", 0, 0 );
303   if (args_info->full_help_given)
304     write_into_file(outfile, "full-help", 0, 0 );
305   if (args_info->version_given)
306     write_into_file(outfile, "version", 0, 0 );
307   if (args_info->output_given)
308     write_into_file(outfile, "output", args_info->output_orig, 0);
309   if (args_info->input_given)
310     write_into_file(outfile, "input", args_info->input_orig, 0);
311   if (args_info->vanilla_given)
312     write_into_file(outfile, "vanilla", 0, 0 );
313   if (args_info->dump_given)
314     write_into_file(outfile, "dump", 0, 0 );
315   if (args_info->silent_given)
316     write_into_file(outfile, "silent", 0, 0 );
317   if (args_info->without_HairpinE_given)
318     write_into_file(outfile, "without-HairpinE", 0, 0 );
319   if (args_info->without_StackE_given)
320     write_into_file(outfile, "without-StackE", 0, 0 );
321   if (args_info->without_IntE_given)
322     write_into_file(outfile, "without-IntE", 0, 0 );
323   if (args_info->without_BulgeE_given)
324     write_into_file(outfile, "without-BulgeE", 0, 0 );
325   if (args_info->without_MultiE_given)
326     write_into_file(outfile, "without-MultiE", 0, 0 );
327   if (args_info->without_MismatchE_given)
328     write_into_file(outfile, "without-MismatchE", 0, 0 );
329   if (args_info->without_MismatchH_given)
330     write_into_file(outfile, "without-MismatchH", 0, 0 );
331   if (args_info->without_MismatchI_given)
332     write_into_file(outfile, "without-MismatchI", 0, 0 );
333   if (args_info->without_MismatchM_given)
334     write_into_file(outfile, "without-MismatchM", 0, 0 );
335   if (args_info->without_Dangle5_given)
336     write_into_file(outfile, "without-Dangle5", 0, 0 );
337   if (args_info->without_Dangle3_given)
338     write_into_file(outfile, "without-Dangle3", 0, 0 );
339   if (args_info->without_Misc_given)
340     write_into_file(outfile, "without-Misc", 0, 0 );
341   
342
343   i = EXIT_SUCCESS;
344   return i;
345 }
346
347 int
348 RNAparconv_cmdline_parser_file_save(const char *filename, struct RNAparconv_args_info *args_info)
349 {
350   FILE *outfile;
351   int i = 0;
352
353   outfile = fopen(filename, "w");
354
355   if (!outfile)
356     {
357       fprintf (stderr, "%s: cannot open file for writing: %s\n", RNAPARCONV_CMDLINE_PARSER_PACKAGE, filename);
358       return EXIT_FAILURE;
359     }
360
361   i = RNAparconv_cmdline_parser_dump(outfile, args_info);
362   fclose (outfile);
363
364   return i;
365 }
366
367 void
368 RNAparconv_cmdline_parser_free (struct RNAparconv_args_info *args_info)
369 {
370   RNAparconv_cmdline_parser_release (args_info);
371 }
372
373 /** @brief replacement of strdup, which is not standard */
374 char *
375 gengetopt_strdup (const char *s)
376 {
377   char *result = 0;
378   if (!s)
379     return result;
380
381   result = (char*)malloc(strlen(s) + 1);
382   if (result == (char*)0)
383     return (char*)0;
384   strcpy(result, s);
385   return result;
386 }
387
388 int
389 RNAparconv_cmdline_parser (int argc, char **argv, struct RNAparconv_args_info *args_info)
390 {
391   return RNAparconv_cmdline_parser2 (argc, argv, args_info, 0, 1, 1);
392 }
393
394 int
395 RNAparconv_cmdline_parser_ext (int argc, char **argv, struct RNAparconv_args_info *args_info,
396                    struct RNAparconv_cmdline_parser_params *params)
397 {
398   int result;
399   result = RNAparconv_cmdline_parser_internal (argc, argv, args_info, params, 0);
400
401   if (result == EXIT_FAILURE)
402     {
403       RNAparconv_cmdline_parser_free (args_info);
404       exit (EXIT_FAILURE);
405     }
406   
407   return result;
408 }
409
410 int
411 RNAparconv_cmdline_parser2 (int argc, char **argv, struct RNAparconv_args_info *args_info, int override, int initialize, int check_required)
412 {
413   int result;
414   struct RNAparconv_cmdline_parser_params params;
415   
416   params.override = override;
417   params.initialize = initialize;
418   params.check_required = check_required;
419   params.check_ambiguity = 0;
420   params.print_errors = 1;
421
422   result = RNAparconv_cmdline_parser_internal (argc, argv, args_info, &params, 0);
423
424   if (result == EXIT_FAILURE)
425     {
426       RNAparconv_cmdline_parser_free (args_info);
427       exit (EXIT_FAILURE);
428     }
429   
430   return result;
431 }
432
433 int
434 RNAparconv_cmdline_parser_required (struct RNAparconv_args_info *args_info, const char *prog_name)
435 {
436   FIX_UNUSED (args_info);
437   FIX_UNUSED (prog_name);
438   return EXIT_SUCCESS;
439 }
440
441 /*
442  * Extracted from the glibc source tree, version 2.3.6
443  *
444  * Licensed under the GPL as per the whole glibc source tree.
445  *
446  * This file was modified so that getopt_long can be called
447  * many times without risking previous memory to be spoiled.
448  *
449  * Modified by Andre Noll and Lorenzo Bettini for use in
450  * GNU gengetopt generated files.
451  *
452  */
453
454 /* 
455  * we must include anything we need since this file is not thought to be
456  * inserted in a file already using getopt.h
457  *
458  * Lorenzo
459  */
460
461 struct option
462 {
463   const char *name;
464   /* has_arg can't be an enum because some compilers complain about
465      type mismatches in all the code that assumes it is an int.  */
466   int has_arg;
467   int *flag;
468   int val;
469 };
470
471 /* This version of `getopt' appears to the caller like standard Unix `getopt'
472    but it behaves differently for the user, since it allows the user
473    to intersperse the options with the other arguments.
474
475    As `getopt' works, it permutes the elements of ARGV so that,
476    when it is done, all the options precede everything else.  Thus
477    all application programs are extended to handle flexible argument order.
478 */
479 /*
480    If the field `flag' is not NULL, it points to a variable that is set
481    to the value given in the field `val' when the option is found, but
482    left unchanged if the option is not found.
483
484    To have a long-named option do something other than set an `int' to
485    a compiled-in constant, such as set a value from `custom_optarg', set the
486    option's `flag' field to zero and its `val' field to a nonzero
487    value (the equivalent single-letter option character, if there is
488    one).  For long options that have a zero `flag' field, `getopt'
489    returns the contents of the `val' field.  */
490
491 /* Names for the values of the `has_arg' field of `struct option'.  */
492 #ifndef no_argument
493 #define no_argument             0
494 #endif
495
496 #ifndef required_argument
497 #define required_argument       1
498 #endif
499
500 #ifndef optional_argument
501 #define optional_argument       2
502 #endif
503
504 struct custom_getopt_data {
505         /*
506          * These have exactly the same meaning as the corresponding global variables,
507          * except that they are used for the reentrant versions of getopt.
508          */
509         int custom_optind;
510         int custom_opterr;
511         int custom_optopt;
512         char *custom_optarg;
513
514         /* True if the internal members have been initialized.  */
515         int initialized;
516
517         /*
518          * The next char to be scanned in the option-element in which the last option
519          * character we returned was found.  This allows us to pick up the scan where
520          * we left off.  If this is zero, or a null string, it means resume the scan by
521          * advancing to the next ARGV-element.
522          */
523         char *nextchar;
524
525         /*
526          * Describe the part of ARGV that contains non-options that have been skipped.
527          * `first_nonopt' is the index in ARGV of the first of them; `last_nonopt' is
528          * the index after the last of them.
529          */
530         int first_nonopt;
531         int last_nonopt;
532 };
533
534 /*
535  * the variables optarg, optind, opterr and optopt are renamed with
536  * the custom_ prefix so that they don't interfere with getopt ones.
537  *
538  * Moreover they're static so they are visible only from within the
539  * file where this very file will be included.
540  */
541
542 /*
543  * For communication from `custom_getopt' to the caller.  When `custom_getopt' finds an
544  * option that takes an argument, the argument value is returned here.
545  */
546 static char *custom_optarg;
547
548 /*
549  * Index in ARGV of the next element to be scanned.  This is used for
550  * communication to and from the caller and for communication between
551  * successive calls to `custom_getopt'.
552  *
553  * On entry to `custom_getopt', 1 means this is the first call; initialize.
554  *
555  * When `custom_getopt' returns -1, this is the index of the first of the non-option
556  * elements that the caller should itself scan.
557  *
558  * Otherwise, `custom_optind' communicates from one call to the next how much of ARGV
559  * has been scanned so far.
560  *
561  * 1003.2 says this must be 1 before any call.
562  */
563 static int custom_optind = 1;
564
565 /*
566  * Callers store zero here to inhibit the error message for unrecognized
567  * options.
568  */
569 static int custom_opterr = 1;
570
571 /*
572  * Set to an option character which was unrecognized.  This must be initialized
573  * on some systems to avoid linking in the system's own getopt implementation.
574  */
575 static int custom_optopt = '?';
576
577 /*
578  * Exchange two adjacent subsequences of ARGV.  One subsequence is elements
579  * [first_nonopt,last_nonopt) which contains all the non-options that have been
580  * skipped so far.  The other is elements [last_nonopt,custom_optind), which contains
581  * all the options processed since those non-options were skipped.
582  * `first_nonopt' and `last_nonopt' are relocated so that they describe the new
583  * indices of the non-options in ARGV after they are moved.
584  */
585 static void exchange(char **argv, struct custom_getopt_data *d)
586 {
587         int bottom = d->first_nonopt;
588         int middle = d->last_nonopt;
589         int top = d->custom_optind;
590         char *tem;
591
592         /*
593          * Exchange the shorter segment with the far end of the longer segment.
594          * That puts the shorter segment into the right place.  It leaves the
595          * longer segment in the right place overall, but it consists of two
596          * parts that need to be swapped next.
597          */
598         while (top > middle && middle > bottom) {
599                 if (top - middle > middle - bottom) {
600                         /* Bottom segment is the short one.  */
601                         int len = middle - bottom;
602                         int i;
603
604                         /* Swap it with the top part of the top segment.  */
605                         for (i = 0; i < len; i++) {
606                                 tem = argv[bottom + i];
607                                 argv[bottom + i] =
608                                         argv[top - (middle - bottom) + i];
609                                 argv[top - (middle - bottom) + i] = tem;
610                         }
611                         /* Exclude the moved bottom segment from further swapping.  */
612                         top -= len;
613                 } else {
614                         /* Top segment is the short one.  */
615                         int len = top - middle;
616                         int i;
617
618                         /* Swap it with the bottom part of the bottom segment.  */
619                         for (i = 0; i < len; i++) {
620                                 tem = argv[bottom + i];
621                                 argv[bottom + i] = argv[middle + i];
622                                 argv[middle + i] = tem;
623                         }
624                         /* Exclude the moved top segment from further swapping.  */
625                         bottom += len;
626                 }
627         }
628         /* Update records for the slots the non-options now occupy.  */
629         d->first_nonopt += (d->custom_optind - d->last_nonopt);
630         d->last_nonopt = d->custom_optind;
631 }
632
633 /* Initialize the internal data when the first call is made.  */
634 static void custom_getopt_initialize(struct custom_getopt_data *d)
635 {
636         /*
637          * Start processing options with ARGV-element 1 (since ARGV-element 0
638          * is the program name); the sequence of previously skipped non-option
639          * ARGV-elements is empty.
640          */
641         d->first_nonopt = d->last_nonopt = d->custom_optind;
642         d->nextchar = NULL;
643         d->initialized = 1;
644 }
645
646 #define NONOPTION_P (argv[d->custom_optind][0] != '-' || argv[d->custom_optind][1] == '\0')
647
648 /* return: zero: continue, nonzero: return given value to user */
649 static int shuffle_argv(int argc, char *const *argv,const struct option *longopts,
650         struct custom_getopt_data *d)
651 {
652         /*
653          * Give FIRST_NONOPT & LAST_NONOPT rational values if CUSTOM_OPTIND has been
654          * moved back by the user (who may also have changed the arguments).
655          */
656         if (d->last_nonopt > d->custom_optind)
657                 d->last_nonopt = d->custom_optind;
658         if (d->first_nonopt > d->custom_optind)
659                 d->first_nonopt = d->custom_optind;
660         /*
661          * If we have just processed some options following some
662          * non-options, exchange them so that the options come first.
663          */
664         if (d->first_nonopt != d->last_nonopt &&
665                         d->last_nonopt != d->custom_optind)
666                 exchange((char **) argv, d);
667         else if (d->last_nonopt != d->custom_optind)
668                 d->first_nonopt = d->custom_optind;
669         /*
670          * Skip any additional non-options and extend the range of
671          * non-options previously skipped.
672          */
673         while (d->custom_optind < argc && NONOPTION_P)
674                 d->custom_optind++;
675         d->last_nonopt = d->custom_optind;
676         /*
677          * The special ARGV-element `--' means premature end of options.  Skip
678          * it like a null option, then exchange with previous non-options as if
679          * it were an option, then skip everything else like a non-option.
680          */
681         if (d->custom_optind != argc && !strcmp(argv[d->custom_optind], "--")) {
682                 d->custom_optind++;
683                 if (d->first_nonopt != d->last_nonopt
684                                 && d->last_nonopt != d->custom_optind)
685                         exchange((char **) argv, d);
686                 else if (d->first_nonopt == d->last_nonopt)
687                         d->first_nonopt = d->custom_optind;
688                 d->last_nonopt = argc;
689                 d->custom_optind = argc;
690         }
691         /*
692          * If we have done all the ARGV-elements, stop the scan and back over
693          * any non-options that we skipped and permuted.
694          */
695         if (d->custom_optind == argc) {
696                 /*
697                  * Set the next-arg-index to point at the non-options that we
698                  * previously skipped, so the caller will digest them.
699                  */
700                 if (d->first_nonopt != d->last_nonopt)
701                         d->custom_optind = d->first_nonopt;
702                 return -1;
703         }
704         /*
705          * If we have come to a non-option and did not permute it, either stop
706          * the scan or describe it to the caller and pass it by.
707          */
708         if (NONOPTION_P) {
709                 d->custom_optarg = argv[d->custom_optind++];
710                 return 1;
711         }
712         /*
713          * We have found another option-ARGV-element. Skip the initial
714          * punctuation.
715          */
716         d->nextchar = (argv[d->custom_optind] + 1 + (longopts != NULL && argv[d->custom_optind][1] == '-'));
717         return 0;
718 }
719
720 /*
721  * Check whether the ARGV-element is a long option.
722  *
723  * If there's a long option "fubar" and the ARGV-element is "-fu", consider
724  * that an abbreviation of the long option, just like "--fu", and not "-f" with
725  * arg "u".
726  *
727  * This distinction seems to be the most useful approach.
728  *
729  */
730 static int check_long_opt(int argc, char *const *argv, const char *optstring,
731                 const struct option *longopts, int *longind,
732                 int print_errors, struct custom_getopt_data *d)
733 {
734         char *nameend;
735         const struct option *p;
736         const struct option *pfound = NULL;
737         int exact = 0;
738         int ambig = 0;
739         int indfound = -1;
740         int option_index;
741
742         for (nameend = d->nextchar; *nameend && *nameend != '='; nameend++)
743                 /* Do nothing.  */ ;
744
745         /* Test all long options for either exact match or abbreviated matches */
746         for (p = longopts, option_index = 0; p->name; p++, option_index++)
747                 if (!strncmp(p->name, d->nextchar, nameend - d->nextchar)) {
748                         if ((unsigned int) (nameend - d->nextchar)
749                                         == (unsigned int) strlen(p->name)) {
750                                 /* Exact match found.  */
751                                 pfound = p;
752                                 indfound = option_index;
753                                 exact = 1;
754                                 break;
755                         } else if (pfound == NULL) {
756                                 /* First nonexact match found.  */
757                                 pfound = p;
758                                 indfound = option_index;
759                         } else if (pfound->has_arg != p->has_arg
760                                         || pfound->flag != p->flag
761                                         || pfound->val != p->val)
762                                 /* Second or later nonexact match found.  */
763                                 ambig = 1;
764                 }
765         if (ambig && !exact) {
766                 if (print_errors) {
767                         fprintf(stderr,
768                                 "%s: option `%s' is ambiguous\n",
769                                 argv[0], argv[d->custom_optind]);
770                 }
771                 d->nextchar += strlen(d->nextchar);
772                 d->custom_optind++;
773                 d->custom_optopt = 0;
774                 return '?';
775         }
776         if (pfound) {
777                 option_index = indfound;
778                 d->custom_optind++;
779                 if (*nameend) {
780                         if (pfound->has_arg != no_argument)
781                                 d->custom_optarg = nameend + 1;
782                         else {
783                                 if (print_errors) {
784                                         if (argv[d->custom_optind - 1][1] == '-') {
785                                                 /* --option */
786                                                 fprintf(stderr, "%s: option `--%s' doesn't allow an argument\n",
787                                                         argv[0], pfound->name);
788                                         } else {
789                                                 /* +option or -option */
790                                                 fprintf(stderr, "%s: option `%c%s' doesn't allow an argument\n",
791                                                         argv[0], argv[d->custom_optind - 1][0], pfound->name);
792                                         }
793
794                                 }
795                                 d->nextchar += strlen(d->nextchar);
796                                 d->custom_optopt = pfound->val;
797                                 return '?';
798                         }
799                 } else if (pfound->has_arg == required_argument) {
800                         if (d->custom_optind < argc)
801                                 d->custom_optarg = argv[d->custom_optind++];
802                         else {
803                                 if (print_errors) {
804                                         fprintf(stderr,
805                                                 "%s: option `%s' requires an argument\n",
806                                                 argv[0],
807                                                 argv[d->custom_optind - 1]);
808                                 }
809                                 d->nextchar += strlen(d->nextchar);
810                                 d->custom_optopt = pfound->val;
811                                 return optstring[0] == ':' ? ':' : '?';
812                         }
813                 }
814                 d->nextchar += strlen(d->nextchar);
815                 if (longind != NULL)
816                         *longind = option_index;
817                 if (pfound->flag) {
818                         *(pfound->flag) = pfound->val;
819                         return 0;
820                 }
821                 return pfound->val;
822         }
823         /*
824          * Can't find it as a long option.  If this is not getopt_long_only, or
825          * the option starts with '--' or is not a valid short option, then
826          * it's an error.  Otherwise interpret it as a short option.
827          */
828         if (print_errors) {
829                 if (argv[d->custom_optind][1] == '-') {
830                         /* --option */
831                         fprintf(stderr,
832                                 "%s: unrecognized option `--%s'\n",
833                                 argv[0], d->nextchar);
834                 } else {
835                         /* +option or -option */
836                         fprintf(stderr,
837                                 "%s: unrecognized option `%c%s'\n",
838                                 argv[0], argv[d->custom_optind][0],
839                                 d->nextchar);
840                 }
841         }
842         d->nextchar = (char *) "";
843         d->custom_optind++;
844         d->custom_optopt = 0;
845         return '?';
846 }
847
848 static int check_short_opt(int argc, char *const *argv, const char *optstring,
849                 int print_errors, struct custom_getopt_data *d)
850 {
851         char c = *d->nextchar++;
852         const char *temp = strchr(optstring, c);
853
854         /* Increment `custom_optind' when we start to process its last character.  */
855         if (*d->nextchar == '\0')
856                 ++d->custom_optind;
857         if (!temp || c == ':') {
858                 if (print_errors)
859                         fprintf(stderr, "%s: invalid option -- %c\n", argv[0], c);
860
861                 d->custom_optopt = c;
862                 return '?';
863         }
864         if (temp[1] == ':') {
865                 if (temp[2] == ':') {
866                         /* This is an option that accepts an argument optionally.  */
867                         if (*d->nextchar != '\0') {
868                                 d->custom_optarg = d->nextchar;
869                                 d->custom_optind++;
870                         } else
871                                 d->custom_optarg = NULL;
872                         d->nextchar = NULL;
873                 } else {
874                         /* This is an option that requires an argument.  */
875                         if (*d->nextchar != '\0') {
876                                 d->custom_optarg = d->nextchar;
877                                 /*
878                                  * If we end this ARGV-element by taking the
879                                  * rest as an arg, we must advance to the next
880                                  * element now.
881                                  */
882                                 d->custom_optind++;
883                         } else if (d->custom_optind == argc) {
884                                 if (print_errors) {
885                                         fprintf(stderr,
886                                                 "%s: option requires an argument -- %c\n",
887                                                 argv[0], c);
888                                 }
889                                 d->custom_optopt = c;
890                                 if (optstring[0] == ':')
891                                         c = ':';
892                                 else
893                                         c = '?';
894                         } else
895                                 /*
896                                  * We already incremented `custom_optind' once;
897                                  * increment it again when taking next ARGV-elt
898                                  * as argument.
899                                  */
900                                 d->custom_optarg = argv[d->custom_optind++];
901                         d->nextchar = NULL;
902                 }
903         }
904         return c;
905 }
906
907 /*
908  * Scan elements of ARGV for option characters given in OPTSTRING.
909  *
910  * If an element of ARGV starts with '-', and is not exactly "-" or "--",
911  * then it is an option element.  The characters of this element
912  * (aside from the initial '-') are option characters.  If `getopt'
913  * is called repeatedly, it returns successively each of the option characters
914  * from each of the option elements.
915  *
916  * If `getopt' finds another option character, it returns that character,
917  * updating `custom_optind' and `nextchar' so that the next call to `getopt' can
918  * resume the scan with the following option character or ARGV-element.
919  *
920  * If there are no more option characters, `getopt' returns -1.
921  * Then `custom_optind' is the index in ARGV of the first ARGV-element
922  * that is not an option.  (The ARGV-elements have been permuted
923  * so that those that are not options now come last.)
924  *
925  * OPTSTRING is a string containing the legitimate option characters.
926  * If an option character is seen that is not listed in OPTSTRING,
927  * return '?' after printing an error message.  If you set `custom_opterr' to
928  * zero, the error message is suppressed but we still return '?'.
929  *
930  * If a char in OPTSTRING is followed by a colon, that means it wants an arg,
931  * so the following text in the same ARGV-element, or the text of the following
932  * ARGV-element, is returned in `custom_optarg'.  Two colons mean an option that
933  * wants an optional arg; if there is text in the current ARGV-element,
934  * it is returned in `custom_optarg', otherwise `custom_optarg' is set to zero.
935  *
936  * If OPTSTRING starts with `-' or `+', it requests different methods of
937  * handling the non-option ARGV-elements.
938  * See the comments about RETURN_IN_ORDER and REQUIRE_ORDER, above.
939  *
940  * Long-named options begin with `--' instead of `-'.
941  * Their names may be abbreviated as long as the abbreviation is unique
942  * or is an exact match for some defined option.  If they have an
943  * argument, it follows the option name in the same ARGV-element, separated
944  * from the option name by a `=', or else the in next ARGV-element.
945  * When `getopt' finds a long-named option, it returns 0 if that option's
946  * `flag' field is nonzero, the value of the option's `val' field
947  * if the `flag' field is zero.
948  *
949  * The elements of ARGV aren't really const, because we permute them.
950  * But we pretend they're const in the prototype to be compatible
951  * with other systems.
952  *
953  * LONGOPTS is a vector of `struct option' terminated by an
954  * element containing a name which is zero.
955  *
956  * LONGIND returns the index in LONGOPT of the long-named option found.
957  * It is only valid when a long-named option has been found by the most
958  * recent call.
959  *
960  * Return the option character from OPTS just read.  Return -1 when there are
961  * no more options.  For unrecognized options, or options missing arguments,
962  * `custom_optopt' is set to the option letter, and '?' is returned.
963  *
964  * The OPTS string is a list of characters which are recognized option letters,
965  * optionally followed by colons, specifying that that letter takes an
966  * argument, to be placed in `custom_optarg'.
967  *
968  * If a letter in OPTS is followed by two colons, its argument is optional.
969  * This behavior is specific to the GNU `getopt'.
970  *
971  * The argument `--' causes premature termination of argument scanning,
972  * explicitly telling `getopt' that there are no more options.  If OPTS begins
973  * with `--', then non-option arguments are treated as arguments to the option
974  * '\0'.  This behavior is specific to the GNU `getopt'.
975  */
976
977 static int getopt_internal_r(int argc, char *const *argv, const char *optstring,
978                 const struct option *longopts, int *longind,
979                 struct custom_getopt_data *d)
980 {
981         int ret, print_errors = d->custom_opterr;
982
983         if (optstring[0] == ':')
984                 print_errors = 0;
985         if (argc < 1)
986                 return -1;
987         d->custom_optarg = NULL;
988
989         /* 
990          * This is a big difference with GNU getopt, since optind == 0
991          * means initialization while here 1 means first call.
992          */
993         if (d->custom_optind == 0 || !d->initialized) {
994                 if (d->custom_optind == 0)
995                         d->custom_optind = 1;   /* Don't scan ARGV[0], the program name.  */
996                 custom_getopt_initialize(d);
997         }
998         if (d->nextchar == NULL || *d->nextchar == '\0') {
999                 ret = shuffle_argv(argc, argv, longopts, d);
1000                 if (ret)
1001                         return ret;
1002         }
1003         if (longopts && (argv[d->custom_optind][1] == '-' ))
1004                 return check_long_opt(argc, argv, optstring, longopts,
1005                         longind, print_errors, d);
1006         return check_short_opt(argc, argv, optstring, print_errors, d);
1007 }
1008
1009 static int custom_getopt_internal(int argc, char *const *argv, const char *optstring,
1010         const struct option *longopts, int *longind)
1011 {
1012         int result;
1013         /* Keep a global copy of all internal members of d */
1014         static struct custom_getopt_data d;
1015
1016         d.custom_optind = custom_optind;
1017         d.custom_opterr = custom_opterr;
1018         result = getopt_internal_r(argc, argv, optstring, longopts,
1019                 longind, &d);
1020         custom_optind = d.custom_optind;
1021         custom_optarg = d.custom_optarg;
1022         custom_optopt = d.custom_optopt;
1023         return result;
1024 }
1025
1026 static int custom_getopt_long (int argc, char *const *argv, const char *options,
1027         const struct option *long_options, int *opt_index)
1028 {
1029         return custom_getopt_internal(argc, argv, options, long_options,
1030                 opt_index);
1031 }
1032
1033
1034 static char *package_name = 0;
1035
1036 /**
1037  * @brief updates an option
1038  * @param field the generic pointer to the field to update
1039  * @param orig_field the pointer to the orig field
1040  * @param field_given the pointer to the number of occurrence of this option
1041  * @param prev_given the pointer to the number of occurrence already seen
1042  * @param value the argument for this option (if null no arg was specified)
1043  * @param possible_values the possible values for this option (if specified)
1044  * @param default_value the default value (in case the option only accepts fixed values)
1045  * @param arg_type the type of this option
1046  * @param check_ambiguity @see RNAparconv_cmdline_parser_params.check_ambiguity
1047  * @param override @see RNAparconv_cmdline_parser_params.override
1048  * @param no_free whether to free a possible previous value
1049  * @param multiple_option whether this is a multiple option
1050  * @param long_opt the corresponding long option
1051  * @param short_opt the corresponding short option (or '-' if none)
1052  * @param additional_error possible further error specification
1053  */
1054 static
1055 int update_arg(void *field, char **orig_field,
1056                unsigned int *field_given, unsigned int *prev_given, 
1057                char *value, const char *possible_values[],
1058                const char *default_value,
1059                RNAparconv_cmdline_parser_arg_type arg_type,
1060                int check_ambiguity, int override,
1061                int no_free, int multiple_option,
1062                const char *long_opt, char short_opt,
1063                const char *additional_error)
1064 {
1065   char *stop_char = 0;
1066   const char *val = value;
1067   int found;
1068   char **string_field;
1069   FIX_UNUSED (field);
1070
1071   stop_char = 0;
1072   found = 0;
1073
1074   if (!multiple_option && prev_given && (*prev_given || (check_ambiguity && *field_given)))
1075     {
1076       if (short_opt != '-')
1077         fprintf (stderr, "%s: `--%s' (`-%c') option given more than once%s\n", 
1078                package_name, long_opt, short_opt,
1079                (additional_error ? additional_error : ""));
1080       else
1081         fprintf (stderr, "%s: `--%s' option given more than once%s\n", 
1082                package_name, long_opt,
1083                (additional_error ? additional_error : ""));
1084       return 1; /* failure */
1085     }
1086
1087   FIX_UNUSED (default_value);
1088     
1089   if (field_given && *field_given && ! override)
1090     return 0;
1091   if (prev_given)
1092     (*prev_given)++;
1093   if (field_given)
1094     (*field_given)++;
1095   if (possible_values)
1096     val = possible_values[found];
1097
1098   switch(arg_type) {
1099   case ARG_FLAG:
1100     *((int *)field) = !*((int *)field);
1101     break;
1102   case ARG_STRING:
1103     if (val) {
1104       string_field = (char **)field;
1105       if (!no_free && *string_field)
1106         free (*string_field); /* free previous string */
1107       *string_field = gengetopt_strdup (val);
1108     }
1109     break;
1110   default:
1111     break;
1112   };
1113
1114
1115   /* store the original value */
1116   switch(arg_type) {
1117   case ARG_NO:
1118   case ARG_FLAG:
1119     break;
1120   default:
1121     if (value && orig_field) {
1122       if (no_free) {
1123         *orig_field = value;
1124       } else {
1125         if (*orig_field)
1126           free (*orig_field); /* free previous string */
1127         *orig_field = gengetopt_strdup (value);
1128       }
1129     }
1130   };
1131
1132   return 0; /* OK */
1133 }
1134
1135
1136 int
1137 RNAparconv_cmdline_parser_internal (
1138   int argc, char **argv, struct RNAparconv_args_info *args_info,
1139                         struct RNAparconv_cmdline_parser_params *params, const char *additional_error)
1140 {
1141   int c;        /* Character of the parsed option.  */
1142
1143   int error = 0;
1144   struct RNAparconv_args_info local_args_info;
1145   
1146   int override;
1147   int initialize;
1148   int check_required;
1149   int check_ambiguity;
1150
1151   char *optarg;
1152   int optind;
1153   int opterr;
1154   int optopt;
1155   
1156   package_name = argv[0];
1157   
1158   override = params->override;
1159   initialize = params->initialize;
1160   check_required = params->check_required;
1161   check_ambiguity = params->check_ambiguity;
1162
1163   if (initialize)
1164     RNAparconv_cmdline_parser_init (args_info);
1165
1166   RNAparconv_cmdline_parser_init (&local_args_info);
1167
1168   optarg = 0;
1169   optind = 0;
1170   opterr = params->print_errors;
1171   optopt = '?';
1172
1173   while (1)
1174     {
1175       int option_index = 0;
1176
1177       static struct option long_options[] = {
1178         { "help",       0, NULL, 'h' },
1179         { "full-help",  0, NULL, 0 },
1180         { "version",    0, NULL, 'V' },
1181         { "output",     1, NULL, 'o' },
1182         { "input",      1, NULL, 'i' },
1183         { "vanilla",    0, NULL, 0 },
1184         { "dump",       0, NULL, 0 },
1185         { "silent",     0, NULL, 0 },
1186         { "without-HairpinE",   0, NULL, 0 },
1187         { "without-StackE",     0, NULL, 0 },
1188         { "without-IntE",       0, NULL, 0 },
1189         { "without-BulgeE",     0, NULL, 0 },
1190         { "without-MultiE",     0, NULL, 0 },
1191         { "without-MismatchE",  0, NULL, 0 },
1192         { "without-MismatchH",  0, NULL, 0 },
1193         { "without-MismatchI",  0, NULL, 0 },
1194         { "without-MismatchM",  0, NULL, 0 },
1195         { "without-Dangle5",    0, NULL, 0 },
1196         { "without-Dangle3",    0, NULL, 0 },
1197         { "without-Misc",       0, NULL, 0 },
1198         { 0,  0, 0, 0 }
1199       };
1200
1201       custom_optarg = optarg;
1202       custom_optind = optind;
1203       custom_opterr = opterr;
1204       custom_optopt = optopt;
1205
1206       c = custom_getopt_long (argc, argv, "hVo:i:", long_options, &option_index);
1207
1208       optarg = custom_optarg;
1209       optind = custom_optind;
1210       opterr = custom_opterr;
1211       optopt = custom_optopt;
1212
1213       if (c == -1) break;       /* Exit from `while (1)' loop.  */
1214
1215       switch (c)
1216         {
1217         case 'h':       /* Print help and exit.  */
1218           RNAparconv_cmdline_parser_print_help ();
1219           RNAparconv_cmdline_parser_free (&local_args_info);
1220           exit (EXIT_SUCCESS);
1221
1222         case 'V':       /* Print version and exit.  */
1223           RNAparconv_cmdline_parser_print_version ();
1224           RNAparconv_cmdline_parser_free (&local_args_info);
1225           exit (EXIT_SUCCESS);
1226
1227         case 'o':       /* Specify an output file name. If argument is missing the converted energy parameters are printed to 'stdout'.
1228         
1229 .  */
1230         
1231         
1232           if (update_arg( (void *)&(args_info->output_arg), 
1233                &(args_info->output_orig), &(args_info->output_given),
1234               &(local_args_info.output_given), optarg, 0, 0, ARG_STRING,
1235               check_ambiguity, override, 0, 0,
1236               "output", 'o',
1237               additional_error))
1238             goto failure;
1239         
1240           break;
1241         case 'i':       /* Specify an input file name. If argument is missing the energy parameter input can be supplied via 'stdin'.
1242         
1243 .  */
1244         
1245         
1246           if (update_arg( (void *)&(args_info->input_arg), 
1247                &(args_info->input_orig), &(args_info->input_given),
1248               &(local_args_info.input_given), optarg, 0, 0, ARG_STRING,
1249               check_ambiguity, override, 0, 0,
1250               "input", 'i',
1251               additional_error))
1252             goto failure;
1253         
1254           break;
1255
1256         case 0: /* Long option with no short option */
1257           if (strcmp (long_options[option_index].name, "full-help") == 0) {
1258             RNAparconv_cmdline_parser_print_full_help ();
1259             RNAparconv_cmdline_parser_free (&local_args_info);
1260             exit (EXIT_SUCCESS);
1261           }
1262
1263           /* Print just as much as needed to represent the given energy parameters data set.
1264           This option overrides all other output settings!
1265           
1266 .  */
1267           if (strcmp (long_options[option_index].name, "vanilla") == 0)
1268           {
1269           
1270           
1271             if (update_arg((void *)&(args_info->vanilla_flag), 0, &(args_info->vanilla_given),
1272                 &(local_args_info.vanilla_given), optarg, 0, 0, ARG_FLAG,
1273                 check_ambiguity, override, 1, 0, "vanilla", '-',
1274                 additional_error))
1275               goto failure;
1276           
1277           }
1278           /* Just dump Vienna 1.8.4 energy parameters in format used since 2.0.
1279           This option skips any energy parameter input!
1280           
1281 .  */
1282           else if (strcmp (long_options[option_index].name, "dump") == 0)
1283           {
1284           
1285           
1286             if (update_arg((void *)&(args_info->dump_flag), 0, &(args_info->dump_given),
1287                 &(local_args_info.dump_given), optarg, 0, 0, ARG_FLAG,
1288                 check_ambiguity, override, 1, 0, "dump", '-',
1289                 additional_error))
1290               goto failure;
1291           
1292           }
1293           /* Print just energy parameters and appropriate comment lines but suppress all other output
1294           
1295 .  */
1296           else if (strcmp (long_options[option_index].name, "silent") == 0)
1297           {
1298           
1299           
1300             if (update_arg((void *)&(args_info->silent_flag), 0, &(args_info->silent_given),
1301                 &(local_args_info.silent_given), optarg, 0, 0, ARG_FLAG,
1302                 check_ambiguity, override, 1, 0, "silent", '-',
1303                 additional_error))
1304               goto failure;
1305           
1306           }
1307           /* Do not print converted hairpin energies and enthalpies
1308           
1309 .  */
1310           else if (strcmp (long_options[option_index].name, "without-HairpinE") == 0)
1311           {
1312           
1313           
1314             if (update_arg((void *)&(args_info->without_HairpinE_flag), 0, &(args_info->without_HairpinE_given),
1315                 &(local_args_info.without_HairpinE_given), optarg, 0, 0, ARG_FLAG,
1316                 check_ambiguity, override, 1, 0, "without-HairpinE", '-',
1317                 additional_error))
1318               goto failure;
1319           
1320           }
1321           /* Do not print converted stacking energies and enthalpies
1322           
1323 .  */
1324           else if (strcmp (long_options[option_index].name, "without-StackE") == 0)
1325           {
1326           
1327           
1328             if (update_arg((void *)&(args_info->without_StackE_flag), 0, &(args_info->without_StackE_given),
1329                 &(local_args_info.without_StackE_given), optarg, 0, 0, ARG_FLAG,
1330                 check_ambiguity, override, 1, 0, "without-StackE", '-',
1331                 additional_error))
1332               goto failure;
1333           
1334           }
1335           /* Do not print converted interior loop energies, enthalpies and asymetry factors
1336           
1337 .  */
1338           else if (strcmp (long_options[option_index].name, "without-IntE") == 0)
1339           {
1340           
1341           
1342             if (update_arg((void *)&(args_info->without_IntE_flag), 0, &(args_info->without_IntE_given),
1343                 &(local_args_info.without_IntE_given), optarg, 0, 0, ARG_FLAG,
1344                 check_ambiguity, override, 1, 0, "without-IntE", '-',
1345                 additional_error))
1346               goto failure;
1347           
1348           }
1349           /* Do not print converted bulge loop energies and enthalpies
1350           
1351 .  */
1352           else if (strcmp (long_options[option_index].name, "without-BulgeE") == 0)
1353           {
1354           
1355           
1356             if (update_arg((void *)&(args_info->without_BulgeE_flag), 0, &(args_info->without_BulgeE_given),
1357                 &(local_args_info.without_BulgeE_given), optarg, 0, 0, ARG_FLAG,
1358                 check_ambiguity, override, 1, 0, "without-BulgeE", '-',
1359                 additional_error))
1360               goto failure;
1361           
1362           }
1363           /* Do not print converted multi loop energies and enthalpies
1364           
1365 .  */
1366           else if (strcmp (long_options[option_index].name, "without-MultiE") == 0)
1367           {
1368           
1369           
1370             if (update_arg((void *)&(args_info->without_MultiE_flag), 0, &(args_info->without_MultiE_given),
1371                 &(local_args_info.without_MultiE_given), optarg, 0, 0, ARG_FLAG,
1372                 check_ambiguity, override, 1, 0, "without-MultiE", '-',
1373                 additional_error))
1374               goto failure;
1375           
1376           }
1377           /* Do not print converted exterior loop mismatch energies and enthalpies
1378           
1379 .  */
1380           else if (strcmp (long_options[option_index].name, "without-MismatchE") == 0)
1381           {
1382           
1383           
1384             if (update_arg((void *)&(args_info->without_MismatchE_flag), 0, &(args_info->without_MismatchE_given),
1385                 &(local_args_info.without_MismatchE_given), optarg, 0, 0, ARG_FLAG,
1386                 check_ambiguity, override, 1, 0, "without-MismatchE", '-',
1387                 additional_error))
1388               goto failure;
1389           
1390           }
1391           /* Do not print converted hairpin mismatch energies and enthalpies
1392           
1393 .  */
1394           else if (strcmp (long_options[option_index].name, "without-MismatchH") == 0)
1395           {
1396           
1397           
1398             if (update_arg((void *)&(args_info->without_MismatchH_flag), 0, &(args_info->without_MismatchH_given),
1399                 &(local_args_info.without_MismatchH_given), optarg, 0, 0, ARG_FLAG,
1400                 check_ambiguity, override, 1, 0, "without-MismatchH", '-',
1401                 additional_error))
1402               goto failure;
1403           
1404           }
1405           /* Do not print converted interior loop mismatch energies and enthalpies
1406           
1407 .  */
1408           else if (strcmp (long_options[option_index].name, "without-MismatchI") == 0)
1409           {
1410           
1411           
1412             if (update_arg((void *)&(args_info->without_MismatchI_flag), 0, &(args_info->without_MismatchI_given),
1413                 &(local_args_info.without_MismatchI_given), optarg, 0, 0, ARG_FLAG,
1414                 check_ambiguity, override, 1, 0, "without-MismatchI", '-',
1415                 additional_error))
1416               goto failure;
1417           
1418           }
1419           /* Do not print converted multi loop mismatch energies and enthalpies
1420           
1421 .  */
1422           else if (strcmp (long_options[option_index].name, "without-MismatchM") == 0)
1423           {
1424           
1425           
1426             if (update_arg((void *)&(args_info->without_MismatchM_flag), 0, &(args_info->without_MismatchM_given),
1427                 &(local_args_info.without_MismatchM_given), optarg, 0, 0, ARG_FLAG,
1428                 check_ambiguity, override, 1, 0, "without-MismatchM", '-',
1429                 additional_error))
1430               goto failure;
1431           
1432           }
1433           /* Do not print converted 5' dangle energies and enthalpies
1434           
1435 .  */
1436           else if (strcmp (long_options[option_index].name, "without-Dangle5") == 0)
1437           {
1438           
1439           
1440             if (update_arg((void *)&(args_info->without_Dangle5_flag), 0, &(args_info->without_Dangle5_given),
1441                 &(local_args_info.without_Dangle5_given), optarg, 0, 0, ARG_FLAG,
1442                 check_ambiguity, override, 1, 0, "without-Dangle5", '-',
1443                 additional_error))
1444               goto failure;
1445           
1446           }
1447           /* Do not print converted 3' dangle energies and enthalpies
1448           
1449 .  */
1450           else if (strcmp (long_options[option_index].name, "without-Dangle3") == 0)
1451           {
1452           
1453           
1454             if (update_arg((void *)&(args_info->without_Dangle3_flag), 0, &(args_info->without_Dangle3_given),
1455                 &(local_args_info.without_Dangle3_given), optarg, 0, 0, ARG_FLAG,
1456                 check_ambiguity, override, 1, 0, "without-Dangle3", '-',
1457                 additional_error))
1458               goto failure;
1459           
1460           }
1461           /* Do not print converted Misc energies and enthalpies (TerminalAU, DuplexInit, lxc)
1462           
1463 .  */
1464           else if (strcmp (long_options[option_index].name, "without-Misc") == 0)
1465           {
1466           
1467           
1468             if (update_arg((void *)&(args_info->without_Misc_flag), 0, &(args_info->without_Misc_given),
1469                 &(local_args_info.without_Misc_given), optarg, 0, 0, ARG_FLAG,
1470                 check_ambiguity, override, 1, 0, "without-Misc", '-',
1471                 additional_error))
1472               goto failure;
1473           
1474           }
1475           
1476           break;
1477         case '?':       /* Invalid option.  */
1478           /* `getopt_long' already printed an error message.  */
1479           goto failure;
1480
1481         default:        /* bug: option not considered.  */
1482           fprintf (stderr, "%s: option unknown: %c%s\n", RNAPARCONV_CMDLINE_PARSER_PACKAGE, c, (additional_error ? additional_error : ""));
1483           abort ();
1484         } /* switch */
1485     } /* while */
1486
1487
1488
1489
1490   RNAparconv_cmdline_parser_release (&local_args_info);
1491
1492   if ( error )
1493     return (EXIT_FAILURE);
1494
1495   if (optind < argc)
1496     {
1497       int i = 0 ;
1498       int found_prog_name = 0;
1499       /* whether program name, i.e., argv[0], is in the remaining args
1500          (this may happen with some implementations of getopt,
1501           but surely not with the one included by gengetopt) */
1502
1503
1504       args_info->inputs_num = argc - optind - found_prog_name;
1505       args_info->inputs =
1506         (char **)(malloc ((args_info->inputs_num)*sizeof(char *))) ;
1507       while (optind < argc)
1508         args_info->inputs[ i++ ] = gengetopt_strdup (argv[optind++]) ;
1509     }
1510
1511   return 0;
1512
1513 failure:
1514   
1515   RNAparconv_cmdline_parser_release (&local_args_info);
1516   return (EXIT_FAILURE);
1517 }