Newer
Older
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
/*
** option.h for 42sh
**
** Made by Seblu
** Login <seblu@epita.fr>
**
** Started on Tue Mar 21 18:50:03 2006 Seblu
** Last update Wed Aug 23 18:39:43 2006 Seblu
*/
#ifndef OPTION_H_
# define OPTION_H_
#define NBR_OPTION 8
#define DEBUG_OPTION 0
typedef struct s_options
{
signed char item[NBR_OPTION];
char *command;
} ts_options;
/*
** ==============
** FILE: option.c
** ==============
*/
/*!
** Create a new options structure
**
** @return A new options structure
*/
ts_options *option_init(void);
/*!
** Set a shell option
**
** @param shopt structure to apply
** @param name name of the option to set
**
** @return 0 on failure, else 1
*/
int option_set(ts_options *shopt, const char *name);
/*!
** Unset a shell option
**
** @param shopt structure to apply
** @param name name of the option to unset
**
** @return 0 on failure, else 1
*/
int option_unset(ts_options *shopt, const char *name);
/*!
** Tell if an option is set. if option nane is not set return -1
**
** @param shopt structure where find
** @param name name to find
**
** @return 0 if unset, 1 if set and -1 if not exist
*/
int option_isset(const ts_options *shopt, const char *name);
/*!
** Return a list of know opt
**
** @return list of opt
*/
const char **opt_get();
/*
** =====================
** FILE: option_parser.c
** =====================
*/
/*!
** Parse the command line
**
** @param opt shell opt structure to set with options
** @param argc program argc
** @param argv program argv
*/
void option_parser(ts_options *opt, int argc, char **argv);
#endif