Polly 19.0.0git
Classes | Functions | Variables
isl_arg.c File Reference
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <isl/arg.h>
#include <isl/ctx.h>
#include <isl_config.h>

Go to the source code of this file.

Classes

struct  isl_prefixes
 

Functions

static void set_default_choice (struct isl_arg *arg, void *opt)
 
static void set_default_flags (struct isl_arg *arg, void *opt)
 
static void set_default_bool (struct isl_arg *arg, void *opt)
 
static void set_default_child (struct isl_arg *arg, void *opt)
 
static void set_default_user (struct isl_arg *arg, void *opt)
 
static void set_default_int (struct isl_arg *arg, void *opt)
 
static void set_default_long (struct isl_arg *arg, void *opt)
 
static void set_default_ulong (struct isl_arg *arg, void *opt)
 
static void set_default_str (struct isl_arg *arg, void *opt)
 
static void set_default_str_list (struct isl_arg *arg, void *opt)
 
void isl_args_set_defaults (struct isl_args *args, void *opt)
 
static void free_args (struct isl_arg *arg, void *opt)
 
static void free_child (struct isl_arg *arg, void *opt)
 
static void free_str_list (struct isl_arg *arg, void *opt)
 
static void free_user (struct isl_arg *arg, void *opt)
 
void isl_args_free (struct isl_args *args, void *opt)
 
static int add_prefix (struct isl_prefixes *prefixes, const char *prefix)
 
static void drop_prefix (struct isl_prefixes *prefixes, int first)
 
static int print_prefixes (struct isl_prefixes *prefixes)
 
static const char * skip_prefixes (const char *name, struct isl_prefixes *prefixes, int *first)
 
static int print_arg_help (struct isl_arg *decl, struct isl_prefixes *prefixes, int no)
 
const void * isl_memrchr (const void *s, int c, size_t n)
 
static int wrap_msg (const char *s, int indent, int pos)
 
static int print_help_msg (struct isl_arg *decl, int pos)
 
static void print_default (struct isl_arg *decl, const char *def, int pos)
 
static void print_default_choice (struct isl_arg *decl, void *opt, int pos)
 
static void print_choice_help (struct isl_arg *decl, struct isl_prefixes *prefixes, void *opt)
 
static void print_default_flags (struct isl_arg *decl, void *opt, int pos)
 
static void print_flags_help (struct isl_arg *decl, struct isl_prefixes *prefixes, void *opt)
 
static void print_bool_help (struct isl_arg *decl, struct isl_prefixes *prefixes, void *opt)
 
static int print_argument_name (struct isl_arg *decl, const char *name, int pos)
 
static void print_int_help (struct isl_arg *decl, struct isl_prefixes *prefixes, void *opt)
 
static void print_long_help (struct isl_arg *decl, struct isl_prefixes *prefixes, void *opt)
 
static void print_ulong_help (struct isl_arg *decl, struct isl_prefixes *prefixes)
 
static void print_str_help (struct isl_arg *decl, struct isl_prefixes *prefixes, void *opt)
 
static void print_str_list_help (struct isl_arg *decl, struct isl_prefixes *prefixes)
 
static void print_help (struct isl_arg *arg, struct isl_prefixes *prefixes, void *opt)
 
static const char * prog_name (const char *prog)
 
static int any_version (struct isl_arg *decl)
 
static void print_help_and_exit (struct isl_arg *arg, const char *prog, void *opt)
 
static int match_long_name (struct isl_arg *decl, const char *start, const char *end)
 
static const char * skip_dash_dash (struct isl_arg *decl, const char *arg)
 
static const char * skip_name (struct isl_arg *decl, const char *arg, struct isl_prefixes *prefixes, int need_argument, int *has_argument)
 
static int parse_choice_option (struct isl_arg *decl, char **arg, struct isl_prefixes *prefixes, void *opt)
 
static int set_flag (struct isl_arg *decl, unsigned *val, const char *flag, size_t len)
 
