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
|
#ifndef LEXICAL_ANALYSIS_H_SENTRY
#define LEXICAL_ANALYSIS_H_SENTRY
#include "queue.h"
#include "dynamic_array.h"
#include <stdio.h>
#include <stdlib.h>
enum {
new_line = 10,
whitespace = ' ',
tab = 9,
backslash = '\\',
double_quotes = '"'
};
/* two-letter tokens */
enum {
append = '>' + 1,
and = '&' + 1,
or = '|' + 1
};
/* storing file names to redirect standard input/output streams */
struct io_type {
char *input_stream;
char *output_stream;
char *output_stream_to_append;
};
struct param_type {
int is_word;
int escape_sequences;
unsigned int double_quotes_counter;
char stored_symbol;
int empty_word_flag;
int tokens;
int wrong_command;
struct io_type streams;
int last_execution_status;
int pipeline;
};
int filename_waiting(struct param_type *params);
void add_filename(struct dynamic_array *tmp_word, struct param_type *params);
void add_word(struct w_queue *word_chain, struct dynamic_array *tmp_word,
struct param_type *params);
int is_stream_redirection_set(const struct param_type *params);
char** create_cmdline(const struct w_queue *word_chain, int word_counter);
int is_double_quotes_pair(struct param_type params);
int escape_double_quotes_or_backslash(int ch, struct param_type params);
int double_quotes_again(int ch, struct param_type params);
int check_separation(int ch, struct param_type params);
int ignore_spaces(int ch, struct param_type params);
int change_mode(int ch, struct param_type params);
int start_escape_sequence(int ch, struct param_type params);
int is_empty_word(int ch, struct param_type params);
int command_execution_condition(struct param_type *params);
int is_special_token(int ch);
int is_redirect_token(int ch, int next_ch);
int excessive_words(int ch, struct param_type *params);
void add_word_or_filename(struct w_queue *word_chain,
struct dynamic_array *tmp_word,
struct param_type *params);
int validate_redirections(int ch, int next_ch, struct param_type *params);
int is_double_token(struct param_type *params);
int stream_redirect_tokens(struct w_queue *word_chain,
struct dynamic_array *tmp_word,
int ch, struct param_type *params);
int double_quotes_again(int ch, struct param_type params);
int pipeline_token_processing(struct w_queue *word_chain,
struct c_queue *cmdlines,
struct dynamic_array *tmp_word,
struct param_type *params);
int special_tokens(struct w_queue *word_chain, struct c_queue *cmdlines,
struct dynamic_array *tmp_word, int ch,
struct param_type *params);
#endif
|