$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/

PATTERN 3 07/25/2000 "Linux Test Project"
NAME
pattern_fill - Fill a buffer with copies of a pattern

pattern_check - Validate a buffer against copies of a pattern

SYNOPSIS
pattern_fill(char *buf, int buflen, char *pat, int patlen, int patshift)

pattern_check(char *buf, int buflen, char *pat, int patlen, int patshift)

DESCRIPTION
pattern_fill() fills a buffer of length buflen with repeated occurrences of a pattern whose length is patlen. If buflen is not a multiple of patlen, 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. pattern_check() verifies that buf contains repeated occurrences of the indicated pattern. The patshift argument to pattern_fill() and pattern_shift() specify that pat should be rotated (patshift % patlen) bytes to the left before filling or comparing the buffer. Since the pattern is rotated by (patshift % patlen), patshift may be greater than pathlen.
EXAMPLES
pattern_fill(buf, sizeof(buf), "abcde", 5, 0)

fill buf with repeated occurrences of "abcde"

pattern_check(buf, sizeof(buf), "abcde", 5, 0)

verify that buf consists of repeated occurrences of "abcde"

pattern_fill(buf, sizeof(buf), "abcde", 5, 3)

fill buf with repeated occurrences of "deabc"

DIAGNOSTICS
pattern_fill() always returns 0 - no validation of arguments is done.

pattern_check() returns -1 if the buffer does not contain repeated occurrences of the indicated pattern (rotated patshift bytes) or 0 otherwise.

BUGS
None known.