本文整理汇总了C++中checkint函数的典型用法代码示例。如果您正苦于以下问题:C++ checkint函数的具体用法?C++ checkint怎么用?C++ checkint使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了checkint函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: _exit
/***
Terminate the calling process.
@function _exit
@int status process exit status
@see _exit(2)
*/
static int
P_exit(lua_State *L)
{
pid_t ret = checkint(L, 1);
checknargs(L, 1);
_exit(ret);
return 0; /* Avoid a compiler warning (or possibly cause one
if the compiler's too clever, sigh). */
}
示例2: luaL_getn
int luaL_getn (lua_State *L, int t) {
int n;
t = abs_index(L, t);
lua_pushliteral(L, "n"); /* try t.n */
lua_rawget(L, t);
if ((n = checkint(L, 1)) >= 0) return n;
getsizes(L); /* else try sizes[t] */
lua_pushvalue(L, t);
lua_rawget(L, -2);
if ((n = checkint(L, 2)) >= 0) return n;
for (n = 1; ; n++) { /* else must count elements */
lua_rawgeti(L, t, n);
if (lua_isnil(L, -1)) break;
lua_pop(L, 1);
}
lua_pop(L, 1);
return n - 1;
}
示例3: slk_label
/***
Fetch the label for a soft label key.
@function slk_label
@int labnum
@treturn string current label for *labnum*
@see slk_label(3x)
*/
static int
Pslk_label(lua_State *L)
{
int labnum = checkint(L, 1);
#if LCURSES_POSIX_COMPLIANT
return pushstringresult(slk_label(labnum));
#else
return binding_notimplemented(L, "slk_label", "curses");
#endif
}
示例4: slk_init
/***
Initialise the soft label keys area.
This must be called before @{initscr}.
@function slk_init
@int fmt
@treturn bool `true`, if successful
@see slk_init(3x)
*/
static int
Pslk_init(lua_State *L)
{
int fmt = checkint(L, 1);
#if LCURSES_POSIX_COMPLIANT
return pushokresult(slk_init(fmt));
#else
return binding_notimplemented(L, "slk_init", "curses");
#endif
}
示例5: curs_set
/***
Change the visibility of the cursor.
@function curs_set
@int vis one of `0` (invisible), `1` (visible) or `2` (very visible)
@treturn[1] int previous cursor state
@return[2] nil if *vis* is not supported
@see curs_set(3x)
*/
static int
Pcurs_set(lua_State *L)
{
int vis = checkint(L, 1);
int state = curs_set(vis);
if (state == ERR)
return 0;
return pushintresult(state);
}
示例6: send
/***
Send a message from a socket.
@function send
@int fd socket descriptor to act on
@string buffer message bytes to send
@treturn[1] int number of bytes sent, if successful
@return[2] nil
@treturn[2] string error message
@treturn[2] int errnum
@see send(2)
*/
static int
Psend(lua_State *L)
{
int fd = checkint (L, 1);
size_t len;
const char *buf = luaL_checklstring(L, 2, &len);
checknargs(L, 2);
return pushresult(L, send(fd, buf, len, 0), "send");
}
示例7: clock_gettime
/***
Read a clock.
@function clock_gettime
@int clk name of clock, one of `CLOCK_REALTIME`, `CLOCK_PROCESS_CPUTIME_ID`,
`CLOCK_MONOTONIC` or `CLOCK_THREAD_CPUTIME_ID`
@treturn[1] PosixTimespec current value of *clk*, if successful
@return[2] nil
@treturn[2] string error message
@treturn[2] int errnum
@see clock_gettime(3)
*/
static int
Pclock_gettime(lua_State *L)
{
struct timespec ts;
int clk = checkint(L, 1);
checknargs(L, 1);
if (clock_gettime(clk, &ts) == -1)
return pusherror(L, "clock_gettime");
return pushtimespec(L, &ts);
}
示例8: localtime
/***
Convert epoch time value to a broken-down local time.
@function localtime
@int t seconds since epoch
@treturn PosixTm broken-down time
@see localtime(3)
@see mktime
*/
static int
Plocaltime(lua_State *L)
{
struct tm t;
time_t epoch = checkint(L, 1);
checknargs(L, 1);
if (localtime_r(&epoch, &t) == NULL)
return pusherror(L, "localtime");
return pushtm(L, &t);
}
示例9: clock_getres
/***
Find the precision of a clock.
@function clock_getres
@int clk name of clock, one of `CLOCK_REALTIME`, `CLOCK_PROCESS_CPUTIME_ID`,
`CLOCK_MONOTONIC` or `CLOCK_THREAD_CPUTIME_ID`
@treturn[1] PosixTimespec resolution of *clk*, if successful
@return[2] nil
@treturn[2] string error message
@treturn[2] int errnum
@see clock_getres(3)
*/
static int
Pclock_getres(lua_State *L)
{
struct timespec resolution;
int clk = checkint(L, 1);
checknargs(L, 1);
if (clock_getres(clk, &resolution) == -1)
return pusherror(L, "clock_getres");
return pushtimespec(L, &resolution);
}
示例10: all
/***
Bitwise OR of all (or selected) video attributes supported by the terminal.
@function termattrs
@int[opt] a terminal attribute bits
@treturn[1] bool `true`, if the terminal supports attribute *a*
@treturn[2] int bitarray of supported terminal attributes
@see termattrs(3x)
*/
static int
Ptermattrs(lua_State *L)
{
if (lua_gettop(L) > 0)
{
int a = checkint(L, 1);
return pushboolresult(termattrs() & a);
}
return pushintresult(termattrs());
}
示例11: checkch
static chtype
checkch(lua_State *L, int narg)
{
if (lua_isnumber(L, narg))
return (chtype)checkint(L, narg);
if (lua_isstring(L, narg))
return *lua_tostring(L, narg);
return argtypeerror(L, narg, "int or char");
}
示例12: fdopen
/***
Create a Lua file object from a file descriptor.
@function fdopen
@tparam int fd file descriptor
@tparam string mode the mode in which to open the file descriptor
@treturn[1] file file Lua file object *fd*, if successful
@return[2] nil
@treturn[2] string error message
@treturn[2] int errnum
@usage
local fdopen = require "posix.stdio".fdopen
local STDOUT_FILENO = require "posix.unistd".STDOUT_FILENO
stdout = fdopen (STDOUT_FILENO, "w")
*/
static int
Pfdopen(lua_State *L) /** fdopen(fd, mode) */
{
int fd = checkint(L, 1);
const char *mode = luaL_checkstring(L, 2);
checknargs(L, 2);
if (!pushfile(L, fd, mode))
return pusherror(L, "fdopen");
return 1;
}
示例13: l_sqlite3_column_info
static int l_sqlite3_column_info(lua_State * L, const char * (*info_func)(sqlite3_stmt*,int) )
{
const char * info = info_func(checkstmt_stmt(L, 1), checkint(L, 2));
if (info)
lua_pushstring(L, info);
else
lua_pushstring(L, "");
return 1;
}
示例14: ptsname
/***
Get the name of a slave pseudo-terminal
@function ptsname
@int fd descriptor returned by @{openpt}
@return[1] path name of the slave terminal device, if successful
@return[2] nil
@treturn[2] string error message
@treturn[2] int errnum
@see ptsname(3)
@see grantpt
@see unlockpt
*/
static int
Pptsname(lua_State *L)
{
int fd=checkint(L, 1);
const char* slave;
checknargs(L, 1);
slave = ptsname(fd);
if (!slave)
return pusherror(L, "getptsname");
return pushstringresult(slave);
}
示例15: connect
/***
Initiate a connection on a socket.
@function connect
@int fd socket descriptor to act on
@tparam sockaddr addr socket address
@treturn[1] int `0`, if successful
@return[2] nil
@treturn[2] string error message
@treturn[2] int errnum
@see connect(2)
*/
static int
Pconnect(lua_State *L)
{
struct sockaddr_storage sa;
socklen_t salen;
int fd = checkint(L, 1);
checknargs (L, 2);
if (sockaddr_from_lua(L, 2, &sa, &salen) != 0)
return pusherror(L, "not a valid IPv4 dotted-decimal or IPv6 address string");
return pushresult(L, connect(fd, (struct sockaddr *)&sa, salen), "connect");
}