HW_Lib/lib/utils/inc/argpase.h

46 lines
844 B
C
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

#ifndef ARGPASE_H
#define ARGPASE_H
#ifdef __cplusplus
extern "C" {
#endif
typedef char OptId;
typedef struct Option {
char *name;
OptId id;
} Option;
typedef struct OptList {
struct OptList *next;
Option *Option;
} OptList;
extern char *Optarg, *Optstr;
//索引指示可手动重载为0
extern int Optindex;
//选项链表创建
OptList *Options_Creat(char *opt, OptId index);
//使用选项结构体创建
OptList *Options_CreatOpt(Option *opt);
//添加
void Options_Add(OptList *opts, OptList *opt);
//删除
bool Options_Del(OptList *opts, char *opt);
//打印选项和id
void Options_Print(OptList *opts);
//开始匹配参数
OptId Options_Load(OptList *opts, char *argv[], size_t argc);
//字符串转参数数组
size_t Str_To_Args(char *str, char *argv[]);
#ifdef __cplusplus
}
#endif
#endif //ARGPASE_H