1 .\" Copyright 1993 David Metcalfe (david@prism.demon.co.uk)
2 .\" and Copyright (c) 2008 Linux Foundation, written by Michael Kerrisk
3 .\" <mtk.manpages@gmail.com>
5 .\" Japanese Version Copyright (c) 1997 HIROFUMI Nishizuka
6 .\" all rights reserved.
7 .\" Translated 1997-12-16, HIROFUMI Nishizuka <nishi@rpts.cl.nec.co.jp>
8 .\" Updated & Modified 2002-03-24, Yuichi SATO <ysato@h4.dion.ne.jp>
9 .\" Updated & Modified 2003-11-27, Yuichi SATO <ysato444@yahoo.co.jp>
10 .\" Updated 2008-08-11, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>
12 .\" Permission is granted to make and distribute verbatim copies of this
13 .\" manual provided the copyright notice and this permission notice are
14 .\" preserved on all copies.
16 .\" Permission is granted to copy and distribute modified versions of this
17 .\" manual under the conditions for verbatim copying, provided that the
18 .\" entire resulting derived work is distributed under the terms of a
19 .\" permission notice identical to this one.
21 .\" Since the Linux kernel and libraries are constantly changing, this
22 .\" manual page may be incorrect or out-of-date. The author(s) assume no
23 .\" responsibility for errors or omissions, or for damages resulting from
24 .\" the use of the information contained herein. The author(s) may not
25 .\" have taken the same level of care in the production of this manual,
26 .\" which is licensed free of charge, as they might when working
29 .\" Formatted or processed versions of this manual, if unaccompanied by
30 .\" the source, must acknowledge the copyright and authors of this work.
32 .\" Modified Mon Apr 12 12:49:57 1993, David Metcalfe
33 .\" Modified Sat Jul 24 18:56:22 1993, Rik Faith (faith@cs.unc.edu)
34 .\" Modified Wed Feb 20 21:09:36 2002, Ian Redfern (redferni@logica.com)
35 .\" 2008-07-09, mtk, add rawmemchr()
37 .TH MEMCHR 3 2009-12-04 "" "Linux Programmer's Manual"
40 .\"O memchr, memrchr, rawmemchr \- scan memory for a character
41 memchr, memrchr, rawmemchr \- ʸ»ú¤òõ¤¹¤¿¤á¤Ë¥á¥â¥ê¤ò¥¹¥¥ã¥ó¤¹¤ë
45 .B #include <string.h>
47 .BI "void *memchr(const void *" s ", int " c ", size_t " n );
49 .BI "void *memrchr(const void *" s ", int " c ", size_t " n );
51 .BI "void *rawmemchr(const void *" s ", int " c );
55 .\"O Feature Test Macro Requirements for glibc (see
56 .\"O .BR feature_test_macros (7)):
57 glibc ¸þ¤±¤Îµ¡Ç½¸¡ºº¥Þ¥¯¥í¤ÎÍ×·ï
58 .RB ( feature_test_macros (7)
69 .\"O function scans the first \fIn\fP bytes of the memory
70 .\"O area pointed to by \fIs\fP for the character \fIc\fP.
71 .\"O The first byte to
72 .\"O match \fIc\fP (interpreted as an unsigned character) stops the operation.
74 ´Ø¿ô¤Ï¡¢¥Ý¥¤¥ó¥¿ \fIs\fP ¤¬»Ø¤·¼¨¤¹¥á¥â¥ê¥Ö¥í¥Ã¥¯¤Î
75 ÀèƬ¤Î \fIn\fP ¥Ð¥¤¥È¤«¤éʸ»ú \fIc\fP ¤òõ¤¹¡£
76 ºÇ½é¤Ë \fIc\fP (unsigned char ¤È²ò¼á¤µ¤ì¤ë) ¤¬¸«¤Ä¤«¤Ã¤¿»þÅÀ¤ÇÆ°ºî¤¬Ää»ß¤¹¤ë¡£
80 .\"O function is like the
83 .\"O except that it searches backward from the end of the \fIn\fP bytes
84 .\"O pointed to by \fIs\fP instead of forward from the beginning.
89 ÀèƬ¤«¤é½çÊý¸þ¤Ëõ¤¹¤Î¤Ç¤Ï¤Ê¤¯¡¢
90 ¥Ý¥¤¥ó¥¿ \fIs\fP ¤¬»Ø¤·¼¨¤¹ \fIn\fP ¥Ð¥¤¥È¤Î¥á¥â¥ê¥Ö¥í¥Ã¥¯¤Î
91 ËöÈø¤«¤éµÕ¸þ¤¤Ëõ¤¹¡£
95 .\"O function is similar to
97 .\"O it assumes (i.e., the programmer knows for certain)
98 .\"O that the character
100 .\"O lies somewhere in the string
102 .\"O and so performs an optimized search
103 .\"O for the character
105 .\"O (i.e., no checking for the terminating null byte, or use of an argument,
107 .\"O to limit the range of the search).
116 Æâ¤Î¤É¤³¤«¤Ë¤¢¤ë¤³¤È¤òÁ°Äó¤Ë¤·¤Æ
117 (¤Ä¤Þ¤ê¡¢¥×¥í¥°¥é¥Þ¤Ï¤½¤Î¤³¤È¤òÃΤäƤ¤¤ë)¡¢
121 (¤¹¤Ê¤ï¤Á¡¢½ªÃ¼¤Î NULL ¥Ð¥¤¥È¤Î¥Á¥§¥Ã¥¯¤â¹Ô¤ï¤ì¤Ê¤¤¤·¡¢
122 ¸¡º÷ÈϰϤξå¸Â¤ò¼¨¤¹°ú¤¿ô
125 .\"O If the character
127 .\"O is not in the string
130 .\"O .BR rawmemchr ()
131 .\"O may proceed to search beyond the end of the string,
132 .\"O and the result is unspecified.
139 ¤Ïʸ»úÎóËöÈø¤ò±Û¤¨¤Æ¸¡º÷¤ò¼Â¹Ô¤¹¤ë¤«¤â¤·¤ì¤º¡¢·ë²Ì¤ÏÉÔÄê¤Ç¤¢¤ë¡£
140 .\"O The folowing call is a fast means of locating a string's
141 .\"O terminating null byte:
142 ¼¡¤Ë¼¨¤¹¸Æ¤Ó½Ð¤·¤Ï¡¢Ê¸»úÎó½ªÃ¼¤Î NULL ¥Ð¥¤¥È¤Î°ÌÃÖ¤òÆÃÄꤹ¤ë
147 char *p = rawmemchr(s,\ \(aq\\0\(aq);
150 .\"O .SH "RETURN VALUE"
156 .\"O functions return a pointer
157 .\"O to the matching byte or NULL if the character does not occur in
158 .\"O the given memory area.
162 ´Ø¿ô¤Ï°ìÃפ¹¤ëʸ»ú¤Ø¤Î¥Ý¥¤¥ó¥¿¤òÊÖ¤·¡¢
163 ¤â¤·Ê¸»ú¤¬»ØÄê¥á¥â¥êÎΰè¤Ë¸½¤ì¤Ê¤¤¾ì¹ç¤Ï NULL ¤òÊÖ¤¹¡£
166 .\"O .BR rawmemchr ()
167 .\"O function returns a pointer to the matching byte, if one is found.
168 .\"O If no matching byte is found, the result is unspecified.
170 ´Ø¿ô¤Ï¥Þ¥Ã¥Á¤¹¤ë¥Ð¥¤¥È¤¬¸«¤Ä¤«¤Ã¤¿¾ì¹ç¤Ï¥Þ¥Ã¥Á¤·¤¿¥Ð¥¤¥È¤Ø¤Î¥Ý¥¤¥ó¥¿¤òÊÖ¤¹¡£
171 ¥Þ¥Ã¥Á¤¹¤ë¥Ð¥¤¥È¤¬¸«¤Ä¤«¤é¤Ê¤«¤Ã¤¿¾ì¹ç¡¢·ë²Ì¤ÏÉÔÄê¤Ç¤¢¤ë¡£
174 .\"O .BR rawmemchr ()
175 .\"O first appeared in glibc in version 2.1.
177 ¤Ï glibc ¥Ð¡¼¥¸¥ç¥ó 2.1 ¤Ç½é¤á¤ÆÅо줷¤¿¡£
180 .\"O first appeared in glibc in version 2.2.
182 ¤Ï glibc ¥Ð¡¼¥¸¥ç¥ó 2.2 ¤Ç½é¤á¤ÆÅо줷¤¿¡£
183 .\"O .SH "CONFORMING TO"
187 .\"O function conforms to SVr4, 4.3BSD, C89, C99, POSIX.1-2001.
189 ´Ø¿ô¤Ï SVr4, 4.3BSD, C89, C99, POSIX.1-2001 ¤Ë½àµò¤¹¤ë¡£
193 .\"O function is a GNU extension, available since glibc 2.1.91.
195 ´Ø¿ô¤Ï GNU ³ÈÄ¥¤Ç¤¢¤ê¡¢glibc 2.1.91 ¤«¤é»ÈÍѲÄǽ¤Ç¤¢¤ë¡£
198 .\"O .BR rawmemchr ()
199 .\"O function is a GNU extension, available since glibc 2.1.
201 ´Ø¿ô¤Ï GNU ³ÈÄ¥¤Ç¤¢¤ê¡¢glibc 2.1 ¤«¤é»ÈÍѲÄǽ¤Ç¤¢¤ë¡£