/*
File autogenerated by gengetopt version 2.1
generated with the following command:
gengetopt -u
The developers of gengetopt consider the fixed text that goes in all
gengetopt output files to be in the public domain:
we make no copyright claims on it.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
/* If we use autoconf. */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
/* Check for configure's getopt check result. */
#ifndef HAVE_GETOPT_LONG
#include "getopt.h"
#else
#include <getopt.h>
#endif
#include "cmdline.h"
/* Don't define PACKAGE and VERSION if we use automake. */
#define PACKAGE "igbhead"
#define VERSION "0.1"
void
print_version (void)
{
printf ("%s %s\n", PACKAGE, VERSION);
}
void
print_help (void)
{
print_version ();
printf ("Usage: %s [OPTIONS]... [FILES]...\n\
-h --help Print help and exit\n\
-V --version Print version and exit\n\
-xINT --x=INT number of x pixels\n\
-yINT --y=INT number of y pixels\n\
-zINT --z=INT number of z pixels\n\
-tINT --t=INT number of time slices\n\
-dSTRING --data-type=STRING char byte int uint float double OR rgba\n\
-sSTRING --system=STRING system on which file produced\n\
-XFLOAT --dim-x=FLOAT Size in x\n\
-YFLOAT --dim-y=FLOAT Size in y\n\
-ZFLOAT --dim-z=FLOAT Size in z\n\
-TFLOAT --dim-t=FLOAT Duration\n\
-5FLOAT --fac-x=FLOAT Scaling factor in x\n\
-6FLOAT --fac-y=FLOAT Scaling factor in y\n\
-7FLOAT --fac-z=FLOAT Scaling factor in z\n\
-8FLOAT --fac-t=FLOAT Scaling factor in t\n\
-oFLOAT --org-x=FLOAT Origin for x\n\
-pFLOAT --org-y=FLOAT Origin for y\n\
-qFLOAT --org-z=FLOAT Origin for z\n\
-rFLOAT --org-t=FLOAT Origin for t\n\
-IFLOAT --inc-x=FLOAT Increment in x\n\
-JFLOAT --inc-y=FLOAT Increment in y\n\
-KFLOAT --inc-z=FLOAT Increment in z\n\
-LFLOAT --inc-t=FLOAT Increment in t\n\
-SFLOAT --data-factor=FLOAT Scaling factor for data\n\
-0FLOAT --data-zero=FLOAT Origin for data scaling\n\
-ASTRING --author=STRING Author name with no spaces\n\
-1STRING --x-units=STRING Units for x\n\
-2STRING --y-units=STRING Units for y\n\
-3STRING --z-units=STRING Units for z\n\
-4STRING --t-units=STRING Units for t\n\
-j --jive-time Make no. time slices jive with data size\n\
-eSTRING --transparent=STRING Transparent pixel value in hex\n\
-E --no-transparent Turn transparency off\n\
-D --decapitate Remove header\n\
-cSTRING --comment=STRING Add a line of comment\n\
-C --clear-comment Clear all comments\n\
-fSTRING --output-file=STRING output file\n\
-FSTRING --frankenstein=STRING attach header to this file\n\
", PACKAGE);
}
char *
gengetopt_strdup (char * s)
{
char * n, * pn, * ps = s;
while (*ps) ps++;
n = (char *) malloc (1 + ps - s);
if (n != NULL)
{
for (ps=s,pn=n; *ps; ps++,pn++)
*pn = *ps;
*pn = 0;
}
return n;
}
int
cmdline_parser (int argc, char **argv, struct gengetopt_args_info *args_info)
{
int c; /* Character of the parsed option. */
int missing_required_options = 0;
args_info->help_given = 0 ;
args_info->version_given = 0 ;
args_info->x_given = 0 ;
args_info->y_given = 0 ;
args_info->z_given = 0 ;
args_info->t_given = 0 ;
args_info->data_type_given = 0 ;
args_info->system_given = 0 ;
args_info->dim_x_given = 0 ;
args_info->dim_y_given = 0 ;
args_info->dim_z_given = 0 ;
args_info->dim_t_given = 0 ;
args_info->fac_x_given = 0 ;
args_info->fac_y_given = 0 ;
args_info->fac_z_given = 0 ;
args_info->fac_t_given = 0 ;
args_info->org_x_given = 0 ;
args_info->org_y_given = 0 ;
args_info->org_z_given = 0 ;
args_info->org_t_given = 0 ;
args_info->inc_x_given = 0 ;
args_info->inc_y_given = 0 ;
args_info->inc_z_given = 0 ;
args_info->inc_t_given = 0 ;
args_info->data_factor_given = 0 ;
args_info->data_zero_given = 0 ;
args_info->author_given = 0 ;
args_info->x_units_given = 0 ;
args_info->y_units_given = 0 ;
args_info->z_units_given = 0 ;
args_info->t_units_given = 0 ;
args_info->jive_time_given = 0 ;
args_info->transparent_given = 0 ;
args_info->no_transparent_given = 0 ;
args_info->decapitate_given = 0 ;
args_info->comment_given = 0 ;
args_info->clear_comment_given = 0 ;
args_info->output_file_given = 0 ;
args_info->frankenstein_given = 0 ;
#define clear_args()
{ \
args_info->data_type_arg = NULL; \
args_info->system_arg = NULL; \
args_info->author_arg = NULL; \
args_info->x_units_arg = NULL; \
args_info->y_units_arg = NULL; \
args_info->z_units_arg = NULL; \
args_info->t_units_arg = NULL; \
args_info->transparent_arg = NULL; \
args_info->comment_arg = NULL; \
args_info->output_file_arg = NULL; \
args_info->frankenstein_arg = NULL; \
}
clear_args();
args_info->inputs = NULL;
args_info->inputs_num = 0;
while (1)
{
int option_index = 0;
static struct option long_options[] = {
{ "help", 0, NULL, 'h' },
{ "version", 0, NULL, 'V' },
{ "x", 1, NULL, 'x' },
{ "y", 1, NULL, 'y' },
{ "z", 1, NULL, 'z' },
{ "t", 1, NULL, 't' },
{ "data-type", 1, NULL, 'd' },
{ "system", 1, NULL, 's' },
{ "dim-x", 1, NULL, 'X' },
{ "dim-y", 1, NULL, 'Y' },
{ "dim-z", 1, NULL, 'Z' },
{ "dim-t", 1, NULL, 'T' },
{ "fac-x", 1, NULL, '5' },
{ "fac-y", 1, NULL, '6' },
{ "fac-z", 1, NULL, '7' },
{ "fac-t", 1, NULL, '8' },
{ "org-x", 1, NULL, 'o' },
{ "org-y", 1, NULL, 'p' },
{ "org-z", 1, NULL, 'q' },
{ "org-t", 1, NULL, 'r' },
{ "inc-x", 1, NULL, 'I' },
{ "inc-y", 1, NULL, 'J' },
{ "inc-z", 1, NULL, 'K' },
{ "inc-t", 1, NULL, 'L' },
{ "data-factor", 1, NULL, 'S' },
{ "data-zero", 1, NULL, '0' },
{ "author", 1, NULL, 'A' },
{ "x-units", 1, NULL, '1' },
{ "y-units", 1, NULL, '2' },
{ "z-units", 1, NULL, '3' },
{ "t-units", 1, NULL, '4' },
{ "jive-time", 0, NULL, 'j' },
{ "transparent", 1, NULL, 'e' },
{ "no-transparent", 0, NULL, 'E' },
{ "decapitate", 0, NULL, 'D' },
{ "comment", 1, NULL, 'c' },
{ "clear-comment", 0, NULL, 'C' },
{ "output-file", 1, NULL, 'f' },
{ "frankenstein", 1, NULL, 'F' },
{ NULL, 0, NULL, 0 }
};
c = getopt_long (argc, argv, "hVx:y:z:t:d:s:X:Y:Z:T:5:6:7:8:o:p:q:r:I:J:K:L:S:0:A:1:2:3:4:je:EDc:Cf:F:", long_options, &option_index);
if (c == -1) break; /* Exit from `while (1)' loop. */
switch (c)
{
case 'h': /* Print help and exit. */
clear_args ();
print_help ();
exit (0);
case 'V': /* Print version and exit. */
clear_args ();
print_version ();
exit (0);
case 'x': /* number of x pixels. */
if (args_info->x_given)
{
fprintf (stderr, "%s: `--x' (`-x') option given more than once\n", PACKAGE);
clear_args ();
print_help ();
exit (1);
}
args_info->x_given = 1;
args_info->x_arg = atoi (optarg);
break;
case 'y': /* number of y pixels. */
if (args_info->y_given)
{
fprintf (stderr, "%s: `--y' (`-y') option given more than once\n", PACKAGE);
clear_args ();
print_help ();
exit (1);
}
args_info->y_given = 1;
args_info->y_arg = atoi (optarg);
break;
case 'z': /* number of z pixels. */
if (args_info->z_given)
{
fprintf (stderr, "%s: `--z' (`-z') option given more than once\n", PACKAGE);
clear_args ();
print_help ();
exit (1);
}
args_info->z_given = 1;
args_info->z_arg = atoi (optarg);
break;
case 't': /* number of time slices. */
if (args_info->t_given)
{
fprintf (stderr, "%s: `--t' (`-t') option given more than once\n", PACKAGE);
clear_args ();
print_help ();
exit (1);
}
args_info->t_given = 1;
args_info->t_arg = atoi (optarg);
break;
case 'd': /* char byte int uint float double OR rgba. */
if (args_info->data_type_given)
{
fprintf (stderr, "%s: `--data-type' (`-d') option given more than once\n", PACKAGE);
clear_args ();
print_help ();
exit (1);
}
args_info->data_type_given = 1;
args_info->data_type_arg = gengetopt_strdup (optarg);
break;
case 's': /* system on which file produced. */
if (args_info->system_given)
{
fprintf (stderr, "%s: `--system' (`-s') option given more than once\n", PACKAGE);
clear_args ();
print_help ();
exit (1);
}
args_info->system_given = 1;
args_info->system_arg = gengetopt_strdup (optarg);
break;
case 'X': /* Size in x. */
if (args_info->dim_x_given)
{
fprintf (stderr, "%s: `--dim-x' (`-X') option given more than once\n", PACKAGE);
clear_args ();
print_help ();
exit (1);
}
args_info->dim_x_given = 1;
args_info->dim_x_arg = (float)strtod (optarg, NULL);
break;
case 'Y': /* Size in y. */
if (args_info->dim_y_given)
{
fprintf (stderr, "%s: `--dim-y' (`-Y') option given more than once\n", PACKAGE);
clear_args ();
print_help ();
exit (1);
}
args_info->dim_y_given = 1;
args_info->dim_y_arg = (float)strtod (optarg, NULL);
break;
case 'Z': /* Size in z. */
if (args_info->dim_z_given)
{
fprintf (stderr, "%s: `--dim-z' (`-Z') option given more than once\n", PACKAGE);
clear_args ();
print_help ();
exit (1);
}
args_info->dim_z_given = 1;
args_info->dim_z_arg = (float)strtod (optarg, NULL);
break;
case 'T': /* Duration. */
if (args_info->dim_t_given)
{
fprintf (stderr, "%s: `--dim-t' (`-T') option given more than once\n", PACKAGE);
clear_args ();
print_help ();
exit (1);
}
args_info->dim_t_given = 1;
args_info->dim_t_arg = (float)strtod (optarg, NULL);
break;
case '5': /* Scaling factor in x. */
if (args_info->fac_x_given)
{
fprintf (stderr, "%s: `--fac-x' (`-5') option given more than once\n", PACKAGE);
clear_args ();
print_help ();
exit (1);
}
args_info->fac_x_given = 1;
args_info->fac_x_arg = (float)strtod (optarg, NULL);
break;
case '6': /* Scaling factor in y. */
if (args_info->fac_y_given)
{
fprintf (stderr, "%s: `--fac-y' (`-6') option given more than once\n", PACKAGE);
clear_args ();
print_help ();
exit (1);
}
args_info->fac_y_given = 1;
args_info->fac_y_arg = (float)strtod (optarg, NULL);
break;
case '7': /* Scaling factor in z. */
if (args_info->fac_z_given)
{
fprintf (stderr, "%s: `--fac-z' (`-7') option given more than once\n", PACKAGE);
clear_args ();
print_help ();
exit (1);
}
args_info->fac_z_given = 1;
args_info->fac_z_arg = (float)strtod (optarg, NULL);
break;
case '8': /* Scaling factor in t. */
if (args_info->fac_t_given)
{
fprintf (stderr, "%s: `--fac-t' (`-8') option given more than once\n", PACKAGE);
clear_args ();
print_help ();
exit (1);
}
args_info->fac_t_given = 1;
args_info->fac_t_arg = (float)strtod (optarg, NULL);
break;
case 'o': /* Origin for x. */
if (args_info->org_x_given)
{
fprintf (stderr, "%s: `--org-x' (`-o') option given more than once\n", PACKAGE);
clear_args ();
print_help ();
exit (1);
}
args_info->org_x_given = 1;
args_info->org_x_arg = (float)strtod (optarg, NULL);
break;
case 'p': /* Origin for y. */
if (args_info->org_y_given)
{
fprintf (stderr, "%s: `--org-y' (`-p') option given more than once\n", PACKAGE);
clear_args ();
print_help ();
exit (1);
}
args_info->org_y_given = 1;
args_info->org_y_arg = (float)strtod (optarg, NULL);
break;
case 'q': /* Origin for z. */
if (args_info->org_z_given)
{
fprintf (stderr, "%s: `--org-z' (`-q') option given more than once\n", PACKAGE);
clear_args ();
print_help ();
exit (1);
}
args_info->org_z_given = 1;
args_info->org_z_arg = (float)strtod (optarg, NULL);
break;
case 'r': /* Origin for t. */
if (args_info->org_t_given)
{
fprintf (stderr, "%s: `--org-t' (`-r') option given more than once\n", PACKAGE);
clear_args ();
print_help ();
exit (1);
}
args_info->org_t_given = 1;
args_info->org_t_arg = (float)strtod (optarg, NULL);
break;
case 'I': /* Increment in x. */
if (args_info->inc_x_given)
{
fprintf (stderr, "%s: `--inc-x' (`-I') option given more than once\n", PACKAGE);
clear_args ();
print_help ();
exit (1);
}
args_info->inc_x_given = 1;
args_info->inc_x_arg = (float)strtod (optarg, NULL);
break;
case 'J': /* Increment in y. */
if (args_info->inc_y_given)
{
fprintf (stderr, "%s: `--inc-y' (`-J') option given more than once\n", PACKAGE);
clear_args ();
print_help ();
exit (1);
}
args_info->inc_y_given = 1;
args_info->inc_y_arg = (float)strtod (optarg, NULL);
break;
case 'K': /* Increment in z. */
if (args_info->inc_z_given)
{
fprintf (stderr, "%s: `--inc-z' (`-K') option given more than once\n", PACKAGE);
clear_args ();
print_help ();
exit (1);
}
args_info->inc_z_given = 1;
args_info->inc_z_arg = (float)strtod (optarg, NULL);
break;
case 'L': /* Increment in t. */
if (args_info->inc_t_given)
{
fprintf (stderr, "%s: `--inc-t' (`-L') option given more than once\n", PACKAGE);
clear_args ();
print_help ();
exit (1);
}
args_info->inc_t_given = 1;
args_info->inc_t_arg = (float)strtod (optarg, NULL);
break;
case 'S': /* Scaling factor for data. */
if (args_info->data_factor_given)
{
fprintf (stderr, "%s: `--data-factor' (`-S') option given more than once\n", PACKAGE);
clear_args ();
print_help ();
exit (1);
}
args_info->data_factor_given = 1;
args_info->data_factor_arg = (float)strtod (optarg, NULL);
break;
case '0': /* Origin for data scaling. */
if (args_info->data_zero_given)
{
fprintf (stderr, "%s: `--data-zero' (`-0') option given more than once\n", PACKAGE);
clear_args ();
print_help ();
exit (1);
}
args_info->data_zero_given = 1;
args_info->data_zero_arg = (float)strtod (optarg, NULL);
break;
case 'A': /* Author name with no spaces. */
if (args_info->author_given)
{
fprintf (stderr, "%s: `--author' (`-A') option given more than once\n", PACKAGE);
clear_args ();
print_help ();
exit (1);
}
args_info->author_given = 1;
args_info->author_arg = gengetopt_strdup (optarg);
break;
case '1': /* Units for x. */
if (args_info->x_units_given)
{
fprintf (stderr, "%s: `--x-units' (`-1') option given more than once\n", PACKAGE);
clear_args ();
print_help ();
exit (1);
}
args_info->x_units_given = 1;
args_info->x_units_arg = gengetopt_strdup (optarg);
break;
case '2': /* Units for y. */
if (args_info->y_units_given)
{
fprintf (stderr, "%s: `--y-units' (`-2') option given more than once\n", PACKAGE);
clear_args ();
print_help ();
exit (1);
}
args_info->y_units_given = 1;
args_info->y_units_arg = gengetopt_strdup (optarg);
break;
case '3': /* Units for z. */
if (args_info->z_units_given)
{
fprintf (stderr, "%s: `--z-units' (`-3') option given more than once\n", PACKAGE);
clear_args ();
print_help ();
exit (1);
}
args_info->z_units_given = 1;
args_info->z_units_arg = gengetopt_strdup (optarg);
break;
case '4': /* Units for t. */
if (args_info->t_units_given)
{
fprintf (stderr, "%s: `--t-units' (`-4') option given more than once\n", PACKAGE);
clear_args ();
print_help ();
exit (1);
}
args_info->t_units_given = 1;
args_info->t_units_arg = gengetopt_strdup (optarg);
break;
case 'j': /* Make no. time slices jive with data size. */
if (args_info->jive_time_given)
{
fprintf (stderr, "%s: `--jive-time' (`-j') option given more than once\n", PACKAGE);
clear_args ();
print_help ();
exit (1);
}
args_info->jive_time_given = 1;
break;
case 'e': /* Transparent pixel value in hex. */
if (args_info->transparent_given)
{
fprintf (stderr, "%s: `--transparent' (`-e') option given more than once\n", PACKAGE);
clear_args ();
print_help ();
exit (1);
}
args_info->transparent_given = 1;
args_info->transparent_arg = gengetopt_strdup (optarg);
break;
case 'E': /* Turn transparency off. */
if (args_info->no_transparent_given)
{
fprintf (stderr, "%s: `--no-transparent' (`-E') option given more than once\n", PACKAGE);
clear_args ();
print_help ();
exit (1);
}
args_info->no_transparent_given = 1;
break;
case 'D': /* Remove header. */
if (args_info->decapitate_given)
{
fprintf (stderr, "%s: `--decapitate' (`-D') option given more than once\n", PACKAGE);
clear_args ();
print_help ();
exit (1);
}
args_info->decapitate_given = 1;
break;
case 'c': /* Add a line of comment. */
if (args_info->comment_given)
{
fprintf (stderr, "%s: `--comment' (`-c') option given more than once\n", PACKAGE);
clear_args ();
print_help ();
exit (1);
}
args_info->comment_given = 1;
args_info->comment_arg = gengetopt_strdup (optarg);
break;
case 'C': /* Clear all comments. */
if (args_info->clear_comment_given)
{
fprintf (stderr, "%s: `--clear-comment' (`-C') option given more than once\n", PACKAGE);
clear_args ();
print_help ();
exit (1);
}
args_info->clear_comment_given = 1;
break;
case 'f': /* output file. */
if (args_info->output_file_given)
{
fprintf (stderr, "%s: `--output-file' (`-f') option given more than once\n", PACKAGE);
clear_args ();
print_help ();
exit (1);
}
args_info->output_file_given = 1;
args_info->output_file_arg = gengetopt_strdup (optarg);
break;
case 'F': /* attach header to this file. */
if (args_info->frankenstein_given)
{
fprintf (stderr, "%s: `--frankenstein' (`-F') option given more than once\n", PACKAGE);
clear_args ();
print_help ();
exit (1);
}
args_info->frankenstein_given = 1;
args_info->frankenstein_arg = gengetopt_strdup (optarg);
break;
case '?': /* Invalid option. */
/* `getopt_long' already printed an error message. */
exit (1);
default: /* bug: option not considered. */
fprintf (stderr, "%s: option unknown: %c\n", PACKAGE, c);
abort ();
} /* switch */
} /* while */
if ( missing_required_options )
exit (1);
if (optind < argc)
{
int i = 0 ;
args_info->inputs_num = argc - optind ;
args_info->inputs =
(char **)(malloc ((args_info->inputs_num)*sizeof(char *))) ;
while (optind < argc)
args_info->inputs[ i++ ] = strdup (argv[optind++]) ;
}
return 0;
}
syntax highlighted by Code2HTML, v. 0.9.1