Main Page | Compound List | File List | Compound Members | File Members

parse_options.c File Reference

#include <stdlib.h>
#include <stdarg.h>
#include <stdio.h>
#include <ctype.h>
#include <string.h>
#include <assert.h>
#include "parse_options.h"

Go to the source code of this file.

Defines

#define MAX_LINE_LENGTH   4*1024
#define MAX_OPTIONS   256
#define MAX_FILENAME   256
#define OPTION   0
#define ENUM_OPTION   1
#define ARGUMENT   2
#define MIN_NAME_WIDTH   4
#define MIN_TYPE_WIDTH   4
#define MIN_DFLT_WIDTH   7
#define MAX_NAME_WIDTH   16
#define MAX_TYPE_WIDTH   16
#define MAX_DFLT_WIDTH   16
#define BUF_LEN   1024
#define MAX_LINE_WIDTH   70
#define MAX_ARGC   MAX_OPTIONS
#define MIN(a, b)   ((a)<(b)?(a):(b))
#define MAX(a, b)   ((a)>(b)?(a):(b))

Functions

int option_class (char *name)
int parse_ini_file (char *ini_filename, option_t options[], int option_found[], int nr_options)
int string2int (char *s, char *set)
char * int2string (int pos, char *set)
int enum_index (char *list, char *name)
void add_string (char ***list, char *s)
int store_strlist (char ***var_p, char *value)
int store_str (option_t option, char **var_p, char *value, char *location)
int store_enum (option_t option, int *var_p, char *value)
int store_int_enum (option_t option, int *var_p, char *value, char *location)
int store_int (option_t option, int *var_p, char *value, char *location)
int store_double (double *var_p, char *value)
int store_float (float *var_p, char *value)
int store_char (char *var_p, char *value)
int store_bool (int *var_p, char *value)
int store_value (option_t option, char *value, char *location)
char * get_value (option_t *option)
int parse_option (char *name, char *value, char *location, option_t options[], int option_found[], int nr_options)
void remove_comment (char *s)
void remove_tabs (char *s)
void remove_leading_spaces (char *s)
void remove_trailing_spaces (char *s)
void remove_eqsign_spaces (char *s)
int parse_cmd_line (int argc, char *argv[], option_t options[], int option_found[], int nr_options)
void build_ini_filename (char *ini_filename, char *appl_name)
int print (FILE *f, char **s, int *len, char *fmt,...)
int gen_print_options (FILE *f, char *s, int len, char *appl_name, option_t options[])
int sprint_options (char *s, int len, char *appl_name, option_t options[])
int fprint_options (FILE *f, char *appl_name, option_t options[])
int print_options (char *appl_name, option_t options[])
int gen_print_option_values (FILE *f, char *s, int len, char *prefix, option_t options[])
int sprint_option_values (char *s, int len, char *prefix, option_t options[])
int fprint_option_values (FILE *f, char *prefix, option_t options[])
int print_option_values (char *prefix, option_t options[])
int parse_options (char *appl_name, int argc, char *argv[], option_t options[])


Define Documentation

#define ARGUMENT   2
 

Definition at line 32 of file parse_options.c.

Referenced by gen_print_options(), option_class(), parse_option(), and parse_options().

#define BUF_LEN   1024
 

Definition at line 42 of file parse_options.c.

Referenced by gen_print_option_values(), and print().

#define ENUM_OPTION   1
 

Definition at line 31 of file parse_options.c.

Referenced by option_class(), and parse_options().

#define MAX a,
 )     ((a)>(b)?(a):(b))
 

Definition at line 49 of file parse_options.c.

Referenced by gen_print_option_values(), and gen_print_options().

#define MAX_ARGC   MAX_OPTIONS
 

Definition at line 46 of file parse_options.c.

#define MAX_DFLT_WIDTH   16
 

Definition at line 40 of file parse_options.c.

Referenced by gen_print_options().

#define MAX_FILENAME   256
 

Definition at line 28 of file parse_options.c.

Referenced by gen_print_options(), parse_ini_file(), and parse_options().

#define MAX_LINE_LENGTH   4*1024
 

Definition at line 26 of file parse_options.c.

Referenced by parse_ini_file().

#define MAX_LINE_WIDTH   70
 

Definition at line 44 of file parse_options.c.

