JSO compiler; packer; update CDB to 0.80; assets now packed into binary
This commit is contained in:
@@ -646,6 +646,11 @@ static inline HMM_Vec4 HMM_SubV4(HMM_Vec4 Left, HMM_Vec4 Right) {
|
||||
return Result;
|
||||
}
|
||||
|
||||
static inline HMM_Vec2 HMM_ScaleV2(HMM_Vec2 v, double s)
|
||||
{
|
||||
return HMM_V2(v.X*s, v.Y*s);
|
||||
}
|
||||
|
||||
static inline HMM_Vec2 HMM_MulV2(HMM_Vec2 Left, HMM_Vec2 Right) {
|
||||
|
||||
HMM_Vec2 Result;
|
||||
|
||||
@@ -1099,6 +1099,14 @@ JSValue duk_cmd(JSContext *js, JSValueConst this, int argc, JSValueConst *argv)
|
||||
case 135:
|
||||
ret = float2js(cam_zoom());
|
||||
break;
|
||||
|
||||
case 136:
|
||||
ret = v22js(world2screen(js2hmmv2(argv[1])));
|
||||
break;
|
||||
|
||||
case 137:
|
||||
ret = v22js(screen2world(js2hmmv2(argv[1])));
|
||||
break;
|
||||
}
|
||||
|
||||
if (str)
|
||||
|
||||
@@ -382,9 +382,6 @@ void call_input_down(int *key) {
|
||||
|
||||
/* This is called once every frame - or more if we want it more! */
|
||||
void input_poll(double wait) {
|
||||
mouse_delta = cpvzero;
|
||||
mousewheel = cpvzero;
|
||||
|
||||
for (int i = 0; i < arrlen(downkeys); i++)
|
||||
call_input_down(&downkeys[i]);
|
||||
}
|
||||
|
||||
@@ -15,6 +15,10 @@
|
||||
#include "stb_ds.h"
|
||||
#include "resources.h"
|
||||
#include "yugine.h"
|
||||
#include "sokol/sokol_app.h"
|
||||
|
||||
#define SOKOL_GLUE_IMPL
|
||||
#include "sokol/sokol_glue.h"
|
||||
|
||||
#include "crt.sglsl.h"
|
||||
#include "box.sglsl.h"
|
||||
@@ -209,6 +213,8 @@ void render_init() {
|
||||
mainwin.height = sapp_height();
|
||||
|
||||
sg_setup(&(sg_desc){
|
||||
.context = sapp_sgcontext(),
|
||||
.mtl_force_managed_storage_mode = 1,
|
||||
.logger = {
|
||||
.func = sg_logging,
|
||||
.user_data = NULL,
|
||||
@@ -372,9 +378,23 @@ cpVect cam_pos() {
|
||||
|
||||
static float zoom = 1.f;
|
||||
float cam_zoom() { return zoom; }
|
||||
|
||||
void add_zoom(float val) { zoom = val; }
|
||||
|
||||
HMM_Vec2 world2screen(HMM_Vec2 pos)
|
||||
{
|
||||
pos = HMM_SubV2(pos, HMM_V2(cam_pos().x, cam_pos().y));
|
||||
pos = HMM_ScaleV2(pos, 1.0/zoom);
|
||||
pos = HMM_AddV2(pos, HMM_V2(mainwin.width/2.0, mainwin.height/2.0));
|
||||
return pos;
|
||||
}
|
||||
|
||||
HMM_Vec2 screen2world(HMM_Vec2 pos)
|
||||
{
|
||||
pos = HMM_AddV2(pos, HMM_V2(mainwin.width/2.0, mainwin.height/2.0));
|
||||
pos = HMM_MulV2(pos, HMM_V2(zoom,zoom));
|
||||
return HMM_AddV2(pos, HMM_V2(cam_pos().x, cam_pos().y));
|
||||
}
|
||||
|
||||
HMM_Mat4 projection = {0.f};
|
||||
HMM_Mat4 hudproj = {0.f};
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#define SOKOL_GLCORE33
|
||||
#define SOKOL_WIN32_FORCE_MAIN
|
||||
#elif __APPLE__
|
||||
// #define SOKOL_METAL
|
||||
#define SOKOL_GLCORE33
|
||||
#endif
|
||||
|
||||
@@ -77,6 +78,8 @@ void set_cam_body(cpBody *body);
|
||||
cpVect cam_pos();
|
||||
float cam_zoom();
|
||||
void add_zoom(float val);
|
||||
HMM_Vec2 world2screen(HMM_Vec2 pos);
|
||||
HMM_Vec2 screen2world(HMM_Vec2 pos);
|
||||
|
||||
sg_shader sg_compile_shader(const char *v, const char *f, sg_shader_desc *d);
|
||||
|
||||
|
||||
@@ -22,6 +22,8 @@
|
||||
|
||||
#include "stb_ds.h"
|
||||
|
||||
#include "core.cdb.h"
|
||||
|
||||
char *DATA_PATH = NULL;
|
||||
char *PREF_PATH = NULL;
|
||||
|
||||
@@ -36,8 +38,8 @@ char pathbuf[MAXPATH + 1];
|
||||
|
||||
const char *DB_NAME = "test.db";
|
||||
|
||||
static struct cdb corecdb;
|
||||
static struct cdb game_cdb;
|
||||
static int loaded_cdb = 0;
|
||||
|
||||
void resources_init() {
|
||||
DATA_PATH = malloc(MAXPATH);
|
||||
@@ -47,10 +49,9 @@ void resources_init() {
|
||||
if (!PREF_PATH)
|
||||
PREF_PATH = strdup("./tmp/");
|
||||
|
||||
int fd;
|
||||
fd = open("test.cdb", O_RDONLY);
|
||||
int fd = open("test.cdb", O_RDONLY);
|
||||
cdb_init(&game_cdb, fd);
|
||||
loaded_cdb = 1;
|
||||
cdb_initf(&corecdb, core_cdb, core_cdb_len);
|
||||
}
|
||||
|
||||
char *get_filename_from_path(char *path, int extension) {
|
||||
@@ -86,6 +87,21 @@ FILE *res_open(char *path, const char *tag) {
|
||||
return f;
|
||||
}
|
||||
|
||||
char *seprint(char *fmt, ...)
|
||||
{
|
||||
va_list args;
|
||||
va_start (args, fmt);
|
||||
char test[128];
|
||||
int len = vsnprintf(test, 128, fmt, args);
|
||||
if (len > 128) {
|
||||
char test = malloc(len+1);
|
||||
vsnprintf(test, len+1, fmt, args);
|
||||
return strdup(test);
|
||||
}
|
||||
|
||||
return strdup(test);
|
||||
}
|
||||
|
||||
static char *ext_paths = NULL;
|
||||
|
||||
#ifndef __EMSCRIPTEN__
|
||||
@@ -163,17 +179,23 @@ char *make_path(const char *file) {
|
||||
return pathbuf;
|
||||
}
|
||||
|
||||
unsigned char *slurp_file(const char *filename, size_t *size)
|
||||
void *cdb_slurp(struct cdb *cdb, const char *file, size_t *size)
|
||||
{
|
||||
if (cdb_find(&game_cdb, filename, strlen(filename))) {
|
||||
unsigned vlen, vpos;
|
||||
vpos = cdb_datapos(&game_cdb);
|
||||
vlen = cdb_datalen(&game_cdb);
|
||||
vpos = cdb_datapos(cdb);
|
||||
vlen = cdb_datalen(cdb);
|
||||
char *data = malloc(vlen);
|
||||
cdb_read(&game_cdb, data, vlen, vpos);
|
||||
cdb_read(cdb, data, vlen, vpos);
|
||||
if (size) *size = vlen;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
unsigned char *slurp_file(const char *filename, size_t *size)
|
||||
{
|
||||
if (cdb_find(&game_cdb, filename, strlen(filename)))
|
||||
return cdb_slurp(&game_cdb, filename, size);
|
||||
else if (cdb_find(&corecdb, filename, strlen(filename)))
|
||||
return cdb_slurp(&corecdb, filename, size);
|
||||
|
||||
FILE *f;
|
||||
|
||||
@@ -197,7 +219,7 @@ unsigned char *slurp_file(const char *filename, size_t *size)
|
||||
char *slurp_text(const char *filename, size_t *size)
|
||||
{
|
||||
size_t len;
|
||||
char *str = slurp_file(filename, &len);
|
||||
unsigned char *str = slurp_file(filename, &len);
|
||||
if (!str) return NULL;
|
||||
char *retstr = malloc(len+1);
|
||||
memcpy(retstr, str, len);
|
||||
|
||||
@@ -19,6 +19,8 @@ unsigned char *slurp_file(const char *filename, size_t *size);
|
||||
char *slurp_text(const char *filename, size_t *size);
|
||||
int slurp_write(const char *txt, const char *filename);
|
||||
|
||||
char *seprint(char *fmt, ...);
|
||||
|
||||
void pack_engine(const char *fname);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -45,6 +45,9 @@ void script_startup() {
|
||||
|
||||
for (int i = 0; i < 100; i++)
|
||||
num_cache[i] = int2js(i);
|
||||
|
||||
script_dofile("scripts/engine.js");
|
||||
// jso_file("scripts/engine.js");
|
||||
}
|
||||
|
||||
JSValue num_cache[100] = {0};
|
||||
@@ -95,13 +98,13 @@ void script_evalf(const char *format, ...)
|
||||
JS_FreeValue(js,obj);
|
||||
}
|
||||
|
||||
uint8_t *compile_script(const char *file) {
|
||||
size_t len;
|
||||
const char *script = slurp_text(file, &len);
|
||||
JSValue obj = JS_Eval(js, script, len, file, JS_EVAL_FLAG_COMPILE_ONLY | JS_EVAL_TYPE_GLOBAL | JS_EVAL_FLAGS);
|
||||
uint8_t *compile_script(const char *file, size_t *len) {
|
||||
const char *script = slurp_text(file, len);
|
||||
JSValue obj = JS_Eval(js, script, *len, file, JS_EVAL_FLAG_COMPILE_ONLY | JS_EVAL_TYPE_GLOBAL | JS_EVAL_FLAGS);
|
||||
free(script);
|
||||
size_t out_len;
|
||||
uint8_t *out;
|
||||
return JS_WriteObject(js, &out_len, obj, JS_WRITE_OBJ_BYTECODE);
|
||||
uint8_t *out = JS_WriteObject(js, &out_len, obj, JS_WRITE_OBJ_BYTECODE);
|
||||
return out;
|
||||
}
|
||||
|
||||
struct callee stacktrace_callee;
|
||||
@@ -127,6 +130,25 @@ int script_dofile(const char *file) {
|
||||
return file_mod_secs(file);
|
||||
}
|
||||
|
||||
JSValue script_runjso(const uint8_t *buf, size_t len)
|
||||
{
|
||||
JSValue obj = JS_ReadObject(js, buf, len, JS_EVAL_FLAGS);
|
||||
JSValue ret = JS_EvalFunction(js, obj);
|
||||
js_print_exception(ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
time_t jso_file(const char *file)
|
||||
{
|
||||
size_t len;
|
||||
uint8_t *byte = compile_script(file, &len);
|
||||
JSValue obj = JS_ReadObject(js, byte, len, JS_READ_OBJ_BYTECODE);
|
||||
JSValue ret = JS_EvalFunction(js, obj);
|
||||
js_print_exception(ret);
|
||||
free(byte);
|
||||
return file_mod_secs(file);
|
||||
}
|
||||
|
||||
JSValue script_runfile(const char *file)
|
||||
{
|
||||
size_t len;
|
||||
|
||||
@@ -20,6 +20,7 @@ void script_startup();
|
||||
void script_run(const char *script, const char *file);
|
||||
void script_evalf(const char *format, ...);
|
||||
int script_dofile(const char *file);
|
||||
time_t jso_file(const char *file);
|
||||
JSValue script_runfile(const char *file);
|
||||
void script_update(double dt);
|
||||
void script_draw();
|
||||
@@ -57,6 +58,6 @@ void call_physics(double dt);
|
||||
|
||||
void register_draw(struct callee c);
|
||||
void call_draw();
|
||||
uint8_t *compile_script(const char *file);
|
||||
uint8_t *compile_script(const char *file, size_t *len);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -292,13 +292,13 @@ static void _sg_metal_encode_texture_pixels(int x, int y, int w, int h, bool ori
|
||||
[cmd_buffer waitUntilCompleted];
|
||||
|
||||
MTLRegion mtl_region = MTLRegionMake2D(0, 0, w, h);
|
||||
void* temp_pixels = (void*)SOKOL_MALLOC(w * 4 * h);
|
||||
void* temp_pixels = malloc(w * 4 * h);
|
||||
SOKOL_ASSERT(temp_pixels);
|
||||
[mtl_dst_texture getBytes:temp_pixels bytesPerRow:w * 4 fromRegion:mtl_region mipmapLevel:0];
|
||||
// int res = SDL_ConvertPixels(w, h, _sg_metal_texture_format_to_sdl_pixel_format(mtl_dst_texture_desc.pixelFormat), temp_pixels, w * 4, SDL_PIXELFORMAT_RGBA32, pixels, w * 4);
|
||||
SOKOL_FREE(temp_pixels);
|
||||
SOKOL_ASSERT(res == 0);
|
||||
_SOKOL_UNUSED(res);
|
||||
free(temp_pixels);
|
||||
// SOKOL_ASSERT(res == 0);
|
||||
// _SOKOL_UNUSED(res);
|
||||
}
|
||||
|
||||
static void _sg_metal_query_image_pixels(_sg_image_t* img, void* pixels) {
|
||||
|
||||
184
source/engine/thirdparty/tinycdb-0.78/ChangeLog
vendored
184
source/engine/thirdparty/tinycdb-0.78/ChangeLog
vendored
@@ -1,184 +0,0 @@
|
||||
2006-06-29 Michael Tokarev <mjt@corpit.ru>
|
||||
|
||||
* see debian/changelog file for further changes.
|
||||
|
||||
2005-04-18 Michael Tokarev <mjt@corpit.ru>
|
||||
|
||||
* move cdb_make_find.c content into cdb_make_put.c
|
||||
|
||||
* introduce CDB_PUT_REPLACE0 - zerofill old duplicates
|
||||
|
||||
* allow usage of cdb.h in C++
|
||||
|
||||
2005-04-11 Michael Tokarev <mjt@corpit.ru>
|
||||
|
||||
* do not autogenerate files (cdb.h.in, cdb.3.in etc), but
|
||||
use real files instead (only substituted VERSION and NAME)
|
||||
|
||||
* finally fixed the `!fputs()' condition to be `fputs() < 0'
|
||||
as it should be in cdb.c (misbehaves on *bsd)
|
||||
|
||||
* kill cdbi_t usage in cdb_int.h
|
||||
|
||||
* export _cdb_make_fullwrite() (was ewrite()) and _cdb_make_flush()
|
||||
and use them in cdb_make.c as appropriate
|
||||
|
||||
* almost completely rewrite _cdb_make_find() and friends:
|
||||
- _cdb_make_find() now accepts new parameter, remove (bool), which,
|
||||
if true, indicates all found records should be deleted from the
|
||||
database.
|
||||
- Call _cdb_make_find() with remove=0 from cdb_make_exists()
|
||||
- Call _cdb_make_find() with appropriate arguments from
|
||||
cdb_make_put(), and simplify the latter greatly (was too clumsy
|
||||
anyway)
|
||||
|
||||
* rename `flags' parameter in cdb_make_put() to be `mode' which is
|
||||
more appropriate
|
||||
|
||||
* change #if conditional in nss_cdb.c
|
||||
from __GLIBC__ to __GNU_LIBRARY__
|
||||
|
||||
2003-11-04 Michael Tokarev <mjt@corpit.ru>
|
||||
|
||||
* added cdb_get() routine: tinycdb officially uses mmap.
|
||||
|
||||
* added cdb_{get,read}{data,key}() macros to read and get
|
||||
current data and key.
|
||||
|
||||
* fixed bug in cdb_seek() - incorrect wrap, sometimes
|
||||
cdb_seek()+cdb_bread() may return EIO instead of finding
|
||||
correct record.
|
||||
|
||||
* added some tweaks to Makefile to build position-independent
|
||||
libcdb_pic.a and shared libcdb.so libraries. Note that
|
||||
using libcdb as shared library is probably not a good idea,
|
||||
due to tiny size of the library.
|
||||
|
||||
* added initial nss_cdb module. Still not well-tested.
|
||||
Probably will not build on non-GNU system.
|
||||
|
||||
* adjusted tests.{ok,sh} for latest cdb utility modifications
|
||||
(-a mode in query by default)
|
||||
|
||||
* Victor Porton (porton at ex-code.com) provided a patch
|
||||
to allow tinycdb to be built on win32 platform (cdb_init.c).
|
||||
Completely untested.
|
||||
|
||||
2003-08-13 Michael Tokarev <mjt@corpit.ru>
|
||||
|
||||
* s/cdbi_t/unsigned/g. No need to keep this type.
|
||||
|
||||
* changed usage of cdb_findnext(): one need to pass
|
||||
pointer to cdb structure to cdb_findnext() now,
|
||||
and should use cdb_datapos(struct cdb_find *)
|
||||
instead of cdb_datapos(struct cdb *)
|
||||
|
||||
* added cdb_seqinit() and cdb_seqnext() routines for sequential
|
||||
record enumeration
|
||||
|
||||
* addded cdb_dend to the cdb structure: end of data
|
||||
position. Use that in cdb_seq*().
|
||||
|
||||
* more strict checking: ensure data is within data section,
|
||||
and hash tables are within hash section of a file.
|
||||
|
||||
* cdb_make.c (cdb_make_start): zerofill cdb_make structure
|
||||
to shut valgrind up (writing uninitialized data to file)
|
||||
|
||||
* cdb.c (cmode): always open file in RDWR mode to allow
|
||||
duplicate key detection
|
||||
|
||||
2002-12-08 Michael Tokarev <mjt+cdb@corpit.ru>
|
||||
|
||||
* version 0.73
|
||||
* de-Debianization. Oh well... ;)
|
||||
* no code changes, just like in 0.72
|
||||
|
||||
2002-10-13 Michael Tokarev <mjt+cdb@corpit.ru>
|
||||
|
||||
* version 0.72
|
||||
|
||||
* cleaned up debian packaging and made it actually work
|
||||
|
||||
* no code changes
|
||||
|
||||
2002-07-22 Michael Tokarev <mjt+cdb@corpit.ru>
|
||||
|
||||
* version 0.71
|
||||
|
||||
* rearranged object files to not depend on ranlib on
|
||||
systems that requires it (i.e. OpenBSD)
|
||||
|
||||
* use ranlib but mark it's possible error as non-fatal
|
||||
|
||||
2001-12-10 Michael Tokarev <mjt+cdb@corpit.ru>
|
||||
|
||||
* version 0.7a
|
||||
|
||||
* converted to CVS, added two missing #include <stdlib.h> for
|
||||
malloc declaration and spec target to the Makefile
|
||||
|
||||
2001-10-14 Michael Tokarev <mjt+cdb@corpit.ru>
|
||||
|
||||
* version 0.7
|
||||
|
||||
* added cdb_seek() and cdb_bread() routines as found
|
||||
in freecdb/cdb-0.64
|
||||
|
||||
2001-07-26 Michael Tokarev <mjt+cdb@corpit.ru>
|
||||
|
||||
* version 0.6
|
||||
|
||||
* added another option, CDB_PUT_WARN, to cdb_make_put's flags
|
||||
(to allow adding unconditionally but still warn about dups),
|
||||
now cdb_make_put seems to be logically complete.
|
||||
|
||||
* added and documented -r and -u options for cdb(1) command,
|
||||
and made them consistent with -w and -e also.
|
||||
|
||||
* reorganized cdb(1) manpage and added changes made to cdb
|
||||
command.
|
||||
|
||||
* added version references to manpages (and make them autogenerated
|
||||
to simplify maintenance).
|
||||
|
||||
* added cdb(5) manpage describing CDB file format.
|
||||
|
||||
2001-07-25 Michael Tokarev <mjt+cdb@corpit.ru>
|
||||
|
||||
* version 0.5
|
||||
|
||||
* added missing #include <sys/types.h> in cdb_init.c, thanks to
|
||||
ppetru@ppetru.net (Petru Paler)
|
||||
|
||||
* removed usage of pread() in cdb_make_find() and friends,
|
||||
suggested by Liviu Daia <Liviu.Daia@imar.ro>
|
||||
|
||||
* autogenerate tinycdb.spec file from template and debian/changelog
|
||||
|
||||
* autogenerate cdb.h from cdb.h.in (substituting version)
|
||||
|
||||
2001-06-29 Michael Tokarev <mjt+cdb@corpit.ru>
|
||||
|
||||
* version 0.4
|
||||
|
||||
* added cdb_make_put() routine to conditionnaly add a record
|
||||
|
||||
* split cdb library to more files (finer granularity)
|
||||
|
||||
* added cdb_findinit() and cdb_findnext() routines
|
||||
|
||||
* renamed cdbtool to cdb
|
||||
|
||||
* simplified cdb utility (dropped various format spec, changed
|
||||
options parsing) and a manpage
|
||||
|
||||
* added small note and copyright to every file in package
|
||||
|
||||
* added some testsuite (make test)
|
||||
|
||||
2001-05-27 Michael Tokarev <mjt+cdb@corpit.ru>
|
||||
|
||||
* version 0.3
|
||||
|
||||
* Initial Release.
|
||||
@@ -1,88 +0,0 @@
|
||||
# tinycdb.spec: tinycdb RPM spec file.
|
||||
#
|
||||
# This file is a part of tinycdb package by Michael Tokarev, mjt@corpit.ru.
|
||||
# Public domain.
|
||||
|
||||
Summary: A package for maintenance of constant databases
|
||||
Name: tinycdb
|
||||
Version: 0.78
|
||||
Release: 1
|
||||
Source: ftp://ftp.corpit.ru/pub/tinycdb/tinycdb_%version.tar.gz
|
||||
License: Public Domain
|
||||
Group: System Environment/Libraries
|
||||
Prefix: %{_prefix}
|
||||
BuildRoot: %{_tmppath}/%{name}-root
|
||||
Summary: TinyCDB - a Constant DataBase
|
||||
|
||||
%description
|
||||
tinycdb is a small, fast and reliable utility set and subroutine
|
||||
library for creating and reading constant databases. The database
|
||||
structure is tuned for fast reading:
|
||||
+ Successful lookups take normally just two disk accesses.
|
||||
+ Unsuccessful lookups take only one disk access.
|
||||
+ Small disk space and memory size requirements; a database
|
||||
uses 2048 bytes for the header and 24 bytes plus size of
|
||||
(key,value) per record.
|
||||
+ Maximum database size is 4GB; individual record size is not
|
||||
otherwise limited.
|
||||
+ Portable file format.
|
||||
+ Fast creation of new databases.
|
||||
+ No locking, updates are atomical.
|
||||
|
||||
This package contains both the utility and the development
|
||||
files, together with nss_cdb module.
|
||||
|
||||
%package devel
|
||||
Summary: Development files for the tinycdb library.
|
||||
Group: System Environment/Libraries
|
||||
Requires: %name = %version-%release
|
||||
Summary: Development files for tinycdb
|
||||
%description devel
|
||||
tinycdb is a small, fast and reliable utility set and subroutine
|
||||
library for creating and reading constant databases.
|
||||
|
||||
This package contains tinycdb development libraries and header files.
|
||||
|
||||
%prep
|
||||
%setup -q
|
||||
|
||||
%build
|
||||
make CFLAGS="$RPM_OPT_FLAGS" \
|
||||
staticlib sharedlib cdb-shared nss \
|
||||
sysconfdir=/etc
|
||||
|
||||
%install
|
||||
rm -rf $RPM_BUILD_ROOT
|
||||
mkdir -p $RPM_BUILD_ROOT
|
||||
%makeinstall DESTDIR=$RPM_BUILD_ROOT \
|
||||
libdir=%_libdir bindir=%_bindir mandir=%_mandir \
|
||||
syslibdir=/%_lib sysconfdir=/etc \
|
||||
includedir=%_includedir \
|
||||
install-all install-nss install-piclib install-sharedlib \
|
||||
INSTALLPROG=cdb-shared CP="cp -p"
|
||||
|
||||
%files
|
||||
%defattr(-,root,root)
|
||||
%_bindir/*
|
||||
%_mandir/man1/*
|
||||
%_mandir/man5/*
|
||||
%_libdir/libcdb.so.*
|
||||
/%_lib/libnss_cdb*
|
||||
/etc/cdb-Makefile
|
||||
%doc ChangeLog NEWS debian/changelog
|
||||
|
||||
%files devel
|
||||
%defattr(-,root,root)
|
||||
%_libdir/libcdb.a
|
||||
%_libdir/libcdb_pic.a
|
||||
%_libdir/libcdb.so
|
||||
%_mandir/man3/*
|
||||
%_includedir/*
|
||||
|
||||
%clean
|
||||
rm -rf $RPM_BUILD_ROOT
|
||||
|
||||
%post -p /sbin/ldconfig
|
||||
%postun -p /sbin/ldconfig
|
||||
|
||||
%changelog
|
||||
175
source/engine/thirdparty/tinycdb/Makefile
vendored
Normal file
175
source/engine/thirdparty/tinycdb/Makefile
vendored
Normal file
@@ -0,0 +1,175 @@
|
||||
#! /usr/bin/make -rf
|
||||
# Makefile: make file for tinycdb package
|
||||
#
|
||||
# This file is a part of tinycdb package by Michael Tokarev, mjt+cdb@corpit.ru.
|
||||
# Public domain.
|
||||
|
||||
VERSION = 0.80
|
||||
|
||||
prefix=/usr/local
|
||||
exec_prefix=$(prefix)
|
||||
bindir=$(exec_prefix)/bin
|
||||
libdir=$(exec_prefix)/lib
|
||||
syslibdir=$(libdir)
|
||||
sysconfdir=/etc
|
||||
includedir=$(prefix)/include
|
||||
mandir=$(prefix)/man
|
||||
NSSCDB_DIR = $(sysconfdir)
|
||||
DESTDIR=
|
||||
|
||||
CC = cc
|
||||
CFLAGS = -O
|
||||
CDEFS = -D_FILE_OFFSET_BITS=64
|
||||
LD = $(CC)
|
||||
LDFLAGS =
|
||||
|
||||
AR = ar
|
||||
ARFLAGS = rv
|
||||
RANLIB = ranlib
|
||||
|
||||
NSS_CDB = libnss_cdb.so.2
|
||||
LIBBASE = libcdb
|
||||
LIB = $(LIBBASE).a
|
||||
PICLIB = $(LIBBASE)_pic.a
|
||||
SHAREDLIB = $(LIBBASE).so.1
|
||||
SOLIB = $(LIBBASE).so
|
||||
CDB_USELIB = $(LIB)
|
||||
NSS_USELIB = $(PICLIB)
|
||||
LIBMAP = $(LIBBASE).map
|
||||
INSTALLPROG = cdb
|
||||
|
||||
# The following assumes GNU CC/LD -
|
||||
# used for building shared libraries only
|
||||
CFLAGS_PIC = -fPIC
|
||||
LDFLAGS_SHARED = -shared
|
||||
LDFLAGS_SONAME = -Wl,--soname=
|
||||
LDFLAGS_VSCRIPT = -Wl,--version-script=
|
||||
|
||||
CP = cp
|
||||
|
||||
LIB_SRCS = cdb_init.c cdb_find.c cdb_findnext.c cdb_seq.c cdb_seek.c \
|
||||
cdb_pack.c cdb_unpack.c \
|
||||
cdb_make_add.c cdb_make_put.c cdb_make.c cdb_hash.c
|
||||
NSS_SRCS = nss_cdb.c nss_cdb-passwd.c nss_cdb-group.c nss_cdb-spwd.c
|
||||
NSSMAP = nss_cdb.map
|
||||
|
||||
DISTFILES = Makefile cdb.h cdb_int.h $(LIB_SRCS) cdb.c \
|
||||
$(NSS_SRCS) nss_cdb.h nss_cdb-Makefile \
|
||||
cdb.3 cdb.1 cdb.5 \
|
||||
tinycdb.spec tests.sh tests.ok \
|
||||
$(LIBMAP) $(NSSMAP) \
|
||||
NEWS
|
||||
|
||||
all: static
|
||||
static: staticlib cdb
|
||||
staticlib: $(LIB)
|
||||
nss: $(NSS_CDB)
|
||||
piclib: $(PICLIB)
|
||||
sharedlib: $(SHAREDLIB)
|
||||
shared: sharedlib cdb-shared
|
||||
|
||||
LIB_OBJS = $(LIB_SRCS:.c=.o)
|
||||
LIB_OBJS_PIC = $(LIB_SRCS:.c=.lo)
|
||||
NSS_OBJS = $(NSS_SRCS:.c=.lo)
|
||||
|
||||
$(LIB): $(LIB_OBJS)
|
||||
-rm -f $@
|
||||
$(AR) $(ARFLAGS) $@ $(LIB_OBJS)
|
||||
-$(RANLIB) $@
|
||||
|
||||
$(PICLIB): $(LIB_OBJS_PIC)
|
||||
-rm -f $@
|
||||
$(AR) $(ARFLAGS) $@ $(LIB_OBJS_PIC)
|
||||
-$(RANLIB) $@
|
||||
|
||||
$(SHAREDLIB): $(LIB_OBJS_PIC) $(LIBMAP)
|
||||
-rm -f $(SOLIB)
|
||||
ln -s $@ $(SOLIB)
|
||||
$(LD) $(LDFLAGS) $(LDFLAGS_SHARED) -o $@ \
|
||||
$(LDFLAGS_SONAME)$(SHAREDLIB) $(LDFLAGS_VSCRIPT)$(LIBMAP) \
|
||||
$(LIB_OBJS_PIC)
|
||||
|
||||
cdb: cdb.o $(CDB_USELIB)
|
||||
$(LD) $(LDFLAGS) -o $@ cdb.o $(CDB_USELIB)
|
||||
cdb-shared: cdb.o $(SHAREDLIB)
|
||||
$(LD) $(LDFLAGS) -o $@ cdb.o $(SHAREDLIB)
|
||||
|
||||
$(NSS_CDB): $(NSS_OBJS) $(NSS_USELIB) $(NSSMAP)
|
||||
$(LD) $(LDFLAGS) $(LDFLAGS_SHARED) -o $@ \
|
||||
$(LDFLAGS_SONAME)$@ $(LDFLAGS_VSCRIPT)$(NSSMAP) \
|
||||
$(NSS_OBJS) $(NSS_USELIB)
|
||||
|
||||
.SUFFIXES:
|
||||
.SUFFIXES: .c .o .lo
|
||||
|
||||
.c.o:
|
||||
$(CC) $(CFLAGS) $(CDEFS) -c $<
|
||||
.c.lo:
|
||||
$(CC) $(CFLAGS) $(CDEFS) $(CFLAGS_PIC) -c -o $@ -DNSSCDB_DIR=\"$(NSSCDB_DIR)\" $<
|
||||
|
||||
cdb.o: cdb.h
|
||||
$(LIB_OBJS) $(LIB_OBJS_PIC): cdb_int.h cdb.h
|
||||
$(NSS_OBJS): nss_cdb.h cdb.h
|
||||
|
||||
clean:
|
||||
-rm -f *.o *.lo core *~ tests.out tests-shared.ok
|
||||
realclean distclean: clean
|
||||
-rm -f $(LIBBASE)[._][aps]* $(NSS_CDB)* cdb cdb-shared
|
||||
|
||||
test tests check: cdb
|
||||
sh ./tests.sh ./cdb > tests.out 2>&1
|
||||
diff tests.ok tests.out
|
||||
@echo All tests passed
|
||||
test-shared tests-shared check-shared: cdb-shared
|
||||
sed 's/^cdb: /cdb-shared: /' <tests.ok >tests-shared.ok
|
||||
LD_LIBRARY_PATH=. sh ./tests.sh ./cdb-shared > tests.out 2>&1
|
||||
diff tests-shared.ok tests.out
|
||||
rm -f tests-shared.ok
|
||||
@echo All tests passed
|
||||
|
||||
do_install = \
|
||||
while [ "$$1" ] ; do \
|
||||
if [ .$$4 = .- ]; then f=$$1; else f=$$4; fi; \
|
||||
d=$(DESTDIR)$$3 ; echo installing $$1 to $$d/$$f; \
|
||||
[ -d $$d ] || mkdir -p $$d || exit 1 ; \
|
||||
$(CP) $$1 $$d/$$f || exit 1; \
|
||||
chmod 0$$2 $$d/$$f || exit 1; \
|
||||
shift 4; \
|
||||
done
|
||||
|
||||
install-all: all $(INSTALLPROG)
|
||||
set -- \
|
||||
cdb.h 644 $(includedir) - \
|
||||
cdb.3 644 $(mandir)/man3 - \
|
||||
cdb.1 644 $(mandir)/man1 - \
|
||||
cdb.5 644 $(mandir)/man5 - \
|
||||
$(INSTALLPROG) 755 $(bindir) cdb \
|
||||
libcdb.a 644 $(libdir) - \
|
||||
; \
|
||||
$(do_install)
|
||||
install-nss: nss
|
||||
@set -- $(NSS_CDB) 644 $(syslibdir) - \
|
||||
nss_cdb-Makefile 644 $(sysconfdir) cdb-Makefile ; \
|
||||
$(do_install)
|
||||
install-sharedlib: sharedlib
|
||||
@set -- $(SHAREDLIB) 644 $(libdir) - ; \
|
||||
$(do_install) ; \
|
||||
ln -sf $(SHAREDLIB) $(DESTDIR)$(libdir)/$(LIBBASE).so
|
||||
install-piclib: piclib
|
||||
@set -- $(PICLIB) 644 $(libdir) - ; \
|
||||
$(do_install)
|
||||
install: install-all
|
||||
|
||||
DNAME = tinycdb-$(VERSION)
|
||||
dist: ../$(DNAME).tar.gz
|
||||
../$(DNAME).tar.gz: $(DISTFILES)
|
||||
mkdir $(DNAME)
|
||||
ln $(DISTFILES) $(DNAME)/
|
||||
rm -f $@
|
||||
tar cfz $@ $(DNAME)
|
||||
rm -fr $(DNAME)
|
||||
|
||||
.PHONY: all clean realclean dist spec
|
||||
.PHONY: test tests check test-shared tests-shared check-shared
|
||||
.PHONY: static staticlib shared sharedlib nss piclib
|
||||
.PHONY: install install-all install-sharedlib install-piclib install-nss
|
||||
@@ -1,5 +1,35 @@
|
||||
User-visible news. Latest at the top.
|
||||
|
||||
tinycdb-0.80 2023-09-17
|
||||
|
||||
- bugfix: cdb utility: check return value from close() too,
|
||||
when creating the cdb file
|
||||
|
||||
- portability: cdb utility: ignore SIGXFSZ signal if defined,
|
||||
to be able to clean up when exceeding file limit
|
||||
|
||||
- robustness: let cdb_make_start to lseek() to the zero position
|
||||
of file. This ensures the file is seekable right at the start
|
||||
instead of at the very end, too
|
||||
|
||||
- robustness: cdb utility: remove temporary file in case create
|
||||
operation fails
|
||||
|
||||
- portability use SEE_SET macro instead of 0 for lseek()
|
||||
|
||||
- split out cdb_pack() into its own .c file
|
||||
|
||||
tinycdb-0.79 2023-09-17
|
||||
|
||||
- bugfix: call fsync() at the end of cdb_make_finish()
|
||||
to ensure data does not stay in some kernel buffer
|
||||
|
||||
- bugfix: clean tests.out in `make distclean' too
|
||||
|
||||
- `make dist' makes tarball in the parent dir
|
||||
|
||||
- stop shipping debian/* - it is not a native debian package
|
||||
|
||||
tinycdb-0.78 2012-05-11
|
||||
|
||||
- bugfix release:
|
||||
@@ -1,11 +1,11 @@
|
||||
/* cdb.h: public cdb include file
|
||||
*
|
||||
* This file is a part of tinycdb package by Michael Tokarev, mjt@corpit.ru.
|
||||
* This file is a part of tinycdb package by Michael Tokarev, mjt+cdb@corpit.ru.
|
||||
* Public domain.
|
||||
*/
|
||||
|
||||
#ifndef TINYCDB_VERSION
|
||||
#define TINYCDB_VERSION 0.78
|
||||
#define TINYCDB_VERSION 0.80
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@@ -37,6 +37,7 @@ struct cdb {
|
||||
#define cdb_fileno(c) ((c)->cdb_fd)
|
||||
|
||||
int cdb_init(struct cdb *cdbp, int fd);
|
||||
int cdb_initf(struct cdb *cdbp, void *p, unsigned len);
|
||||
void cdb_free(struct cdb *cdbp);
|
||||
|
||||
int cdb_read(const struct cdb *cdbp,
|
||||
@@ -1,6 +1,6 @@
|
||||
/* cdb_find.c: cdb_find routine
|
||||
*
|
||||
* This file is a part of tinycdb package by Michael Tokarev, mjt@corpit.ru.
|
||||
* This file is a part of tinycdb package by Michael Tokarev, mjt+cdb@corpit.ru.
|
||||
* Public domain.
|
||||
*/
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* cdb_findnext.c: sequential cdb_find routines
|
||||
*
|
||||
* This file is a part of tinycdb package by Michael Tokarev, mjt@corpit.ru.
|
||||
* This file is a part of tinycdb package by Michael Tokarev, mjt+cdb@corpit.ru.
|
||||
* Public domain.
|
||||
*/
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* cdb_hash.c: cdb hashing routine
|
||||
*
|
||||
* This file is a part of tinycdb package by Michael Tokarev, mjt@corpit.ru.
|
||||
* This file is a part of tinycdb package by Michael Tokarev, mjt+cdb@corpit.ru.
|
||||
* Public domain.
|
||||
*/
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* cdb_init.c: cdb_init, cdb_free and cdb_read routines
|
||||
*
|
||||
* This file is a part of tinycdb package by Michael Tokarev, mjt@corpit.ru.
|
||||
* This file is a part of tinycdb package by Michael Tokarev, mjt+cdb@corpit.ru.
|
||||
* Public domain.
|
||||
*/
|
||||
|
||||
@@ -16,6 +16,27 @@
|
||||
#include <sys/stat.h>
|
||||
#include "cdb_int.h"
|
||||
|
||||
int cdb_initf(struct cdb *cdbp, void *p, unsigned len)
|
||||
{
|
||||
/* get file size */
|
||||
if (len < 0)
|
||||
return -1;
|
||||
|
||||
cdbp->cdb_fd = -1;
|
||||
cdbp->cdb_fsize = len;
|
||||
cdbp->cdb_mem = p;
|
||||
cdbp->cdb_vpos = cdbp->cdb_vlen = 0;
|
||||
cdbp->cdb_kpos = cdbp->cdb_klen = 0;
|
||||
unsigned dend;
|
||||
unsigned fsize = len;
|
||||
dend = cdb_unpack(p);
|
||||
if (dend < 2048) dend = 2048;
|
||||
else if (dend >= fsize) dend = fsize;
|
||||
cdbp->cdb_dend = dend;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
cdb_init(struct cdb *cdbp, int fd)
|
||||
{
|
||||
@@ -1,6 +1,6 @@
|
||||
/* cdb_int.h: internal cdb library declarations
|
||||
*
|
||||
* This file is a part of tinycdb package by Michael Tokarev, mjt@corpit.ru.
|
||||
* This file is a part of tinycdb package by Michael Tokarev, mjt+cdb@corpit.ru.
|
||||
* Public domain.
|
||||
*/
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* cdb_make.c: basic cdb creation routines
|
||||
*
|
||||
* This file is a part of tinycdb package by Michael Tokarev, mjt@corpit.ru.
|
||||
* This file is a part of tinycdb package by Michael Tokarev, mjt+cdb@corpit.ru.
|
||||
* Public domain.
|
||||
*/
|
||||
|
||||
@@ -9,15 +9,6 @@
|
||||
#include <string.h>
|
||||
#include "cdb_int.h"
|
||||
|
||||
void
|
||||
cdb_pack(unsigned num, unsigned char buf[4])
|
||||
{
|
||||
buf[0] = num & 255; num >>= 8;
|
||||
buf[1] = num & 255; num >>= 8;
|
||||
buf[2] = num & 255;
|
||||
buf[3] = num >> 8;
|
||||
}
|
||||
|
||||
int
|
||||
cdb_make_start(struct cdb_make *cdbmp, int fd)
|
||||
{
|
||||
@@ -25,7 +16,7 @@ cdb_make_start(struct cdb_make *cdbmp, int fd)
|
||||
cdbmp->cdb_fd = fd;
|
||||
cdbmp->cdb_dpos = 2048;
|
||||
cdbmp->cdb_bpos = cdbmp->cdb_buf + 2048;
|
||||
return 0;
|
||||
return lseek(fd, 0, SEEK_SET);
|
||||
}
|
||||
|
||||
int internal_function
|
||||
@@ -152,11 +143,11 @@ cdb_make_finish_internal(struct cdb_make *cdbmp)
|
||||
cdb_pack(hpos[t], p + (t << 3));
|
||||
cdb_pack(hcnt[t], p + (t << 3) + 4);
|
||||
}
|
||||
if (lseek(cdbmp->cdb_fd, 0, 0) != 0 ||
|
||||
if (lseek(cdbmp->cdb_fd, 0, SEEK_SET) != 0 ||
|
||||
_cdb_make_fullwrite(cdbmp->cdb_fd, p, 2048) != 0)
|
||||
return -1;
|
||||
|
||||
return 0;
|
||||
return fsync(cdbmp->cdb_fd);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -1,6 +1,6 @@
|
||||
/* cdb_make_add.c: basic cdb_make_add routine
|
||||
*
|
||||
* This file is a part of tinycdb package by Michael Tokarev, mjt@corpit.ru.
|
||||
* This file is a part of tinycdb package by Michael Tokarev, mjt+cdb@corpit.ru.
|
||||
* Public domain.
|
||||
*/
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* cdb_make_put.c: "advanced" cdb_make_put routine
|
||||
*
|
||||
* This file is a part of tinycdb package by Michael Tokarev, mjt@corpit.ru.
|
||||
* This file is a part of tinycdb package by Michael Tokarev, mjt+cdb@corpit.ru.
|
||||
* Public domain.
|
||||
*/
|
||||
|
||||
16
source/engine/thirdparty/tinycdb/cdb_pack.c
vendored
Normal file
16
source/engine/thirdparty/tinycdb/cdb_pack.c
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
/* cdb_pack.c: pack a 32bit integer (to network byte order)
|
||||
*
|
||||
* This file is a part of tinycdb package by Michael Tokarev, mjt+cdb@corpit.ru.
|
||||
* Public domain.
|
||||
*/
|
||||
|
||||
#include "cdb.h"
|
||||
|
||||
void
|
||||
cdb_pack(unsigned num, unsigned char buf[4])
|
||||
{
|
||||
buf[0] = num & 255; num >>= 8;
|
||||
buf[1] = num & 255; num >>= 8;
|
||||
buf[2] = num & 255;
|
||||
buf[3] = num >> 8;
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
/* cdb_seek.c: old interface for reading cdb file
|
||||
*
|
||||
* This file is a part of tinycdb package by Michael Tokarev, mjt@corpit.ru.
|
||||
* This file is a part of tinycdb package by Michael Tokarev, mjt+cdb@corpit.ru.
|
||||
* Public domain.
|
||||
*/
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* cdb_seq.c: sequential record retrieval routines
|
||||
*
|
||||
* This file is a part of tinycdb package by Michael Tokarev, mjt@corpit.ru.
|
||||
* This file is a part of tinycdb package by Michael Tokarev, mjt+cdb@corpit.ru.
|
||||
* Public domain.
|
||||
*/
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* cdb_unpack.c: unpack 32bit integer
|
||||
/* cdb_unpack.c: unpack a 32bit integer from network byte order
|
||||
*
|
||||
* This file is a part of tinycdb package by Michael Tokarev, mjt@corpit.ru.
|
||||
* This file is a part of tinycdb package by Michael Tokarev, mjt+cdb@corpit.ru.
|
||||
* Public domain.
|
||||
*/
|
||||
|
||||
83
source/engine/thirdparty/tinycdb/tests.ok
vendored
Normal file
83
source/engine/thirdparty/tinycdb/tests.ok
vendored
Normal file
@@ -0,0 +1,83 @@
|
||||
Create simple db
|
||||
0
|
||||
checksum may fail if no md5sum program
|
||||
97549c2e76e2d446430a392d77ed1bcb
|
||||
Dump simple db
|
||||
+3,4:one->here
|
||||
+1,1:a->b
|
||||
+1,3:b->abc
|
||||
+3,4:one->also
|
||||
|
||||
0
|
||||
Stats for simple db
|
||||
number of records: 4
|
||||
key min/avg/max length: 1/2/3
|
||||
val min/avg/max length: 1/3/4
|
||||
hash tables/entries/collisions: 3/8/1
|
||||
hash table min/avg/max length: 2/3/4
|
||||
hash table distances:
|
||||
d0: 3 75%
|
||||
d1: 1 25%
|
||||
d2: 0 0%
|
||||
d3: 0 0%
|
||||
d4: 0 0%
|
||||
d5: 0 0%
|
||||
d6: 0 0%
|
||||
d7: 0 0%
|
||||
d8: 0 0%
|
||||
d9: 0 0%
|
||||
>9: 0 0%
|
||||
0
|
||||
Query simple db (two records match)
|
||||
herealso
|
||||
0
|
||||
Query for non-existed key
|
||||
100
|
||||
Doing 600 repeated records
|
||||
0
|
||||
checksum may fail if no md5sum program
|
||||
412a0b7578efca528bf8398c8811caf4
|
||||
cdb stats should show 601 record
|
||||
number of records: 601
|
||||
key min/avg/max length: 1/1/1
|
||||
val min/avg/max length: 3/3/5
|
||||
hash tables/entries/collisions: 2/1202/599
|
||||
hash table min/avg/max length: 2/601/1200
|
||||
hash table distances:
|
||||
d0: 2 0%
|
||||
d1: 1 0%
|
||||
d2: 1 0%
|
||||
d3: 1 0%
|
||||
d4: 1 0%
|
||||
d5: 1 0%
|
||||
d6: 1 0%
|
||||
d7: 1 0%
|
||||
d8: 1 0%
|
||||
d9: 1 0%
|
||||
>9: 590 98%
|
||||
0
|
||||
Querying key
|
||||
other
|
||||
0
|
||||
Dumping and re-creating db
|
||||
0
|
||||
0
|
||||
Handling large key size
|
||||
cdb: (stdin): bad format
|
||||
2
|
||||
Handling large value size
|
||||
cdb: (stdin): bad format
|
||||
2
|
||||
Handling invalid input format (short file)
|
||||
cdb: unable to read: short file
|
||||
2
|
||||
Creating db with eol in key and value
|
||||
0
|
||||
checksum may fail if no md5sum program
|
||||
1d444fe759c26d36f500d01c41cfda40
|
||||
Querying key-value with eol
|
||||
b
|
||||
0
|
||||
Handling file size limits
|
||||
cdb: cdb_make_put: File too large
|
||||
111
|
||||
143
source/engine/thirdparty/tinycdb/tests.sh
vendored
Executable file
143
source/engine/thirdparty/tinycdb/tests.sh
vendored
Executable file
@@ -0,0 +1,143 @@
|
||||
#! /bin/sh
|
||||
|
||||
# tests.sh: This script will run tests for cdb.
|
||||
# Execute with ./tests.sh ./cdb
|
||||
# (first arg if present gives path to cdb tool to use, default is `cdb').
|
||||
#
|
||||
# This file is a part of tinycdb package by Michael Tokarev, mjt+cdb@corpit.ru.
|
||||
# Public domain.
|
||||
|
||||
case "$1" in
|
||||
"") cdb=cdb ;;
|
||||
*) cdb="$1" ;;
|
||||
esac
|
||||
|
||||
do_csum() {
|
||||
echo checksum may fail if no md5sum program
|
||||
md5sum $1 | sed -e 's|[ ].*||' -e 'y|[ABCDEF]|[abcdef]|'
|
||||
}
|
||||
|
||||
rm -f 1.cdb 1a.cdb
|
||||
|
||||
echo Create simple db
|
||||
echo "+3,4:one->here
|
||||
+1,1:a->b
|
||||
+1,3:b->abc
|
||||
+3,4:one->also
|
||||
|
||||
" | $cdb -c 1.cdb
|
||||
echo $?
|
||||
do_csum 1.cdb
|
||||
|
||||
echo Dump simple db
|
||||
$cdb -d 1.cdb
|
||||
echo $?
|
||||
|
||||
echo Stats for simple db
|
||||
$cdb -s 1.cdb
|
||||
echo $?
|
||||
|
||||
echo "Query simple db (two records match)"
|
||||
$cdb -q 1.cdb one
|
||||
echo "
|
||||
$?"
|
||||
|
||||
echo Query for non-existed key
|
||||
$cdb -q 1.cdb none
|
||||
echo $?
|
||||
|
||||
echo Doing 600 repeated records
|
||||
(
|
||||
for i in 0 1 2 3 4 5 ; do
|
||||
for j in 0 1 2 3 4 5 6 7 8 9 ; do
|
||||
for k in 0 1 2 3 4 5 6 7 8 9 ; do
|
||||
echo "+1,3:a->$i$j$k"
|
||||
done
|
||||
done
|
||||
done
|
||||
echo "+1,5:b->other"
|
||||
echo
|
||||
) | $cdb -c 1.cdb
|
||||
echo $?
|
||||
do_csum 1.cdb
|
||||
echo cdb stats should show 601 record
|
||||
$cdb -s 1.cdb
|
||||
echo $?
|
||||
|
||||
echo Querying key
|
||||
$cdb -q 1.cdb b
|
||||
echo "
|
||||
"$?
|
||||
|
||||
echo Dumping and re-creating db
|
||||
$cdb -d 1.cdb | $cdb -c 1a.cdb
|
||||
echo $?
|
||||
cmp 1.cdb 1a.cdb
|
||||
|
||||
$cdb -d -m 1.cdb | $cdb -c -m 1a.cdb
|
||||
echo $?
|
||||
cmp 1.cdb 1a.cdb
|
||||
|
||||
echo Handling large key size
|
||||
echo "+123456789012,1:" | $cdb -c 1.cdb
|
||||
echo $?
|
||||
|
||||
echo Handling large value size
|
||||
echo "+1,123456789012:" | $cdb -c 1.cdb
|
||||
echo $?
|
||||
|
||||
echo "Handling invalid input format (short file)"
|
||||
echo "+10,10:" | $cdb -c 1.cdb
|
||||
echo $?
|
||||
|
||||
echo Creating db with eol in key and value
|
||||
echo "+2,2:a
|
||||
->b
|
||||
|
||||
" | $cdb -c 1.cdb
|
||||
echo $?
|
||||
do_csum 1.cdb
|
||||
|
||||
echo Querying key-value with eol
|
||||
$cdb -q 1.cdb "a
|
||||
"
|
||||
echo $?
|
||||
|
||||
echo Handling file size limits
|
||||
(
|
||||
ulimit -f 4
|
||||
trap '' 25
|
||||
(
|
||||
for i in 0 1 2 3 4 5 6 7 8 9 ; do
|
||||
for j in 0 1 2 3 4 5 6 7 8 9 ; do
|
||||
for k in 0 1 2 3 4 5 6 7 8 9 ; do
|
||||
echo "+4,4:k$i$j$k->v$i$j$k"
|
||||
done
|
||||
done
|
||||
done
|
||||
echo
|
||||
) | $cdb -c 1.cdb
|
||||
echo $?
|
||||
)
|
||||
|
||||
if false ; then # does not work for now, bugs in libc
|
||||
echo Handling oom condition
|
||||
(
|
||||
for i0 in 0 1 2 3 4 5 6 7 8 9 ; do
|
||||
for i1 in 0 1 2 3 4 5 6 7 8 9 ; do
|
||||
for i2 in 0 1 2 3 4 5 6 7 8 9 ; do
|
||||
for i3 in 0 1 2 3 4 5 6 7 8 9 ; do
|
||||
for i4 in 0 1 2 3 4 5 6 7 8 9 ; do
|
||||
echo "+5,0:$i0$i1$i2$i3$i4->"
|
||||
done
|
||||
done
|
||||
done
|
||||
done
|
||||
done
|
||||
echo
|
||||
) | (ulimit -v 1900; $cdb -c 1.cdb)
|
||||
echo $?
|
||||
fi
|
||||
|
||||
rm -rf 1.cdb 1a.cdb 1.cdb.tmp
|
||||
exit 0
|
||||
@@ -8,6 +8,8 @@
|
||||
#include "sound.h"
|
||||
#include "resources.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "datastream.h"
|
||||
|
||||
#include "timer.h"
|
||||
@@ -42,6 +44,7 @@
|
||||
#include "sokol/sokol_app.h"
|
||||
#include "sokol/sokol_audio.h"
|
||||
#include "sokol/sokol_time.h"
|
||||
#include "sokol/sokol_args.h"
|
||||
|
||||
#define STB_DS_IMPLEMENTATION
|
||||
#include <stb_ds.h>
|
||||
@@ -152,7 +155,7 @@ int frame_fps() {
|
||||
return 1.0/sapp_frame_duration();
|
||||
}
|
||||
|
||||
static double low_fps = 1/24.0; /* Chosen because of apple's 24 hz mode */
|
||||
static double low_fps = 1/24.0;
|
||||
static double low_fps_c = 0.0;
|
||||
|
||||
void c_frame()
|
||||
@@ -355,8 +358,6 @@ sapp_desc sokol_main(int argc, char **argv) {
|
||||
phys2d_init();
|
||||
|
||||
script_startup();
|
||||
|
||||
script_dofile("scripts/engine.js");
|
||||
|
||||
int argsize = 0;
|
||||
for (int i = 0; i < argc; i++) {
|
||||
|
||||
Reference in New Issue
Block a user