47 lines
865 B
C
47 lines
865 B
C
#ifndef ARGPASE_H
|
||
#define ARGPASE_H
|
||
#ifdef __cplusplus
|
||
extern "C" {
|
||
#endif
|
||
#include "stdbool.h"
|
||
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
|