-------------------------------------------------------------------------*\ * Sets timeout values for IO operations * Lua Input: base, time [, mode] * time: time out value in seconds * mode: "b" for block timeout, "t" for total timeout. (default: b) \*-------------------------------------------------------------------------*/
| 159 | * mode: "b" for block timeout, "t" for total timeout. (default: b) |
| 160 | \*-------------------------------------------------------------------------*/ |
| 161 | int timeout_meth_settimeout(lua_State *L, p_timeout tm) { |
| 162 | double t = luaL_optnumber(L, 2, -1); |
| 163 | const char *mode = luaL_optstring(L, 3, "b"); |
| 164 | switch (*mode) { |
| 165 | case 'b': |
| 166 | tm->block = t; |
| 167 | break; |
| 168 | case 'r': case 't': |
| 169 | tm->total = t; |
| 170 | break; |
| 171 | default: |
| 172 | luaL_argcheck(L, 0, 3, "invalid timeout mode"); |
| 173 | break; |
| 174 | } |
| 175 | lua_pushnumber(L, 1); |
| 176 | return 1; |
| 177 | } |
| 178 | |
| 179 | /*=========================================================================*\ |
| 180 | * Test support functions |
no test coverage detected