Add missing binaty and statis library
[jabaws.git] / binaries / src / ViennaRNA / Progs / RNAPKplex_cmdl.c
1 /*
2   File autogenerated by gengetopt version 2.22.5
3   generated with the following command:
4   gengetopt -i RNAPKplex.ggo --file-name=RNAPKplex_cmdl --include-getopt --default-optional --func-name=PKplex_cmdline_parser --arg-struct-name=PKplex_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 "RNAPKplex_cmdl.h"
26
27 const char *PKplex_args_info_purpose = "predicts RNA secondary structures including pseudoknots";
28
29 const char *PKplex_args_info_usage = "Usage: RNAPKplex [OPTIONS]...";
30
31 const char *PKplex_args_info_description = "Computes RNA secondary structures by first making two sequence intervals \naccessible and unpaired using the algorithm of RNAplfold and then calculating \nthe energy of the interaction of those two intervals. The algorithm uses \nO(n^2*w^4) CPU time and O(n*w^2) memory space.\nThe algorithm furthermore always considers dangle=2 model.\n";
32
33 const char *PKplex_args_info_detailed_help[] = {
34   "  -h, --help                 Print help and exit",
35   "      --detailed-help        Print help, including all details and hidden \n                               options, and exit",
36   "  -V, --version              Print version and exit",
37   "  -c, --cutoff=FLOAT         Report only base pairs with an average probability \n                               > cutoff in the dot plot\n\n                                 (default=`0.01')",
38   "  -T, --temp=DOUBLE          Rescale energy parameters to a temperature of temp \n                               C. Default is 37C.\n\n",
39   "  -4, --noTetra              Do not include special stabilizing energies for \n                               certain tetra-loops. Mostly for testing.\n\n                                 (default=off)",
40   "      --noLP                 Produce structures without lonely pairs (helices \n                               of length 1).\n                                 (default=off)",
41   "  For partition function folding this only disallows pairs that can only occur \n  isolated. Other pairs may still occasionally occur as helices of length 1.\n\n",
42   "      --noGU                 Do not allow GU pairs\n\n                                 (default=off)",
43   "      --noClosingGU          Do not allow GU pairs at the end of helices\n\n                                 (default=off)",
44   "      --noconv               Do not automatically substitude nucleotide \"T\" \n                               with \"U\"\n\n                                 (default=off)",
45   "      --nsp=STRING           Allow other pairs in addition to the usual \n                               AU,GC,and GU pairs.\n                                 (default=`empty')",
46   "  Its argument is a comma separated list of additionally allowed pairs. If the \n  first character is a \"-\" then AB will imply that AB and BA are allowed \n  pairs.\n  e.g. RNAfold -nsp -GA  will allow GA and AG pairs. Nonstandard pairs are \n  given 0 stacking energy.\n\n",
47   "  -e, --energyCutoff=DOUBLE  Energy cutoff or pseudoknot initiation cost. \n                               Minimum energy gain of a pseudoknot interaction \n                               for it to be returned. Pseudoknots with smaller \n                               energy gains are rejected.\n\n                                 (default=`-8.10')",
48   "  -P, --paramFile=paramfile  Read energy parameters from paramfile, instead of \n                               using the default parameter set.\n",
49   "  A sample parameter file should accompany your distribution.\n  See the RNAlib documentation for details on the file format.\n\n",
50   "  -v, --verbose              print verbose output\n                                 (default=off)",
51   "  -s, --subopts=DOUBLE       print suboptimal structures whose energy \n                               difference of the pseudoknot to the optimum \n                               pseudoknot is smaller than the given value.\n                                 (default=`0.0')",
52   "  NOTE: The final energy of a structure is calculated as the sum of the \n  pseudoknot interaction energy, the penalty for initiating a  pseudoknot and \n  the energy of the pseudoknot-free part of the structure. The -s option only \n  takes the pseudoknot interaction energy into account, so the final energy \n  differences may be bigger than the specified value (default=0.).\n\n",
53   "\nIf in doubt our program is right, nature is at fault.\nComments should be sent to rna@tbi.univie.ac.at.\n",
54     0
55 };
56
57 static void
58 init_help_array(void)
59 {
60   PKplex_args_info_help[0] = PKplex_args_info_detailed_help[0];
61   PKplex_args_info_help[1] = PKplex_args_info_detailed_help[1];
62   PKplex_args_info_help[2] = PKplex_args_info_detailed_help[2];
63   PKplex_args_info_help[3] = PKplex_args_info_detailed_help[3];
64   PKplex_args_info_help[4] = PKplex_args_info_detailed_help[4];
65   PKplex_args_info_help[5] = PKplex_args_info_detailed_help[5];
66   PKplex_args_info_help[6] = PKplex_args_info_detailed_help[6];
67   PKplex_args_info_help[7] = PKplex_args_info_detailed_help[8];
68   PKplex_args_info_help[8] = PKplex_args_info_detailed_help[9];
69   PKplex_args_info_help[9] = PKplex_args_info_detailed_help[10];
70   PKplex_args_info_help[10] = PKplex_args_info_detailed_help[11];
71   PKplex_args_info_help[11] = PKplex_args_info_detailed_help[13];
72   PKplex_args_info_help[12] = PKplex_args_info_detailed_help[14];
73   PKplex_args_info_help[13] = PKplex_args_info_detailed_help[16];
74   PKplex_args_info_help[14] = PKplex_args_info_detailed_help[17];
75   PKplex_args_info_help[15] = PKplex_args_info_detailed_help[19];
76   PKplex_args_info_help[16] = 0; 
77   
78 }
79
80 const char *PKplex_args_info_help[17];
81
82 typedef enum {ARG_NO
83   , ARG_FLAG
84   , ARG_STRING
85   , ARG_FLOAT
86   , ARG_DOUBLE
87 } PKplex_cmdline_parser_arg_type;
88
89 static
90 void clear_given (struct PKplex_args_info *args_info);
91 static
92 void clear_args (struct PKplex_args_info *args_info);
93
94 static int
95 PKplex_cmdline_parser_internal (int argc, char **argv, struct PKplex_args_info *args_info,
96                         struct PKplex_cmdline_parser_params *params, const char *additional_error);
97
98
99 static char *
100 gengetopt_strdup (const char *s);
101
102 static
103 void clear_given (struct PKplex_args_info *args_info)
104 {
105   args_info->help_given = 0 ;
106   args_info->detailed_help_given = 0 ;
107   args_info->version_given = 0 ;
108   args_info->cutoff_given = 0 ;
109   args_info->temp_given = 0 ;
110   args_info->noTetra_given = 0 ;
111   args_info->noLP_given = 0 ;
112   args_info->noGU_given = 0 ;
113   args_info->noClosingGU_given = 0 ;
114   args_info->noconv_given = 0 ;
115   args_info->nsp_given = 0 ;
116   args_info->energyCutoff_given = 0 ;
117   args_info->paramFile_given = 0 ;
118   args_info->verbose_given = 0 ;
119   args_info->subopts_given = 0 ;
120 }
121
122 static
123 void clear_args (struct PKplex_args_info *args_info)
124 {
125   FIX_UNUSED (args_info);
126   args_info->cutoff_arg = 0.01;
127   args_info->cutoff_orig = NULL;
128   args_info->temp_orig = NULL;
129   args_info->noTetra_flag = 0;
130   args_info->noLP_flag = 0;
131   args_info->noGU_flag = 0;
132   args_info->noClosingGU_flag = 0;
133   args_info->noconv_flag = 0;
134   args_info->nsp_arg = gengetopt_strdup ("empty");
135   args_info->nsp_orig = NULL;
136   args_info->energyCutoff_arg = -8.10;
137   args_info->energyCutoff_orig = NULL;
138   args_info->paramFile_arg = NULL;
139   args_info->paramFile_orig = NULL;
140   args_info->verbose_flag = 0;
141   args_info->subopts_arg = 0.0;
142   args_info->subopts_orig = NULL;
143   
144 }
145
146 static
147 void init_args_info(struct PKplex_args_info *args_info)
148 {
149
150   init_help_array(); 
151   args_info->help_help = PKplex_args_info_detailed_help[0] ;
152   args_info->detailed_help_help = PKplex_args_info_detailed_help[1] ;
153   args_info->version_help = PKplex_args_info_detailed_help[2] ;
154   args_info->cutoff_help = PKplex_args_info_detailed_help[3] ;
155   args_info->temp_help = PKplex_args_info_detailed_help[4] ;
156   args_info->noTetra_help = PKplex_args_info_detailed_help[5] ;
157   args_info->noLP_help = PKplex_args_info_detailed_help[6] ;
158   args_info->noGU_help = PKplex_args_info_detailed_help[8] ;
159   args_info->noClosingGU_help = PKplex_args_info_detailed_help[9] ;
160   args_info->noconv_help = PKplex_args_info_detailed_help[10] ;
161   args_info->nsp_help = PKplex_args_info_detailed_help[11] ;
162   args_info->energyCutoff_help = PKplex_args_info_detailed_help[13] ;
163   args_info->paramFile_help = PKplex_args_info_detailed_help[14] ;
164   args_info->verbose_help = PKplex_args_info_detailed_help[16] ;
165   args_info->subopts_help = PKplex_args_info_detailed_help[17] ;
166   
167 }
168
169 void
170 PKplex_cmdline_parser_print_version (void)
171 {
172   printf ("%s %s\n",
173      (strlen(PKPLEX_CMDLINE_PARSER_PACKAGE_NAME) ? PKPLEX_CMDLINE_PARSER_PACKAGE_NAME : PKPLEX_CMDLINE_PARSER_PACKAGE),
174      PKPLEX_CMDLINE_PARSER_VERSION);
175 }
176
177 static void print_help_common(void) {
178   PKplex_cmdline_parser_print_version ();
179
180   if (strlen(PKplex_args_info_purpose) > 0)
181     printf("\n%s\n", PKplex_args_info_purpose);
182
183   if (strlen(PKplex_args_info_usage) > 0)
184     printf("\n%s\n", PKplex_args_info_usage);
185
186   printf("\n");
187
188   if (strlen(PKplex_args_info_description) > 0)
189     printf("%s\n\n", PKplex_args_info_description);
190 }
191
192 void
193 PKplex_cmdline_parser_print_help (void)
194 {
195   int i = 0;
196   print_help_common();
197   while (PKplex_args_info_help[i])
198     printf("%s\n", PKplex_args_info_help[i++]);
199 }
200
201 void
202 PKplex_cmdline_parser_print_detailed_help (void)
203 {
204   int i = 0;
205   print_help_common();
206   while (PKplex_args_info_detailed_help[i])
207     printf("%s\n", PKplex_args_info_detailed_help[i++]);
208 }
209
210 void
211 PKplex_cmdline_parser_init (struct PKplex_args_info *args_info)
212 {
213   clear_given (args_info);
214   clear_args (args_info);
215   init_args_info (args_info);
216 }
217
218 void
219 PKplex_cmdline_parser_params_init(struct PKplex_cmdline_parser_params *params)
220 {
221   if (params)
222     { 
223       params->override = 0;
224       params->initialize = 1;
225       params->check_required = 1;
226       params->check_ambiguity = 0;
227       params->print_errors = 1;
228     }
229 }
230
231 struct PKplex_cmdline_parser_params *
232 PKplex_cmdline_parser_params_create(void)
233 {
234   struct PKplex_cmdline_parser_params *params = 
235     (struct PKplex_cmdline_parser_params *)malloc(sizeof(struct PKplex_cmdline_parser_params));
236   PKplex_cmdline_parser_params_init(params);  
237   return params;
238 }
239
240 static void
241 free_string_field (char **s)
242 {
243   if (*s)
244     {
245       free (*s);
246       *s = 0;
247     }
248 }
249
250
251 static void
252 PKplex_cmdline_parser_release (struct PKplex_args_info *args_info)
253 {
254
255   free_string_field (&(args_info->cutoff_orig));
256   free_string_field (&(args_info->temp_orig));
257   free_string_field (&(args_info->nsp_arg));
258   free_string_field (&(args_info->nsp_orig));
259   free_string_field (&(args_info->energyCutoff_orig));
260   free_string_field (&(args_info->paramFile_arg));
261   free_string_field (&(args_info->paramFile_orig));
262   free_string_field (&(args_info->subopts_orig));
263   
264   
265
266   clear_given (args_info);
267 }
268
269
270 static void
271 write_into_file(FILE *outfile, const char *opt, const char *arg, const char *values[])
272 {
273   FIX_UNUSED (values);
274   if (arg) {
275     fprintf(outfile, "%s=\"%s\"\n", opt, arg);
276   } else {
277     fprintf(outfile, "%s\n", opt);
278   }
279 }
280
281
282 int
283 PKplex_cmdline_parser_dump(FILE *outfile, struct PKplex_args_info *args_info)
284 {
285   int i = 0;
286
287   if (!outfile)
288     {
289       fprintf (stderr, "%s: cannot dump options to stream\n", PKPLEX_CMDLINE_PARSER_PACKAGE);
290       return EXIT_FAILURE;
291     }
292
293   if (args_info->help_given)
294     write_into_file(outfile, "help", 0, 0 );
295   if (args_info->detailed_help_given)
296     write_into_file(outfile, "detailed-help", 0, 0 );
297   if (args_info->version_given)
298     write_into_file(outfile, "version", 0, 0 );
299   if (args_info->cutoff_given)
300     write_into_file(outfile, "cutoff", args_info->cutoff_orig, 0);
301   if (args_info->temp_given)
302     write_into_file(outfile, "temp", args_info->temp_orig, 0);
303   if (args_info->noTetra_given)
304     write_into_file(outfile, "noTetra", 0, 0 );
305   if (args_info->noLP_given)
306     write_into_file(outfile, "noLP", 0, 0 );
307   if (args_info->noGU_given)
308     write_into_file(outfile, "noGU", 0, 0 );
309   if (args_info->noClosingGU_given)
310     write_into_file(outfile, "noClosingGU", 0, 0 );
311   if (args_info->noconv_given)
312     write_into_file(outfile, "noconv", 0, 0 );
313   if (args_info->nsp_given)
314     write_into_file(outfile, "nsp", args_info->nsp_orig, 0);
315   if (args_info->energyCutoff_given)
316     write_into_file(outfile, "energyCutoff", args_info->energyCutoff_orig, 0);
317   if (args_info->paramFile_given)
318     write_into_file(outfile, "paramFile", args_info->paramFile_orig, 0);
319   if (args_info->verbose_given)
320     write_into_file(outfile, "verbose", 0, 0 );
321   if (args_info->subopts_given)
322     write_into_file(outfile, "subopts", args_info->subopts_orig, 0);
323   
324
325   i = EXIT_SUCCESS;
326   return i;
327 }
328
329 int
330 PKplex_cmdline_parser_file_save(const char *filename, struct PKplex_args_info *args_info)
331 {
332   FILE *outfile;
333   int i = 0;
334
335   outfile = fopen(filename, "w");
336
337   if (!outfile)
338     {
339       fprintf (stderr, "%s: cannot open file for writing: %s\n", PKPLEX_CMDLINE_PARSER_PACKAGE, filename);
340       return EXIT_FAILURE;
341     }
342
343   i = PKplex_cmdline_parser_dump(outfile, args_info);
344   fclose (outfile);
345
346   return i;
347 }
348
349 void
350 PKplex_cmdline_parser_free (struct PKplex_args_info *args_info)
351 {
352   PKplex_cmdline_parser_release (args_info);
353 }
354
355 /** @brief replacement of strdup, which is not standard */
356 char *
357 gengetopt_strdup (const char *s)
358 {
359   char *result = 0;
360   if (!s)
361     return result;
362
363   result = (char*)malloc(strlen(s) + 1);
364   if (result == (char*)0)
365     return (char*)0;
366   strcpy(result, s);
367   return result;
368 }
369
370 int
371 PKplex_cmdline_parser (int argc, char **argv, struct PKplex_args_info *args_info)
372 {
373   return PKplex_cmdline_parser2 (argc, argv, args_info, 0, 1, 1);
374 }
375
376 int
377 PKplex_cmdline_parser_ext (int argc, char **argv, struct PKplex_args_info *args_info,
378                    struct PKplex_cmdline_parser_params *params)
379 {
380   int result;
381   result = PKplex_cmdline_parser_internal (argc, argv, args_info, params, 0);
382
383   if (result == EXIT_FAILURE)
384     {
385       PKplex_cmdline_parser_free (args_info);
386       exit (EXIT_FAILURE);
387     }
388   
389   return result;
390 }
391
392 int
393 PKplex_cmdline_parser2 (int argc, char **argv, struct PKplex_args_info *args_info, int override, int initialize, int check_required)
394 {
395   int result;
396   struct PKplex_cmdline_parser_params params;
397   
398   params.override = override;
399   params.initialize = initialize;
400   params.check_required = check_required;
401   params.check_ambiguity = 0;
402   params.print_errors = 1;
403
404   result = PKplex_cmdline_parser_internal (argc, argv, args_info, &params, 0);
405
406   if (result == EXIT_FAILURE)
407     {
408       PKplex_cmdline_parser_free (args_info);
409       exit (EXIT_FAILURE);
410     }
411   
412   return result;
413 }
414
415 int
416 PKplex_cmdline_parser_required (struct PKplex_args_info *args_info, const char *prog_name)
417 {
418   FIX_UNUSED (args_info);
419   FIX_UNUSED (prog_name);
420   return EXIT_SUCCESS;
421 }
422
423 /*
424  * Extracted from the glibc source tree, version 2.3.6
425  *
426  * Licensed under the GPL as per the whole glibc source tree.
427  *
428  * This file was modified so that getopt_long can be called
429  * many times without risking previous memory to be spoiled.
430  *
431  * Modified by Andre Noll and Lorenzo Bettini for use in
432  * GNU gengetopt generated files.
433  *
434  */
435
436 /* 
437  * we must include anything we need since this file is not thought to be
438  * inserted in a file already using getopt.h
439  *
440  * Lorenzo
441  */
442
443 struct option
444 {
445   const char *name;
446   /* has_arg can't be an enum because some compilers complain about
447      type mismatches in all the code that assumes it is an int.  */
448   int has_arg;
449   int *flag;
450   int val;
451 };
452
453 /* This version of `getopt' appears to the caller like standard Unix `getopt'
454    but it behaves differently for the user, since it allows the user
455    to intersperse the options with the other arguments.
456
457    As `getopt' works, it permutes the elements of ARGV so that,
458    when it is done, all the options precede everything else.  Thus
459    all application programs are extended to handle flexible argument order.
460 */
461 /*
462    If the field `flag' is not NULL, it points to a variable that is set
463    to the value given in the field `val' when the option is found, but
464    left unchanged if the option is not found.
465
466    To have a long-named option do something other than set an `int' to
467    a compiled-in constant, such as set a value from `custom_optarg', set the
468    option's `flag' field to zero and its `val' field to a nonzero
469    value (the equivalent single-letter option character, if there is
470    one).  For long options that have a zero `flag' field, `getopt'
471    returns the contents of the `val' field.  */
472
473 /* Names for the values of the `has_arg' field of `struct option'.  */
474 #ifndef no_argument
475 #define no_argument             0
476 #endif
477
478 #ifndef required_argument
479 #define required_argument       1
480 #endif
481
482 #ifndef optional_argument
483 #define optional_argument       2
484 #endif
485
486 struct custom_getopt_data {
487         /*
488          * These have exactly the same meaning as the corresponding global variables,
489          * except that they are used for the reentrant versions of getopt.
490          */
491         int custom_optind;
492         int custom_opterr;
493         int custom_optopt;
494         char *custom_optarg;
495
496         /* True if the internal members have been initialized.  */
497         int initialized;
498
499         /*
500          * The next char to be scanned in the option-element in which the last option
501          * character we returned was found.  This allows us to pick up the scan where
502          * we left off.  If this is zero, or a null string, it means resume the scan by
503          * advancing to the next ARGV-element.
504          */
505         char *nextchar;
506
507         /*
508          * Describe the part of ARGV that contains non-options that have been skipped.
509          * `first_nonopt' is the index in ARGV of the first of them; `last_nonopt' is
510          * the index after the last of them.
511          */
512         int first_nonopt;
513         int last_nonopt;
514 };
515
516 /*
517  * the variables optarg, optind, opterr and optopt are renamed with
518  * the custom_ prefix so that they don't interfere with getopt ones.
519  *
520  * Moreover they're static so they are visible only from within the
521  * file where this very file will be included.
522  */
523
524 /*
525  * For communication from `custom_getopt' to the caller.  When `custom_getopt' finds an
526  * option that takes an argument, the argument value is returned here.
527  */
528 static char *custom_optarg;
529
530 /*
531  * Index in ARGV of the next element to be scanned.  This is used for
532  * communication to and from the caller and for communication between
533  * successive calls to `custom_getopt'.
534  *
535  * On entry to `custom_getopt', 1 means this is the first call; initialize.
536  *
537  * When `custom_getopt' returns -1, this is the index of the first of the non-option
538  * elements that the caller should itself scan.
539  *
540  * Otherwise, `custom_optind' communicates from one call to the next how much of ARGV
541  * has been scanned so far.
542  *
543  * 1003.2 says this must be 1 before any call.
544  */
545 static int custom_optind = 1;
546
547 /*
548  * Callers store zero here to inhibit the error message for unrecognized
549  * options.
550  */
551 static int custom_opterr = 1;
552
553 /*
554  * Set to an option character which was unrecognized.  This must be initialized
555  * on some systems to avoid linking in the system's own getopt implementation.
556  */
557 static int custom_optopt = '?';
558
559 /*
560  * Exchange two adjacent subsequences of ARGV.  One subsequence is elements
561  * [first_nonopt,last_nonopt) which contains all the non-options that have been
562  * skipped so far.  The other is elements [last_nonopt,custom_optind), which contains
563  * all the options processed since those non-options were skipped.
564  * `first_nonopt' and `last_nonopt' are relocated so that they describe the new
565  * indices of the non-options in ARGV after they are moved.
566  */
567 static void exchange(char **argv, struct custom_getopt_data *d)
568 {
569         int bottom = d->first_nonopt;
570         int middle = d->last_nonopt;
571         int top = d->custom_optind;
572         char *tem;
573
574         /*
575          * Exchange the shorter segment with the far end of the longer segment.
576          * That puts the shorter segment into the right place.  It leaves the
577          * longer segment in the right place overall, but it consists of two
578          * parts that need to be swapped next.
579          */
580         while (top > middle && middle > bottom) {
581                 if (top - middle > middle - bottom) {
582                         /* Bottom segment is the short one.  */
583                         int len = middle - bottom;
584                         int i;
585
586                         /* Swap it with the top part of the top segment.  */
587                         for (i = 0; i < len; i++) {
588                                 tem = argv[bottom + i];
589                                 argv[bottom + i] =
590                                         argv[top - (middle - bottom) + i];
591                                 argv[top - (middle - bottom) + i] = tem;
592                         }
593                         /* Exclude the moved bottom segment from further swapping.  */
594                         top -= len;
595                 } else {
596                         /* Top segment is the short one.  */
597                         int len = top - middle;
598                         int i;
599
600                         /* Swap it with the bottom part of the bottom segment.  */
601                         for (i = 0; i < len; i++) {
602                                 tem = argv[bottom + i];
603                                 argv[bottom + i] = argv[middle + i];
604                                 argv[middle + i] = tem;
605                         }
606                         /* Exclude the moved top segment from further swapping.  */
607                         bottom += len;
608                 }
609         }
610         /* Update records for the slots the non-options now occupy.  */
611         d->first_nonopt += (d->custom_optind - d->last_nonopt);
612         d->last_nonopt = d->custom_optind;
613 }
614
615 /* Initialize the internal data when the first call is made.  */
616 static void custom_getopt_initialize(struct custom_getopt_data *d)
617 {
618         /*
619          * Start processing options with ARGV-element 1 (since ARGV-element 0
620          * is the program name); the sequence of previously skipped non-option
621          * ARGV-elements is empty.
622          */
623         d->first_nonopt = d->last_nonopt = d->custom_optind;
624         d->nextchar = NULL;
625         d->initialized = 1;
626 }
627
628 #define NONOPTION_P (argv[d->custom_optind][0] != '-' || argv[d->custom_optind][1] == '\0')
629
630 /* return: zero: continue, nonzero: return given value to user */
631 static int shuffle_argv(int argc, char *const *argv,const struct option *longopts,
632         struct custom_getopt_data *d)
633 {
634         /*
635          * Give FIRST_NONOPT & LAST_NONOPT rational values if CUSTOM_OPTIND has been
636          * moved back by the user (who may also have changed the arguments).
637          */
638         if (d->last_nonopt > d->custom_optind)
639                 d->last_nonopt = d->custom_optind;
640         if (d->first_nonopt > d->custom_optind)
641                 d->first_nonopt = d->custom_optind;
642         /*
643          * If we have just processed some options following some
644          * non-options, exchange them so that the options come first.
645          */
646         if (d->first_nonopt != d->last_nonopt &&
647                         d->last_nonopt != d->custom_optind)
648                 exchange((char **) argv, d);
649         else if (d->last_nonopt != d->custom_optind)
650                 d->first_nonopt = d->custom_optind;
651         /*
652          * Skip any additional non-options and extend the range of
653          * non-options previously skipped.
654          */
655         while (d->custom_optind < argc && NONOPTION_P)
656                 d->custom_optind++;
657         d->last_nonopt = d->custom_optind;
658         /*
659          * The special ARGV-element `--' means premature end of options.  Skip
660          * it like a null option, then exchange with previous non-options as if
661          * it were an option, then skip everything else like a non-option.
662          */
663         if (d->custom_optind != argc && !strcmp(argv[d->custom_optind], "--")) {
664                 d->custom_optind++;
665                 if (d->first_nonopt != d->last_nonopt
666                                 && d->last_nonopt != d->custom_optind)
667                         exchange((char **) argv, d);
668                 else if (d->first_nonopt == d->last_nonopt)
669                         d->first_nonopt = d->custom_optind;
670                 d->last_nonopt = argc;
671                 d->custom_optind = argc;
672         }
673         /*
674          * If we have done all the ARGV-elements, stop the scan and back over
675          * any non-options that we skipped and permuted.
676          */
677         if (d->custom_optind == argc) {
678                 /*
679                  * Set the next-arg-index to point at the non-options that we
680                  * previously skipped, so the caller will digest them.
681                  */
682                 if (d->first_nonopt != d->last_nonopt)
683                         d->custom_optind = d->first_nonopt;
684                 return -1;
685         }
686         /*
687          * If we have come to a non-option and did not permute it, either stop
688          * the scan or describe it to the caller and pass it by.
689          */
690         if (NONOPTION_P) {
691                 d->custom_optarg = argv[d->custom_optind++];
692                 return 1;
693         }
694         /*
695          * We have found another option-ARGV-element. Skip the initial
696          * punctuation.
697          */
698         d->nextchar = (argv[d->custom_optind] + 1 + (longopts != NULL && argv[d->custom_optind][1] == '-'));
699         return 0;
700 }
701
702 /*
703  * Check whether the ARGV-element is a long option.
704  *
705  * If there's a long option "fubar" and the ARGV-element is "-fu", consider
706  * that an abbreviation of the long option, just like "--fu", and not "-f" with
707  * arg "u".
708  *
709  * This distinction seems to be the most useful approach.
710  *
711  */
712 static int check_long_opt(int argc, char *const *argv, const char *optstring,
713                 const struct option *longopts, int *longind,
714                 int print_errors, struct custom_getopt_data *d)
715 {
716         char *nameend;
717         const struct option *p;
718         const struct option *pfound = NULL;
719         int exact = 0;
720         int ambig = 0;
721         int indfound = -1;
722         int option_index;
723
724         for (nameend = d->nextchar; *nameend && *nameend != '='; nameend++)
725                 /* Do nothing.  */ ;
726
727         /* Test all long options for either exact match or abbreviated matches */
728         for (p = longopts, option_index = 0; p->name; p++, option_index++)
729                 if (!strncmp(p->name, d->nextchar, nameend - d->nextchar)) {
730                         if ((unsigned int) (nameend - d->nextchar)
731                                         == (unsigned int) strlen(p->name)) {
732                                 /* Exact match found.  */
733                                 pfound = p;
734                                 indfound = option_index;
735                                 exact = 1;
736                                 break;
737                         } else if (pfound == NULL) {
738                                 /* First nonexact match found.  */
739                                 pfound = p;
740                                 indfound = option_index;
741                         } else if (pfound->has_arg != p->has_arg
742                                         || pfound->flag != p->flag
743                                         || pfound->val != p->val)
744                                 /* Second or later nonexact match found.  */
745                                 ambig = 1;
746                 }
747         if (ambig && !exact) {
748                 if (print_errors) {
749                         fprintf(stderr,
750                                 "%s: option `%s' is ambiguous\n",
751                                 argv[0], argv[d->custom_optind]);
752                 }
753                 d->nextchar += strlen(d->nextchar);
754                 d->custom_optind++;
755                 d->custom_optopt = 0;
756                 return '?';
757         }
758         if (pfound) {
759                 option_index = indfound;
760                 d->custom_optind++;
761                 if (*nameend) {
762                         if (pfound->has_arg != no_argument)
763                                 d->custom_optarg = nameend + 1;
764                         else {
765                                 if (print_errors) {
766                                         if (argv[d->custom_optind - 1][1] == '-') {
767                                                 /* --option */
768                                                 fprintf(stderr, "%s: option `--%s' doesn't allow an argument\n",
769                                                         argv[0], pfound->name);
770                                         } else {
771                                                 /* +option or -option */
772                                                 fprintf(stderr, "%s: option `%c%s' doesn't allow an argument\n",
773                                                         argv[0], argv[d->custom_optind - 1][0], pfound->name);
774                                         }
775
776                                 }
777                                 d->nextchar += strlen(d->nextchar);
778                                 d->custom_optopt = pfound->val;
779                                 return '?';
780                         }
781                 } else if (pfound->has_arg == required_argument) {
782                         if (d->custom_optind < argc)
783                                 d->custom_optarg = argv[d->custom_optind++];
784                         else {
785                                 if (print_errors) {
786                                         fprintf(stderr,
787                                                 "%s: option `%s' requires an argument\n",
788                                                 argv[0],
789                                                 argv[d->custom_optind - 1]);
790                                 }
791                                 d->nextchar += strlen(d->nextchar);
792                                 d->custom_optopt = pfound->val;
793                                 return optstring[0] == ':' ? ':' : '?';
794                         }
795                 }
796                 d->nextchar += strlen(d->nextchar);
797                 if (longind != NULL)
798                         *longind = option_index;
799                 if (pfound->flag) {
800                         *(pfound->flag) = pfound->val;
801                         return 0;
802                 }
803                 return pfound->val;
804         }
805         /*
806          * Can't find it as a long option.  If this is not getopt_long_only, or
807          * the option starts with '--' or is not a valid short option, then
808          * it's an error.  Otherwise interpret it as a short option.
809          */
810         if (print_errors) {
811                 if (argv[d->custom_optind][1] == '-') {
812                         /* --option */
813                         fprintf(stderr,
814                                 "%s: unrecognized option `--%s'\n",
815                                 argv[0], d->nextchar);
816                 } else {
817                         /* +option or -option */
818                         fprintf(stderr,
819                                 "%s: unrecognized option `%c%s'\n",
820                                 argv[0], argv[d->custom_optind][0],
821                                 d->nextchar);
822                 }
823         }
824         d->nextchar = (char *) "";
825         d->custom_optind++;
826         d->custom_optopt = 0;
827         return '?';
828 }
829
830 static int check_short_opt(int argc, char *const *argv, const char *optstring,
831                 int print_errors, struct custom_getopt_data *d)
832 {
833         char c = *d->nextchar++;
834         const char *temp = strchr(optstring, c);
835
836         /* Increment `custom_optind' when we start to process its last character.  */
837         if (*d->nextchar == '\0')
838                 ++d->custom_optind;
839         if (!temp || c == ':') {
840                 if (print_errors)
841                         fprintf(stderr, "%s: invalid option -- %c\n", argv[0], c);
842
843                 d->custom_optopt = c;
844                 return '?';
845         }
846         if (temp[1] == ':') {
847                 if (temp[2] == ':') {
848                         /* This is an option that accepts an argument optionally.  */
849                         if (*d->nextchar != '\0') {
850                                 d->custom_optarg = d->nextchar;
851                                 d->custom_optind++;
852                         } else
853                                 d->custom_optarg = NULL;
854                         d->nextchar = NULL;
855                 } else {
856                         /* This is an option that requires an argument.  */
857                         if (*d->nextchar != '\0') {
858                                 d->custom_optarg = d->nextchar;
859                                 /*
860                                  * If we end this ARGV-element by taking the
861                                  * rest as an arg, we must advance to the next
862                                  * element now.
863                                  */
864                                 d->custom_optind++;
865                         } else if (d->custom_optind == argc) {
866                                 if (print_errors) {
867                                         fprintf(stderr,
868                                                 "%s: option requires an argument -- %c\n",
869                                                 argv[0], c);
870                                 }
871                                 d->custom_optopt = c;
872                                 if (optstring[0] == ':')
873                                         c = ':';
874                                 else
875                                         c = '?';
876                         } else
877                                 /*
878                                  * We already incremented `custom_optind' once;
879                                  * increment it again when taking next ARGV-elt
880                                  * as argument.
881                                  */
882                                 d->custom_optarg = argv[d->custom_optind++];
883                         d->nextchar = NULL;
884                 }
885         }
886         return c;
887 }
888
889 /*
890  * Scan elements of ARGV for option characters given in OPTSTRING.
891  *
892  * If an element of ARGV starts with '-', and is not exactly "-" or "--",
893  * then it is an option element.  The characters of this element
894  * (aside from the initial '-') are option characters.  If `getopt'
895  * is called repeatedly, it returns successively each of the option characters
896  * from each of the option elements.
897  *
898  * If `getopt' finds another option character, it returns that character,
899  * updating `custom_optind' and `nextchar' so that the next call to `getopt' can
900  * resume the scan with the following option character or ARGV-element.
901  *
902  * If there are no more option characters, `getopt' returns -1.
903  * Then `custom_optind' is the index in ARGV of the first ARGV-element
904  * that is not an option.  (The ARGV-elements have been permuted
905  * so that those that are not options now come last.)
906  *
907  * OPTSTRING is a string containing the legitimate option characters.
908  * If an option character is seen that is not listed in OPTSTRING,
909  * return '?' after printing an error message.  If you set `custom_opterr' to
910  * zero, the error message is suppressed but we still return '?'.
911  *
912  * If a char in OPTSTRING is followed by a colon, that means it wants an arg,
913  * so the following text in the same ARGV-element, or the text of the following
914  * ARGV-element, is returned in `custom_optarg'.  Two colons mean an option that
915  * wants an optional arg; if there is text in the current ARGV-element,
916  * it is returned in `custom_optarg', otherwise `custom_optarg' is set to zero.
917  *
918  * If OPTSTRING starts with `-' or `+', it requests different methods of
919  * handling the non-option ARGV-elements.
920  * See the comments about RETURN_IN_ORDER and REQUIRE_ORDER, above.
921  *
922  * Long-named options begin with `--' instead of `-'.
923  * Their names may be abbreviated as long as the abbreviation is unique
924  * or is an exact match for some defined option.  If they have an
925  * argument, it follows the option name in the same ARGV-element, separated
926  * from the option name by a `=', or else the in next ARGV-element.
927  * When `getopt' finds a long-named option, it returns 0 if that option's
928  * `flag' field is nonzero, the value of the option's `val' field
929  * if the `flag' field is zero.
930  *
931  * The elements of ARGV aren't really const, because we permute them.
932  * But we pretend they're const in the prototype to be compatible
933  * with other systems.
934  *
935  * LONGOPTS is a vector of `struct option' terminated by an
936  * element containing a name which is zero.
937  *
938  * LONGIND returns the index in LONGOPT of the long-named option found.
939  * It is only valid when a long-named option has been found by the most
940  * recent call.
941  *
942  * Return the option character from OPTS just read.  Return -1 when there are
943  * no more options.  For unrecognized options, or options missing arguments,
944  * `custom_optopt' is set to the option letter, and '?' is returned.
945  *
946  * The OPTS string is a list of characters which are recognized option letters,
947  * optionally followed by colons, specifying that that letter takes an
948  * argument, to be placed in `custom_optarg'.
949  *
950  * If a letter in OPTS is followed by two colons, its argument is optional.
951  * This behavior is specific to the GNU `getopt'.
952  *
953  * The argument `--' causes premature termination of argument scanning,
954  * explicitly telling `getopt' that there are no more options.  If OPTS begins
955  * with `--', then non-option arguments are treated as arguments to the option
956  * '\0'.  This behavior is specific to the GNU `getopt'.
957  */
958
959 static int getopt_internal_r(int argc, char *const *argv, const char *optstring,
960                 const struct option *longopts, int *longind,
961                 struct custom_getopt_data *d)
962 {
963         int ret, print_errors = d->custom_opterr;
964
965         if (optstring[0] == ':')
966                 print_errors = 0;
967         if (argc < 1)
968                 return -1;
969         d->custom_optarg = NULL;
970
971         /* 
972          * This is a big difference with GNU getopt, since optind == 0
973          * means initialization while here 1 means first call.
974          */
975         if (d->custom_optind == 0 || !d->initialized) {
976                 if (d->custom_optind == 0)
977                         d->custom_optind = 1;   /* Don't scan ARGV[0], the program name.  */
978                 custom_getopt_initialize(d);
979         }
980         if (d->nextchar == NULL || *d->nextchar == '\0') {
981                 ret = shuffle_argv(argc, argv, longopts, d);
982                 if (ret)
983                         return ret;
984         }
985         if (longopts && (argv[d->custom_optind][1] == '-' ))
986                 return check_long_opt(argc, argv, optstring, longopts,
987                         longind, print_errors, d);
988         return check_short_opt(argc, argv, optstring, print_errors, d);
989 }
990
991 static int custom_getopt_internal(int argc, char *const *argv, const char *optstring,
992         const struct option *longopts, int *longind)
993 {
994         int result;
995         /* Keep a global copy of all internal members of d */
996         static struct custom_getopt_data d;
997
998         d.custom_optind = custom_optind;
999         d.custom_opterr = custom_opterr;
1000         result = getopt_internal_r(argc, argv, optstring, longopts,
1001                 longind, &d);
1002         custom_optind = d.custom_optind;
1003         custom_optarg = d.custom_optarg;
1004         custom_optopt = d.custom_optopt;
1005         return result;
1006 }
1007
1008 static int custom_getopt_long (int argc, char *const *argv, const char *options,
1009         const struct option *long_options, int *opt_index)
1010 {
1011         return custom_getopt_internal(argc, argv, options, long_options,
1012                 opt_index);
1013 }
1014
1015
1016 static char *package_name = 0;
1017
1018 /**
1019  * @brief updates an option
1020  * @param field the generic pointer to the field to update
1021  * @param orig_field the pointer to the orig field
1022  * @param field_given the pointer to the number of occurrence of this option
1023  * @param prev_given the pointer to the number of occurrence already seen
1024  * @param value the argument for this option (if null no arg was specified)
1025  * @param possible_values the possible values for this option (if specified)
1026  * @param default_value the default value (in case the option only accepts fixed values)
1027  * @param arg_type the type of this option
1028  * @param check_ambiguity @see PKplex_cmdline_parser_params.check_ambiguity
1029  * @param override @see PKplex_cmdline_parser_params.override
1030  * @param no_free whether to free a possible previous value
1031  * @param multiple_option whether this is a multiple option
1032  * @param long_opt the corresponding long option
1033  * @param short_opt the corresponding short option (or '-' if none)
1034  * @param additional_error possible further error specification
1035  */
1036 static
1037 int update_arg(void *field, char **orig_field,
1038                unsigned int *field_given, unsigned int *prev_given, 
1039                char *value, const char *possible_values[],
1040                const char *default_value,
1041                PKplex_cmdline_parser_arg_type arg_type,
1042                int check_ambiguity, int override,
1043                int no_free, int multiple_option,
1044                const char *long_opt, char short_opt,
1045                const char *additional_error)
1046 {
1047   char *stop_char = 0;
1048   const char *val = value;
1049   int found;
1050   char **string_field;
1051   FIX_UNUSED (field);
1052
1053   stop_char = 0;
1054   found = 0;
1055
1056   if (!multiple_option && prev_given && (*prev_given || (check_ambiguity && *field_given)))
1057     {
1058       if (short_opt != '-')
1059         fprintf (stderr, "%s: `--%s' (`-%c') option given more than once%s\n", 
1060                package_name, long_opt, short_opt,
1061                (additional_error ? additional_error : ""));
1062       else
1063         fprintf (stderr, "%s: `--%s' option given more than once%s\n", 
1064                package_name, long_opt,
1065                (additional_error ? additional_error : ""));
1066       return 1; /* failure */
1067     }
1068
1069   FIX_UNUSED (default_value);
1070     
1071   if (field_given && *field_given && ! override)
1072     return 0;
1073   if (prev_given)
1074     (*prev_given)++;
1075   if (field_given)
1076     (*field_given)++;
1077   if (possible_values)
1078     val = possible_values[found];
1079
1080   switch(arg_type) {
1081   case ARG_FLAG:
1082     *((int *)field) = !*((int *)field);
1083     break;
1084   case ARG_FLOAT:
1085     if (val) *((float *)field) = (float)strtod (val, &stop_char);
1086     break;
1087   case ARG_DOUBLE:
1088     if (val) *((double *)field) = strtod (val, &stop_char);
1089     break;
1090   case ARG_STRING:
1091     if (val) {
1092       string_field = (char **)field;
1093       if (!no_free && *string_field)
1094         free (*string_field); /* free previous string */
1095       *string_field = gengetopt_strdup (val);
1096     }
1097     break;
1098   default:
1099     break;
1100   };
1101
1102   /* check numeric conversion */
1103   switch(arg_type) {
1104   case ARG_FLOAT:
1105   case ARG_DOUBLE:
1106     if (val && !(stop_char && *stop_char == '\0')) {
1107       fprintf(stderr, "%s: invalid numeric value: %s\n", package_name, val);
1108       return 1; /* failure */
1109     }
1110     break;
1111   default:
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 PKplex_cmdline_parser_internal (
1138   int argc, char **argv, struct PKplex_args_info *args_info,
1139                         struct PKplex_cmdline_parser_params *params, const char *additional_error)
1140 {
1141   int c;        /* Character of the parsed option.  */
1142
1143   int error = 0;
1144   struct PKplex_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     PKplex_cmdline_parser_init (args_info);
1165
1166   PKplex_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         { "detailed-help",      0, NULL, 0 },
1180         { "version",    0, NULL, 'V' },
1181         { "cutoff",     1, NULL, 'c' },
1182         { "temp",       1, NULL, 'T' },
1183         { "noTetra",    0, NULL, '4' },
1184         { "noLP",       0, NULL, 0 },
1185         { "noGU",       0, NULL, 0 },
1186         { "noClosingGU",        0, NULL, 0 },
1187         { "noconv",     0, NULL, 0 },
1188         { "nsp",        1, NULL, 0 },
1189         { "energyCutoff",       1, NULL, 'e' },
1190         { "paramFile",  1, NULL, 'P' },
1191         { "verbose",    0, NULL, 'v' },
1192         { "subopts",    1, NULL, 's' },
1193         { 0,  0, 0, 0 }
1194       };
1195
1196       custom_optarg = optarg;
1197       custom_optind = optind;
1198       custom_opterr = opterr;
1199       custom_optopt = optopt;
1200
1201       c = custom_getopt_long (argc, argv, "hVc:T:4e:P:vs:", long_options, &option_index);
1202
1203       optarg = custom_optarg;
1204       optind = custom_optind;
1205       opterr = custom_opterr;
1206       optopt = custom_optopt;
1207
1208       if (c == -1) break;       /* Exit from `while (1)' loop.  */
1209
1210       switch (c)
1211         {
1212         case 'h':       /* Print help and exit.  */
1213           PKplex_cmdline_parser_print_help ();
1214           PKplex_cmdline_parser_free (&local_args_info);
1215           exit (EXIT_SUCCESS);
1216
1217         case 'V':       /* Print version and exit.  */
1218           PKplex_cmdline_parser_print_version ();
1219           PKplex_cmdline_parser_free (&local_args_info);
1220           exit (EXIT_SUCCESS);
1221
1222         case 'c':       /* Report only base pairs with an average probability > cutoff in the dot plot
1223         
1224 .  */
1225         
1226         
1227           if (update_arg( (void *)&(args_info->cutoff_arg), 
1228                &(args_info->cutoff_orig), &(args_info->cutoff_given),
1229               &(local_args_info.cutoff_given), optarg, 0, "0.01", ARG_FLOAT,
1230               check_ambiguity, override, 0, 0,
1231               "cutoff", 'c',
1232               additional_error))
1233             goto failure;
1234         
1235           break;
1236         case 'T':       /* Rescale energy parameters to a temperature of temp C. Default is 37C.
1237         
1238 .  */
1239         
1240         
1241           if (update_arg( (void *)&(args_info->temp_arg), 
1242                &(args_info->temp_orig), &(args_info->temp_given),
1243               &(local_args_info.temp_given), optarg, 0, 0, ARG_DOUBLE,
1244               check_ambiguity, override, 0, 0,
1245               "temp", 'T',
1246               additional_error))
1247             goto failure;
1248         
1249           break;
1250         case '4':       /* Do not include special stabilizing energies for certain tetra-loops. Mostly for testing.
1251         
1252 .  */
1253         
1254         
1255           if (update_arg((void *)&(args_info->noTetra_flag), 0, &(args_info->noTetra_given),
1256               &(local_args_info.noTetra_given), optarg, 0, 0, ARG_FLAG,
1257               check_ambiguity, override, 1, 0, "noTetra", '4',
1258               additional_error))
1259             goto failure;
1260         
1261           break;
1262         case 'e':       /* Energy cutoff or pseudoknot initiation cost. Minimum energy gain of a pseudoknot interaction for it to be returned. Pseudoknots with smaller energy gains are rejected.
1263         
1264 .  */
1265         
1266         
1267           if (update_arg( (void *)&(args_info->energyCutoff_arg), 
1268                &(args_info->energyCutoff_orig), &(args_info->energyCutoff_given),
1269               &(local_args_info.energyCutoff_given), optarg, 0, "-8.10", ARG_DOUBLE,
1270               check_ambiguity, override, 0, 0,
1271               "energyCutoff", 'e',
1272               additional_error))
1273             goto failure;
1274         
1275           break;
1276         case 'P':       /* Read energy parameters from paramfile, instead of using the default parameter set.
1277 .  */
1278         
1279         
1280           if (update_arg( (void *)&(args_info->paramFile_arg), 
1281                &(args_info->paramFile_orig), &(args_info->paramFile_given),
1282               &(local_args_info.paramFile_given), optarg, 0, 0, ARG_STRING,
1283               check_ambiguity, override, 0, 0,
1284               "paramFile", 'P',
1285               additional_error))
1286             goto failure;
1287         
1288           break;
1289         case 'v':       /* print verbose output
1290 .  */
1291         
1292         
1293           if (update_arg((void *)&(args_info->verbose_flag), 0, &(args_info->verbose_given),
1294               &(local_args_info.verbose_given), optarg, 0, 0, ARG_FLAG,
1295               check_ambiguity, override, 1, 0, "verbose", 'v',
1296               additional_error))
1297             goto failure;
1298         
1299           break;
1300         case 's':       /* print suboptimal structures whose energy difference of the pseudoknot to the optimum pseudoknot is smaller than the given value.
1301 .  */
1302         
1303         
1304           if (update_arg( (void *)&(args_info->subopts_arg), 
1305                &(args_info->subopts_orig), &(args_info->subopts_given),
1306               &(local_args_info.subopts_given), optarg, 0, "0.0", ARG_DOUBLE,
1307               check_ambiguity, override, 0, 0,
1308               "subopts", 's',
1309               additional_error))
1310             goto failure;
1311         
1312           break;
1313
1314         case 0: /* Long option with no short option */
1315           if (strcmp (long_options[option_index].name, "detailed-help") == 0) {
1316             PKplex_cmdline_parser_print_detailed_help ();
1317             PKplex_cmdline_parser_free (&local_args_info);
1318             exit (EXIT_SUCCESS);
1319           }
1320
1321           /* Produce structures without lonely pairs (helices of length 1).
1322 .  */
1323           if (strcmp (long_options[option_index].name, "noLP") == 0)
1324           {
1325           
1326           
1327             if (update_arg((void *)&(args_info->noLP_flag), 0, &(args_info->noLP_given),
1328                 &(local_args_info.noLP_given), optarg, 0, 0, ARG_FLAG,
1329                 check_ambiguity, override, 1, 0, "noLP", '-',
1330                 additional_error))
1331               goto failure;
1332           
1333           }
1334           /* Do not allow GU pairs
1335           
1336 .  */
1337           else if (strcmp (long_options[option_index].name, "noGU") == 0)
1338           {
1339           
1340           
1341             if (update_arg((void *)&(args_info->noGU_flag), 0, &(args_info->noGU_given),
1342                 &(local_args_info.noGU_given), optarg, 0, 0, ARG_FLAG,
1343                 check_ambiguity, override, 1, 0, "noGU", '-',
1344                 additional_error))
1345               goto failure;
1346           
1347           }
1348           /* Do not allow GU pairs at the end of helices
1349           
1350 .  */
1351           else if (strcmp (long_options[option_index].name, "noClosingGU") == 0)
1352           {
1353           
1354           
1355             if (update_arg((void *)&(args_info->noClosingGU_flag), 0, &(args_info->noClosingGU_given),
1356                 &(local_args_info.noClosingGU_given), optarg, 0, 0, ARG_FLAG,
1357                 check_ambiguity, override, 1, 0, "noClosingGU", '-',
1358                 additional_error))
1359               goto failure;
1360           
1361           }
1362           /* Do not automatically substitude nucleotide \"T\" with \"U\"
1363           
1364 .  */
1365           else if (strcmp (long_options[option_index].name, "noconv") == 0)
1366           {
1367           
1368           
1369             if (update_arg((void *)&(args_info->noconv_flag), 0, &(args_info->noconv_given),
1370                 &(local_args_info.noconv_given), optarg, 0, 0, ARG_FLAG,
1371                 check_ambiguity, override, 1, 0, "noconv", '-',
1372                 additional_error))
1373               goto failure;
1374           
1375           }
1376           /* Allow other pairs in addition to the usual AU,GC,and GU pairs.
1377 .  */
1378           else if (strcmp (long_options[option_index].name, "nsp") == 0)
1379           {
1380           
1381           
1382             if (update_arg( (void *)&(args_info->nsp_arg), 
1383                  &(args_info->nsp_orig), &(args_info->nsp_given),
1384                 &(local_args_info.nsp_given), optarg, 0, "empty", ARG_STRING,
1385                 check_ambiguity, override, 0, 0,
1386                 "nsp", '-',
1387                 additional_error))
1388               goto failure;
1389           
1390           }
1391           
1392           break;
1393         case '?':       /* Invalid option.  */
1394           /* `getopt_long' already printed an error message.  */
1395           goto failure;
1396
1397         default:        /* bug: option not considered.  */
1398           fprintf (stderr, "%s: option unknown: %c%s\n", PKPLEX_CMDLINE_PARSER_PACKAGE, c, (additional_error ? additional_error : ""));
1399           abort ();
1400         } /* switch */
1401     } /* while */
1402
1403
1404
1405
1406   PKplex_cmdline_parser_release (&local_args_info);
1407
1408   if ( error )
1409     return (EXIT_FAILURE);
1410
1411   return 0;
1412
1413 failure:
1414   
1415   PKplex_cmdline_parser_release (&local_args_info);
1416   return (EXIT_FAILURE);
1417 }