summaryrefslogtreecommitdiff
path: root/command_handling.c
diff options
context:
space:
mode:
authorDominik Kaiser2024-04-12 20:51:04 +0200
committerDominik Kaiser2024-04-12 20:51:04 +0200
commit925c50a9b094f6d244b621c8750d5ecf0caa38a1 (patch)
tree405616d0682be11b48bacb9a773b47da86f755ef /command_handling.c
parent9c64c9d253fa22b29005ec53dca6fedcead2ae6c (diff)
downloadpush_swap-925c50a9b094f6d244b621c8750d5ecf0caa38a1.tar.gz
push_swap-925c50a9b094f6d244b621c8750d5ecf0caa38a1.zip
Add error handling and create base for commands
Diffstat (limited to 'command_handling.c')
-rw-r--r--command_handling.c48
1 files changed, 48 insertions, 0 deletions
diff --git a/command_handling.c b/command_handling.c
new file mode 100644
index 0000000..484c858
--- /dev/null
+++ b/command_handling.c
@@ -0,0 +1,48 @@
+#include "libft/libft.h"
+#include "push_swap.h"
+
+static int add_cmd_to_queue(t_list **cmds, enum e_pscmd cmd)
+{
+ t_list *new_elem;
+ enum e_pscmd *ptr_cmd;
+
+ ptr_cmd = malloc(sizeof(enum e_pscmd));
+ if (!ptr_cmd)
+ return 1;
+
+ new_elem = ft_lstnew(ptr_cmd);
+ if (!new_elem)
+ {
+ free(ptr_cmd);
+ return 1;
+ }
+ ft_lstadd_back(cmds, new_elem);
+ return 0;
+}
+
+void run_command(t_list **stack_a, t_list **stack_b, t_list **cmds, enum e_pscmd cmd)
+{
+ if (cmd == SA)
+ ;
+ else if (cmd == SB)
+ ;
+ else if (cmd == SS)
+ ;
+ else if (cmd == PA)
+ ;
+ else if (cmd == PB)
+ ;
+ else if (cmd == RA)
+ ;
+ else if (cmd == RB)
+ ;
+ else if (cmd == RR)
+ ;
+ else if (cmd == RRA)
+ ;
+ else if (cmd == RRB)
+ ;
+ else if (cmd == RRR)
+ ;
+ add_cmd_to_queue(cmds, cmd);
+}