ROSS
tw-opts.c File Reference
#include <ctype.h>
#include <ross.h>
#include <string.h>

Go to the source code of this file.

Macros

#define ARRAY_SIZE(a)

Functions

static void need_argument (const tw_optdef *def)
static int is_empty (const tw_optdef *def)
static void parse_args_file (const char *file_name, int *argc_p, char ***argv_p)
void tw_opt_add (const tw_optdef *options)
static void show_help (void)
void tw_opt_settings (FILE *outfile)
void tw_opt_print (void)
char * ltrim (char *s)
char * next_argument (char **line)
static void apply_opt (const tw_optdef *def, const char *value)
static void match_opt (const char *arg)
void tw_opt_parse (int *argc_p, char ***argv_p)

Variables

static const char * program
static const tw_optdefall_groups [10]
static const tw_optdefopt_groups [10]
static unsigned int opt_index = 0
static uint args_file_depth = 0
static const tw_optdef basic []

Macro Definition Documentation

◆ ARRAY_SIZE

#define ARRAY_SIZE ( a)
Value:
( sizeof((a)) / sizeof((a)[0]) )

Definition at line 6 of file tw-opts.c.

Referenced by tw_opt_parse().

Function Documentation

◆ apply_opt()

◆ is_empty()

int is_empty ( const tw_optdef * def)
static

Definition at line 496 of file tw-opts.c.

References TWOPTTYPE_GROUP, and tw_optdef::type.

Referenced by tw_opt_add(), and tw_opt_parse().

◆ ltrim()

char * ltrim ( char * s)

Definition at line 296 of file tw-opts.c.

Referenced by parse_args_file().

◆ match_opt()

void match_opt ( const char * arg)
static

◆ need_argument()

void need_argument ( const tw_optdef * def)
static

Definition at line 285 of file tw-opts.c.

References tw_optdef::name, program, tw_ismaster(), and tw_net_stop().

Referenced by apply_opt().

◆ next_argument()

char * next_argument ( char ** line)

Definition at line 304 of file tw-opts.c.

Referenced by parse_args_file().

◆ parse_args_file()

void parse_args_file ( const char * file_name,
int * argc_p,
char *** argv_p )
static

Definition at line 507 of file tw-opts.c.

References ltrim(), next_argument(), tw_error(), and TW_LOC.

Referenced by apply_opt().

◆ show_help()

◆ tw_opt_add()

void tw_opt_add ( const tw_optdef * options)

Add an opt group

Definition at line 23 of file tw-opts.c.

References is_empty(), opt_groups, opt_index, and tw_optdef::type.

Referenced by main(), and tw_init().

◆ tw_opt_parse()

void tw_opt_parse ( int * argc,
char *** argv )

Remove options from the command line arguments.

Definition at line 552 of file tw-opts.c.

References all_groups, ARRAY_SIZE, basic, is_empty(), match_opt(), opt_groups, program, tw_error(), and TW_LOC.

Referenced by apply_opt(), and tw_init().

◆ tw_opt_print()

void tw_opt_print ( void )

◆ tw_opt_settings()

void tw_opt_settings ( FILE * f)

Variable Documentation

◆ all_groups

const tw_optdef* all_groups[10]
static

Definition at line 10 of file tw-opts.c.

Referenced by match_opt(), show_help(), tw_opt_parse(), tw_opt_print(), and tw_opt_settings().

◆ args_file_depth

uint args_file_depth = 0
static

Definition at line 20 of file tw-opts.c.

Referenced by apply_opt().

◆ basic

const tw_optdef basic[]
static
Initial value:
= {
{ TWOPTTYPE_SHOWHELP, "help", "show this message", NULL },
{ (tw_opttype)0, NULL, NULL, NULL }
}
tw_opttype
Definition tw-opts.h:7
@ TWOPTTYPE_SHOWHELP
Definition tw-opts.h:17

Definition at line 491 of file tw-opts.c.

Referenced by tw_opt_parse().

◆ opt_groups

const tw_optdef* opt_groups[10]
static

Definition at line 16 of file tw-opts.c.

Referenced by tw_opt_add(), and tw_opt_parse().

◆ opt_index

unsigned int opt_index = 0
static

Definition at line 17 of file tw-opts.c.

Referenced by tw_opt_add().

◆ program

const char* program
static

Definition at line 9 of file tw-opts.c.

Referenced by apply_opt(), match_opt(), need_argument(), show_help(), and tw_opt_parse().