Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
apk-tools
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
59
Issues
59
List
Boards
Labels
Service Desk
Milestones
Merge Requests
13
Merge Requests
13
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
alpine
apk-tools
Commits
08533d74
Commit
08533d74
authored
Dec 15, 2010
by
Natanael Copa
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
lua: implement who_owns
parent
17b1e1ae
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
41 additions
and
0 deletions
+41
-0
src/lua-apk.c
src/lua-apk.c
+41
-0
No files found.
src/lua-apk.c
View file @
08533d74
#include <features.h>
#include <lua.h>
#include <lualib.h>
#include <lauxlib.h>
...
...
@@ -83,6 +84,14 @@ static const char *get_opt_string_field(lua_State *L, int index,
return
value
;
}
static
void
set_string_field
(
lua_State
*
L
,
int
index
,
const
char
*
key
,
const
char
*
value
)
{
lua_pushstring
(
L
,
key
);
lua_pushstring
(
L
,
value
);
lua_settable
(
L
,
index
);
}
static
int
get_opt_int_field
(
lua_State
*
L
,
int
index
,
const
char
*
key
,
int
def
)
{
int
value
;
...
...
@@ -92,6 +101,13 @@ static int get_opt_int_field(lua_State *L, int index, const char *key, int def)
return
value
;
}
static
void
set_int_field
(
lua_State
*
L
,
int
index
,
const
char
*
key
,
int
value
)
{
lua_pushstring
(
L
,
key
);
lua_pushinteger
(
L
,
value
);
lua_settable
(
L
,
index
);
}
static
int
get_boolean_field
(
lua_State
*
L
,
int
index
,
const
char
*
key
)
{
int
value
;
...
...
@@ -153,11 +169,36 @@ static int Papk_db_close(lua_State *L)
}
static
int
push_package
(
lua_State
*
L
,
struct
apk_package
*
pkg
)
{
if
(
pkg
==
NULL
)
{
lua_pushnil
(
L
);
return
1
;
}
lua_newtable
(
L
);
set_string_field
(
L
,
-
3
,
"name"
,
pkg
->
name
->
name
);
set_string_field
(
L
,
-
3
,
"version"
,
apk_blob_cstr
(
*
pkg
->
version
));
set_string_field
(
L
,
-
3
,
"url"
,
pkg
->
url
);
set_string_field
(
L
,
-
3
,
"license"
,
apk_blob_cstr
(
*
pkg
->
license
));
set_string_field
(
L
,
-
3
,
"description"
,
pkg
->
description
);
set_string_field
(
L
,
-
3
,
"filename"
,
pkg
->
filename
);
set_int_field
(
L
,
-
3
,
"size"
,
pkg
->
size
);
return
1
;
}
static
int
Papk_who_owns
(
lua_State
*
L
)
{
struct
apk_database
*
db
=
checkdb
(
L
,
1
);
const
char
*
path
=
luaL_checkstring
(
L
,
2
);
struct
apk_package
*
pkg
=
apk_db_get_file_owner
(
db
,
APK_BLOB_STR
(
path
));
return
push_package
(
L
,
pkg
);
}
static
const
luaL_reg
reg_apk_methods
[]
=
{
{
"version_validate"
,
Pversion_validate
},
{
"version_compare"
,
Pversion_compare
},
{
"version_is_less"
,
Pversion_is_less
},
{
"db_open"
,
Papk_db_open
},
{
"who_owns"
,
Papk_who_owns
},
{
NULL
,
NULL
}
};
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment