mirror of
https://github.com/X11Libre/xserver.git
synced 2026-03-24 01:34:11 +00:00
This little helper does the OS specific part for gethostname() calls. It's putting the result into a fixed-length struct and making sure it's properly filled and the string is always zero-terminated. Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
24 lines
568 B
C
24 lines
568 B
C
/* SPDX-License-Identifier: MIT OR X11
|
|
*
|
|
* Copyright © 2024 Enrico Weigelt, metux IT consult <info@metux.net>
|
|
*/
|
|
#ifndef _XSERVER_OS_XHOSTNAME_H_
|
|
#define _XSERVER_OS_XHOSTNAME_H_
|
|
|
|
#define XHOSTNAME_MAX 2048
|
|
|
|
struct xhostname {
|
|
char name[XHOSTNAME_MAX];
|
|
};
|
|
|
|
/*
|
|
* retrieve host's nodename. basically a safer way of gethostname() / uname()
|
|
* making sure that the nodename is always zero-terminated.
|
|
*
|
|
* @hn pointer to struct xhostname that will be filled
|
|
* @return 0 on success
|
|
*/
|
|
int xhostname(struct xhostname* hn);
|
|
|
|
#endif /* _XSERVER_OS_XHOSTNAME_H_ */
|