diff --git a/ar.c b/ar.c index bc7739c..6810a71 100644 --- a/ar.c +++ b/ar.c @@ -39,7 +39,7 @@ static int ar_version(lua_State *L) { ////////////////////////////////////////////////////////////////////// LUALIB_API int luaopen_archive(lua_State *L) { - static luaL_reg fns[] = { + static luaL_Reg fns[] = { { "version", ar_version }, { NULL, NULL } }; diff --git a/ar_entry.c b/ar_entry.c index 72056ac..b89fb75 100644 --- a/ar_entry.c +++ b/ar_entry.c @@ -31,6 +31,7 @@ int ar_entry(lua_State *L) { *self_ref = archive_entry_new(); if ( lua_istable(L, 1) ) { + int mt; // If given a sourcepath, copy stat buffer from there: lua_pushliteral(L, "sourcepath"); // ..., {ud}, "sourcepath" lua_rawget(L, 1); // ..., {ud}, src @@ -47,7 +48,9 @@ int ar_entry(lua_State *L) { archive_entry_set_mode(*self_ref, S_IFREG); } lua_pop(L, 1); // ... {ud} - assert(0 != lua_getmetatable(L, -1)); // ..., {ud}, {meta} + /* XXX: optimized away by assert */ + mt = lua_getmetatable(L, -1); // ..., {ud}, {meta} + assert(mt != 0); // Iterate over the table and call the method with that name lua_pushnil(L); // ..., {ud}, {meta}, nil @@ -430,13 +433,13 @@ static int ar_entry_pathname(lua_State *L) { ////////////////////////////////////////////////////////////////////// int ar_entry_init(lua_State *L) { - static luaL_reg fns[] = { + static luaL_Reg fns[] = { { "entry", ar_entry }, { "_entry_ref_count", ar_ref_count }, { NULL, NULL } }; // So far there are no methods on the entry objects. - static luaL_reg m_fns[] = { + static luaL_Reg m_fns[] = { { "fflags", ar_entry_fflags }, { "dev", ar_entry_dev }, { "ino", ar_entry_ino }, diff --git a/ar_entry.h b/ar_entry.h index 0fd2c22..dc09339 100644 --- a/ar_entry.h +++ b/ar_entry.h @@ -1,5 +1,21 @@ // This is a private header subject to change. +/* + * 64-bit integers + */ +#if defined(_MSC_VER) || defined(__BORLANDC__) +typedef __int64 int64_t; +typedef unsigned __int64 uint64_t; +#else +#include +#endif + +#if LUA_VERSION_NUM >= 502 +#define luaL_register(L,n,l) luaL_setfuncs((L), (l), 0) +#define lua_setfenv lua_setuservalue +#define lua_getfenv lua_getuservalue +#endif + #define AR_ENTRY "archive{entry}" #define ar_entry_check(L, narg) \ diff --git a/ar_read.c b/ar_read.c index 39e0812..6296aa1 100644 --- a/ar_read.c +++ b/ar_read.c @@ -85,13 +85,13 @@ static int ar_read(lua_State *L) { { NULL, NULL } }; static named_setter compression_names[] = { - { "all", archive_read_support_compression_all }, - { "bzip2", archive_read_support_compression_bzip2 }, - { "compress", archive_read_support_compression_compress }, - { "gzip", archive_read_support_compression_gzip }, - { "lzma", archive_read_support_compression_lzma }, - { "none", archive_read_support_compression_none }, - { "xz", archive_read_support_compression_xz }, + { "all", archive_read_support_filter_all }, + { "bzip2", archive_read_support_filter_bzip2 }, + { "compress", archive_read_support_filter_compress }, + { "gzip", archive_read_support_filter_gzip }, + { "lzma", archive_read_support_filter_lzma }, + { "none", archive_read_support_filter_none }, + { "xz", archive_read_support_filter_xz }, { NULL, NULL } }; @@ -118,8 +118,8 @@ static int ar_read(lua_State *L) { // Do it the easy way for now... perhaps in the future we will // have a parameter to support toggling which algorithms are // supported: - if ( ARCHIVE_OK != archive_read_support_compression_all(*self_ref) ) { - err("archive_read_support_compression_all: %s", archive_error_string(*self_ref)); + if ( ARCHIVE_OK != archive_read_support_filter_all(*self_ref) ) { + err("archive_read_support_filter_all: %s", archive_error_string(*self_ref)); } if ( ARCHIVE_OK != archive_read_support_format_all(*self_ref) ) { err("archive_read_support_format_all: %s", archive_error_string(*self_ref)); @@ -197,7 +197,7 @@ static int ar_read_destroy(lua_State *L) { if ( ARCHIVE_OK != archive_read_close(*self_ref) ) { lua_pushfstring(L, "archive_read_close: %s", archive_error_string(*self_ref)); - archive_read_finish(*self_ref); + archive_read_free(*self_ref); __ref_count--; *self_ref = NULL; lua_error(L); @@ -210,8 +210,8 @@ static int ar_read_destroy(lua_State *L) { lua_call(L, 2, 1); // {self}, result } - if ( ARCHIVE_OK != archive_read_finish(*self_ref) ) { - luaL_error(L, "archive_read_finish: %s", archive_error_string(*self_ref)); + if ( ARCHIVE_OK != archive_read_free(*self_ref) ) { + luaL_error(L, "archive_read_free: %s", archive_error_string(*self_ref)); } __ref_count--; *self_ref = NULL; @@ -293,7 +293,7 @@ static int ar_read_data(lua_State *L) { struct archive* self = *ar_read_check(L, 1); const void* buff; size_t buff_len; - off_t offset; + int64_t offset; int result; if ( NULL == self ) err("NULL archive{read}!"); @@ -317,12 +317,12 @@ static int ar_read_data(lua_State *L) { // of the stack, and the archive{read} metatable is registered. ////////////////////////////////////////////////////////////////////// int ar_read_init(lua_State *L) { - static luaL_reg fns[] = { + static luaL_Reg fns[] = { { "read", ar_read }, { "_read_ref_count", ar_ref_count }, { NULL, NULL } }; - static luaL_reg m_fns[] = { + static luaL_Reg m_fns[] = { { "next_header", ar_read_next_header }, { "headers", ar_read_headers }, { "data", ar_read_data }, diff --git a/ar_write.c b/ar_write.c index 95ed17e..b647483 100644 --- a/ar_write.c +++ b/ar_write.c @@ -154,11 +154,11 @@ static int ar_write(lua_State *L) { const char *name; int (*setter)(struct archive *); } names[] = { - { "bzip2", archive_write_set_compression_bzip2 }, - { "compress", archive_write_set_compression_compress }, - { "gzip", archive_write_set_compression_gzip }, - { "lzma", archive_write_set_compression_lzma }, - { "xz", archive_write_set_compression_xz }, + { "bzip2", archive_write_add_filter_bzip2 }, + { "compress", archive_write_add_filter_compress }, + { "gzip", archive_write_add_filter_gzip }, + { "lzma", archive_write_add_filter_lzma }, + { "xz", archive_write_add_filter_xz }, { NULL, NULL } }; int idx = 0; @@ -215,7 +215,7 @@ static int ar_write_destroy(lua_State *L) { if ( ARCHIVE_OK != archive_write_close(*self_ref) ) { lua_pushfstring(L, "archive_write_close: %s", archive_error_string(*self_ref)); - archive_write_finish(*self_ref); + archive_write_free(*self_ref); __ref_count--; *self_ref = NULL; lua_error(L); @@ -228,8 +228,8 @@ static int ar_write_destroy(lua_State *L) { lua_call(L, 2, 1); // {self}, result } - if ( ARCHIVE_OK != archive_write_finish(*self_ref) ) { - luaL_error(L, "archive_write_finish: %s", archive_error_string(*self_ref)); + if ( ARCHIVE_OK != archive_write_free(*self_ref) ) { + luaL_error(L, "archive_write_free: %s", archive_error_string(*self_ref)); } __ref_count--; *self_ref = NULL; @@ -303,7 +303,7 @@ static int ar_write_data(lua_State *L) { data = lua_tolstring(L, 2, &len); - archive_write_data(self, data, len); + wrote = archive_write_data(self, data, len); if ( -1 == wrote ) { err("archive_write_data: %s", archive_error_string(self)); } @@ -319,12 +319,12 @@ static int ar_write_data(lua_State *L) { // of the stack, and the archive{write} metatable is registered. ////////////////////////////////////////////////////////////////////// int ar_write_init(lua_State *L) { - static luaL_reg fns[] = { + static luaL_Reg fns[] = { { "write", ar_write }, { "_write_ref_count", ar_ref_count }, { NULL, NULL } }; - static luaL_reg m_fns[] = { + static luaL_Reg m_fns[] = { { "header", ar_write_header }, { "data", ar_write_data }, { "close", ar_write_destroy },