diff options
| author | Soikk | 2022-04-27 22:23:59 +0200 |
|---|---|---|
| committer | Soikk | 2022-04-27 22:23:59 +0200 |
| commit | 8a2981d9137357d4b2c86e8037e4f2ca9cea5578 (patch) | |
| tree | 8410987af957afc9ced113c521c07cba92b3d302 /parser.c | |
| download | soikk-DB-8a2981d9137357d4b2c86e8037e4f2ca9cea5578.tar.xz soikk-DB-8a2981d9137357d4b2c86e8037e4f2ca9cea5578.tar.zst | |
Initial commit
Diffstat (limited to 'parser.c')
| -rw-r--r-- | parser.c | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/parser.c b/parser.c new file mode 100644 index 0000000..1c127cd --- /dev/null +++ b/parser.c @@ -0,0 +1,33 @@ +#include "db.h" + + +uint16_t len(const char *s){ + uint16_t l = -1; + while(s[++l]); + return l; +} + +bool sameStr(const char* s1, const char *s2){ + uint16_t i1 = 0, i2 = 0; + while(s1[i1] && s2[i2] && s1[i1] == s2[i2]) + ++i1, ++i2; + return !s1[i1] && !s2[i2]; +} + +int handleMetaCommand(inputBuffer *in){ + if(sameStr(in->buffer, ".exit")){ + freeInputBuffer(in); + printf("EXIT M'NIGGA\n"); + exit(EXIT_SUCCESS); + }else{ + return META_COMMAND_FAIL; + } +} + +int handleInput(inputBuffer *in){ + if(in->buffer[0] == '.'){ + return handleMetaCommand(in); + }else{ + printf("normal command\n"); + } +}
\ No newline at end of file |
