commit bb3bf1fe53e8c6634814d5dea36455c90b6e8e59 Author: @@@No user configured@@@ <@@@No user configured@@@> Date: Sun May 15 22:56:38 2016 +0200 Initial import. diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..71bb07e --- /dev/null +++ b/Makefile @@ -0,0 +1,20 @@ + +SRC = $(wildcard src/*.c) +DEPS = $(wildcard deps/**/*.c) +OBJS = $(DEPS:.c=.o) + +CFLAGS = -std=c99 -Ideps -Wall -Wno-unused-function -U__STRICT_ANSI__ +BINS = exercice + + +all: $(BINS) + +$(BINS): $(SRC) $(OBJS) + $(CC) $(CFLAGS) -o $@ src/$(@:.exe=).c $(OBJS) $(LDFLAGS) + +%.o: %.c + $(CC) $< -c -o $@ $(CFLAGS) + +clean: + $(foreach c, $(BINS), rm $(c);) + rm $(OBJS) src/*.o diff --git a/exercice b/exercice new file mode 100644 index 0000000..15b370d Binary files /dev/null and b/exercice differ diff --git a/src/exercice.c b/src/exercice.c new file mode 100644 index 0000000..4bef677 --- /dev/null +++ b/src/exercice.c @@ -0,0 +1,33 @@ +#include +#include + +typedef struct arg_opt { + char * name; + void * fn; +} Arg_opt; + +Arg_opt options[1] = {{"toto", NULL}}; + +int main(int argc, char ** argv) { + int arg_idx = argc; + int opt_idx; + char * txt; + char * arg; + + + while(arg_idx > 0) { + printf("arg_idx=%d\n", arg_idx); + arg = argv[arg_idx-1]; + opt_idx = sizeof(options) / sizeof(options[0]); + while (opt_idx > 0) { + printf("opt_idx=%d\n", opt_idx); + txt = options[opt_idx-1].name; + if (strcmp(txt, arg)==0) { + printf("[+] %s\n", arg); + } + opt_idx--; + } + arg_idx--; + } + return 0; +}