static int parse_flags_option (struct isl_arg *decl, char **arg, struct isl_prefixes *prefixes, void *opt)
 
static int parse_bool_option (struct isl_arg *decl, char **arg, struct isl_prefixes *prefixes, void *opt)
 
static int parse_str_option (struct isl_arg *decl, char **arg, struct isl_prefixes *prefixes, void *opt)
 
static int isl_arg_str_list_append (struct isl_arg *decl, void *opt, const char *s)
 
static int parse_str_list_option (struct isl_arg *decl, char **arg, struct isl_prefixes *prefixes, void *opt)
 
static int parse_int_option (struct isl_arg *decl, char **arg, struct isl_prefixes *prefixes, void *opt)
 
static int parse_long_option (struct isl_arg *decl, char **arg, struct isl_prefixes *prefixes, void *opt)
 
static int parse_ulong_option (struct isl_arg *decl, char **arg, struct isl_prefixes *prefixes, void *opt)
 
static int parse_option (struct isl_arg *decl, char **arg, struct isl_prefixes *prefixes, void *opt)
 
static int parse_child_option (struct isl_arg *decl, char **arg, struct isl_prefixes *prefixes, void *opt)
 
static void print_version (struct isl_arg *decl)
 
static void print_version_and_exit (struct isl_arg *decl)
 
static int drop_argument (int argc, char **argv, int drop, int n)
 
static int n_arg (struct isl_arg *arg)
 
static int next_arg (struct isl_arg *arg, int a)
 
static void check_help (struct isl_args *args, char *arg, char *prog, void *opt, unsigned flags)
 
int isl_args_parse (struct isl_args *args, int argc, char **argv, void *opt, unsigned flags)
 

Variables

static struct isl_arg help_arg []
 

Function Documentation

◆ add_prefix()

static int add_prefix ( struct isl_prefixes prefixes,
const char *  prefix 
)
static

Definition at line 224 of file isl_arg.c.

References isl_prefixes::len, isl_prefixes::n, n, and isl_prefixes::prefix.

Referenced by parse_child_option(), and print_help().

◆ any_version()

static int any_version ( struct isl_arg decl)
static

◆ check_help()

static void check_help ( struct isl_args args,
char *  arg,
char *  prog,
void *  opt,
unsigned  flags 
)
static

Definition at line 1246 of file isl_arg.c.

References arg, isl_args::args, ISL_ARG_SKIP_HELP, ISL_FL_ISSET, and print_help_and_exit().

Referenced by isl_args_parse().

◆ drop_argument()

static int drop_argument ( int  argc,
char **  argv,
int  drop,
int  n 
)
static

Definition at line 1214 of file isl_arg.c.

References drop(), and n.

Referenced by isl_args_parse().

◆ drop_prefix()

static void drop_prefix ( struct isl_prefixes prefixes,
int  first 
)
static

Definition at line 244 of file isl_arg.c.

References isl_prefixes::n.

Referenced by parse_child_option(), and print_help().

◆ free_args()

static void free_args ( struct isl_arg arg,
void *  opt 
)
static

◆ free_child()

static void free_child ( struct isl_arg arg,
void *  opt 
)
static

Definition at line 139 of file isl_arg.c.

References arg, free_args(), ISL_ARG_OFFSET_NONE, and isl_args_free().

Referenced by free_args().

◆ free_str_list()

static void free_str_list ( struct isl_arg arg,
void *  opt 
)
static

Definition at line 148 of file isl_arg.c.

References arg, isl_arg::i, and n.

Referenced by free_args().

◆ free_user()

static void free_user ( struct isl_arg arg,
void *  opt 
)
static

Definition at line 159 of file isl_arg.c.

References arg.

Referenced by free_args(), and isl_id_set_free_user().

◆ isl_arg_str_list_append()

static int isl_arg_str_list_append ( struct isl_arg decl,
void *  opt,
const char *  s 
)
static

Definition at line 977 of file isl_arg.c.

