all repos — conver-tool @ 4a69a0711f0c5244f6cc276d7f7ba3eb438db3ff

A command line tool to manage ConVer projects.

Started implementing release command.
h3rald h3rald@h3rald.com
Wed, 10 Jun 2026 07:07:45 +0200
commit

4a69a0711f0c5244f6cc276d7f7ba3eb438db3ff

parent

0f741e4642ae960988c6cd45913e1665cbc0b140

2 files changed, 51 insertions(+), 9 deletions(-)

jump to
M src/conver.csrc/conver.c

@@ -189,6 +189,40 @@ print_result(fs_file_create(CONVER_HISTORY_FILE));

} } +void command_release() +{ + char input_score[64]; + uint16_t score; + int valid = 0; + while (!valid) { + printf("Specify the dependability score of the release [001-FFF]: "); + fgets(input_score, sizeof(input_score), stdin); + if (strlen(input_score) > 4) { + print_result(CONVER_ERR_INVALID_SCORE); + continue; + } + int invalid_digit = 0; + for (int i=0; i<3; i++){ + if (!isxdigit(input_score[i])){ + invalid_digit = 1; + printf("Invalid: %c", input_score[i]); + break; + } + } + if (invalid_digit) { + print_result(CONVER_ERR_INVALID_SCORE); + continue; + } + score = (uint16_t)strtoul(input_score, NULL, 16); + if (score <= 0) { + print_result(CONVER_ERR_INVALID_SCORE); + continue; + } + valid = 1; + } + printf("Score: %4X\n", score); +} + //// Main int main(int argc, char *argv[])

@@ -207,6 +241,10 @@ }

if ((strcmp(arg, "init") == 0)) { command_init(); + } + if ((strcmp(arg, "release") == 0)) + { + command_release(); } } }
M src/conver.hsrc/conver.h

@@ -13,27 +13,31 @@

#include <stddef.h> #include <stdio.h> #include <stdlib.h> +#include <stdint.h> #include <string.h> +#include <ctype.h> typedef enum { - CONVER_OK = 0, - CONVER_ERR_OPEN = 1, - CONVER_ERR_WRITE = 2, - CONVER_ERR_READ = 3, - CONVER_ERR_ALLOC = 4, - CONVER_ERR_STAT = 5, - CONVER_ERR_MKDIR = 6 + CONVER_OK = 0, + CONVER_ERR_OPEN = 1, + CONVER_ERR_WRITE = 2, + CONVER_ERR_READ = 3, + CONVER_ERR_ALLOC = 4, + CONVER_ERR_STAT = 5, + CONVER_ERR_MKDIR = 6, + CONVER_ERR_INVALID_SCORE = 7 } conver_result_t; -char * conver_errors[7] = { +char * conver_errors[8] = { "Success", "Unable to open file.", "Unable to write file", "Unable to read file", "Unable to allocate memory for file", "Unable to get file/directory information", - "Unable to create directory" + "Unable to create directory", + "Invalid dependability score" }; #endif // CONVER_H