No description
Find a file
2023-07-20 21:26:03 -05:00
examples initial version 2020-11-03 22:08:44 -06:00
src initial version 2020-11-03 22:08:44 -06:00
tests initial version 2020-11-03 22:08:44 -06:00
.gitignore Initial commit 2020-11-03 22:05:04 -06:00
LICENSE Initial commit 2020-11-03 22:05:04 -06:00
oshostname.nimble initial version 2020-11-03 22:08:44 -06:00
README.md Update README.md 2023-07-20 21:26:03 -05:00

oshostname

Get the current hostname with gethostname(2)

Support platforms

Currently, just any that support gethostname() similarly to Linux.

Why even use this?

EDIT: don't. I don't know how i missed it, but std/nativeosckets has getHostname() already, for windows and Posix platforms, including macOS.

gethostname() has this gotcha: if the configured hostname is longer than the buffer given to it, then the buffer might not be NUL terminated. This library takes the small amount of care required to avoid this case.

In the future it might also grow support for other platforms.

Usage

Add the following to your .nimble file:

requires "oshostname >= 0.1.0"

Then use the provided hostname() proc:

import oshostname, options
echo hostname().get

In this code, if gethostbyname() fails, that .get will fail with an UnpackDefect.