References n, isl_arg::offset, isl_arg::offset_n, isl_arg::str_list, and isl_arg::u.

Referenced by parse_str_list_option().

◆ isl_args_free()

void isl_args_free ( struct isl_args args,
void *  opt 
)

Definition at line 199 of file isl_arg.c.

References isl_args::args, and free_args().

Referenced by free_child(), isl_ctx_alloc_with_options(), and isl_ctx_free().

◆ isl_args_parse()

int isl_args_parse ( struct isl_args args,
int  argc,
char **  argv,
void *  opt,
unsigned  flags 
)

◆ isl_args_set_defaults()

void isl_args_set_defaults ( struct isl_args args,
void *  opt 
)

◆ isl_memrchr()

const void * isl_memrchr ( const void *  s,
int  c,
size_t  n 
)

Definition at line 333 of file isl_arg.c.

References n, and p.

Referenced by wrap_msg().

◆ match_long_name()

static int match_long_name ( struct isl_arg decl,
const char *  start,
const char *  end 
)
static

Definition at line 745 of file isl_arg.c.

References isl_arg_alias, isl_arg::long_name, and type.

Referenced by parse_bool_option(), and skip_name().

◆ n_arg()

static int n_arg ( struct isl_arg arg)
static

◆ next_arg()

static int next_arg ( struct isl_arg arg,
int  a 
)
static

Definition at line 1234 of file isl_arg.c.

References a(), arg, isl_arg_arg, isl_arg_end, and type.

Referenced by isl_args_parse().

◆ parse_bool_option()

static int parse_bool_option ( struct isl_arg decl,
char **  arg,
struct isl_prefixes prefixes,
void *  opt 
)
static

◆ parse_child_option()

static int parse_child_option ( struct isl_arg decl,
char **  arg,
struct isl_prefixes prefixes,
void *  opt 
)
static

◆ parse_choice_option()

static int parse_choice_option ( struct isl_arg decl,
char **  arg,
struct isl_prefixes prefixes,
void *  opt 
)
static

◆ parse_flags_option()

static int parse_flags_option ( struct isl_arg decl,
char **  arg,
struct isl_prefixes prefixes,
void *  opt 
)
static

Definition at line 863 of file isl_arg.c.

References arg, isl_arg::offset, set_flag(), skip_name(), and val.

Referenced by parse_option().

◆ parse_int_option()

static int parse_int_option ( struct isl_arg decl,
char **  arg,
struct isl_prefixes prefixes,
void *  opt 
)
static

Definition at line 1015 of file isl_arg.c.

References arg, isl_arg::offset, p, skip_name(), and val.

Referenced by parse_option().

◆ parse_long_option()

static int parse_long_option ( struct isl_arg decl,
char **  arg,
struct isl_prefixes prefixes,
void *  opt 
)
static

◆ parse_option()

static int parse_option ( struct isl_arg decl,
char **  arg,
struct isl_prefixes prefixes,
void *  opt 
)
static

◆ parse_str_list_option()

static int parse_str_list_option ( struct isl_arg decl,
char **  arg,
struct isl_prefixes prefixes,
void *  opt 
)
static

Definition at line 992 of file isl_arg.c.

References arg, isl_arg_str_list_append(), and skip_name().

Referenced by parse_option().

◆ parse_str_option()

static int parse_str_option ( struct isl_arg decl,
char **  arg,
struct isl_prefixes prefixes,
void *  opt 
)
static

Definition at line 951 of file isl_arg.c.

References arg, isl_arg::offset, p, and skip_name().

Referenced by parse_option().

◆ parse_ulong_option()

static int parse_ulong_option ( struct isl_arg decl,
char **  arg,
struct isl_prefixes prefixes,
void *  opt 
)
static

Definition at line 1083 of file isl_arg.c.

References arg, isl_arg::offset, p, skip_name(), and val.

Referenced by parse_option().

◆ print_arg_help()

static int print_arg_help ( struct isl_arg decl,
struct isl_prefixes prefixes,
int  no 
)
static

