argparse.h

Reference Documentation

product_line_custom
IntelĀ® PAC
Napatech SmartNIC
category
Reference Information
Napatech Software Suite: examples/common/argparse.h File Reference
argparse.h File Reference
#include <assert.h>
#include <math.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

Go to the source code of this file.

Functions

int argparse_help_cb (struct argparse *This, const struct argparse_option *option, int terminate)
 
int argparse_init (struct argparse *This, struct argparse_option *options, const char *const *usage, int flags)
 
int argparse_parse (struct argparse *This, int argc, const char **argv)
 
void argparse_usage (struct argparse *This)
 

Data Structures

struct  argparse_option
 
struct  argparse
 

Macros

#define OPT_END()    { ARGPARSE_OPT_END, '0', "", NULL, "", NULL, 0, 0, NULL }
 
#define OPT_BOOLEAN(...)    { ARGPARSE_OPT_BOOLEAN, __VA_ARGS__ }
 
#define OPT_BIT(...)    { ARGPARSE_OPT_BIT, __VA_ARGS__ }
 
#define OPT_BIT64(...)    { ARGPARSE_OPT_BIT64, __VA_ARGS__ }
 
#define OPT_INTEGER(...)    { ARGPARSE_OPT_INTEGER, __VA_ARGS__ }
 
#define OPT_UINT64(...)    { ARGPARSE_OPT_UINT64, __VA_ARGS__ }
 
#define OPT_STRING(...)    { ARGPARSE_OPT_STRING, __VA_ARGS__ }
 
#define OPT_HELP()    OPT_BOOLEAN('h', "help", NULL, "show this help message and exit", argparse_help_cb, 0, 0, NULL)
 

Typedefs

typedef int argparse_callback(struct argparse *This, const struct argparse_option *option, int terminate)
 

Enumerations

enum  argparse_flag { ARGPARSE_STOP_AT_NON_OPTION = 0x0001, ARGPARSE_INTERNAL_OPTION = 0x8000 }
 
enum  argparse_option_type {
  ARGPARSE_OPT_END, ARGPARSE_OPT_BOOLEAN, ARGPARSE_OPT_BIT, ARGPARSE_OPT_BIT64,
  ARGPARSE_OPT_INTEGER, ARGPARSE_OPT_STRING, ARGPARSE_OPT_UINT64
}
 
enum  argparse_option_flags { OPT_NONEG = 1 }
 

Function Documentation

int argparse_help_cb ( struct argparse This,
const struct argparse_option option,
int  terminate 
)

Definition at line 388 of file argparse.c.

int argparse_init ( struct argparse This,
struct argparse_option options,
const char *const *  usage,
int  flags 
)

Definition at line 208 of file argparse.c.

Referenced by main().

int argparse_parse ( struct argparse This,
int  argc,
const char **  argv 
)

Definition at line 219 of file argparse.c.

Referenced by main().

void argparse_usage ( struct argparse This)

Definition at line 286 of file argparse.c.

Referenced by argparse_help_cb(), argparse_parse(), and main().

Macro Definition Documentation

#define OPT_BOOLEAN (   ...)    { ARGPARSE_OPT_BOOLEAN, __VA_ARGS__ }
Examples:
net/capfileconvert/capfileconvert_example.c, and net/replayGS/replayGS_example.c.

Definition at line 108 of file argparse.h.

#define OPT_BIT (   ...)    { ARGPARSE_OPT_BIT, __VA_ARGS__ }

Definition at line 109 of file argparse.h.

#define OPT_BIT64 (   ...)    { ARGPARSE_OPT_BIT64, __VA_ARGS__ }

Definition at line 110 of file argparse.h.

#define OPT_UINT64 (   ...)    { ARGPARSE_OPT_UINT64, __VA_ARGS__ }
Examples:
net/replayGS/replayGS_example.c.

Definition at line 112 of file argparse.h.

Typedef Documentation

typedef int argparse_callback(struct argparse *This, const struct argparse_option *option, int terminate)

Definition at line 24 of file argparse.h.

Enumeration Type Documentation

Enumerator
ARGPARSE_STOP_AT_NON_OPTION 
ARGPARSE_INTERNAL_OPTION 

Definition at line 26 of file argparse.h.

Enumerator
ARGPARSE_OPT_END 
ARGPARSE_OPT_BOOLEAN 
ARGPARSE_OPT_BIT 
ARGPARSE_OPT_BIT64 
ARGPARSE_OPT_INTEGER 
ARGPARSE_OPT_STRING 
ARGPARSE_OPT_UINT64 

Definition at line 31 of file argparse.h.

Enumerator
OPT_NONEG 

Definition at line 44 of file argparse.h.