summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOskar <[email protected]>2024-04-04 22:29:27 +0200
committerOskar <[email protected]>2024-04-04 22:29:27 +0200
commit0ea0f8bf579da9ce9c61f941598983d81f3d5cde (patch)
treeee52c4c448d10065529989f9a517b816333de55d
parent81f43e3057c2fb533595c3e624d2c11813aff1c2 (diff)
Some fixes for the 'single' inputs. Now only allows for single
characters and NOTHING more
-rw-r--r--input.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/input.c b/input.c
index 41ff0f5..a86ec4c 100644
--- a/input.c
+++ b/input.c
@@ -12,6 +12,27 @@ int clfstdin_doubleprint = 1; // variable accessed via extern int in startmode s
int check_length_fix_stdin(char *smode_buf) {
+ int not_newline = 1;
+ switch (smode_buf[0]) { // This whole thing just checks for 'single' inputs. The single inputs can ONLY and should only allow for single characters.
+ case 'p':
+ case 'P':
+ case 'e':
+ case 'E':
+ case 'c':
+ case 'C':
+ case 'q':
+ case 'Q':
+ case 'a':
+ case 'A':
+ if (smode_buf[1] != '\n') { // If not a new line
+ not_newline = 0;
+ break;
+ } else {
+ return 0;
+ }
+ break;
+ }
+
int sbl = 0;
for ( ; sbl < SMODE_MAX_INPUT_SIZE ; sbl++) {
if(smode_buf[sbl] == '\0' || smode_buf[sbl] == '\n') {
@@ -27,6 +48,10 @@ int check_length_fix_stdin(char *smode_buf) {
return _FAIL;
}
+ if (not_newline == 0) {
+ return _FAIL;
+ }
+
return 0;
}