=========================================================================*\ * Library functions \*=========================================================================*/ -------------------------------------------------------------------------*\ * Creates a master unix object \*-------------------------------------------------------------------------*/
| 322 | * Creates a master unix object |
| 323 | \*-------------------------------------------------------------------------*/ |
| 324 | static int global_create(lua_State *L) { |
| 325 | t_socket sock; |
| 326 | int err = socket_create(&sock, AF_UNIX, SOCK_STREAM, 0); |
| 327 | /* try to allocate a system socket */ |
| 328 | if (err == IO_DONE) { |
| 329 | /* allocate unix object */ |
| 330 | p_unix un = (p_unix) lua_newuserdata(L, sizeof(t_unix)); |
| 331 | /* set its type as master object */ |
| 332 | auxiliar_setclass(L, "unix{master}", -1); |
| 333 | /* initialize remaining structure fields */ |
| 334 | socket_setnonblocking(&sock); |
| 335 | un->sock = sock; |
| 336 | io_init(&un->io, (p_send) socket_send, (p_recv) socket_recv, |
| 337 | (p_error) socket_ioerror, &un->sock); |
| 338 | timeout_init(&un->tm, -1, -1); |
| 339 | buffer_init(&un->buf, &un->io, &un->tm); |
| 340 | return 1; |
| 341 | } else { |
| 342 | lua_pushnil(L); |
| 343 | lua_pushstring(L, socket_strerror(err)); |
| 344 | return 2; |
| 345 | } |
| 346 | } |
nothing calls this directly
no test coverage detected