diff options
| author | Diego Nehab <diego@tecgraf.puc-rio.br> | 2004-01-24 02:47:24 +0000 |
|---|---|---|
| committer | Diego Nehab <diego@tecgraf.puc-rio.br> | 2004-01-24 02:47:24 +0000 |
| commit | 62a4c505e488c714e8795ea85564504562d30301 (patch) | |
| tree | f270f53f26905b7275cea172e52ebc269a41c695 /src/luasocket.c | |
| parent | 0c9f420a3549df3fb331bb24157b65a3301641d4 (diff) | |
| download | luasocket-62a4c505e488c714e8795ea85564504562d30301.tar.gz luasocket-62a4c505e488c714e8795ea85564504562d30301.tar.bz2 luasocket-62a4c505e488c714e8795ea85564504562d30301.zip | |
Working on the manual...
Making better tests for error messages.
Changed a few names.
Moved gethostname to inet.c.
Diffstat (limited to 'src/luasocket.c')
| -rw-r--r-- | src/luasocket.c | 27 |
1 files changed, 0 insertions, 27 deletions
diff --git a/src/luasocket.c b/src/luasocket.c index 73583a8..bfe71c2 100644 --- a/src/luasocket.c +++ b/src/luasocket.c | |||
| @@ -38,15 +38,8 @@ | |||
| 38 | /*=========================================================================*\ | 38 | /*=========================================================================*\ |
| 39 | * Declarations | 39 | * Declarations |
| 40 | \*=========================================================================*/ | 40 | \*=========================================================================*/ |
| 41 | static int global_gethostname(lua_State *L); | ||
| 42 | static int base_open(lua_State *L); | 41 | static int base_open(lua_State *L); |
| 43 | 42 | ||
| 44 | /* functions in library namespace */ | ||
| 45 | static luaL_reg func[] = { | ||
| 46 | {"gethostname", global_gethostname}, | ||
| 47 | {NULL, NULL} | ||
| 48 | }; | ||
| 49 | |||
| 50 | /*-------------------------------------------------------------------------*\ | 43 | /*-------------------------------------------------------------------------*\ |
| 51 | * Setup basic stuff. | 44 | * Setup basic stuff. |
| 52 | \*-------------------------------------------------------------------------*/ | 45 | \*-------------------------------------------------------------------------*/ |
| @@ -70,30 +63,10 @@ static int base_open(lua_State *L) | |||
| 70 | lua_pushstring(L, "LUASOCKET_LIBNAME"); | 63 | lua_pushstring(L, "LUASOCKET_LIBNAME"); |
| 71 | lua_pushstring(L, LUASOCKET_LIBNAME); | 64 | lua_pushstring(L, LUASOCKET_LIBNAME); |
| 72 | lua_settable(L, LUA_GLOBALSINDEX); | 65 | lua_settable(L, LUA_GLOBALSINDEX); |
| 73 | /* define library functions */ | ||
| 74 | luaL_openlib(L, LUASOCKET_LIBNAME, func, 0); | ||
| 75 | lua_pop(L, 1); | ||
| 76 | return 0; | 66 | return 0; |
| 77 | } | 67 | } |
| 78 | 68 | ||
| 79 | /*-------------------------------------------------------------------------*\ | 69 | /*-------------------------------------------------------------------------*\ |
| 80 | * Gets the host name | ||
| 81 | \*-------------------------------------------------------------------------*/ | ||
| 82 | static int global_gethostname(lua_State *L) | ||
| 83 | { | ||
| 84 | char name[257]; | ||
| 85 | name[256] = '\0'; | ||
| 86 | if (gethostname(name, 256) < 0) { | ||
| 87 | lua_pushnil(L); | ||
| 88 | lua_pushstring(L, "gethostname failed"); | ||
| 89 | return 2; | ||
| 90 | } else { | ||
| 91 | lua_pushstring(L, name); | ||
| 92 | return 1; | ||
| 93 | } | ||
| 94 | } | ||
| 95 | |||
| 96 | /*-------------------------------------------------------------------------*\ | ||
| 97 | * Initializes all library modules. | 70 | * Initializes all library modules. |
| 98 | \*-------------------------------------------------------------------------*/ | 71 | \*-------------------------------------------------------------------------*/ |
| 99 | LUASOCKET_API int luaopen_socket(lua_State *L) | 72 | LUASOCKET_API int luaopen_socket(lua_State *L) |
