@@ -74,85 +74,16 @@ typedef enum {
7474 FOSSIL_MYSHELL_ERROR_PARSE_FAILED, /* *< Parsing of input or file failed. */
7575 FOSSIL_MYSHELL_ERROR_RESTORE_FAILED, /* *< Restore operation failed. */
7676 FOSSIL_MYSHELL_ERROR_LOCK_FAILED, /* *< Failed to acquire or release lock. */
77+ FOSSIL_MYSHELL_ERROR_SCHEMA_MISMATCH, /* *< Schema or format mismatch between versions. */
78+ FOSSIL_MYSHELL_ERROR_VERSION_UNSUPPORTED, /* *< Database created with unsupported version. */
79+ FOSSIL_MYSHELL_ERROR_INDEX_CORRUPTED, /* *< Index structure corrupted or unreadable. */
80+ FOSSIL_MYSHELL_ERROR_INTEGRITY, /* *< Data integrity check failed (hash mismatch). */
81+ FOSSIL_MYSHELL_ERROR_TRANSACTION_FAILED, /* *< Transaction aborted or rolled back. */
82+ FOSSIL_MYSHELL_ERROR_CAPACITY_EXCEEDED, /* *< Reached maximum size or record capacity. */
83+ FOSSIL_MYSHELL_ERROR_CONFIG_INVALID, /* *< Invalid configuration or options. */
7784 FOSSIL_MYSHELL_ERROR_UNKNOWN /* *< Unknown or unspecified error occurred. */
7885} fossil_bluecrab_myshell_error_t ;
7986
80- /* *
81- * ============================================================================
82- * FSON v2 Compatible Value Representation (Local to MyShell)
83- * ============================================================================
84- * Enumerates supported value types for FSON v2 serialization/deserialization.
85- * These types cover nulls, booleans, scalar integers/floats, literals, strings,
86- * composite structures, and v2 additions such as enums and time/duration.
87- */
88- typedef enum {
89- MYSHELL_FSON_TYPE_NULL = 0 , /* *< Null value. */
90- MYSHELL_FSON_TYPE_BOOL, /* *< Boolean value (true/false). */
91-
92- /* Scalar integer and floating-point types */
93- MYSHELL_FSON_TYPE_I8, /* *< 8-bit signed integer. */
94- MYSHELL_FSON_TYPE_I16, /* *< 16-bit signed integer. */
95- MYSHELL_FSON_TYPE_I32, /* *< 32-bit signed integer. */
96- MYSHELL_FSON_TYPE_I64, /* *< 64-bit signed integer. */
97- MYSHELL_FSON_TYPE_U8, /* *< 8-bit unsigned integer. */
98- MYSHELL_FSON_TYPE_U16, /* *< 16-bit unsigned integer. */
99- MYSHELL_FSON_TYPE_U32, /* *< 32-bit unsigned integer. */
100- MYSHELL_FSON_TYPE_U64, /* *< 64-bit unsigned integer. */
101- MYSHELL_FSON_TYPE_F32, /* *< 32-bit floating-point value. */
102- MYSHELL_FSON_TYPE_F64, /* *< 64-bit floating-point value. */
103-
104- /* Literal types */
105- MYSHELL_FSON_TYPE_OCT, /* *< Octal literal string. */
106- MYSHELL_FSON_TYPE_HEX, /* *< Hexadecimal literal string. */
107- MYSHELL_FSON_TYPE_BIN, /* *< Binary literal string. */
108-
109- /* String types */
110- MYSHELL_FSON_TYPE_CHAR, /* *< Single character. */
111- MYSHELL_FSON_TYPE_CSTR, /* *< Null-terminated C string. */
112-
113- /* Composite types */
114- MYSHELL_FSON_TYPE_ARRAY, /* *< Array of values. */
115- MYSHELL_FSON_TYPE_OBJECT, /* *< Object (key-value map). */
116-
117- /* v2 Additions */
118- MYSHELL_FSON_TYPE_ENUM, /* *< Enum symbol. */
119- MYSHELL_FSON_TYPE_DATETIME, /* *< Date/time string. */
120- MYSHELL_FSON_TYPE_DURATION /* *< Duration string. */
121- } fossil_bluecrab_myshell_fson_type_t ;
122-
123- /* *
124- * @struct fossil_bluecrab_myshell_fson_value_t
125- * Represents a typed value for FSON v2 serialization/deserialization.
126- * The type field indicates the kind of value stored, and the union 'as'
127- * holds the actual value data for the corresponding type.
128- */
129- typedef struct {
130- fossil_bluecrab_myshell_fson_type_t type; /* *< Type of the value. */
131- union {
132- bool b; /* *< Boolean value. */
133- int8_t i8 ; /* *< 8-bit signed integer. */
134- int16_t i16 ; /* *< 16-bit signed integer. */
135- int32_t i32 ; /* *< 32-bit signed integer. */
136- int64_t i64 ; /* *< 64-bit signed integer. */
137- uint8_t u8 ; /* *< 8-bit unsigned integer. */
138- uint16_t u16 ; /* *< 16-bit unsigned integer. */
139- uint32_t u32 ; /* *< 32-bit unsigned integer. */
140- uint64_t u64 ; /* *< 64-bit unsigned integer. */
141- float f32 ; /* *< 32-bit floating-point value. */
142- double f64 ; /* *< 64-bit floating-point value. */
143- char *oct; /* *< Octal literal string. */
144- char *hex; /* *< Hexadecimal literal string. */
145- char *bin; /* *< Binary literal string. */
146- char c; /* *< Single character. */
147- char *cstr; /* *< Null-terminated C string. */
148- char *array; /* *< Array representation (serialized). */
149- char *object; /* *< Object representation (serialized). */
150- char *enum_symbol; /* *< Enum symbol string. */
151- char *datetime; /* *< Date/time string. */
152- char *duration; /* *< Duration string. */
153- } as; /* *< Union holding the actual value data. */
154- } fossil_bluecrab_myshell_fson_value_t ;
155-
15687/* *
15788 * -------------------------------
15889 * Simple, Git-like Public API
@@ -327,6 +258,14 @@ fossil_bluecrab_myshell_error_t fossil_myshell_restore(const char *backup_path,
327258 */
328259const char *fossil_myshell_errstr (fossil_bluecrab_myshell_error_t err);
329260
261+ /* *
262+ * Validates database integrity (hash chain, file size, corruption).
263+ * Time Complexity: O(n) (n = number of records/commits).
264+ * @param db Database handle.
265+ * @return Error code.
266+ */
267+ fossil_bluecrab_myshell_error_t fossil_myshell_check_integrity (fossil_bluecrab_myshell_t *db);
268+
330269#ifdef __cplusplus
331270}
332271#include < string>
@@ -534,6 +473,16 @@ namespace fossil {
534473 return fossil_myshell_errstr (err);
535474 }
536475
476+ /* *
477+ * o-Utility (check_integrity)
478+ * - Validates database integrity (hash chain, file size, corruption).
479+ * - Time Complexity: O(n) (n = number of records/commits).
480+ * @return Error code.
481+ */
482+ fossil_bluecrab_myshell_error_t check_integrity () {
483+ return fossil_myshell_check_integrity (db_);
484+ }
485+
537486 /* *
538487 * o-Utility (is_open)
539488 * - Returns true if the database is open.
0 commit comments