Simplify option definition with som handy macros
This commit is contained in:
@@ -24,12 +24,20 @@
|
|||||||
|
|
||||||
#define IS_CMD(x,c) (strncmp((x),(c),(LEN_CMD_MAX)) == 0)
|
#define IS_CMD(x,c) (strncmp((x),(c),(LEN_CMD_MAX)) == 0)
|
||||||
|
|
||||||
|
#define GETOPT_HELP GETOPT_FLAG( OPT_HELP, 'h' )
|
||||||
|
#define GETOPT_ADDR GETOPT_ARG( OPT_ADDR, 'l' )
|
||||||
|
#define GETOPT_PORT GETOPT_ARG( OPT_PORT, 'p' )
|
||||||
|
#define GETOPT_FILE GETOPT_ARG( OPT_FILE, 'f' )
|
||||||
|
#define GETOPT_SOCK GETOPT_ARG( OPT_SOCK, 's' )
|
||||||
|
#define GETOPT_FROM GETOPT_ARG( OPT_FROM, 'F' )
|
||||||
|
#define GETOPT_SIZE GETOPT_ARG( OPT_SIZE, 'S' )
|
||||||
|
|
||||||
static struct option serve_options[] = {
|
static struct option serve_options[] = {
|
||||||
GETOPT_FLAG( OPT_HELP, 'h' ),
|
GETOPT_HELP,
|
||||||
GETOPT_ARG( OPT_ADDR, 'l' ),
|
GETOPT_ADDR,
|
||||||
GETOPT_ARG( OPT_PORT, 'p' ),
|
GETOPT_PORT,
|
||||||
GETOPT_ARG( OPT_FILE, 'f' ),
|
GETOPT_FILE,
|
||||||
GETOPT_ARG( OPT_SOCK, 's' ),
|
GETOPT_SOCK,
|
||||||
{0}
|
{0}
|
||||||
};
|
};
|
||||||
static char serve_short_options[] = "hl:p:f:s:";
|
static char serve_short_options[] = "hl:p:f:s:";
|
||||||
@@ -43,12 +51,12 @@ static char serve_help_text[] =
|
|||||||
"\t--" OPT_SOCK ",-s <SOCK>\tPath to the control socket to open.\n";
|
"\t--" OPT_SOCK ",-s <SOCK>\tPath to the control socket to open.\n";
|
||||||
|
|
||||||
static struct option read_options[] = {
|
static struct option read_options[] = {
|
||||||
GETOPT_FLAG( OPT_HELP, 'h' ),
|
GETOPT_HELP,
|
||||||
GETOPT_ARG( OPT_ADDR, 'l' ),
|
GETOPT_ADDR,
|
||||||
GETOPT_ARG( OPT_PORT, 'p' ),
|
GETOPT_PORT,
|
||||||
GETOPT_ARG( OPT_FROM, 'F' ),
|
GETOPT_FROM,
|
||||||
GETOPT_ARG( OPT_SIZE, 'S' ),
|
GETOPT_SIZE,
|
||||||
{0}
|
{0}
|
||||||
};
|
};
|
||||||
static char read_short_options[] = "hl:p:F:S:";
|
static char read_short_options[] = "hl:p:F:S:";
|
||||||
static char read_help_text[] =
|
static char read_help_text[] =
|
||||||
@@ -73,8 +81,8 @@ static char write_help_text[] =
|
|||||||
"\t--" OPT_SIZE ",-S <SIZE>\tBytes to write.\n";
|
"\t--" OPT_SIZE ",-S <SIZE>\tBytes to write.\n";
|
||||||
|
|
||||||
struct option acl_options[] = {
|
struct option acl_options[] = {
|
||||||
GETOPT_FLAG( OPT_HELP, 'h' ),
|
GETOPT_HELP,
|
||||||
GETOPT_ARG( OPT_SOCK, 's' ),
|
GETOPT_SOCK,
|
||||||
{0}
|
{0}
|
||||||
};
|
};
|
||||||
static char acl_short_options[] = "hs:";
|
static char acl_short_options[] = "hs:";
|
||||||
@@ -85,10 +93,10 @@ static char acl_help_text[] =
|
|||||||
"\t--" OPT_SOCK ",-s <SOCK>\tPath to the control socket.\n";
|
"\t--" OPT_SOCK ",-s <SOCK>\tPath to the control socket.\n";
|
||||||
|
|
||||||
struct option mirror_options[] = {
|
struct option mirror_options[] = {
|
||||||
GETOPT_FLAG( OPT_HELP, 'h' ),
|
GETOPT_HELP,
|
||||||
GETOPT_ARG( OPT_SOCK, 's' ),
|
GETOPT_SOCK,
|
||||||
GETOPT_ARG( OPT_ADDR, 'l' ),
|
GETOPT_ADDR,
|
||||||
GETOPT_ARG( OPT_PORT, 'p' ),
|
GETOPT_PORT,
|
||||||
{0}
|
{0}
|
||||||
};
|
};
|
||||||
static char mirror_short_options[] = "hs:l:p:";
|
static char mirror_short_options[] = "hs:l:p:";
|
||||||
@@ -102,8 +110,8 @@ static char mirror_help_text[] =
|
|||||||
|
|
||||||
|
|
||||||
struct option status_options[] = {
|
struct option status_options[] = {
|
||||||
GETOPT_FLAG( OPT_HELP, 'h' ),
|
GETOPT_HELP,
|
||||||
GETOPT_ARG( OPT_SOCK, 's' ),
|
GETOPT_SOCK,
|
||||||
{0}
|
{0}
|
||||||
};
|
};
|
||||||
static char status_short_options[] = "hs:";
|
static char status_short_options[] = "hs:";
|
||||||
|
Reference in New Issue
Block a user