.\" Copyright 1993 David Metcalfe (david@prism.demon.co.uk) .\" and Copyright (c) 2008 Linux Foundation, written by Michael Kerrisk .\" .\" .\" Japanese Version Copyright (c) 1997 HIROFUMI Nishizuka .\" all rights reserved. .\" Translated 1997-12-16, HIROFUMI Nishizuka .\" Updated & Modified 2002-03-24, Yuichi SATO .\" Updated & Modified 2003-11-27, Yuichi SATO .\" Updated 2008-08-11, Akihiro MOTOKI .\" .\" Permission is granted to make and distribute verbatim copies of this .\" manual provided the copyright notice and this permission notice are .\" preserved on all copies. .\" .\" Permission is granted to copy and distribute modified versions of this .\" manual under the conditions for verbatim copying, provided that the .\" entire resulting derived work is distributed under the terms of a .\" permission notice identical to this one. .\" .\" Since the Linux kernel and libraries are constantly changing, this .\" manual page may be incorrect or out-of-date. The author(s) assume no .\" responsibility for errors or omissions, or for damages resulting from .\" the use of the information contained herein. The author(s) may not .\" have taken the same level of care in the production of this manual, .\" which is licensed free of charge, as they might when working .\" professionally. .\" .\" Formatted or processed versions of this manual, if unaccompanied by .\" the source, must acknowledge the copyright and authors of this work. .\" .\" Modified Mon Apr 12 12:49:57 1993, David Metcalfe .\" Modified Sat Jul 24 18:56:22 1993, Rik Faith (faith@cs.unc.edu) .\" Modified Wed Feb 20 21:09:36 2002, Ian Redfern (redferni@logica.com) .\" 2008-07-09, mtk, add rawmemchr() .\" .TH MEMCHR 3 2009-12-04 "" "Linux Programmer's Manual" .\"O .SH NAME .SH 名前 .\"O memchr, memrchr, rawmemchr \- scan memory for a character memchr, memrchr, rawmemchr \- 文字を探すためにメモリをスキャンする .\"O .SH SYNOPSIS .SH 書式 .nf .B #include .BI "void *memchr(const void *" s ", int " c ", size_t " n ); .BI "void *memrchr(const void *" s ", int " c ", size_t " n ); .BI "void *rawmemchr(const void *" s ", int " c ); .fi .sp .in -4n .\"O Feature Test Macro Requirements for glibc (see .\"O .BR feature_test_macros (7)): glibc 向けの機能検査マクロの要件 .RB ( feature_test_macros (7) 参照): .in .sp .BR memrchr (): .BR rawmemchr (): _GNU_SOURCE .\"O .SH DESCRIPTION .SH 説明 .\"O The .\"O .BR memchr () .\"O function scans the first \fIn\fP bytes of the memory .\"O area pointed to by \fIs\fP for the character \fIc\fP. .\"O The first byte to .\"O match \fIc\fP (interpreted as an unsigned character) stops the operation. .BR memchr () 関数は、ポインタ \fIs\fP が指し示すメモリブロックの 先頭の \fIn\fP バイトから文字 \fIc\fP を探す。 最初に \fIc\fP (unsigned char と解釈される) が見つかった時点で動作が停止する。 .PP .\"O The .\"O .BR memrchr () .\"O function is like the .\"O .BR memchr () .\"O function, .\"O except that it searches backward from the end of the \fIn\fP bytes .\"O pointed to by \fIs\fP instead of forward from the beginning. .BR memrchr () 関数は .BR memchr () 関数に似ているが、 先頭から順方向に探すのではなく、 ポインタ \fIs\fP が指し示す \fIn\fP バイトのメモリブロックの 末尾から逆向きに探す。 .\"O The .\"O .BR rawmemchr () .\"O function is similar to .\"O .BR memchr (): .\"O it assumes (i.e., the programmer knows for certain) .\"O that the character .\"O .I c .\"O lies somewhere in the string .\"O .IR s , .\"O and so performs an optimized search .\"O for the character .\"O .IR c .\"O (i.e., no checking for the terminating null byte, or use of an argument, .\"O .IR n , .\"O to limit the range of the search). .BR rawmemchr () 関数は .BR memchr () と同様だが、 文字 .I c が文字列 .I s 内のどこかにあることを前提にして (つまり、プログラマはそのことを知っている)、 最適化した方法で文字 .I c の検索を実行する (すなわち、終端の NULL バイトのチェックも行われないし、 検索範囲の上限を示す引き数 .I n も使用されない)。 .\"O If the character .\"O .I c .\"O is not in the string .\"O .IR s , .\"O then .\"O .BR rawmemchr () .\"O may proceed to search beyond the end of the string, .\"O and the result is unspecified. 文字 .I c が文字列 .I s 内にない場合、 .BR rawmemchr () は文字列末尾を越えて検索を実行するかもしれず、結果は不定である。 .\"O The folowing call is a fast means of locating a string's .\"O terminating null byte: 次に示す呼び出しは、文字列終端の NULL バイトの位置を特定する 高速な手段である。 .in +4n .nf char *p = rawmemchr(s,\ \(aq\\0\(aq); .fi .in .\"O .SH "RETURN VALUE" .SH 返り値 .\"O The .\"O .BR memchr () .\"O and .\"O .BR memrchr () .\"O functions return a pointer .\"O to the matching byte or NULL if the character does not occur in .\"O the given memory area. .BR memchr () 関数と .BR memrchr () 関数は一致する文字へのポインタを返し、 もし文字が指定メモリ領域に現れない場合は NULL を返す。 .\"O The .\"O .BR rawmemchr () .\"O function returns a pointer to the matching byte, if one is found. .\"O If no matching byte is found, the result is unspecified. .BR rawmemchr () 関数はマッチするバイトが見つかった場合はマッチしたバイトへのポインタを返す。 マッチするバイトが見つからなかった場合、結果は不定である。 .\"O .SH VERSIONS .SH バージョン .\"O .BR rawmemchr () .\"O first appeared in glibc in version 2.1. .BR rawmemchr () は glibc バージョン 2.1 で初めて登場した。 .\"O .BR memrchr () .\"O first appeared in glibc in version 2.2. .BR memrchr () は glibc バージョン 2.2 で初めて登場した。 .\"O .SH "CONFORMING TO" .SH 準拠 .\"O The .\"O .BR memchr () .\"O function conforms to SVr4, 4.3BSD, C89, C99, POSIX.1-2001. .BR memchr () 関数は SVr4, 4.3BSD, C89, C99, POSIX.1-2001 に準拠する。 .\"O The .\"O .BR memrchr () .\"O function is a GNU extension, available since glibc 2.1.91. .BR memrchr () 関数は GNU 拡張であり、glibc 2.1.91 から使用可能である。 .\"O The .\"O .BR rawmemchr () .\"O function is a GNU extension, available since glibc 2.1. .BR rawmemchr () 関数は GNU 拡張であり、glibc 2.1 から使用可能である。 .\"O .SH "SEE ALSO" .SH 関連項目 .BR ffs (3), .BR index (3), .BR rindex (3), .BR strchr (3), .BR strpbrk (3), .BR strrchr (3), .BR strsep (3), .BR strspn (3), .BR strstr (3), .BR wmemchr (3)