Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ar.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
};
Expand Down
9 changes: 6 additions & 3 deletions ar_entry.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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 },
Expand Down
16 changes: 16 additions & 0 deletions ar_entry.h
Original file line number Diff line number Diff line change
@@ -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 <stdint.h>
#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) \
Expand Down
30 changes: 15 additions & 15 deletions ar_read.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
};

Expand All @@ -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));
Expand Down Expand Up @@ -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);
Expand All @@ -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;
Expand Down Expand Up @@ -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}!");
Expand All @@ -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 },
Expand Down
22 changes: 11 additions & 11 deletions ar_write.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand All @@ -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;
Expand Down Expand Up @@ -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));
}
Expand All @@ -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 },
Expand Down