From bf0d77d7d448e964e9716d5af67c48f3d014f090 Mon Sep 17 00:00:00 2001 From: Filip Wandzio Date: Sun, 1 Mar 2026 01:03:39 +0100 Subject: Scaffold basic project tree, implement benchmarking logic Implement unit testing guardian --- include/syntax_essentials.h | 81 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100644 include/syntax_essentials.h (limited to 'include/syntax_essentials.h') diff --git a/include/syntax_essentials.h b/include/syntax_essentials.h new file mode 100644 index 0000000..181cb99 --- /dev/null +++ b/include/syntax_essentials.h @@ -0,0 +1,81 @@ +#pragma once + +/** + * + * TASK 1: validate_first_name + * --------------------------- + * Check if the first name is valid. + * - Cannot be NULL or empty + * - Only letters (a-z, A-Z) + * - Minimum length: 2 + */ +int validate_first_name(const char *first_name); + +/** + * TASK 2: validate_last_name + * -------------------------- + * Check if the last name is valid. + * - Cannot be NULL or empty + * - Only letters (a-z, A-Z) + * - Minimum length: 2 + */ +int validate_last_name(const char *last_name); + +/** + * TASK 3: validate_full_name + * -------------------------- + * Check if a full name "First Last" is valid. + * Use TASK 1 and TASK 2 internally. + */ +int validate_full_name(const char *full_name); + +/** + * TASK 4: validate_index + * ---------------------- + * Check if a student index is valid. + * - Exactly 6 digits + */ +int validate_index(const char *index); + +/** + * TASK 5: register_student + * ------------------------ + * Register a student given full name and index. + * Return codes: + * 0 -> valid + * 1 -> invalid name + * 2 -> invalid index + */ +int register_student(const char *full_name, const char *index); + +/** + * TASK 6: name_length + * ------------------ + * Return length of the string (do not use strlen). + */ +int name_length(const char *name); + +/** + * TASK 7: student struct + * --------------------- + * Simple student structure + */ +typedef struct { + char full_name[64]; + char index[16]; +} Student; + +/** + * TASK 8: add_student + * ------------------- + * Add a student to an array of Student. Return 0 if added. + */ +int add_student(Student *array, int max_size, const char *name, + const char *index); + +/** + * TASK 9: get_error_message + * ------------------------ + * Return error message string for code returned by register_student + */ +const char *get_error_message(int code); -- cgit v1.2.3