forked from rizinorg/rizin
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Make SDB code SPDX compliant * Use some RzUtil functions inside SDB util: compile natively without any extra dependency
- Loading branch information
Showing
63 changed files
with
11,520 additions
and
159 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -255,3 +255,11 @@ License: LGPL-3.0-only | |
Files: librz/reg/p/x86-linux.regs | ||
Copyright: 2009 pancake <[email protected]> | ||
License: LGPL-3.0-only | ||
|
||
Files: librz/util/sdb/src/json/README | ||
Copyright: pancake <[email protected]> | ||
License: MIT | ||
|
||
Files: librz/util/sdb/src/json/test.json | ||
Copyright: pancake <[email protected]> | ||
License: MIT |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
|
||
The person or persons who have associated work with this document (the "Dedicator" or "Certifier") hereby either (a) certifies that, to the best of his knowledge, the work of authorship identified is in the public domain of the country from which the work is published, or (b) hereby dedicates whatever copyright the dedicators holds in the work of authorship identified below (the "Work") to the public domain. A certifier, moreover, dedicates any copyright interest he may have in the associated work, and for these purposes, is described as a "dedicator" below. | ||
|
||
A certifier has taken reasonable steps to verify the copyright status of this work. Certifier recognizes that his good faith efforts may not shield him from liability if in fact the work certified is not in the public domain. | ||
|
||
Dedicator makes this dedication for the benefit of the public at large and to the detriment of the Dedicator's heirs and successors. Dedicator intends this dedication to be an overt act of relinquishment in perpetuity of all present and future rights under copyright law, whether vested or contingent, in the Work. Dedicator understands that such relinquishment of all rights includes the relinquishment of all rights to enforce (by lawsuit or otherwise) those copyrights in the Work. | ||
|
||
Dedicator recognizes that, once placed in the public domain, the Work may be freely reproduced, distributed, transmitted, used, modified, built upon, or otherwise exploited by anyone for any purpose, commercial or non-commercial, and in any way, including by methods that have not yet been invented or conceived. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
SDB (string database) | ||
===================== | ||
|
||
sdb is a simple string key/value database based on djb's cdb | ||
disk storage and supports JSON and arrays introspection. | ||
|
||
Author | ||
------ | ||
pancake <[email protected]> | ||
|
||
Contains | ||
-------- | ||
* namespaces (multiple sdb paths) | ||
* atomic database sync (never corrupted) | ||
* commandline frontend for sdb databases | ||
* arrays support (syntax sugar) | ||
* json parser/getter (js0n.c) | ||
|
||
Rips | ||
---- | ||
* disk storage based on cdb code | ||
* linked lists from rizin api | ||
|
||
Compilation | ||
----------- | ||
SDB requires [Meson](https://mesonbuild.com/) and [Ninja](https://ninja-build.org/) buildsystems to be built: | ||
``` | ||
meson build | ||
ninja -C build | ||
``` | ||
|
||
Changes | ||
------- | ||
I have modified cdb code a little to create smaller databases and | ||
be memory leak free in order to use it from a library. | ||
|
||
The sdb's cdb database format is 10% smaller than the original | ||
one. This is because keylen and valuelen are encoded in 4 bytes: | ||
1 for the key length and 3 for the value length. | ||
|
||
In a test case, a 4.3MB cdb database takes only 3.9MB after this | ||
file format change. | ||
|
||
Usage example | ||
------------- | ||
Let's create a database! | ||
``` | ||
$ sdb d hello=world | ||
$ sdb d hello | ||
world | ||
``` | ||
Using arrays (>=0.6): | ||
``` | ||
$ sdb - '[]list=1,2' '[0]list' '[0]list=foo' '[]list' '[+1]list=bar' | ||
1 | ||
foo | ||
2 | ||
``` | ||
Let's play with json: | ||
``` | ||
$ sdb d g='{"foo":1,"bar":{"cow":3}}' | ||
$ sdb d g:bar.cow | ||
3 | ||
$ sdb - user='{"id":123}' user:id=99 user:id | ||
99 | ||
``` | ||
Using the commandline without any disk database: | ||
``` | ||
$ sdb - foo=bar foo a=3 +a -a | ||
bar | ||
4 | ||
3 | ||
``` | ||
``` | ||
$ sdb - | ||
foo=bar | ||
foo | ||
bar | ||
a=3 | ||
+a | ||
4 | ||
-a | ||
3 | ||
``` | ||
Remove the database | ||
``` | ||
$ rm -f d | ||
``` |
Oops, something went wrong.