Initial import.

This commit is contained in:
@@@No user configured@@@ 2016-05-15 22:56:38 +02:00
commit bb3bf1fe53
3 changed files with 53 additions and 0 deletions

20
Makefile Normal file
View file

@ -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

BIN
exercice Normal file

Binary file not shown.

33
src/exercice.c Normal file
View file

@ -0,0 +1,33 @@
#include <stdio.h>
#include <string.h>
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;
}