back to scratko.xyz
summaryrefslogtreecommitdiff
path: root/queue.c
diff options
context:
space:
mode:
authorscratko <m@scratko.xyz>2024-05-25 21:36:07 +0300
committerscratko <m@scratko.xyz>2024-05-25 22:05:47 +0300
commitfb322edd72bebddee1a9828baec2f8bc83666ddf (patch)
treefab49e1e88ab1b3b20a45aba354b85b5fdafeff4 /queue.c
parentc1e5cffb43977f5a2f8d9623e40c01dab6d80c46 (diff)
downloadshell-fb322edd72bebddee1a9828baec2f8bc83666ddf.tar.gz
shell-fb322edd72bebddee1a9828baec2f8bc83666ddf.tar.bz2
shell-fb322edd72bebddee1a9828baec2f8bc83666ddf.zip
Shell-II releaseshell-II
Implementation of launching external programs via fork(). Running cd as a change to the current process directory (chdir). Ability to change to user's home directory (cd without arguments).
Diffstat (limited to 'queue.c')
-rw-r--r--queue.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/queue.c b/queue.c
index 861f1e5..eed3cf8 100644
--- a/queue.c
+++ b/queue.c
@@ -33,6 +33,7 @@ void queue_clear(struct queue *q)
q->last = NULL;
}
+#if 0
void queue_processing(const struct queue *q, void (*callback)(char*))
{
struct word_item *tmp;
@@ -42,3 +43,22 @@ void queue_processing(const struct queue *q, void (*callback)(char*))
tmp = tmp->next;
}
}
+#endif
+
+int queue_get_word_count(const struct queue *q)
+{
+ struct word_item *tmp;
+ int counter;
+ for(counter = 0, tmp = q->first; tmp; tmp = tmp->next, ++counter)
+ {}
+ return counter;
+}
+
+void queue_copy_words_to_args(const struct queue *q, char **cmdline)
+{
+ struct word_item *tmp;
+ int mas_idx;
+ for(tmp = q->first, mas_idx = 0; tmp; tmp = tmp->next, ++mas_idx)
+ cmdline[mas_idx] = tmp->word;
+ cmdline[mas_idx] = NULL;
+}