feat(parsing/sources): adding the sources for help

This commit is contained in:
Raphael 2026-03-28 15:39:43 +01:00
parent 9349d485df
commit 0d28235c3e
No known key found for this signature in database

29
parsing/sources/help.c Normal file
View file

@ -0,0 +1,29 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* help.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2026/03/28 12:38:44 by rparodi #+# #+# */
/* Updated: 2026/03/28 15:23:53 by rparodi ### ########.fr */
/* */
/* ************************************************************************** */
#include <ctype.h>
#include <stddef.h>
#include <stdio.h>
#include "parsing.h"
void print_help(size_t size) {
dprintf(2, "Usage: ./ft_ping [OPTION...] HOST ...\nSend ICMP ECHO_REQUEST packets to network hosts.\n\n");
dprintf(2, "Options:\n");
for (size_t i = 0; i < size; i++)
if (_flags[i].is_mandatory != false || BONUS == 1) {
if (isprint(_flags[i].short_option))
dprintf(2, "\t-%c, --%-15s%-15s%-15s\n", _flags[i].short_option, (_flags[i].long_option ? _flags[i].long_option : ""), (_flags[i].usage ? _flags[i].usage : ""), _flags[i].description);
else
dprintf(2, "\t --%-15s%-15s%-15s\n", (_flags[i].long_option ? _flags[i].long_option : ""), (_flags[i].usage ? _flags[i].usage : ""), _flags[i].description);
}
}