/*************************************************************************************************
* Lua binding of Tokyo Cabinet
* Copyright (C) 2006-2010 FAL Labs
* This file is part of Tokyo Cabinet.
* Tokyo Cabinet is free software; you can redistribute it and/or modify it under the terms of
* the GNU Lesser General Public License as published by the Free Software Foundation; either
* version 2.1 of the License or any later version. Tokyo Cabinet is distributed in the hope
* that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
* You should have received a copy of the GNU Lesser General Public License along with Tokyo
* Cabinet; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
* Boston, MA 02111-1307 USA.
*************************************************************************************************/
#include "lua.h"
#include "lualib.h"
#include "lauxlib.h"
#include <tcutil.h>
#include <tchdb.h>
#include <tcbdb.h>
#include <tcfdb.h>
#include <tctdb.h>
#include <tcadb.h>
#include <stdlib.h>
#include <stdbool.h>
#include <stdint.h>
#include <string.h>
#include <limits.h>
#include <math.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#define SWAB16(TC_num) \
( \
((TC_num & 0x00ffU) << 8) | \
((TC_num & 0xff00U) >> 8) \
)
#define SWAB32(TC_num) \
( \
((TC_num & 0x000000ffUL) << 24) | \
((TC_num & 0x0000ff00UL) << 8) | \
((TC_num & 0x00ff0000UL) >> 8) | \
((TC_num & 0xff000000UL) >> 24) \
)
#define SWAB64(TC_num) \
( \
((TC_num & 0x00000000000000ffULL) << 56) | \
((TC_num & 0x000000000000ff00ULL) << 40) | \
((TC_num & 0x0000000000ff0000ULL) << 24) | \
((TC_num & 0x00000000ff000000ULL) << 8) | \
((TC_num & 0x000000ff00000000ULL) >> 8) | \
((TC_num & 0x0000ff0000000000ULL) >> 24) | \
((TC_num & 0x00ff000000000000ULL) >> 40) | \
((TC_num & 0xff00000000000000ULL) >> 56) \
)
#if defined(_MYBIGEND) || defined(_MYSWAB)
#define HTONS(TC_num) (TC_num)
#define HTONL(TC_num) (TC_num)
#define HTONLL(TC_num) (TC_num)
#define NTOHS(TC_num) (TC_num)
#define NTOHL(TC_num) (TC_num)
#define NTOHLL(TC_num) (TC_num)
#else
#define HTONS(TC_num) SWAB16(TC_num)
#define HTONL(TC_num) SWAB32(TC_num)
#define HTONLL(TC_num) SWAB64(TC_num)
#define NTOHS(TC_num) SWAB16(TC_num)
#define NTOHL(TC_num) SWAB32(TC_num)
#define NTOHLL(TC_num) SWAB64(TC_num)
#endif
#define NUMBUFSIZ 32
#define HDBDATAVAR "_hdbdata_"
#define BDBDATAVAR "_bdbdata_"
#define BDBCURDATAVAR "_bdbcurdata_"
#define FDBDATAVAR "_fdbdata_"
#define TDBDATAVAR "_tdbdata_"
#define TDBQRYDATAVAR "_tdbqrydata_"
#define ADBDATAVAR "_adbdata_"
typedef struct {
lua_State *lua;
char *fname;
} FUNCOP;
typedef struct {
TCHDB *hdb;
} HDBDATA;
typedef struct {
TCBDB *bdb;
} BDBDATA;
typedef struct {
BDBCUR *cur;
} BDBCURDATA;
typedef struct {
TCFDB *fdb;
} FDBDATA;
typedef struct {
TCTDB *tdb;
} TDBDATA;
typedef struct {
TDBQRY *qry;
} TDBQRYDATA;
typedef struct {
TCADB *adb;
} ADBDATA;
/* function prototypes */
int luaopen_tokyocabinet(lua_State *lua);
static TCLIST *tabletotclist(lua_State *lua, int index);
static void tclisttotable(lua_State *lua, TCLIST *list);
static TCMAP *tabletotcmap(lua_State *lua, int index);
static void tcmaptotable(lua_State *lua, TCMAP *map);
static void util_init(lua_State *lua);
static int util_tablenew(lua_State *lua);
static int util_pack(lua_State *lua);
static int util_unpack(lua_State *lua);
static int util_split(lua_State *lua);
static int util_codec(lua_State *lua);
static int util_hash(lua_State *lua);
static int util_bit(lua_State *lua);
static int util_strstr(lua_State *lua);
static int util_regex(lua_State *lua);
static int util_ucs(lua_State *lua);
static int util_dist(lua_State *lua);
static int util_isect(lua_State *lua);
static int util_union(lua_State *lua);
static int util_time(lua_State *lua);
static int util_sleep(lua_State *lua);
static int util_stat(lua_State *lua);
static int util_glob(lua_State *lua);
static int util_remove(lua_State *lua);
static int util_mkdir(lua_State *lua);
static int util_chdir(lua_State *lua);
static bool util_iterrec(const void *kbuf, int ksiz, const void *vbuf, int vsiz, FUNCOP *funcop);
static int util_cmpobj(const char *aptr, int asiz, const char *bptr, int bsiz, FUNCOP *funcop);
static void hdb_init(lua_State *lua);
static int hdb_new(lua_State *lua);
static int hdb_del(lua_State *lua);
static int hdb_errmsg(lua_State *lua);
static int hdb_ecode(lua_State *lua);
static int hdb_tune(lua_State *lua);
static int hdb_setcache(lua_State *lua);
static int hdb_setxmsiz(lua_State *lua);
static int hdb_setdfunit(lua_State *lua);
static int hdb_open(lua_State *lua);
static int hdb_close(lua_State *lua);
static int hdb_put(lua_State *lua);
static int hdb_putkeep(lua_State *lua);
static int hdb_putcat(lua_State *lua);
static int hdb_putasync(lua_State *lua);
static int hdb_out(lua_State *lua);
static int hdb_get(lua_State *lua);
static int hdb_vsiz(lua_State *lua);
static int hdb_iterinit(lua_State *lua);
static int hdb_iternext(lua_State *lua);
static int hdb_fwmkeys(lua_State *lua);
static int hdb_addint(lua_State *lua);
static int hdb_adddouble(lua_State *lua);
static int hdb_sync(lua_State *lua);
static int hdb_optimize(lua_State *lua);
static int hdb_vanish(lua_State *lua);
static int hdb_copy(lua_State *lua);
static int hdb_tranbegin(lua_State *lua);
static int hdb_trancommit(lua_State *lua);
static int hdb_tranabort(lua_State *lua);
static int hdb_path(lua_State *lua);
static int hdb_rnum(lua_State *lua);
static int hdb_fsiz(lua_State *lua);
static int hdb_foreach(lua_State *lua);
static int hdb_pairs(lua_State *lua);
static int hdb_next(lua_State *lua);
static void bdb_init(lua_State *lua);
static int bdb_new(lua_State *lua);
static int bdb_del(lua_State *lua);
static int bdb_errmsg(lua_State *lua);
static int bdb_ecode(lua_State *lua);
static int bdb_setcmpfunc(lua_State *lua);
static int bdb_tune(lua_State *lua);
static int bdb_setcache(lua_State *lua);
static int bdb_setxmsiz(lua_State *lua);
static int bdb_setdfunit(lua_State *lua);
static int bdb_open(lua_State *lua);
static int bdb_close(lua_State *lua);
static int bdb_put(lua_State *lua);
static int bdb_putkeep(lua_State *lua);
static int bdb_putcat(lua_State *lua);
static int bdb_putdup(lua_State *lua);
static int bdb_putlist(lua_State *lua);
static int bdb_out(lua_State *lua);
static int bdb_outlist(lua_State *lua);
static int bdb_get(lua_State *lua);
static int bdb_getlist(lua_State *lua);
static int bdb_vnum(lua_State *lua);
static int bdb_vsiz(lua_State *lua);
static int bdb_range(lua_State *lua);
static int bdb_fwmkeys(lua_State *lua);
static int bdb_addint(lua_State *lua);
static int bdb_adddouble(lua_State *lua);
static int bdb_sync(lua_State *lua);
static int bdb_optimize(lua_State *lua);
static int bdb_vanish(lua_State *lua);
static int bdb_copy(lua_State *lua);
static int bdb_tranbegin(lua_State *lua);
static int bdb_trancommit(lua_State *lua);
static int bdb_tranabort(lua_State *lua);
static int bdb_path(lua_State *lua);
static int bdb_rnum(lua_State *lua);
static int bdb_fsiz(lua_State *lua);
static int bdb_foreach(lua_State *lua);
static int bdb_pairs(lua_State *lua);
static int bdb_next(lua_State *lua);
static void bdbcur_init(lua_State *lua);
static int bdbcur_new(lua_State *lua);
static int bdbcur_del(lua_State *lua);
static int bdbcur_first(lua_State *lua);
static int bdbcur_last(lua_State *lua);
static int bdbcur_jump(lua_State *lua);
static int bdbcur_prev(lua_State *lua);
static int bdbcur_next(lua_State *lua);
static int bdbcur_put(lua_State *lua);
static int bdbcur_out(lua_State *lua);
static int bdbcur_key(lua_State *lua);
static int bdbcur_val(lua_
没有合适的资源?快使用搜索试试~ 我知道了~
tokyocabinet-lua-1.10.tar.gz_TOKYO_Tokyo Cabinet
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 62 浏览量
2022-09-20
17:50:56
上传
评论
收藏 109KB GZ 举报
温馨提示
Tokyo cabinet C 库的Lua绑定接口。 Tokyo cabinet 是一个管理数据库的库。该数据库是一个单一的数据文件,每个记录为关键字和值。每个关键字和值是可变长度的字节序。二进制数据和字符串都可作为关键字或值。每个关键字必须唯一。没有数据表和数据类型的概念。记录以哈希表、b树和定长数据组织。
资源推荐
资源详情
资源评论
收起资源包目录
tokyocabinet-lua-1.10.tar.gz (24个子文件)
tokyocabinet-lua-1.10
libpath.lua 319B
tcutest.lua 7KB
tcftest.lua 16KB
tokyocabinet.c 190KB
example
tctdbex.lua 1KB
tchdbex.lua 1013B
tcbdbex.lua 1KB
tcadbex.lua 987B
tcfdbex.lua 1008B
memsize.lua 902B
tcbtest.lua 17KB
tokyocabinet-doc.lua 81KB
overview.html 9KB
configure.in 4KB
Makefile.in 5KB
docrefine.lua 472B
tcatest.lua 13KB
doc
luadoc.css 5KB
index.html 10KB
modules
tokyocabinet.html 128KB
configure 133KB
tcttest.lua 23KB
COPYING 26KB
tchtest.lua 17KB
共 24 条
- 1
资源评论
局外狗
- 粉丝: 80
- 资源: 1万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功