]> Untitled Git - axy/ft/pushswap.git/commitdiff
Adding args parsing in main
authorCorentin Lefrere <clefrere@k1r1p10.42mulhouse.fr>
Mon, 8 Dec 2025 09:39:02 +0000 (10:39 +0100)
committerCorentin Lefrere <clefrere@k1r1p10.42mulhouse.fr>
Mon, 8 Dec 2025 09:39:02 +0000 (10:39 +0100)
main_pushswap.c

index d0c92f35ae2529810ff7bc567a548d2fb4e9df88..b4ad9e1e2737d87826cee369db1fbb4cd15625c4 100644 (file)
@@ -3,15 +3,42 @@
 /*                                                        :::      ::::::::   */
 /*   main_pushswap.c                                    :+:      :+:    :+:   */
 /*                                                    +:+ +:+         +:+     */
-/*   By: agilliar <agilliar@student.42mulhouse.fr>  +#+  +:+       +#+        */
+/*   By: clefrere <clefrere@student.42.fr>          +#+  +:+       +#+        */
 /*                                                +#+#+#+#+#+   +#+           */
 /*   Created: 2025/12/02 22:15:12 by agilliar          #+#    #+#             */
-/*   Updated: 2025/12/03 15:19:10 by agilliar         ###   ########.fr       */
+/*   Updated: 2025/12/08 10:38:21 by clefrere         ###   ########.fr       */
 /*                                                                            */
 /* ************************************************************************** */
 
 #include "pushswap.h"
 
+static bool    ft_streq(char *str1, char *str2)
+{
+       size_t  i;
+
+       i = 0;
+       while (str1[i] && str2[i] && str1[i] == str2[i])
+               i++;
+       return (str1[i] == '\0' && str2[i] == '\0');
+}
+
+
+static void    arg_step(char *str, t_args *arg)
+{
+       if (ft_streq(str, "--simple"))
+               arg->algo = NULL;
+       else if (ft_streq(str, "--medium"))
+               arg->algo = NULL;
+       else if (ft_streq(str, "--complex"))
+               arg->algo = NULL;
+       else if (ft_streq(str, "--adaptive"))
+               arg->algo = NULL;
+       else if (ft_streq(str, "--bench"))
+               arg->bench = true;
+       else
+               stack_push_back(&arg->state.a, psval_parse(str));
+}
+
 static void    algorithm(const t_stacks *stacks, t_closure clos)
 {
        (void) stacks;