CDI SDK
SDK for transporting chunks of data reliably and with low latency using a polled mode network driver.
Loading...
Searching...
No Matches
optarg.h
Go to the documentation of this file.
1// -------------------------------------------------------------------------------------------
2// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
3// This file is part of the AWS CDI-SDK, licensed under the BSD 2-Clause "Simplified" License.
4// License details at: https://github.com/aws/aws-cdi-sdk/blob/mainline/LICENSE
5// -------------------------------------------------------------------------------------------
6
13#ifndef CDI_OPTARG_H__
14#define CDI_OPTARG_H__
15
16#include <stdbool.h>
17
18#include "cdi_core_api.h"
19
20//*********************************************************************************************************************
21//***************************************** START OF DEFINITIONS AND TYPES ********************************************
22//*********************************************************************************************************************
23
25#define OPTARG_MAX_OPTION_ARGS (20)
26
28#define OPTARG_MAX_OPTION_LENGTH (16)
29
31#define OPTARG_MAX_SHORT_OPTION_LENGTH (5)
32
34#define OPTARG_MAX_ARG_STR_LENGTH (16)
35
37#define OPTARG_MAX_DESCRIPTION_STRING_LEN (800)
38
40#define OPTARG_MAX_IP_STRING_LEN (20)
41
43#define OPTARG_OPTION_ARRAY_MAX_CHAR_LEN (400)
44
46#define OPTARG_USAGE_DESCRIPTION_INDENT (1 + OPTARG_MAX_SHORT_OPTION_LENGTH + 5 + OPTARG_MAX_OPTION_LENGTH + 1 + OPTARG_MAX_ARG_STR_LENGTH + 3)
47
49#define OPTARG_AVM_USAGE_LIST_INDENT (29)
50
55typedef struct
56{
58 const char* short_name_str;
60 const char* long_name_str;
64 const char* argument_str;
68 const char* description_str;
69} OptDef;
70
74typedef struct
75{
79 char short_name_str[OPTARG_MAX_SHORT_OPTION_LENGTH];
83 const char* args_array[OPTARG_MAX_OPTION_ARGS];
84} OptArg;
85
86//*********************************************************************************************************************
87//******************************************* START OF PUBLIC FUNCTIONS ***********************************************
88//*********************************************************************************************************************
95void PrintKeyArrayNames(const CdiEnumStringKey* key_array, const int indent);
96
102void PrintOption(const OptDef* option_ptr);
103
110void PrintUsage(const OptDef* opt_array_ptr, bool has_error);
111
128bool GetOpt(int argc, const char* argv_ptr[], int* index_ptr, OptDef* opt_array_ptr, OptArg* this_opt_ptr);
129
130#endif // CDI_OPTARG_H__
This file declares the public API data types, structures and functions that comprise the CDI low-leve...
static void PrintUsage()
Print usage message.
Definition dump_riff.c:53
void PrintOption(const OptDef *option_ptr)
Definition optarg.c:302
#define OPTARG_MAX_SHORT_OPTION_LENGTH
The maximum length of any short option string.
Definition optarg.h:31
bool GetOpt(int argc, const char *argv_ptr[], int *index_ptr, OptDef *opt_array_ptr, OptArg *this_opt_ptr)
Definition optarg.c:387
#define OPTARG_MAX_OPTION_ARGS
The maximum number of arguments allowed for any command line option.
Definition optarg.h:25
void PrintKeyArrayNames(const CdiEnumStringKey *key_array, const int indent)
Definition optarg.c:223
Type used for holding arrays of enums and related string representations.
Definition cdi_utility_api.h:46
A structure that describes a single command line option and its associated arguments.
Definition optarg.h:75
int num_args
The number of arguments discovered for the option.
Definition optarg.h:81
int option_index
The index of this option.
Definition optarg.h:77
A structure that is used by the user to define a single option. An array of these option structs is p...
Definition optarg.h:56
const CdiEnumStringKey * arg_choices_array_ptr
Pointer to array of strings of option argument choices.
Definition optarg.h:66
const char * argument_str
A string that describes the arguments to the option.
Definition optarg.h:64
int num_args
The number of expected arguments for the option.
Definition optarg.h:62
const char * short_name_str
The short multi-character short name of the option (short opt).
Definition optarg.h:58
const char * description_str
A string that describes the function of the option. Max length is OPTARG_MAX_DESCRIPTION_STRING_LEN.
Definition optarg.h:68
const char * long_name_str
The multiple-character long name of the option (long opt).
Definition optarg.h:60