1 Star 0 Fork 2

bluesubmarine/optparse

forked from RT-Thread-Mirror/optparse 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
optparse.h 1.92 KB
一键复制 编辑 原始数据 按行查看 历史
/*
* @File: optparse.h
* @Author: liu2guang
* @Date: 2018-06-20 14:52:10
*
* @LICENSE: MIT
* https://github.com/liu2guang/optparse/blob/master/LICENSE
*
* Change Logs:
* Date Author Notes
* 2018-06-20 liu2guang Adapter RT-Thread.
*/
#ifndef __OPTPARSE_H_
#define __OPTPARSE_H_
struct optparse
{
char **argv;
int permute;
int optind;
int optopt;
char *optarg;
char errmsg[64];
int subopt;
};
enum optparse_argtype
{
OPTPARSE_NONE,
OPTPARSE_REQUIRED,
OPTPARSE_OPTIONAL
};
struct optparse_long
{
const char *longname;
int shortname;
enum optparse_argtype argtype;
};
/**
* Initializes the parser state.
*/
void optparse_init(struct optparse *options, char **argv);
/**
* Read the next option in the argv array.
* @param optstring a getopt()-formatted option string.
* @return the next option character, -1 for done, or '?' for error
*
* Just like getopt(), a character followed by no colons means no
* argument. One colon means the option has a required argument. Two
* colons means the option takes an optional argument.
*/
int optparse(struct optparse *options, const char *optstring);
/**
* Handles GNU-style long options in addition to getopt() options.
* This works a lot like GNU's getopt_long(). The last option in
* longopts must be all zeros, marking the end of the array. The
* longindex argument may be NULL.
*/
int optparse_long(struct optparse *options, const struct optparse_long *longopts, int *longindex);
/**
* Used for stepping over non-option arguments.
* @return the next non-option argument, or NULL for no more arguments
*
* Argument parsing can continue with optparse() after using this
* function. That would be used to parse the options for the
* subcommand returned by optparse_arg(). This function allows you to
* ignore the value of optind.
*/
char *optparse_arg(struct optparse *options);
#endif /* __OPTPARSE_H_ */
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/lukeson/optparse.git
[email protected]:lukeson/optparse.git
lukeson
optparse
optparse
master

搜索帮助