From 4fcb1ec318d74a454f6cfbefe018f35bbb32d6bf Mon Sep 17 00:00:00 2001 From: Thomas Voss Date: Thu, 3 Oct 2024 23:11:23 +0200 Subject: Typedef enums and structures --- include/cli.h | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) (limited to 'include') diff --git a/include/cli.h b/include/cli.h index 970b228..8efa2d0 100644 --- a/include/cli.h +++ b/include/cli.h @@ -7,7 +7,7 @@ #include "_rune.h" #include "_uNview.h" -struct optparser { +typedef struct { bool _b; int _subopt; char **_argv; @@ -15,28 +15,27 @@ struct optparser { int optind; char errmsg[128]; u8view_t optarg; -}; +} optparser_t; -enum cliarg { +typedef enum { CLI_NONE, CLI_OPT, CLI_REQ, -}; +} cli_opt_kind_t; -struct cli_option { +typedef struct { rune shortopt; u8view_t longopt; - enum cliarg argtype; -}; + cli_opt_kind_t argtype; +} cli_opt_t; -[[nodiscard]] rune optparse(struct optparser *, const struct cli_option *, - size_t); +[[nodiscard]] rune optparse(optparser_t *, const cli_opt_t *, size_t); [[_mlib_inline]] -static inline struct optparser +static inline optparser_t mkoptparser(char **argv) { - return (struct optparser){ + return (optparser_t){ ._argv = argv, .optind = argv[0] != nullptr, }; -- cgit v1.2.3