back to scratko.xyz
summaryrefslogtreecommitdiff
path: root/queue.h
diff options
context:
space:
mode:
authorscratko <m@scratko.xyz>2024-06-12 18:52:28 +0300
committerscratko <m@scratko.xyz>2024-06-12 18:52:28 +0300
commit1ee0911f2def54f1b63d18b0924ac65c2db92f11 (patch)
tree945cf5fc2e0e3fe3095349950ff51e4b561a1f8e /queue.h
parent8bcfbe6a15f6195c3501b9bde633081da67179d1 (diff)
downloadshell-1ee0911f2def54f1b63d18b0924ac65c2db92f11.tar.gz
shell-1ee0911f2def54f1b63d18b0924ac65c2db92f11.tar.bz2
shell-1ee0911f2def54f1b63d18b0924ac65c2db92f11.zip
version shell-V with commented out code
Diffstat (limited to 'queue.h')
-rw-r--r--queue.h66
1 files changed, 57 insertions, 9 deletions
diff --git a/queue.h b/queue.h
index fedcd0b..325706e 100644
--- a/queue.h
+++ b/queue.h
@@ -1,23 +1,71 @@
#ifndef QUEUE_H_SENTRY
#define QUEUE_H_SENTRY
+#define MAKE_QUEUE_INIT(NAME) \
+ void NAME ## _init(struct NAME *q) \
+{ \
+ q->first = NULL; \
+ q->last = NULL; \
+}
+
+#define MAKE_QUEUE_PUSH(NAME, VALUE, TYPE) \
+ void NAME ## _push(struct NAME *q, TYPE VALUE) \
+{ \
+ struct VALUE ## _item *tmp = malloc(sizeof(struct VALUE ## _item)); \
+ tmp-> VALUE = VALUE; \
+ tmp->next = NULL; \
+ if(!q->first) { \
+ q->first = tmp; \
+ q->last = q->first; \
+ } else { \
+ q->last->next = tmp; \
+ q->last = q->last->next; \
+ } \
+}
+
struct word_item {
char *word;
struct word_item *next;
};
-struct queue {
+struct cmdline_item {
+ char **cmdline;
+ struct cmdline_item *next;
+};
+
+struct pid_item {
+ int pid;
+ struct pid_item *next;
+};
+
+struct w_queue {
struct word_item *first;
struct word_item *last;
};
-void queue_init(struct queue *q);
-void queue_push(struct queue *q, char *word);
-void queue_clear(struct queue *q);
-#if 0
-void queue_processing(const struct queue *q, void (*callback)(char*));
-#endif
-int queue_get_word_count(const struct queue *q);
-void queue_copy_words_to_args(const struct queue *q, char **cmdline);
+struct c_queue {
+ struct cmdline_item *first;
+ struct cmdline_item *last;
+ struct cmdline_item *last_extracted_item;
+};
+
+struct p_queue {
+ struct pid_item *first;
+ struct pid_item *last;
+};
+
+void w_queue_clear(struct w_queue *q);
+int w_queue_get_word_count(const struct w_queue *q);
+void w_queue_copy_words_to_args(const struct w_queue *q, char **cmdline);
+
+void c_queue_init(struct c_queue *q);
+void c_queue_push(struct c_queue *q, char **cmdline);
+char** c_queue_pop(struct c_queue *q);
+void c_queue_clear(struct c_queue *q);
+int c_queue_is_empty(struct c_queue *q);
+
+int p_queue_find_pid(struct p_queue *q, int pid);
+void p_queue_clear(struct p_queue *q);
+int p_queue_get_process_quantity(struct p_queue *q);
#endif