551 { |
552 { |
552 abort(); |
553 abort(); |
553 return 0; |
554 return 0; |
554 } |
555 } |
555 |
556 |
|
557 int lc_uname(lua_State* L) |
|
558 { |
|
559 struct utsname uname_info; |
|
560 if(uname(&uname_info) != 0) |
|
561 { |
|
562 lua_pushstring(L, strerror(errno)); |
|
563 return 2; |
|
564 } |
|
565 lua_newtable(L); |
|
566 lua_pushstring(L, uname_info.sysname); |
|
567 lua_setfield(L, -2, "sysname"); |
|
568 lua_pushstring(L, uname_info.nodename); |
|
569 lua_setfield(L, -2, "nodename"); |
|
570 lua_pushstring(L, uname_info.release); |
|
571 lua_setfield(L, -2, "release"); |
|
572 lua_pushstring(L, uname_info.version); |
|
573 lua_setfield(L, -2, "version"); |
|
574 lua_pushstring(L, uname_info.machine); |
|
575 lua_setfield(L, -2, "machine"); |
|
576 return 1; |
|
577 } |
|
578 |
556 /* Register functions */ |
579 /* Register functions */ |
557 |
580 |
558 int luaopen_util_pposix(lua_State *L) |
581 int luaopen_util_pposix(lua_State *L) |
559 { |
582 { |
560 luaL_Reg exports[] = { |
583 luaL_Reg exports[] = { |
580 { "mkdir", lc_mkdir }, |
603 { "mkdir", lc_mkdir }, |
581 |
604 |
582 { "setrlimit", lc_setrlimit }, |
605 { "setrlimit", lc_setrlimit }, |
583 { "getrlimit", lc_getrlimit }, |
606 { "getrlimit", lc_getrlimit }, |
584 |
607 |
|
608 { "uname", lc_uname }, |
|
609 |
585 { NULL, NULL } |
610 { NULL, NULL } |
586 }; |
611 }; |
587 |
612 |
588 luaL_register(L, "pposix", exports); |
613 luaL_register(L, "pposix", exports); |
589 |
614 |