#include <netdb.h>
int getnetent_r(size_t size;
struct netent *restrict result_buf,
char buf[restrict size], size_t size,
struct netent **restrict result,
int *restrict h_errnop);
int getnetbyname_r(size_t size;
const char *restrict name,
struct netent *restrict result_buf,
char buf[restrict size], size_t size,
struct netent **restrict result,
int *restrict h_errnop);
int getnetbyaddr_r(size_t size;
uint32_t net, int type,
struct netent *restrict result_buf,
char buf[restrict size], size_t size,
struct netent **restrict result,
int *restrict h_errnop);
glibc 向けの機能検査マクロの要件 (feature_test_macros(7) 参照):
getnetent_r(), getnetbyname_r(), getnetbyaddr_r():
glibc 2.19 以降:
_DEFAULT_SOURCE
glibc 2.19 以前:
_BSD_SOURCE || _SVID_SOURCE
これらの関数は、関数の結果として静的に割り当てられた netent 構造体 へのポインターを返すのではなく、 netent 構造体を result_buf が 指す場所にコピーする。
The buf array is used to store the string fields pointed to by the returned netent structure. (The nonreentrant functions allocate these strings in static storage.) The size of this array is specified in size. If buf is too small, the call fails with the error ERANGE, and the caller must try again with a larger buffer. (A buffer of size 1024 bytes should be sufficient for most applications.)
関数呼び出しでネットワークレコードの取得に成功すると、 *result は result_buf を指すように設定される。 それ以外の場合は *result に NULL が設定される。
h_errnop が指すバッファーは、リエントラントでない関数では グローバル変数 h_errno に格納されていた値を返すのに使用される。
エラーの場合、レコードが見つからなかった場合 (getnetbyname_r(), getnetbyaddr_r()) やこれ以上レコードがない場合 (getnetent_r())、 result には NULL が設定される。
| Interface | Attribute | Value |
| getnetent_r(), getnetbyname_r(), getnetbyaddr_r() | Thread safety | MT-Safe locale |