commit 7cd340ef2d43ac87ef4451c985ab72d37ff310c2
parent 7d20b407d5adaf66abf69a8c987eb4a98cd14325
Author: klewer-martin <martin.cachari@gmail.com>
Date: Sat, 10 Jul 2021 03:07:30 -0300
Added inlude folder with all the header files, and funcition validate_arguments is working properly
Diffstat:
13 files changed, 112 insertions(+), 47 deletions(-)
diff --git a/Makefile b/Makefile
@@ -1,14 +1,22 @@
CC=gcc
CFLAGS=-std=c99 -pedantic -Wall
SRCFOLDER=source
+HFOLDER=include
+PROGNAME=main
-all: main
+all: main clean
-main: main.o cla.o
- $(CC) $(CFLAGS) main.o cla.o
+main: main.o cla.o errors.o
+ $(CC) $(CFLAGS) main.o cla.o errors.o -o $(PROGNAME)
-main.o:
- $(CC) $(CFLAGS) -c $(SRCFOLDER)/main.c
+main.o: $(HFOLDER)/cla.h $(HFOLDER)/errors.h
+ $(CC) $(CFLAGS) -c $(SRCFOLDER)/main.c
-cla.o:
+cla.o: $(HFOLDER)/cla.h $(HFOLDER)/types.h
$(CC) $(CFLAGS) -c $(SRCFOLDER)/cla.c
+
+errors.o: $(HFOLDER)/types.h
+ $(CC) $(CFLAGS) -c $(SRCFOLDER)/errors.c
+
+clean:
+ rm *.o
diff --git a/include/cla.h b/include/cla.h
@@ -0,0 +1,23 @@
+#ifndef CLA__H
+#define CLA__H
+
+#include <string.h>
+#include <stdbool.h>
+
+#include "types.h"
+
+#define NO_ARGS_ENTERED 1
+#define NORMAL_AMOUNT_ARGS 11
+#define FLAGS_MAX 5
+#define FORMATS_MAX 2
+
+status_t validate_arguments(int argc, char **argv);
+status_t check_flags_position(int argc, char **argv);
+status_t check_flags_repeated(int argc, char **argv);
+
+status_t get_flags_values(int argc, char **argv);
+
+extern const char *available_flags[FLAGS_MAX];
+extern const char *available_formats[FORMATS_MAX];
+
+#endif
diff --git a/include/errors.h b/include/errors.h
@@ -0,0 +1,12 @@
+#ifndef ERRROS__H
+#define ERRORS__H
+
+#include <stdio.h>
+
+#include "types.h"
+
+void show_status(status_t st);
+
+extern const char *status_strings[STATUS_T_MAX];
+
+#endif
diff --git a/source/io.h b/include/io.h
diff --git a/source/parse.h b/include/parse.h
diff --git a/source/sort.h b/include/sort.h
diff --git a/include/types.h b/include/types.h
@@ -0,0 +1,15 @@
+#ifndef TYPES__H
+#define TYPES__H
+
+#define STATUS_T_MAX 6
+
+typedef enum {
+ OK,
+ ERROR_MISSING_ARGS,
+ ERROR_WRONG_FLAGS,
+ ERROR_FLAG_NOT_FOUND,
+ ERROR_FLAG_REPEATED,
+ ERROR_NULL_POINTER
+} status_t;
+
+#endif
diff --git a/source/cla.c b/source/cla.c
@@ -1,7 +1,7 @@
-#include "cla.h"
-#include "types.h"
+#include "../include/cla.h"
-#include <stdio.h>
+const char *available_flags[] = { "-fmt", "-out", "-in", "-ti", "-tf" };
+const char *available_formats[] = { "csv", "xml" };
status_t validate_arguments(int argc, char **argv)
{
@@ -12,8 +12,7 @@ status_t validate_arguments(int argc, char **argv)
return ERROR_MISSING_ARGS;
if((st = check_flags_position(argc, argv))) return st;
-
- if((st = check_flags_repeated(argc, argv))) return st;
+ if((st = check_flags_repeated(argc, argv))) return st;
return OK;
}
@@ -55,4 +54,3 @@ status_t check_flags_repeated(int argc, char **argv)
}
return OK;
}
-
diff --git a/source/cla.h b/source/cla.h
@@ -1,19 +0,0 @@
-#ifndef CLA__H
-#define CLA__H
-
-#include <stdbool.h>
-#include <string.h>
-
-#include "types.h"
-
-#define NO_ARGS_ENTERED 1
-#define NORMAL_AMOUNT_ARGS 11
-#define FLAGS_MAX 5
-
-status_t validate_arguments(int argc, char **argv);
-status_t check_flags_position(int argc, char **argv);
-status_t check_flags_repeated(int argc, char **argv);
-
-static const char *available_flags[FLAGS_MAX + 1] = { "-fmt", "-out", "-in", "-ti", "-tf" };
-
-#endif
diff --git a/source/errors.c b/source/errors.c
@@ -0,0 +1,15 @@
+#include "../include/errors.h"
+
+const char *status_strings[] = {
+ "Everything executed succesfully. Have a nice day.",
+ "There are arguments missing",
+ "There is a flags misspeled",
+ "ERROR_FLAG_NOT_FOUND_",
+ "ERROR_FLAG_REPEATED_",
+ "ERROR_NULL_POINTER_"
+};
+
+void show_status(status_t st)
+{
+ fprintf(stderr, "%s\n", status_strings[st]);
+}
diff --git a/source/main.c b/source/main.c
@@ -1,10 +1,36 @@
-#include "cla.h"
+#include "../include/cla.h"
+#include "../include/errors.h"
+
+typedef struct {
+ int id, credit, debt;
+} user_t, *user;
+
+typedef struct {
+ char *fmt, *fi, fo;
+ unsigned long ti, tf;
+} cla_t, *cla;
+
+/* user_create */
+/* user_destroy */
+/* user_assign_amount */
+/* user_get_amount */
int main (int argc, char *argv[])
{
status_t st;
- if((st = validate_arguments(argc, argv)) != OK) return st;
+ if((st = validate_arguments(argc, argv)) != OK) {
+ show_status(st);
+ return st;
+ }
+
+ /* parse_arguments(argc, argv); */
+
+ /* get_argument(argc, argv); */
+ /* if((st = parse_file())) { */
+ /* show_error(st); */
+ /* return st; */
+ /* } */
- return 0;
+ return OK;
}
diff --git a/source/types.c b/source/types.c
diff --git a/source/types.h b/source/types.h
@@ -1,13 +0,0 @@
-#ifndef TYPES__H
-#define TYPES__H
-
-typedef enum {
- OK,
- ERROR_MISSING_ARGS,
- ERROR_WRONG_FLAGS,
- ERROR_FLAG_NOT_FOUND,
- ERROR_FLAG_REPEATED,
- ERROR_NULL_POINTER
-} status_t;
-
-#endif