diff options
| author | Filip Wandzio <contact@philw.dev> | 2026-03-01 01:03:39 +0100 |
|---|---|---|
| committer | Filip Wandzio <contact@philw.dev> | 2026-03-01 01:03:39 +0100 |
| commit | bf0d77d7d448e964e9716d5af67c48f3d014f090 (patch) | |
| tree | e55f1e91a8c20cd737dfb01dc12a954c25711e01 /include/syntax_essentials.h | |
| download | embedded_guardian-bf0d77d7d448e964e9716d5af67c48f3d014f090.tar.gz embedded_guardian-bf0d77d7d448e964e9716d5af67c48f3d014f090.zip | |
Scaffold basic project tree, implement benchmarking logic
Implement unit testing guardian
Diffstat (limited to '')
| -rw-r--r-- | include/syntax_essentials.h | 81 |
1 files changed, 81 insertions, 0 deletions
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 @@ | |||
| 1 | #pragma once | ||
| 2 | |||
| 3 | /** | ||
| 4 | * | ||
| 5 | * TASK 1: validate_first_name | ||
| 6 | * --------------------------- | ||
| 7 | * Check if the first name is valid. | ||
| 8 | * - Cannot be NULL or empty | ||
| 9 | * - Only letters (a-z, A-Z) | ||
| 10 | * - Minimum length: 2 | ||
| 11 | */ | ||
| 12 | int validate_first_name(const char *first_name); | ||
| 13 | |||
| 14 | /** | ||
| 15 | * TASK 2: validate_last_name | ||
| 16 | * -------------------------- | ||
| 17 | * Check if the last name is valid. | ||
| 18 | * - Cannot be NULL or empty | ||
| 19 | * - Only letters (a-z, A-Z) | ||
| 20 | * - Minimum length: 2 | ||
| 21 | */ | ||
| 22 | int validate_last_name(const char *last_name); | ||
| 23 | |||
| 24 | /** | ||
| 25 | * TASK 3: validate_full_name | ||
| 26 | * -------------------------- | ||
| 27 | * Check if a full name "First Last" is valid. | ||
| 28 | * Use TASK 1 and TASK 2 internally. | ||
| 29 | */ | ||
| 30 | int validate_full_name(const char *full_name); | ||
| 31 | |||
| 32 | /** | ||
| 33 | * TASK 4: validate_index | ||
| 34 | * ---------------------- | ||
| 35 | * Check if a student index is valid. | ||
| 36 | * - Exactly 6 digits | ||
| 37 | */ | ||
| 38 | int validate_index(const char *index); | ||
| 39 | |||
| 40 | /** | ||
| 41 | * TASK 5: register_student | ||
| 42 | * ------------------------ | ||
| 43 | * Register a student given full name and index. | ||
| 44 | * Return codes: | ||
| 45 | * 0 -> valid | ||
| 46 | * 1 -> invalid name | ||
| 47 | * 2 -> invalid index | ||
| 48 | */ | ||
| 49 | int register_student(const char *full_name, const char *index); | ||
| 50 | |||
| 51 | /** | ||
| 52 | * TASK 6: name_length | ||
| 53 | * ------------------ | ||
| 54 | * Return length of the string (do not use strlen). | ||
| 55 | */ | ||
| 56 | int name_length(const char *name); | ||
| 57 | |||
| 58 | /** | ||
| 59 | * TASK 7: student struct | ||
| 60 | * --------------------- | ||
| 61 | * Simple student structure | ||
| 62 | */ | ||
| 63 | typedef struct { | ||
| 64 | char full_name[64]; | ||
| 65 | char index[16]; | ||
| 66 | } Student; | ||
| 67 | |||
| 68 | /** | ||
| 69 | * TASK 8: add_student | ||
| 70 | * ------------------- | ||
| 71 | * Add a student to an array of Student. Return 0 if added. | ||
| 72 | */ | ||
| 73 | int add_student(Student *array, int max_size, const char *name, | ||
| 74 | const char *index); | ||
| 75 | |||
| 76 | /** | ||
| 77 | * TASK 9: get_error_message | ||
| 78 | * ------------------------ | ||
| 79 | * Return error message string for code returned by register_student | ||
| 80 | */ | ||
| 81 | const char *get_error_message(int code); | ||