◆ print_argument_name()

static int print_argument_name ( struct isl_arg decl,
const char *  name,
int  pos 
)
static

Definition at line 529 of file isl_arg.c.

References isl_arg::long_name, name, and pos().

Referenced by print_int_help(), print_str_help(), and print_str_list_help().

◆ print_bool_help()

static void print_bool_help ( struct isl_arg decl,
struct isl_prefixes prefixes,
void *  opt 
)
static

◆ print_choice_help()

static void print_choice_help ( struct isl_arg decl,
struct isl_prefixes prefixes,
void *  opt 
)
static

◆ print_default()

static void print_default ( struct isl_arg decl,
const char *  def,
int  pos 
)
static

Definition at line 380 of file isl_arg.c.

References isl_arg::help_msg, and pos().

Referenced by print_bool_help(), print_default_choice(), print_int_help(), and print_str_help().

◆ print_default_choice()

static void print_default_choice ( struct isl_arg decl,
void *  opt,
int  pos 
)
static

◆ print_default_flags()

static void print_default_flags ( struct isl_arg decl,
void *  opt,
int  pos 
)
static

Definition at line 443 of file isl_arg.c.

References isl_arg::flags, isl_arg::help_msg, isl_arg::offset, p, pos(), and isl_arg::u.

Referenced by print_flags_help().

◆ print_flags_help()

static void print_flags_help ( struct isl_arg decl,
struct isl_prefixes prefixes,
void *  opt 
)
static

Definition at line 482 of file isl_arg.c.

References isl_arg::flags, pos(), print_arg_help(), print_default_flags(), print_help_msg(), and isl_arg::u.

Referenced by print_help().

◆ print_help()

static void print_help ( struct isl_arg arg,
struct isl_prefixes prefixes,
void *  opt 
)
static

◆ print_help_and_exit()

static void print_help_and_exit ( struct isl_arg arg,
const char *  prog,
void *  opt 
)
static

◆ print_help_msg()

static int print_help_msg ( struct isl_arg decl,
int  pos 
)
static

◆ print_int_help()

static void print_int_help ( struct isl_arg decl,
struct isl_prefixes prefixes,
void *  opt 
)
static

◆ print_long_help()

static void print_long_help ( struct isl_arg decl,
struct isl_prefixes prefixes,
void *  opt 
)
static

◆ print_prefixes()

static int print_prefixes ( struct isl_prefixes prefixes)
static

Definition at line 251 of file isl_arg.c.

References isl_prefixes::n, and isl_prefixes::prefix.

Referenced by print_arg_help().

◆ print_str_help()

static void print_str_help ( struct isl_arg decl,
struct isl_prefixes prefixes,
void *  opt 
)
static

◆ print_str_list_help()

static void print_str_list_help ( struct isl_arg decl,
struct isl_prefixes prefixes 
)
static

Definition at line 594 of file isl_arg.c.

References a(), isl_arg::argument_name, pos(), print_arg_help(), print_argument_name(), and print_help_msg().

Referenced by print_help().

◆ print_ulong_help()

static void print_ulong_help ( struct isl_arg decl,
struct isl_prefixes prefixes 
)
static

Definition at line 569 of file isl_arg.c.

References pos(), print_arg_help(), and print_help_msg().

Referenced by print_help().

◆ print_version()

static void print_version ( struct isl_arg decl)
static

◆ print_version_and_exit()

static void print_version_and_exit ( struct isl_arg decl)
static

Definition at line 1207 of file isl_arg.c.

References print_version().

Referenced by isl_args_parse().

◆ prog_name()

static const char * prog_name ( const char *  prog)
static

Definition at line 682 of file isl_arg.c.

Referenced by isl_args_parse(), and print_help_and_exit().

◆ set_default_bool()

static void set_default_bool ( struct isl_arg arg,
void *  opt 
)
static

Definition at line 35 of file isl_arg.c.

References arg, and ISL_ARG_OFFSET_NONE.

