Blender V4.3
BLI_args.c File Reference

A general argument parsing module. More...

#include <ctype.h>
#include <stdio.h>
#include <string.h>
#include "MEM_guardedalloc.h"
#include "BLI_args.h"
#include "BLI_ghash.h"
#include "BLI_listbase.h"
#include "BLI_string.h"
#include "BLI_utildefines.h"

Go to the source code of this file.

Classes

struct  bArgDoc
 
struct  bAKey
 
struct  bArgument
 
struct  bArgs
 

Typedefs

typedef struct bArgDoc bArgDoc
 
typedef struct bAKey bAKey
 
typedef struct bArgument bArgument
 

Functions

static uint case_strhash (const void *ptr)
 
static uint keyhash (const void *ptr)
 
static bool keycmp (const void *a, const void *b)
 
static bArgumentlookUp (bArgs *ba, const char *arg, int pass, int case_str)
 
static void args_print_wrapper (void *UNUSED(user_data), const char *format, va_list args)
 
bArgsBLI_args_create (int argc, const char **argv)
 
void BLI_args_destroy (bArgs *ba)
 
void BLI_args_printf (bArgs *ba, const char *format,...)
 
void BLI_args_print_fn_set (bArgs *ba, bArgPrintFn print_fn, void *user_data)
 
void BLI_args_pass_set (bArgs *ba, int current_pass)
 
void BLI_args_print (const bArgs *ba)
 
static bArgDocinternalDocs (bArgs *ba, const char *short_arg, const char *long_arg, const char *doc)
 
static void internalAdd (bArgs *ba, const char *arg, int case_str, BA_ArgCallback cb, void *data, bArgDoc *d)
 
void BLI_args_add_case (bArgs *ba, const char *short_arg, int short_case, const char *long_arg, int long_case, const char *doc, BA_ArgCallback cb, void *data)
 
void BLI_args_add (bArgs *ba, const char *short_arg, const char *long_arg, const char *doc, BA_ArgCallback cb, void *data)
 
static void internalDocPrint (bArgs *ba, bArgDoc *d)
 
void BLI_args_print_arg_doc (bArgs *ba, const char *arg)
 
void BLI_args_print_other_doc (bArgs *ba)
 
bool BLI_args_has_other_doc (const bArgs *ba)
 
void BLI_args_parse (bArgs *ba, int pass, BA_ArgCallback default_cb, void *default_data)
 

Variables

static char NO_DOCS [] = "NO DOCUMENTATION SPECIFIED"
 

Detailed Description

A general argument parsing module.

Definition in file BLI_args.c.

Typedef Documentation

◆ bAKey

typedef struct bAKey bAKey

◆ bArgDoc

typedef struct bArgDoc bArgDoc

◆ bArgument

typedef struct bArgument bArgument

Function Documentation

◆ args_print_wrapper()

static void args_print_wrapper ( void * UNUSEDuser_data,
const char * format,
va_list args )
static

Default print function.

Definition at line 105 of file BLI_args.c.

Referenced by BLI_args_create().

◆ BLI_args_add()

void BLI_args_add ( struct bArgs * ba,
const char * short_arg,
const char * long_arg,
const char * doc,
BA_ArgCallback cb,
void * data )

Pass starts at 1, -1 means valid all the time short_arg or long_arg can be null to specify no short or long versions

Definition at line 241 of file BLI_args.c.

References BLI_args_add_case().

Referenced by main_args_setup().

◆ BLI_args_add_case()

void BLI_args_add_case ( struct bArgs * ba,
const char * short_arg,
int short_case,
const char * long_arg,
int long_case,
const char * doc,
BA_ArgCallback cb,
void * data )

Short_case and long_case specify if those arguments are case specific

Definition at line 221 of file BLI_args.c.

References internalAdd(), and internalDocs().

Referenced by BLI_args_add(), and main_args_setup().

◆ BLI_args_create()

◆ BLI_args_destroy()

void BLI_args_destroy ( bArgs * ba)

◆ BLI_args_has_other_doc()

bool BLI_args_has_other_doc ( const bArgs * ba)

Definition at line 290 of file BLI_args.c.

References bArgs::docs, and ListBase::first.

◆ BLI_args_parse()

void BLI_args_parse ( bArgs * ba,
int pass,
BA_ArgCallback default_cb,
void * default_data )

Definition at line 300 of file BLI_args.c.

References bArgs::argc, bArgs::argv, BLI_assert, lookUp(), NULL, and bArgs::passes.

Referenced by main().

◆ BLI_args_pass_set()

void BLI_args_pass_set ( struct bArgs * ba,
int current_pass )

The pass to use for BLI_args_add.

Definition at line 149 of file BLI_args.c.

References BLI_assert, and bArgs::current_pass.

Referenced by main_args_setup().

◆ BLI_args_print()

void BLI_args_print ( const bArgs * ba)

Definition at line 155 of file BLI_args.c.

References bArgs::argc, bArgs::argv, and printf.

◆ BLI_args_print_arg_doc()

void BLI_args_print_arg_doc ( bArgs * ba,
const char * arg )

Definition at line 266 of file BLI_args.c.

References bArgDoc::done, internalDocPrint(), and lookUp().

Referenced by print_help().

◆ BLI_args_print_fn_set()

void BLI_args_print_fn_set ( bArgs * ba,
bArgPrintFn print_fn,
void * user_data )

Definition at line 143 of file BLI_args.c.

References bArgs::print_fn, and bArgs::print_user_data.

Referenced by BLI_args_create().

◆ BLI_args_print_other_doc()

void BLI_args_print_other_doc ( bArgs * ba)

Definition at line 279 of file BLI_args.c.

References bArgs::docs, bArgDoc::done, ListBase::first, internalDocPrint(), and bArgDoc::next.

Referenced by print_help().

◆ BLI_args_printf()

void BLI_args_printf ( bArgs * ba,
const char * format,
... )

Definition at line 135 of file BLI_args.c.

References bArgs::print_fn, and bArgs::print_user_data.

Referenced by internalDocPrint().

◆ case_strhash()

static uint case_strhash ( const void * ptr)
static

Definition at line 60 of file BLI_args.c.

References ptr.

Referenced by keyhash().

◆ internalAdd()

static void internalAdd ( bArgs * ba,
const char * arg,
int case_str,
BA_ArgCallback cb,
void * data,
bArgDoc * d )
static

◆ internalDocPrint()

static void internalDocPrint ( bArgs * ba,
bArgDoc * d )
static

◆ internalDocs()

static bArgDoc * internalDocs ( bArgs * ba,
const char * short_arg,
const char * long_arg,
const char * doc )
static

◆ keycmp()

static bool keycmp ( const void * a,
const void * b )
static

Definition at line 79 of file BLI_args.c.

References bAKey::arg, b, BLI_ghashutil_intcmp(), BLI_strcasecmp(), bAKey::case_str, bAKey::pass, and STREQ.

Referenced by BLI_args_create().

◆ keyhash()

static uint keyhash ( const void * ptr)
static

Definition at line 73 of file BLI_args.c.

References bAKey::arg, case_strhash(), and ptr.

Referenced by BLI_args_create().

◆ lookUp()

static bArgument * lookUp ( bArgs * ba,
const char * arg,
int pass,
int case_str )
static

Variable Documentation

◆ NO_DOCS

char NO_DOCS[] = "NO DOCUMENTATION SPECIFIED"
static

Definition at line 22 of file BLI_args.c.

Referenced by internalDocs().