.\" .\" $Id: pattern.3,v 1.1 2000/07/27 16:59:03 alaffin Exp $ .\" .\" Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved. .\" .\" This program is free software; you can redistribute it and/or modify it .\" under the terms of version 2 of the GNU General Public License as .\" published by the Free Software Foundation. .\" .\" This program is distributed in the hope that it would be useful, but .\" WITHOUT ANY WARRANTY; without even the implied warranty of .\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. .\" .\" Further, this software is distributed without any warranty that it is .\" free of the rightful claim of any third person regarding infringement .\" or the like. Any license provided herein, whether implied or .\" otherwise, applies only to this software file. Patent licenses, if .\" any, provided herein do not apply to combinations of this program with .\" other software, or any other product whatsoever. .\" .\" You should have received a copy of the GNU General Public License along .\" with this program; if not, write the Free Software Foundation, Inc., .\" 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. .\" .\" Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, .\" Mountain View, CA 94043, or: .\" .\" http://www.sgi.com .\" .\" For further information regarding this notice, see: .\" .\" http://oss.sgi.com/projects/GenInfo/NoticeExplan/ .\" .TH PATTERN 3 07/25/2000 "Linux Test Project" .SH NAME pattern_fill \- Fill a buffer with copies of a pattern .br pattern_check \- Validate a buffer against copies of a pattern .SH SYNOPSIS \fBpattern_fill\fP(char *\fIbuf\fP, int \fIbuflen\fP, char *\fIpat\fP, int \fIpatlen\fP, int \fIpatshift\fP) .br \fBpattern_check\fP(char *\fIbuf\fP, int \fIbuflen\fP, char *\fIpat\fP, int \fIpatlen\fP, int \fIpatshift\fP) .SH DESCRIPTION \fBpattern_fill()\fP fills a buffer of length \fIbuflen\fP with repeated occurrences of a pattern whose length is \fIpatlen\fP. If \fIbuflen\fP is not a multiple of \fIpatlen\fP, a partial pattern will be written in the last part of the buffer. This implies that a buffer which is shorter than the pattern length will receive only a partial pattern. \fBpattern_check()\fP verifies that \fIbuf\fP contains repeated occurrences of the indicated pattern. The \fIpatshift\fP argument to \fBpattern_fill()\fP and \fBpattern_shift()\fP specify that \fIpat\fP should be rotated (\fIpatshift\fP % \fIpatlen\fP) bytes to the left before filling or comparing the buffer. Since the pattern is rotated by (\fIpatshift\fP % \fIpatlen\fP), \fIpatshift\fP may be greater than \fIpathlen\fP. .SH EXAMPLES \fBpattern_fill(buf, sizeof(buf), "abcde", 5, 0)\fR .br .RS 8 fill buf with repeated occurrences of "abcde" .RE .br \fBpattern_check(buf, sizeof(buf), "abcde", 5, 0)\fR .br .RS 8 verify that buf consists of repeated occurrences of "abcde" .RE .br \fBpattern_fill(buf, sizeof(buf), "abcde", 5, 3)\fR .br .RS 8 fill buf with repeated occurrences of "deabc" .RE .SH DIAGNOSTICS \fBpattern_fill()\fP always returns 0 - no validation of arguments is done. .br \fBpattern_check()\fP returns -1 if the buffer does not contain repeated occurrences of the indicated pattern (rotated \fIpatshift\fB bytes) or 0 otherwise. .SH BUGS None known.