diff options
-rw-r--r-- | TODO | 1 | ||||
-rw-r--r-- | i_validation.h | 4 | ||||
-rw-r--r-- | input.c | 28 |
3 files changed, 24 insertions, 9 deletions
@@ -1,7 +1,6 @@ TODO list. This is mostly so i can plan more granularly and remember small stuff i was working on last time and what i should prioritise first. This is not my overall big planning board. (1 highest prio, 10 lowest) -1 - Think about how i want 'd' and 'x' to work and how it will be validated 1 - Implement 'd' validation 1 - Test 'd' validation 2 - Implement 'x' validation diff --git a/i_validation.h b/i_validation.h index 52e7c51..39e5848 100644 --- a/i_validation.h +++ b/i_validation.h @@ -13,8 +13,8 @@ #define _IMM_NOTHING _VALID #define _CONTINUE 6 #define _NA 7 -#define MODE_L 76 -#define MODE_N 78 +#define MODE_L 76 // MODE_L works for Commands with + and - +#define MODE_N 78 // MODE_N works for Commands with + only int validate_imm_numbers(char *smode_buf); @@ -53,18 +53,34 @@ int smode_input(char *single, char **multiple, uint64_t focus) { // This functio *multiple = (char *)malloc(strlen(smode_buf) + 1); strcpy(*multiple, smode_buf); return _MULTIPLE; + break; } case 'x': - case 'X': + case 'X': { + + // X will work with MODE_N mode for now. I may update in the future to use MODE_L but for now i will only use MODE_N for simplicity sake. + int chk = validate_LN(smode_buf, MODE_N); + if (chk == _INVALID) { + return _FAIL; + } + *multiple = (char *)malloc(strlen(smode_buf) + 1); + strcpy(*multiple, smode_buf); return _MULTIPLE; - break; - case 'd': - case 'D': - *multiple = (char *)malloc(strlen(smode_buf) + 1); // just a test + break; } + case 'd': + case 'D': { + + // X will work with MODE_N mode for now. I may update in the future to use MODE_L but for now i will only use MODE_N for simplicity sake. + int chk = validate_LN(smode_buf, MODE_N); + if (chk == _INVALID) { + return _FAIL; + } + *multiple = (char *)malloc(strlen(smode_buf) + 1); strcpy(*multiple, smode_buf); return _MULTIPLE; - break; // singles below this point + + break; }// singles below this point case 'p': case 'P': *single = smode_buf[0]; |