commit d6f24c8d7d39038b4042f41997881a140d2b2b36
Author: klewer-martin <martin.cachari@gmail.com>
Date: Fri, 9 Jul 2021 17:06:38 -0300
First commit: Added basic files.
Diffstat:
13 files changed, 93 insertions(+), 0 deletions(-)
diff --git a/Makefile b/Makefile
diff --git a/examples/input_gen.py b/examples/input_gen.py
@@ -0,0 +1,36 @@
+from string import digits
+from time import strftime, gmtime
+from random import randint, choice
+
+LINES = 10000000
+
+# OUTPUT:
+# ID_TRANSACCION, ID_USUARIO, FECHA, MONTO, NUMERO DE TRAJETA, DESCRIPCION
+# 123412,1,05/11/2011 10:00:00,-10,4916288217067475, Compra supermercado
+
+descs = [ "Compras supermercado", "Pago tarjeta", "Compras libreria", "Pago Mecanico", "Pago Dentista", "Compras farmacia", "Ventas online", "Extraccion cajero" ]
+
+def card_number_generator():
+ return ''.join(choice(digits) for i in range(1, 16))
+
+def generate_file(max_lines):
+ id_transaction_base = 123400
+ id_user_base = 1
+ id_user_max = 2000
+ amount_base = 10
+ amount_max = 10000
+ for i in range(max_lines):
+ id_transaction = (i + id_transaction_base)
+ id_user = randint(id_user_base, id_user_max)
+ card_nr = card_number_generator()
+ date = strftime("%d/%m/%Y %H:%M:%S", gmtime(1320487200 + i))
+
+ j = randint(1, len(descs) - 1)
+ desc = descs[j]
+
+ if j > 5: amount = randint(amount_base, amount_max)
+ else: amount = randint(-amount_max, -amount_base)
+
+ print(id_transaction,id_user,date,amount,card_nr,desc, sep=',')
+
+generate_file(LINES)
diff --git a/source/cla.c b/source/cla.c
@@ -0,0 +1,20 @@
+#include "cla.h"
+#include <bool.h>
+
+status_t validate_arguments(int argc, char *argv[])
+{
+ if(argv == NULL) return ERROR_NULL_POINTER;
+ if(argc == NO_ARGS_ENTERED || argc != NORMAL_AMOUNT_ARGS)
+ return ERROR_MISSING_ARGS;
+
+ bool prev_was_flag = 0;
+ bool current_arg_is_flag = 0;
+ for(size_t i = 1; i < argc; i++, prev_was_flag = current_arg_is_flag) {
+ if(argv[i][0] == '-') current_arg_is_flag = 1;
+ else current_arg_is_flag = 0;
+
+ if(current_arg_is_flag && prev_was_flag) return ERROR_WRONG_FLAGS;
+ }
+
+ return OK;
+}
diff --git a/source/cla.h b/source/cla.h
@@ -0,0 +1,13 @@
+#ifndef CLA__H
+#define CLA__H
+
+#include "types.h"
+
+#define NO_ARGS_ENTERED 1
+#define NORMAL_AMOUNT_ARGS 11
+
+status_t validate_arguments(int argc, char *argv[]);
+
+static char *available_flags[] = { "-fmt", "-out", "-in", "-ti", "-tf" };
+
+#endif
diff --git a/source/io.c b/source/io.c
diff --git a/source/io.h b/source/io.h
@@ -0,0 +1,4 @@
+#ifndef IO__H
+#define IO__H
+
+#endif
diff --git a/source/main.c b/source/main.c
diff --git a/source/parse.c b/source/parse.c
diff --git a/source/parse.h b/source/parse.h
@@ -0,0 +1,4 @@
+#ifndef PARSE__H
+#define PARSE__H
+
+#endif
diff --git a/source/sort.c b/source/sort.c
diff --git a/source/sort.h b/source/sort.h
@@ -0,0 +1,5 @@
+#ifndef SORT__H
+#define SORT__H
+
+
+#endif
diff --git a/source/types.c b/source/types.c
diff --git a/source/types.h b/source/types.h
@@ -0,0 +1,11 @@
+#ifndef TYPES__H
+#define TYPES__H
+
+typedef enum {
+ OK,
+ ERROR_MISSING_ARGS,
+ ERROR_WRONG_FLAGS,
+ ERROR_NULL_POINTER
+} status_t;
+
+#endif