diff --git a/lib/libcompat/4.1/ftime.3 b/lib/libcompat/4.1/ftime.3 new file mode 100644 index 000000000000..a9491af78669 --- /dev/null +++ b/lib/libcompat/4.1/ftime.3 @@ -0,0 +1,84 @@ +.\" Copyright (c) 1980, 1991, 1993 +.\" The Regents of the University of California. All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" 3. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. Neither the name of the University nor the names of its contributors +.\" may be used to endorse or promote products derived from this software +.\" without specific prior written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" @(#)ftime.3 8.1 (Berkeley) 6/4/93 +.\" +.Dd June 4, 1993 +.Dt FTIME 3 +.Os BSD 4 +.Sh NAME +.Nm ftime +.Nd get date and time +.Sh SYNOPSIS +.Fd #include +.Fd #include +.Ft struct timeb * +.Fn ftime "struct timeb *tp" +.Sh DESCRIPTION +.Bf -symbolic +This interface is obsoleted by gettimeofday(2). +.Pp +It is available from the compatibility library, libcompat. +.Ef +.Pp +The +.Fn ftime +routine fills in a structure pointed to by its argument, +as defined by +.Aq Pa sys/timeb.h : +.Bd -literal -offset indent +/* + * Structure returned by ftime system call + */ +struct timeb +{ + time_t time; + unsigned short millitm; + short timezone; + short dstflag; +}; +.Ed +.Pp +The structure contains the time since the epoch in seconds, +up to 1000 milliseconds of more-precise interval, +the local time zone (measured in minutes of time westward from Greenwich), +and a flag that, if nonzero, indicates that +Daylight Saving time applies locally during the appropriate part of the year. +.Sh SEE ALSO +.Xr gettimeofday 2 , +.Xr settimeofday 2 , +.Xr time 2 , +.Xr ctime 3 +.Sh HISTORY +The +.Nm +function appeared in +.Bx 4.2 . diff --git a/lib/libcompat/4.1/getpw.3 b/lib/libcompat/4.1/getpw.3 new file mode 100644 index 000000000000..1568e746e389 --- /dev/null +++ b/lib/libcompat/4.1/getpw.3 @@ -0,0 +1,78 @@ +.\" Copyright (c) 1990, 1993 +.\" The Regents of the University of California. All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" 3. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. Neither the name of the University nor the names of its contributors +.\" may be used to endorse or promote products derived from this software +.\" without specific prior written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" @(#)getpw.3 8.1 (Berkeley) 6/4/93 +.\" +.Dd June 4, 1993 +.Dt GETPW 3 +.Os +.Sh NAME +.Nm getpw +.Nd get name from uid +.Sh SYNOPSIS +.Fn getpw uid "char *buf" +.Sh DESCRIPTION +.Bf -symbolic +The getpw function is made obsolete by getpwuid(3). +.br +It is available from the compatibility library, libcompat. +.Ef +.Pp +The +.Fn getpw +function reads the file +.Pa /etc/passwd , +and if it finds +the specified +.Fa uid , +copies the password entry line into the string pointed to by +.Fa buf . +the null terminated entry line from the password database, +and appends the +.Dv NUL +character. +.Sh RETURN VALUES +The +.Fn getpw +function returns the zero if successful, otherwise +a non-zero if the entry does not exist. +.Sh FILES +.Bl -tag -width /etc/passwd - compact +.It Pa /etc/passwd +.El +.Sh SEE ALSO +.Xr getpwent 3 , +.Xr passwd 5 +.Sh HISTORY +A +.Fn getpw +function appeared in +.At v6 . diff --git a/lib/libcompat/4.1/stty.3 b/lib/libcompat/4.1/stty.3 new file mode 100644 index 000000000000..eb3a5c8c839f --- /dev/null +++ b/lib/libcompat/4.1/stty.3 @@ -0,0 +1,93 @@ +.\" Copyright (c) 1983, 1991, 1993 +.\" The Regents of the University of California. All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" 3. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. Neither the name of the University nor the names of its contributors +.\" may be used to endorse or promote products derived from this software +.\" without specific prior written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" @(#)stty.3 8.1 (Berkeley) 6/4/93 +.\" +.Dd June 4, 1993 +.Dt STTY 3 +.Os BSD 4.2 +.Sh NAME +.Nm stty , +.Nm gtty +.Nd set and get terminal state (defunct) +.Sh SYNOPSIS +.Fd #include +.Fn stty "int fd" "struct sgttyb *buf" +.Fn gtty "int fd" "struct sgttyb *buf" +.Sh DESCRIPTION +.Bf -symbolic +These interfaces are obsoleted by ioctl(2). +They are available from the compatibility library, libcompat. +.Ef +.Pp +The +.Fn stty +function +sets the state of the terminal associated with +.Fa fd . +The +.Fn gtty +function +retrieves the state of the terminal associated +with +.Fa fd . +To set the state of a terminal the call must have +write permission. +.Pp +The +.Fn stty +call is actually +.Ql ioctl(fd, TIOCSETP, buf) , +while +the +.Fn gtty +call is +.Ql ioctl(fd, TIOCGETP, buf) . +See +.Xr ioctl 2 +and +.Xr tty 4 +for an explanation. +.Sh DIAGNOSTICS +If the call is successful 0 is returned, otherwise \-1 is +returned and the global variable +.Va errno +contains the reason for the failure. +.Sh SEE ALSO +.Xr ioctl 2 , +.Xr tty 4 +.Sh HISTORY +The +.Fn stty +and +.Fn gtty +functions appeared in +.Bx 4.2 . diff --git a/lib/libcompat/4.1/vlimit.3 b/lib/libcompat/4.1/vlimit.3 new file mode 100644 index 000000000000..062f557d1720 --- /dev/null +++ b/lib/libcompat/4.1/vlimit.3 @@ -0,0 +1,123 @@ +.\" Copyright (c) 1980, 1991, 1993 +.\" The Regents of the University of California. All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" 3. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. Neither the name of the University nor the names of its contributors +.\" may be used to endorse or promote products derived from this software +.\" without specific prior written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" @(#)vlimit.3 8.1 (Berkeley) 6/4/93 +.\" +.Dd June 4, 1993 +.Dt VLIMIT 3 +.Os BSD 4 +.Sh NAME +.Nm vlimit +.Nd control maximum system resource consumption +.Sh SYNOPSIS +.Fd #include +.Fn vlimit resource value +.Sh DESCRIPTION +.Bf -symbolic +This interface is obsoleted by getrlimit(2). +It is available from the compatibility library, libcompat. +.Ef +.Pp +Limits the consumption by the current process and each process +it creates to not individually exceed +.Fa value +on the specified +.Fa resource . +If +.Fa value +is specified as \-1, then the current limit is returned and the +limit is unchanged. +The resources which are currently controllable are: +.Bl -tag -width LIM_NORAISE +.It Dv LIM_NORAISE +A pseudo-limit; if set non-zero then the limits may not be raised. +Only the super-user may remove the +.Em noraise +restriction. +.It Dv LIM_CPU +the maximum +number of cpu-seconds to be used by each process +.It Dv LIM_FSIZE +the largest single file which can be created +.It Dv LIM_DATA +the maximum growth of the data+stack region via +.Xr sbrk 2 +beyond the end of the program text +.It Dv LIM_STACK +the maximum +size of the automatically-extended stack region +.It Dv LIM_CORE +the size of the largest core dump that will be created. +.It Dv LIM_MAXRSS +a soft limit for the amount of physical memory (in bytes) to be given +to the program. If memory is tight, the system will prefer to take memory +from processes which are exceeding their declared +.Dv LIM_MAXRSS. +.El +.Pp +Because this information is stored in the per-process information +this system call must be executed directly by the shell if it +is to affect all future processes created by the shell; +.Xr limit +is thus a built-in command to +.Xr csh 1 . +.Pp +The system refuses to extend the data or stack space when the limits +would be exceeded in the normal way; a +.Xr break 2 +call fails if the data space limit is reached, or the process is +killed when the stack limit is reached (since the stack cannot be +extended, there is no way to send a signal!). +.Pp +A file +.Tn I/O +operation which would create a file which is too large +will cause a signal +.Dv SIGXFSZ +to be generated, this normally terminates +the process, but may be caught. +When the cpu time limit is exceeded, a signal +.Dv SIGXCPU +is sent to the +offending process; to allow it time to process the signal it is +given 5 seconds grace by raising the +.Tn CPU +time limit. +.Sh SEE ALSO +.Xr csh 1 +.Sh HISTORY +The +.Fn vlimit +function appeared in +.Bx 4.2 . +.Sh BUGS +.Dv LIM_NORAISE +no longer exists. diff --git a/lib/libcompat/4.1/vtimes.3 b/lib/libcompat/4.1/vtimes.3 new file mode 100644 index 000000000000..dc4ff4add94d --- /dev/null +++ b/lib/libcompat/4.1/vtimes.3 @@ -0,0 +1,141 @@ +.\" Copyright (c) 1980, 1991, 1993 +.\" The Regents of the University of California. All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" 3. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. Neither the name of the University nor the names of its contributors +.\" may be used to endorse or promote products derived from this software +.\" without specific prior written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" @(#)vtimes.3 8.1 (Berkeley) 6/4/93 +.\" +.Dd June 4, 1993 +.Dt VTIMES 3 +.Os BSD 4 +.Sh NAME +.Nm vtimes +.Nd get information about resource utilization +.Sh SYNOPSIS +.Fd #include +.Fn vtimes "struct vtimes *par_vm" "struct vtimes *ch_vm" +.Sh DESCRIPTION +.Bf -symbolic +This interface is obsoleted by getrusage(2). +It is available from the compatibility library, libcompat. +.Ef +.Pp +The +.Fn vtimes +function +returns accounting information for the current process and for +the terminated child processes of the current +process. Either +.Fa par_vm +or +.Fa ch_vm +or both may be 0, in which case only the information for the pointers +which are non-zero is returned. +.Pp +After the call, each buffer contains information as defined by the +contents of the include file +.Pa /usr/include/sys/vtimes.h : +.Bd -literal -offset indent +struct vtimes { + int vm_utime; /* user time (*HZ) */ + int vm_stime; /* system time (*HZ) */ + /* divide next two by utime+stime to get averages */ + unsigned vm_idsrss; /* integral of d+s rss */ + unsigned vm_ixrss; /* integral of text rss */ + int vm_maxrss; /* maximum rss */ + int vm_majflt; /* major page faults */ + int vm_minflt; /* minor page faults */ + int vm_nswap; /* number of swaps */ + int vm_inblk; /* block reads */ + int vm_oublk; /* block writes */ +}; +.Ed +.Pp +The +.Fa vm_utime +and +.Fa vm_stime +fields give the user and system +time respectively in 60ths of a second (or 50ths if that +is the frequency of wall current in your locality.) The +.Fa vm_idrss +and +.Fa vm_ixrss +measure memory usage. They are computed by integrating the number of +memory pages in use each +over +.Tn CPU +time. They are reported as though computed +discretely, adding the current memory usage (in 512 byte +pages) each time the clock ticks. If a process used 5 core +pages over 1 cpu-second for its data and stack, then +.Fa vm_idsrss +would have the value 5*60, where +.Fa vm_utime+vm_stime +would be the 60. +The +.Fa Vm_idsrss +argument +integrates data and stack segment +usage, while +.Fa vm_ixrss +integrates text segment usage. +The +.Fa Vm_maxrss +function +reports the maximum instantaneous sum of the +text+data+stack core-resident page count. +.Pp +The +.Fa vm_majflt +field gives the number of page faults which +resulted in disk activity; the +.Fa vm_minflt +field gives the +number of page faults incurred in simulation of reference +bits; +.Fa vm_nswap +is the number of swaps which occurred. The +number of file system input/output events are reported in +.Fa vm_inblk +and +.Fa vm_oublk +These numbers account only for real +.Tn I/O ; +data supplied by the caching mechanism is charged only +to the first process to read or write the data. +.Sh SEE ALSO +.Xr time 2 , +.Xr wait3 2 , +.Xr getrusage 2 +.Sh HISTORY +The +.Fn vlimit +function appeared in +.Bx 4.2 . diff --git a/lib/libcompat/4.3/cfree.c b/lib/libcompat/4.3/cfree.c new file mode 100644 index 000000000000..8bade2ef8538 --- /dev/null +++ b/lib/libcompat/4.3/cfree.c @@ -0,0 +1,43 @@ +/*- + * Copyright (c) 1992, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#if defined(LIBC_SCCS) && !defined(lint) +static char sccsid[] = "@(#)cfree.c 8.1 (Berkeley) 6/4/93"; +#endif /* LIBC_SCCS and not lint */ + +void +cfree(p) + void *p; +{ + free(p); +} diff --git a/lib/libcompat/4.3/lsearch.3 b/lib/libcompat/4.3/lsearch.3 new file mode 100644 index 000000000000..d6abfca11592 --- /dev/null +++ b/lib/libcompat/4.3/lsearch.3 @@ -0,0 +1,102 @@ +.\" Copyright (c) 1989, 1991, 1993 +.\" The Regents of the University of California. All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" 3. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. Neither the name of the University nor the names of its contributors +.\" may be used to endorse or promote products derived from this software +.\" without specific prior written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" @(#)lsearch.3 8.1 (Berkeley) 6/4/93 +.\" +.Dd June 4, 1993 +.Dt LSEARCH 3 +.Os +.Sh NAME +.Nm lsearch , +.Nm lfind, +.Nd linear searching routines +.Sh SYNOPSIS +.Ft char * +.Fn lsearch "const void *key" "const void *base" "size_t *nelp" "size_t width" "int (*compar)(void *, void *)" +.Ft char * +.Fn lfind "const void *key" "const void *base" "size_t *nelp" "size_t width" "int (*compar)(void *, void *)" +.Sh DESCRIPTION +.Bf -symbolic +This interface was obsolete before it was written. +It is available from the compatibility library, libcompat. +.Ef +.Pp +The functions +.Fn lsearch , +and +.Fn lfind +provide basic linear searching functionality. +.Pp +.Fa Base +is the pointer to the beginning of an array. +The argument +.Fa nelp +is the current number of elements in the array, where each element +is +.Fa width +bytes long. +The +.Fa compar +function +is a comparison routine which is used to compare two elements. +It takes two arguments which point to the +.Fa key +object and to an array member, in that order, and must return an integer +less than, equivalent to, or greater than zero if the +.Fa key +object is considered, respectively, to be less than, equal to, or greater +than the array member. +.Pp +The +.Fn lsearch +and +.Fn lfind +functions +return a pointer into the array referenced by +.Fa base +where +.Fa key +is located. +If +.Fa key +does not exist, +.Fn lfind +will return a null pointer and +.Fn lsearch +will add it to the array. +When an element is added to the array by +.Fn lsearch +the location referenced by the argument +.Fa nelp +is incremented by one. +.Sh SEE ALSO +.Xr bsearch 3 , +.Xr db 3 diff --git a/lib/libcompat/4.3/lsearch.c b/lib/libcompat/4.3/lsearch.c new file mode 100644 index 000000000000..baf90ed0365b --- /dev/null +++ b/lib/libcompat/4.3/lsearch.c @@ -0,0 +1,92 @@ +/* + * Copyright (c) 1989, 1993 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Roger L. Snyder. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#if defined(LIBC_SCCS) && !defined(lint) +static char sccsid[] = "@(#)lsearch.c 8.1 (Berkeley) 6/4/93"; +#endif /* LIBC_SCCS and not lint */ + +#include +#include + +static char *linear_base(); + +char * +lsearch(key, base, nelp, width, compar) + char *key, *base; + u_int *nelp, width; + int (*compar)(); +{ + return(linear_base(key, base, nelp, width, compar, 1)); +} + +char * +lfind(key, base, nelp, width, compar) + char *key, *base; + u_int *nelp, width; + int (*compar)(); +{ + return(linear_base(key, base, nelp, width, compar, 0)); +} + +static char * +linear_base(key, base, nelp, width, compar, add_flag) + char *key, *base; + u_int *nelp, width; + int (*compar)(), add_flag; +{ + register char *element, *end; + + end = base + *nelp * width; + for (element = base; element < end; element += width) + if (!compar(element, key)) /* key found */ + return(element); + + if (!add_flag) /* key not found */ + return(NULL); + + /* + * The UNIX System User's Manual, 1986 edition claims that + * a NULL pointer is returned by lsearch with errno set + * appropriately, if there is not enough room in the table + * to add a new item. This can't be done as none of these + * routines have any method of determining the size of the + * table. This comment was isn't in the 1986-87 System V + * manual. + */ + ++*nelp; + bcopy(key, end, (int)width); + return(end); +} diff --git a/lib/libcompat/4.3/re_comp.3 b/lib/libcompat/4.3/re_comp.3 new file mode 100644 index 000000000000..498e6394f3b2 --- /dev/null +++ b/lib/libcompat/4.3/re_comp.3 @@ -0,0 +1,123 @@ +.\" Copyright (c) 1980, 1991, 1993 +.\" The Regents of the University of California. All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" 3. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. Neither the name of the University nor the names of its contributors +.\" may be used to endorse or promote products derived from this software +.\" without specific prior written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" @(#)re_comp.3 8.1 (Berkeley) 6/4/93 +.\" +.Dd June 4, 1993 +.Dt RE_COMP 3 +.Os +.Sh NAME +.Nm re_comp , +.Nm re_exec +.Nd regular expression handler +.Sh SYNOPSIS +.Fd #include +.Ft char * +.Fn re_comp "const char *s" +.Ft int +.Fn re_exec "const char *s" +.Sh DESCRIPTION +This interface is made obsolete by +.Xr regex 3 . +.Pp +The +.Fn re_comp +function +compiles a string into an internal form suitable for pattern matching. +The +.Fn re_exec +function +checks the argument string against the last string passed to +.Fn re_comp . +.Pp +The +.Fn re_comp +function +returns 0 if the string +.Fa s +was compiled successfully; otherwise a string containing an +error message is returned. If +.Fn re_comp +is passed 0 or a null string, it returns without changing the currently +compiled regular expression. +.Pp +The +.Fn re_exec +function +returns 1 if the string +.Fa s +matches the last compiled regular expression, 0 if the string +.Fa s +failed to match the last compiled regular expression, and \-1 if the compiled +regular expression was invalid (indicating an internal error). +.Pp +The strings passed to both +.Fn re_comp +and +.Fn re_exec +may have trailing or embedded newline characters; +they are terminated by +.Dv NUL Ns s. +The regular expressions recognized are described in the manual entry for +.Xr ed 1 , +given the above difference. +.Sh DIAGNOSTICS +The +.Fn re_exec +function +returns \-1 for an internal error. +.Pp +The +.Fn re_comp +function +returns one of the following strings if an error occurs: +.Bd -unfilled -offset indent +No previous regular expression, +Regular expression too long, +unmatched \e(, +missing ], +too many \e(\e) pairs, +unmatched \e). +.Ed +.Sh SEE ALSO +.Xr ed 1 , +.Xr ex 1 , +.Xr egrep 1 , +.Xr fgrep 1 , +.Xr grep 1 , +.Xr regex 3 +.Sh HISTORY +The +.Fn re_comp +and +.Fn re_exec +functions appeared in +.Bx 4.0 . diff --git a/lib/libcompat/4.3/rexec.3 b/lib/libcompat/4.3/rexec.3 new file mode 100644 index 000000000000..2bcb5bed966f --- /dev/null +++ b/lib/libcompat/4.3/rexec.3 @@ -0,0 +1,122 @@ +.\" Copyright (c) 1983, 1991, 1993 +.\" The Regents of the University of California. All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" 3. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. Neither the name of the University nor the names of its contributors +.\" may be used to endorse or promote products derived from this software +.\" without specific prior written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" @(#)rexec.3 8.1 (Berkeley) 6/4/93 +.\" +.Dd June 4, 1993 +.Dt REXEC 3 +.Os BSD 4.2 +.Sh NAME +.Nm rexec +.Nd return stream to a remote command +.Sh SYNOPSIS +.Ft int +.Fn rexec ahost "int inport" "char *user" "char *passwd" "char *cmd" "int *fd2p" +.Sh DESCRIPTION +.Bf -symbolic +This interface is obsoleted by krcmd(3). +It is available from the compatibility library, libcompat. +.Ef +.Pp +The +.Fn rexec +function +looks up the host +.Fa *ahost +using +.Xr gethostbyname 3 , +returning \-1 if the host does not exist. +Otherwise +.Fa *ahost +is set to the standard name of the host. +If a username and password are both specified, then these +are used to authenticate to the foreign host; otherwise +the environment and then the user's +.Pa .netrc +file in his +home directory are searched for appropriate information. +If all this fails, the user is prompted for the information. +.Pp +The port +.Fa inport +specifies which well-known +.Tn DARPA +Internet port to use for +the connection; the call +.Ql getservbyname(\\*qexec\\*q, \\*qtcp\\*q) +(see +.Xr getservent 3 ) +will return a pointer to a structure, which contains the +necessary port. +The protocol for connection is described in detail in +.Xr rexecd 8 . +.Pp +If the connection succeeds, +a socket in the Internet domain of type +.Dv SOCK_STREAM +is returned to +the caller, and given to the remote command as +.Em stdin +and +.Em stdout . +If +.Fa fd2p +is non-zero, then an auxiliary channel to a control +process will be setup, and a descriptor for it will be placed +in +.Fa *fd2p . +The control process will return diagnostic +output from the command (unit 2) on this channel, and will also +accept bytes on this channel as being +.Tn UNIX +signal numbers, to be +forwarded to the process group of the command. The diagnostic +information returned does not include remote authorization failure, +as the secondary connection is set up after authorization has been +verified. +If +.Fa fd2p +is 0, then the +.Em stderr +(unit 2 of the remote +command) will be made the same as the +.Em stdout +and no +provision is made for sending arbitrary signals to the remote process, +although you may be able to get its attention by using out-of-band data. +.Sh SEE ALSO +.Xr rcmd 3 , +.Xr rexecd 8 +.Sh HISTORY +The +.Fn rexec +function appeared in +.Bx 4.2 .