Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members

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

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 Mar 17 17:44:27 2006 for trapper by  doxygen 1.4.4