Referenced by isl_args_set_defaults().

◆ set_default_child()

static void set_default_child ( struct isl_arg arg,
void *  opt 
)
static

Definition at line 42 of file isl_arg.c.

References arg, isl_arg::child, ISL_ARG_OFFSET_NONE, and isl_args_set_defaults().

Referenced by isl_args_set_defaults().

◆ set_default_choice()

static void set_default_choice ( struct isl_arg arg,
void *  opt 
)
static

Definition at line 23 of file isl_arg.c.

References arg, and ISL_ARG_OFFSET_NONE.

Referenced by isl_args_set_defaults().

◆ set_default_flags()

static void set_default_flags ( struct isl_arg arg,
void *  opt 
)
static

Definition at line 30 of file isl_arg.c.

References arg.

Referenced by isl_args_set_defaults().

◆ set_default_int()

static void set_default_int ( struct isl_arg arg,
void *  opt 
)
static

Definition at line 62 of file isl_arg.c.

References arg.

Referenced by isl_args_set_defaults().

◆ set_default_long()

static void set_default_long ( struct isl_arg arg,
void *  opt 
)
static

Definition at line 67 of file isl_arg.c.

References arg.

Referenced by isl_args_set_defaults().

◆ set_default_str()

static void set_default_str ( struct isl_arg arg,
void *  opt 
)
static

Definition at line 77 of file isl_arg.c.

References arg, and str.

Referenced by isl_args_set_defaults().

◆ set_default_str_list()

static void set_default_str_list ( struct isl_arg arg,
void *  opt 
)
static

Definition at line 85 of file isl_arg.c.

References arg.

Referenced by isl_args_set_defaults().

◆ set_default_ulong()

static void set_default_ulong ( struct isl_arg arg,
void *  opt 
)
static

Definition at line 72 of file isl_arg.c.

References arg.

Referenced by isl_args_set_defaults().

◆ set_default_user()

static void set_default_user ( struct isl_arg arg,
void *  opt 
)
static

Definition at line 57 of file isl_arg.c.

References arg.

Referenced by isl_args_set_defaults().

◆ set_flag()

static int set_flag ( struct isl_arg decl,
unsigned *  val,
const char *  flag,
size_t  len 
)
static

Definition at line 845 of file isl_arg.c.

References isl_arg::flags, isl_prefixes::len, isl_arg::u, and val.

Referenced by parse_flags_option().

◆ skip_dash_dash()

static const char * skip_dash_dash ( struct isl_arg decl,
const char *  arg 
)
static

Definition at line 757 of file isl_arg.c.

References arg, isl_arg::flags, and ISL_ARG_SINGLE_DASH.

Referenced by parse_bool_option(), and skip_name().

◆ skip_name()

static const char * skip_name ( struct isl_arg decl,
const char *  arg,
struct isl_prefixes prefixes,
int  need_argument,
int *  has_argument 
)
static

◆ skip_prefixes()

static const char * skip_prefixes ( const char *  name,
struct isl_prefixes prefixes,
int *  first 
)
static

Definition at line 272 of file isl_arg.c.

References isl_prefixes::len, isl_prefixes::n, name, and isl_prefixes::prefix.

Referenced by parse_bool_option(), and skip_name().

◆ wrap_msg()

static int wrap_msg ( const char *  s,
int  indent,
int  pos 
)
static

Definition at line 342 of file isl_arg.c.

References isl_memrchr(), and pos().

Referenced by print_help_and_exit(), and print_help_msg().

Variable Documentation

◆ help_arg

struct isl_arg help_arg[]
static
Initial value:
= {
ISL_ARG_PHANTOM_BOOL('h', "help", NULL, "print this help, then exit")
}
@ isl_arg_end
Definition: arg.h:32
#define ISL_ARG_PHANTOM_BOOL(s, l, setter, h)
Definition: arg.h:186

Definition at line 18 of file isl_arg.c.

Referenced by print_help_and_exit().