Airframe Application Utilities
libairframe 2.12.0 API documentation

Macros | Functions | Variables
mio_config.h File Reference

Airframe Multiple I/O Configuration Support. More...

#include <airframe/mio.h>
#include <airframe/airopt.h>

Go to the source code of this file.

Macros

#define MIO_F_CLI_INMASK   0x0000007F
 Mask covering input flag bits; used internally.
 
#define MIO_F_CLI_FILE_IN   0x00000001
 Enable configuration of file, glob, and standard input.
 
#define MIO_F_CLI_DIR_IN   0x00000002
 Enable configuration of file input from directory (requires FILE_IN)
 
#define MIO_F_CLI_UDP_IN   0x00000004
 Enable configuration of UDP passive socket input.
 
#define MIO_F_CLI_TCP_IN   0x00000008
 Enable configuration of single-thread TCP passive socket input.
 
#define MIO_F_CLI_PCAP_IN   0x00000040
 Enable configuration of libpcap dump file and live capture input.
 
#define MIO_F_CLI_DEF_STDIN   0x00000080
 Default to standard input with no input specifier (requires FILE_IN)
 
#define MIO_F_CLI_OUTMASK   0x00007F00
 Mask covering output flag bits; used internally.
 
#define MIO_F_CLI_FILE_OUT   0x00000100
 Enable configuration of file output.
 
#define MIO_F_CLI_DIR_OUT   0x00000200
 Enable configuration of file output to directory.
 
#define MIO_F_CLI_UDP_OUT   0x00000400
 Enable configuration of UDP active socket output.
 
#define MIO_F_CLI_TCP_OUT   0x00000800
 Enable configuration of TCP active socket output.
 
#define MIO_F_CLI_DEF_STDOUT   0x00008000
 Default to standard output with no output specifier with standard input.
 

Functions

gboolean mio_add_option_group (AirOptionCtx *aoctx, uint32_t flags)
 Add an option group appropriate for parsing MIO options consistent with the given CLI flags to the given options context. More...
 
gboolean mio_config_source (MIOSource *source, uint32_t cli_flags, uint32_t *miod_flags, GError **err)
 Configure an MIOSource from mio_config command-line and global application options. More...
 
gboolean mio_config_sink (MIOSource *source, MIOSink *sink, char *basepat, uint32_t cli_flags, uint32_t *miod_flags, GError **err)
 Configure an MIOSink from mio_config command-line and global application options. More...
 
gboolean mio_config_multisink_file (MIOSource *source, MIOSink *sink, char *basepat, uint32_t count, char **labels, uint32_t cli_flags, uint32_t *miod_flags, GError **err)
 Configure a multiple MIOSink array of file sinks of from mio_config command-line and global application options, as well as a set of application-defined labels. More...
 

Variables

char * mio_ov_in
 Input specifier (–in argument). More...
 
char * mio_ov_out
 Output specifier (–out argument). More...
 
char * mio_ov_nextdir
 Next directory for file source (–nextdir argument), empty for delete, NULL for no routing. More...
 
char * mio_ov_faildir
 Fail directory for file source (–faildir argument), empty for delete, NULL for no routing. More...
 
int mio_ov_poll
 Polling delay (–poll argument). More...
 
gboolean mio_ov_lock
 Lock option flag (TRUE if –lock present). More...
 
gboolean mio_ov_live
 Live capture option flag (TRUE if –live present). More...
 
char * mio_ov_bpf
 BPF expression for pcap filter (–bpf argument). More...
 
uint32_t mio_ov_pcaplen
 Live capture length in octets. More...
 
uint32_t mio_ov_pcapto
 Live capture timeout in milliseconds. More...
 
char * mio_ov_port
 UDP/TCP source and sink default application service; string naming a service to be passed to getaddrinfo(3)/getservbyname(3), or a string containing an integer port number. More...
 
MIOType mio_ov_filetype
 MIOType of the FILE_IN sources and FILE_OUT sinks; valid values are MIO_T_NULL, MIO_T_FD, and MIO_T_FP. More...
 

Detailed Description

Airframe Multiple I/O Configuration Support.

Supplies command-line processing and configuration of MIOSource and MIOSink instances for MIO-based applications.

Applications use mio_config by describing the source and sink types they support via a set of flags, passing these flags to mio_option_group to get an option group for GOption-based processing; then, after the command line has been parsed, the application calls mio_config_source() and mio_config_sink() to create an appropriate source and sink, respectively.

Function Documentation

◆ mio_add_option_group()

gboolean mio_add_option_group ( AirOptionCtx aoctx,
uint32_t  flags 
)

Add an option group appropriate for parsing MIO options consistent with the given CLI flags to the given options context.

Parameters
aoctxairframe option context
flagsMIO_F_CLI_* flags describing application I/O capabilities.
Returns
TRUE if successful, FALSE otherwise

◆ mio_config_multisink_file()

gboolean mio_config_multisink_file ( MIOSource source,
MIOSink sink,
char *  basepat,
uint32_t  count,
char **  labels,
uint32_t  cli_flags,
uint32_t *  miod_flags,
GError **  err 
)

Configure a multiple MIOSink array of file sinks of from mio_config command-line and global application options, as well as a set of application-defined labels.

See mio_sink_multi.h and mio_sink_file.h for more. Call this after calling mio_option_group() and g_option_context_parse() on a GOptionContext containing the returned MIO GOptionGroup.

