29#ifndef __DATAWORKS_DW_DATABASE_H__
30#define __DATAWORKS_DW_DATABASE_H__
47#define __dw_buffer_to_db_v1_indexentry(buf, index) \
48 memcpy(&index.flag, buf, 1); \
50 memcpy(&be_count, buf + 1, 8); \
51 __dw_native_endian(be_count, uint64_t, index.count = __converted); \
52 memcpy(&index.dbname_len, buf + 1 + 8, 1); \
53 memcpy(index.dbname, buf + 1 + 8 + 1, 256); \
54 memcpy(index.fields, buf + 1 + 8 + 1 + 256, 4096);
216#define DATAWORKS_V1_INDEXENTRY_USED (1 << 7)
int dataworks_database_create(const char *fname)
Creates the database.
uint64_t dataworks_database_get_mtime(struct dataworks_db *db)
Get the last modified time of the database.
void dataworks_database_close(struct dataworks_db *db)
Closes the database.
void dataworks_database_update_mtime(struct dataworks_db *db)
Update mtime.
struct dataworks_db_result * dataworks_database_execute_code(struct dataworks_db *db, const char *code)
Executes the code.
bool dataworks_database_get_error(struct dataworks_db *db)
Get the error flag of the database.
int dataworks_database_create_table(struct dataworks_db *db, const char *name, char **fields, const char *fieldtypes)
Creates a table.
char ** dataworks_database_get_table_list(struct dataworks_db *db)
Get the table list of the database.
const char * dataworks_database_strerror(int n)
Converts error number to a string.
int dataworks_database_get_error_number(struct dataworks_db *db)
Get the error number of the database.
void dataworks_database_free_result(struct dataworks_db_result *result)
Frees the result.
@ DW_ERR_EXEC_INSUFFICIENT_ARGUMENTS
Insufficient arguments.
@ DW_ERR_INVALID_SIGNATURE
Invalid signature.
@ DW_ERR_EXEC_UNKNOWN_METHOD
Unknown method.
@ DW_ERR_INVALID_VERSION
Invalid version.
@ DW_ERR_FAIL_FOPEN
File open fail.
@ DW_ERR_USED
Used already.
@ DW_ERR_EXEC_NON_METHOD
Cannot call non-method.
@ DW_ERR_PARSER_NULL
Parser returned NULL.
struct dataworks_db * dataworks_database_open(const char *fname)
Opens the database.
int dataworks_database_get_version(struct dataworks_db *db)
Get the version of the database.
bool error
True if this is an error.
indexentry for v1 database.
bool error
True if this is an error.
uint64_t mtime
Last modified time of the database.
FILE * fp
File pointer to the database file.
uint16_t version
Version of the database.