| Name | Size | Type | Info |
| ---- | ---- | ---- | ---- |
-| length | 4 bytes | uint32\_t | Size of the entry |
-| size | 4 bytes | uint32\_t | |
| flag | 1 byte | uint8\_t | |
+| length | 8 bytes | uint64\_t | Size of the entry |
+| size | 8 bytes | uint64\_t | |
| field\_index | 1 byte | uint8\_t | |
| db\_index | 1 byte | uint8\_t | |
| count | 8 bytes | uint64\_t | |
| fragnum | 8 bytes | uint64\_t | |
-| data | \[size\] bytes | ASCII | |
+| data | \[size\] bytes | Binary | |
and 2 flags for `dbentry`:
| Type | Mask | Info |
| ---- | ---- | ---- |
| Used | 0b10000000 | Flag this if you are using the entry. |
| Fragment | 0b01000000 | Flag this if the entry is fragment. |
+| Unset | 0b00100000 | Flag this if the entry is unset. |
Index entry (`indexentry`) MUST be in this format:
| Name | Size | Type | Info |
const char sig[3] = {0x7f, 'D', 'W'};
-const char* dw_errors[] = {"Success", "Used already", "File open fail", "Invalid signature", "Invalid version", "Parser returned NULL", "Cannot call non-method", "Unknown method", "Insufficient arguments", "Too many arguments", "Not used", "Too many tables"};
+const char* dw_errors[] = {"Success", "Used already", "File open fail", "Invalid signature", "Invalid version", "Parser returned NULL", "Cannot call non-method", "Unknown method", "Insufficient arguments", "Too many arguments", "Not used", "Too many tables", "Database not selected"};
#ifdef M_I86
#define BUFSIZE 128
memcpy(index.dbname, buf + 1 + 8 + 1, 256); \
memcpy(index.fields, buf + 1 + 8 + 1 + 256, 4096);
+#define __dw_buffer_to_db_v1_dbentry(buf, dbent) \
+ memcpy(&dbent.flag, buf, 1); \
+ uint64_t be; \
+ memcpy(&be, buf + 1, 8); \
+ __dw_native_endian(be, uint64_t, index.length = __converted); \
+ memcpy(&be, buf + 1 + 8, 8); \
+ __dw_native_endian(be, uint64_t, index.size = __converted); \
+ memcpy(&dbent.field_index, 1 + 8 + 8, 1); \
+ memcpy(&dbent.db_index, 1 + 8 + 8 + 1, 1); \
+ memcpy(&be, buf + 1 + 8 + 8 + 1 + 1, 8); \
+ __dw_native_endian(be, uint64_t, index.count = __converted); \
+ memcpy(&be, buf + 1 + 8 + 8 + 1 + 1 + 8, 8); \
+ __dw_native_endian(be, uint64_t, index.fragnum = __converted);
+
/**
* @~english
* @brief Error enum
*
*/
DW_ERR_TOO_MANY_TABLES,
+
+ /**
+ * @~english
+ * @brief Database not selected
+ *
+ */
+ DW_ERR_DATABASE_NOT_SELECTED,
};
/**
char fields[4096];
};
+/**
+ * @~english
+ * @brief `dbentry` for v1 database.
+ * @note See \ref FORMATv1 for more info.
+ *
+ */
+struct dataworks_db_v1_dbentry {
+ uint8_t flag;
+ uint64_t length;
+ uint64_t size;
+ uint8_t field_index;
+ uint8_t db_index;
+ uint64_t count;
+ uint64_t fragnum;
+ uint8_t* data;
+};
+
/**
* @~english
* @brief "Used" bitmask for indexentry for v1 database.
*/
#define DATAWORKS_V1_INDEXENTRY_USED (1 << 7)
+/**
+ * @~english
+ * @brief "Used" bitmask for dbentry for v1 database.
+ * @note See \ref FORMATv1 for more info.
+ *
+ */
+#define DATAWORKS_V1_DBENTRY_USED (1 << 7)
+
+/**
+ * @~english
+ * @brief "Fragment" bitmask for dbentry for v1 database.
+ * @note See \ref FORMATv1 for more info.
+ *
+ */
+#define DATAWORKS_V1_DBENTRY_FRAGMENT (1 << 6)
+
+/**
+ * @~english
+ * @brief "Unset" bitmask for dbentry for v1 database.
+ * @note See \ref FORMATv1 for more info.
+ *
+ */
+#define DATAWORKS_V1_DBENTRY_UNSET (1 << 5)
+
/**
* @~english
* @brief `infoentry` for database.
*/
void dataworks_database_free_result(struct dataworks_db_result* result);
+/**
+ * @~english
+ * @brief Inserts the record.
+ * @param db Database
+ * @param records Records
+ * @param prop List which contains character `U` or `S`
+ * `U` indicates the field is unset
+ * @return Result
+ *
+ */
+struct dataworks_db_result* dataworks_database_insert_record(struct dataworks_db* db, char** fields, const char* prop);
+
#ifdef __cplusplus
}
#endif