Parameters
sourcePointer to a configured MIOSource (generally from mio_config_source()); used for determining whether to default to standard output (pipe-filter mode). May pass NULL if your application is sourceless.
sinkPointer to MIOSink to configure. This MIOSink will be overwritten.
basepatBase pattern describing output filenames. See mio_sink_init_file_pattern() for pattern substitution rules; user-specified directory and application-specified labels will be prepended to this pattern.
countNumber of file sinks to create in the multiple sink; also defines the size of the labels array.
labelsArray of labels to attach to each output file in the multiple file sink.
cli_flagsMIO_F_CLI_* flags describing application I/O capabilities. Must be identical to or a subset of the flags argument to mio_option_group(); applications may decide based on other command-line options that certain source types are no longer acceptable, for example.
miod_flagsPointer to an mio_dispatch() flags word. mio_config_multisink_file() may set or unset any MIO_F_OPT_* flags in this word as appropriate.
errAn error description pointer; will contain error if mio_config_sink() was unable to configure a sink.
Returns
TRUE if the MIOSink was configured successfully.

◆ mio_config_sink()

gboolean mio_config_sink ( MIOSource source,
MIOSink sink,
char *  basepat,
uint32_t  cli_flags,
uint32_t *  miod_flags,
GError **  err 
)

Configure an MIOSink from mio_config command-line and global application options.

Call this after calling mio_option_group() and g_option_context_parse() on a GOptionContext containing the returned MIO GOptionGroup.

Parameters
sourcePointer to a configured MIOSource (generally from mio_config_source()); used for determining whether to default to standard output (pipe-filter mode). May pass NULL if your application is sourceless.
sinkPointer to MIOSink to configure. This MIOSink will be overwritten.
basepatBase pattern describing output filenames for FILE_OUT or DIR_OUT modes. See mio_sink_init_file_pattern() for pattern substitution rules; user-specified directory may be prepended to this pattern if supplied.
cli_flagsMIO_F_CLI_* flags describing application I/O capabilities. Must be identical to or a subset of the flags argument to mio_option_group(); applications may decide based on other command-line options that certain source types are no longer acceptable, for example.
miod_flagsPointer to an mio_dispatch() flags word. mio_config_sink() may set or unset any MIO_F_OPT_* flags in this word as appropriate.
errAn error description pointer; will contain error if mio_config_sink() was unable to configure a sink.
Returns
TRUE if the MIOSink was configured successfully.

◆ mio_config_source()

gboolean mio_config_source ( MIOSource source,
uint32_t  cli_flags,
uint32_t *  miod_flags,
GError **  err 
)

Configure an MIOSource from mio_config command-line and global application options.

Call this after calling mio_option_group() and g_option_context_parse() on a GOptionContext containing the returned MIO GOptionGroup.

Parameters
sourcePointer to MIOSource to configure. This MIOSource will be overwritten.
cli_flagsMIO_F_CLI_* flags describing application I/O capabilities. Must be identical to or a subset of the flags argument to mio_option_group(); applications may decide based on other command-line options that certain source types are no longer acceptable, for example.
miod_flagsPointer to an mio_dispatch() flags word. mio_config_source() may set or unset any MIO_F_OPT_* flags in this word as appropriate.
errAn error description pointer; will contain error if mio_config_source() was unable to configure a source.
Returns
TRUE if the MIOSource was configured successfully.

Variable Documentation

◆ mio_ov_bpf

char* mio_ov_bpf
extern

BPF expression for pcap filter (–bpf argument).

Global; do not modify.

◆ mio_ov_faildir

char* mio_ov_faildir
extern

Fail directory for file source (–faildir argument), empty for delete, NULL for no routing.

Global; do not modify.

◆ mio_ov_filetype

MIOType mio_ov_filetype
extern

MIOType of the FILE_IN sources and FILE_OUT sinks; valid values are MIO_T_NULL, MIO_T_FD, and MIO_T_FP.

Default is MIO_T_FP. Global application option; set before calling mio_config_source(), mio_config_sink(), or mio_dispatch().

◆ mio_ov_in

char* mio_ov_in
extern

Input specifier (–in argument).

Global; do not modify.

◆ mio_ov_live

gboolean mio_ov_live
extern

Live capture option flag (TRUE if –live present).

Global; do not modify.

◆ mio_ov_lock

gboolean mio_ov_lock
extern

Lock option flag (TRUE if –lock present).

Global; do not modify.

◆ mio_ov_nextdir

char* mio_ov_nextdir
extern

Next directory for file source (–nextdir argument), empty for delete, NULL for no routing.

Global; do not modify.

◆ mio_ov_out

char* mio_ov_out
extern

Output specifier (–out argument).

Global; do not modify.

◆ mio_ov_pcaplen

uint32_t mio_ov_pcaplen
extern

Live capture length in octets.

Global application option; set before calling mio_config_source() or mio_dispatch().

◆ mio_ov_pcapto

uint32_t mio_ov_pcapto
extern

Live capture timeout in milliseconds.

Global application option; set before calling mio_config_source() or mio_dispatch().

◆ mio_ov_poll

int mio_ov_poll
extern

Polling delay (–poll argument).

Amount of time in seconds mio_dispatch_loop() will sleep when no input is available for file source. Global; do not modify.

◆ mio_ov_port

char* mio_ov_port
extern

UDP/TCP source and sink default application service; string naming a service to be passed to getaddrinfo(3)/getservbyname(3), or a string containing an integer port number.

Global application option; set before calling mio_config_source(), mio_config_sink(), or mio_dispatch().