Moved mch_get_host_name and renamed it to os_get_hostanme

This commit is contained in:
Stefan Hoffmann
2014-04-05 13:51:48 +02:00
committed by Thiago de Arruda
parent a8013f2bb1
commit e76249c813
8 changed files with 44 additions and 36 deletions

View File

@@ -9,6 +9,7 @@ const char *os_getenv(const char *name);
int os_setenv(const char *name, const char *value, int override);
char *os_getenvname_at_index(size_t index);
long os_get_pid(void);
void os_get_hostname(char *hostname, size_t len);
]]
NULL = ffi.cast 'void*', 0
@@ -104,3 +105,13 @@ describe 'env function', ->
-- /proc is not avaliable on all systems, test if pid is nonzero.
eq true, (env.os_get_pid! > 0)
describe 'os_get_hostname', ->
it 'returns the hostname', ->
handle = io.popen 'hostname'
hostname = handle\read '*l'
handle\close!
hostname_buf = cstr 255, ''
env.os_get_hostname hostname_buf, 255
eq hostname, (ffi.string hostname_buf)