This commit is contained in:
Aaron Blakely 2024-03-06 02:52:38 -06:00
parent 24e535dbaf
commit c3281dc946
8 changed files with 1 additions and 59 deletions

1
.gitignore vendored
View File

@ -7,6 +7,7 @@ mods/test
.cache
UpgradeLog*.XML
xbot.db
*.so
*.dll
*.lib

View File

@ -1,2 +0,0 @@
hello.lua
test.lua

View File

BIN
test.db

Binary file not shown.

BIN
test1.db

Binary file not shown.

View File

@ -1,57 +0,0 @@
#include "db.h"
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#define FNAME "xbot.db"
int main()
{
struct db_table *db;
int i;
if (access(FNAME, F_OK) == -1)
{
printf("Creating db\n");
db = (struct db_table *)malloc(sizeof(struct db_table));
db->count = 0;
db->hashes = NULL;
}
else
{
db = read_db(FNAME);
}
// write some data if db is empty
if (db->count == 0)
{
db_set_hash_char(db, "lua.scripts", "hello.lua,test.lua,youtube.lua");
db_set_hash_int(db, "lua.scriptcount", 2);
db_set_hash_float(db, "lua.version", 5.1);
write_db(db, FNAME);
return 0;
}
for (i = 0; i < db->count; i++)
{
if (db->hashes[i].type == DB_TYPE_INT)
{
printf("Key: %s, Value: %d\n", db->hashes[i].key, get_hash_int(db, db->hashes[i].key));
}
else if (db->hashes[i].type == DB_TYPE_FLOAT)
{
printf("Key: %s, Value: %f\n", db->hashes[i].key, get_hash_float(db, db->hashes[i].key));
}
else if (db->hashes[i].type == DB_TYPE_CHAR)
{
printf("Key: %s, Value: %s\n", db->hashes[i].key, get_hash_char(db, db->hashes[i].key));
}
}
free(db);
return 0;
}

BIN
testdb

Binary file not shown.

BIN
xbot.db

Binary file not shown.