summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDominik Kaiser2024-04-13 14:52:57 +0200
committerDominik Kaiser2024-04-13 14:52:57 +0200
commitabc12d29679ae6049c9cacbf09a897529377d79c (patch)
tree5b82dec8bfb4332652ced35a44653ddc22c7aa89
parent2cef393801e18d68c762e293b5cef1194f77e078 (diff)
downloadpush_swap-abc12d29679ae6049c9cacbf09a897529377d79c.tar.gz
push_swap-abc12d29679ae6049c9cacbf09a897529377d79c.zip
Add command handling to makefile and setup main
-rw-r--r--Makefile2
-rw-r--r--command_handling.c4
-rw-r--r--main.c13
-rw-r--r--push_swap.h4
4 files changed, 11 insertions, 12 deletions
diff --git a/Makefile b/Makefile
index 5edb601..9a704a1 100644
--- a/Makefile
+++ b/Makefile
@@ -5,7 +5,7 @@ LIBFT = libft
CC = cc
CFLAGS = -Wall -Wextra -Werror
-SRC_FILES = main.c input_handling.c
+SRC_FILES = main.c input_handling.c stack_utils.c command_handling.c
OBJ_FILES = $(SRC_FILES:%.c=%.o)
LIB_DIR = $(LIBFT)
diff --git a/command_handling.c b/command_handling.c
index e25f47c..b1fe85a 100644
--- a/command_handling.c
+++ b/command_handling.c
@@ -6,11 +6,10 @@
/* By: dkaiser <dkaiser@student.42heilbronn.de +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/04/13 14:38:47 by dkaiser #+# #+# */
-/* Updated: 2024/04/13 14:43:45 by dkaiser ### ########.fr */
+/* Updated: 2024/04/13 14:47:55 by dkaiser ### ########.fr */
/* */
/* ************************************************************************** */
-#include "libft/libft.h"
#include "push_swap.h"
static int add_cmd_to_queue(t_list **cmds, enum e_pscmd cmd)
@@ -21,6 +20,7 @@ static int add_cmd_to_queue(t_list **cmds, enum e_pscmd cmd)
ptr_cmd = malloc(sizeof(enum e_pscmd));
if (!ptr_cmd)
return (1);
+ *ptr_cmd = cmd;
new_elem = ft_lstnew(ptr_cmd);
if (!new_elem)
{
diff --git a/main.c b/main.c
index e9a96e1..fcb75fc 100644
--- a/main.c
+++ b/main.c
@@ -6,11 +6,10 @@
/* By: dkaiser <dkaiser@student.42heilbronn.de +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/04/12 17:03:30 by dkaiser #+# #+# */
-/* Updated: 2024/04/12 18:55:38 by dkaiser ### ########.fr */
+/* Updated: 2024/04/13 14:52:31 by dkaiser ### ########.fr */
/* */
/* ************************************************************************** */
-#include "libft/libft.h"
#include "push_swap.h"
static void print_content(void *content)
@@ -21,6 +20,8 @@ static void print_content(void *content)
int main(int argc, char *argv[])
{
t_list *stack_a;
+ t_list *stack_b;
+ t_list *pscmds;
stack_a = create_stack(argc, argv);
if (!stack_a)
@@ -28,12 +29,10 @@ int main(int argc, char *argv[])
ft_putendl_fd("Error", 2);
return 1;
}
+ stack_b = NULL;
+ pscmds = NULL;
- ft_lstiter(stack_a, print_content);
-
- // TODO: Sort stack
// TODO: Optimize commands
- // TODO: Print commands
-
+ print_commands(pscmds);
return 0;
}
diff --git a/push_swap.h b/push_swap.h
index 332da4e..8cfc473 100644
--- a/push_swap.h
+++ b/push_swap.h
@@ -6,7 +6,7 @@
/* By: dkaiser <dkaiser@student.42heilbronn.de +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/04/12 16:59:09 by dkaiser #+# #+# */
-/* Updated: 2024/04/13 14:45:16 by dkaiser ### ########.fr */
+/* Updated: 2024/04/13 14:46:45 by dkaiser ### ########.fr */
/* */
/* ************************************************************************** */
@@ -39,6 +39,6 @@ void stack_rrotate(t_list **stack);
void run_command(t_list **stack_a, t_list **stack_b, t_list **cmds,
enum e_pscmd cmd);
-void print_commands(t_list *cmds)
+void print_commands(t_list *cmds);
#endif // PUSH_SWAP_H