-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcli.h
More file actions
47 lines (40 loc) · 1023 Bytes
/
cli.h
File metadata and controls
47 lines (40 loc) · 1023 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#ifndef CLI_H
#define CLI_H
#include "context.h"
typedef struct {
int json;
int xml;
int group;
int eval;
const char *filename;
char *expr;
} CLIOptions;
//The enum ORDER is very important!
//modify carefully
typedef enum {
S_START, // Initial state
S_FORMAT, // After -json or -xml
S_EVAL, // After -eval
S_GROUP, // After -g/-group (requires format or eval)
S_FILE, // After -f (terminal for options)
S_EXPR, // Expression parsing (terminal)
S_ERROR // Error state
} State;
// Token type identification
typedef enum {
TOK_FORMAT,
TOK_EVAL,
TOK_GROUP,
TOK_FILE,
TOK_EXPR,
TOK_UNKNOWN
} TokenType;
typedef struct {
State state;
int arg_pos;
char error[256];
} CLIParser;
CLIOptions parse_cli(int argc, char **argv);
void process_expressions(CLIOptions *opts, CtxNode *ctx);
int process_expressions_count(CLIOptions *opts, CtxNode *ctx);
#endif