back to scratko.xyz
summaryrefslogtreecommitdiff
path: root/shell.h
diff options
context:
space:
mode:
authorscratko <m@scratko.xyz>2024-06-23 22:35:56 +0300
committerscratko <m@scratko.xyz>2024-06-23 23:40:20 +0300
commit821b146c54330cecba3ed2cc03a0f71ad83e540f (patch)
tree866fa9808cba7703aba4ce8c81a59c9b2eae76a8 /shell.h
parentef4604d9c146dbab1a653f66209103b74e6feb36 (diff)
downloadshell-821b146c54330cecba3ed2cc03a0f71ad83e540f.tar.gz
shell-821b146c54330cecba3ed2cc03a0f71ad83e540f.tar.bz2
shell-821b146c54330cecba3ed2cc03a0f71ad83e540f.zip
Shell-VI releaseHEADshell-VImaster
Running processes in a single pgid. Changing foreground group to the group of running processes (if readline doesn't end with &).
Diffstat (limited to 'shell.h')
-rw-r--r--shell.h65
1 files changed, 65 insertions, 0 deletions
diff --git a/shell.h b/shell.h
new file mode 100644
index 0000000..b3dd93d
--- /dev/null
+++ b/shell.h
@@ -0,0 +1,65 @@
+#ifndef SHELL_H_SENTRY
+#define SHELL_H_SENTRY
+
+#include "dynamic_array.h"
+#include "queue.h"
+
+enum {
+ /* CTRL-D */
+ end_of_file = 4,
+ new_line = 10,
+ whitespace = ' ',
+ tab = 9,
+ esc = 27,
+ backslash = '\\',
+ double_quotes = '"'
+};
+
+/* two-letter tokens */
+enum {
+ append = '>' + 1,
+ and = '&' + 1,
+ or = '|' + 1
+};
+
+/* error codes */
+enum {
+ err_filename_expected = 1,
+ err_redirect_stream_again = 2,
+ err_redirect_stream_in_pipeline = 3,
+ err_bg_process = 4,
+ err_empty_command = 5,
+ err_extra_chars_after_filename = 6,
+ err_odd_double_quotes = 7
+};
+
+/* 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 new_readline;
+ int general_pgid;
+};
+
+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);
+
+#endif