summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--TODO1
-rw-r--r--i_validation.c35
-rw-r--r--input.c13
-rwxr-xr-xtest/smodebin0 -> 32256 bytes
4 files changed, 30 insertions, 19 deletions
diff --git a/TODO b/TODO
index c6bda3a..16f2266 100644
--- a/TODO
+++ b/TODO
@@ -4,4 +4,5 @@ This is not my overall big planning board. (1 highest prio, 10 lowest)
1 - Have a big long think about how validate_N should work
1 - implement validate_N
1 - Perform tests on validate_N
+2 - add some sort of length check
3 - Have a big long think about how the strings will be processed and translate in to actually doing things in the program.
diff --git a/i_validation.c b/i_validation.c
index 293f47e..4c313cf 100644
--- a/i_validation.c
+++ b/i_validation.c
@@ -146,59 +146,59 @@ int validate_L(char *smode_buf) {
int plus_continue = TRUE_7ED;
switch(vcpm_result) {
case _PLUS_ONLY:
- printf("PLUS ONLY\n");
+ //printf("PLUS ONLY\n");
return _VALID;
break;
case _PLUS_CONTINUE:
- printf("PLUS CONTINUE\n");
+ //printf("PLUS CONTINUE\n");
break;
case _INVALID:
- printf("INVALID\n");
+ //printf("INVALID\n");
return _INVALID;
break;
case _NA:
- printf("NA\n");
+ //printf("NA\n");
vcimm = TRUE_7ED;
plus_continue = FALSE_7ED;
break;
}
if (vcimm == TRUE_7ED) { // This is where L0 is caught
- printf("vcimm start\n");
+ //printf("vcimm start\n");
int vcimm_result = validate_check_imm(smode_buf);
int imm_number = FALSE_7ED;
switch(vcimm_result) {
case _IMM_NUMBER:
- printf("imm number\n");
+ //printf("imm number\n");
imm_number = TRUE_7ED;
break;
case _VALID:
- printf("valid\n");
+ //printf("valid\n");
return _VALID;
break;
case _INVALID:
- printf("invalid\n");
+ //printf("invalid\n");
return _INVALID;
break;
case _NA:
- printf("NA\n");
+ //printf("NA\n");
return _INVALID;
break;
}
if (imm_number == TRUE_7ED) {
- printf("vimmn start\n");
+ //printf("vimmn start\n");
int vimmn_result = validate_imm_numbers(smode_buf);
switch(vimmn_result) {
case _VALID:
- printf("valid\n");
+ //printf("valid\n");
return _VALID;
break;
case _INVALID:
- printf("invalid\n");
+ //printf("invalid\n");
return _INVALID;
break;
case _NA:
- printf("NA\n");
+ //printf("NA\n");
return _INVALID;
break;
}
@@ -208,24 +208,23 @@ int validate_L(char *smode_buf) {
if (plus_continue == TRUE_7ED) {
- printf("validate plus continue \n");
+ //printf("validate plus continue \n");
int vpct_result = validate_plus_continue(smode_buf);
switch(vpct_result) {
case _VALID:
- printf("valid\n");
+ //printf("valid\n");
return _VALID;
break;
case _INVALID:
- printf("invalid\n");
+ //printf("invalid\n");
return _INVALID;
break;
case _NA:
- printf("NA\n");
+ //printf("NA\n");
return _INVALID;
break;
}
-
}
// this below will become validate_imm_numbers or something
diff --git a/input.c b/input.c
index 9a8c91c..2cc2089 100644
--- a/input.c
+++ b/input.c
@@ -13,10 +13,21 @@ int smode_input(char *single, char **multiple, uint64_t focus) { // This functio
// char *single is for p, e, c, q, a
// char **multiple is for L, n, x and d. Although it can be expanded to be used in p and e.
- char smode_buf[SMODE_MAX_SIZE]; // Smode buffer
+ char smode_buf[SMODE_MAX_SIZE] = { '\0' }; // Smode buffer
fprintf(stdout, "(%lu): ", focus); // UI
fgets(smode_buf, SMODE_MAX_SIZE, stdin); // Read user input
+ int sbl = 0;
+ for ( ; sbl < SMODE_MAX_SIZE ; sbl++) {
+ if(smode_buf[sbl] == '\0') {
+ break;
+ }
+ }
+ if (sbl >= SMODE_MAX_INPUT_SIZE) {
+ fprintf(stderr, "sbl > SMODE_MAX_SIZE\n");
+ return _FAIL;
+ }
+
switch (smode_buf[0]) {
// from L to D there will be the 'Multiple' options. In their respective cases i will check if the input is valid or not.
// I will not make the program clean the input because that could lead to assumptions.
diff --git a/test/smode b/test/smode
new file mode 100755
index 0000000..1c5a9f0
--- /dev/null
+++ b/test/smode
Binary files differ