cmdline.h File Reference

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  gengetopt_args_info

Defines

#define PACKAGE   "trapper"
#define VERSION   "0.1"

Functions

int cmdline_parser (int argc, char *const *argv, struct gengetopt_args_info *args_info)
void cmdline_parser_print_help (void)
void cmdline_parser_print_version (void)


Define Documentation

#define PACKAGE   "trapper"

Definition at line 14 of file cmdline.h.

Referenced by cmdline_parser(), cmdline_parser_print_help(), and cmdline_parser_print_version().

#define VERSION   "0.1"

Definition at line 18 of file cmdline.h.

Referenced by cmdline_parser_print_version().


Function Documentation

int cmdline_parser ( int  argc,
char *const *  argv,
struct gengetopt_args_info args_info 
)

Definition at line 72 of file cmdline.c.

References clear_args, cmdline_parser_print_help(), cmdline_parser_print_version(), gengetopt_args_info::configuration_file_arg, gengetopt_args_info::configuration_file_given, gengetopt_args_info::dbhome_dir_arg, gengetopt_args_info::dbhome_dir_given, gengetopt_args_info::help_given, gengetopt_args_info::inputs, gengetopt_args_info::inputs_num, PACKAGE, strdup, and gengetopt_args_info::version_given.

Referenced by main().

00073 {
00074   int c;        /* Character of the parsed option.  */
00075   int missing_required_options = 0;
00076 
00077   args_info->help_given = 0 ;
00078   args_info->version_given = 0 ;
00079   args_info->dbhome_dir_given = 0 ;
00080   args_info->configuration_file_given = 0 ;
00081 #define clear_args() { \
00082   args_info->dbhome_dir_arg = NULL; \
00083   args_info->configuration_file_arg = NULL; \
00084 }
00085 
00086   clear_args();
00087 
00088   args_info->inputs = NULL;
00089   args_info->inputs_num = 0;
00090 
00091   optarg = 0;
00092   optind = 1;
00093   opterr = 1;
00094   optopt = '?';
00095 
00096   while (1)
00097     {
00098       int option_index = 0;
00099       static struct option long_options[] = {
00100         { "help",       0, NULL, 'h' },
00101         { "version",    0, NULL, 'V' },
00102         { "dbhome-dir", 1, NULL, 'd' },
00103         { "configuration-file", 1, NULL, 'c' },
00104         { NULL, 0, NULL, 0 }
00105       };
00106 
00107       c = getopt_long (argc, argv, "hVd:c:", long_options, &option_index);
00108 
00109       if (c == -1) break;       /* Exit from `while (1)' loop.  */
00110 
00111       switch (c)
00112         {
00113         case 'h':       /* Print help and exit.  */
00114           clear_args ();
00115           cmdline_parser_print_help ();
00116           exit (EXIT_SUCCESS);
00117 
00118         case 'V':       /* Print version and exit.  */
00119           clear_args ();
00120           cmdline_parser_print_version ();
00121           exit (EXIT_SUCCESS);
00122 
00123         case 'd':       /* directory home for the database environment ( try to avoid nfs file system ).  */
00124           if (args_info->dbhome_dir_given)
00125             {
00126               fprintf (stderr, "%s: `--dbhome-dir' (`-d') option given more than once\n", PACKAGE);
00127               clear_args ();
00128               exit (EXIT_FAILURE);
00129             }
00130           args_info->dbhome_dir_given = 1;
00131           args_info->dbhome_dir_arg = strdup (optarg);
00132           break;
00133 
00134         case 'c':       /* configuration file for view modes.  */
00135           if (args_info->configuration_file_given)
00136             {
00137               fprintf (stderr, "%s: `--configuration-file' (`-c') option given more than once\n", PACKAGE);
00138               clear_args ();
00139               exit (EXIT_FAILURE);
00140             }
00141           args_info->configuration_file_given = 1;
00142           args_info->configuration_file_arg = strdup (optarg);
00143           break;
00144 
00145 
00146         case 0: /* Long option with no short option */
00147 
00148         case '?':       /* Invalid option.  */
00149           /* `getopt_long' already printed an error message.  */
00150           exit (EXIT_FAILURE);
00151 
00152         default:        /* bug: option not considered.  */
00153           fprintf (stderr, "%s: option unknown: %c\n", PACKAGE, c);
00154           abort ();
00155         } /* switch */
00156     } /* while */
00157 
00158 
00159   if (! args_info->dbhome_dir_given)
00160     {
00161       fprintf (stderr, "%s: '--dbhome-dir' ('-d') option required\n", PACKAGE);
00162       missing_required_options = 1;
00163     }
00164   if (! args_info->configuration_file_given)
00165     {
00166       fprintf (stderr, "%s: '--configuration-file' ('-c') option required\n", PACKAGE);
00167       missing_required_options = 1;
00168     }
00169   if ( missing_required_options )
00170     exit (EXIT_FAILURE);
00171 
00172   if (optind < argc)
00173     {
00174       int i = 0 ;
00175   
00176       args_info->inputs_num = argc - optind ;
00177       args_info->inputs = 
00178         (char **)(malloc ((args_info->inputs_num)*sizeof(char *))) ;
00179       while (optind < argc)
00180         args_info->inputs[ i++ ] = strdup (argv[optind++]) ; 
00181     }
00182   
00183   return 0;
00184 }

void cmdline_parser_print_help ( void   ) 

Definition at line 40 of file cmdline.c.

References cmdline_parser_print_version(), and PACKAGE.

Referenced by cmdline_parser().

00041 {
00042   cmdline_parser_print_version ();
00043   printf("\n"
00044   "Purpose:\n"
00045   "  This program is a visualizing, editing and prosessing tool for dna reads coming from \n"
00046   "  dna sequence readers. The data\n"
00047   "  is stored in a Berkeley Db database which gives fast access to hugh amount of data\n"
00048   "\n"
00049   "Usage: %s [OPTIONS]... [FILES]...\n", PACKAGE);
00050   printf("   -h         --help                       Print help and exit\n");
00051   printf("   -V         --version                    Print version and exit\n");
00052   printf("   -dSTRING   --dbhome-dir=STRING          directory home for the database environment ( try to avoid nfs file system )\n");
00053   printf("   -cSTRING   --configuration-file=STRING  configuration file for view modes\n");
00054 }

void cmdline_parser_print_version ( void   ) 

Definition at line 34 of file cmdline.c.

References PACKAGE, and VERSION.

Referenced by cmdline_parser(), and cmdline_parser_print_help().

00035 {
00036   printf ("%s %s\n", PACKAGE, VERSION);
00037 }


Generated on Fri Jul 17 20:19:31 2009 for ngsview by  doxygen 1.5.1