diff options
author | Richard Lowe <richlowe@richlowe.net> | 2011-03-14 14:05:30 -0400 |
---|---|---|
committer | Richard Lowe <richlowe@richlowe.net> | 2011-03-14 14:05:30 -0400 |
commit | c10c16dec587a0662068f6e2991c29ed3a9db943 (patch) | |
tree | f414286f4bba41d75683ed4fbbaa6bfa4bf7fabd /usr/src/man/man3gen | |
parent | 68caef18a23a498d9e3017b983562c0f4fd8ab23 (diff) | |
download | illumos-joyent-c10c16dec587a0662068f6e2991c29ed3a9db943.tar.gz |
243 system manual pages should live with the software
Reviewed by: garrett@nexenta.com
Reviewed by: gwr@nexenta.com
Reviewed by: trisk@opensolaris.org
Approved by: gwr@nexenta.com
--HG--
extra : rebase_source : 0c599d0bec0dc8865fbba67721a7a6cd6b1feefb
Diffstat (limited to 'usr/src/man/man3gen')
-rw-r--r-- | usr/src/man/man3gen/Makefile | 67 | ||||
-rw-r--r-- | usr/src/man/man3gen/bgets.3gen | 122 | ||||
-rw-r--r-- | usr/src/man/man3gen/bufsplit.3gen | 83 | ||||
-rw-r--r-- | usr/src/man/man3gen/copylist.3gen | 85 | ||||
-rw-r--r-- | usr/src/man/man3gen/gmatch.3gen | 72 | ||||
-rw-r--r-- | usr/src/man/man3gen/isencrypt.3gen | 75 | ||||
-rw-r--r-- | usr/src/man/man3gen/mkdirp.3gen | 97 | ||||
-rw-r--r-- | usr/src/man/man3gen/p2open.3gen | 113 | ||||
-rw-r--r-- | usr/src/man/man3gen/pathfind.3gen | 133 | ||||
-rw-r--r-- | usr/src/man/man3gen/regexpr.3gen | 216 | ||||
-rw-r--r-- | usr/src/man/man3gen/strccpy.3gen | 105 | ||||
-rw-r--r-- | usr/src/man/man3gen/strfind.3gen | 93 |
12 files changed, 1261 insertions, 0 deletions
diff --git a/usr/src/man/man3gen/Makefile b/usr/src/man/man3gen/Makefile new file mode 100644 index 0000000000..3d7d513f18 --- /dev/null +++ b/usr/src/man/man3gen/Makefile @@ -0,0 +1,67 @@ +# +# This file and its contents are supplied under the terms of the +# Common Development and Distribution License ("CDDL"), version 1.0. +# You may only use this file in accordance with the terms of version +# 1.0 of the CDDL. +# +# A full copy of the text of the CDDL should have accompanied this +# source. A copy of the CDDL is also available via the Internet +# at http://www.illumos.org/license/CDDL. +# + +# Copyright 2011, Richard Lowe + +include ../../Makefile.master + +MANSECT = 3gen + +MANFILES = bgets.3gen \ + bufsplit.3gen \ + copylist.3gen \ + gmatch.3gen \ + isencrypt.3gen \ + mkdirp.3gen \ + p2open.3gen \ + pathfind.3gen \ + regexpr.3gen \ + strccpy.3gen \ + strfind.3gen + +MANSOFILES = advance.3gen \ + compile.3gen \ + p2close.3gen \ + rmdirp.3gen \ + step.3gen \ + str.3gen \ + strcadd.3gen \ + streadd.3gen \ + strecpy.3gen \ + strrspn.3gen \ + strtrns.3gen + +MANFILES += $(MANSOFILES) + +rmdirp.3gen := SOSRC = man3gen/mkdirp.3gen + +p2close.3gen := SOSRC = man3gen/p2open.3gen + +advance.3gen := SOSRC = man3gen/regexpr.3gen +compile.3gen := SOSRC = man3gen/regexpr.3gen +step.3gen := SOSRC = man3gen/regexpr.3gen + +strcadd.3gen := SOSRC = man3gen/strccpy.3gen +streadd.3gen := SOSRC = man3gen/strccpy.3gen +strecpy.3gen := SOSRC = man3gen/strccpy.3gen + +str.3gen := SOSRC = man3gen/strfind.3gen +strrspn.3gen := SOSRC = man3gen/strfind.3gen +strtrns.3gen := SOSRC = man3gen/strfind.3gen + + +.KEEP_STATE: + +include ../Makefile.man + +install: $(ROOTMANFILES) + + diff --git a/usr/src/man/man3gen/bgets.3gen b/usr/src/man/man3gen/bgets.3gen new file mode 100644 index 0000000000..9b90c465db --- /dev/null +++ b/usr/src/man/man3gen/bgets.3gen @@ -0,0 +1,122 @@ +'\" te +.\" Copyright 1989 AT&T Copyright (c) 2001, Sun Microsystems, Inc. All Rights Reserved +.\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License. +.\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License. +.\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner] +.TH bgets 3GEN "9 May 2001" "SunOS 5.11" "String Pattern-Matching Library Functions" +.SH NAME +bgets \- read stream up to next delimiter +.SH SYNOPSIS +.LP +.nf +cc [ \fIflag\fR ... ] \fIfile\fR ... \fB-lgen\fR [ \fIlibrary\fR ... ] +#include <libgen.h> + +\fBchar *\fR\fBbgets\fR(\fBchar *\fR\fIbuffer\fR, \fBsize_t\fR \fIcount\fR, \fBFILE *\fR\fIstream\fR, + \fBconst char *\fR\fIbreakstring\fR); +.fi + +.SH DESCRIPTION +.sp +.LP +The \fBbgets()\fR function reads characters from \fIstream\fR into \fIbuffer\fR +until either \fIcount\fR is exhausted or one of the characters in +\fIbreakstring\fR is encountered in the stream. The read data is terminated +with a null byte ('\fB\e0\fR\&') and a pointer to the trailing null is +returned. If a \fIbreakstring\fR character is encountered, the last non-null is +the delimiter character that terminated the scan. +.sp +.LP +Note that, except for the fact that the returned value points to the \fBend\fR +of the read string rather than to the beginning, the call +.sp +.in +2 +.nf +bgets(buffer, sizeof buffer, stream, "\en"); +.fi +.in -2 + +.sp +.LP +is identical to +.sp +.in +2 +.nf +fgets (buffer, sizeof buffer, stream); +.fi +.in -2 + +.sp +.LP +There is always enough room reserved in the buffer for the trailing null +character. +.sp +.LP +If \fIbreakstring\fR is a null pointer, the value of \fIbreakstring\fR from the +previous call is used. If \fIbreakstring\fR is null at the first call, no +characters will be used to delimit the string. +.SH RETURN VALUES +.sp +.LP +\fINULL\fR is returned on error or end-of-file. Reporting the condition is +delayed to the next call if any characters were read but not yet returned. +.SH EXAMPLES +.LP +\fBExample 1 \fRExample of the \fBbgets()\fR function. +.sp +.LP +The following example prints the name of the first user encountered in +\fB/etc/passswd\fR, including a trailing ":" + +.sp +.in +2 +.nf +#include <stdio.h> +#include<libgen.h> + +int main() +{ + char buffer[8]; + FILE *fp; + + if ((fp = fopen("/etc/passwd","r")) == NULL) { + perror("/etc/passwd"); + return 1; + } + if (bgets(buffer, 8, fp, ":") == NULL) { + perror("bgets"); + return 1; + } + (void) puts(buffer); + return 0; +} +.fi +.in -2 + +.SH ATTRIBUTES +.sp +.LP +See \fBattributes\fR(5) for descriptions of the following attributes: +.sp + +.sp +.TS +tab() box; +cw(2.75i) |cw(2.75i) +lw(2.75i) |lw(2.75i) +. +ATTRIBUTE TYPEATTRIBUTE VALUE +_ +MT-LevelMT-Safe +.TE + +.SH SEE ALSO +.sp +.LP +\fBgets\fR(3C), \fBattributes\fR(5) +.SH NOTES +.sp +.LP +When compiling multithread applications, the \fB_REENTRANT\fR flag must be +defined on the compile line. This flag should only be used in multithreaded +applications. diff --git a/usr/src/man/man3gen/bufsplit.3gen b/usr/src/man/man3gen/bufsplit.3gen new file mode 100644 index 0000000000..c092e5df37 --- /dev/null +++ b/usr/src/man/man3gen/bufsplit.3gen @@ -0,0 +1,83 @@ +'\" te +.\" Copyright 1989 AT&T Copyright (c) 1997, Sun Microsystems, Inc. All Rights Reserved +.\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License. +.\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License. +.\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner] +.TH bufsplit 3GEN "29 Dec 1996" "SunOS 5.11" "String Pattern-Matching Library Functions" +.SH NAME +bufsplit \- split buffer into fields +.SH SYNOPSIS +.LP +.nf +cc [ \fIflag\fR ... ] \fIfile\fR ... \fB-lgen\fR [ \fIlibrary\fR ... ] +#include <libgen.h> + +\fBsize_t\fR \fBbufsplit\fR(\fBchar *\fR\fIbuf\fR, \fBsize_t\fR \fIn\fR, \fBchar **\fR\fIa\fR); +.fi + +.SH DESCRIPTION +.sp +.LP +\fBbufsplit()\fR examines the buffer, \fIbuf\fR, and assigns values to the +pointer array, \fIa\fR, so that the pointers point to the first \fIn\fR fields +in \fIbuf\fR that are delimited by \fBTABs\fR or \fBNEWLINEs.\fR +.sp +.LP +To change the characters used to separate fields, call \fBbufsplit()\fR with +\fIbuf\fR pointing to the string of characters, and \fIn\fR and \fIa\fR set to +zero. For example, to use colon (\|:\|), period (\|.\|), and comma (\|,\|), +as separators along with \fBTAB\fR and \fBNEWLINE:\fR +.sp +.LP +\fBbufsplit (":.,\et\en", 0, (char**)0 );\fR +.SH RETURN VALUES +.sp +.LP +The number of fields assigned in the array \fIa\fR. If \fIbuf\fR is zero, the +return value is zero and the array is unchanged. Otherwise the value is at +least one. The remainder of the elements in the array are assigned the address +of the null byte at the end of the buffer. +.SH EXAMPLES +.LP +\fBExample 1 \fRExample of \fBbufsplit()\fR function. +.sp +.in +2 +.nf +/* + * set a[0] = "This", a[1] = "is", a[2] = "a", + * a[3] = "test" + */ +bufsplit("This\etis\eta\ettest\en", 4, a); +.fi +.in -2 + +.SH NOTES +.sp +.LP +\fBbufsplit()\fR changes the delimiters to null bytes in \fIbuf\fR. +.sp +.LP +When compiling multithreaded applications, the \fB_REENTRANT\fR flag must be +defined on the compile line. This flag should only be used in multithreaded +applications. +.SH ATTRIBUTES +.sp +.LP +See \fBattributes\fR(5) for descriptions of the following attributes: +.sp + +.sp +.TS +tab() box; +cw(2.75i) |cw(2.75i) +lw(2.75i) |lw(2.75i) +. +ATTRIBUTE TYPEATTRIBUTE VALUE +_ +MT-LevelMT-Safe +.TE + +.SH SEE ALSO +.sp +.LP +\fBattributes\fR(5) diff --git a/usr/src/man/man3gen/copylist.3gen b/usr/src/man/man3gen/copylist.3gen new file mode 100644 index 0000000000..72e07d3e68 --- /dev/null +++ b/usr/src/man/man3gen/copylist.3gen @@ -0,0 +1,85 @@ +'\" te +.\" Copyright 1989 AT&T Copyright (c) 1996, Sun Microsystems, Inc. All Rights Reserved +.\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License. +.\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License. +.\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner] +.TH copylist 3GEN "29 Dec 1996" "SunOS 5.11" "String Pattern-Matching Library Functions" +.SH NAME +copylist \- copy a file into memory +.SH SYNOPSIS +.LP +.nf +cc [ \fIflag\fR ... ] \fIfile\fR ... \fB-lgen\fR [ \fIlibrary\fR ... ] +#include <libgen.h> + +\fBchar *\fR\fBcopylist\fR(\fBconst char *\fR\fIfilenm\fR, \fBoff_t *\fR\fIszptr\fR); +.fi + +.SH DESCRIPTION +.sp +.LP +The \fBcopylist()\fR function copies a list of items from a file into freshly +allocated memory, replacing new-lines with null characters. It expects two +arguments: a pointer \fIfilenm\fR to the name of the file to be copied, and a +pointer \fIszptr\fR to a variable where the size of the file will be stored. +.sp +.LP +Upon success, \fBcopylist()\fR returns a pointer to the memory allocated. +Otherwise it returns NULL if it has trouble finding the file, calling +\fBmalloc()\fR, or reading the file. +.SH USAGE +.sp +.LP +The \fBcopylist()\fR function has a transitional interface for 64-bit file +offsets. See \fBlf64\fR(5). +.SH EXAMPLES +.LP +\fBExample 1 \fRExample of \fBcopylist()\fR function. +.sp +.in +2 +.nf +/* read "file" into buf */ +off_t size; +char *buf; +buf = copylist("file", &size); +if (buf) { + for (i=0; i<size; i++) + if (buf[i]) + putchar(buf[i]); + else + putchar('\en'); + } +} else { + fprintf(stderr, "%s: Copy failed for "file".\en", argv[0]); + exit (1); +} +.fi +.in -2 + +.SH ATTRIBUTES +.sp +.LP +See \fBattributes\fR(5) for descriptions of the following attributes: +.sp + +.sp +.TS +tab() box; +cw(2.75i) |cw(2.75i) +lw(2.75i) |lw(2.75i) +. +ATTRIBUTE TYPEATTRIBUTE VALUE +_ +MT-LevelMT-Safe +.TE + +.SH SEE ALSO +.sp +.LP +\fBmalloc\fR(3C), \fBattributes\fR(5), \fBlf64\fR(5) +.SH NOTES +.sp +.LP +When compiling multithreaded applications, the \fB_REENTRANT\fR flag must be +defined on the compile line. This flag should only be used in multithreaded +applications. diff --git a/usr/src/man/man3gen/gmatch.3gen b/usr/src/man/man3gen/gmatch.3gen new file mode 100644 index 0000000000..0ec321eedf --- /dev/null +++ b/usr/src/man/man3gen/gmatch.3gen @@ -0,0 +1,72 @@ +'\" te +.\" Copyright 1989 AT&T Copyright (c) 1997, Sun Microsystems, Inc. All Rights Reserved +.\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License. +.\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License. +.\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner] +.TH gmatch 3GEN "29 Dec 1996" "SunOS 5.11" "String Pattern-Matching Library Functions" +.SH NAME +gmatch \- shell global pattern matching +.SH SYNOPSIS +.LP +.nf +cc [ \fIflag\fR ... ] \fIfile\fR ... \fB-lgen\fR [ \fIlibrary\fR ... ] +#include <libgen.h> + +\fBint\fR \fBgmatch\fR(\fBconst char *\fR\fIstr\fR, \fBconst char *\fR\fIpattern\fR); +.fi + +.SH DESCRIPTION +.sp +.LP +\fBgmatch()\fR checks whether the null-terminated string \fIstr\fR matches the +null-terminated pattern string \fIpattern\fR. See the \fBsh\fR(1), section +\fBFile Name Generation\fR, for a discussion of pattern matching. A backslash +(\fB\e\fR) is used as an escape character in pattern strings. +.SH RETURN VALUES +.sp +.LP +\fBgmatch()\fR returns non-zero if the pattern matches the string, zero if the +pattern does not. +.SH EXAMPLES +.LP +\fBExample 1 \fRExamples of \fBgmatch()\fR function. +.sp +.LP +In the following example, \fBgmatch()\fR returns non-zero (true) for all +strings with "\fBa\fR" or "\fB-\fR" as their last character. + +.sp +.in +2 +.nf +char *s; +gmatch (s, "*[a\e-]" ) +.fi +.in -2 + +.SH ATTRIBUTES +.sp +.LP +See \fBattributes\fR(5) for descriptions of the following attributes: +.sp + +.sp +.TS +tab() box; +cw(2.75i) |cw(2.75i) +lw(2.75i) |lw(2.75i) +. +ATTRIBUTE TYPEATTRIBUTE VALUE +_ +MT-LevelMT-Safe +.TE + +.SH SEE ALSO +.sp +.LP +\fBsh\fR(1), \fBattributes\fR(5) +.SH NOTES +.sp +.LP +When compiling multithreaded applications, the \fB_REENTRANT\fR flag must be +defined on the compile line. This flag should only be used in multithreaded +applications. diff --git a/usr/src/man/man3gen/isencrypt.3gen b/usr/src/man/man3gen/isencrypt.3gen new file mode 100644 index 0000000000..84aca5a80d --- /dev/null +++ b/usr/src/man/man3gen/isencrypt.3gen @@ -0,0 +1,75 @@ +'\" te +.\" Copyright 1989 AT&T Copyright (c) 1997, Sun Microsystems, Inc. All Rights Reserved +.\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License. +.\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License. +.\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner] +.TH isencrypt 3GEN "29 Dec 1996" "SunOS 5.11" "String Pattern-Matching Library Functions" +.SH NAME +isencrypt \- determine whether a buffer of characters is encrypted +.SH SYNOPSIS +.LP +.nf +\fBcc\fR [\fIflag\fR]... [\fIfile\fR]... \fB-lgen\fR [\fIlibrary\fR]... +.fi + +.LP +.nf +#include<libgen.h> + +\fBint\fR \fBisencrypt\fR(\fBconst char *\fR\fIfbuf\fR, \fBsize_t\fR \fIninbuf\fR); +.fi + +.SH DESCRIPTION +.sp +.LP +\fBisencrypt()\fR uses heuristics to determine whether a buffer of characters +is encrypted. It requires two arguments: a pointer to an array of characters +and the number of characters in the buffer. +.sp +.LP +\fBisencrypt()\fR assumes that the file is not encrypted if all the characters +in the first block are \fBASCII\fR characters. If there are non-\fBASCII\fR +characters in the first \fIninbuf\fR characters, and if the \fBsetlocale()\fR +\fBLC_CTYPE\fR category is set to \fBC\fR or \fBascii\fR, \fBisencrypt()\fR +assumes that the buffer is encrypted +.sp +.LP +If the \fBLC_CTYPE\fR category is set to a value other than \fBC\fR or +\fBascii\fR, then \fBisencrypt()\fR uses a combination of heuristics to +determine if the buffer is encrypted. If \fIninbuf\fR has at least 64 +characters, a chi-square test is used to determine if the bytes in the buffer +have a uniform distribution; if it does, then \fBisencrypt()\fR assumes the +buffer is encrypted. If the buffer has less than 64 characters, a check is +made for null characters and a terminating new-line to determine whether the +buffer is encrypted. +.SH RETURN VALUES +.sp +.LP +If the buffer is encrypted, \fB1\fR is returned; otherwise, zero is returned. +.SH ATTRIBUTES +.sp +.LP +See \fBattributes\fR(5) for descriptions of the following attributes: +.sp + +.sp +.TS +tab() box; +cw(2.75i) |cw(2.75i) +lw(2.75i) |lw(2.75i) +. +ATTRIBUTE TYPEATTRIBUTE VALUE +_ +MT-LevelMT-Safe +.TE + +.SH SEE ALSO +.sp +.LP +\fBsetlocale\fR(3C), \fBattributes\fR(5) +.SH NOTES +.sp +.LP +When compiling multithreaded applications, the \fB_REENTRANT\fR flag must be +defined on the compile line. This flag should only be used in multithreaded +applications. diff --git a/usr/src/man/man3gen/mkdirp.3gen b/usr/src/man/man3gen/mkdirp.3gen new file mode 100644 index 0000000000..e95888cd0a --- /dev/null +++ b/usr/src/man/man3gen/mkdirp.3gen @@ -0,0 +1,97 @@ +'\" te +.\" Copyright 1989 AT&T. Copyright (c) 2003, Sun Microsystems, Inc. All Rights Reserved. +.\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License. +.\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License. +.\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner] +.TH mkdirp 3GEN "14 Oct 2003" "SunOS 5.11" "String Pattern-Matching Library Functions" +.SH NAME +mkdirp, rmdirp \- create or remove directories in a path +.SH SYNOPSIS +.LP +.nf +cc [ \fIflag\fR ... ] \fIfile\fR ... \fB-lgen\fR [ \fIlibrary\fR ... ] +#include <libgen.h> + +\fBint\fR \fBmkdirp\fR(\fBconst char *\fR\fIpath\fR, \fBmode_t\fR \fImode\fR); +.fi + +.LP +.nf +\fBint\fR \fBrmdirp\fR(\fBchar *\fR\fIdir\fR, \fBchar *\fR\fIdir1\fR); +.fi + +.SH DESCRIPTION +.sp +.LP +The \fBmkdirp()\fR function creates all the missing directories in \fIpath\fR +with \fImode\fR. See \fBchmod\fR(2) for the values of \fImode\fR. +.sp +.LP +The \fBrmdirp()\fR function removes directories in path \fIdir\fR. This removal +begins at the end of the path and moves backward toward the root as far as +possible. If an error occurs, the remaining path is stored in \fIdir1\fR. +.SH RETURN VALUES +.sp +.LP +If \fIpath\fR already exists or if a needed directory cannot be created, +\fBmkdirp()\fR returns \fB\(mi1\fR and sets \fBerrno\fR to one of the error +values listed for \fBmkdir\fR(2). It returns zero if all the directories are +created. +.sp +.LP +The \fBrmdirp()\fR function returns \fB0\fR if it is able to remove every +directory in the path. It returns \fB\(mi2\fR if a ``\fB\&.\fR'' or +``\fB\&..\fR'' is in the path and \fB\(mi3\fR if an attempt is made to remove +the current directory. Otherwise it returns \fB\(mi1\fR\&. +.SH EXAMPLES +.LP +\fBExample 1 \fRExample of creating scratch directories. +.sp +.LP +The following example creates scratch directories. + +.sp +.in +2 +.nf +/* create scratch directories */ +if(mkdirp("/tmp/sub1/sub2/sub3", 0755) == \(mi1) { + fprintf(stderr, "cannot create directory"); + exit(1); +} +chdir("/tmp/sub1/sub2/sub3"); +\&. +\&. +\&. +/* cleanup */ +chdir("/tmp"); +rmdirp("sub1/sub2/sub3"); +.fi +.in -2 + +.SH ATTRIBUTES +.sp +.LP +See \fBattributes\fR(5) for descriptions of the following attributes: +.sp + +.sp +.TS +tab() box; +cw(2.75i) |cw(2.75i) +lw(2.75i) |lw(2.75i) +. +ATTRIBUTE TYPEATTRIBUTE VALUE +_ +MT-LevelMT-Safe +.TE + +.SH SEE ALSO +.sp +.LP +\fBchmod\fR(2), \fBmkdir\fR(2), \fBrmdir\fR(2), \fBmalloc\fR(3C), +\fBattributes\fR(5) +.SH NOTES +.sp +.LP +The \fBmkdirp()\fR function uses \fBmalloc\fR(3C) to allocate temporary space +for the string. diff --git a/usr/src/man/man3gen/p2open.3gen b/usr/src/man/man3gen/p2open.3gen new file mode 100644 index 0000000000..8d1f75dabb --- /dev/null +++ b/usr/src/man/man3gen/p2open.3gen @@ -0,0 +1,113 @@ +'\" te +.\" Copyright (c) 1996, Sun Microsystems, Inc. All Rights Reserved. +.\" Copyright 1989 AT&T +.\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License. +.\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License. +.\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner] +.TH p2open 3GEN "29 Dec 1996" "SunOS 5.11" "String Pattern-Matching Library Functions" +.SH NAME +p2open, p2close \- open, close pipes to and from a command +.SH SYNOPSIS +.LP +.nf +cc [ \fIflag\fR ... ] \fIfile\fR ... \fB-lgen\fR [ \fIlibrary\fR ... ] +#include <libgen.h> + +\fBint\fR \fBp2open\fR(\fBconst char *\fR\fIcmd\fR, \fBFILE *\fR\fIfp\fR[2]); +.fi + +.LP +.nf +\fBint\fR \fBp2close\fR(\fBFILE *\fR\fIfp\fR[2]); +.fi + +.SH DESCRIPTION +.sp +.LP +The \fBp2open()\fRgfunction forks and execs a shell running the command line +pointed to by \fIcmd\fR. On return, \fBfp[0]\fR points to a \fBFILE\fR pointer +to write the command's standard input and \fBfp[1]\fR points to a \fBFILE\fR +pointer to read from the command's standard output. In this way the program +has control over the input and output of the command. +.sp +.LP +The function returns \fB0\fR if successful; otherwise, it returns +\fB\(mi1\fR\&. +.sp +.LP +The \fBp2close()\fR function is used to close the file pointers that +\fBp2open()\fR opened. It waits for the process to terminate and returns the +process status. It returns \fB0\fR if successful; otherwise, it returns +\fB\(mi1\fR\&. +.SH RETURN VALUES +.sp +.LP +A common problem is having too few file descriptors. The \fBp2close()\fR +function returns \fB\(mi1\fR if the two file pointers are not from the same +\fBp2open()\fR. +.SH EXAMPLES +.LP +\fBExample 1 \fRExample of file descriptors. +.sp +.in +2 +.nf +#include <stdio.h> +#include <libgen.h> + +main(argc,argv) +int argc; +char **argv; +{ + FILE *fp[2]; + pid_t pid; + char buf[16]; + + pid=p2open("/usr/bin/cat", fp); + if ( pid == \(mi1 ) { + fprintf(stderr, "p2open failed\en"); + exit(1); + } + write(fileno(fp[0]),"This is a test\en", 16); + if(read(fileno(fp[1]), buf, 16) <=0) + fprintf(stderr, "p2open failed\en"); + else + write(1, buf, 16); + (void)p2close(fp); +} +.fi +.in -2 + +.SH ATTRIBUTES +.sp +.LP +See \fBattributes\fR(5) for descriptions of the following attributes: +.sp + +.sp +.TS +tab() box; +cw(2.75i) |cw(2.75i) +lw(2.75i) |lw(2.75i) +. +ATTRIBUTE TYPEATTRIBUTE VALUE +_ +MT-LevelUnsafe +.TE + +.SH SEE ALSO +.sp +.LP +\fBfclose\fR(3C), \fBpopen\fR(3C), \fBsetbuf\fR(3C), \fBattributes\fR(5) +.SH NOTES +.sp +.LP +Buffered writes on \fBfp[0]\fR can make it appear that the command is not +listening. Judiciously placed \fBfflush()\fR calls or unbuffering \fBfp[0]\fR +can be a big help; see \fBfclose\fR(3C). +.sp +.LP +Many commands use buffered output when connected to a pipe. That, too, can make +it appear as if things are not working. +.sp +.LP +Usage is not the same as for \fBpopen()\fR, although it is closely related. diff --git a/usr/src/man/man3gen/pathfind.3gen b/usr/src/man/man3gen/pathfind.3gen new file mode 100644 index 0000000000..0d9121559c --- /dev/null +++ b/usr/src/man/man3gen/pathfind.3gen @@ -0,0 +1,133 @@ +'\" te +.\" Copyright 1989 AT&T Copyright (c) 1999, Sun Microsystems, Inc. All Rights Reserved +.\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License. +.\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License. +.\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner] +.TH pathfind 3GEN "10 Mar 1999" "SunOS 5.11" "String Pattern-Matching Library Functions" +.SH NAME +pathfind \- search for named file in named directories +.SH SYNOPSIS +.LP +.nf +cc [ \fIflag\fR ... ] \fIfile\fR ... \fB-lgen\fR [ \fIlibrary\fR ... ] +#include <libgen.h> + +\fBchar *\fR\fBpathfind\fR(\fBconst char *\fR\fIpath\fR, \fBconst char *\fR\fIname\fR, \fBconst char *\fR\fImode\fR); +.fi + +.SH DESCRIPTION +.sp +.LP +The \fBpathfind()\fR function searches the directories named in \fIpath\fR for +the file \fIname\fR. The directories named in \fIpath\fR are separated by +colons (:). The \fImode\fR argument is a string of option letters chosen from +the set \fB[rwxfbcdpugks]:\fR +.sp + +.sp +.TS +tab() box; +cw(2.75i) |cw(2.75i) +lw(2.75i) |lw(2.75i) +. +LetterMeaning +_ +\fBr\fRreadable +_ +\fBw\fRwritable +_ +\fBx\fRexecutable +_ +\fBf\fRnormal file +_ +\fBb\fRblock special +_ +\fBc\fRcharacter special +_ +\fBd\fRdirectory +_ +\fBp\fRFIFO (pipe) +_ +\fBu\fRset user ID bit +_ +\fBg\fRset group ID bit +_ +\fBk\fRsticky bit +_ +\fBs\fRsize non-zero +.TE + +.sp +.LP +Options read, write, and execute are checked relative to the real (not the +effective) user \fBID\fR and group \fBID\fR of the current process. +.sp +.LP +If \fIname\fR begins with a slash, it is treated as an absolute path name, and +\fIpath\fR is ignored. +.sp +.LP +An empty \fIpath\fR member is treated as the current directory. A slash +(\fB/\fR) character is not prepended at the occurrence of the first match; +rather, the unadorned \fIname\fR is returned. +.SH EXAMPLES +.LP +\fBExample 1 \fRExample of finding the \fBls\fR command using the PATH +environment variable. +.sp +.LP +To find the \fBls\fR command using the \fBPATH\fR environment variable: + +.sp +.LP +pathfind (getenv ("PATH"), "ls", "rx") + +.SH RETURN VALUES +.sp +.LP +The \fBpathfind()\fR function returns a \fB(char *)\fR value containing static, +thread-specific data that will be overwritten upon the next call from the same +thread. +.sp +.LP +If the file \fIname\fR with all characteristics specified by \fImode\fR is +found in any of the directories specified by \fIpath\fR, then \fBpathfind()\fR +returns a pointer to a string containing the member of \fIpath\fR, followed by +a slash character (\fB/\fR), followed by \fIname\fR. +.sp +.LP +If no match is found, \fBpathname()\fR returns a null pointer, \fB((char *) +0)\fR. +.SH ATTRIBUTES +.sp +.LP +See \fBattributes\fR(5) for descriptions of the following attributes: +.sp + +.sp +.TS +tab() box; +cw(2.75i) |cw(2.75i) +lw(2.75i) |lw(2.75i) +. +ATTRIBUTE TYPEATTRIBUTE VALUE +_ +MT-LevelMT-Safe +.TE + +.SH SEE ALSO +.sp +.LP +\fBsh\fR(1), \fBtest\fR(1), \fBaccess\fR(2), \fBmknod\fR(2), \fBstat\fR(2), +\fBgetenv\fR(3C), \fBattributes\fR(5) +.SH NOTES +.sp +.LP +The string pointed to by the returned pointer is stored in an area that is +reused on subsequent calls to \fBpathfind()\fR. The string should not be +deallocated by the caller. +.sp +.LP +When compiling multithreaded applications, the \fB_REENTRANT\fR flag must be +defined on the compile line. This flag should only be used in +multithreadedapplications. diff --git a/usr/src/man/man3gen/regexpr.3gen b/usr/src/man/man3gen/regexpr.3gen new file mode 100644 index 0000000000..6f28b96635 --- /dev/null +++ b/usr/src/man/man3gen/regexpr.3gen @@ -0,0 +1,216 @@ +'\" te +.\" Copyright 1989 AT&T Copyright (c) 1996, Sun Microsystems, Inc. All Rights Reserved +.\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License. +.\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License. +.\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner] +.TH regexpr 3GEN "29 Dec 1996" "SunOS 5.11" "String Pattern-Matching Library Functions" +.SH NAME +regexpr, compile, step, advance \- regular expression compile and match +routines +.SH SYNOPSIS +.LP +.nf +\fBcc\fR [\fIflag\fR]... [\fIfile\fR]... \fB-lgen\fR [\fIlibrary\fR]... +.fi + +.LP +.nf +#include <regexpr.h> + +\fBchar *\fR\fBcompile\fR(\fBchar *\fR\fIinstring\fR, \fBchar *\fR\fIexpbuf\fR, \fBconst char *\fR\fIendbuf\fR); +.fi + +.LP +.nf +\fBint\fR +\fBstep\fR(\fBconst char *\fR\fIstring\fR, \fBconst char *\fR\fIexpbuf\fR); +.fi + +.LP +.nf +\fBint\fR +\fBadvance\fR(\fBconst char *\fR\fIstring\fR, \fBconst char *\fR\fIexpbuf\fR); +.fi + +.LP +.nf +\fBextern char *\fRloc1\fB, \fRloc2\fB, \fRlocs\fB;\fR +.fi + +.LP +.nf +\fBextern int \fRnbra\fB, \fRregerrno\fB, \fRreglength\fB;\fR +.fi + +.LP +.nf +\fBextern char *\fRbraslist\fB[], *\fRbraelist\fB[];\fR +.fi + +.SH DESCRIPTION +.sp +.LP +These routines are used to compile regular expressions and match the compiled +expressions against lines. The regular expressions compiled are in the form +used by \fBed\fR(1). +.sp +.LP +The parameter \fIinstring\fR is a null-terminated string representing the +regular expression. +.sp +.LP +The parameter \fIexpbuf\fR points to the place where the compiled regular +expression is to be placed. If \fIexpbuf\fR is \fINULL\fR, \fBcompile()\fR +uses \fBmalloc\fR(3C) to allocate the space for the compiled regular +expression. If an error occurs, this space is freed. It is the user's +responsibility to free unneeded space after the compiled regular expression is +no longer needed. +.sp +.LP +The parameter \fIendbuf\fR is one more than the highest address where the +compiled regular expression may be placed. This argument is ignored if +\fIexpbuf\fR is \fINULL\fR. If the compiled expression cannot fit in +(\fIendbuf\fR\(mi\fIexpbuf\fR) bytes, \fBcompile()\fR returns \fINULL\fR and +\fBregerrno\fR (see below) is set to 50. +.sp +.LP +The parameter \fIstring\fR is a pointer to a string of characters to be +checked for a match. This string should be null-terminated. +.sp +.LP +The parameter \fIexpbuf\fR is the compiled regular expression obtained by a +call of the function \fBcompile()\fR. +.sp +.LP +The function \fBstep()\fR returns non-zero if the given string matches the +regular expression, and zero if the expressions do not match. If there is a +match, two external character pointers are set as a side effect to the call to +\fBstep()\fR. The variables set in \fBstep()\fR are \fIloc1\fR and \fIloc2\fR. +\fIloc1\fR is a pointer to the first character that matched the regular +expression. The variable \fIloc2\fR points to the character after the last +character that matches the regular expression. Thus if the regular expression +matches the entire line, \fIloc1\fR points to the first character of +\fIstring\fR and \fIloc2\fR points to the null at the end of \fIstring\fR. +.sp +.LP +The purpose of \fBstep()\fR is to step through the \fIstring\fR argument until +a match is found or until the end of \fIstring\fR is reached. If the regular +expression begins with \fB^\fR, \fBstep()\fR tries to match the regular +expression at the beginning of the string only. +.sp +.LP +The \fBadvance()\fR function is similar to \fBstep()\fR; but, it only sets the +variable \fIloc2\fR and always restricts matches to the beginning of the +string. +.sp +.LP +If one is looking for successive matches in the same string of characters, +\fBlocs\fR should be set equal to \fIloc2\fR, and \fBstep()\fR should be called +with \fIstring\fR equal to \fIloc2\fR. \fIlocs\fR is used by commands like +\fBed\fR and \fBsed\fR so that global substitutions like \fBs/y*//g\fR do not +loop forever, and is \fINULL\fR by default. +.sp +.LP +The external variable \fBnbra\fR is used to determine the number of +subexpressions in the compiled regular expression. \fBbraslist\fR and +\fBbraelist\fR are arrays of character pointers that point to the start and end +of the \fBnbra\fR subexpressions in the matched string. For example, after +calling \fBstep()\fR or \fBadvance()\fR with string \fBsabcdefg\fR and regular +expression \fB\e(abcdef\e)\fR, \fBbraslist[0]\fR will point at \fBa\fR and +\fBbraelist[0]\fR will point at \fBg\fR. These arrays are used by commands like +\fBed\fR and \fBsed\fR for substitute replacement patterns that contain the +\fB\e\fR\fIn\fR notation for subexpressions. +.sp +.LP +Note that it is not necessary to use the external variables \fBregerrno\fR, +\fBnbra\fR, \fBloc1\fR, \fBloc2\fR \fBlocs\fR, \fBbraelist\fR, and +\fBbraslist\fR if one is only checking whether or not a string matches a +regular expression. +.SH EXAMPLES +.LP +\fBExample 1 \fRThe following is similar to the regular expression code from +\fBgrep\fR: +.sp +.in +2 +.nf +#include<regexpr.h> + . . . +if(compile(*argv, (char *)0, (char *)0) == (char *)0) + regerr(regerrno); + . . . +if (step(linebuf, expbuf)) + succeed(\|); +.fi +.in -2 + +.SH RETURN VALUES +.sp +.LP +If \fBcompile()\fR succeeds, it returns a non-\fINULL\fR pointer whose value +depends on \fIexpbuf\fR. If \fIexpbuf\fR is non-\fINULL\fR, \fBcompile()\fR +returns a pointer to the byte after the last byte in the compiled regular +expression. The length of the compiled regular expression is stored in +\fBreglength\fR. Otherwise, \fBcompile()\fR returns a pointer to the space +allocated by \fBmalloc\fR(3C). +.sp +.LP +The functions \fBstep()\fR and \fBadvance()\fR return non-zero if the given +string matches the regular expression, and zero if the expressions do not +match. +.SH ERRORS +.sp +.LP +If an error is detected when compiling the regular expression, a \fINULL\fR +pointer is returned from \fBcompile()\fR and \fBregerrno\fR is set to one of +the non-zero error numbers indicated below: +.sp + +.sp +.TS +tab(); +cw(2.75i) cw(2.75i) +lw(2.75i) lw(2.75i) +. +ERRORMEANING +11Range endpoint too large. +16Bad Number. +25"\edigit" out or range. +36Illegal or missing delimiter. +41No remembered string search. +42\e(~\e) imbalance. +43Too many \e(. +44More than 2 numbers given in \e[~\e}. +45} expected after \e. +46First number exceeds second in \e{~\e}. +49[] imbalance. +50 Regular expression overflow. +.TE + +.SH ATTRIBUTES +.sp +.LP +See \fBattributes\fR(5) for descriptions of the following attributes: +.sp + +.sp +.TS +tab() box; +cw(2.75i) |cw(2.75i) +lw(2.75i) |lw(2.75i) +. +ATTRIBUTE TYPEATTRIBUTE VALUE +_ +MT-LevelMT-Safe +.TE + +.SH SEE ALSO +.sp +.LP +\fBed\fR(1), \fBgrep\fR(1), \fBsed\fR(1), \fBmalloc\fR(3C), +\fBattributes\fR(5), \fBregexp\fR(5) +.SH NOTES +.sp +.LP +When compiling multi-threaded applications, the \fB_REENTRANT\fR flag must be +defined on the compile line. This flag should only be used in multi-threaded +applications. diff --git a/usr/src/man/man3gen/strccpy.3gen b/usr/src/man/man3gen/strccpy.3gen new file mode 100644 index 0000000000..6fff8e0acb --- /dev/null +++ b/usr/src/man/man3gen/strccpy.3gen @@ -0,0 +1,105 @@ +'\" te +.\" Copyright 1989 AT&T +.\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License. +.\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License. +.\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner] +.TH strccpy 3GEN "29 Dec 1996" "SunOS 5.11" "String Pattern-Matching Library Functions" +.SH NAME +strccpy, streadd, strcadd, strecpy \- copy strings, compressing or expanding +escape codes +.SH SYNOPSIS +.LP +.nf +cc [ \fIflag\fR ... ] \fIfile\fR ... \fB-lgen\fR [ \fIlibrary\fR ... ] +#include <libgen.h> + +\fBchar *\fR\fBstrccpy\fR(\fBchar *\fR\fIoutput\fR, \fBconst char *\fR\fIinput\fR); +.fi + +.LP +.nf +\fBchar *\fR\fBstrcadd\fR(\fBchar *\fR\fIoutput\fR, \fBconst char *\fR\fIinput\fR); +.fi + +.LP +.nf +\fBchar *\fR\fBstrecpy\fR(\fBchar *\fR\fIoutput\fR, \fBconst char *\fR\fIinput\fR, \fBconst char *\fR\fIexceptions\fR); +.fi + +.LP +.nf +\fBchar *\fR\fBstreadd\fR(\fBchar *\fR\fIoutput\fR, \fBconst char *\fR\fIinput\fR, \fBconst char *\fR\fIexceptions\fR); +.fi + +.SH DESCRIPTION +.sp +.LP +\fBstrccpy()\fR copies the \fIinput\fR string, up to a null byte, to the +\fIoutput\fR string, compressing the C-language escape sequences (for example, +\fB\en\fR, \fB\e001\fR) to the equivalent character. A null byte is appended +to the output. The \fIoutput\fR argument must point to a space big enough to +accommodate the result. If it is as big as the space pointed to by \fIinput\fR +it is guaranteed to be big enough. \fBstrccpy()\fR returns the \fIoutput\fR +argument. +.sp +.LP +\fBstrcadd()\fR is identical to \fBstrccpy()\fR, except that it returns the +pointer to the null byte that terminates the output. +.sp +.LP +\fBstrecpy()\fR copies the \fIinput\fR string, up to a null byte, to the +\fIoutput\fR string, expanding non-graphic characters to their equivalent +C-language escape sequences (for example, \fB\en\fR, \fB\e001\fR). The +\fIoutput\fR argument must point to a space big enough to accommodate the +result; four times the space pointed to by \fIinput\fR is guaranteed to be big +enough (each character could become \fB\e\fR and 3 digits). Characters in the +\fIexceptions\fR string are not expanded. The \fIexceptions\fR argument may be +zero, meaning all non-graphic characters are expanded. \fBstrecpy()\fR returns +the \fIoutput\fR argument. +.sp +.LP +\fBstreadd()\fR is identical to \fBstrecpy()\fR, except that it returns the +pointer to the null byte that terminates the output. +.SH EXAMPLES +.LP +\fBExample 1 \fRExample of expanding and compressing escape codes. +.sp +.in +2 +.nf +/* expand all but newline and tab */ +strecpy( output, input, "\en\et" ); + +/* concatenate and compress several strings */ +cp = strcadd( output, input1 ); +cp = strcadd( cp, input2 ); +cp = strcadd( cp, input3 ); +.fi +.in -2 + +.SH ATTRIBUTES +.sp +.LP +See \fBattributes\fR(5) for descriptions of the following attributes: +.sp + +.sp +.TS +tab() box; +cw(2.75i) |cw(2.75i) +lw(2.75i) |lw(2.75i) +. +ATTRIBUTE TYPEATTRIBUTE VALUE +_ +MT-LevelMT-Safe +.TE + +.SH SEE ALSO +.sp +.LP +\fBstring\fR(3C), \fBstrfind\fR(3GEN), \fBattributes\fR(5) +.SH NOTES +.sp +.LP +When compiling multi-thread applications, the \fB_REENTRANT\fR flag must be +defined on the compile line. This flag should only be used in multi-thread +applications. diff --git a/usr/src/man/man3gen/strfind.3gen b/usr/src/man/man3gen/strfind.3gen new file mode 100644 index 0000000000..cf574063ac --- /dev/null +++ b/usr/src/man/man3gen/strfind.3gen @@ -0,0 +1,93 @@ +'\" te +.\" Copyright 1989 AT&T Copyright (c) 1999, Sun Microsystems, Inc. All Rights Reserved +.\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License. +.\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License. +.\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner] +.TH strfind 3GEN "20 Jan 1999" "SunOS 5.11" "String Pattern-Matching Library Functions" +.SH NAME +strfind, strrspn, strtrns, str \- string manipulations +.SH SYNOPSIS +.LP +.nf +cc [ \fIflag\fR ... ] \fIfile\fR ... \fB-lgen\fR [ \fIlibrary\fR ... ] +#include <libgen.h> + +\fBint\fR \fBstrfind\fR(\fBconst char *\fR\fIas1\fR, \fBconst char *\fR\fIas2\fR); +.fi + +.LP +.nf +\fBchar *\fR\fBstrrspn\fR(\fBconst char *\fR\fIstring\fR, \fBconst char *\fR\fItc\fR); +.fi + +.LP +.nf +\fBchar *\fR \fBstrtrns\fR(\fBconst char *\fR\fIstring\fR, \fBconst char *\fR\fIold\fR, \fBconst char *\fR\fInew\fR, + \fBchar *\fR\fIresult\fR); +.fi + +.SH DESCRIPTION +.sp +.LP +The \fBstrfind()\fR function returns the offset of the first occurrence of the +second string, \fIas2\fR, if it is a substring of string \fIas1\fR. If the +second string is not a substring of the first string \fBstrfind()\fR returns +\fB\(mi1\fR\&. +.sp +.LP +The \fBstrrspn()\fR function trims chartacters from a string. It searches from +the end of \fIstring\fR for the first character that is not contained in +\fItc\fR. If such a character is found, \fBstrrspn()\fR returns a pointer to +the next character; otherwise, it returns a pointer to \fIstring\fR. +.sp +.LP + The \fBstrtrns()\fR function transforms \fIstring\fR and copies it into +\fIresult\fR. Any character that appears in \fIold\fR is replaced with the +character in the same position in \fInew\fR. The \fInew\fR result is +returned. +.SH USAGE +.sp +.LP +When compiling multithreaded applications, the \fB_REENTRANT\fR flag must be +defined on the compile line. This flag should only be used in multithreaded +applications. +.SH EXAMPLES +.LP +\fBExample 1 \fRAn example of the \fBstrfind()\fR function. +.sp +.in +2 +.nf +\fB/* find offset to substring "hello" within as1 */ +i = strfind(as1, "hello"); +/* trim junk from end of string */ +s2 = strrspn(s1, "*?#$%"); +*s2 = '\e0'; +/* transform lower case to upper case */ +a1[] = "abcdefghijklmnopqrstuvwxyz"; +a2[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; +s2 = strtrns(s1, a1, a2, s2);\fR +.fi +.in -2 +.sp + +.SH ATTRIBUTES +.sp +.LP +See \fBattributes\fR(5) for descriptions of the following attributes: +.sp + +.sp +.TS +tab() box; +cw(2.75i) |cw(2.75i) +lw(2.75i) |lw(2.75i) +. +ATTRIBUTE TYPEATTRIBUTE VALUE +_ +MT-LevelMT-Safe +.TE + +.SH SEE ALSO +.sp +.LP +\fBstring\fR(3C), \fBattributes\fR(5) |