getnetent_r

Section: C Library Functions (3)
Updated: 2025-06-28
Index JM Home Page roff page
 

名前

getnetent_r, getnetbyname_r, getnetbyaddr_r - ネットワークエントリーを 取得する (リエントラント版)  

ライブラリ

標準 C ライブラリ (libc,~-lc)  

書式

#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
 

説明

関数 getnetent_r(), getnetbyname_r(), getnetbyaddr_r() は、 それぞれ getnetent(3), getnetbyname(3), getnetbynumber(3) の リエントラント版である。 netent 構造体の返し方と、関数呼び出し時の引数と返り値が異なる。 このマニュアルページでは、リエントラントでない関数との違いだけを 説明する。

これらの関数は、関数の結果として静的に割り当てられた 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 に格納されていた値を返すのに使用される。  

返り値

成功すると、これらの関数は 0 を返す。エラーの場合、「エラー」の節の リストにある正のエラー番号のいずれかを返す。

エラーの場合、レコードが見つからなかった場合 (getnetbyname_r(), getnetbyaddr_r()) やこれ以上レコードがない場合 (getnetent_r())、 result には NULL が設定される。  

エラー

ENOENT
(getnetent_r()) データベースにこれ以上レコードがない。
ERANGE
buf が小さすぎる。もっと大きなバッファーにして(size を増やして) 再度呼び出すこと。
 

属性

この節で使用されている用語の説明は attributes(7) を参照のこと。
InterfaceAttributeValue
getnetent_r(), getnetbyname_r(), getnetbyaddr_r() Thread safetyMT-Safe locale
 

バージョン

Functions with similar names exist on some other systems, though typically with different calling signatures.  

標準規格

GNU.  

関連項目

getnetent(3), networks(5)


 

Index

名前
ライブラリ
書式
説明
返り値
エラー
属性
バージョン
標準規格
関連項目

This document was created by man2html, using the manual pages.