]> git.dkaiser.de - 42/push_swap.git/commitdiff
Add command handling to makefile and setup main
authorDominik Kaiser <dkaiser@2-E-4.42heilbronn.de>
Sat, 13 Apr 2024 12:52:57 +0000 (14:52 +0200)
committerDominik Kaiser <dkaiser@2-E-4.42heilbronn.de>
Sat, 13 Apr 2024 12:52:57 +0000 (14:52 +0200)
Makefile
command_handling.c
main.c
push_swap.h

index 5edb601302d2e7a6930dbb1ee2461501d2fec4a7..9a704a1d8128346f48da90a897090de70d1d74cb 100644 (file)
--- 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)
index e25f47c5a629b76d717ba626d6b6c83990a98284..b1fe85a08c2ed995e4016461079ebeb075f5f55c 100644 (file)
@@ -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 e9a96e1999af887dc9d9df431020bac1faa316c3..fcb75fce158f6b144121e60a8ba4e6d1df8713bd 100644 (file)
--- 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;
 }
index 332da4eaa069014f68b9cae3a5a54989cc38b1c5..8cfc473adc60d10409257e25cc6b70314ca261e0 100644 (file)
@@ -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