OSDN Git Service

Import translated manuals from JM CVS Repository.
[linuxjm/jm.git] / manual / LDP_man-pages / draft / man3 / rpmatch.3
1 .\" Copyright (C) 2006 Justin Pryzby <pryzbyj@justinpryzby.com>
2 .\"
3 .\" Permission is hereby granted, free of charge, to any person obtaining
4 .\" a copy of this software and associated documentation files (the
5 .\" "Software"), to deal in the Software without restriction, including
6 .\" without limitation the rights to use, copy, modify, merge, publish,
7 .\" distribute, sublicense, and/or sell copies of the Software, and to
8 .\" permit persons to whom the Software is furnished to do so, subject to
9 .\" the following conditions:
10 .\"
11 .\" The above copyright notice and this permission notice shall be
12 .\" included in all copies or substantial portions of the Software.
13 .\"
14 .\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15 .\" EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16 .\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
17 .\" IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
18 .\" CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
19 .\" TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
20 .\" SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21 .\"
22 .\" References:
23 .\"   glibc manual and source
24 .\"
25 .\" 2006-05-19, mtk, various edits and example program
26 .\"
27 .\" Japanese Version Copyright (c) 2006 Akihiro MOTOKI all rights reserved.
28 .\" Translated 2006-07-31, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>
29 .\"
30 .TH RPMATCH 3 2007-07-26 "GNU" "Linux Programmer's Manual"
31 .\"O .SH NAME
32 .SH Ì¾Á°
33 .\"O rpmatch \- determine if the answer to a question is affirmative or negative
34 rpmatch \- ¼ÁÌä¤Ø¤Î±þÅú¤¬¹ÎÄ꤫ÈÝÄ꤫¤òȽÄꤹ¤ë
35 .\"O .SH SYNOPSIS
36 .SH ½ñ¼°
37 .nf
38 .B #include <stdlib.h>
39
40 .BI "int rpmatch(const char *" response );
41 .fi
42 .sp
43 .in -4n
44 .\"O Feature Test Macro Requirements for glibc (see
45 .\"O .BR feature_test_macros (7)):
46 glibc ¸þ¤±¤Îµ¡Ç½¸¡ºº¥Þ¥¯¥í¤ÎÍ×·ï
47 .RB ( feature_test_macros (7)
48 »²¾È):
49 .in
50 .sp
51 .BR rpmatch ():
52 _SVID_SOURCE
53 .\"O .SH DESCRIPTION
54 .SH ÀâÌÀ
55 .\"O .BR rpmatch ()
56 .\"O handles a user response to yes or no questions, with
57 .\"O support for internationalization.
58 .BR  rpmatch ()
59 ¤Ï yes/no ¤Î¼ÁÌä¤ËÂФ¹¤ë¥æ¡¼¥¶¤«¤é¤Î±þÅú¤ò½èÍý¤¹¤ë¡£
60 ¹ñºÝ²½ (I18N) ¤ËÂбþ¤·¤Æ¤¤¤ë¡£
61
62 .\"O \fIresponse\fP should be a null-terminated string containing a
63 .\"O user-supplied response, perhaps obtained with
64 .\"O .BR fgets (3)
65 .\"O or
66 .\"O .BR getline (3).
67 .I response
68 ¤Ë¤Ï¥æ¡¼¥¶¤«¤é¤Î±þÅú¤ò³ÊǼ¤·¤¿ NULL ½ªÃ¼Ê¸»úÎó¤¬Æþ¤Ã¤Æ¤¤¤ëɬÍפ¬¤¢¤ë¡£
69 ¤¿¤¤¤Æ¤¤¤Ï¡¢
70 .BR fgets (3)
71 ¤ä
72 .BR getline (3)
73 ¤Ç¼è¤ê¹þ¤ó¤À¤â¤Î¤Ç¤¢¤í¤¦¡£
74
75 .\"O The user's language preference is taken into account per the
76 .\"O environment variables \fBLANG\fP, \fBLC_MESSAGES\fP, and \fBLC_ALL\fP,
77 .\"O if the program has called
78 .\"O .BR setlocale (3)
79 .\"O to effect their changes.
80 ¥×¥í¥°¥é¥à¤¬
81 .BR setlocale (3)
82 ¤ò¸Æ¤Ó½Ð¤·¤Æ´Ä¶­ÊÑ¿ô¤ÎÊѹ¹¤òÍ­¸ú¤Ë¤·¤¿¾ì¹ç¡¢
83 ´Ä¶­ÊÑ¿ô \fBLANG\fP, \fBLC_MESSAGES\fP, \fBLC_ALL\fP ¤¬
84 ¥æ¡¼¥¶¤Î¸À¸ìÀßÄê¤È¤·¤Æ¹Í褵¤ì¤ë¡£
85
86 .\"O Regardless of the locale, responses matching \fB^[Yy]\fP are always
87 .\"O accepted as affirmative, and those matching \fB^[Nn]\fP are always
88 .\"O accepted as negative.
89 ¥í¥±¡¼¥ë¤Ë´Ø¤ï¤é¤º¡¢\fB^[Yy]\fP ¤Ë¥Þ¥Ã¥Á¤¹¤ë±þÅú¤Ï¾ï¤Ë¹ÎÄê¤À¤È²ò¼á¤µ¤ì¡¢
90 \fB^[Nn]\fP ¤Ë¥Þ¥Ã¥Á¤¹¤ë±þÅú¤Ï¾ï¤ËÈÝÄê¤À¤È²ò¼á¤µ¤ì¤ë¡£
91 .\"O .SH "RETURN VALUE"
92 .SH ÊÖ¤êÃÍ
93 .\"O After examining
94 .\"O .IR response ,
95 .\"O .BR rpmatch ()
96 .\"O returns 0 for a recognized negative response ("no"), 1
97 .\"O for a recognized positive response ("yes"), and \-1 when the value
98 .\"O of \fIresponse\fP is unrecognized.
99 .I response
100 ¤ò¸¡ºº¤·¤¿¸å¡¢
101 .BR rpmatch ()
102 ¤ÏÈÝÄêŪ¤Ê±þÅú ("no") ¤Èǧ¼±¤·¤¿¾ì¹ç¤Ï 0 ¤òÊÖ¤·¡¢
103 ¹ÎÄêŪ¤Ê±þÅú ("yes") ¤Èǧ¼±¤·¤¿¾ì¹ç¤Ï 1 ¤òÊÖ¤¹¡£
104 .I response
105 ¤ÎÃͤò²ò¼á¤Ç¤­¤Ê¤«¤Ã¤¿¾ì¹ç¤Ï \-1 ¤òÊÖ¤¹¡£
106 .\"O .SH ERRORS
107 .SH ¥¨¥é¡¼
108 .\"O A return value of \-1 may indicate either an invalid input, or some
109 .\"O other error.
110 .\"O It is incorrect to only test if the return value is nonzero.
111 ÊÖ¤êÃÍ \-1 ¤¬Ê֤俾ì¹ç¡¢ÆþÎϤ¬ÉÔÀµ¤Ç¤¢¤Ã¤¿¤«¡¢Â¾¤Î²¿¤é¤«¤Î¥¨¥é¡¼¤¬
112 ¤¢¤Ã¤¿¤³¤È¤ò°ÕÌ£¤¹¤ë¡£ÊÖ¤êÃͤ¬ 0 °Ê³°¤«¤É¤¦¤«¤ò³Îǧ¤¹¤ë¤À¤±¤Ç¤Ï
113 ½½Ê¬¤Ç¤Ï¤Ê¤¤¡£
114
115 .\"O .BR rpmatch ()
116 .\"O can fail for any of the reasons that
117 .\"O .BR regcomp (3)
118 .\"O or
119 .\"O .BR regexec (3)
120 .\"O can fail; the cause of the error
121 .\"O is not available from \fIerrno\fP or anywhere else, but indicates a
122 .\"O failure of the regex engine (but this case is indistinguishable from
123 .\"O that of an unrecognized value of \fIresponse\fP).
124 .BR rpmatch ()
125 ¤Ï¡¢
126 .BR regcomp (3)
127 ¤ä
128 .BR regexec (3)
129 ¤¬¼ºÇÔ¤¹¤ëÍýͳ¤Î¤É¤ì¤«¤Ç¼ºÇÔ¤¹¤ë¤³¤È¤¬¤¢¤ë¡£
130 ¥¨¥é¡¼¤Î¸¶°ø¤ò
131 .I errno
132 ¤ä¾¤Î²¿¤«¤ÇÃΤ뤳¤È¤Ï¤Ç¤­¤Ê¤¤¤¬¡¢
133 .I errno
134 ¤ÏÀµµ¬É½¸½¥¨¥ó¥¸¥ó¤Î¼ºÇԤθ¶°ø¤ò¼¨¤·¤Æ¤¤¤ë
135 (⤷¡¢¤³¤Î¥±¡¼¥¹¤È
136 .I response
137 ¤ÎÃͤòǧ¼±¤Ç¤­¤º¤Ë¼ºÇÔ¤·¤¿¾ì¹ç¤ò¶èÊ̤¹¤ë¤³¤È¤Ï¤Ç¤­¤Ê¤¤)¡£
138 .\"O .SH "CONFORMING TO"
139 .SH ½àµò
140 .\"O .BR rpmatch ()
141 .\"O is not required by any standard, but
142 .\"O is available on a few other systems.
143 .BR rpmatch ()
144 ¤Ï¤É¤Îɸ½à¤Ç¤âɬ¿Ü¤È¤Ê¤Ã¤Æ¤¤¤Ê¤¤¤¬¡¢
145 Linux °Ê³°¤Ë¤âÍøÍѤǤ­¤ë¥·¥¹¥Æ¥à¤â¤¤¤¯¤Ä¤«¤Ï¸ºß¤¹¤ë¡£
146 .\"O .\" It is available on at least AIX 5.1 and FreeBSD 6.0.
147 .\" ¾¯¤Ê¤¯¤È¤â AIX 5.1 ¤È FreeBSD 6.0 ¤Ç¤ÏÍøÍѤǤ­¤ë¡£
148 .\"O .SH BUGS
149 .SH ¥Ð¥°
150 .\"O The
151 .\"O .BR rpmatch ()
152 .\"O implementation looks at only the first character
153 .\"O of \fIresponse\fP.
154 .\"O As a consequence, "nyes" returns 0, and
155 .\"O "ynever; not in a million years" returns 1.
156 .\"O It would be preferable to accept input strings much more
157 .\"O strictly, for example (using the extended regular
158 .\"O expression notation described in
159 .\"O .BR regex (7)):
160 .\"O \fB^([yY]|yes|YES)$\fP and \fB^([nN]|no|NO)$\fP.
161 .BR rpmatch ()
162 ¤Î¼ÂÁõ¤Ï
163 .I response
164 ¤ÎºÇ½é¤Î 1 Ê¸»ú¤À¤±¤ò¸«¤Æ¤¤¤ë¤è¤¦¤Ç¤¢¤ë¡£¤½¤Î·ë²Ì¡¢
165 "nyes" ¤Ï 0 ¤òÊÖ¤·¡¢
166 "ynever; not in a million years" ¤Ï 1 ¤òÊÖ¤¹¤³¤È¤Ë¤Ê¤ë¡£
167 ÆþÎÏʸ»úÎó¤ò¤â¤Ã¤È¸·Ì©¤Ë²ò¼á¤·¤¿Êý¤¬¤è¤¤¤À¤í¤¦¡£
168 Î㤨¤Ð¡¢
169 .RB ( regex (7)
170 ¤ÇÀâÌÀ¤µ¤ì¤Æ¤¤¤ë³ÈÄ¥Àµµ¬É½¸½¤ò»È¤Ã¤Æ)
171 .BR ^([yY]|yes|YES)$ " ¤ä " ^([nN]|no|NO)$
172 ¤Ç²ò¼á¤¹¤ë¤Ê¤É¡£
173 .\"O .SH EXAMPLE
174 .SH Îã
175 .\"O The following program displays the results when
176 .\"O .BR rpmatch ()
177 .\"O is applied to the string given in the program's command-line argument.
178 °Ê²¼¤Î¥×¥í¥°¥é¥à¤Ï¡¢¥³¥Þ¥ó¥É¥é¥¤¥ó°ú¤­¿ô¤Ç
179 »ØÄꤵ¤ì¤¿Ê¸»úÎó¤ò
180 .BR rpmatch ()
181 ¤ËÅϤ·¤¿¾ì¹ç¤Î·ë²Ì¤òɽ¼¨¤¹¤ë¡£
182 .nf
183
184 #define _SVID_SOURCE
185 #include <locale.h>
186 #include <stdlib.h>
187 #include <string.h>
188 #include <stdio.h>
189
190 int
191 main(int argc, char *argv[])
192 {
193     if (argc != 2 || strcmp(argv[1], "\-\-help") == 0) {
194         fprintf(stderr, "%s response\\n", argv[0]);
195         exit(EXIT_FAILURE);
196     }
197
198     setlocale(LC_ALL, "");
199     printf("rpmatch() returns: %d\\n", rpmatch(argv[1]));
200     exit(EXIT_SUCCESS);
201 }
202 .fi
203 .\"O .SH SEE ALSO
204 .SH ´ØÏ¢¹àÌÜ
205 .BR fgets (3),
206 .BR getline (3),
207 .BR nl_langinfo (3),
208 .BR regcomp (3),
209 .BR setlocale (3)