Referenced by gen_print_option_values().

#define MAX_NAME_WIDTH   16
 

Definition at line 38 of file parse_options.c.

Referenced by gen_print_option_values(), and gen_print_options().

#define MAX_OPTIONS   256
 

Definition at line 27 of file parse_options.c.

Referenced by parse_options().

#define MAX_TYPE_WIDTH   16
 

Definition at line 39 of file parse_options.c.

Referenced by gen_print_options().

#define MIN a,
 )     ((a)<(b)?(a):(b))
 

Definition at line 48 of file parse_options.c.

#define MIN_DFLT_WIDTH   7
 

Definition at line 36 of file parse_options.c.

Referenced by gen_print_options().

#define MIN_NAME_WIDTH   4
 

Definition at line 34 of file parse_options.c.

Referenced by gen_print_option_values(), and gen_print_options().

#define MIN_TYPE_WIDTH   4
 

Definition at line 35 of file parse_options.c.

Referenced by gen_print_options().

#define OPTION   0
 

Definition at line 30 of file parse_options.c.

Referenced by gen_print_option_values(), option_class(), and parse_options().


Function Documentation

void add_string char ***  list,
char *  s
[static]
 

Definition at line 177 of file parse_options.c.

Referenced by store_strlist().

void build_ini_filename char *  ini_filename,
char *  appl_name
[static]
 

Definition at line 1056 of file parse_options.c.

Referenced by gen_print_options(), and parse_options().

int enum_index char *  list,
char *  name
[static]
 

Definition at line 145 of file parse_options.c.

Referenced by parse_option(), and store_enum().

int fprint_option_values FILE *  f,
char *  prefix,
option_t  options[]
 

Definition at line 1280 of file parse_options.c.

References gen_print_option_values().

int fprint_options FILE *  f,
char *  appl_name,
option_t  options[]
 

Definition at line 1209 of file parse_options.c.

References gen_print_options().

int gen_print_option_values FILE *  f,
char *  s,
int  len,
char *  prefix,
option_t  options[]
[static]
 

Definition at line 1224 of file parse_options.c.

References BUF_LEN, get_value(), MAX, MAX_LINE_WIDTH, MAX_NAME_WIDTH, MIN_NAME_WIDTH, option_t::name, OPTION, option_class(), print(), and option_t::type.

Referenced by fprint_option_values(), print_option_values(), and sprint_option_values().

int gen_print_options FILE *  f,
char *  s,
int  len,
char *  appl_name,
option_t  options[]
[static]
 

Definition at line 1110 of file parse_options.c.

References ARGUMENT, build_ini_filename(), option_t::default_value, option_t::help, MAX, MAX_DFLT_WIDTH, MAX_FILENAME, MAX_NAME_WIDTH, MAX_TYPE_WIDTH, MIN_DFLT_WIDTH, MIN_NAME_WIDTH, MIN_TYPE_WIDTH, option_t::name, option_class(), print(), and option_t::type.

Referenced by fprint_options(), print_options(), and sprint_options().

char* get_value option_t option  )  [static]
 

Definition at line 495 of file parse_options.c.

References int2string(), option_t::name, option_t::type, and option_t::var.

Referenced by gen_print_option_values().

char* int2string int  pos,
char *  set
[static]
 

Definition at line 114 of file parse_options.c.

Referenced by get_value().

int option_class char *  name  )  [static]
 

Definition at line 51 of file parse_options.c.

References ARGUMENT, ENUM_OPTION, and OPTION.

Referenced by gen_print_option_values(), gen_print_options(), parse_option(), and parse_options().

int parse_cmd_line int  argc,
char *  argv[],
option_t  options[],
int  option_found[],
int  nr_options
[static]
 

Definition at line 1032 of file parse_options.c.

References parse_option().

Referenced by parse_options().

int parse_ini_file char *  ini_filename,
option_t  options[],
int  option_found[],
int  nr_options
[static]
 

Definition at line 796 of file parse_options.c.

References MAX_FILENAME, MAX_LINE_LENGTH, parse_option(), remove_comment(), remove_eqsign_spaces(), remove_leading_spaces(), remove_tabs(), and remove_trailing_spaces().

Referenced by parse_option(), and parse_options().

