Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
illuna-minetest
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Illuna-Minetest
illuna-minetest
Commits
62d15ac7
Commit
62d15ac7
authored
8 years ago
by
red-001
Committed by
kwolekr
8 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Add base64 encoding and decoding to the lua api. (#3919)
parent
c4e083f7
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
doc/lua_api.txt
+4
-0
4 additions, 0 deletions
doc/lua_api.txt
doc/menu_lua_api.txt
+4
-0
4 additions, 0 deletions
doc/menu_lua_api.txt
src/script/lua_api/l_util.cpp
+35
-0
35 additions, 0 deletions
src/script/lua_api/l_util.cpp
src/script/lua_api/l_util.h
+6
-0
6 additions, 0 deletions
src/script/lua_api/l_util.h
with
49 additions
and
0 deletions
doc/lua_api.txt
+
4
−
0
View file @
62d15ac7
...
...
@@ -2438,6 +2438,10 @@ These functions return the leftover itemstack.
* See documentation on `minetest.compress()` for supported compression methods.
* currently supported.
* `...` indicates method-specific arguments. Currently, no methods use this.
* `minetest.encode_base64(string)`: returns string encoded in base64
* Encodes a string in base64.
* `minetest.decode_base64(string)`: returns string
* Decodes a string encoded in base64.
* `minetest.is_protected(pos, name)`: returns boolean
* Returns true, if player `name` shouldn't be abled to dig at `pos` or do other
actions, defineable by mods, due to some mod-defined ownership-like concept.
...
...
This diff is collapsed.
Click to expand it.
doc/menu_lua_api.txt
+
4
−
0
View file @
62d15ac7
...
...
@@ -210,6 +210,10 @@ string:trim()
^ eg. string.trim("\n \t\tfoo bar\t ") == "foo bar"
core.is_yes(arg) (possible in async calls)
^ returns whether arg can be interpreted as yes
minetest.encode_base64(string) (possible in async calls)
^ Encodes a string in base64.
minetest.decode_base64(string) (possible in async calls)
^ Decodes a string encoded in base64.
Version compat:
core.get_min_supp_proto()
...
...
This diff is collapsed.
Click to expand it.
src/script/lua_api/l_util.cpp
+
35
−
0
View file @
62d15ac7
...
...
@@ -32,6 +32,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include
"filesys.h"
#include
"settings.h"
#include
"util/auth.h"
#include
"util/base64.h"
#include
<algorithm>
// log([level,] text)
...
...
@@ -320,6 +321,34 @@ int ModApiUtil::l_decompress(lua_State *L)
return
1
;
}
// encode_base64(string)
int
ModApiUtil
::
l_encode_base64
(
lua_State
*
L
)
{
NO_MAP_LOCK_REQUIRED
;
size_t
size
;
const
char
*
data
=
luaL_checklstring
(
L
,
1
,
&
size
);
std
::
string
out
=
base64_encode
((
const
unsigned
char
*
)(
data
),
size
);
lua_pushlstring
(
L
,
out
.
data
(),
out
.
size
());
return
1
;
}
// decode_base64(string)
int
ModApiUtil
::
l_decode_base64
(
lua_State
*
L
)
{
NO_MAP_LOCK_REQUIRED
;
size_t
size
;
const
char
*
data
=
luaL_checklstring
(
L
,
1
,
&
size
);
std
::
string
out
=
base64_decode
(
std
::
string
(
data
,
size
));
lua_pushlstring
(
L
,
out
.
data
(),
out
.
size
());
return
1
;
}
// mkdir(path)
int
ModApiUtil
::
l_mkdir
(
lua_State
*
L
)
{
...
...
@@ -433,6 +462,9 @@ void ModApiUtil::Initialize(lua_State *L, int top)
API_FCT
(
get_dir_list
);
API_FCT
(
request_insecure_environment
);
API_FCT
(
encode_base64
);
API_FCT
(
decode_base64
);
}
void
ModApiUtil
::
InitializeAsync
(
AsyncEngine
&
engine
)
...
...
@@ -459,5 +491,8 @@ void ModApiUtil::InitializeAsync(AsyncEngine& engine)
ASYNC_API_FCT
(
mkdir
);
ASYNC_API_FCT
(
get_dir_list
);
ASYNC_API_FCT
(
encode_base64
);
ASYNC_API_FCT
(
decode_base64
);
}
This diff is collapsed.
Click to expand it.
src/script/lua_api/l_util.h
+
6
−
0
View file @
62d15ac7
...
...
@@ -95,6 +95,12 @@ class ModApiUtil : public ModApiBase {
// request_insecure_environment()
static
int
l_request_insecure_environment
(
lua_State
*
L
);
// encode_base64(string)
static
int
l_encode_base64
(
lua_State
*
L
);
// decode_base64(string)
static
int
l_decode_base64
(
lua_State
*
L
);
public:
static
void
Initialize
(
lua_State
*
L
,
int
top
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment