-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_parse_options.h
66 lines (55 loc) · 1.74 KB
/
ft_parse_options.h
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_parse_options.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: laranda <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/04/10 16:58:43 by laranda #+# #+# */
/* Updated: 2019/04/11 16:28:50 by laranda ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef FT_PARSE_OPTIONS_H
# define FT_PARSE_OPTIONS_H
# ifdef DEV
# define D(x) x
# else
# define D(x)
# endif
# define OPTION_SHORT_PREFIX "-"
# define OPTION_LONG_PREFIX "--"
# define END_OF_OPTION_STR "--"
typedef struct s_option t_option;
typedef struct s_parsing_context t_parsing_context;
typedef enum e_opt_type t_opt_type;
typedef enum e_arg_type t_arg_type;
enum e_arg_type
{
OPTION_SHORT,
OPTION_LONG,
OPTION_ERROR,
END_OF_OPTION,
PARAM
};
enum e_opt_type
{
OPTION_END = 0,
OPTION_BIT,
};
struct s_option
{
t_opt_type type;
char short_name;
char *long_name;
void *value;
};
struct s_parsing_context
{
int argc;
char **argv;
t_option *options;
char *usage;
void (*error_callback)(char *arg);
};
int ft_parse_options(t_parsing_context *ctxt);
#endif