diff options
author | Anton L. Šijanec <anton@sijanec.eu> | 2020-05-03 21:00:05 +0200 |
---|---|---|
committer | Anton L. Šijanec <anton@sijanec.eu> | 2020-05-03 21:00:05 +0200 |
commit | f80f005c602654abe137f152a5128c8abd81f9a7 (patch) | |
tree | 883df3ae2bb5873c34ea05a379122bd28db7a831 /src/bvrcommands.c | |
parent | fix glede na prejšnji komit (diff) | |
download | bverbose-f80f005c602654abe137f152a5128c8abd81f9a7.tar bverbose-f80f005c602654abe137f152a5128c8abd81f9a7.tar.gz bverbose-f80f005c602654abe137f152a5128c8abd81f9a7.tar.bz2 bverbose-f80f005c602654abe137f152a5128c8abd81f9a7.tar.lz bverbose-f80f005c602654abe137f152a5128c8abd81f9a7.tar.xz bverbose-f80f005c602654abe137f152a5128c8abd81f9a7.tar.zst bverbose-f80f005c602654abe137f152a5128c8abd81f9a7.zip |
Diffstat (limited to '')
-rw-r--r-- | src/bvrcommands.c | 92 |
1 files changed, 92 insertions, 0 deletions
diff --git a/src/bvrcommands.c b/src/bvrcommands.c new file mode 100644 index 0000000..2e0761b --- /dev/null +++ b/src/bvrcommands.c @@ -0,0 +1,92 @@ +#pragma once +#include <bvr.h> +#include <bvrvar.c> +char bvr_var_skip_separator_chars(FILE * input) { + char input_char = fgetc(input); + while(input_char == ' ' || input_char == CLOSING_COMMAND_TAG_CHAR_1 || input_char == ',' || input_char == ';' || input_char == EOF || + input_char == '\0' || input_char == '\n') { + input_char = fgetc(input); + } + return input_char; +} +int bvr_handle_get(FILE * input, FILE * output) { + char item[BVR_MAX_VARIABLE_SIZE+1]; + char input_char = bvr_var_skip_separator_chars(input); + int i = 0; + while(input_char != ' ' && input_char != CLOSING_COMMAND_TAG_CHAR_1 && input_char != ',' && input_char != ';' && input_char != EOF && + input_char != '\0' && input_char != '\n' && i < BVR_MAX_VARIABLE_SIZE) { + item[i++] = input_char; + input_char = fgetc(input); + } + item[i++] = '\0'; + fprintf(output, "%s", bvr_var_get(item)); + fflush(output); + return SUCCESS; +} +int bvr_handle_set(FILE * input, FILE * output) { + char item[BVR_MAX_VARIABLE_SIZE+1]; + char value[BVR_MAX_VARIABLE_SIZE+1]; + char input_char = bvr_var_skip_separator_chars(input); + int i = 0; + while(input_char != ' ' && input_char != CLOSING_COMMAND_TAG_CHAR_1 && input_char != ',' && input_char != ';' && input_char != EOF && + input_char != '\0' && input_char != '\n' && i < BVR_MAX_VARIABLE_SIZE) { + item[i++] = input_char; + input_char = fgetc(input); + } + item[i++] = '\0'; + i = 0; + input_char = bvr_var_skip_separator_chars(input); + while(input_char != ' ' && input_char != CLOSING_COMMAND_TAG_CHAR_1 && input_char != ',' && input_char != ';' && input_char != EOF && + input_char != '\0' && input_char != '\n' && i < BVR_MAX_VARIABLE_SIZE) { + value[i++] = input_char; + input_char = fgetc(input); + } + value[i++] = '\0'; + return bvr_var_set(item, value); + fflush(output); + return SUCCESS; +} +int bvr_handle_include(FILE * input, FILE * output) { + char item[BVR_MAX_VARIABLE_SIZE+1]; + char input_char = bvr_var_skip_separator_chars(input); + int i = 0; + while(input_char != ' ' && input_char != CLOSING_COMMAND_TAG_CHAR_1 && input_char != ',' && input_char != ';' && input_char != EOF && + input_char != '\0' && input_char != '\n' && i < BVR_MAX_VARIABLE_SIZE) { + item[++i] = input_char; + input_char = fgetc(input); + } + item[++i] = '\0'; + fprintf(output, "%s", bvr_var_get(item)); + fflush(output); + return SUCCESS; +} +int bvr_handle_move(FILE * input, FILE * output) { + char item[BVR_MAX_VARIABLE_SIZE+1]; + char value[BVR_MAX_VARIABLE_SIZE+1]; + char input_char = bvr_var_skip_separator_chars(input); + int i = 0; + while(input_char != ' ' && input_char != CLOSING_COMMAND_TAG_CHAR_1 && input_char != ',' && input_char != ';' && input_char != EOF && + input_char != '\0' && input_char != '\n' && i < BVR_MAX_VARIABLE_SIZE) { + item[++i] = input_char; + input_char = fgetc(input); + } + item[++i] = '\0'; + i = 0; + input_char = bvr_var_skip_separator_chars(input); + value[i] = input_char; + while(input_char != ' ' && input_char != CLOSING_COMMAND_TAG_CHAR_1 && input_char != ',' && input_char != ';' && input_char != EOF && + input_char != '\0' && input_char != '\n' && i < BVR_MAX_VARIABLE_SIZE) { + value[++i] = input_char; + input_char = fgetc(input); + } + value[++i] = '\0'; + return bvr_var_mv(item, value); + fflush(output); + return SUCCESS; + +} +int bvr_handle_info(FILE * input, FILE * output) { + // fprintf(stderr, "[bvrcommands.c] bvr_handle_info: bvr bVerbose HTPCMS %d.%d.%d\n", BVR_VER_MAJOR, BVR_VER_MINOR, BVR_VER_PATCH); + fprintf(output, "\nbvr bVerbose HTPCMS %d.%d.%d\n", BVR_VER_MAJOR, BVR_VER_MINOR, BVR_VER_PATCH); + return SUCCESS; +} |