builder

package builder
Log | Files | Refs | Submodules | README | LICENSE | git clone https://git.ne02ptzero.me/git/builder

commit 50e176598f7e1f950b4f34dc80f2abee0bde68a3
parent 865c58ebbfbd4936d0ff091d4f0e5535af8add3a
Author: enerdhil <enerdhil@bob.lan>
Date:   Sat, 21 Jan 2017 18:05:30 +0100

Add(main)

Diffstat:
MMakefile | 2+-
Abuilder | 0
Ainc/builder.h | 23+++++++++++++++++++++++
Msrc/main.c | 43++++++++++++++++++++++++++++++++++++++-----
4 files changed, 62 insertions(+), 6 deletions(-)

diff --git a/Makefile b/Makefile @@ -24,7 +24,7 @@ CFLAGS = -Wall -Wextra -Werror -Wno-unused-result \ LFLAGS = -lmorphux SRCS = $(wildcard src/*.c) OBJS = $(SRCS:%.c=%.o) -VERSION = +VERSION = 0.0.0.0 MAINTAINER = Jules HEZARD <hezardj@gmail.com> all: $(NAME) diff --git a/builder b/builder Binary files differ. diff --git a/inc/builder.h b/inc/builder.h @@ -0,0 +1,23 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* builder.h :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: jhezard <jhezard@student.42.fr> +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2017/01/21 17:43:23 by jhezard #+# #+# */ +/* Updated: 2017/01/21 17:54:39 by jhezard ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#ifndef BUILDER_H +# define BUILDER_H + +# include <morphux.h> + +typedef struct s_opts { + bool force; + char *str; +} opts_t; + +#endif /* BUILDER_H */ diff --git a/src/main.c b/src/main.c @@ -6,16 +6,49 @@ /* By: jhezard <jhezard@student.42.fr> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/01/21 17:04:29 by jhezard #+# #+# */ -/* Updated: 2017/01/21 17:09:56 by jhezard ### ########.fr */ +/* Updated: 2017/01/21 18:04:29 by jhezard ### ########.fr */ /* */ /* ************************************************************************** */ -#include <morphux.h> +#include <builder.h> + +void force(const char *str) { + m_info("%s\n", str); +} + +int list_opt_free(void *tofree) { + opts_t *tmp = tofree; + if (tofree) + free(tmp->str); + return 0; +} + +int main(int ac, char *av[]) { + margs_t opts[] = { + {'f', "force", "Do not launch the program as a daemon.", false, &force}, + ARGS_EOL + }; + opts_t *opts2; + opts_t *opts_tmp = NULL; + mlist_t *opt_lst = NULL; + mlist_t *tmp_lst = NULL; -int main(int ac, const char *av[]) { - (void)ac; - (void)av; set_program_name(NAME); set_version(VERSION); set_maintainer(MAINTAINER); + read_opt(ac, av, opts); + + opts2 = malloc(sizeof(opts_t)); + + opts2->force = true; + opts2->str = strdup("toto"); + list_add(opt_lst, &opts2, sizeof(opts2)); + free(opts2); + + m_info("lstsize : %d\n", list_size(opt_lst)); + + list_for_each(opt_lst, tmp_lst, opts_tmp) { + m_info("bool : %d|%s\n", opts_tmp->force, opts_tmp->str); + } + list_free(opt_lst, &list_opt_free); return 0; }