Revisión | fd8c9a832178ecc0f57d47b762d26b76226038e2 (tree) |
---|---|
Tiempo | 2012-05-08 02:23:02 |
Autor | Akihiro MOTOKI <amotoki@gmai...> |
Commiter | Akihiro MOTOKI |
(split) LDP: Add new releases for LDP v3.40.
@@ -0,0 +1,257 @@ | ||
1 | +.\" Copyright (C) 2006 Michael Kerrisk | |
2 | +.\" and Copyright (C) 2008 Linux Foundation, written by Michael Kerrisk | |
3 | +.\" <mtk.manpages@gmail.com> | |
4 | +.\" | |
5 | +.\" Permission is granted to make and distribute verbatim copies of this | |
6 | +.\" manual provided the copyright notice and this permission notice are | |
7 | +.\" preserved on all copies. | |
8 | +.\" | |
9 | +.\" Permission is granted to copy and distribute modified versions of this | |
10 | +.\" manual under the conditions for verbatim copying, provided that the | |
11 | +.\" entire resulting derived work is distributed under the terms of a | |
12 | +.\" permission notice identical to this one. | |
13 | +.\" | |
14 | +.\" Since the Linux kernel and libraries are constantly changing, this | |
15 | +.\" manual page may be incorrect or out-of-date. The author(s) assume no | |
16 | +.\" responsibility for errors or omissions, or for damages resulting from | |
17 | +.\" the use of the information contained herein. The author(s) may not | |
18 | +.\" have taken the same level of care in the production of this manual, | |
19 | +.\" which is licensed free of charge, as they might when working | |
20 | +.\" professionally. | |
21 | +.\" | |
22 | +.\" Formatted or processed versions of this manual, if unaccompanied by | |
23 | +.\" the source, must acknowledge the copyright and authors of this work. | |
24 | +.\" | |
25 | +.\"******************************************************************* | |
26 | +.\" | |
27 | +.\" This file was generated with po4a. Translate the source file. | |
28 | +.\" | |
29 | +.\"******************************************************************* | |
30 | +.TH CPU_SET 3 2012\-03\-15 Linux "Linux Programmer's Manual" | |
31 | +.SH 名前 | |
32 | +CPU_SET, CPU_CLR, CPU_ISSET, CPU_ZERO, CPU_COUNT, CPU_AND, CPU_OR, CPU_XOR, | |
33 | +CPU_EQUAL, CPU_ALLOC, CPU_ALLOC_SIZE, CPU_FREE, CPU_SET_S, CPU_CLR_S, | |
34 | +CPU_ISSET_S, CPU_ZERO_S, CPU_COUNT_S, CPU_AND_S, CPU_OR_S, CPU_XOR_S, | |
35 | +CPU_EQUAL_S \- macros for manipulating CPU sets | |
36 | +.SH 書式 | |
37 | +.nf | |
38 | +\fB#define _GNU_SOURCE\fP /* feature_test_macros(7) 参照 */ | |
39 | +\fB#include <sched.h>\fP | |
40 | +.sp | |
41 | +\fBvoid CPU_ZERO(cpu_set_t *\fP\fIset\fP\fB);\fP | |
42 | +.sp | |
43 | +\fBvoid CPU_SET(int \fP\fIcpu\fP\fB, cpu_set_t *\fP\fIset\fP\fB);\fP | |
44 | +\fBvoid CPU_CLR(int \fP\fIcpu\fP\fB, cpu_set_t *\fP\fIset\fP\fB);\fP | |
45 | +\fBint CPU_ISSET(int \fP\fIcpu\fP\fB, cpu_set_t *\fP\fIset\fP\fB);\fP | |
46 | +.sp | |
47 | +\fBint CPU_COUNT(cpu_set_t *\fP\fIset\fP\fB);\fP | |
48 | +.sp | |
49 | +\fBvoid CPU_AND(cpu_set_t *\fP\fIdestset\fP\fB,\fP | |
50 | +\fB cpu_set_t *\fP\fIsrcset1\fP\fB, cpu_set_t *\fP\fIsrcset2\fP\fB);\fP | |
51 | +\fBvoid CPU_OR(cpu_set_t *\fP\fIdestset\fP\fB,\fP | |
52 | +\fB cpu_set_t *\fP\fIsrcset1\fP\fB, cpu_set_t *\fP\fIsrcset2\fP\fB);\fP | |
53 | +\fBvoid CPU_XOR(cpu_set_t *\fP\fIdestset\fP\fB,\fP | |
54 | +\fB cpu_set_t *\fP\fIsrcset1\fP\fB, cpu_set_t *\fP\fIsrcset2\fP\fB);\fP | |
55 | +.sp | |
56 | +\fBint CPU_EQUAL(cpu_set_t *\fP\fIset1\fP\fB, cpu_set_t *\fP\fIset2\fP\fB);\fP | |
57 | +.sp | |
58 | +\fBcpu_set_t *CPU_ALLOC(int \fP\fInum_cpus\fP\fB);\fP | |
59 | +\fBvoid CPU_FREE(cpu_set_t *\fP\fIset\fP\fB);\fP | |
60 | +\fBsize_t CPU_ALLOC_SIZE(int \fP\fInum_cpus\fP\fB);\fP | |
61 | +.sp | |
62 | +\fBvoid CPU_ZERO_S(size_t \fP\fIsetsize\fP\fB, cpu_set_t *\fP\fIset\fP\fB);\fP | |
63 | +.sp | |
64 | +\fBvoid CPU_SET_S(int \fP\fIcpu\fP\fB, size_t \fP\fIsetsize\fP\fB, cpu_set_t *\fP\fIset\fP\fB);\fP | |
65 | +\fBvoid CPU_CLR_S(int \fP\fIcpu\fP\fB, size_t \fP\fIsetsize\fP\fB, cpu_set_t *\fP\fIset\fP\fB);\fP | |
66 | +\fBint CPU_ISSET_S(int \fP\fIcpu\fP\fB, size_t \fP\fIsetsize\fP\fB, cpu_set_t *\fP\fIset\fP\fB);\fP | |
67 | +.sp | |
68 | +\fBint CPU_COUNT_S(size_t \fP\fIsetsize\fP\fB, cpu_set_t *\fP\fIset\fP\fB);\fP | |
69 | +.sp | |
70 | +\fBvoid CPU_AND_S(size_t \fP\fIsetsize\fP\fB, cpu_set_t *\fP\fIdestset\fP\fB,\fP | |
71 | +\fB cpu_set_t *\fP\fIsrcset1\fP\fB, cpu_set_t *\fP\fIsrcset2\fP\fB);\fP | |
72 | +\fBvoid CPU_OR_S(size_t \fP\fIsetsize\fP\fB, cpu_set_t *\fP\fIdestset\fP\fB,\fP | |
73 | +\fB cpu_set_t *\fP\fIsrcset1\fP\fB, cpu_set_t *\fP\fIsrcset2\fP\fB);\fP | |
74 | +\fBvoid CPU_XOR_S(size_t \fP\fIsetsize\fP\fB, cpu_set_t *\fP\fIdestset\fP\fB,\fP | |
75 | +\fB cpu_set_t *\fP\fIsrcset1\fP\fB, cpu_set_t *\fP\fIsrcset2\fP\fB);\fP | |
76 | +.sp | |
77 | +\fBint CPU_EQUAL_S(size_t \fP\fIsetsize\fP\fB, cpu_set_t *\fP\fIset1\fP\fB, cpu_set_t *\fP\fIset2\fP\fB);\fP | |
78 | +.fi | |
79 | +.SH 説明 | |
80 | +The \fIcpu_set_t\fP data structure represents a set of CPUs. CPU sets are used | |
81 | +by \fBsched_setaffinity\fP(2) and similar interfaces. | |
82 | + | |
83 | +The \fIcpu_set_t\fP data type is implemented as a bitset. However, the data | |
84 | +structure treated as considered opaque: all manipulation of CPU sets should | |
85 | +be done via the macros described in this page. | |
86 | + | |
87 | +The following macros are provided to operate on the CPU set \fIset\fP: | |
88 | +.TP 17 | |
89 | +\fBCPU_ZERO\fP() | |
90 | +Clears \fIset\fP, so that it contains no CPUs. | |
91 | +.TP | |
92 | +\fBCPU_SET\fP() | |
93 | +Add CPU \fIcpu\fP to \fIset\fP. | |
94 | +.TP | |
95 | +\fBCPU_CLR\fP() | |
96 | +Remove CPU \fIcpu\fP from \fIset\fP. | |
97 | +.TP | |
98 | +\fBCPU_ISSET\fP() | |
99 | +Test to see if CPU \fIcpu\fP is a member of \fIset\fP. | |
100 | +.TP | |
101 | +\fBCPU_COUNT\fP() | |
102 | +Return the number of CPUs in \fIset\fP. | |
103 | +.PP | |
104 | +Where a \fIcpu\fP argument is specified, it should not produce side effects, | |
105 | +since the above macros may evaluate the argument more than once. | |
106 | +.PP | |
107 | +The first available CPU on the system corresponds to a \fIcpu\fP value of 0, | |
108 | +the next CPU corresponds to a \fIcpu\fP value of 1, and so on. The constant | |
109 | +\fBCPU_SETSIZE\fP (currently 1024) specifies a value one greater than the | |
110 | +maximum CPU number that can be stored in \fIcpu_set_t\fP. | |
111 | + | |
112 | +The following macros perform logical operations on CPU sets: | |
113 | +.TP 17 | |
114 | +\fBCPU_AND\fP() | |
115 | +Store the intersection of the sets \fIsrcset1\fP and \fIsrcset2\fP in \fIdestset\fP | |
116 | +(which may be one of the source sets). | |
117 | +.TP | |
118 | +\fBCPU_OR\fP() | |
119 | +Store the union of the sets \fIsrcset1\fP and \fIsrcset2\fP in \fIdestset\fP (which | |
120 | +may be one of the source sets). | |
121 | +.TP | |
122 | +\fBCPU_XOR\fP() | |
123 | +Store the XOR of the sets \fIsrcset1\fP and \fIsrcset2\fP in \fIdestset\fP (which may | |
124 | +be one of the source sets). The XOR means the set of CPUs that are in | |
125 | +either \fIsrcset1\fP or \fIsrcset2\fP, but not both. | |
126 | +.TP | |
127 | +\fBCPU_EQUAL\fP() | |
128 | +Test whether two CPU set contain exactly the same CPUs. | |
129 | +.SS "Dynamically sized CPU sets" | |
130 | +Because some applications may require the ability to dynamically size CPU | |
131 | +sets (e.g., to allocate sets larger than that defined by the standard | |
132 | +\fIcpu_set_t\fP data type), glibc nowadays provides a set of macros to support | |
133 | +this. | |
134 | + | |
135 | +The following macros are used to allocate and deallocate CPU sets: | |
136 | +.TP 17 | |
137 | +\fBCPU_ALLOC\fP() | |
138 | +Allocate a CPU set large enough to hold CPUs in the range 0 to | |
139 | +\fInum_cpus\-1\fP. | |
140 | +.TP | |
141 | +\fBCPU_ALLOC_SIZE\fP() | |
142 | +Return the size in bytes of the CPU set that would be needed to hold CPUs in | |
143 | +the range 0 to \fInum_cpus\-1\fP. This macro provides the value that can be | |
144 | +used for the \fIsetsize\fP argument in the \fBCPU_*_S\fP() macros described | |
145 | +below. | |
146 | +.TP | |
147 | +\fBCPU_FREE\fP() | |
148 | +Free a CPU set previously allocated by \fBCPU_ALLOC\fP(). | |
149 | +.PP | |
150 | +The macros whose names end with "_S" are the analogs of the similarly named | |
151 | +macros without the suffix. These macros perform the same tasks as their | |
152 | +analogs, but operate on the dynamically allocated CPU set(s) whose size is | |
153 | +\fIsetsize\fP bytes. | |
154 | +.SH 返り値 | |
155 | +\fBCPU_ISSET\fP() and \fBCPU_ISSET_S\fP() return nonzero if \fIcpu\fP is in \fIset\fP; | |
156 | +otherwise, it returns 0. | |
157 | + | |
158 | +\fBCPU_COUNT\fP() and \fBCPU_COUNT_S\fP() return the number of CPUs in \fIset\fP. | |
159 | + | |
160 | +\fBCPU_EQUAL\fP() and \fBCPU_EQUAL_S\fP() return nonzero if the two CPU sets are | |
161 | +equal; otherwise it returns 0. | |
162 | + | |
163 | +\fBCPU_ALLOC\fP() returns a pointer on success, or NULL on failure. (Errors | |
164 | +are as for \fBmalloc\fP(3).) | |
165 | + | |
166 | +\fBCPU_ALLOC_SIZE\fP() returns the number of bytes required to store a CPU set | |
167 | +of the specified cardinality. | |
168 | + | |
169 | +The other functions do not return a value. | |
170 | +.SH バージョン | |
171 | +The \fBCPU_ZERO\fP(), \fBCPU_SET\fP(), \fBCPU_CLR\fP(), and \fBCPU_ISSET\fP() macros | |
172 | +were added in glibc 2.3.3. | |
173 | + | |
174 | +\fBCPU_COUNT\fP() first appeared in glibc 2.6. | |
175 | + | |
176 | +\fBCPU_AND\fP(), \fBCPU_OR\fP(), \fBCPU_XOR\fP(), \fBCPU_EQUAL\fP(), \fBCPU_ALLOC\fP(), | |
177 | +\fBCPU_ALLOC_SIZE\fP(), \fBCPU_FREE\fP(), \fBCPU_ZERO_S\fP(), \fBCPU_SET_S\fP(), | |
178 | +\fBCPU_CLR_S\fP(), \fBCPU_ISSET_S\fP(), \fBCPU_AND_S\fP(), \fBCPU_OR_S\fP(), | |
179 | +\fBCPU_XOR_S\fP(), and \fBCPU_EQUAL_S\fP() first appeared in glibc 2.7. | |
180 | +.SH 準拠 | |
181 | +These interfaces are Linux\-specific. | |
182 | +.SH 注意 | |
183 | +To duplicate a CPU set, use \fBmemcpy\fP(3). | |
184 | + | |
185 | +Since CPU sets are bitsets allocated in units of long words, the actual | |
186 | +number of CPUs in a dynamically allocated CPU set will be rounded up to the | |
187 | +next multiple of \fIsizeof(unsigned long)\fP. An application should consider | |
188 | +the contents of these extra bits to be undefined. | |
189 | + | |
190 | +Notwithstanding the similarity in the names, note that the constant | |
191 | +\fBCPU_SETSIZE\fP indicates the number of CPUs in the \fIcpu_set_t\fP data type | |
192 | +(thus, it is effectively a count of bits in the bitset), while the | |
193 | +\fIsetsize\fP argument of the \fBCPU_*_S\fP() macros is a size in bytes. | |
194 | + | |
195 | +The data types for arguments and return values shown in the SYNOPSIS are | |
196 | +hints what about is expected in each case. However, since these interfaces | |
197 | +are implemented as macros, the compiler won't necessarily catch all type | |
198 | +errors if you violate the suggestions. | |
199 | +.SH バグ | |
200 | +.\" http://sourceware.org/bugzilla/show_bug.cgi?id=7029 | |
201 | +On 32\-bit platforms with glibc 2.8 and earlier, \fBCPU_ALLOC\fP() allocates | |
202 | +twice as much space as is required, and \fBCPU_ALLOC_SIZE\fP() returns a value | |
203 | +twice as large as it should. This bug should not affect the semantics of a | |
204 | +program, but does result in wasted memory and less efficient operation of | |
205 | +the macros that operate on dynamically allocated CPU sets. These bugs are | |
206 | +fixed in glibc 2.9. | |
207 | +.SH EXAMPLE | |
208 | +The following program demonstrates the use of some of the macros used for | |
209 | +dynamically allocated CPU sets. | |
210 | + | |
211 | +.nf | |
212 | +#define _GNU_SOURCE | |
213 | +#include <sched.h> | |
214 | +#include <stdlib.h> | |
215 | +#include <unistd.h> | |
216 | +#include <stdio.h> | |
217 | +#include <assert.h> | |
218 | + | |
219 | +int | |
220 | +main(int argc, char *argv[]) | |
221 | +{ | |
222 | + cpu_set_t *cpusetp; | |
223 | + size_t size; | |
224 | + int num_cpus, cpu; | |
225 | + | |
226 | + if (argc < 2) { | |
227 | + fprintf(stderr, "Usage: %s <num\-cpus>\en", argv[0]); | |
228 | + exit(EXIT_FAILURE); | |
229 | + } | |
230 | + | |
231 | + num_cpus = atoi(argv[1]); | |
232 | + | |
233 | + cpusetp = CPU_ALLOC(num_cpus); | |
234 | + if (cpusetp == NULL) { | |
235 | + perror("CPU_ALLOC"); | |
236 | + exit(EXIT_FAILURE); | |
237 | + } | |
238 | + | |
239 | + size = CPU_ALLOC_SIZE(num_cpus); | |
240 | + | |
241 | + CPU_ZERO_S(size, cpusetp); | |
242 | + for (cpu = 0; cpu < num_cpus; cpu += 2) | |
243 | + CPU_SET_S(cpu, size, cpusetp); | |
244 | + | |
245 | + printf("CPU_COUNT() of set: %d\en", CPU_COUNT_S(size, cpusetp)); | |
246 | + | |
247 | + CPU_FREE(cpusetp); | |
248 | + exit(EXIT_SUCCESS); | |
249 | +} | |
250 | +.fi | |
251 | +.SH 関連項目 | |
252 | +\fBsched_setaffinity\fP(2), \fBpthread_attr_setaffinity_np\fP(3), | |
253 | +\fBpthread_setaffinity_np\fP(3), \fBcpuset\fP(7) | |
254 | +.SH この文書について | |
255 | +この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 3.40 の一部 | |
256 | +である。プロジェクトの説明とバグ報告に関する情報は | |
257 | +http://www.kernel.org/doc/man\-pages/ に書かれている。 |
@@ -0,0 +1,116 @@ | ||
1 | +.\" Copyright 2008, Linux Foundation, written by Michael Kerrisk | |
2 | +.\" <mtk.manpages@gmail.com> | |
3 | +.\" | |
4 | +.\" Permission is granted to make and distribute verbatim copies of this | |
5 | +.\" manual provided the copyright notice and this permission notice are | |
6 | +.\" preserved on all copies. | |
7 | +.\" | |
8 | +.\" Permission is granted to copy and distribute modified versions of this | |
9 | +.\" manual under the conditions for verbatim copying, provided that the | |
10 | +.\" entire resulting derived work is distributed under the terms of a | |
11 | +.\" permission notice identical to this one. | |
12 | +.\" | |
13 | +.\" Since the Linux kernel and libraries are constantly changing, this | |
14 | +.\" manual page may be incorrect or out-of-date. The author(s) assume no | |
15 | +.\" responsibility for errors or omissions, or for damages resulting from | |
16 | +.\" the use of the information contained herein. The author(s) may not | |
17 | +.\" have taken the same level of care in the production of this manual, | |
18 | +.\" which is licensed free of charge, as they might when working | |
19 | +.\" professionally. | |
20 | +.\" | |
21 | +.\" Formatted or processed versions of this manual, if unaccompanied by | |
22 | +.\" the source, must acknowledge the copyright and authors of this work. | |
23 | +.\" | |
24 | +.\"******************************************************************* | |
25 | +.\" | |
26 | +.\" This file was generated with po4a. Translate the source file. | |
27 | +.\" | |
28 | +.\"******************************************************************* | |
29 | +.TH GETNETENT_R 3 2010\-09\-10 GNU "Linux Programmer's Manual" | |
30 | +.SH 名前 | |
31 | +getnetent_r, getnetbyname_r, getnetbyaddr_r \- ネットワークエントリを | |
32 | +取得する (リエントラント版) | |
33 | +.SH 書式 | |
34 | +.nf | |
35 | +\fB#include <netdb.h>\fP | |
36 | +.sp | |
37 | +\fBint getnetent_r(struct netent *\fP\fIresult_buf\fP\fB, char *\fP\fIbuf\fP\fB,\fP | |
38 | +\fB size_t \fP\fIbuflen\fP\fB, struct netent **\fP\fIresult\fP\fB,\fP | |
39 | +\fB int *\fP\fIh_errnop\fP\fB);\fP | |
40 | +.sp | |
41 | +\fBint getnetbyname_r(const char *\fP\fIname\fP\fB,\fP | |
42 | +\fB struct netent *\fP\fIresult_buf\fP\fB, char *\fP\fIbuf\fP\fB,\fP | |
43 | +\fB size_t \fP\fIbuflen\fP\fB, struct netent **\fP\fIresult\fP\fB,\fP | |
44 | +\fB int *\fP\fIh_errnop\fP\fB);\fP | |
45 | +.sp | |
46 | +\fBint getnetbyaddr_r(uint32_t \fP\fInet\fP\fB, int \fP\fItype\fP\fB,\fP | |
47 | +\fB struct netent *\fP\fIresult_buf\fP\fB, char *\fP\fIbuf\fP\fB,\fP | |
48 | +\fB size_t \fP\fIbuflen\fP\fB, struct netent **\fP\fIresult\fP\fB,\fP | |
49 | +\fB int *\fP\fIh_errnop\fP\fB);\fP | |
50 | +.sp | |
51 | +.fi | |
52 | +.in -4n | |
53 | +glibc 向けの機能検査マクロの要件 (\fBfeature_test_macros\fP(7) 参照): | |
54 | +.ad l | |
55 | +.in | |
56 | +.sp | |
57 | +\fBgetnetent_r\fP(), \fBgetnetbyname_r\fP(), \fBgetnetbyaddr_r\fP(): | |
58 | +.RS 4 | |
59 | +_BSD_SOURCE || _SVID_SOURCE | |
60 | +.RE | |
61 | +.ad b | |
62 | +.SH 説明 | |
63 | +関数 \fBgetnetent_r\fP(), \fBgetnetbyname_r\fP(), \fBgetnetbyaddr_r\fP() は、 | |
64 | +それぞれ \fBgetnetent\fP(3), \fBgetnetbyname\fP(3), \fBgetnetbynumber\fP(3) の | |
65 | +リエントラント版である。 | |
66 | +\fInetent\fP 構造体の返し方と、関数呼び出し時の引き数と返り値が異なる。 | |
67 | +このマニュアルページでは、リエントラントでない関数との違いだけを | |
68 | +説明する。 | |
69 | + | |
70 | +これらの関数は、関数の結果として静的に割り当てられた \fInetent\fP 構造体 | |
71 | +へのポインタを返すのではなく、 \fInetent\fP 構造体を \fIresult_buf\fP が | |
72 | +指す場所にコピーする。 | |
73 | + | |
74 | +.\" I can find no information on the required/recommended buffer size; | |
75 | +.\" the nonreentrant functions use a 1024 byte buffer -- mtk. | |
76 | +配列 \fIbuf\fP は、返される \fInetent\fP 構造体が指す文字列フィールドを格納 | |
77 | +するのに使用される (リエントラントでない関数の場合は、 | |
78 | +これらの文字列は静的な領域に格納される)。 | |
79 | +この配列の大きさは \fIbuflen\fP で指定される。 | |
80 | +\fIbuf\fP が小さすぎる場合、関数呼び出しはエラー \fBERANGE\fP で失敗し、 | |
81 | +呼び出し側ではもっと大きなバッファで再度呼び出す必要がある (ほとんどの | |
82 | +アプリケーションでは、長さ 1024 バイトのバッファで十分なはずである)。 | |
83 | + | |
84 | +関数呼び出しでネットワークレコードの取得に成功すると、 | |
85 | +\fI*result\fP は \fIresult_buf\fP を指すように設定される。 | |
86 | +それ以外の場合は \fI*result\fP に NULL が設定される。 | |
87 | + | |
88 | +.\" getnetent.3 doesn't document any use of h_errno, but nevertheless | |
89 | +.\" the nonreentrant functions no seem to set h_errno. | |
90 | +\fIh_errnop\fP が指すバッファは、リエントラントでない関数では | |
91 | +グローバル変数 \fIh_errno\fP に格納されていた値を返すのに使用される。 | |
92 | +.SH 返り値 | |
93 | +成功すると、これらの関数は 0 を返す。エラーの場合、「エラー」の節の | |
94 | +リストにある正のエラー番号のいずれかを返す。 | |
95 | + | |
96 | +エラーの場合、レコードが見つからなかった場合 (\fBgetnetbyname_r\fP(), | |
97 | +\fBgetnetbyaddr_r\fP()) やこれ以上レコードがない場合 (\fBgetnetent_r\fP())、 | |
98 | +\fIresult\fP には NULL が設定される。 | |
99 | +.SH エラー | |
100 | +.TP | |
101 | +\fBENOENT\fP | |
102 | +(\fBgetnetent_r\fP()) データベースにこれ以上レコードがない。 | |
103 | +.TP | |
104 | +\fBERANGE\fP | |
105 | +\fIbuf\fP が小さすぎる。もっと大きなバッファにして | |
106 | +(または \fIbuflen\fP を増やして) 再度呼び出すこと。 | |
107 | +.SH 準拠 | |
108 | +これらの関数は GNU による拡張である。 | |
109 | +他のシステムにも同様の名前の関数が存在する場合があるが、 | |
110 | +通常は関数の引き数が異なる。 | |
111 | +.SH 関連項目 | |
112 | +\fBgetnetent\fP(3), \fBnetworks\fP(5) | |
113 | +.SH この文書について | |
114 | +この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 3.40 の一部 | |
115 | +である。プロジェクトの説明とバグ報告に関する情報は | |
116 | +http://www.kernel.org/doc/man\-pages/ に書かれている。 |
@@ -0,0 +1,205 @@ | ||
1 | +.\" Copyright 2008, Linux Foundation, written by Michael Kerrisk | |
2 | +.\" <mtk.manpages@gmail.com> | |
3 | +.\" | |
4 | +.\" Permission is granted to make and distribute verbatim copies of this | |
5 | +.\" manual provided the copyright notice and this permission notice are | |
6 | +.\" preserved on all copies. | |
7 | +.\" | |
8 | +.\" Permission is granted to copy and distribute modified versions of this | |
9 | +.\" manual under the conditions for verbatim copying, provided that the | |
10 | +.\" entire resulting derived work is distributed under the terms of a | |
11 | +.\" permission notice identical to this one. | |
12 | +.\" | |
13 | +.\" Since the Linux kernel and libraries are constantly changing, this | |
14 | +.\" manual page may be incorrect or out-of-date. The author(s) assume no | |
15 | +.\" responsibility for errors or omissions, or for damages resulting from | |
16 | +.\" the use of the information contained herein. The author(s) may not | |
17 | +.\" have taken the same level of care in the production of this manual, | |
18 | +.\" which is licensed free of charge, as they might when working | |
19 | +.\" professionally. | |
20 | +.\" | |
21 | +.\" Formatted or processed versions of this manual, if unaccompanied by | |
22 | +.\" the source, must acknowledge the copyright and authors of this work. | |
23 | +.\" | |
24 | +.\"******************************************************************* | |
25 | +.\" | |
26 | +.\" This file was generated with po4a. Translate the source file. | |
27 | +.\" | |
28 | +.\"******************************************************************* | |
29 | +.TH GETPROTOENT_R 3 2010\-09\-10 GNU "Linux Programmer's Manual" | |
30 | +.SH 名前 | |
31 | +getprotoent_r, getprotobyname_r, getprotobynumber_r \- プロトコル | |
32 | +エントリを取得する (リエントラント版) | |
33 | +.SH 書式 | |
34 | +.nf | |
35 | +\fB#include <netdb.h>\fP | |
36 | +.sp | |
37 | +\fBint getprotoent_r(struct protoent *\fP\fIresult_buf\fP\fB, char *\fP\fIbuf\fP\fB,\fP | |
38 | +\fB size_t \fP\fIbuflen\fP\fB, struct protoent **\fP\fIresult\fP\fB);\fP | |
39 | +.sp | |
40 | +\fBint getprotobyname_r(const char *\fP\fIname\fP\fB,\fP | |
41 | +\fB struct protoent *\fP\fIresult_buf\fP\fB, char *\fP\fIbuf\fP\fB,\fP | |
42 | +\fB size_t \fP\fIbuflen\fP\fB, struct protoent **\fP\fIresult\fP\fB);\fP | |
43 | +.sp | |
44 | +\fBint getprotobynumber_r(int \fP\fIproto\fP\fB,\fP | |
45 | +\fB struct protoent *\fP\fIresult_buf\fP\fB, char *\fP\fIbuf\fP\fB,\fP | |
46 | +\fB size_t \fP\fIbuflen\fP\fB, struct protoent **\fP\fIresult\fP\fB);\fP | |
47 | +.sp | |
48 | +.fi | |
49 | +.in -4n | |
50 | +glibc 向けの機能検査マクロの要件 (\fBfeature_test_macros\fP(7) 参照): | |
51 | +.ad l | |
52 | +.in | |
53 | +.sp | |
54 | +\fBgetprotoent_r\fP(), \fBgetprotobyname_r\fP(), \fBgetprotobynumber_r\fP(): | |
55 | +.RS 4 | |
56 | +_BSD_SOURCE || _SVID_SOURCE | |
57 | +.RE | |
58 | +.ad b | |
59 | +.SH 説明 | |
60 | +関数 \fBgetprotoent_r\fP(), \fBgetprotobyname_r\fP(), | |
61 | +\fBgetprotobynumber_r\fP() は、それぞれ \fBgetprotoent\fP(3), | |
62 | +\fBgetprotobyname\fP(3), \fBgetprotobynumber\fP(3) のリエントラント版である。 | |
63 | +\fIprotoent\fP 構造体の返し方と、関数呼び出し時の引き数と返り値が異なる。 | |
64 | +このマニュアルページでは、リエントラントでない関数との違いだけを | |
65 | +説明する。 | |
66 | + | |
67 | +これらの関数は、関数の結果として静的に割り当てられた \fIprotoent\fP 構造体 | |
68 | +へのポインタを返すのではなく、 \fIprotoent\fP 構造体を \fIresult_buf\fP が | |
69 | +指す場所にコピーする。 | |
70 | + | |
71 | +.\" I can find no information on the required/recommended buffer size; | |
72 | +.\" the nonreentrant functions use a 1024 byte buffer. | |
73 | +.\" The 1024 byte value is also what the Solaris man page suggests. -- mtk | |
74 | +配列 \fIbuf\fP は、返される \fIprotoent\fP 構造体が指す文字列フィールドを | |
75 | +格納するのに使用される (リエントラントでない関数の場合は、 | |
76 | +これらの文字列は静的な領域に格納される)。 | |
77 | +この配列の大きさは \fIbuflen\fP で指定される。 | |
78 | +\fIbuf\fP が小さすぎる場合、関数呼び出しはエラー \fBERANGE\fP で失敗し、 | |
79 | +呼び出し側ではもっと大きなバッファで再度呼び出す必要がある (ほとんどの | |
80 | +アプリケーションでは、長さ 1024 バイトのバッファで十分なはずである)。 | |
81 | + | |
82 | +関数呼び出しでプロトコルレコードの取得に成功すると、 | |
83 | +\fI*result\fP は \fIresult_buf\fP を指すように設定される。 | |
84 | +それ以外の場合は \fI*result\fP に NULL が設定される。 | |
85 | +.SH 返り値 | |
86 | +成功すると、これらの関数は 0 を返す。エラーの場合、「エラー」の節の | |
87 | +リストにある正のエラー番号のいずれかを返す。 | |
88 | + | |
89 | +エラーの場合、レコードが見つからなかった場合 (\fBgetprotobyname_r\fP(), | |
90 | +\fBgetprotobyaddr_r\fP()) やこれ以上レコードがない場合 | |
91 | +(\fBgetprotoent_r\fP())、\fIresult\fP には NULL が設定される。 | |
92 | +.SH エラー | |
93 | +.TP | |
94 | +\fBENOENT\fP | |
95 | +(\fBgetprotoent_r\fP()) データベースにこれ以上レコードがない。 | |
96 | +.TP | |
97 | +\fBERANGE\fP | |
98 | +\fIbuf\fP が小さすぎる。もっと大きなバッファにして | |
99 | +(または \fIbuflen\fP を増やして) 再度呼び出すこと。 | |
100 | +.SH 準拠 | |
101 | +これらの関数は GNU による拡張である。 | |
102 | +他のシステムにも同様の名前の関数が存在する場合があるが、 | |
103 | +通常は関数の引き数が異なる。 | |
104 | +.SH 例 | |
105 | +以下のプログラムは、 \fBgetprotobyname_r\fP() を使って、最初のコマンド | |
106 | +ライン引き数で指定された名前のプロトコルのレコードを取得する。 | |
107 | +二番目のコマンドライン引き数 (整数値) が指定された場合は、 | |
108 | +その値が \fIbuflen\fP の初期値として使用される。 | |
109 | +\fBgetprotobyname_r\fP() がエラー \fBERANGE\fP で失敗すると、プログラムは | |
110 | +より大きなバッファサイズで再度 \fBgetprotobyname_r\fP を呼び出す。 | |
111 | +下記のシェルのセッションは、実行例を示している。 | |
112 | +.in +4n | |
113 | +.nf | |
114 | + | |
115 | +$\fB ./a.out tcp 1\fP | |
116 | +ERANGE! Retrying with larger buffer | |
117 | +getprotobyname_r() returned: 0 (success) (buflen=78) | |
118 | +p_name=tcp; p_proto=6; aliases=TCP | |
119 | +$\fB ./a.out xxx 1\fP | |
120 | +ERANGE! Retrying with larger buffer | |
121 | +getprotobyname_r() returned: 0 (success) (buflen=100) | |
122 | +Call failed/record not found | |
123 | +.fi | |
124 | +.in | |
125 | +.SS プログラムのソース | |
126 | +\& | |
127 | +.nf | |
128 | +#define _GNU_SOURCE | |
129 | +#include <ctype.h> | |
130 | +#include <netdb.h> | |
131 | +#include <stdlib.h> | |
132 | +#include <stdio.h> | |
133 | +#include <errno.h> | |
134 | +#include <string.h> | |
135 | + | |
136 | +#define MAX_BUF 10000 | |
137 | + | |
138 | +int | |
139 | +main(int argc, char *argv[]) | |
140 | +{ | |
141 | + int buflen, erange_cnt, s; | |
142 | + struct protoent result_buf; | |
143 | + struct protoent *result; | |
144 | + char buf[MAX_BUF]; | |
145 | + char **p; | |
146 | + | |
147 | + if (argc < 2) { | |
148 | + printf("Usage: %s proto\-name [buflen]\en", argv[0]); | |
149 | + exit(EXIT_FAILURE); | |
150 | + } | |
151 | + | |
152 | + buflen = 1024; | |
153 | + if (argc > 2) | |
154 | + buflen = atoi(argv[2]); | |
155 | + | |
156 | + if (buflen > MAX_BUF) { | |
157 | + printf("Exceeded buffer limit (%d)\en", MAX_BUF); | |
158 | + exit(EXIT_FAILURE); | |
159 | + } | |
160 | + | |
161 | + erange_cnt = 0; | |
162 | + do { | |
163 | + s = getprotobyname_r(argv[1], &result_buf, | |
164 | + buf, buflen, &result); | |
165 | + if (s == ERANGE) { | |
166 | + if (erange_cnt == 0) | |
167 | + printf("ERANGE! Retrying with larger buffer\en"); | |
168 | + erange_cnt++; | |
169 | + | |
170 | + /* Increment a byte at a time so we can see exactly | |
171 | + what size buffer was required */ | |
172 | + | |
173 | + buflen++; | |
174 | + | |
175 | + if (buflen > MAX_BUF) { | |
176 | + printf("Exceeded buffer limit (%d)\en", MAX_BUF); | |
177 | + exit(EXIT_FAILURE); | |
178 | + } | |
179 | + } | |
180 | + } while (s == ERANGE); | |
181 | + | |
182 | + printf("getprotobyname_r() returned: %s (buflen=%d)\en", | |
183 | + (s == 0) ? "0 (success)" : (s == ENOENT) ? "ENOENT" : | |
184 | + strerror(s), buflen); | |
185 | + | |
186 | + if (s != 0 || result == NULL) { | |
187 | + printf("Call failed/record not found\en"); | |
188 | + exit(EXIT_FAILURE); | |
189 | + } | |
190 | + | |
191 | + printf("p_name=%s; p_proto=%d; aliases=", | |
192 | + result_buf.p_name, result_buf.p_proto); | |
193 | + for (p = result_buf.p_aliases; *p != NULL; p++) | |
194 | + printf("%s ", *p); | |
195 | + printf("\en"); | |
196 | + | |
197 | + exit(EXIT_SUCCESS); | |
198 | +} | |
199 | +.fi | |
200 | +.SH 関連項目 | |
201 | +\fBgetprotoent\fP(3), \fBprotocols\fP(5) | |
202 | +.SH この文書について | |
203 | +この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 3.40 の一部 | |
204 | +である。プロジェクトの説明とバグ報告に関する情報は | |
205 | +http://www.kernel.org/doc/man\-pages/ に書かれている。 |
@@ -0,0 +1,108 @@ | ||
1 | +.\" Copyright 2008, Linux Foundation, written by Michael Kerrisk | |
2 | +.\" <mtk.manpages@gmail.com> | |
3 | +.\" | |
4 | +.\" Permission is granted to make and distribute verbatim copies of this | |
5 | +.\" manual provided the copyright notice and this permission notice are | |
6 | +.\" preserved on all copies. | |
7 | +.\" | |
8 | +.\" Permission is granted to copy and distribute modified versions of this | |
9 | +.\" manual under the conditions for verbatim copying, provided that the | |
10 | +.\" entire resulting derived work is distributed under the terms of a | |
11 | +.\" permission notice identical to this one. | |
12 | +.\" | |
13 | +.\" Since the Linux kernel and libraries are constantly changing, this | |
14 | +.\" manual page may be incorrect or out-of-date. The author(s) assume no | |
15 | +.\" responsibility for errors or omissions, or for damages resulting from | |
16 | +.\" the use of the information contained herein. The author(s) may not | |
17 | +.\" have taken the same level of care in the production of this manual, | |
18 | +.\" which is licensed free of charge, as they might when working | |
19 | +.\" professionally. | |
20 | +.\" | |
21 | +.\" Formatted or processed versions of this manual, if unaccompanied by | |
22 | +.\" the source, must acknowledge the copyright and authors of this work. | |
23 | +.\" | |
24 | +.\"******************************************************************* | |
25 | +.\" | |
26 | +.\" This file was generated with po4a. Translate the source file. | |
27 | +.\" | |
28 | +.\"******************************************************************* | |
29 | +.TH GETRPCENT_R 3 2010\-09\-10 GNU "Linux Programmer's Manual" | |
30 | +.SH 名前 | |
31 | +getrpcent_r, getrpcbyname_r, getrpcbynumber_r \- RPC エントリを | |
32 | +取得する (リエントラント版) | |
33 | +.SH 書式 | |
34 | +.nf | |
35 | +\fB#include <netdb.h>\fP | |
36 | +.sp | |
37 | +\fBint getrpcent_r(struct rpcent *\fP\fIresult_buf\fP\fB, char *\fP\fIbuf\fP\fB,\fP | |
38 | +\fB size_t \fP\fIbuflen\fP\fB, struct rpcent **\fP\fIresult\fP\fB);\fP | |
39 | +.sp | |
40 | +\fBint getrpcbyname_r(const char *\fP\fIname\fP\fB,\fP | |
41 | +\fB struct rpcent *\fP\fIresult_buf\fP\fB, char *\fP\fIbuf\fP\fB,\fP | |
42 | +\fB size_t \fP\fIbuflen\fP\fB, struct rpcent **\fP\fIresult\fP\fB);\fP | |
43 | +.sp | |
44 | +\fBint getrpcbynumber_r(int \fP\fInumber\fP\fB,\fP | |
45 | +\fB struct rpcent *\fP\fIresult_buf\fP\fB, char *\fP\fIbuf\fP\fB,\fP | |
46 | +\fB size_t \fP\fIbuflen\fP\fB, struct rpcent **\fP\fIresult\fP\fB);\fP | |
47 | +.sp | |
48 | +.fi | |
49 | +.in -4n | |
50 | +glibc 向けの機能検査マクロの要件 (\fBfeature_test_macros\fP(7) 参照): | |
51 | +.ad l | |
52 | +.in | |
53 | +.sp | |
54 | +\fBgetrpcent_r\fP(), \fBgetrpcbyname_r\fP(), \fBgetrpcbynumber_r\fP(): | |
55 | +.RS 4 | |
56 | +_BSD_SOURCE || _SVID_SOURCE | |
57 | +.RE | |
58 | +.ad b | |
59 | +.SH 説明 | |
60 | +関数 \fBgetrpcent_r\fP(), \fBgetrpcbyname_r\fP(), \fBgetrpcbynumber_r\fP() は、 | |
61 | +それぞれ \fBgetrpcent\fP(3), \fBgetrpcbyname\fP(3), \fBgetrpcbynumber\fP(3) の | |
62 | +リエントラント版である。 | |
63 | +\fIrpcent\fP 構造体の返し方と、関数呼び出し時の引き数と返り値が異なる。 | |
64 | +このマニュアルページでは、リエントラントでない関数との違いだけを | |
65 | +説明する。 | |
66 | + | |
67 | +これらの関数は、関数の結果として静的に割り当てられた \fIrpcent\fP 構造体 | |
68 | +へのポインタを返すのではなく、 \fIrpcent\fP 構造体を \fIresult_buf\fP が | |
69 | +指す場所にコピーする。 | |
70 | + | |
71 | +.\" I can find no information on the required/recommended buffer size; | |
72 | +.\" the nonreentrant functions use a 1024 byte buffer -- mtk. | |
73 | +配列 \fIbuf\fP は、返される \fIrpcent\fP 構造体が指す文字列フィールドを | |
74 | +格納するのに使用される (リエントラントでない関数の場合は、 | |
75 | +これらの文字列は静的な領域に格納される)。 | |
76 | +この配列の大きさは \fIbuflen\fP で指定される。 | |
77 | +\fIbuf\fP が小さすぎる場合、関数呼び出しはエラー \fBERANGE\fP で失敗し、 | |
78 | +呼び出し側ではもっと大きなバッファで再度呼び出す必要がある (ほとんどの | |
79 | +アプリケーションでは、長さ 1024 バイトのバッファで十分なはずである)。 | |
80 | + | |
81 | +関数呼び出しで RPC レコードの取得に成功すると、 | |
82 | +\fI*result\fP は \fIresult_buf\fP を指すように設定される。 | |
83 | +それ以外の場合は \fI*result\fP に NULL が設定される。 | |
84 | +.SH 返り値 | |
85 | +成功すると、これらの関数は 0 を返す。エラーの場合、「エラー」の節の | |
86 | +リストにある正のエラー番号のいずれかを返す。 | |
87 | + | |
88 | +エラーの場合、レコードが見つからなかった場合 (\fBgetrpcbyname_r\fP(), | |
89 | +\fBgetrpcbyaddr_r\fP()) やこれ以上レコードがない場合 (\fBgetrpcent_r\fP())、 | |
90 | +\fIresult\fP には NULL が設定される。 | |
91 | +.SH エラー | |
92 | +.TP | |
93 | +\fBENOENT\fP | |
94 | +(\fBgetrpcent_r\fP()) データベースにこれ以上レコードがない。 | |
95 | +.TP | |
96 | +\fBERANGE\fP | |
97 | +\fIbuf\fP が小さすぎる。もっと大きなバッファにして | |
98 | +(または \fIbuflen\fP を増やして) 再度呼び出すこと。 | |
99 | +.SH 準拠 | |
100 | +これらの関数は GNU による拡張である。 | |
101 | +他のシステムにも同様の名前の関数が存在する場合があるが、 | |
102 | +通常は関数の引き数が異なる。 | |
103 | +.SH 関連項目 | |
104 | +\fBgetrpcent\fP(3), \fBrpc\fP(5) | |
105 | +.SH この文書について | |
106 | +この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 3.40 の一部 | |
107 | +である。プロジェクトの説明とバグ報告に関する情報は | |
108 | +http://www.kernel.org/doc/man\-pages/ に書かれている。 |
@@ -0,0 +1,210 @@ | ||
1 | +.\" Copyright 2008, Linux Foundation, written by Michael Kerrisk | |
2 | +.\" <mtk.manpages@gmail.com> | |
3 | +.\" | |
4 | +.\" Permission is granted to make and distribute verbatim copies of this | |
5 | +.\" manual provided the copyright notice and this permission notice are | |
6 | +.\" preserved on all copies. | |
7 | +.\" | |
8 | +.\" Permission is granted to copy and distribute modified versions of this | |
9 | +.\" manual under the conditions for verbatim copying, provided that the | |
10 | +.\" entire resulting derived work is distributed under the terms of a | |
11 | +.\" permission notice identical to this one. | |
12 | +.\" | |
13 | +.\" Since the Linux kernel and libraries are constantly changing, this | |
14 | +.\" manual page may be incorrect or out-of-date. The author(s) assume no | |
15 | +.\" responsibility for errors or omissions, or for damages resulting from | |
16 | +.\" the use of the information contained herein. The author(s) may not | |
17 | +.\" have taken the same level of care in the production of this manual, | |
18 | +.\" which is licensed free of charge, as they might when working | |
19 | +.\" professionally. | |
20 | +.\" | |
21 | +.\" Formatted or processed versions of this manual, if unaccompanied by | |
22 | +.\" the source, must acknowledge the copyright and authors of this work. | |
23 | +.\" | |
24 | +.\"******************************************************************* | |
25 | +.\" | |
26 | +.\" This file was generated with po4a. Translate the source file. | |
27 | +.\" | |
28 | +.\"******************************************************************* | |
29 | +.TH GETSERVENT_R 3 2010\-09\-10 GNU "Linux Programmer's Manual" | |
30 | +.SH 名前 | |
31 | +getservent_r, getservbyname_r, getservbyport_r \- サービスエントリを | |
32 | +取得する (リエントラント版) | |
33 | +.SH 書式 | |
34 | +.nf | |
35 | +\fB#include <netdb.h>\fP | |
36 | +.sp | |
37 | +\fBint getservent_r(struct servent *\fP\fIresult_buf\fP\fB, char *\fP\fIbuf\fP\fB,\fP | |
38 | +\fB size_t \fP\fIbuflen\fP\fB, struct servent **\fP\fIresult\fP\fB);\fP | |
39 | +.sp | |
40 | +\fBint getservbyname_r(const char *\fP\fIname\fP\fB, const char *\fP\fIproto\fP\fB,\fP | |
41 | +\fB struct servent *\fP\fIresult_buf\fP\fB, char *\fP\fIbuf\fP\fB,\fP | |
42 | +\fB size_t \fP\fIbuflen\fP\fB, struct servent **\fP\fIresult\fP\fB);\fP | |
43 | +.sp | |
44 | +\fBint getservbyport_r(int \fP\fIport\fP\fB, const char *\fP\fIproto\fP\fB,\fP | |
45 | +\fB struct servent *\fP\fIresult_buf\fP\fB, char *\fP\fIbuf\fP\fB,\fP | |
46 | +\fB size_t \fP\fIbuflen\fP\fB, struct servent **\fP\fIresult\fP\fB);\fP | |
47 | +.sp | |
48 | +.fi | |
49 | +.in -4n | |
50 | +glibc 向けの機能検査マクロの要件 (\fBfeature_test_macros\fP(7) 参照): | |
51 | +.ad l | |
52 | +.in | |
53 | +.sp | |
54 | +\fBgetservent_r\fP(), \fBgetservbyname_r\fP(), \fBgetservbyport_r\fP(): | |
55 | +.RS 4 | |
56 | +_BSD_SOURCE || _SVID_SOURCE | |
57 | +.RE | |
58 | +.ad b | |
59 | +.SH 説明 | |
60 | +関数 \fBgetservent_r\fP(), \fBgetservbyname_r\fP(), \fBgetservbyport_r\fP() は、 | |
61 | +それぞれ \fBgetservent\fP(3), \fBgetservbyname\fP(3), \fBgetservbyport\fP(3) の | |
62 | +リエントラント版である。 | |
63 | +\fIservent\fP 構造体の返し方と、関数呼び出し時の引き数と返り値が異なる。 | |
64 | +このマニュアルページでは、リエントラントでない関数との違いだけを | |
65 | +説明する。 | |
66 | + | |
67 | +これらの関数は、関数の結果として静的に割り当てられた \fIservent\fP 構造体 | |
68 | +へのポインタを返すのではなく、 \fIservent\fP 構造体を \fIresult_buf\fP が | |
69 | +指す場所にコピーする。 | |
70 | + | |
71 | +.\" I can find no information on the required/recommended buffer size; | |
72 | +.\" the nonreentrant functions use a 1024 byte buffer -- mtk. | |
73 | +配列 \fIbuf\fP は、返される \fIservent\fP 構造体が指す文字列フィールドを | |
74 | +格納するのに使用される (リエントラントでない関数の場合は、 | |
75 | +これらの文字列は静的な領域に格納される)。 | |
76 | +この配列の大きさは \fIbuflen\fP で指定される。 | |
77 | +\fIbuf\fP が小さすぎる場合、関数呼び出しはエラー \fBERANGE\fP で失敗し、 | |
78 | +呼び出し側ではもっと大きなバッファで再度呼び出す必要がある (ほとんどの | |
79 | +アプリケーションでは、長さ 1024 バイトのバッファで十分なはずである)。 | |
80 | + | |
81 | +関数呼び出しでサービスレコードの取得に成功すると、 | |
82 | +\fI*result\fP は \fIresult_buf\fP を指すように設定される。 | |
83 | +それ以外の場合は \fI*result\fP に NULL が設定される。 | |
84 | +.SH 返り値 | |
85 | +成功すると、これらの関数は 0 を返す。エラーの場合、「エラー」の節の | |
86 | +リストにある正のエラー番号のいずれかを返す。 | |
87 | + | |
88 | +エラーの場合、レコードが見つからなかった場合 (\fBgetservbyname_r\fP(), | |
89 | +\fBgetservbyaddr_r\fP()) やこれ以上レコードがない場合 (\fBgetservent_r\fP())、 | |
90 | +\fIresult\fP には NULL が設定される。 | |
91 | +.SH エラー | |
92 | +.TP | |
93 | +\fBENOENT\fP | |
94 | +(\fBgetservent_r\fP()) データベースにこれ以上レコードがない。 | |
95 | +.TP | |
96 | +\fBERANGE\fP | |
97 | +\fIbuf\fP が小さすぎる。もっと大きなバッファにして | |
98 | +(または \fIbuflen\fP を増やして) 再度呼び出すこと。 | |
99 | +.SH 準拠 | |
100 | +これらの関数は GNU による拡張である。 | |
101 | +他のシステムにも同様の名前の関数が存在する場合があるが、 | |
102 | +通常は関数の引き数が異なる。 | |
103 | +.SH 例 | |
104 | +以下のプログラムは、 \fBgetservbyport_r\fP() を使って、コマンド | |
105 | +ライン引き数で指定されたポート番号とプロトコル名を持つ | |
106 | +サービスレコードを取得する。 | |
107 | +三番目のコマンドライン引き数 (整数値) が指定された場合は、 | |
108 | +その値が \fIbuflen\fP の初期値として使用される。 | |
109 | +\fBgetservbyport_r\fP() がエラー \fBERANGE\fP で失敗すると、プログラムは | |
110 | +より大きなバッファサイズで再度 \fBgetservbyport_r\fP を呼び出す。 | |
111 | +下記のシェルのセッションは実行例を示している。 | |
112 | +.in +4n | |
113 | +.nf | |
114 | + | |
115 | +$\fB ./a.out 7 tcp 1\fP | |
116 | +ERANGE! Retrying with larger buffer | |
117 | +getservbyport_r() returned: 0 (success) (buflen=87) | |
118 | +s_name=echo; s_proto=tcp; s_port=7; aliases= | |
119 | +$\fB ./a.out 77777 tcp\fP | |
120 | +getservbyport_r() returned: 0 (success) (buflen=1024) | |
121 | +Call failed/record not found | |
122 | +.fi | |
123 | +.in | |
124 | +.SS プログラムのソース | |
125 | +\& | |
126 | +.nf | |
127 | +#define _GNU_SOURCE | |
128 | +#include <ctype.h> | |
129 | +#include <netdb.h> | |
130 | +#include <stdlib.h> | |
131 | +#include <stdio.h> | |
132 | +#include <errno.h> | |
133 | +#include <string.h> | |
134 | + | |
135 | +#define MAX_BUF 10000 | |
136 | + | |
137 | +int | |
138 | +main(int argc, char *argv[]) | |
139 | +{ | |
140 | + int buflen, erange_cnt, port, s; | |
141 | + struct servent result_buf; | |
142 | + struct servent *result; | |
143 | + char buf[MAX_BUF]; | |
144 | + char *protop; | |
145 | + char **p; | |
146 | + | |
147 | + if (argc < 3) { | |
148 | + printf("Usage: %s port\-num proto\-name [buflen]\en", argv[0]); | |
149 | + exit(EXIT_FAILURE); | |
150 | + } | |
151 | + | |
152 | + port = htons(atoi(argv[1])); | |
153 | + protop = (strcmp(argv[2], "null") == 0 || | |
154 | + strcmp(argv[2], "NULL") == 0) ? NULL : argv[2]; | |
155 | + | |
156 | + buflen = 1024; | |
157 | + if (argc > 3) | |
158 | + buflen = atoi(argv[3]); | |
159 | + | |
160 | + if (buflen > MAX_BUF) { | |
161 | + printf("Exceeded buffer limit (%d)\en", MAX_BUF); | |
162 | + exit(EXIT_FAILURE); | |
163 | + } | |
164 | + | |
165 | + erange_cnt = 0; | |
166 | + do { | |
167 | + s = getservbyport_r(port, protop, &result_buf, | |
168 | + buf, buflen, &result); | |
169 | + if (s == ERANGE) { | |
170 | + if (erange_cnt == 0) | |
171 | + printf("ERANGE! Retrying with larger buffer\en"); | |
172 | + erange_cnt++; | |
173 | + | |
174 | + /* Increment a byte at a time so we can see exactly | |
175 | + what size buffer was required */ | |
176 | + | |
177 | + buflen++; | |
178 | + | |
179 | + if (buflen > MAX_BUF) { | |
180 | + printf("Exceeded buffer limit (%d)\en", MAX_BUF); | |
181 | + exit(EXIT_FAILURE); | |
182 | + } | |
183 | + } | |
184 | + } while (s == ERANGE); | |
185 | + | |
186 | + printf("getservbyport_r() returned: %s (buflen=%d)\en", | |
187 | + (s == 0) ? "0 (success)" : (s == ENOENT) ? "ENOENT" : | |
188 | + strerror(s), buflen); | |
189 | + | |
190 | + if (s != 0 || result == NULL) { | |
191 | + printf("Call failed/record not found\en"); | |
192 | + exit(EXIT_FAILURE); | |
193 | + } | |
194 | + | |
195 | + printf("s_name=%s; s_proto=%s; s_port=%d; aliases=", | |
196 | + result_buf.s_name, result_buf.s_proto, | |
197 | + ntohs(result_buf.s_port)); | |
198 | + for (p = result_buf.s_aliases; *p != NULL; p++) | |
199 | + printf("%s ", *p); | |
200 | + printf("\en"); | |
201 | + | |
202 | + exit(EXIT_SUCCESS); | |
203 | +} | |
204 | +.fi | |
205 | +.SH 関連項目 | |
206 | +\fBgetservent\fP(3), \fBservices\fP(5) | |
207 | +.SH この文書について | |
208 | +この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 3.40 の一部 | |
209 | +である。プロジェクトの説明とバグ報告に関する情報は | |
210 | +http://www.kernel.org/doc/man\-pages/ に書かれている。 |
@@ -0,0 +1,65 @@ | ||
1 | +.\" Copyright (c) 2008, Linux Foundation, written by Michael Kerrisk | |
2 | +.\" <mtk.manpages@gmail.com> | |
3 | +.\" | |
4 | +.\" Permission is granted to make and distribute verbatim copies of this | |
5 | +.\" manual provided the copyright notice and this permission notice are | |
6 | +.\" preserved on all copies. | |
7 | +.\" | |
8 | +.\" Permission is granted to copy and distribute modified versions of this | |
9 | +.\" manual under the conditions for verbatim copying, provided that the | |
10 | +.\" entire resulting derived work is distributed under the terms of a | |
11 | +.\" permission notice identical to this one. | |
12 | +.\" | |
13 | +.\" Since the Linux kernel and libraries are constantly changing, this | |
14 | +.\" manual page may be incorrect or out-of-date. The author(s) assume no | |
15 | +.\" responsibility for errors or omissions, or for damages resulting from | |
16 | +.\" the use of the information contained herein. The author(s) may not | |
17 | +.\" have taken the same level of care in the production of this manual, | |
18 | +.\" which is licensed free of charge, as they might when working | |
19 | +.\" professionally. | |
20 | +.\" | |
21 | +.\" Formatted or processed versions of this manual, if unaccompanied by | |
22 | +.\" the source, must acknowledge the copyright and authors of this work. | |
23 | +.\" | |
24 | +.\"******************************************************************* | |
25 | +.\" | |
26 | +.\" This file was generated with po4a. Translate the source file. | |
27 | +.\" | |
28 | +.\"******************************************************************* | |
29 | +.TH GETUTMP 3 2010\-09\-10 Linux "Linux Programmer's Manual" | |
30 | +.SH 名前 | |
31 | +getutmp, getutmpx \- utmp 構造体から utmpx 構造体、その逆のコピーを行う | |
32 | +.SH 書式 | |
33 | +.nf | |
34 | +\fB#define _GNU_SOURCE\fP /* feature_test_macros(7) 参照 */ | |
35 | +\fB#include <utmpx.h>\fP | |
36 | + | |
37 | +\fB void getutmp(const struct utmpx *\fP\fIux\fP\fB, struct utmp *\fP\fIu\fP\fB);\fP | |
38 | +\fB void getutmpx(const struct utmp *\fP\fIu\fP\fB, struct utmpx *\fP\fIux\fP\fB);\fP | |
39 | +.fi | |
40 | +.SH 説明 | |
41 | +\fBgetutmp\fP() 関数は、 \fIux\fP が指す \fIutmpx\fP 構造体の各フィールドを、 | |
42 | +\fIu\fP が指す \fIutmp\fP 構造体の対応するフィールドにコピーする。 | |
43 | +\fBgetutmpx\fP() 関数は逆の操作を行う。 | |
44 | +.SH 返り値 | |
45 | +これらの関数は値を返さない。 | |
46 | +.SH バージョン | |
47 | +これらの関数は glibc バージョン 2.1.1 で初めて登場した。 | |
48 | +.SH 準拠 | |
49 | +これらの関数は非標準である。 | |
50 | +Linux 以外にも、これらの関数が存在するシステムもいくつかある | |
51 | +(Solaris や NetBSD など)。 | |
52 | +.SH 注意 | |
53 | +.\" e.g., on Solaris, the utmpx structure is rather larger than utmp. | |
54 | +これらの関数が存在する一番の目的は、 | |
55 | +\fIutmp\fP 構造体と \fIutmpx\fP 構造体が異なるフィールドを持たり、 | |
56 | +対応するフィールドの大きさが異なっている、他のシステムとの | |
57 | +互換性のためである。 | |
58 | +Linux では、これらの構造体は同じフィールドを持っており、 | |
59 | +各フィールドのサイズも同じである。 | |
60 | +.SH 関連項目 | |
61 | +\fBgetutent\fP(3), \fButmp\fP(5) | |
62 | +.SH この文書について | |
63 | +この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 3.40 の一部 | |
64 | +である。プロジェクトの説明とバグ報告に関する情報は | |
65 | +http://www.kernel.org/doc/man\-pages/ に書かれている。 |
@@ -0,0 +1,76 @@ | ||
1 | +.\" Copyright (c) 2001 Martin Schulze <joey@infodrom.org> | |
2 | +.\" | |
3 | +.\" This is free documentation; you can redistribute it and/or | |
4 | +.\" modify it under the terms of the GNU General Public License as | |
5 | +.\" published by the Free Software Foundation; either version 2 of | |
6 | +.\" the License, or (at your option) any later version. | |
7 | +.\" | |
8 | +.\" The GNU General Public License's references to "object code" | |
9 | +.\" and "executables" are to be interpreted as the output of any | |
10 | +.\" document formatting or typesetting system, including | |
11 | +.\" intermediate and printed output. | |
12 | +.\" | |
13 | +.\" This manual is distributed in the hope that it will be useful, | |
14 | +.\" but WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 | +.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
16 | +.\" GNU General Public License for more details. | |
17 | +.\" | |
18 | +.\" You should have received a copy of the GNU General Public | |
19 | +.\" License along with this manual; if not, write to the Free | |
20 | +.\" Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, | |
21 | +.\" USA. | |
22 | +.\" 2008-09-04, mtk, taken from Debian downstream, with a few light edits | |
23 | +.\" | |
24 | +.\"******************************************************************* | |
25 | +.\" | |
26 | +.\" This file was generated with po4a. Translate the source file. | |
27 | +.\" | |
28 | +.\"******************************************************************* | |
29 | +.TH NETWORKS 5 2008\-09\-04 GNU/Linux "Linux System Administration" | |
30 | +.SH 名前 | |
31 | +networks \- ネットワーク名の情報 | |
32 | +.SH 説明 | |
33 | +\fI/etc/networks\fP ファイルは、通常の ASCII ファイルで、よく使われる | |
34 | +DARPA ネットワークとその分かりやすい名前を記載したファイルである。 | |
35 | +各行が一つのネットワークを表し、以下の構造となっている。 | |
36 | + | |
37 | +.RS | |
38 | +\fIname number aliases ...\fP | |
39 | +.RE | |
40 | + | |
41 | +フィールドはスペースかタブで区切られる。空行は無視される。 | |
42 | +ハッシュ文字 (\fB#\fP) はコメントの開始を示し、このファイルを処理する | |
43 | +ライブラリ関数はこの文字とその行のそれ以降の文字を無視する。 | |
44 | + | |
45 | +フィールドの説明は以下のとおり。 | |
46 | + | |
47 | +.TP | |
48 | +\fIname\fP | |
49 | +ネットワークの分かりやすい名前 (symbolic name)。 | |
50 | +ネットワーク名には、ホワイトスペースとコメント文字以外の | |
51 | +印字可能な文字を使うことができる。 | |
52 | +.TP | |
53 | +\fInumber\fP | |
54 | +このネットワークの正式な数字での値。 | |
55 | +ドット区切りの数字表記 (\fBinet\fP(3) 参照) で記載する。 | |
56 | +末尾の ".0" (ネットワークアドレスのホスト部分) は省略してもよい。 | |
57 | +.TP | |
58 | +\fIaliases\fP | |
59 | +そのネットワークの別名 (省略可能)。 | |
60 | +.LP | |
61 | + | |
62 | +このファイルは、 \fBroute\fP(8) と \fBnetstat\fP(8) ユーティリティにより | |
63 | +利用される。クラス A, B, C のネットワークだけがサポートされており、 | |
64 | +(network/26 や network/28 といった) 分割されたネットワークは | |
65 | +このファイルではサポートされていない。 | |
66 | +.SH ファイル | |
67 | +.TP | |
68 | +\fI/etc/networks\fP | |
69 | +ネットワーク定義ファイル。 | |
70 | +.SH 関連項目 | |
71 | +\fBgetnetbyaddr\fP(3), \fBgetnetbyname\fP(3), \fBgetnetent\fP(3), \fBnetstat\fP(8), | |
72 | +\fBroute\fP(8) | |
73 | +.SH この文書について | |
74 | +この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 3.40 の一部 | |
75 | +である。プロジェクトの説明とバグ報告に関する情報は | |
76 | +http://www.kernel.org/doc/man\-pages/ に書かれている。 |
@@ -0,0 +1,93 @@ | ||
1 | +.\" Copyright (c) 1987, 1990, 1993 | |
2 | +.\" The Regents of the University of California. All rights reserved. | |
3 | +.\" | |
4 | +.\" Redistribution and use in source and binary forms, with or without | |
5 | +.\" modification, are permitted provided that the following conditions | |
6 | +.\" are met: | |
7 | +.\" 1. Redistributions of source code must retain the above copyright | |
8 | +.\" notice, this list of conditions and the following disclaimer. | |
9 | +.\" 2. Redistributions in binary form must reproduce the above copyright | |
10 | +.\" notice, this list of conditions and the following disclaimer in the | |
11 | +.\" documentation and/or other materials provided with the distribution. | |
12 | +.\" 3. All advertising materials mentioning features or use of this software | |
13 | +.\" must display the following acknowledgement: | |
14 | +.\" This product includes software developed by the University of | |
15 | +.\" California, Berkeley and its contributors. | |
16 | +.\" 4. Neither the name of the University nor the names of its contributors | |
17 | +.\" may be used to endorse or promote products derived from this software | |
18 | +.\" without specific prior written permission. | |
19 | +.\" | |
20 | +.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND | |
21 | +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
22 | +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |
23 | +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | |
24 | +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |
25 | +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | |
26 | +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
27 | +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
28 | +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
29 | +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
30 | +.\" SUCH DAMAGE. | |
31 | +.\" | |
32 | +.\" @(#)hostname.7 8.2 (Berkeley) 12/30/93 | |
33 | +.\" $FreeBSD: src/share/man/man7/hostname.7,v 1.7 2004/07/03 18:29:23 ru Exp $ | |
34 | +.\" | |
35 | +.\" 2008-06-11, mtk, Taken from FreeBSD 6.2 and modified for Linux. | |
36 | +.\" | |
37 | +.\"******************************************************************* | |
38 | +.\" | |
39 | +.\" This file was generated with po4a. Translate the source file. | |
40 | +.\" | |
41 | +.\"******************************************************************* | |
42 | +.TH HOSTNAME 7 2010\-11\-07 Linux "Linux Programmer's Manual" | |
43 | +.SH 名前 | |
44 | +hostname \- ホスト名の名前解決の説明 | |
45 | +.SH 説明 | |
46 | +ホスト名は、階層構造でドット区切りのサブドメインである。 | |
47 | +例えば、 EDU ドメインの Berkeley サブドメインのマシン monet は、 | |
48 | +"monet.Berkeley.EDU" と表現される。 | |
49 | + | |
50 | +ホスト名は、ネットワーククライアントやサーバのプログラムでは一般的に | |
51 | +使用され、使用する際には名前からアドレスに変換しなければならない (一般 | |
52 | +的にはアドレスへの変換処理は \fBgetaddrinfo\fP(3) か (廃止予定の) | |
53 | +\fBgethostbyname\fP(3) で行われる)。ホスト名の解決は、 | |
54 | +インターネット・ネームリゾルバによって以下の方法で実行される。 | |
55 | + | |
56 | +ホスト名がドットを含まない単一要素で構成されていて、環境変数 | |
57 | +\fBHOSTALIASES\fP にファイル名が設定されている場合、入力されたホスト名に | |
58 | +マッチする文字列を検索するのに指定されたファイルが使用される。 | |
59 | +そのファイルの各行は、ホワイトスペースで区切られた文字列 2 つで | |
60 | +構成され、各行の最初の文字列がホスト名のエイリアス (別名) で、 | |
61 | +二番目の文字列がそのエイリアスに対応する完全なホスト名である。 | |
62 | +解決するホスト名と一致するホスト名のエイリアス (ファイルの各行の最初の | |
63 | +フィールド) が見つかれば、完全なホスト名に置き換えられ、 | |
64 | +それ以上の変換処理は行わずに、そのホスト名で検索処理が行われる | |
65 | +(ホスト名とエイリアスの照合では大文字、小文字の違いは無視される)。 | |
66 | + | |
67 | +入力されたホスト名の末尾がドットの場合、 | |
68 | +末尾のドットは削除され、それ以上の処理は行われず、 | |
69 | +(末尾のドットを削除した) 残りの名前で検索が行われる。 | |
70 | + | |
71 | +入力された名前の末尾がドットでない場合、 | |
72 | +マッチするものが見つかるまでドメインのリストの検索が行われる。 | |
73 | +デフォルトのドメインの検索リストは、先頭ローカルのドメインで、 | |
74 | +親ドメインが (長いものから順に) 続く (親ドメインはドット区切りで | |
75 | +少なくとも 2 要素あるものだけが使用される)。 | |
76 | +例えば、 CS.Berkeley.EDU ドメインで、 | |
77 | +lithium.CChem というホスト名の場合には、 | |
78 | +最初に lithium.CChem.CS.Berkeley.EDU が確認され、 | |
79 | +次に lithium.CChem.Berkeley.EDU が確認される。 | |
80 | +Lithium.CChem.EDU はチェックされない。 | |
81 | +なぜなら、ローカルドメイン CS.Berkeley.EDU で残っているドメインは | |
82 | +EDU で、これは一つしか要素がないからである。 | |
83 | +検索リストはシステム全体で共通の設定ファイルでデフォルト値から | |
84 | +変更できる (\fBresolver\fP(5) 参照)。 | |
85 | +.SH 関連項目 | |
86 | +.\" .SH HISTORY | |
87 | +.\" Hostname appeared in | |
88 | +.\" 4.2BSD. | |
89 | +\fBgethostbyname\fP(3), \fBresolver\fP(5), \fBmailaddr\fP(7), \fBnamed\fP(8) | |
90 | +.SH この文書について | |
91 | +この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 3.40 の一部 | |
92 | +である。プロジェクトの説明とバグ報告に関する情報は | |
93 | +http://www.kernel.org/doc/man\-pages/ に書かれている。 |