diff options
| author | ruki <[email protected]> | 2022-04-05 23:37:32 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2022-04-05 23:37:32 +0800 |
| commit | 4724bc52df2b22357103d6569f9664c5651a3ebe (patch) | |
| tree | cd184820e9d10c707e18a5ed15d0594e54306f6f /core/src | |
| parent | 0125ddfe80f8d8fee5ea55fe1ed2f45acf188997 (diff) | |
improve get uid
Diffstat (limited to 'core/src')
| -rw-r--r-- | core/src/xmake/engine.c | 8 | ||||
| -rw-r--r-- | core/src/xmake/makefile | 4 | ||||
| -rw-r--r-- | core/src/xmake/os/getgid.c (renamed from core/src/xmake/os/gid.c) | 24 | ||||
| -rw-r--r-- | core/src/xmake/os/getuid.c (renamed from core/src/xmake/os/uid.c) | 24 |
4 files changed, 30 insertions, 30 deletions
diff --git a/core/src/xmake/engine.c b/core/src/xmake/engine.c index 005d2eebe..7183140e0 100644 --- a/core/src/xmake/engine.c +++ b/core/src/xmake/engine.c @@ -113,8 +113,8 @@ tb_int_t xm_os_syserror(lua_State* lua); tb_int_t xm_os_strerror(lua_State* lua); tb_int_t xm_os_getwinsize(lua_State* lua); #ifndef TB_CONFIG_OS_WINDOWS -tb_int_t xm_os_uid(lua_State* lua); -tb_int_t xm_os_gid(lua_State* lua); +tb_int_t xm_os_getuid(lua_State* lua); +tb_int_t xm_os_getgid(lua_State* lua); tb_int_t xm_os_getown(lua_State* lua); #endif @@ -290,8 +290,8 @@ static luaL_Reg const g_os_functions[] = , { "filesize", xm_os_filesize } , { "getwinsize", xm_os_getwinsize} #ifndef TB_CONFIG_OS_WINDOWS -, { "uid", xm_os_uid } -, { "gid", xm_os_gid } +, { "uid", xm_os_getuid } +, { "gid", xm_os_getgid } , { "getown", xm_os_getown } #endif , { tb_null, tb_null } diff --git a/core/src/xmake/makefile b/core/src/xmake/makefile index 2203b81b7..c07ba7153 100644 --- a/core/src/xmake/makefile +++ b/core/src/xmake/makefile @@ -44,8 +44,8 @@ xmake_C_FILES += \ os/strerror \ os/filesize \ os/getwinsize \ - os/uid \ - os/gid \ + os/getuid \ + os/getgid \ os/getown \ io/stdfile \ io/file_size \ diff --git a/core/src/xmake/os/gid.c b/core/src/xmake/os/getgid.c index 8a05cd145..a089f855e 100644 --- a/core/src/xmake/os/gid.c +++ b/core/src/xmake/os/getgid.c @@ -15,14 +15,14 @@ * Copyright (C) 2015-present, TBOOX Open Source Group. * * @author TitanSnow - * @file gid.c + * @file getgid.c * */ /* ////////////////////////////////////////////////////////////////////////////////////// * trace */ -#define TB_TRACE_MODULE_NAME "gid" +#define TB_TRACE_MODULE_NAME "getgid" #define TB_TRACE_MODULE_DEBUG (0) /* ////////////////////////////////////////////////////////////////////////////////////// @@ -40,7 +40,7 @@ #ifndef TB_CONFIG_OS_WINDOWS // get & set gid -tb_int_t xm_os_gid(lua_State* lua) +tb_int_t xm_os_getgid(lua_State* lua) { // check tb_assert_and_check_return_val(lua, 0); @@ -52,14 +52,14 @@ tb_int_t xm_os_gid(lua_State* lua) { if (lua_istable(lua, 1)) { - // os.gid({["rgid"] = rgid, ["egid"] = egid}) + // os.getgid({["rgid"] = rgid, ["egid"] = egid}) lua_getfield(lua, 1, "rgid"); lua_getfield(lua, 1, "egid"); if (!lua_isnil(lua, -1)) { if (!lua_isnumber(lua, -1)) { - lua_pushfstring(lua, "invalid field type(%s) in `egid` for os.gid", luaL_typename(lua, -1)); + lua_pushfstring(lua, "invalid field type(%s) in `egid` for os.getgid", luaL_typename(lua, -1)); lua_error(lua); return 0; } @@ -70,7 +70,7 @@ tb_int_t xm_os_gid(lua_State* lua) { if (!lua_isnumber(lua, -1)) { - lua_pushfstring(lua, "invalid field type(%s) in `rgid` for os.gid", luaL_typename(lua, -1)); + lua_pushfstring(lua, "invalid field type(%s) in `rgid` for os.getgid", luaL_typename(lua, -1)); lua_error(lua); return 0; } @@ -80,24 +80,24 @@ tb_int_t xm_os_gid(lua_State* lua) } else if (lua_isnumber(lua, 1)) { - // os.gid(gid) + // os.getgid(gid) rgidset = egidset = (tb_int_t)lua_tonumber(lua, 1); } else { - lua_pushfstring(lua, "invalid argument type(%s) for os.gid", luaL_typename(lua, 1)); + lua_pushfstring(lua, "invalid argument type(%s) for os.getgid", luaL_typename(lua, 1)); lua_error(lua); return 0; } } else if (argc == 2) { - // os.gid(rgid, egid) + // os.getgid(rgid, egid) if (!lua_isnil(lua, 1)) { if (!lua_isnumber(lua, 1)) { - lua_pushfstring(lua, "invalid argument type(%s) for os.gid", luaL_typename(lua, 1)); + lua_pushfstring(lua, "invalid argument type(%s) for os.getgid", luaL_typename(lua, 1)); lua_error(lua); return 0; } @@ -107,7 +107,7 @@ tb_int_t xm_os_gid(lua_State* lua) { if (!lua_isnumber(lua, 2)) { - lua_pushfstring(lua, "invalid argument type(%s) for os.gid", luaL_typename(lua, 2)); + lua_pushfstring(lua, "invalid argument type(%s) for os.getgid", luaL_typename(lua, 2)); lua_error(lua); return 0; } @@ -116,7 +116,7 @@ tb_int_t xm_os_gid(lua_State* lua) } else if (argc != 0) { - lua_pushstring(lua, "invalid argument count for os.gid"); + lua_pushstring(lua, "invalid argument count for os.getgid"); lua_error(lua); return 0; } diff --git a/core/src/xmake/os/uid.c b/core/src/xmake/os/getuid.c index bdaee036f..9c2c2fa2c 100644 --- a/core/src/xmake/os/uid.c +++ b/core/src/xmake/os/getuid.c @@ -15,14 +15,14 @@ * Copyright (C) 2015-present, TBOOX Open Source Group. * * @author TitanSnow - * @file uid.c + * @file getuid.c * */ /* ////////////////////////////////////////////////////////////////////////////////////// * trace */ -#define TB_TRACE_MODULE_NAME "uid" +#define TB_TRACE_MODULE_NAME "getuid" #define TB_TRACE_MODULE_DEBUG (0) /* ////////////////////////////////////////////////////////////////////////////////////// @@ -40,7 +40,7 @@ #ifndef TB_CONFIG_OS_WINDOWS // get & set uid -tb_int_t xm_os_uid(lua_State* lua) +tb_int_t xm_os_getuid(lua_State* lua) { // check tb_assert_and_check_return_val(lua, 0); @@ -52,14 +52,14 @@ tb_int_t xm_os_uid(lua_State* lua) { if (lua_istable(lua, 1)) { - // os.uid({["ruid"] = ruid, ["euid"] = euid}) + // os.getuid({["ruid"] = ruid, ["euid"] = euid}) lua_getfield(lua, 1, "ruid"); lua_getfield(lua, 1, "euid"); if (!lua_isnil(lua, -1)) { if (!lua_isnumber(lua, -1)) { - lua_pushfstring(lua, "invalid field type(%s) in `euid` for os.uid", luaL_typename(lua, -1)); + lua_pushfstring(lua, "invalid field type(%s) in `euid` for os.getuid", luaL_typename(lua, -1)); lua_error(lua); return 0; } @@ -70,7 +70,7 @@ tb_int_t xm_os_uid(lua_State* lua) { if (!lua_isnumber(lua, -1)) { - lua_pushfstring(lua, "invalid field type(%s) in `ruid` for os.uid", luaL_typename(lua, -1)); + lua_pushfstring(lua, "invalid field type(%s) in `ruid` for os.getuid", luaL_typename(lua, -1)); lua_error(lua); return 0; } @@ -80,24 +80,24 @@ tb_int_t xm_os_uid(lua_State* lua) } else if (lua_isnumber(lua, 1)) { - // os.uid(uid) + // os.getuid(uid) ruidset = euidset = (tb_int_t)lua_tonumber(lua, 1); } else { - lua_pushfstring(lua, "invalid argument type(%s) for os.uid", luaL_typename(lua, 1)); + lua_pushfstring(lua, "invalid argument type(%s) for os.getuid", luaL_typename(lua, 1)); lua_error(lua); return 0; } } else if (argc == 2) { - // os.uid(ruid, euid) + // os.getuid(ruid, euid) if (!lua_isnil(lua, 1)) { if (!lua_isnumber(lua, 1)) { - lua_pushfstring(lua, "invalid argument type(%s) for os.uid", luaL_typename(lua, 1)); + lua_pushfstring(lua, "invalid argument type(%s) for os.getuid", luaL_typename(lua, 1)); lua_error(lua); return 0; } @@ -107,7 +107,7 @@ tb_int_t xm_os_uid(lua_State* lua) { if (!lua_isnumber(lua, 2)) { - lua_pushfstring(lua, "invalid argument type(%s) for os.uid", luaL_typename(lua, 2)); + lua_pushfstring(lua, "invalid argument type(%s) for os.getuid", luaL_typename(lua, 2)); lua_error(lua); return 0; } @@ -116,7 +116,7 @@ tb_int_t xm_os_uid(lua_State* lua) } else if (argc != 0) { - lua_pushstring(lua, "invalid argument count for os.uid"); + lua_pushstring(lua, "invalid argument count for os.getuid"); lua_error(lua); return 0; } |
