=========================================================================*\ * Library functions \*=========================================================================*/ -------------------------------------------------------------------------*\ * Creates a master unixstream object \*-------------------------------------------------------------------------*/
| 332 | * Creates a master unixstream object |
| 333 | \*-------------------------------------------------------------------------*/ |
| 334 | static int global_create(lua_State *L) { |
| 335 | t_socket sock; |
| 336 | int err = socket_create(&sock, AF_UNIX, SOCK_STREAM, 0); |
| 337 | /* try to allocate a system socket */ |
| 338 | if (err == IO_DONE) { |
| 339 | /* allocate unixstream object */ |
| 340 | p_unix un = (p_unix) lua_newuserdata(L, sizeof(t_unix)); |
| 341 | /* set its type as master object */ |
| 342 | auxiliar_setclass(L, "unixstream{master}", -1); |
| 343 | /* initialize remaining structure fields */ |
| 344 | socket_setnonblocking(&sock); |
| 345 | un->sock = sock; |
| 346 | io_init(&un->io, (p_send) socket_send, (p_recv) socket_recv, |
| 347 | (p_error) socket_ioerror, &un->sock); |
| 348 | timeout_init(&un->tm, -1, -1); |
| 349 | buffer_init(&un->buf, &un->io, &un->tm); |
| 350 | return 1; |
| 351 | } else { |
| 352 | lua_pushnil(L); |
| 353 | lua_pushstring(L, socket_strerror(err)); |
| 354 | return 2; |
| 355 | } |
| 356 | } |
| 357 | |
| 358 | #endif |
nothing calls this directly
no test coverage detected