int parse_option char *  name,
char *  value,
char *  location,
option_t  options[],
int  option_found[],
int  nr_options
[static]
 

Definition at line 597 of file parse_options.c.

References ARGUMENT, enum_index(), option_class(), parse_ini_file(), and store_value().

Referenced by parse_cmd_line(), and parse_ini_file().

int parse_options char *  appl_name,
int  argc,
char *  argv[],
option_t  options[]
 

Definition at line 1294 of file parse_options.c.

References ARGUMENT, build_ini_filename(), option_t::default_value, ENUM_OPTION, MAX_FILENAME, MAX_OPTIONS, option_t::name, OPTION, option_class(), parse_cmd_line(), parse_ini_file(), and store_value().

int print FILE *  f,
char **  s,
int *  len,
char *  fmt,
... 
[static]
 

Definition at line 1078 of file parse_options.c.

References BUF_LEN.

Referenced by gen_print_option_values(), and gen_print_options().

int print_option_values char *  prefix,
option_t  options[]
 

Definition at line 1285 of file parse_options.c.

References gen_print_option_values().

int print_options char *  appl_name,
option_t  options[]
 

Definition at line 1214 of file parse_options.c.

References gen_print_options().

void remove_comment char *  s  )  [static]
 

Definition at line 689 of file parse_options.c.

Referenced by parse_ini_file().

void remove_eqsign_spaces char *  s  )  [static]
 

Definition at line 759 of file parse_options.c.

Referenced by parse_ini_file().

void remove_leading_spaces char *  s  )  [static]
 

Definition at line 724 of file parse_options.c.

Referenced by parse_ini_file().

void remove_tabs char *  s  )  [static]
 

Definition at line 708 of file parse_options.c.

Referenced by parse_ini_file().

void remove_trailing_spaces char *  s  )  [static]
 

Definition at line 744 of file parse_options.c.

Referenced by parse_ini_file().

int sprint_option_values char *  s,
int  len,
char *  prefix,
option_t  options[]
 

Definition at line 1275 of file parse_options.c.

References gen_print_option_values().

int sprint_options char *  s,
int  len,
char *  appl_name,
option_t  options[]
 

Definition at line 1204 of file parse_options.c.

References gen_print_options().

int store_bool int *  var_p,
char *  value
[static]
 

Definition at line 408 of file parse_options.c.

Referenced by store_value().

int store_char char *  var_p,
char *  value
[static]
 

Definition at line 396 of file parse_options.c.

Referenced by store_value().

int store_double double *  var_p,
char *  value
[static]
 

Definition at line 372 of file parse_options.c.

Referenced by store_value().

int store_enum option_t  option,
int *  var_p,
char *  value
[static]
 

Definition at line 269 of file parse_options.c.

References enum_index(), and option_t::name.

Referenced by store_value().

int store_float float *  var_p,
char *  value
[static]
 

Definition at line 384 of file parse_options.c.

Referenced by store_value().

int store_int option_t  option,
int *  var_p,
char *  value,
char *  location
[static]
 

Definition at line 306 of file parse_options.c.

References option_t::name, and option_t::type.

Referenced by store_value().

int store_int_enum option_t  option,
int *  var_p,
char *  value,
char *  location
[static]
 

Definition at line 283 of file parse_options.c.

References option_t::name, string2int(), and option_t::type.

Referenced by store_value().

int store_str option_t  option,
char **  var_p,
char *  value,
char *  location
[static]
 

Definition at line 236 of file parse_options.c.

References option_t::name, string2int(), and option_t::type.

Referenced by store_value().

int store_strlist char ***  var_p,
char *  value
[static]
 

Definition at line 218 of file parse_options.c.

References add_string().

Referenced by store_value().

int store_value option_t  option,
char *  value,
char *  location
[static]
 

Definition at line 416 of file parse_options.c.

References option_t::name, store_bool(), store_char(), store_double(), store_enum(), store_float(), store_int(), store_int_enum(), store_str(), store_strlist(), option_t::type, and option_t::var.

Referenced by parse_option(), and parse_options().

int string2int char *  s,
char *  set
[static]
 

Definition at line 82 of file parse_options.c.

Referenced by store_int_enum(), and store_str().


Generated on Wed Feb 15 14:52:42 2006 for util by doxygen 1.3.2