kill the undead
This commit is contained in:
parent
365c345167
commit
65b3003d2d
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=27369
151
include/tzfile.h
151
include/tzfile.h
@ -1,151 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 1988, 1993
|
|
||||||
* The Regents of the University of California. All rights reserved.
|
|
||||||
*
|
|
||||||
* This code is derived from software contributed to Berkeley by
|
|
||||||
* Arthur David Olson of the National Cancer Institute.
|
|
||||||
*
|
|
||||||
* 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.
|
|
||||||
*
|
|
||||||
* @(#)tzfile.h 8.1 (Berkeley) 6/2/93
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _TZFILE_H_
|
|
||||||
#define _TZFILE_H_
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Information about time zone files.
|
|
||||||
*/
|
|
||||||
/* Time zone object file directory */
|
|
||||||
#define TZDIR "/usr/share/zoneinfo"
|
|
||||||
#define TZDEFAULT "/etc/localtime"
|
|
||||||
#define TZDEFRULES "posixrules"
|
|
||||||
|
|
||||||
/*
|
|
||||||
** Each file begins with. . .
|
|
||||||
*/
|
|
||||||
|
|
||||||
struct tzhead {
|
|
||||||
char tzh_reserved[24]; /* reserved for future use */
|
|
||||||
char tzh_ttisstdcnt[4]; /* coded number of trans. time flags */
|
|
||||||
char tzh_leapcnt[4]; /* coded number of leap seconds */
|
|
||||||
char tzh_timecnt[4]; /* coded number of transition times */
|
|
||||||
char tzh_typecnt[4]; /* coded number of local time types */
|
|
||||||
char tzh_charcnt[4]; /* coded number of abbr. chars */
|
|
||||||
};
|
|
||||||
|
|
||||||
/*
|
|
||||||
** . . .followed by. . .
|
|
||||||
**
|
|
||||||
** tzh_timecnt (char [4])s coded transition times a la time(2)
|
|
||||||
** tzh_timecnt (unsigned char)s types of local time starting at above
|
|
||||||
** tzh_typecnt repetitions of
|
|
||||||
** one (char [4]) coded GMT offset in seconds
|
|
||||||
** one (unsigned char) used to set tm_isdst
|
|
||||||
** one (unsigned char) that's an abbreviation list index
|
|
||||||
** tzh_charcnt (char)s '\0'-terminated zone abbreviations
|
|
||||||
** tzh_leapcnt repetitions of
|
|
||||||
** one (char [4]) coded leap second transition times
|
|
||||||
** one (char [4]) total correction after above
|
|
||||||
** tzh_ttisstdcnt (char)s indexed by type; if TRUE, transition
|
|
||||||
** time is standard time, if FALSE,
|
|
||||||
** transition time is wall clock time
|
|
||||||
** if absent, transition times are
|
|
||||||
** assumed to be wall clock time
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
** In the current implementation, "tzset()" refuses to deal with files that
|
|
||||||
** exceed any of the limits below.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
** The TZ_MAX_TIMES value below is enough to handle a bit more than a
|
|
||||||
** year's worth of solar time (corrected daily to the nearest second) or
|
|
||||||
** 138 years of Pacific Presidential Election time
|
|
||||||
** (where there are three time zone transitions every fourth year).
|
|
||||||
*/
|
|
||||||
#define TZ_MAX_TIMES 370
|
|
||||||
|
|
||||||
#define NOSOLAR /* 4BSD doesn't currently handle solar time */
|
|
||||||
|
|
||||||
#ifndef NOSOLAR
|
|
||||||
#define TZ_MAX_TYPES 256 /* Limited by what (unsigned char)'s can hold */
|
|
||||||
#else
|
|
||||||
#define TZ_MAX_TYPES 10 /* Maximum number of local time types */
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define TZ_MAX_CHARS 50 /* Maximum number of abbreviation characters */
|
|
||||||
|
|
||||||
#define TZ_MAX_LEAPS 50 /* Maximum number of leap second corrections */
|
|
||||||
|
|
||||||
#define SECSPERMIN 60
|
|
||||||
#define MINSPERHOUR 60
|
|
||||||
#define HOURSPERDAY 24
|
|
||||||
#define DAYSPERWEEK 7
|
|
||||||
#define DAYSPERNYEAR 365
|
|
||||||
#define DAYSPERLYEAR 366
|
|
||||||
#define SECSPERHOUR (SECSPERMIN * MINSPERHOUR)
|
|
||||||
#define SECSPERDAY ((long) SECSPERHOUR * HOURSPERDAY)
|
|
||||||
#define MONSPERYEAR 12
|
|
||||||
|
|
||||||
#define TM_SUNDAY 0
|
|
||||||
#define TM_MONDAY 1
|
|
||||||
#define TM_TUESDAY 2
|
|
||||||
#define TM_WEDNESDAY 3
|
|
||||||
#define TM_THURSDAY 4
|
|
||||||
#define TM_FRIDAY 5
|
|
||||||
#define TM_SATURDAY 6
|
|
||||||
|
|
||||||
#define TM_JANUARY 0
|
|
||||||
#define TM_FEBRUARY 1
|
|
||||||
#define TM_MARCH 2
|
|
||||||
#define TM_APRIL 3
|
|
||||||
#define TM_MAY 4
|
|
||||||
#define TM_JUNE 5
|
|
||||||
#define TM_JULY 6
|
|
||||||
#define TM_AUGUST 7
|
|
||||||
#define TM_SEPTEMBER 8
|
|
||||||
#define TM_OCTOBER 9
|
|
||||||
#define TM_NOVEMBER 10
|
|
||||||
#define TM_DECEMBER 11
|
|
||||||
|
|
||||||
#define TM_YEAR_BASE 1900
|
|
||||||
|
|
||||||
#define EPOCH_YEAR 1970
|
|
||||||
#define EPOCH_WDAY TM_THURSDAY
|
|
||||||
|
|
||||||
/*
|
|
||||||
** Accurate only for the past couple of centuries;
|
|
||||||
** that will probably do.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#define isleap(y) (((y) % 4) == 0 && ((y) % 100) != 0 || ((y) % 400) == 0)
|
|
||||||
|
|
||||||
#endif /* !_TZFILE_H_ */
|
|
@ -1,93 +0,0 @@
|
|||||||
.\" Copyright (c) 1980, 1991, 1993, 1994
|
|
||||||
.\" 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.
|
|
||||||
.\"
|
|
||||||
.\" @(#)setregid.2 8.2 (Berkeley) 4/16/94
|
|
||||||
.\"
|
|
||||||
.Dd April 16, 1994
|
|
||||||
.Dt SETREGID 2
|
|
||||||
.Os BSD 4.2
|
|
||||||
.Sh NAME
|
|
||||||
.Nm setregid
|
|
||||||
.Nd set real and effective group ID
|
|
||||||
.Sh SYNOPSIS
|
|
||||||
.Fd #include <unistd.h>
|
|
||||||
.Ft int
|
|
||||||
.Fn setregid "gid_t rgid" "gid_t egid"
|
|
||||||
.Sh DESCRIPTION
|
|
||||||
The real and effective group ID's of the current process
|
|
||||||
are set to the arguments.
|
|
||||||
Unprivileged users may change the real group
|
|
||||||
ID to the effective group ID and vice-versa; only the super-user may
|
|
||||||
make other changes.
|
|
||||||
.Pp
|
|
||||||
Supplying a value of -1 for either the real or effective
|
|
||||||
group ID forces the system to substitute the current
|
|
||||||
ID in place of the -1 parameter.
|
|
||||||
.Pp
|
|
||||||
The
|
|
||||||
.Fn setregid
|
|
||||||
function was intended to allow swapping
|
|
||||||
the real and effective group IDs
|
|
||||||
in set-group-ID programs to temporarily relinquish the set-group-ID value.
|
|
||||||
This function did not work correctly,
|
|
||||||
and its purpose is now better served by the use of the
|
|
||||||
.Fn setegid
|
|
||||||
function (see
|
|
||||||
.Xr setuid 2 ) .
|
|
||||||
.Pp
|
|
||||||
When setting the real and effective group IDs to the same value,
|
|
||||||
the standard
|
|
||||||
.Fn setgid
|
|
||||||
function is preferred.
|
|
||||||
.Sh RETURN VALUES
|
|
||||||
Upon successful completion, a value of 0 is returned. Otherwise,
|
|
||||||
a value of -1 is returned and
|
|
||||||
.Va errno
|
|
||||||
is set to indicate the error.
|
|
||||||
.Sh ERRORS
|
|
||||||
.Bl -tag -width [EPERM]
|
|
||||||
.It Bq Er EPERM
|
|
||||||
The current process is not the super-user and a change
|
|
||||||
other than changing the effective group-id to the real group-id
|
|
||||||
was specified.
|
|
||||||
.El
|
|
||||||
.Sh SEE ALSO
|
|
||||||
.Xr getgid 2 ,
|
|
||||||
.Xr setegid 2 ,
|
|
||||||
.Xr setgid 2 ,
|
|
||||||
.Xr setuid 2
|
|
||||||
.Sh HISTORY
|
|
||||||
The
|
|
||||||
.Nm
|
|
||||||
function call appeared in
|
|
||||||
.Bx 4.2
|
|
||||||
and was dropped in
|
|
||||||
.Bx 4.4 .
|
|
@ -1,62 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 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[] = "@(#)setregid.c 8.1 (Berkeley) 6/2/93";
|
|
||||||
#endif /* LIBC_SCCS and not lint */
|
|
||||||
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <errno.h>
|
|
||||||
|
|
||||||
int
|
|
||||||
setregid(rgid, egid)
|
|
||||||
gid_t rgid, egid;
|
|
||||||
{
|
|
||||||
static gid_t savedgid = -1;
|
|
||||||
|
|
||||||
if (savedgid == -1)
|
|
||||||
savedgid = getegid();
|
|
||||||
/*
|
|
||||||
* we assume that the intent here is to be able to
|
|
||||||
* get back rgid priviledge. So we make sure that
|
|
||||||
* we will be able to do so, but do not actually
|
|
||||||
* set the rgid.
|
|
||||||
*/
|
|
||||||
if (rgid != -1 && rgid != getgid() && rgid != savedgid) {
|
|
||||||
errno = EPERM;
|
|
||||||
return (-1);
|
|
||||||
}
|
|
||||||
if (egid != -1 && setegid(egid) < 0)
|
|
||||||
return (-1);
|
|
||||||
return (0);
|
|
||||||
}
|
|
@ -1,91 +0,0 @@
|
|||||||
.\" Copyright (c) 1980, 1991, 1993, 1994
|
|
||||||
.\" 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.
|
|
||||||
.\"
|
|
||||||
.\" @(#)setreuid.2 8.2 (Berkeley) 4/16/94
|
|
||||||
.\"
|
|
||||||
.Dd April 16, 1994
|
|
||||||
.Dt SETREUID 2
|
|
||||||
.Os BSD 4
|
|
||||||
.Sh NAME
|
|
||||||
.Nm setreuid
|
|
||||||
.Nd set real and effective user ID's
|
|
||||||
.Sh SYNOPSIS
|
|
||||||
.Fd #include <unistd.h>
|
|
||||||
.Ft int
|
|
||||||
.Fn setreuid "uid_t ruid" "uid_t euid"
|
|
||||||
.Sh DESCRIPTION
|
|
||||||
The real and effective user IDs of the
|
|
||||||
current process are set according to the arguments.
|
|
||||||
If
|
|
||||||
.Fa ruid
|
|
||||||
or
|
|
||||||
.Fa euid
|
|
||||||
is -1, the current uid is filled in by the system.
|
|
||||||
Unprivileged users may change the real user
|
|
||||||
ID to the effective user ID and vice-versa; only the super-user may
|
|
||||||
make other changes.
|
|
||||||
.Pp
|
|
||||||
The
|
|
||||||
.Fn setreuid
|
|
||||||
function has been used to swap the real and effective user IDs
|
|
||||||
in set-user-ID programs to temporarily relinquish the set-user-ID value.
|
|
||||||
This purpose is now better served by the use of the
|
|
||||||
.Fn seteuid
|
|
||||||
function (see
|
|
||||||
.Xr setuid 2 ) .
|
|
||||||
.Pp
|
|
||||||
When setting the real and effective user IDs to the same value,
|
|
||||||
the standard
|
|
||||||
.Fn setuid
|
|
||||||
function is preferred.
|
|
||||||
.Sh RETURN VALUES
|
|
||||||
Upon successful completion, a value of 0 is returned. Otherwise,
|
|
||||||
a value of -1 is returned and
|
|
||||||
.Va errno
|
|
||||||
is set to indicate the error.
|
|
||||||
.Sh ERRORS
|
|
||||||
.Bl -tag -width [EPERM]
|
|
||||||
.It Bq Er EPERM
|
|
||||||
The current process is not the super-user and a change
|
|
||||||
other than changing the effective user-id to the real user-id
|
|
||||||
was specified.
|
|
||||||
.El
|
|
||||||
.Sh SEE ALSO
|
|
||||||
.Xr getuid 2 ,
|
|
||||||
.Xr seteuid 2 ,
|
|
||||||
.Xr setuid 2
|
|
||||||
.Sh HISTORY
|
|
||||||
The
|
|
||||||
.Nm
|
|
||||||
function call appeared in
|
|
||||||
.Bx 4.2
|
|
||||||
and was dropped in
|
|
||||||
.Bx 4.4 .
|
|
@ -1,62 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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[] = "@(#)setreuid.c 8.1 (Berkeley) 6/2/93";
|
|
||||||
#endif /* LIBC_SCCS and not lint */
|
|
||||||
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <errno.h>
|
|
||||||
|
|
||||||
int
|
|
||||||
setreuid(ruid, euid)
|
|
||||||
uid_t ruid, euid;
|
|
||||||
{
|
|
||||||
static uid_t saveduid = -1;
|
|
||||||
|
|
||||||
if (saveduid == -1)
|
|
||||||
saveduid = geteuid();
|
|
||||||
/*
|
|
||||||
* we assume that the intent here is to be able to
|
|
||||||
* get back ruid priviledge. So we make sure that
|
|
||||||
* we will be able to do so, but do not actually
|
|
||||||
* set the ruid.
|
|
||||||
*/
|
|
||||||
if (ruid != -1 && ruid != getuid() && ruid != saveduid) {
|
|
||||||
errno = EPERM;
|
|
||||||
return (-1);
|
|
||||||
}
|
|
||||||
if (euid != -1 && seteuid(euid) < 0)
|
|
||||||
return (-1);
|
|
||||||
return (0);
|
|
||||||
}
|
|
@ -1,258 +0,0 @@
|
|||||||
.\" Copyright (c) 1989, 1991, 1993
|
|
||||||
.\" The Regents of the University of California. All rights reserved.
|
|
||||||
.\"
|
|
||||||
.\" This code is derived from software contributed to Berkeley by
|
|
||||||
.\" Arthur Olson.
|
|
||||||
.\" 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.
|
|
||||||
.\"
|
|
||||||
.\" @(#)ctime.3 8.1 (Berkeley) 6/4/93
|
|
||||||
.\"
|
|
||||||
.Dd June 4, 1993
|
|
||||||
.Dt CTIME 3
|
|
||||||
.Os BSD 4.3
|
|
||||||
.Sh NAME
|
|
||||||
.Nm asctime ,
|
|
||||||
.Nm ctime ,
|
|
||||||
.Nm difftime ,
|
|
||||||
.Nm gmtime ,
|
|
||||||
.Nm localtime ,
|
|
||||||
.Nm mktime
|
|
||||||
.Nd transform binary date and time value to
|
|
||||||
.Tn ASCII
|
|
||||||
.Sh SYNOPSIS
|
|
||||||
.Fd #include <sys/types.h>
|
|
||||||
.Fd #include <time.h>
|
|
||||||
.Vt extern char *tzname[2];
|
|
||||||
.Ft char *
|
|
||||||
.Fn ctime "const time_t *clock"
|
|
||||||
.Ft double
|
|
||||||
.Fn difftime "time_t time1" "time_t time0"
|
|
||||||
.Ft char *
|
|
||||||
.Fn asctime "const struct tm *tm"
|
|
||||||
.Ft struct tm *
|
|
||||||
.Fn localtime "const time_t *clock"
|
|
||||||
.Ft struct tm *
|
|
||||||
.Fn gmtime "const time_t *clock"
|
|
||||||
.Ft time_t
|
|
||||||
.Fn mktime "struct tm *tm"
|
|
||||||
.Sh DESCRIPTION
|
|
||||||
The functions
|
|
||||||
.Fn ctime ,
|
|
||||||
.Fn gmtime
|
|
||||||
and
|
|
||||||
.Fn localtime
|
|
||||||
all take as an argument a time value representing the time in seconds since
|
|
||||||
the Epoch (00:00:00
|
|
||||||
.Tn UTC ,
|
|
||||||
January 1, 1970; see
|
|
||||||
.Xr time 3 ) .
|
|
||||||
.Pp
|
|
||||||
The function
|
|
||||||
.Fn localtime
|
|
||||||
converts the time value pointed at by
|
|
||||||
.Fa clock ,
|
|
||||||
and returns a pointer to a
|
|
||||||
.Dq Fa struct tm
|
|
||||||
(described below) which contains
|
|
||||||
the broken-out time information for the value after adjusting for the current
|
|
||||||
time zone (and any other factors such as Daylight Saving Time).
|
|
||||||
Time zone adjustments are performed as specified by the
|
|
||||||
.Ev TZ
|
|
||||||
environmental variable (see
|
|
||||||
.Xr tzset 3 ) .
|
|
||||||
The function
|
|
||||||
.Fn localtime
|
|
||||||
uses
|
|
||||||
.Xr tzset
|
|
||||||
to initialize time conversion information if
|
|
||||||
.Xr tzset
|
|
||||||
has not already been called by the process.
|
|
||||||
.Pp
|
|
||||||
After filling in the tm structure,
|
|
||||||
.Fn localtime
|
|
||||||
sets the
|
|
||||||
.Fa tm_isdst Ns 'th
|
|
||||||
element of
|
|
||||||
.Fa tzname
|
|
||||||
to a pointer to an
|
|
||||||
.Tn ASCII
|
|
||||||
string that's the time zone abbreviation to be
|
|
||||||
used with
|
|
||||||
.Fn localtime Ns 's
|
|
||||||
return value.
|
|
||||||
.Pp
|
|
||||||
The function
|
|
||||||
.Fn gmtime
|
|
||||||
similarly converts the time value, but without any time zone adjustment,
|
|
||||||
and returns a pointer to a tm structure (described below).
|
|
||||||
.Pp
|
|
||||||
The
|
|
||||||
.Fn ctime
|
|
||||||
function
|
|
||||||
adjusts the time value for the current time zone in the same manner as
|
|
||||||
.Fn localtime ,
|
|
||||||
and returns a pointer to a 26-character string of the form:
|
|
||||||
.Bd -literal -offset indent
|
|
||||||
Thu Nov 24 18:22:48 1986\en\e0
|
|
||||||
.Ed
|
|
||||||
.Pp
|
|
||||||
All the fields have constant width.
|
|
||||||
.Pp
|
|
||||||
The
|
|
||||||
.Fn asctime
|
|
||||||
function
|
|
||||||
converts the broken down time in the structure
|
|
||||||
.Fa tm
|
|
||||||
pointed at by
|
|
||||||
.Fa *tm
|
|
||||||
to the form
|
|
||||||
shown in the example above.
|
|
||||||
.Pp
|
|
||||||
The function
|
|
||||||
.Fn mktime
|
|
||||||
converts the broken-down time, expressed as local time, in the structure
|
|
||||||
pointed to by tm into a time value with the same encoding as that of the
|
|
||||||
values returned by the
|
|
||||||
.Xr time 3
|
|
||||||
function, that is, seconds from the Epoch,
|
|
||||||
.Tn UTC .
|
|
||||||
.Pp
|
|
||||||
The original values of the
|
|
||||||
.Fa tm_wday
|
|
||||||
and
|
|
||||||
.Fa tm_yday
|
|
||||||
components of the structure are ignored, and the original values of the
|
|
||||||
other components are not restricted to their normal ranges.
|
|
||||||
(A positive or zero value for
|
|
||||||
.Fa tm_isdst
|
|
||||||
causes
|
|
||||||
.Fn mktime
|
|
||||||
to presume initially that summer time (for example, Daylight Saving Time)
|
|
||||||
is or is not in effect for the specified time, respectively.
|
|
||||||
A negative value for
|
|
||||||
.Fa tm_isdst
|
|
||||||
causes the
|
|
||||||
.Fn mktime
|
|
||||||
function to attempt to divine whether summer time is in effect for the
|
|
||||||
specified time.)
|
|
||||||
.Pp
|
|
||||||
On successful completion, the values of the
|
|
||||||
.Fa tm_wday
|
|
||||||
and
|
|
||||||
.Fa tm_yday
|
|
||||||
components of the structure are set appropriately, and the other components
|
|
||||||
are set to represent the specified calendar time, but with their values
|
|
||||||
forced to their normal ranges; the final value of
|
|
||||||
.Fa tm_mday
|
|
||||||
is not set until
|
|
||||||
.Fa tm_mon
|
|
||||||
and
|
|
||||||
.Fa tm_year
|
|
||||||
are determined.
|
|
||||||
.Fn Mktime
|
|
||||||
returns the specified calendar time; if the calendar time cannot be
|
|
||||||
represented, it returns \-1;
|
|
||||||
.Pp
|
|
||||||
The
|
|
||||||
.Fn difftime
|
|
||||||
function
|
|
||||||
returns the difference between two calendar times,
|
|
||||||
.Pf ( Fa time1
|
|
||||||
-
|
|
||||||
.Fa time0 ) ,
|
|
||||||
expressed in seconds.
|
|
||||||
.Pp
|
|
||||||
External declarations as well as the tm structure definition are in the
|
|
||||||
.Aq Pa time.h
|
|
||||||
include file.
|
|
||||||
The tm structure includes at least the following fields:
|
|
||||||
.Bd -literal -offset indent
|
|
||||||
int tm_sec; /\(** seconds (0 - 60) \(**/
|
|
||||||
int tm_min; /\(** minutes (0 - 59) \(**/
|
|
||||||
int tm_hour; /\(** hours (0 - 23) \(**/
|
|
||||||
int tm_mday; /\(** day of month (1 - 31) \(**/
|
|
||||||
int tm_mon; /\(** month of year (0 - 11) \(**/
|
|
||||||
int tm_year; /\(** year \- 1900 \(**/
|
|
||||||
int tm_wday; /\(** day of week (Sunday = 0) \(**/
|
|
||||||
int tm_yday; /\(** day of year (0 - 365) \(**/
|
|
||||||
int tm_isdst; /\(** is summer time in effect? \(**/
|
|
||||||
char \(**tm_zone; /\(** abbreviation of timezone name \(**/
|
|
||||||
long tm_gmtoff; /\(** offset from UTC in seconds \(**/
|
|
||||||
.Ed
|
|
||||||
.Pp
|
|
||||||
The
|
|
||||||
field
|
|
||||||
.Fa tm_isdst
|
|
||||||
is non-zero if summer time is in effect.
|
|
||||||
.Pp
|
|
||||||
The field
|
|
||||||
.Fa tm_gmtoff
|
|
||||||
is the offset (in seconds) of the time represented from
|
|
||||||
.Tn UTC ,
|
|
||||||
with positive
|
|
||||||
values indicating east of the Prime Meridian.
|
|
||||||
.Sh SEE ALSO
|
|
||||||
.Xr date 1 ,
|
|
||||||
.Xr gettimeofday 2 ,
|
|
||||||
.Xr getenv 3 ,
|
|
||||||
.Xr time 3 ,
|
|
||||||
.Xr tzset 3 ,
|
|
||||||
.Xr tzfile 5
|
|
||||||
.Sh HISTORY
|
|
||||||
This manual page is derived from
|
|
||||||
the time package contributed to Berkeley by
|
|
||||||
Arthur Olsen and which appeared in
|
|
||||||
.Bx 4.3 .
|
|
||||||
.Sh BUGS
|
|
||||||
Except for
|
|
||||||
.Fn difftime
|
|
||||||
and
|
|
||||||
.Fn mktime ,
|
|
||||||
these functions leaves their result in an internal static object and return
|
|
||||||
a pointer to that object. Subsequent calls to these
|
|
||||||
function will modify the same object.
|
|
||||||
.Pp
|
|
||||||
The
|
|
||||||
.Fa tm_zone
|
|
||||||
field of a returned tm structure points to a static array of characters,
|
|
||||||
which will also be overwritten by any subsequent calls (as well as by
|
|
||||||
subsequent calls to
|
|
||||||
.Xr tzset 3
|
|
||||||
and
|
|
||||||
.Xr tzsetwall 3 ) .
|
|
||||||
.Pp
|
|
||||||
Use of the external variable
|
|
||||||
.Fa tzname
|
|
||||||
is discouraged; the
|
|
||||||
.Fa tm_zone
|
|
||||||
entry in the tm structure is preferred.
|
|
||||||
.Pp
|
|
||||||
Avoid using out-of-range values with
|
|
||||||
.Fn mktime
|
|
||||||
when setting up lunch with promptness sticklers in Riyadh.
|
|
1381
lib/libc/gen/ctime.c
1381
lib/libc/gen/ctime.c
File diff suppressed because it is too large
Load Diff
@ -1,45 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 1989, 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[] = "@(#)difftime.c 8.1 (Berkeley) 6/4/93";
|
|
||||||
#endif /* LIBC_SCCS and not lint */
|
|
||||||
|
|
||||||
#include <sys/types.h>
|
|
||||||
|
|
||||||
double
|
|
||||||
difftime(time1, time0)
|
|
||||||
time_t time1, time0;
|
|
||||||
{
|
|
||||||
return(time1 - time0);
|
|
||||||
}
|
|
@ -1,78 +0,0 @@
|
|||||||
/*-
|
|
||||||
* Copyright (c) 1990, 1993
|
|
||||||
* The Regents of the University of California. All rights reserved.
|
|
||||||
*
|
|
||||||
* This code is derived from software contributed to Berkeley by
|
|
||||||
* William Jolitz.
|
|
||||||
*
|
|
||||||
* 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)
|
|
||||||
.asciz "@(#)_setjmp.s 8.1 (Berkeley) 6/4/93"
|
|
||||||
#endif /* LIBC_SCCS and not lint */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* C library -- _setjmp, _longjmp
|
|
||||||
*
|
|
||||||
* _longjmp(a,v)
|
|
||||||
* will generate a "return(v)" from the last call to
|
|
||||||
* _setjmp(a)
|
|
||||||
* by restoring registers from the stack.
|
|
||||||
* The previous signal state is NOT restored.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "DEFS.h"
|
|
||||||
|
|
||||||
ENTRY(_setjmp)
|
|
||||||
movl 4(%esp),%eax
|
|
||||||
movl 0(%esp),%edx
|
|
||||||
movl %edx, 0(%eax) /* rta */
|
|
||||||
movl %ebx, 4(%eax)
|
|
||||||
movl %esp, 8(%eax)
|
|
||||||
movl %ebp,12(%eax)
|
|
||||||
movl %esi,16(%eax)
|
|
||||||
movl %edi,20(%eax)
|
|
||||||
movl $0,%eax
|
|
||||||
ret
|
|
||||||
|
|
||||||
ENTRY(_longjmp)
|
|
||||||
movl 4(%esp),%edx
|
|
||||||
movl 8(%esp),%eax
|
|
||||||
movl 0(%edx),%ecx
|
|
||||||
movl 4(%edx),%ebx
|
|
||||||
movl 8(%edx),%esp
|
|
||||||
movl 12(%edx),%ebp
|
|
||||||
movl 16(%edx),%esi
|
|
||||||
movl 20(%edx),%edi
|
|
||||||
cmpl $0,%eax
|
|
||||||
jne 1f
|
|
||||||
movl $1,%eax
|
|
||||||
1: movl %ecx,0(%esp)
|
|
||||||
ret
|
|
@ -1,57 +0,0 @@
|
|||||||
/*-
|
|
||||||
* Copyright (c) 1990, 1993
|
|
||||||
* The Regents of the University of California. All rights reserved.
|
|
||||||
*
|
|
||||||
* This code is derived from software contributed to Berkeley by
|
|
||||||
* William Jolitz.
|
|
||||||
*
|
|
||||||
* 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)
|
|
||||||
.asciz "@(#)alloca.s 8.1 (Berkeley) 6/4/93"
|
|
||||||
#endif /* LIBC_SCCS and not lint */
|
|
||||||
|
|
||||||
/* like alloc, but automatic automatic free in return */
|
|
||||||
|
|
||||||
#include "DEFS.h"
|
|
||||||
|
|
||||||
ENTRY(alloca)
|
|
||||||
popl %edx /* pop return addr */
|
|
||||||
popl %eax /* pop amount to allocate */
|
|
||||||
movl %esp,%ecx
|
|
||||||
addl $3,%eax /* round up to next word */
|
|
||||||
andl $0xfffffffc,%eax
|
|
||||||
subl %eax,%esp
|
|
||||||
movl %esp,%eax /* base of newly allocated space */
|
|
||||||
pushl 8(%ecx) /* copy possible saved registers */
|
|
||||||
pushl 4(%ecx)
|
|
||||||
pushl 0(%ecx)
|
|
||||||
pushl %eax /* dummy to pop at callsite */
|
|
||||||
jmp %edx /* "return" */
|
|
@ -1,46 +0,0 @@
|
|||||||
/*-
|
|
||||||
* Copyright (c) 1990, 1993
|
|
||||||
* The Regents of the University of California. All rights reserved.
|
|
||||||
*
|
|
||||||
* This code is derived from software contributed to Berkeley by
|
|
||||||
* William Jolitz.
|
|
||||||
*
|
|
||||||
* 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)
|
|
||||||
.asciz "@(#)divsi3.s 8.1 (Berkeley) 6/4/93"
|
|
||||||
#endif /* LIBC_SCCS and not lint */
|
|
||||||
|
|
||||||
.globl ___divsi3
|
|
||||||
___divsi3:
|
|
||||||
movl 4(%esp),%eax
|
|
||||||
cltd
|
|
||||||
idivl 8(%esp)
|
|
||||||
ret
|
|
@ -1,46 +0,0 @@
|
|||||||
/*-
|
|
||||||
* Copyright (c) 1990, 1993
|
|
||||||
* The Regents of the University of California. All rights reserved.
|
|
||||||
*
|
|
||||||
* This code is derived from software contributed to Berkeley by
|
|
||||||
* William Jolitz.
|
|
||||||
*
|
|
||||||
* 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)
|
|
||||||
.asciz "@(#)fabs.s 8.1 (Berkeley) 6/4/93"
|
|
||||||
#endif /* LIBC_SCCS and not lint */
|
|
||||||
|
|
||||||
#include "DEFS.h"
|
|
||||||
|
|
||||||
ENTRY(fabs)
|
|
||||||
fldl 4(%esp)
|
|
||||||
fabs
|
|
||||||
ret
|
|
@ -1,46 +0,0 @@
|
|||||||
/*-
|
|
||||||
* Copyright (c) 1991, 1993
|
|
||||||
* The Regents of the University of California. All rights reserved.
|
|
||||||
*
|
|
||||||
* This code is derived from software contributed to Berkeley by
|
|
||||||
* William Jolitz.
|
|
||||||
*
|
|
||||||
* 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)
|
|
||||||
.asciz "@(#)fixdfsi.s 8.1 (Berkeley) 6/4/93"
|
|
||||||
#endif /* LIBC_SCCS and not lint */
|
|
||||||
|
|
||||||
.globl ___fixdfsi
|
|
||||||
___fixdfsi:
|
|
||||||
fldl 4(%esp)
|
|
||||||
fistpl 4(%esp)
|
|
||||||
movl 4(%esp),%eax
|
|
||||||
ret
|
|
@ -1,60 +0,0 @@
|
|||||||
/*-
|
|
||||||
* Copyright (c) 1990, 1993
|
|
||||||
* The Regents of the University of California. All rights reserved.
|
|
||||||
*
|
|
||||||
* This code is derived from software contributed to Berkeley by
|
|
||||||
* William Jolitz.
|
|
||||||
*
|
|
||||||
* 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)
|
|
||||||
.asciz "@(#)fixunsdfsi.s 8.1 6/4/93"
|
|
||||||
#endif /* LIBC_SCCS and not lint */
|
|
||||||
|
|
||||||
.globl ___fixunsdfsi
|
|
||||||
___fixunsdfsi:
|
|
||||||
fldl 4(%esp) /* argument double to accum stack */
|
|
||||||
frndint /* create integer */
|
|
||||||
fcoml fbiggestsigned /* bigger than biggest signed? */
|
|
||||||
fstsw %ax
|
|
||||||
sahf
|
|
||||||
jnb 1f
|
|
||||||
|
|
||||||
fistpl 4(%esp)
|
|
||||||
movl 4(%esp),%eax
|
|
||||||
ret
|
|
||||||
|
|
||||||
1: fsubl fbiggestsigned /* reduce for proper conversion */
|
|
||||||
fistpl 4(%esp) /* convert */
|
|
||||||
movl 4(%esp),%eax
|
|
||||||
orl $0x80000000,%eax /* restore bias */
|
|
||||||
ret
|
|
||||||
|
|
||||||
fbiggestsigned: .double 0r2147483648.0
|
|
@ -1,75 +0,0 @@
|
|||||||
/*-
|
|
||||||
* Copyright (c) 1990, 1993
|
|
||||||
* The Regents of the University of California. All rights reserved.
|
|
||||||
*
|
|
||||||
* This code is derived from software contributed to Berkeley by
|
|
||||||
* Sean Eric Fagan.
|
|
||||||
*
|
|
||||||
* 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)
|
|
||||||
.asciz "@(#)modf.s 8.1 (Berkeley) 6/4/93"
|
|
||||||
#endif /* LIBC_SCCS and not lint */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* modf(value, iptr): return fractional part of value, and stores the
|
|
||||||
* integral part into iptr (a pointer to double).
|
|
||||||
*
|
|
||||||
* Written by Sean Eric Fagan (sef@kithrup.COM)
|
|
||||||
* Sun Mar 11 20:27:30 PST 1990
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* With CHOP mode on, frndint behaves as TRUNC does. Useful. */
|
|
||||||
.text
|
|
||||||
.globl _modf
|
|
||||||
_modf:
|
|
||||||
pushl %ebp
|
|
||||||
movl %esp,%ebp
|
|
||||||
subl $16,%esp
|
|
||||||
fnstcw -12(%ebp)
|
|
||||||
movw -12(%ebp),%dx
|
|
||||||
orw $3072,%dx
|
|
||||||
movw %dx,-16(%ebp)
|
|
||||||
fldcw -16(%ebp)
|
|
||||||
fldl 8(%ebp)
|
|
||||||
frndint
|
|
||||||
fstpl -8(%ebp)
|
|
||||||
fldcw -12(%ebp)
|
|
||||||
movl 16(%ebp),%eax
|
|
||||||
movl -8(%ebp),%edx
|
|
||||||
movl -4(%ebp),%ecx
|
|
||||||
movl %edx,(%eax)
|
|
||||||
movl %ecx,4(%eax)
|
|
||||||
fldl 8(%ebp)
|
|
||||||
fsubl -8(%ebp)
|
|
||||||
jmp L1
|
|
||||||
L1:
|
|
||||||
leave
|
|
||||||
ret
|
|
@ -1,86 +0,0 @@
|
|||||||
/*-
|
|
||||||
* Copyright (c) 1990, 1993
|
|
||||||
* The Regents of the University of California. All rights reserved.
|
|
||||||
*
|
|
||||||
* This code is derived from software contributed to Berkeley by
|
|
||||||
* William Jolitz.
|
|
||||||
*
|
|
||||||
* 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)
|
|
||||||
.asciz "@(#)setjmp.s 8.1 (Berkeley) 6/4/93"
|
|
||||||
#endif /* LIBC_SCCS and not lint */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* C library -- _setjmp, _longjmp
|
|
||||||
*
|
|
||||||
* longjmp(a,v)
|
|
||||||
* will generate a "return(v)" from the last call to
|
|
||||||
* setjmp(a)
|
|
||||||
* by restoring registers from the stack.
|
|
||||||
* The previous signal state is restored.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "DEFS.h"
|
|
||||||
|
|
||||||
ENTRY(setjmp)
|
|
||||||
pushl $0
|
|
||||||
call _sigblock
|
|
||||||
popl %edx
|
|
||||||
movl 4(%esp),%ecx
|
|
||||||
movl 0(%esp),%edx
|
|
||||||
movl %edx, 0(%ecx)
|
|
||||||
movl %ebx, 4(%ecx)
|
|
||||||
movl %esp, 8(%ecx)
|
|
||||||
movl %ebp,12(%ecx)
|
|
||||||
movl %esi,16(%ecx)
|
|
||||||
movl %edi,20(%ecx)
|
|
||||||
movl %eax,24(%ecx)
|
|
||||||
movl $0,%eax
|
|
||||||
ret
|
|
||||||
|
|
||||||
ENTRY(longjmp)
|
|
||||||
movl 4(%esp),%edx
|
|
||||||
pushl 24(%edx)
|
|
||||||
call _sigsetmask
|
|
||||||
popl %eax
|
|
||||||
movl 4(%esp),%edx
|
|
||||||
movl 8(%esp),%eax
|
|
||||||
movl 0(%edx),%ecx
|
|
||||||
movl 4(%edx),%ebx
|
|
||||||
movl 8(%edx),%esp
|
|
||||||
movl 12(%edx),%ebp
|
|
||||||
movl 16(%edx),%esi
|
|
||||||
movl 20(%edx),%edi
|
|
||||||
cmpl $0,%eax
|
|
||||||
jne 1f
|
|
||||||
movl $1,%eax
|
|
||||||
1: movl %ecx,0(%esp)
|
|
||||||
ret
|
|
@ -1,46 +0,0 @@
|
|||||||
/*-
|
|
||||||
* Copyright (c) 1990, 1993
|
|
||||||
* The Regents of the University of California. All rights reserved.
|
|
||||||
*
|
|
||||||
* This code is derived from software contributed to Berkeley by
|
|
||||||
* William Jolitz.
|
|
||||||
*
|
|
||||||
* 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)
|
|
||||||
.asciz "@(#)udivsi3.s 8.1 (Berkeley) 6/4/93"
|
|
||||||
#endif /* LIBC_SCCS and not lint */
|
|
||||||
|
|
||||||
.globl ___udivsi3
|
|
||||||
___udivsi3:
|
|
||||||
movl 4(%esp),%eax
|
|
||||||
xorl %edx,%edx
|
|
||||||
divl 8(%esp)
|
|
||||||
ret
|
|
@ -1,50 +0,0 @@
|
|||||||
/*-
|
|
||||||
* Copyright (c) 1990, 1993
|
|
||||||
* The Regents of the University of California. All rights reserved.
|
|
||||||
*
|
|
||||||
* This code is derived from software contributed to Berkeley by
|
|
||||||
* William Jolitz.
|
|
||||||
*
|
|
||||||
* 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)
|
|
||||||
.asciz "@(#)htonl.s 8.1 (Berkeley) 6/4/93"
|
|
||||||
#endif /* LIBC_SCCS and not lint */
|
|
||||||
|
|
||||||
/* netorder = htonl(hostorder) */
|
|
||||||
|
|
||||||
#include "DEFS.h"
|
|
||||||
|
|
||||||
ENTRY(htonl)
|
|
||||||
movl 4(%esp),%eax
|
|
||||||
xchgb %al,%ah
|
|
||||||
roll $16,%eax
|
|
||||||
xchgb %al,%ah
|
|
||||||
ret
|
|
@ -1,48 +0,0 @@
|
|||||||
/*-
|
|
||||||
* Copyright (c) 1990, 1993
|
|
||||||
* The Regents of the University of California. All rights reserved.
|
|
||||||
*
|
|
||||||
* This code is derived from software contributed to Berkeley by
|
|
||||||
* William Jolitz.
|
|
||||||
*
|
|
||||||
* 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)
|
|
||||||
.asciz "@(#)htons.s 8.1 (Berkeley) 6/4/93"
|
|
||||||
#endif /* LIBC_SCCS and not lint */
|
|
||||||
|
|
||||||
/* netorder = htons(hostorder) */
|
|
||||||
|
|
||||||
#include "DEFS.h"
|
|
||||||
|
|
||||||
ENTRY(htons)
|
|
||||||
movzwl 4(%esp),%eax
|
|
||||||
xchgb %al,%ah
|
|
||||||
ret
|
|
@ -1,50 +0,0 @@
|
|||||||
/*-
|
|
||||||
* Copyright (c) 1990, 1993
|
|
||||||
* The Regents of the University of California. All rights reserved.
|
|
||||||
*
|
|
||||||
* This code is derived from software contributed to Berkeley by
|
|
||||||
* William Jolitz.
|
|
||||||
*
|
|
||||||
* 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)
|
|
||||||
.asciz "@(#)ntohl.s 8.1 (Berkeley) 6/4/93"
|
|
||||||
#endif /* LIBC_SCCS and not lint */
|
|
||||||
|
|
||||||
/* hostorder = ntohl(netorder) */
|
|
||||||
|
|
||||||
#include "DEFS.h"
|
|
||||||
|
|
||||||
ENTRY(ntohl)
|
|
||||||
movl 4(%esp),%eax
|
|
||||||
xchgb %al,%ah
|
|
||||||
roll $16,%eax
|
|
||||||
xchgb %al,%ah
|
|
||||||
ret
|
|
@ -1,48 +0,0 @@
|
|||||||
/*-
|
|
||||||
* Copyright (c) 1990, 1993
|
|
||||||
* The Regents of the University of California. All rights reserved.
|
|
||||||
*
|
|
||||||
* This code is derived from software contributed to Berkeley by
|
|
||||||
* William Jolitz.
|
|
||||||
*
|
|
||||||
* 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)
|
|
||||||
.asciz "@(#)ntohs.s 8.1 (Berkeley) 6/4/93"
|
|
||||||
#endif /* LIBC_SCCS and not lint */
|
|
||||||
|
|
||||||
/* hostorder = ntohs(netorder) */
|
|
||||||
|
|
||||||
#include "DEFS.h"
|
|
||||||
|
|
||||||
ENTRY(ntohs)
|
|
||||||
movzwl 4(%esp),%eax
|
|
||||||
xchgb %al,%ah
|
|
||||||
ret
|
|
@ -1,48 +0,0 @@
|
|||||||
/*-
|
|
||||||
* Copyright (c) 1990, 1993
|
|
||||||
* The Regents of the University of California. All rights reserved.
|
|
||||||
*
|
|
||||||
* This code is derived from software contributed to Berkeley by
|
|
||||||
* William Jolitz.
|
|
||||||
*
|
|
||||||
* 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)
|
|
||||||
.asciz "@(#)abs.s 8.1 (Berkeley) 6/4/93"
|
|
||||||
#endif /* LIBC_SCCS and not lint */
|
|
||||||
|
|
||||||
#include "DEFS.h"
|
|
||||||
|
|
||||||
ENTRY(abs)
|
|
||||||
movl 4(%esp),%eax
|
|
||||||
cmpl $0,%eax
|
|
||||||
jge 1f
|
|
||||||
negl %eax
|
|
||||||
1: ret
|
|
@ -1,53 +0,0 @@
|
|||||||
/*-
|
|
||||||
* Copyright (c) 1990, 1993
|
|
||||||
* The Regents of the University of California. All rights reserved.
|
|
||||||
*
|
|
||||||
* This code is derived from software contributed to Berkeley by
|
|
||||||
* William Jolitz.
|
|
||||||
*
|
|
||||||
* 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)
|
|
||||||
.asciz "@(#)bzero.s 8.1 (Berkeley) 6/4/93"
|
|
||||||
#endif /* LIBC_SCCS and not lint */
|
|
||||||
|
|
||||||
/* bzero (base,cnt) */
|
|
||||||
|
|
||||||
.globl _bzero
|
|
||||||
_bzero:
|
|
||||||
pushl %edi
|
|
||||||
movl 8(%esp),%edi
|
|
||||||
movl 12(%esp),%ecx
|
|
||||||
movb $0x00,%al
|
|
||||||
cld
|
|
||||||
rep
|
|
||||||
stosb
|
|
||||||
popl %edi
|
|
||||||
ret
|
|
@ -1,70 +0,0 @@
|
|||||||
/*-
|
|
||||||
* Copyright (c) 1990, 1993
|
|
||||||
* The Regents of the University of California. All rights reserved.
|
|
||||||
*
|
|
||||||
* This code is derived from software contributed to Berkeley by
|
|
||||||
* William Jolitz.
|
|
||||||
*
|
|
||||||
* 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(SYSLIBC_SCCS) && !defined(lint)
|
|
||||||
.asciz "@(#)Ovfork.s 8.1 (Berkeley) 6/4/93"
|
|
||||||
#endif /* SYSLIBC_SCCS and not lint */
|
|
||||||
|
|
||||||
#include "SYS.h"
|
|
||||||
|
|
||||||
/*
|
|
||||||
* pid = vfork();
|
|
||||||
*
|
|
||||||
* %edx == 0 in parent process, %edx == 1 in child process.
|
|
||||||
* %eax == pid of child in parent, %eax == pid of parent in child.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
.set vfork,66
|
|
||||||
.globl _vfork
|
|
||||||
|
|
||||||
_vfork:
|
|
||||||
popl %ecx /* my rta into ecx */
|
|
||||||
movl $vfork, %eax
|
|
||||||
LCALL(7,0)
|
|
||||||
jb verror
|
|
||||||
vforkok:
|
|
||||||
cmpl $0,%edx /* child process? */
|
|
||||||
jne child /* yes */
|
|
||||||
jmp parent
|
|
||||||
.globl _errno
|
|
||||||
verror:
|
|
||||||
movl %eax,_errno
|
|
||||||
movl $-1,%eax
|
|
||||||
jmp %ecx
|
|
||||||
child:
|
|
||||||
movl $0,%eax
|
|
||||||
parent:
|
|
||||||
jmp %ecx
|
|
@ -1,65 +0,0 @@
|
|||||||
/*-
|
|
||||||
* Copyright (c) 1990, 1993
|
|
||||||
* The Regents of the University of California. All rights reserved.
|
|
||||||
*
|
|
||||||
* This code is derived from software contributed to Berkeley by
|
|
||||||
* William Jolitz.
|
|
||||||
*
|
|
||||||
* 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(SYSLIBC_SCCS) && !defined(lint)
|
|
||||||
.asciz "@(#)brk.s 8.1 (Berkeley) 6/4/93"
|
|
||||||
#endif /* SYSLIBC_SCCS and not lint */
|
|
||||||
|
|
||||||
#include "SYS.h"
|
|
||||||
|
|
||||||
#define SYS_brk 17
|
|
||||||
|
|
||||||
.globl curbrk
|
|
||||||
.globl minbrk
|
|
||||||
ENTRY(_brk)
|
|
||||||
jmp ok
|
|
||||||
|
|
||||||
ENTRY(brk)
|
|
||||||
movl 4(%esp),%eax
|
|
||||||
cmpl %eax,minbrk
|
|
||||||
jl ok
|
|
||||||
movl minbrk,%eax
|
|
||||||
movl %eax,4(%esp)
|
|
||||||
ok:
|
|
||||||
lea SYS_brk,%eax
|
|
||||||
LCALL(7,0)
|
|
||||||
jb err
|
|
||||||
movl 4(%esp),%eax
|
|
||||||
movl %eax,curbrk
|
|
||||||
movl $0,%eax
|
|
||||||
ret
|
|
||||||
err:
|
|
||||||
jmp cerror
|
|
@ -1,47 +0,0 @@
|
|||||||
/*-
|
|
||||||
* Copyright (c) 1990, 1993
|
|
||||||
* The Regents of the University of California. All rights reserved.
|
|
||||||
*
|
|
||||||
* This code is derived from software contributed to Berkeley by
|
|
||||||
* William Jolitz.
|
|
||||||
*
|
|
||||||
* 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(SYSLIBC_SCCS) && !defined(lint)
|
|
||||||
.asciz "@(#)cerror.s 8.1 (Berkeley) 6/4/93"
|
|
||||||
#endif /* SYSLIBC_SCCS and not lint */
|
|
||||||
|
|
||||||
#include "SYS.h"
|
|
||||||
|
|
||||||
.globl _errno
|
|
||||||
cerror:
|
|
||||||
movl %eax,_errno
|
|
||||||
movl $-1,%eax
|
|
||||||
ret
|
|
@ -1,52 +0,0 @@
|
|||||||
/*-
|
|
||||||
* Copyright (c) 1990, 1993
|
|
||||||
* The Regents of the University of California. All rights reserved.
|
|
||||||
*
|
|
||||||
* This code is derived from software contributed to Berkeley by
|
|
||||||
* William Jolitz.
|
|
||||||
*
|
|
||||||
* 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(SYSLIBC_SCCS) && !defined(lint)
|
|
||||||
.asciz "@(#)exect.s 8.1 (Berkeley) 6/4/93"
|
|
||||||
#endif /* SYSLIBC_SCCS and not lint */
|
|
||||||
|
|
||||||
#include "SYS.h"
|
|
||||||
#include <machine/psl.h>
|
|
||||||
|
|
||||||
ENTRY(exect)
|
|
||||||
lea SYS_execve,%eax
|
|
||||||
pushf
|
|
||||||
popl %edx
|
|
||||||
orl $ PSL_T,%edx
|
|
||||||
pushl %edx
|
|
||||||
popf
|
|
||||||
LCALL(7,0)
|
|
||||||
jmp cerror /* exect(file, argv, env); */
|
|
@ -1,48 +0,0 @@
|
|||||||
/*-
|
|
||||||
* Copyright (c) 1990, 1993
|
|
||||||
* The Regents of the University of California. All rights reserved.
|
|
||||||
*
|
|
||||||
* This code is derived from software contributed to Berkeley by
|
|
||||||
* William Jolitz.
|
|
||||||
*
|
|
||||||
* 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(SYSLIBC_SCCS) && !defined(lint)
|
|
||||||
.asciz "@(#)fork.s 8.1 (Berkeley) 6/4/93"
|
|
||||||
#endif /* SYSLIBC_SCCS and not lint */
|
|
||||||
|
|
||||||
#include "SYS.h"
|
|
||||||
|
|
||||||
SYSCALL(fork)
|
|
||||||
cmpl $0,%edx /* parent, since %edx == 0 in parent, 1 in child */
|
|
||||||
je 1f
|
|
||||||
movl $0,%eax
|
|
||||||
1:
|
|
||||||
ret /* pid = fork(); */
|
|
@ -1,45 +0,0 @@
|
|||||||
/*-
|
|
||||||
* Copyright (c) 1990, 1993
|
|
||||||
* The Regents of the University of California. All rights reserved.
|
|
||||||
*
|
|
||||||
* This code is derived from software contributed to Berkeley by
|
|
||||||
* William Jolitz.
|
|
||||||
*
|
|
||||||
* 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(SYSLIBC_SCCS) && !defined(lint)
|
|
||||||
.asciz "@(#)mount.s 8.1 (Berkeley) 6/4/93"
|
|
||||||
#endif /* SYSLIBC_SCCS and not lint */
|
|
||||||
|
|
||||||
#include "SYS.h"
|
|
||||||
|
|
||||||
SYSCALL(mount)
|
|
||||||
movl $0,%eax
|
|
||||||
ret
|
|
@ -1,48 +0,0 @@
|
|||||||
/*-
|
|
||||||
* Copyright (c) 1990, 1993
|
|
||||||
* The Regents of the University of California. All rights reserved.
|
|
||||||
*
|
|
||||||
* This code is derived from software contributed to Berkeley by
|
|
||||||
* William Jolitz.
|
|
||||||
*
|
|
||||||
* 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(SYSLIBC_SCCS) && !defined(lint)
|
|
||||||
.asciz "@(#)pipe.s 8.1 (Berkeley) 6/4/93"
|
|
||||||
#endif /* SYSLIBC_SCCS and not lint */
|
|
||||||
|
|
||||||
#include "SYS.h"
|
|
||||||
|
|
||||||
SYSCALL(pipe)
|
|
||||||
movl 4(%esp),%ecx
|
|
||||||
movl %eax,(%ecx)
|
|
||||||
movl %edx,4(%ecx)
|
|
||||||
movl $0,%eax
|
|
||||||
ret
|
|
@ -1,51 +0,0 @@
|
|||||||
/*-
|
|
||||||
* Copyright (c) 1990, 1993
|
|
||||||
* The Regents of the University of California. All rights reserved.
|
|
||||||
*
|
|
||||||
* This code is derived from software contributed to Berkeley by
|
|
||||||
* William Jolitz.
|
|
||||||
*
|
|
||||||
* 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(SYSLIBC_SCCS) && !defined(lint)
|
|
||||||
.asciz "@(#)ptrace.s 8.1 (Berkeley) 6/4/93"
|
|
||||||
#endif /* SYSLIBC_SCCS and not lint */
|
|
||||||
|
|
||||||
#include "SYS.h"
|
|
||||||
|
|
||||||
ENTRY(ptrace)
|
|
||||||
xorl %eax,%eax
|
|
||||||
movl %eax,_errno
|
|
||||||
lea SYS_ptrace,%eax
|
|
||||||
LCALL(7,0)
|
|
||||||
jb err
|
|
||||||
ret
|
|
||||||
err:
|
|
||||||
jmp cerror
|
|
@ -1,44 +0,0 @@
|
|||||||
/*-
|
|
||||||
* Copyright (c) 1990, 1993
|
|
||||||
* The Regents of the University of California. All rights reserved.
|
|
||||||
*
|
|
||||||
* This code is derived from software contributed to Berkeley by
|
|
||||||
* William Jolitz.
|
|
||||||
*
|
|
||||||
* 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(SYSLIBC_SCCS) && !defined(lint)
|
|
||||||
.asciz "@(#)reboot.s 8.1 (Berkeley) 6/4/93"
|
|
||||||
#endif /* SYSLIBC_SCCS and not lint */
|
|
||||||
|
|
||||||
#include "SYS.h"
|
|
||||||
|
|
||||||
SYSCALL(reboot)
|
|
||||||
iret
|
|
@ -1,65 +0,0 @@
|
|||||||
/*-
|
|
||||||
* Copyright (c) 1990, 1993
|
|
||||||
* The Regents of the University of California. All rights reserved.
|
|
||||||
*
|
|
||||||
* This code is derived from software contributed to Berkeley by
|
|
||||||
* William Jolitz.
|
|
||||||
*
|
|
||||||
* 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(SYSLIBC_SCCS) && !defined(lint)
|
|
||||||
.asciz "@(#)sbrk.s 8.1 (Berkeley) 6/4/93"
|
|
||||||
#endif /* SYSLIBC_SCCS and not lint */
|
|
||||||
|
|
||||||
#include "SYS.h"
|
|
||||||
|
|
||||||
#define SYS_brk 17
|
|
||||||
|
|
||||||
.globl _end
|
|
||||||
.globl minbrk
|
|
||||||
.globl curbrk
|
|
||||||
|
|
||||||
.data
|
|
||||||
minbrk: .long _end
|
|
||||||
curbrk: .long _end
|
|
||||||
.text
|
|
||||||
|
|
||||||
ENTRY(sbrk)
|
|
||||||
movl 4(%esp),%ecx
|
|
||||||
movl curbrk,%eax
|
|
||||||
addl %eax,4(%esp)
|
|
||||||
lea SYS_brk,%eax
|
|
||||||
LCALL(7,0)
|
|
||||||
jb err
|
|
||||||
movl curbrk,%eax
|
|
||||||
addl %ecx,curbrk
|
|
||||||
ret
|
|
||||||
err:
|
|
||||||
jmp cerror
|
|
@ -1,47 +0,0 @@
|
|||||||
/*-
|
|
||||||
* Copyright (c) 1991, 1993
|
|
||||||
* The Regents of the University of California. All rights reserved.
|
|
||||||
*
|
|
||||||
* This code is derived from software contributed to Berkeley by
|
|
||||||
* William Jolitz.
|
|
||||||
*
|
|
||||||
* 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)
|
|
||||||
.asciz "@(#)setlogin.s 8.1 (Berkeley) 6/4/93"
|
|
||||||
#endif /* LIBC_SCCS and not lint */
|
|
||||||
|
|
||||||
#include "SYS.h"
|
|
||||||
|
|
||||||
.globl __logname_valid /* in getlogin() */
|
|
||||||
|
|
||||||
SYSCALL(setlogin)
|
|
||||||
movl $0,__logname_valid
|
|
||||||
ret /* setlogin(name) */
|
|
@ -1,47 +0,0 @@
|
|||||||
/*-
|
|
||||||
* Copyright (c) 1990, 1993
|
|
||||||
* The Regents of the University of California. All rights reserved.
|
|
||||||
*
|
|
||||||
* This code is derived from software contributed to Berkeley by
|
|
||||||
* William Jolitz.
|
|
||||||
*
|
|
||||||
* 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(SYSLIBC_SCCS) && !defined(lint)
|
|
||||||
.asciz "@(#)sigpending.s 8.1 (Berkeley) 6/4/93"
|
|
||||||
#endif /* SYSLIBC_SCCS and not lint */
|
|
||||||
|
|
||||||
#include "SYS.h"
|
|
||||||
|
|
||||||
SYSCALL(sigpending)
|
|
||||||
movl 4(%esp),%ecx # fetch pointer to...
|
|
||||||
movl %eax,(%ecx) # store old mask
|
|
||||||
xorl %eax,%eax
|
|
||||||
ret
|
|
@ -1,64 +0,0 @@
|
|||||||
/*-
|
|
||||||
* Copyright (c) 1990, 1993
|
|
||||||
* The Regents of the University of California. All rights reserved.
|
|
||||||
*
|
|
||||||
* This code is derived from software contributed to Berkeley by
|
|
||||||
* William Jolitz.
|
|
||||||
*
|
|
||||||
* 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(SYSLIBC_SCCS) && !defined(lint)
|
|
||||||
.asciz "@(#)sigprocmask.s 8.1 (Berkeley) 6/4/93"
|
|
||||||
#endif /* SYSLIBC_SCCS and not lint */
|
|
||||||
|
|
||||||
#include "SYS.h"
|
|
||||||
|
|
||||||
err:
|
|
||||||
jmp cerror
|
|
||||||
|
|
||||||
ENTRY(sigprocmask)
|
|
||||||
movl 8(%esp),%ecx # fetch new sigset pointer
|
|
||||||
cmpl $0,%ecx # check new sigset pointer
|
|
||||||
jne 1f # if not null, indirect
|
|
||||||
/* movl $0,8(%esp) # null mask pointer: block empty set */
|
|
||||||
movl $1,4(%esp) # SIG_BLOCK
|
|
||||||
jmp 2f
|
|
||||||
1: movl (%ecx),%ecx # fetch indirect ...
|
|
||||||
movl %ecx,8(%esp) # to new mask arg
|
|
||||||
2: movl $ SYS_sigprocmask , %eax
|
|
||||||
LCALL(0x7,0)
|
|
||||||
jb err
|
|
||||||
movl 12(%esp),%ecx # fetch old mask requested
|
|
||||||
cmpl $0,%ecx # test if old mask requested
|
|
||||||
je out
|
|
||||||
movl %eax,(%ecx) # store old mask
|
|
||||||
out:
|
|
||||||
xorl %eax,%eax
|
|
||||||
ret
|
|
@ -1,54 +0,0 @@
|
|||||||
/*-
|
|
||||||
* Copyright (c) 1990, 1993
|
|
||||||
* The Regents of the University of California. All rights reserved.
|
|
||||||
*
|
|
||||||
* This code is derived from software contributed to Berkeley by
|
|
||||||
* William Jolitz.
|
|
||||||
*
|
|
||||||
* 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(SYSLIBC_SCCS) && !defined(lint)
|
|
||||||
.asciz "@(#)sigreturn.s 8.1 (Berkeley) 6/4/93"
|
|
||||||
#endif /* SYSLIBC_SCCS and not lint */
|
|
||||||
|
|
||||||
#include "SYS.h"
|
|
||||||
|
|
||||||
/*
|
|
||||||
* We must preserve the state of the registers as the user has set them up.
|
|
||||||
*/
|
|
||||||
#ifdef PROF
|
|
||||||
#undef ENTRY
|
|
||||||
#define ENTRY(x) \
|
|
||||||
.globl _/**/x; .align 2; _/**/x: pusha ; \
|
|
||||||
.data; 1:; .long 0; .text; movl $1b,%eax; call mcount; popa ; nop
|
|
||||||
#endif /* PROF */
|
|
||||||
|
|
||||||
SYSCALL(sigreturn)
|
|
||||||
ret
|
|
@ -1,54 +0,0 @@
|
|||||||
/*-
|
|
||||||
* Copyright (c) 1990, 1993
|
|
||||||
* The Regents of the University of California. All rights reserved.
|
|
||||||
*
|
|
||||||
* This code is derived from software contributed to Berkeley by
|
|
||||||
* William Jolitz.
|
|
||||||
*
|
|
||||||
* 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(SYSLIBC_SCCS) && !defined(lint)
|
|
||||||
.asciz "@(#)sigsuspend.s 8.1 (Berkeley) 6/4/93"
|
|
||||||
#endif /* SYSLIBC_SCCS and not lint */
|
|
||||||
|
|
||||||
#include "SYS.h"
|
|
||||||
|
|
||||||
err:
|
|
||||||
jmp cerror
|
|
||||||
|
|
||||||
ENTRY(sigsuspend)
|
|
||||||
movl 4(%esp),%eax # fetch mask arg
|
|
||||||
movl (%eax),%eax # indirect to mask arg
|
|
||||||
movl %eax,4(%esp)
|
|
||||||
movl $ SYS_sigsuspend ,%eax
|
|
||||||
LCALL(0x7,0)
|
|
||||||
jb err
|
|
||||||
xorl %eax,%eax # shouldn t happen
|
|
||||||
ret
|
|
@ -1,51 +0,0 @@
|
|||||||
/*-
|
|
||||||
* Copyright (c) 1990, 1993
|
|
||||||
* The Regents of the University of California. All rights reserved.
|
|
||||||
*
|
|
||||||
* This code is derived from software contributed to Berkeley by
|
|
||||||
* William Jolitz.
|
|
||||||
*
|
|
||||||
* 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(SYSLIBC_SCCS) && !defined(lint)
|
|
||||||
.asciz "@(#)syscall.s 8.1 (Berkeley) 6/4/93"
|
|
||||||
#endif /* SYSLIBC_SCCS and not lint */
|
|
||||||
|
|
||||||
#include "SYS.h"
|
|
||||||
|
|
||||||
ENTRY(syscall)
|
|
||||||
pop %ecx /* rta */
|
|
||||||
pop %eax /* syscall number */
|
|
||||||
push %ecx
|
|
||||||
LCALL(7,0)
|
|
||||||
jb 1f
|
|
||||||
ret
|
|
||||||
1:
|
|
||||||
jmp cerror
|
|
@ -1,62 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 1983, 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[] = "@(#)getnetbyname.c 8.1 (Berkeley) 6/4/93";
|
|
||||||
#endif /* LIBC_SCCS and not lint */
|
|
||||||
|
|
||||||
#include <netdb.h>
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
extern int _net_stayopen;
|
|
||||||
|
|
||||||
struct netent *
|
|
||||||
getnetbyname(name)
|
|
||||||
register const char *name;
|
|
||||||
{
|
|
||||||
register struct netent *p;
|
|
||||||
register char **cp;
|
|
||||||
|
|
||||||
setnetent(_net_stayopen);
|
|
||||||
while (p = getnetent()) {
|
|
||||||
if (strcmp(p->n_name, name) == 0)
|
|
||||||
break;
|
|
||||||
for (cp = p->n_aliases; *cp != 0; cp++)
|
|
||||||
if (strcmp(*cp, name) == 0)
|
|
||||||
goto found;
|
|
||||||
}
|
|
||||||
found:
|
|
||||||
if (!_net_stayopen)
|
|
||||||
endnetent();
|
|
||||||
return (p);
|
|
||||||
}
|
|
@ -1,121 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 1983, 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[] = "@(#)getnetent.c 8.1 (Berkeley) 6/4/93";
|
|
||||||
#endif /* LIBC_SCCS and not lint */
|
|
||||||
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <sys/socket.h>
|
|
||||||
#include <netinet/in.h>
|
|
||||||
#include <arpa/inet.h>
|
|
||||||
#include <netdb.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
#define MAXALIASES 35
|
|
||||||
|
|
||||||
static FILE *netf;
|
|
||||||
static char line[BUFSIZ+1];
|
|
||||||
static struct netent net;
|
|
||||||
static char *net_aliases[MAXALIASES];
|
|
||||||
int _net_stayopen;
|
|
||||||
|
|
||||||
void
|
|
||||||
setnetent(f)
|
|
||||||
int f;
|
|
||||||
{
|
|
||||||
if (netf == NULL)
|
|
||||||
netf = fopen(_PATH_NETWORKS, "r" );
|
|
||||||
else
|
|
||||||
rewind(netf);
|
|
||||||
_net_stayopen |= f;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
endnetent()
|
|
||||||
{
|
|
||||||
if (netf) {
|
|
||||||
fclose(netf);
|
|
||||||
netf = NULL;
|
|
||||||
}
|
|
||||||
_net_stayopen = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
struct netent *
|
|
||||||
getnetent()
|
|
||||||
{
|
|
||||||
char *p;
|
|
||||||
register char *cp, **q;
|
|
||||||
|
|
||||||
if (netf == NULL && (netf = fopen(_PATH_NETWORKS, "r" )) == NULL)
|
|
||||||
return (NULL);
|
|
||||||
again:
|
|
||||||
p = fgets(line, BUFSIZ, netf);
|
|
||||||
if (p == NULL)
|
|
||||||
return (NULL);
|
|
||||||
if (*p == '#')
|
|
||||||
goto again;
|
|
||||||
cp = strpbrk(p, "#\n");
|
|
||||||
if (cp == NULL)
|
|
||||||
goto again;
|
|
||||||
*cp = '\0';
|
|
||||||
net.n_name = p;
|
|
||||||
cp = strpbrk(p, " \t");
|
|
||||||
if (cp == NULL)
|
|
||||||
goto again;
|
|
||||||
*cp++ = '\0';
|
|
||||||
while (*cp == ' ' || *cp == '\t')
|
|
||||||
cp++;
|
|
||||||
p = strpbrk(cp, " \t");
|
|
||||||
if (p != NULL)
|
|
||||||
*p++ = '\0';
|
|
||||||
net.n_net = inet_network(cp);
|
|
||||||
net.n_addrtype = AF_INET;
|
|
||||||
q = net.n_aliases = net_aliases;
|
|
||||||
if (p != NULL)
|
|
||||||
cp = p;
|
|
||||||
while (cp && *cp) {
|
|
||||||
if (*cp == ' ' || *cp == '\t') {
|
|
||||||
cp++;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (q < &net_aliases[MAXALIASES - 1])
|
|
||||||
*q++ = cp;
|
|
||||||
cp = strpbrk(cp, " \t");
|
|
||||||
if (cp != NULL)
|
|
||||||
*cp++ = '\0';
|
|
||||||
}
|
|
||||||
*q = NULL;
|
|
||||||
return (&net);
|
|
||||||
}
|
|
@ -1,56 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 1985, 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[] = "@(#)sethostent.c 8.1 (Berkeley) 6/4/93";
|
|
||||||
#endif /* LIBC_SCCS and not lint */
|
|
||||||
|
|
||||||
#include <sys/param.h>
|
|
||||||
#include <netinet/in.h>
|
|
||||||
#include <arpa/nameser.h>
|
|
||||||
#include <netdb.h>
|
|
||||||
#include <resolv.h>
|
|
||||||
|
|
||||||
void
|
|
||||||
sethostent(stayopen)
|
|
||||||
{
|
|
||||||
if (stayopen)
|
|
||||||
_res.options |= RES_STAYOPEN | RES_USEVC;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
endhostent()
|
|
||||||
{
|
|
||||||
_res.options &= ~(RES_STAYOPEN | RES_USEVC);
|
|
||||||
_res_close();
|
|
||||||
}
|
|
@ -1,81 +0,0 @@
|
|||||||
.\" Copyright (c) 1991, 1993
|
|
||||||
.\" The Regents of the University of California. All rights reserved.
|
|
||||||
.\"
|
|
||||||
.\" This code is derived from software contributed to Berkeley by
|
|
||||||
.\" the American National Standards Committee X3, on Information
|
|
||||||
.\" Processing Systems.
|
|
||||||
.\"
|
|
||||||
.\" 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.
|
|
||||||
.\"
|
|
||||||
.\" @(#)free.3 8.1 (Berkeley) 6/4/93
|
|
||||||
.\"
|
|
||||||
.Dd June 4, 1993
|
|
||||||
.Dt FREE 3
|
|
||||||
.Os
|
|
||||||
.Sh NAME
|
|
||||||
.Nm free
|
|
||||||
.Nd free up memory allocated with malloc, calloc or realloc
|
|
||||||
.Sh SYNOPSIS
|
|
||||||
.Fd #include <stdlib.h>
|
|
||||||
.Ft void
|
|
||||||
.Fn free "void *ptr"
|
|
||||||
.Sh DESCRIPTION
|
|
||||||
The
|
|
||||||
.Fn free
|
|
||||||
function causes the space pointed to by
|
|
||||||
.Fa ptr
|
|
||||||
to be deallocated, that is, made available
|
|
||||||
for further allocation.
|
|
||||||
If
|
|
||||||
.Fa ptr
|
|
||||||
is a null pointer, no action occurs.
|
|
||||||
Otherwise, if the argument does not match a pointer earlier
|
|
||||||
returned by the
|
|
||||||
.Xr calloc ,
|
|
||||||
.Xr malloc ,
|
|
||||||
or
|
|
||||||
.Xr realloc
|
|
||||||
function, or if the space has been deallocated by a call to
|
|
||||||
.Fn free
|
|
||||||
or
|
|
||||||
.Xr realloc ,
|
|
||||||
general havoc may occur.
|
|
||||||
.Sh RETURN VALUES
|
|
||||||
The
|
|
||||||
.Fn free
|
|
||||||
function returns no value.
|
|
||||||
.Sh SEE ALSO
|
|
||||||
.Xr calloc 3 ,
|
|
||||||
.Xr malloc 3 ,
|
|
||||||
.Xr realloc 3
|
|
||||||
.Sh STANDARDS
|
|
||||||
The
|
|
||||||
.Fn free
|
|
||||||
function conforms to
|
|
||||||
.St -ansiC .
|
|
@ -1,99 +0,0 @@
|
|||||||
.\" Copyright (c) 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.
|
|
||||||
.\"
|
|
||||||
.\" @(#)realloc.3 8.2 (Berkeley) 4/19/94
|
|
||||||
.\"
|
|
||||||
.Dd April 19, 1994
|
|
||||||
.Dt REALLOC 3
|
|
||||||
.Os
|
|
||||||
.Sh NAME
|
|
||||||
.Nm realloc
|
|
||||||
.Nd reallocation of memory function
|
|
||||||
.Sh SYNOPSIS
|
|
||||||
.Fd #include <stdlib.h>
|
|
||||||
.Ft void *
|
|
||||||
.Fn realloc "void *ptr" "size_t size"
|
|
||||||
.Sh DESCRIPTION
|
|
||||||
The
|
|
||||||
.Fn realloc
|
|
||||||
function changes the size of the object pointed to by
|
|
||||||
.Fa ptr
|
|
||||||
to the size specified by
|
|
||||||
.Fa size .
|
|
||||||
The contents of the object are unchanged up to the lesser
|
|
||||||
of the new and old sizes.
|
|
||||||
If the new size is larger, the value of the newly allocated portion
|
|
||||||
of the object is indeterminate.
|
|
||||||
If
|
|
||||||
.Fa ptr
|
|
||||||
is a null pointer, the
|
|
||||||
.Fn realloc
|
|
||||||
function behaves like the
|
|
||||||
.Xr malloc 3
|
|
||||||
function for the specified size.
|
|
||||||
Otherwise, if
|
|
||||||
.Fa ptr
|
|
||||||
does not match a pointer earlier returned by the
|
|
||||||
.Xr calloc 3 ,
|
|
||||||
.Xr malloc 3 ,
|
|
||||||
or
|
|
||||||
.Fn realloc
|
|
||||||
function, or if the space has been deallocated
|
|
||||||
by a call to the
|
|
||||||
.Xr free
|
|
||||||
or
|
|
||||||
.Fn realloc
|
|
||||||
function, unpredictable and usually detrimental
|
|
||||||
behavior will occur.
|
|
||||||
If the space cannot be allocated, the object
|
|
||||||
pointed to by
|
|
||||||
.Fa ptr
|
|
||||||
is unchanged.
|
|
||||||
If
|
|
||||||
.Fa size
|
|
||||||
is zero and
|
|
||||||
.Fa ptr
|
|
||||||
is not a null pointer, the object it points to is freed.
|
|
||||||
.Pp
|
|
||||||
The
|
|
||||||
.Fn realloc
|
|
||||||
function returns either a null pointer or a pointer
|
|
||||||
to the possibly moved allocated space.
|
|
||||||
.Sh SEE ALSO
|
|
||||||
.Xr alloca 3 ,
|
|
||||||
.Xr calloc 3 ,
|
|
||||||
.Xr free 3 ,
|
|
||||||
.Xr malloc 3 ,
|
|
||||||
.Sh STANDARDS
|
|
||||||
The
|
|
||||||
.Fn realloc
|
|
||||||
function conforms to
|
|
||||||
.St -ansiC .
|
|
@ -1,186 +0,0 @@
|
|||||||
.\" Copyright (c) 1989, 1991, 1993
|
|
||||||
.\" The Regents of the University of California. All rights reserved.
|
|
||||||
.\"
|
|
||||||
.\" This code is derived from software contributed to Berkeley by
|
|
||||||
.\" the American National Standards Committee X3, on Information
|
|
||||||
.\" Processing Systems.
|
|
||||||
.\"
|
|
||||||
.\" 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.
|
|
||||||
.\"
|
|
||||||
.\" @(#)strftime.3 8.1 (Berkeley) 6/4/93
|
|
||||||
.\"
|
|
||||||
.Dd June 4, 1993
|
|
||||||
.Dt STRFTIME 3
|
|
||||||
.Os
|
|
||||||
.Sh NAME
|
|
||||||
.Nm strftime
|
|
||||||
.Nd format date and time
|
|
||||||
.Sh SYNOPSIS
|
|
||||||
.Fd #include <sys/types.h>
|
|
||||||
.Fd #include <time.h>
|
|
||||||
.Fd #include <string.h>
|
|
||||||
.Ft size_t
|
|
||||||
.Fn strftime "char *buf" "size_t maxsize" "const char *format" "const struct tm *timeptr"
|
|
||||||
.Sh DESCRIPTION
|
|
||||||
The
|
|
||||||
.Fn strftime
|
|
||||||
function formats the information from
|
|
||||||
.Fa timeptr
|
|
||||||
into the buffer
|
|
||||||
.Fa buf
|
|
||||||
according to the string pointed to by
|
|
||||||
.Fa format .
|
|
||||||
.Pp
|
|
||||||
The
|
|
||||||
.Fa format
|
|
||||||
string consists of zero or more conversion specifications and
|
|
||||||
ordinary characters.
|
|
||||||
All ordinary characters are copied directly into the buffer.
|
|
||||||
A conversion specification consists of a percent sign
|
|
||||||
.Dq Ql %
|
|
||||||
and one other character.
|
|
||||||
.Pp
|
|
||||||
No more than
|
|
||||||
.Fa maxsize
|
|
||||||
characters will be placed into the array.
|
|
||||||
If the total number of resulting characters, including the terminating
|
|
||||||
null character, is not more than
|
|
||||||
.Fa maxsize ,
|
|
||||||
.Fn strftime
|
|
||||||
returns the number of characters in the array, not counting the
|
|
||||||
terminating null.
|
|
||||||
Otherwise, zero is returned.
|
|
||||||
.Pp
|
|
||||||
Each conversion specification is replaced by the characters as
|
|
||||||
follows which are then copied into the buffer.
|
|
||||||
.Bl -tag -width "xxxx"
|
|
||||||
.It Cm \&%A
|
|
||||||
is replaced by the full weekday name.
|
|
||||||
.It Cm %a
|
|
||||||
is replaced by the abbreviated weekday name, where the abbreviation
|
|
||||||
is the first three characters.
|
|
||||||
.It Cm \&%B
|
|
||||||
is replaced by the full month name.
|
|
||||||
.It Cm %b or %h
|
|
||||||
is replaced by the abbreviated month name, where the abbreviation is
|
|
||||||
the first three characters.
|
|
||||||
.It Cm \&%C
|
|
||||||
is equivalent to
|
|
||||||
.Dq Li %a %b %e %H:%M:%S %Y
|
|
||||||
(the format produced by
|
|
||||||
.Xr asctime 3 .
|
|
||||||
.It Cm %c
|
|
||||||
is equivalent to
|
|
||||||
.Dq Li %m/%d/%y .
|
|
||||||
.It Cm \&%D
|
|
||||||
is replaced by the date in the format
|
|
||||||
.Dq Ql mm/dd/yy .
|
|
||||||
.It Cm %d
|
|
||||||
is replaced by the day of the month as a decimal number (01-31).
|
|
||||||
.It Cm %e
|
|
||||||
is replaced by the day of month as a decimal number (1-31); single
|
|
||||||
digits are preceded by a blank.
|
|
||||||
.It Cm \&%H
|
|
||||||
is replaced by the hour (24-hour clock) as a decimal number (00-23).
|
|
||||||
.It Cm \&%I
|
|
||||||
is replaced by the hour (12-hour clock) as a decimal number (01-12).
|
|
||||||
.It Cm %j
|
|
||||||
is replaced by the day of the year as a decimal number (001-366).
|
|
||||||
.It Cm %k
|
|
||||||
is replaced by the hour (24-hour clock) as a decimal number (0-23);
|
|
||||||
single digits are preceded by a blank.
|
|
||||||
.It Cm %l
|
|
||||||
is replaced by the hour (12-hour clock) as a decimal number (1-12);
|
|
||||||
single digits are preceded by a blank.
|
|
||||||
.It Cm \&%M
|
|
||||||
is replaced by the minute as a decimal number (00-59).
|
|
||||||
.It Cm %m
|
|
||||||
is replaced by the month as a decimal number (01-12).
|
|
||||||
.It Cm %n
|
|
||||||
is replaced by a newline.
|
|
||||||
.It Cm %p
|
|
||||||
is replaced by either
|
|
||||||
.Dq Tn AM
|
|
||||||
or
|
|
||||||
.Dq Tn PM
|
|
||||||
as appropriate.
|
|
||||||
.It Cm \&%R
|
|
||||||
is equivalent to
|
|
||||||
.Dq Li %H:%M
|
|
||||||
.It Cm %r
|
|
||||||
is equivalent to
|
|
||||||
.Dq Li %I:%M:%S %p .
|
|
||||||
.It Cm %t
|
|
||||||
is replaced by a tab.
|
|
||||||
.It Cm \&%S
|
|
||||||
is replaced by the second as a decimal number (00-60).
|
|
||||||
.It Cm %s
|
|
||||||
is replaced by the number of seconds since the Epoch, UCT (see
|
|
||||||
.Xr mktime 3 ) .
|
|
||||||
.It Cm \&%T No or Cm \&%X
|
|
||||||
is equivalent to
|
|
||||||
.Dq Li %H:%M:%S .
|
|
||||||
.It Cm \&%U
|
|
||||||
is replaced by the week number of the year (Sunday as the first day of
|
|
||||||
the week) as a decimal number (00-53).
|
|
||||||
.It Cm \&%W
|
|
||||||
is replaced by the week number of the year (Monday as the first day of
|
|
||||||
the week) as a decimal number (00-53).
|
|
||||||
.It Cm %w
|
|
||||||
is replaced by the weekday (Sunday as the first day of the week)
|
|
||||||
as a decimal number (0-6).
|
|
||||||
.It Cm %x
|
|
||||||
is equivalent to
|
|
||||||
.Dq Li %m/%d/%y %H:%M:%S .
|
|
||||||
.It Cm \&%Y
|
|
||||||
is replaced by the year with century as a decimal number.
|
|
||||||
.It Cm %y
|
|
||||||
is replaced by the year without century as a decimal number (00-99).
|
|
||||||
.It Cm \&%Z
|
|
||||||
is replaced by the time zone name.
|
|
||||||
.It Cm %%
|
|
||||||
is replaced by
|
|
||||||
.Ql % .
|
|
||||||
.El
|
|
||||||
.Sh SEE ALSO
|
|
||||||
.Xr date 1 ,
|
|
||||||
.Xr ctime 3 ,
|
|
||||||
.Xr printf 1 ,
|
|
||||||
.Xr printf 3
|
|
||||||
.Sh STANDARDS
|
|
||||||
The
|
|
||||||
.Fn strftime
|
|
||||||
function
|
|
||||||
conforms to
|
|
||||||
.St -ansiC .
|
|
||||||
The
|
|
||||||
.Ql %s
|
|
||||||
conversion specification is an extension.
|
|
||||||
.Sh BUGS
|
|
||||||
There is no conversion specification for the phase of the moon.
|
|
@ -1,292 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 1989, 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[] = "@(#)strftime.c 8.1 (Berkeley) 6/4/93";
|
|
||||||
#endif /* LIBC_SCCS and not lint */
|
|
||||||
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <sys/time.h>
|
|
||||||
#include <tzfile.h>
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
static char *afmt[] = {
|
|
||||||
"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat",
|
|
||||||
};
|
|
||||||
static char *Afmt[] = {
|
|
||||||
"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday",
|
|
||||||
"Saturday",
|
|
||||||
};
|
|
||||||
static char *bfmt[] = {
|
|
||||||
"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep",
|
|
||||||
"Oct", "Nov", "Dec",
|
|
||||||
};
|
|
||||||
static char *Bfmt[] = {
|
|
||||||
"January", "February", "March", "April", "May", "June", "July",
|
|
||||||
"August", "September", "October", "November", "December",
|
|
||||||
};
|
|
||||||
|
|
||||||
static size_t gsize;
|
|
||||||
static char *pt;
|
|
||||||
static int _add __P((char *));
|
|
||||||
static int _conv __P((int, int, int));
|
|
||||||
static int _secs __P((const struct tm *));
|
|
||||||
static size_t _fmt __P((const char *, const struct tm *));
|
|
||||||
|
|
||||||
size_t
|
|
||||||
strftime(s, maxsize, format, t)
|
|
||||||
char *s;
|
|
||||||
size_t maxsize;
|
|
||||||
const char *format;
|
|
||||||
const struct tm *t;
|
|
||||||
{
|
|
||||||
|
|
||||||
pt = s;
|
|
||||||
if ((gsize = maxsize) < 1)
|
|
||||||
return(0);
|
|
||||||
if (_fmt(format, t)) {
|
|
||||||
*pt = '\0';
|
|
||||||
return(maxsize - gsize);
|
|
||||||
}
|
|
||||||
return(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
static size_t
|
|
||||||
_fmt(format, t)
|
|
||||||
register const char *format;
|
|
||||||
const struct tm *t;
|
|
||||||
{
|
|
||||||
for (; *format; ++format) {
|
|
||||||
if (*format == '%')
|
|
||||||
switch(*++format) {
|
|
||||||
case '\0':
|
|
||||||
--format;
|
|
||||||
break;
|
|
||||||
case 'A':
|
|
||||||
if (t->tm_wday < 0 || t->tm_wday > 6)
|
|
||||||
return(0);
|
|
||||||
if (!_add(Afmt[t->tm_wday]))
|
|
||||||
return(0);
|
|
||||||
continue;
|
|
||||||
case 'a':
|
|
||||||
if (t->tm_wday < 0 || t->tm_wday > 6)
|
|
||||||
return(0);
|
|
||||||
if (!_add(afmt[t->tm_wday]))
|
|
||||||
return(0);
|
|
||||||
continue;
|
|
||||||
case 'B':
|
|
||||||
if (t->tm_mon < 0 || t->tm_mon > 11)
|
|
||||||
return(0);
|
|
||||||
if (!_add(Bfmt[t->tm_mon]))
|
|
||||||
return(0);
|
|
||||||
continue;
|
|
||||||
case 'b':
|
|
||||||
case 'h':
|
|
||||||
if (t->tm_mon < 0 || t->tm_mon > 11)
|
|
||||||
return(0);
|
|
||||||
if (!_add(bfmt[t->tm_mon]))
|
|
||||||
return(0);
|
|
||||||
continue;
|
|
||||||
case 'C':
|
|
||||||
if (!_fmt("%a %b %e %H:%M:%S %Y", t))
|
|
||||||
return(0);
|
|
||||||
continue;
|
|
||||||
case 'c':
|
|
||||||
if (!_fmt("%m/%d/%y %H:%M:%S", t))
|
|
||||||
return(0);
|
|
||||||
continue;
|
|
||||||
case 'D':
|
|
||||||
if (!_fmt("%m/%d/%y", t))
|
|
||||||
return(0);
|
|
||||||
continue;
|
|
||||||
case 'd':
|
|
||||||
if (!_conv(t->tm_mday, 2, '0'))
|
|
||||||
return(0);
|
|
||||||
continue;
|
|
||||||
case 'e':
|
|
||||||
if (!_conv(t->tm_mday, 2, ' '))
|
|
||||||
return(0);
|
|
||||||
continue;
|
|
||||||
case 'H':
|
|
||||||
if (!_conv(t->tm_hour, 2, '0'))
|
|
||||||
return(0);
|
|
||||||
continue;
|
|
||||||
case 'I':
|
|
||||||
if (!_conv(t->tm_hour % 12 ?
|
|
||||||
t->tm_hour % 12 : 12, 2, '0'))
|
|
||||||
return(0);
|
|
||||||
continue;
|
|
||||||
case 'j':
|
|
||||||
if (!_conv(t->tm_yday + 1, 3, '0'))
|
|
||||||
return(0);
|
|
||||||
continue;
|
|
||||||
case 'k':
|
|
||||||
if (!_conv(t->tm_hour, 2, ' '))
|
|
||||||
return(0);
|
|
||||||
continue;
|
|
||||||
case 'l':
|
|
||||||
if (!_conv(t->tm_hour % 12 ?
|
|
||||||
t->tm_hour % 12 : 12, 2, ' '))
|
|
||||||
return(0);
|
|
||||||
continue;
|
|
||||||
case 'M':
|
|
||||||
if (!_conv(t->tm_min, 2, '0'))
|
|
||||||
return(0);
|
|
||||||
continue;
|
|
||||||
case 'm':
|
|
||||||
if (!_conv(t->tm_mon + 1, 2, '0'))
|
|
||||||
return(0);
|
|
||||||
continue;
|
|
||||||
case 'n':
|
|
||||||
if (!_add("\n"))
|
|
||||||
return(0);
|
|
||||||
continue;
|
|
||||||
case 'p':
|
|
||||||
if (!_add(t->tm_hour >= 12 ? "PM" : "AM"))
|
|
||||||
return(0);
|
|
||||||
continue;
|
|
||||||
case 'R':
|
|
||||||
if (!_fmt("%H:%M", t))
|
|
||||||
return(0);
|
|
||||||
continue;
|
|
||||||
case 'r':
|
|
||||||
if (!_fmt("%I:%M:%S %p", t))
|
|
||||||
return(0);
|
|
||||||
continue;
|
|
||||||
case 'S':
|
|
||||||
if (!_conv(t->tm_sec, 2, '0'))
|
|
||||||
return(0);
|
|
||||||
continue;
|
|
||||||
case 's':
|
|
||||||
if (!_secs(t))
|
|
||||||
return(0);
|
|
||||||
continue;
|
|
||||||
case 'T':
|
|
||||||
case 'X':
|
|
||||||
if (!_fmt("%H:%M:%S", t))
|
|
||||||
return(0);
|
|
||||||
continue;
|
|
||||||
case 't':
|
|
||||||
if (!_add("\t"))
|
|
||||||
return(0);
|
|
||||||
continue;
|
|
||||||
case 'U':
|
|
||||||
if (!_conv((t->tm_yday + 7 - t->tm_wday) / 7,
|
|
||||||
2, '0'))
|
|
||||||
return(0);
|
|
||||||
continue;
|
|
||||||
case 'W':
|
|
||||||
if (!_conv((t->tm_yday + 7 -
|
|
||||||
(t->tm_wday ? (t->tm_wday - 1) : 6))
|
|
||||||
/ 7, 2, '0'))
|
|
||||||
return(0);
|
|
||||||
continue;
|
|
||||||
case 'w':
|
|
||||||
if (!_conv(t->tm_wday, 1, '0'))
|
|
||||||
return(0);
|
|
||||||
continue;
|
|
||||||
case 'x':
|
|
||||||
if (!_fmt("%m/%d/%y", t))
|
|
||||||
return(0);
|
|
||||||
continue;
|
|
||||||
case 'y':
|
|
||||||
if (!_conv((t->tm_year + TM_YEAR_BASE)
|
|
||||||
% 100, 2, '0'))
|
|
||||||
return(0);
|
|
||||||
continue;
|
|
||||||
case 'Y':
|
|
||||||
if (!_conv(t->tm_year + TM_YEAR_BASE, 4, '0'))
|
|
||||||
return(0);
|
|
||||||
continue;
|
|
||||||
case 'Z':
|
|
||||||
if (!t->tm_zone || !_add(t->tm_zone))
|
|
||||||
return(0);
|
|
||||||
continue;
|
|
||||||
case '%':
|
|
||||||
/*
|
|
||||||
* X311J/88-090 (4.12.3.5): if conversion char is
|
|
||||||
* undefined, behavior is undefined. Print out the
|
|
||||||
* character itself as printf(3) does.
|
|
||||||
*/
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (!gsize--)
|
|
||||||
return(0);
|
|
||||||
*pt++ = *format;
|
|
||||||
}
|
|
||||||
return(gsize);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
|
||||||
_secs(t)
|
|
||||||
const struct tm *t;
|
|
||||||
{
|
|
||||||
static char buf[15];
|
|
||||||
register time_t s;
|
|
||||||
register char *p;
|
|
||||||
struct tm tmp;
|
|
||||||
|
|
||||||
/* Make a copy, mktime(3) modifies the tm struct. */
|
|
||||||
tmp = *t;
|
|
||||||
s = mktime(&tmp);
|
|
||||||
for (p = buf + sizeof(buf) - 2; s > 0 && p > buf; s /= 10)
|
|
||||||
*p-- = s % 10 + '0';
|
|
||||||
return(_add(++p));
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
|
||||||
_conv(n, digits, pad)
|
|
||||||
int n, digits, pad;
|
|
||||||
{
|
|
||||||
static char buf[10];
|
|
||||||
register char *p;
|
|
||||||
|
|
||||||
for (p = buf + sizeof(buf) - 2; n > 0 && p > buf; n /= 10, --digits)
|
|
||||||
*p-- = n % 10 + '0';
|
|
||||||
while (p > buf && digits-- > 0)
|
|
||||||
*p-- = pad;
|
|
||||||
return(_add(++p));
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
|
||||||
_add(str)
|
|
||||||
register char *str;
|
|
||||||
{
|
|
||||||
for (;; ++pt, --gsize) {
|
|
||||||
if (!gsize)
|
|
||||||
return(0);
|
|
||||||
if (!(*pt = *str++))
|
|
||||||
return(1);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,21 +0,0 @@
|
|||||||
/*
|
|
||||||
* Definitions etc. for regexp(3) routines.
|
|
||||||
*
|
|
||||||
* Caveat: this is V8 regexp(3) [actually, a reimplementation thereof],
|
|
||||||
* not the System V one.
|
|
||||||
*/
|
|
||||||
#define NSUBEXP 10
|
|
||||||
typedef struct regexp {
|
|
||||||
char *startp[NSUBEXP];
|
|
||||||
char *endp[NSUBEXP];
|
|
||||||
char regstart; /* Internal use only. */
|
|
||||||
char reganch; /* Internal use only. */
|
|
||||||
char *regmust; /* Internal use only. */
|
|
||||||
int regmlen; /* Internal use only. */
|
|
||||||
char program[1]; /* Unwarranted chumminess with compiler. */
|
|
||||||
} regexp;
|
|
||||||
|
|
||||||
extern regexp *regcomp();
|
|
||||||
extern int regexec();
|
|
||||||
extern void regsub();
|
|
||||||
extern void regerror();
|
|
@ -1,28 +0,0 @@
|
|||||||
/*
|
|
||||||
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for
|
|
||||||
* unrestricted use provided that this legend is included on all tape
|
|
||||||
* media and as a part of the software program in whole or part. Users
|
|
||||||
* may copy or modify Sun RPC without charge, but are not authorized
|
|
||||||
* to license or distribute it to anyone else except as part of a product or
|
|
||||||
* program developed by the user.
|
|
||||||
*
|
|
||||||
* SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
|
|
||||||
* WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
|
|
||||||
* PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
|
|
||||||
*
|
|
||||||
* Sun RPC is provided with no support and without any obligation on the
|
|
||||||
* part of Sun Microsystems, Inc. to assist in its use, correction,
|
|
||||||
* modification or enhancement.
|
|
||||||
*
|
|
||||||
* SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
|
|
||||||
* INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
|
|
||||||
* OR ANY PART THEREOF.
|
|
||||||
*
|
|
||||||
* In no event will Sun Microsystems, Inc. be liable for any lost revenue
|
|
||||||
* or profits or other special, indirect and consequential damages, even if
|
|
||||||
* Sun has been advised of the possibility of such damages.
|
|
||||||
*
|
|
||||||
* Sun Microsystems, Inc.
|
|
||||||
* 2550 Garcia Avenue
|
|
||||||
* Mountain View, California 94043
|
|
||||||
*/
|
|
@ -1,30 +0,0 @@
|
|||||||
#
|
|
||||||
# @(#)Makefile 2.1 88/08/11 4.0 RPCSRC
|
|
||||||
#
|
|
||||||
# Build and install everything.
|
|
||||||
#
|
|
||||||
# These directories are presumed to exist in DESTDIR:
|
|
||||||
# /usr/lib /usr/bin /usr/include
|
|
||||||
#
|
|
||||||
DESTDIR=
|
|
||||||
CFLAGS=-O
|
|
||||||
MAKE=make
|
|
||||||
|
|
||||||
# These are not used by BSD except portmap which lives in
|
|
||||||
# /usr/src/usr.sbin/portmap.
|
|
||||||
# SUBDIR= rpcgen etc rpcsvc
|
|
||||||
|
|
||||||
all install: rpclib ${SUBDIR}
|
|
||||||
|
|
||||||
rpclib: FRC
|
|
||||||
@echo "Building and installing RPC library"
|
|
||||||
cd rpc; $(MAKE) ${MFLAGS} all DESTDIR=${DESTDIR}; \
|
|
||||||
$(MAKE) ${MFLAGS} install DESTDIR=${DESTDIR}
|
|
||||||
|
|
||||||
${SUBDIR}: FRC
|
|
||||||
@echo "Building and installing files from: $@"
|
|
||||||
cd $@; $(MAKE) ${MFLAGS} DESTDIR=${DESTDIR} CFLAGS=${CFLAGS};\
|
|
||||||
$(MAKE) ${MFLAGS} install DESTDIR=${DESTDIR}
|
|
||||||
|
|
||||||
FRC:
|
|
||||||
|
|
@ -1,233 +0,0 @@
|
|||||||
RPCSRC 4.0 7/11/89
|
|
||||||
|
|
||||||
This distribution contains Sun Microsystem's implementation of the
|
|
||||||
RPC and XDR protocols and is compatible with 4.2BSD and 4.3BSD. Also
|
|
||||||
included is complete documentation, utilities, RPC service
|
|
||||||
specification files, and demonstration services in the format used by
|
|
||||||
the RPC protocol compiler (rpcgen). See WHAT'S NEW below for
|
|
||||||
details.
|
|
||||||
|
|
||||||
NOTE ABOUT SECURE RPC:
|
|
||||||
|
|
||||||
This release of RPCSRC contains most of the code needed to implement
|
|
||||||
Secure RPC (see "DES Authentication" in the RPC Protocol Specification,
|
|
||||||
doc/rpc.rfc.ms). Due to legal considerations, we are unable to
|
|
||||||
distribute an implementation of DES, the Data Encryption Standard, which
|
|
||||||
Secure RPC requires. For this reason, all of the files, documentation, and
|
|
||||||
programs associated with Secure RPC have been placed into a separate
|
|
||||||
directory, secure_rpc. The RPC library contained in the main body of this
|
|
||||||
release *DOES NOT* support Secure RPC. See secure_rpc/README for more
|
|
||||||
details. (A DES library was posted in Volume 18 of comp.sources.unix.)
|
|
||||||
|
|
||||||
If you wish to report bugs found in this release, send mail to:
|
|
||||||
|
|
||||||
Portable ONC/NFS
|
|
||||||
Sun Microsystems, Inc
|
|
||||||
MS 12-33
|
|
||||||
2550 Garcia Avenue
|
|
||||||
Mountain View, CA 94043
|
|
||||||
|
|
||||||
or send Email to nfsnet@sun.com (the Internet) or sun!nfsnet (Usenet).
|
|
||||||
|
|
||||||
ROADMAP
|
|
||||||
|
|
||||||
The directory hierarchy is as follows:
|
|
||||||
|
|
||||||
demo/ Various demonstration services
|
|
||||||
demo/dir Remote directory lister
|
|
||||||
demo/msg Remote console message delivery service
|
|
||||||
demo/sort Remote sort service
|
|
||||||
|
|
||||||
doc/ Documentation for RPC, XDR and NFS in "-ms" format.
|
|
||||||
|
|
||||||
etc/ Utilities (rpcinfo and portmap). portmap must be
|
|
||||||
started by root before any other RPC network services are
|
|
||||||
used. SEE BELOW FOR BUGFIX TO 4.3BSD COMPILER.
|
|
||||||
|
|
||||||
man/ Manual pages for RPC library, rpcgen, and utilities.
|
|
||||||
|
|
||||||
rpc/ The RPC and XDR library. SEE BELOW
|
|
||||||
FOR BUGFIX TO 4.2BSD COMPILER.
|
|
||||||
|
|
||||||
rpcgen/ The RPC Language compiler (for .x files)
|
|
||||||
|
|
||||||
rpcsvc/ Service definition files for various services and the
|
|
||||||
server and client code for the Remote Status service.
|
|
||||||
|
|
||||||
secure_rpc/ The files in this directory are used to build a version of
|
|
||||||
the RPC library with DES Authentication. See the README
|
|
||||||
file in that directory for more details.
|
|
||||||
|
|
||||||
BUILD INSTRUCTIONS
|
|
||||||
|
|
||||||
Makefiles can be found in all directories except for man. The
|
|
||||||
Makefile in the top directory will cause these others to be invoked
|
|
||||||
(except for in the doc, man and demo directories), in turn building the
|
|
||||||
entire release.
|
|
||||||
|
|
||||||
WARNING! THE DEFAULT INSTALLATION PROCEDURES WILL INSTALL FILES
|
|
||||||
IN /usr/include, /usr/lib, /usr/bin and /etc.
|
|
||||||
|
|
||||||
The master RPC include file, rpc/rpc.h, is used by all programs and
|
|
||||||
routines that use RPC. It includes other RPC and system include files
|
|
||||||
needed by the RPC system. PLEASE NOTE: If your system has NFS, it
|
|
||||||
may have been based on Sun's NFS Source. The include files installed
|
|
||||||
by this package may duplicate include files you will find on your NFS
|
|
||||||
system. The RPCSRC 4.0 include files are upwardly compatible to all
|
|
||||||
NFS Source include files as of the date of this distribution (not
|
|
||||||
including any new definitions or declarations added by your system
|
|
||||||
vendor). HOWEVER: Please read the comments towards the end of
|
|
||||||
rpc/rpc.h regarding rpc/netdb.h. You may need to uncomment the
|
|
||||||
inclusion of that file if the structures it defines are already
|
|
||||||
defined by your system's include files.
|
|
||||||
|
|
||||||
After making any compiler fixes that are needed (see below), at
|
|
||||||
the top directory, type:
|
|
||||||
|
|
||||||
make install
|
|
||||||
|
|
||||||
For all installations, the Makefile macro DESTDIR is prepended to the
|
|
||||||
installation path. It is defined to be null in the Makefiles, so
|
|
||||||
installations are relative to root. (You will probably need root
|
|
||||||
privileges for installing the files under the default path.) To
|
|
||||||
install the files under some other tree (e.g., /usr/local), use the
|
|
||||||
command:
|
|
||||||
|
|
||||||
make install DESTDIR=/usr/local
|
|
||||||
|
|
||||||
This will place the include files in /usr/local/usr/include, the RPC
|
|
||||||
library in /usr/local/usr/lib, rpcgen in /usr/local/usr/bin, and the
|
|
||||||
utilities in /usr/local/etc. You'll have to edit the Makefiles or
|
|
||||||
install the files by hand if you want to do anything other than this
|
|
||||||
kind of relocation of the installation tree.
|
|
||||||
|
|
||||||
The RPC library will be built and installed first. By default it is
|
|
||||||
installed in /usr/lib as "librpclib.a". The directory
|
|
||||||
/usr/include/rpc will also be created, and several header files will
|
|
||||||
be installed there. ALL RPC SERVICES INCLUDE THESE HEADER FILES.
|
|
||||||
|
|
||||||
The programs in etc/ link in routines from librpclib.a. If you change
|
|
||||||
where it is installed, be sure to edit etc/'s Makefile to reflect this.
|
|
||||||
These programs are installed in /etc. PORTMAP MUST BE RUNNING ON
|
|
||||||
YOUR SYSTEM BEFORE YOU START ANY OTHER RPC SERVICE.
|
|
||||||
|
|
||||||
rpcgen is installed in /usr/bin. This program is required to build
|
|
||||||
the demonstration services in demo and the rstat client and server in
|
|
||||||
rpcsvc/.
|
|
||||||
|
|
||||||
The rpcsvc/ directory will install its files in the directory
|
|
||||||
/usr/include/rpcsvc. The Remote Status service (rstat_svc) will be
|
|
||||||
compiled and installed in /etc. If you wish to make this service
|
|
||||||
available, you should either start this service when needed or have
|
|
||||||
it started at boot time by invoking it in your /etc/rc.local script.
|
|
||||||
(Be sure that portmap is started first!) Sun has modified its
|
|
||||||
version of inetd to automatically start RPC services. (Use "make
|
|
||||||
LIB=" when building rstat on a Sun Workstation.) The Remote Status
|
|
||||||
client (rstat) will be installed in /usr/bin. This program queries
|
|
||||||
the rstat_svc on a remote host and prints a system status summary
|
|
||||||
similar to the one printed by "uptime".
|
|
||||||
|
|
||||||
The documentation is not built during the "make install" command.
|
|
||||||
Typing "make" in the doc directory will cause all of the manuals to
|
|
||||||
be formatted using nroff into a single file. We have had a report
|
|
||||||
that certain "troff" equivalents have trouble processing the full
|
|
||||||
manual. If you have trouble, try building the manuals individually
|
|
||||||
(see the Makefile).
|
|
||||||
|
|
||||||
The demonstration services in the demo directory are not built by the
|
|
||||||
top-level "make install" command. To build these, cd to the demo
|
|
||||||
directory and enter "make". The three services will be built.
|
|
||||||
RPCGEN MUST BE INSTALLED in a path that make can find. To run the
|
|
||||||
services, start the portmap program as root and invoke the service
|
|
||||||
(you probably will want to put it in the background). rpcinfo can be
|
|
||||||
used to check that the service succeeded in getting registered with
|
|
||||||
portmap, and to ping the service (see rpcinfo's man page). You can
|
|
||||||
then use the corresponding client program to exercise the service.
|
|
||||||
To build these services on a Sun workstation, you must prevent the
|
|
||||||
Makefile from trying to link the RPC library (as these routines are
|
|
||||||
already a part of Sun's libc). Use: "make LIB=".
|
|
||||||
|
|
||||||
BUGFIX FOR 4.3BSD COMPILER
|
|
||||||
|
|
||||||
The use of a 'void *' declaration for one of the arguments in
|
|
||||||
the reply_proc() procedure in etc/rpcinfo.c will trigger a bug
|
|
||||||
in the 4.3BSD compiler. The bug is fixed by the following change to
|
|
||||||
the compiler file mip/manifest.h:
|
|
||||||
|
|
||||||
*** manifest.h.r1.1 Thu Apr 30 13:52:25 1987
|
|
||||||
--- manifest.h.r1.2 Mon Nov 23 18:58:17 1987
|
|
||||||
***************
|
|
||||||
*** 21,27 ****
|
|
||||||
/*
|
|
||||||
* Bogus type values
|
|
||||||
*/
|
|
||||||
! #define TNULL PTR /* pointer to UNDEF */
|
|
||||||
#define TVOID FTN /* function returning UNDEF (for void) */
|
|
||||||
|
|
||||||
/*
|
|
||||||
--- 21,27 ----
|
|
||||||
/*
|
|
||||||
* Bogus type values
|
|
||||||
*/
|
|
||||||
! #define TNULL INCREF(MOETY) /* pointer to MOETY -- impossible type */
|
|
||||||
#define TVOID FTN /* function returning UNDEF (for void) */
|
|
||||||
|
|
||||||
/*
|
|
||||||
|
|
||||||
If you cannot fix your compiler, change the declaration in reply_proc()
|
|
||||||
from 'void *' to 'char *'.
|
|
||||||
|
|
||||||
BUGFIX FOR 4.2BSD COMPILER
|
|
||||||
|
|
||||||
Unpatched 4.2BSD compilers complain about valid C. You can make old
|
|
||||||
compilers happy by changing some voids to ints. However, the fix to
|
|
||||||
the 4.2 VAX compiler is as follows (to mip/trees.c):
|
|
||||||
|
|
||||||
*** trees.c.r1.1 Mon May 11 13:47:58 1987
|
|
||||||
--- trees.c.r1.2 Wed Jul 2 18:28:52 1986
|
|
||||||
***************
|
|
||||||
*** 1247,1253 ****
|
|
||||||
if(o==CAST && mt1==0)return(TYPL+TYMATCH);
|
|
||||||
if( mt12 & MDBI ) return( TYPL+LVAL+TYMATCH );
|
|
||||||
else if( (mt1&MENU)||(mt2&MENU) ) return( LVAL+NCVT+TYPL+PTMATCH+PUN );
|
|
||||||
! else if( mt12 == 0 ) break;
|
|
||||||
else if( mt1 & MPTR ) return( LVAL+PTMATCH+PUN );
|
|
||||||
else if( mt12 & MPTI ) return( TYPL+LVAL+TYMATCH+PUN );
|
|
||||||
break;
|
|
||||||
--- 1261,1269 ----
|
|
||||||
if(o==CAST && mt1==0)return(TYPL+TYMATCH);
|
|
||||||
if( mt12 & MDBI ) return( TYPL+LVAL+TYMATCH );
|
|
||||||
else if( (mt1&MENU)||(mt2&MENU) ) return( LVAL+NCVT+TYPL+PTMATCH+PUN );
|
|
||||||
! /* if right is TVOID and looks like a CALL, is not ok */
|
|
||||||
! else if (mt2 == 0 && (p->in.right->in.op == CALL || p->in.right->in.op == UNARY CALL))
|
|
||||||
! break;
|
|
||||||
else if( mt1 & MPTR ) return( LVAL+PTMATCH+PUN );
|
|
||||||
else if( mt12 & MPTI ) return( TYPL+LVAL+TYMATCH+PUN );
|
|
||||||
break;
|
|
||||||
|
|
||||||
WHAT'S NEW IN THIS RELEASE: RPCSRC 4.0
|
|
||||||
|
|
||||||
The previous release was RPCSRC 3.9. As with all previous releases,
|
|
||||||
this release is based directly on files from Sun Microsystem's
|
|
||||||
implementation.
|
|
||||||
|
|
||||||
Upgrade from RPCSRC 3.9
|
|
||||||
|
|
||||||
1) RPCSRC 4.0 upgrades RPCSRC 3.9. Improvements from SunOS 4.0 have
|
|
||||||
been integrated into this release.
|
|
||||||
|
|
||||||
Secure RPC (in the secure_rpc/ directory)
|
|
||||||
|
|
||||||
2) DES Authentication routines and programs are provided.
|
|
||||||
3) A new manual, "Secure NFS" is provided, which describes Secure RPC
|
|
||||||
and Secure NFS.
|
|
||||||
4) Skeleton routines and manual pages are provided which describe the
|
|
||||||
DES encryption procedures required by Secure RPC. HOWEVER, NO DES
|
|
||||||
ROUTINE IS PROVIDED.
|
|
||||||
|
|
||||||
New Functionality
|
|
||||||
|
|
||||||
5) rpcinfo can now be used to de-register services from the portmapper
|
|
||||||
which may have terminated abnormally.
|
|
||||||
6) A new client, rstat, is provided which queries the rstat_svc and
|
|
||||||
prints a status line similar to the one displayed by "uptime".
|
|
@ -1,25 +0,0 @@
|
|||||||
#
|
|
||||||
# @(#)Makefile 2.1 88/08/02 4.0 RPCSRC
|
|
||||||
#
|
|
||||||
#
|
|
||||||
# Build all demo services
|
|
||||||
#
|
|
||||||
MAKE = make
|
|
||||||
LIB=-lrpclib
|
|
||||||
|
|
||||||
SUBDIR= dir msg sort
|
|
||||||
|
|
||||||
all: ${SUBDIR}
|
|
||||||
|
|
||||||
clean cleanup:
|
|
||||||
cd dir; $(MAKE) ${MFLAGS} cleanup
|
|
||||||
cd msg; $(MAKE) ${MFLAGS} cleanup
|
|
||||||
cd sort; $(MAKE) ${MFLAGS} cleanup
|
|
||||||
|
|
||||||
install:
|
|
||||||
@echo "No installations done."
|
|
||||||
|
|
||||||
${SUBDIR}: FRC
|
|
||||||
cd $@; $(MAKE) ${MFLAGS} LIB=$(LIB)
|
|
||||||
|
|
||||||
FRC:
|
|
@ -1,26 +0,0 @@
|
|||||||
#
|
|
||||||
# @(#)Makefile 2.1 88/08/02 4.0 RPCSRC
|
|
||||||
#
|
|
||||||
BIN = dir_svc rls
|
|
||||||
GEN = dir_clnt.c dir_svc.c dir_xdr.c dir.h
|
|
||||||
LIB = -lrpclib
|
|
||||||
RPCCOM = rpcgen
|
|
||||||
|
|
||||||
all: $(BIN)
|
|
||||||
|
|
||||||
$(GEN): dir.x
|
|
||||||
$(RPCCOM) dir.x
|
|
||||||
|
|
||||||
dir_svc: dir_proc.o dir_svc.o dir_xdr.o
|
|
||||||
$(CC) -o $@ dir_proc.o dir_svc.o dir_xdr.o $(LIB)
|
|
||||||
|
|
||||||
rls: rls.o dir_clnt.o dir_xdr.o
|
|
||||||
$(CC) -o $@ rls.o dir_clnt.o dir_xdr.o $(LIB)
|
|
||||||
|
|
||||||
rls.o: rls.c dir.h
|
|
||||||
|
|
||||||
dir_proc.o: dir_proc.c dir.h
|
|
||||||
|
|
||||||
clean cleanup:
|
|
||||||
rm -f $(GEN) *.o $(BIN)
|
|
||||||
|
|
@ -1,37 +0,0 @@
|
|||||||
/* @(#)dir.x 2.1 88/08/02 4.0 RPCSRC */
|
|
||||||
/*
|
|
||||||
* dir.x: Remote directory listing protocol
|
|
||||||
*/
|
|
||||||
const MAXNAMELEN = 255; /* maximum length of a directory entry */
|
|
||||||
|
|
||||||
typedef string nametype<MAXNAMELEN>; /* a directory entry */
|
|
||||||
|
|
||||||
typedef struct namenode *namelist; /* a link in the listing */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* A node in the directory listing
|
|
||||||
*/
|
|
||||||
struct namenode {
|
|
||||||
nametype name; /* name of directory entry */
|
|
||||||
namelist next; /* next entry */
|
|
||||||
};
|
|
||||||
|
|
||||||
/*
|
|
||||||
* The result of a READDIR operation.
|
|
||||||
*/
|
|
||||||
union readdir_res switch (int errno) {
|
|
||||||
case 0:
|
|
||||||
namelist list; /* no error: return directory listing */
|
|
||||||
default:
|
|
||||||
void; /* error occurred: nothing else to return */
|
|
||||||
};
|
|
||||||
|
|
||||||
/*
|
|
||||||
* The directory program definition
|
|
||||||
*/
|
|
||||||
program DIRPROG {
|
|
||||||
version DIRVERS {
|
|
||||||
readdir_res
|
|
||||||
READDIR(nametype) = 1;
|
|
||||||
} = 1;
|
|
||||||
} = 76;
|
|
@ -1,55 +0,0 @@
|
|||||||
/* @(#)dir_proc.c 2.1 88/08/02 4.0 RPCSRC */
|
|
||||||
/*
|
|
||||||
* dir_proc.c: remote readdir implementation
|
|
||||||
*/
|
|
||||||
#include <rpc/rpc.h>
|
|
||||||
#include <sys/dir.h>
|
|
||||||
#include "dir.h"
|
|
||||||
|
|
||||||
extern int errno;
|
|
||||||
extern char *malloc();
|
|
||||||
extern char *strcpy();
|
|
||||||
|
|
||||||
readdir_res *
|
|
||||||
readdir_1(dirname)
|
|
||||||
nametype *dirname;
|
|
||||||
{
|
|
||||||
DIR *dirp;
|
|
||||||
struct direct *d;
|
|
||||||
namelist nl;
|
|
||||||
namelist *nlp;
|
|
||||||
static readdir_res res; /* must be static! */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Open directory
|
|
||||||
*/
|
|
||||||
dirp = opendir(*dirname);
|
|
||||||
if (dirp == NULL) {
|
|
||||||
res.errno = errno;
|
|
||||||
return (&res);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Free previous result
|
|
||||||
*/
|
|
||||||
xdr_free(xdr_readdir_res, &res);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Collect directory entries
|
|
||||||
*/
|
|
||||||
nlp = &res.readdir_res_u.list;
|
|
||||||
while (d = readdir(dirp)) {
|
|
||||||
nl = *nlp = (namenode *) malloc(sizeof(namenode));
|
|
||||||
nl->name = malloc(strlen(d->d_name)+1);
|
|
||||||
strcpy(nl->name, d->d_name);
|
|
||||||
nlp = &nl->next;
|
|
||||||
}
|
|
||||||
*nlp = NULL;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Return the result
|
|
||||||
*/
|
|
||||||
res.errno = 0;
|
|
||||||
closedir(dirp);
|
|
||||||
return (&res);
|
|
||||||
}
|
|
@ -1,81 +0,0 @@
|
|||||||
/* @(#)rls.c 2.2 88/08/12 4.0 RPCSRC */
|
|
||||||
/*
|
|
||||||
* rls.c: Remote directory listing client
|
|
||||||
*/
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <rpc/rpc.h> /* always need this */
|
|
||||||
#include "dir.h" /* need this too: will be generated by rpcgen*/
|
|
||||||
|
|
||||||
extern int errno;
|
|
||||||
|
|
||||||
main(argc, argv)
|
|
||||||
int argc;
|
|
||||||
char *argv[];
|
|
||||||
{
|
|
||||||
CLIENT *cl;
|
|
||||||
char *server;
|
|
||||||
char *dir;
|
|
||||||
readdir_res *result;
|
|
||||||
namelist nl;
|
|
||||||
|
|
||||||
|
|
||||||
if (argc != 3) {
|
|
||||||
fprintf(stderr, "usage: %s host directory\n", argv[0]);
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Remember what our command line arguments refer to
|
|
||||||
*/
|
|
||||||
server = argv[1];
|
|
||||||
dir = argv[2];
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Create client "handle" used for calling DIRPROG on the
|
|
||||||
* server designated on the command line. We tell the rpc package
|
|
||||||
* to use the "tcp" protocol when contacting the server.
|
|
||||||
*/
|
|
||||||
cl = clnt_create(server, DIRPROG, DIRVERS, "tcp");
|
|
||||||
if (cl == NULL) {
|
|
||||||
/*
|
|
||||||
* Couldn't establish connection with server.
|
|
||||||
* Print error message and die.
|
|
||||||
*/
|
|
||||||
clnt_pcreateerror(server);
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Call the remote procedure "readdir" on the server
|
|
||||||
*/
|
|
||||||
result = readdir_1(&dir, cl);
|
|
||||||
if (result == NULL) {
|
|
||||||
/*
|
|
||||||
* An error occurred while calling the server.
|
|
||||||
* Print error message and die.
|
|
||||||
*/
|
|
||||||
clnt_perror(cl, server);
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Okay, we successfully called the remote procedure.
|
|
||||||
*/
|
|
||||||
if (result->errno != 0) {
|
|
||||||
/*
|
|
||||||
* A remote system error occurred.
|
|
||||||
* Print error message and die.
|
|
||||||
*/
|
|
||||||
errno = result->errno;
|
|
||||||
perror(dir);
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Successfuly got a directory listing.
|
|
||||||
* Print it out.
|
|
||||||
*/
|
|
||||||
for (nl = result->readdir_res_u.list; nl != NULL; nl = nl->next) {
|
|
||||||
printf("%s\n", nl->name);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,36 +0,0 @@
|
|||||||
#
|
|
||||||
# @(#)Makefile 2.1 88/08/11 4.0 RPCSRC
|
|
||||||
#
|
|
||||||
BIN = printmsg msg_svc rprintmsg
|
|
||||||
GEN = msg_clnt.c msg_svc.c msg.h
|
|
||||||
LIB = -lrpclib
|
|
||||||
RPCCOM = rpcgen
|
|
||||||
|
|
||||||
all: $(BIN)
|
|
||||||
|
|
||||||
#
|
|
||||||
# This is the non-networked version of the program
|
|
||||||
#
|
|
||||||
printmsg: printmsg.o
|
|
||||||
$(CC) -o $@ printmsg.o
|
|
||||||
|
|
||||||
#
|
|
||||||
# note: no xdr routines are generated here, due this service's
|
|
||||||
# use of basic data types.
|
|
||||||
#
|
|
||||||
$(GEN): msg.x
|
|
||||||
$(RPCCOM) msg.x
|
|
||||||
|
|
||||||
msg_svc: msg_proc.o msg_svc.o
|
|
||||||
$(CC) -o $@ msg_proc.o msg_svc.o $(LIB)
|
|
||||||
|
|
||||||
rprintmsg: rprintmsg.o msg_clnt.o
|
|
||||||
$(CC) -o $@ rprintmsg.o msg_clnt.o $(LIB)
|
|
||||||
|
|
||||||
rprintmsg.o: rprintmsg.c msg.h
|
|
||||||
|
|
||||||
msg_proc.o: msg_proc.c msg.h
|
|
||||||
|
|
||||||
clean cleanup:
|
|
||||||
rm -f $(GEN) *.o $(BIN)
|
|
||||||
|
|
@ -1,9 +0,0 @@
|
|||||||
/* @(#)msg.x 2.1 88/08/11 4.0 RPCSRC */
|
|
||||||
/*
|
|
||||||
* msg.x: Remote message printing protocol
|
|
||||||
*/
|
|
||||||
program MESSAGEPROG {
|
|
||||||
version MESSAGEVERS {
|
|
||||||
int PRINTMESSAGE(string) = 1;
|
|
||||||
} = 1;
|
|
||||||
} = 99;
|
|
@ -1,28 +0,0 @@
|
|||||||
/* @(#)msg_proc.c 2.1 88/08/11 4.0 RPCSRC */
|
|
||||||
/*
|
|
||||||
* msg_proc.c: implementation of the remote procedure "printmessage"
|
|
||||||
*/
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <rpc/rpc.h> /* always need this here */
|
|
||||||
#include "msg.h" /* need this too: msg.h will be generated by rpcgen */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Remote verson of "printmessage"
|
|
||||||
*/
|
|
||||||
int *
|
|
||||||
printmessage_1(msg)
|
|
||||||
char **msg;
|
|
||||||
{
|
|
||||||
static int result; /* must be static! */
|
|
||||||
FILE *f;
|
|
||||||
|
|
||||||
f = fopen("/dev/console", "w");
|
|
||||||
if (f == NULL) {
|
|
||||||
result = 0;
|
|
||||||
return (&result);
|
|
||||||
}
|
|
||||||
fprintf(f, "%s\n", *msg);
|
|
||||||
fclose(f);
|
|
||||||
result = 1;
|
|
||||||
return (&result);
|
|
||||||
}
|
|
@ -1,43 +0,0 @@
|
|||||||
/* @(#)printmsg.c 2.1 88/08/11 4.0 RPCSRC */
|
|
||||||
/*
|
|
||||||
* printmsg.c: print a message on the console
|
|
||||||
*/
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
main(argc, argv)
|
|
||||||
int argc;
|
|
||||||
char *argv[];
|
|
||||||
{
|
|
||||||
char *message;
|
|
||||||
|
|
||||||
if (argc < 2) {
|
|
||||||
fprintf(stderr, "usage: %s <message>\n", argv[0]);
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
message = argv[1];
|
|
||||||
|
|
||||||
if (!printmessage(message)) {
|
|
||||||
fprintf(stderr, "%s: sorry, couldn't print your message\n",
|
|
||||||
argv[0]);
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
printf("Message delivered!\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Print a message to the console.
|
|
||||||
* Return a boolean indicating whether the message was actually printed.
|
|
||||||
*/
|
|
||||||
printmessage(msg)
|
|
||||||
char *msg;
|
|
||||||
{
|
|
||||||
FILE *f;
|
|
||||||
|
|
||||||
f = fopen("/dev/console", "w");
|
|
||||||
if (f == NULL) {
|
|
||||||
return (0);
|
|
||||||
}
|
|
||||||
fprintf(f, "%s\n", msg);
|
|
||||||
fclose(f);
|
|
||||||
return(1);
|
|
||||||
}
|
|
@ -1,74 +0,0 @@
|
|||||||
/* @(#)rprintmsg.c 2.1 88/08/11 4.0 RPCSRC */
|
|
||||||
/*
|
|
||||||
* rprintmsg.c: remote version of "printmsg.c"
|
|
||||||
*/
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <rpc/rpc.h> /* always need this */
|
|
||||||
#include "msg.h" /* need this too: will be generated by rpcgen*/
|
|
||||||
|
|
||||||
main(argc, argv)
|
|
||||||
int argc;
|
|
||||||
char *argv[];
|
|
||||||
{
|
|
||||||
CLIENT *cl;
|
|
||||||
int *result;
|
|
||||||
char *server;
|
|
||||||
char *message;
|
|
||||||
|
|
||||||
if (argc < 3) {
|
|
||||||
fprintf(stderr, "usage: %s host message\n", argv[0]);
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Remember what our command line arguments refer to
|
|
||||||
*/
|
|
||||||
server = argv[1];
|
|
||||||
message = argv[2];
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Create client "handle" used for calling MESSAGEPROG on the
|
|
||||||
* server designated on the command line. We tell the rpc package
|
|
||||||
* to use the "tcp" protocol when contacting the server.
|
|
||||||
*/
|
|
||||||
cl = clnt_create(server, MESSAGEPROG, MESSAGEVERS, "tcp");
|
|
||||||
if (cl == NULL) {
|
|
||||||
/*
|
|
||||||
* Couldn't establish connection with server.
|
|
||||||
* Print error message and die.
|
|
||||||
*/
|
|
||||||
clnt_pcreateerror(server);
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Call the remote procedure "printmessage" on the server
|
|
||||||
*/
|
|
||||||
result = printmessage_1(&message, cl);
|
|
||||||
if (result == NULL) {
|
|
||||||
/*
|
|
||||||
* An error occurred while calling the server.
|
|
||||||
* Print error message and die.
|
|
||||||
*/
|
|
||||||
clnt_perror(cl, server);
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Okay, we successfully called the remote procedure.
|
|
||||||
*/
|
|
||||||
if (*result == 0) {
|
|
||||||
/*
|
|
||||||
* Server was unable to print our message.
|
|
||||||
* Print error message and die.
|
|
||||||
*/
|
|
||||||
fprintf(stderr, "%s: sorry, %s couldn't print your message\n",
|
|
||||||
argv[0], server);
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* The message got printed on the server's console
|
|
||||||
*/
|
|
||||||
printf("Message delivered to %s!\n", server);
|
|
||||||
}
|
|
@ -1,36 +0,0 @@
|
|||||||
#
|
|
||||||
# @(#)Makefile 2.1 88/08/11 4.0 RPCSRC
|
|
||||||
#
|
|
||||||
|
|
||||||
BIN = rsort sort_svc
|
|
||||||
GEN = sort_clnt.c sort_svc.c sort_xdr.c sort.h
|
|
||||||
LIB = -lrpclib
|
|
||||||
RPCCOM = rpcgen
|
|
||||||
|
|
||||||
all: $(BIN)
|
|
||||||
|
|
||||||
rsort: rsort.o sort_clnt.o sort_xdr.o
|
|
||||||
$(CC) $(LDFLAGS) -o $@ rsort.o sort_clnt.o sort_xdr.o $(LIB)
|
|
||||||
|
|
||||||
rsort.o: rsort.c sort.h
|
|
||||||
|
|
||||||
sort_clnt.c:
|
|
||||||
$(RPCCOM) -l sort.x >$@
|
|
||||||
|
|
||||||
sort_svc: sort_proc.o sort_svc.o sort_xdr.o
|
|
||||||
$(CC) $(LDFLAGS) -o $@ sort_proc.o sort_svc.o sort_xdr.o $(LIB)
|
|
||||||
|
|
||||||
sort_proc.o: sort_proc.c sort.h
|
|
||||||
|
|
||||||
sort_svc.c:
|
|
||||||
$(RPCCOM) -s udp sort.x >$@
|
|
||||||
|
|
||||||
sort_xdr.c:
|
|
||||||
$(RPCCOM) -c sort.x >$@
|
|
||||||
|
|
||||||
sort.h:
|
|
||||||
$(RPCCOM) -h sort.x >$@
|
|
||||||
|
|
||||||
clean cleanup:
|
|
||||||
rm -f $(GEN) *.o $(BIN)
|
|
||||||
|
|
@ -1,43 +0,0 @@
|
|||||||
/* @(#)rsort.c 2.1 88/08/11 4.0 RPCSRC */
|
|
||||||
/*
|
|
||||||
* rsort.c
|
|
||||||
* Client side application which sorts argc, argv.
|
|
||||||
*/
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <rpc/rpc.h>
|
|
||||||
#include "sort.h"
|
|
||||||
|
|
||||||
main(argc, argv)
|
|
||||||
int argc;
|
|
||||||
char **argv;
|
|
||||||
{
|
|
||||||
char *machinename;
|
|
||||||
struct sortstrings args, res;
|
|
||||||
int i;
|
|
||||||
|
|
||||||
if (argc < 3) {
|
|
||||||
fprintf(stderr, "usage: %s machinename [s1 ...]\n", argv[0]);
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
machinename = argv[1];
|
|
||||||
args.ss.ss_len = argc - 2; /* substract off progname, machinename */
|
|
||||||
args.ss.ss_val = &argv[2];
|
|
||||||
res.ss.ss_val = (char **)NULL;
|
|
||||||
|
|
||||||
if ((i = callrpc(machinename, SORTPROG, SORTVERS, SORT,
|
|
||||||
xdr_sortstrings, &args, xdr_sortstrings, &res)))
|
|
||||||
{
|
|
||||||
fprintf(stderr, "%s: call to sort service failed. ", argv[0]);
|
|
||||||
clnt_perrno(i);
|
|
||||||
fprintf(stderr, "\n");
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (i = 0; i < res.ss.ss_len; i++) {
|
|
||||||
printf("%s\n", res.ss.ss_val[i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* should free res here */
|
|
||||||
exit(0);
|
|
||||||
}
|
|
||||||
|
|
@ -1,19 +0,0 @@
|
|||||||
/* @(#)sort.x 2.1 88/08/11 4.0 RPCSRC */
|
|
||||||
/*
|
|
||||||
* The sort procedure receives an array of strings and returns an array
|
|
||||||
* of strings. This toy service handles a maximum of 64 strings.
|
|
||||||
*/
|
|
||||||
const MAXSORTSIZE = 64;
|
|
||||||
const MAXSTRINGLEN = 64;
|
|
||||||
|
|
||||||
typedef string str<MAXSTRINGLEN>; /* the string itself */
|
|
||||||
|
|
||||||
struct sortstrings {
|
|
||||||
str ss<MAXSORTSIZE>;
|
|
||||||
};
|
|
||||||
|
|
||||||
program SORTPROG {
|
|
||||||
version SORTVERS {
|
|
||||||
sortstrings SORT(sortstrings) = 1;
|
|
||||||
} = 1;
|
|
||||||
} = 22855;
|
|
@ -1,27 +0,0 @@
|
|||||||
/* @(#)sort_proc.c 2.1 88/08/11 4.0 RPCSRC */
|
|
||||||
#include <rpc/rpc.h>
|
|
||||||
#include "sort.h"
|
|
||||||
|
|
||||||
static int
|
|
||||||
comparestrings(sp1, sp2)
|
|
||||||
char **sp1, **sp2;
|
|
||||||
{
|
|
||||||
return (strcmp(*sp1, *sp2));
|
|
||||||
}
|
|
||||||
|
|
||||||
struct sortstrings *
|
|
||||||
sort_1(ssp)
|
|
||||||
struct sortstrings *ssp;
|
|
||||||
{
|
|
||||||
static struct sortstrings ss_res;
|
|
||||||
|
|
||||||
if (ss_res.ss.ss_val != (str *)NULL)
|
|
||||||
free(ss_res.ss.ss_val);
|
|
||||||
|
|
||||||
qsort(ssp->ss.ss_val, ssp->ss.ss_len, sizeof (char *), comparestrings);
|
|
||||||
ss_res.ss.ss_len = ssp->ss.ss_len;
|
|
||||||
ss_res.ss.ss_val = (str *)malloc(ssp->ss.ss_len * sizeof(str *));
|
|
||||||
bcopy(ssp->ss.ss_val, ss_res.ss.ss_val,
|
|
||||||
ssp->ss.ss_len * sizeof(str *));
|
|
||||||
return(&ss_res);
|
|
||||||
}
|
|
@ -1,84 +0,0 @@
|
|||||||
#
|
|
||||||
# @(#)Makefile 2.1 88/08/04 4.0 RPCSRC
|
|
||||||
#
|
|
||||||
#
|
|
||||||
# The targets all.nroff and all.troff will make monolithic documents
|
|
||||||
# with nroff and troff, respectively. The other *.nroff and *.troff
|
|
||||||
# targets will make individual documents
|
|
||||||
#
|
|
||||||
TROFF= ditroff
|
|
||||||
TOPTS= -t
|
|
||||||
NROFF= nroff
|
|
||||||
NOPTS=
|
|
||||||
PIC= pic
|
|
||||||
TBL= tbl
|
|
||||||
EQN= eqn
|
|
||||||
|
|
||||||
SRC= rpc.prog.ms rpcgen.ms xdr.nts.ms xdr.rfc.ms rpc.rfc.ms nfs.rfc.ms
|
|
||||||
|
|
||||||
all default: all.nroff
|
|
||||||
|
|
||||||
install: all.nroff
|
|
||||||
@echo "Nothing installed."
|
|
||||||
|
|
||||||
all.nroff: ${SRC}
|
|
||||||
${TBL} ${SRC} | ${EQN} | ${NROFF} ${NOPTS} -ms >all.nroff
|
|
||||||
|
|
||||||
all.troff: ${SRC}
|
|
||||||
${TBL} ${SRC} | ${PIC} | ${EQN} | ${TROFF} ${TOPTS} -ms >all.troff
|
|
||||||
|
|
||||||
#
|
|
||||||
|
|
||||||
rpc.prog.nroff: rpc.prog.ms
|
|
||||||
${TBL} rpc.prog.ms | ${NROFF} ${NOPTS} -ms >rpc.prog.nroff
|
|
||||||
|
|
||||||
rpc.prog.troff: rpc.prog.ms
|
|
||||||
${TBL} rpc.prog.ms | ${PIC} | ${TROFF} ${TOPTS} -ms >rpc.prog.troff
|
|
||||||
|
|
||||||
#
|
|
||||||
|
|
||||||
rpcgen.troff: rpcgen.ms
|
|
||||||
${TBL} rpcgen.ms | ${TROFF} ${TOPTS} -ms >rpcgen.troff
|
|
||||||
|
|
||||||
rpcgen.nroff: rpcgen.ms
|
|
||||||
${TBL} rpcgen.ms | ${NROFF} ${NOPTS} -ms >rpcgen.nroff
|
|
||||||
|
|
||||||
#
|
|
||||||
|
|
||||||
xdr.nts.troff: xdr.nts.ms
|
|
||||||
${TBL} xdr.nts.ms | ${EQN} | ${TROFF} ${TOPTS} -ms >xdr.nts.troff
|
|
||||||
|
|
||||||
xdr.nts.nroff: xdr.nts.ms
|
|
||||||
${TBL} xdr.nts.ms | ${EQN} | ${NROFF} ${NOPTS} -ms >xdr.nts.nroff
|
|
||||||
|
|
||||||
#
|
|
||||||
|
|
||||||
xdr.rfc.troff: xdr.rfc.ms
|
|
||||||
${TBL} xdr.rfc.ms | ${TROFF} ${TOPTS} -ms >xdr.rfc.troff
|
|
||||||
|
|
||||||
xdr.rfc.nroff: xdr.rfc.ms
|
|
||||||
${TBL} xdr.rfc.ms | ${NROFF} ${NOPTS} -ms >xdr.rfc.nroff
|
|
||||||
|
|
||||||
#
|
|
||||||
|
|
||||||
rpc.rfc.troff: rpc.rfc.ms
|
|
||||||
${TBL} rpc.rfc.ms | ${TROFF} ${TOPTS} -ms >rpc.rfc.troff
|
|
||||||
|
|
||||||
rpc.rfc.nroff: rpc.rfc.ms
|
|
||||||
${TBL} rpc.rfc.ms | ${NROFF} ${NOPTS} -ms >rpc.rfc.nroff
|
|
||||||
|
|
||||||
#
|
|
||||||
|
|
||||||
nfs.rfc.troff: nfs.rfc.ms
|
|
||||||
${TBL} nfs.rfc.ms | ${TROFF} ${TOPTS} -ms >nfs.rfc.troff
|
|
||||||
|
|
||||||
nfs.rfc.nroff: nfs.rfc.ms
|
|
||||||
${TBL} nfs.rfc.ms | ${NROFF} ${NOPTS} -ms >nfs.rfc.nroff
|
|
||||||
|
|
||||||
clean:
|
|
||||||
rm -f *.nroff *.troff
|
|
||||||
|
|
||||||
spell: ${SRC}
|
|
||||||
@for i in ${SRC}; do \
|
|
||||||
echo $$i; spell $$i | sort | comm -23 - spell.ok > $$i.spell; \
|
|
||||||
done
|
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1,74 +0,0 @@
|
|||||||
#
|
|
||||||
# @(#)Makefile 2.1 88/08/01 4.0 RPCSRC
|
|
||||||
#
|
|
||||||
# Files and programs for /etc. rpclib must have already been installed.
|
|
||||||
#
|
|
||||||
DESTDIR=
|
|
||||||
CFLAGS= -O
|
|
||||||
LIB = -lrpclib
|
|
||||||
LDFLAGS= $(LIB)
|
|
||||||
|
|
||||||
BIN = portmap rpcinfo
|
|
||||||
MISC= rpc
|
|
||||||
|
|
||||||
all: ${BIN}
|
|
||||||
|
|
||||||
portmap:
|
|
||||||
${CC} ${CFLAGS} -o $@ $@.c ${LDFLAGS}
|
|
||||||
|
|
||||||
rpcinfo: getopt.o
|
|
||||||
${CC} ${CFLAGS} -o $@ $@.c getopt.o ${LDFLAGS}
|
|
||||||
|
|
||||||
install: ${BIN}
|
|
||||||
-mkdir ${DESTDIR}/etc && chown bin ${DESTDIR}/etc && \
|
|
||||||
chmod 755 ${DESTDIR}/etc
|
|
||||||
@echo "Installing RPC utility files in ${DESTDIR}/etc"
|
|
||||||
@set -x;for i in ${BIN}; do \
|
|
||||||
(install -s $$i ${DESTDIR}/etc/$$i); done
|
|
||||||
@echo "Installing ${DESTDIR}/etc/rpc"
|
|
||||||
@set -x;for i in ${MISC}; do \
|
|
||||||
(install -c -m 644 $$i ${DESTDIR}/etc/$$i); done
|
|
||||||
|
|
||||||
clean:
|
|
||||||
rm -f core *.o
|
|
||||||
rm -f ${BIN}
|
|
||||||
|
|
||||||
depend: ${BIN}
|
|
||||||
rm -f makedep
|
|
||||||
for i in ${BIN}; do \
|
|
||||||
${CC} -M ${INCPATH} $$i.c | sed 's/\.o//' | \
|
|
||||||
awk ' { if ($$1 != prev) { print rec; rec = $$0; prev = $$1; } \
|
|
||||||
else { if (length(rec $$2) > 78) { print rec; rec = $$0; } \
|
|
||||||
else rec = rec " " $$2 } } \
|
|
||||||
END { print rec } ' >> makedep; done
|
|
||||||
echo '/^# DO NOT DELETE THIS LINE/+2,$$d' >eddep
|
|
||||||
echo '$$r makedep' >>eddep
|
|
||||||
echo 'w' >>eddep
|
|
||||||
cp Makefile Makefile.bak
|
|
||||||
ed - Makefile < eddep
|
|
||||||
rm eddep makedep
|
|
||||||
echo '# DEPENDENCIES MUST END AT END OF FILE' >> Makefile
|
|
||||||
echo '# IF YOU PUT STUFF HERE IT WILL GO AWAY' >> Makefile
|
|
||||||
echo '# see make depend above' >> Makefile
|
|
||||||
|
|
||||||
|
|
||||||
depend.42BSD depend.42bsd:
|
|
||||||
cp /dev/null x.c
|
|
||||||
for i in $(BIN) ; do \
|
|
||||||
(/bin/grep '^#[ ]*include' x.c $$i.c | sed \
|
|
||||||
-e 's,<\(.*\)>,"/usr/include/\1",' \
|
|
||||||
-e 's/:[^"]*"\([^"]*\)".*/: \1/' \
|
|
||||||
-e 's/\.c/\.o/' >>makedep); done
|
|
||||||
echo '/^# DO NOT DELETE THIS LINE/+2,$$d' >eddep
|
|
||||||
echo '$$r makedep' >>eddep
|
|
||||||
echo 'w' >>eddep
|
|
||||||
cp Makefile Makefile.bak
|
|
||||||
ed - Makefile < eddep
|
|
||||||
rm eddep makedep x.c
|
|
||||||
echo '# DEPENDENCIES MUST END AT END OF FILE' >> Makefile
|
|
||||||
echo '# IF YOU PUT STUFF HERE IT WILL GO AWAY' >> Makefile
|
|
||||||
echo '# see make depend above' >> Makefile
|
|
||||||
|
|
||||||
# DO NOT DELETE THIS LINE -- make depend uses it
|
|
||||||
|
|
||||||
|
|
@ -1,75 +0,0 @@
|
|||||||
/* @(#)getopt.c 2.1 88/08/01 4.0 RPCSRC */
|
|
||||||
|
|
||||||
/* this is a public domain version of getopt */
|
|
||||||
|
|
||||||
/*LINTLIBRARY*/
|
|
||||||
#ifndef NULL
|
|
||||||
#define NULL 0
|
|
||||||
#endif NULL
|
|
||||||
#ifndef EOF
|
|
||||||
#define EOF (-1)
|
|
||||||
#endif EOF
|
|
||||||
|
|
||||||
#define ERR(s, c) if(opterr){\
|
|
||||||
extern int strlen(), write();\
|
|
||||||
char errbuf[2];\
|
|
||||||
errbuf[0] = c; errbuf[1] = '\n';\
|
|
||||||
(void) write(2, argv[0], strlen(argv[0]));\
|
|
||||||
(void) write(2, s, strlen(s));\
|
|
||||||
(void) write(2, errbuf, 2);}
|
|
||||||
|
|
||||||
#define strchr index
|
|
||||||
|
|
||||||
extern int strcmp();
|
|
||||||
extern char *strchr();
|
|
||||||
|
|
||||||
int opterr = 1;
|
|
||||||
int optind = 1;
|
|
||||||
int optopt;
|
|
||||||
char *optarg;
|
|
||||||
|
|
||||||
int
|
|
||||||
getopt(argc, argv, opts)
|
|
||||||
int argc;
|
|
||||||
char **argv, *opts;
|
|
||||||
{
|
|
||||||
static int sp = 1;
|
|
||||||
register int c;
|
|
||||||
register char *cp;
|
|
||||||
|
|
||||||
if(sp == 1)
|
|
||||||
if(optind >= argc ||
|
|
||||||
argv[optind][0] != '-' || argv[optind][1] == '\0')
|
|
||||||
return(EOF);
|
|
||||||
else if(strcmp(argv[optind], "--") == NULL) {
|
|
||||||
optind++;
|
|
||||||
return(EOF);
|
|
||||||
}
|
|
||||||
optopt = c = argv[optind][sp];
|
|
||||||
if(c == ':' || (cp=strchr(opts, c)) == NULL) {
|
|
||||||
ERR(": unknown option, -", c);
|
|
||||||
if(argv[optind][++sp] == '\0') {
|
|
||||||
optind++;
|
|
||||||
sp = 1;
|
|
||||||
}
|
|
||||||
return('?');
|
|
||||||
}
|
|
||||||
if(*++cp == ':') {
|
|
||||||
if(argv[optind][sp+1] != '\0')
|
|
||||||
optarg = &argv[optind++][sp+1];
|
|
||||||
else if(++optind >= argc) {
|
|
||||||
ERR(": argument missing for -", c);
|
|
||||||
sp = 1;
|
|
||||||
return('?');
|
|
||||||
} else
|
|
||||||
optarg = argv[optind++];
|
|
||||||
sp = 1;
|
|
||||||
} else {
|
|
||||||
if(argv[optind][++sp] == '\0') {
|
|
||||||
sp = 1;
|
|
||||||
optind++;
|
|
||||||
}
|
|
||||||
optarg = NULL;
|
|
||||||
}
|
|
||||||
return(c);
|
|
||||||
}
|
|
@ -1,481 +0,0 @@
|
|||||||
/* @(#)portmap.c 2.3 88/08/11 4.0 RPCSRC */
|
|
||||||
#ifndef lint
|
|
||||||
static char sccsid[] = "@(#)portmap.c 1.32 87/08/06 Copyr 1984 Sun Micro";
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright (c) 1984 by Sun Microsystems, Inc.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* portmap.c, Implements the program,version to port number mapping for
|
|
||||||
* rpc.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for
|
|
||||||
* unrestricted use provided that this legend is included on all tape
|
|
||||||
* media and as a part of the software program in whole or part. Users
|
|
||||||
* may copy or modify Sun RPC without charge, but are not authorized
|
|
||||||
* to license or distribute it to anyone else except as part of a product or
|
|
||||||
* program developed by the user.
|
|
||||||
*
|
|
||||||
* SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
|
|
||||||
* WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
|
|
||||||
* PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
|
|
||||||
*
|
|
||||||
* Sun RPC is provided with no support and without any obligation on the
|
|
||||||
* part of Sun Microsystems, Inc. to assist in its use, correction,
|
|
||||||
* modification or enhancement.
|
|
||||||
*
|
|
||||||
* SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
|
|
||||||
* INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
|
|
||||||
* OR ANY PART THEREOF.
|
|
||||||
*
|
|
||||||
* In no event will Sun Microsystems, Inc. be liable for any lost revenue
|
|
||||||
* or profits or other special, indirect and consequential damages, even if
|
|
||||||
* Sun has been advised of the possibility of such damages.
|
|
||||||
*
|
|
||||||
* Sun Microsystems, Inc.
|
|
||||||
* 2550 Garcia Avenue
|
|
||||||
* Mountain View, California 94043
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <rpc/rpc.h>
|
|
||||||
#include <rpc/pmap_prot.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <netdb.h>
|
|
||||||
#include <sys/socket.h>
|
|
||||||
#include <sys/ioctl.h>
|
|
||||||
#include <sys/wait.h>
|
|
||||||
#include <sys/signal.h>
|
|
||||||
|
|
||||||
char *malloc();
|
|
||||||
int reg_service();
|
|
||||||
void reap();
|
|
||||||
struct pmaplist *pmaplist;
|
|
||||||
static int debugging = 0;
|
|
||||||
|
|
||||||
main()
|
|
||||||
{
|
|
||||||
SVCXPRT *xprt;
|
|
||||||
int sock, pid, t;
|
|
||||||
struct sockaddr_in addr;
|
|
||||||
int len = sizeof(struct sockaddr_in);
|
|
||||||
register struct pmaplist *pml;
|
|
||||||
|
|
||||||
#ifndef DEBUG
|
|
||||||
pid = fork();
|
|
||||||
if (pid < 0) {
|
|
||||||
perror("portmap: fork");
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
if (pid != 0)
|
|
||||||
exit(0);
|
|
||||||
for (t = 0; t < 20; t++)
|
|
||||||
close(t);
|
|
||||||
open("/", 0);
|
|
||||||
dup2(0, 1);
|
|
||||||
dup2(0, 2);
|
|
||||||
t = open("/dev/tty", 2);
|
|
||||||
if (t >= 0) {
|
|
||||||
ioctl(t, TIOCNOTTY, (char *)0);
|
|
||||||
close(t);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
if ((sock = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) < 0) {
|
|
||||||
perror("portmap cannot create socket");
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
addr.sin_addr.s_addr = 0;
|
|
||||||
addr.sin_family = AF_INET;
|
|
||||||
addr.sin_port = htons(PMAPPORT);
|
|
||||||
if (bind(sock, (struct sockaddr *)&addr, len) != 0) {
|
|
||||||
perror("portmap cannot bind");
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((xprt = svcudp_create(sock)) == (SVCXPRT *)NULL) {
|
|
||||||
fprintf(stderr, "couldn't do udp_create\n");
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
/* make an entry for ourself */
|
|
||||||
pml = (struct pmaplist *)malloc((u_int)sizeof(struct pmaplist));
|
|
||||||
pml->pml_next = 0;
|
|
||||||
pml->pml_map.pm_prog = PMAPPROG;
|
|
||||||
pml->pml_map.pm_vers = PMAPVERS;
|
|
||||||
pml->pml_map.pm_prot = IPPROTO_UDP;
|
|
||||||
pml->pml_map.pm_port = PMAPPORT;
|
|
||||||
pmaplist = pml;
|
|
||||||
|
|
||||||
if ((sock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)) < 0) {
|
|
||||||
perror("portmap cannot create socket");
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
if (bind(sock, (struct sockaddr *)&addr, len) != 0) {
|
|
||||||
perror("portmap cannot bind");
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
if ((xprt = svctcp_create(sock, RPCSMALLMSGSIZE, RPCSMALLMSGSIZE))
|
|
||||||
== (SVCXPRT *)NULL) {
|
|
||||||
fprintf(stderr, "couldn't do tcp_create\n");
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
/* make an entry for ourself */
|
|
||||||
pml = (struct pmaplist *)malloc((u_int)sizeof(struct pmaplist));
|
|
||||||
pml->pml_map.pm_prog = PMAPPROG;
|
|
||||||
pml->pml_map.pm_vers = PMAPVERS;
|
|
||||||
pml->pml_map.pm_prot = IPPROTO_TCP;
|
|
||||||
pml->pml_map.pm_port = PMAPPORT;
|
|
||||||
pml->pml_next = pmaplist;
|
|
||||||
pmaplist = pml;
|
|
||||||
|
|
||||||
(void)svc_register(xprt, PMAPPROG, PMAPVERS, reg_service, FALSE);
|
|
||||||
|
|
||||||
(void)signal(SIGCHLD, reap);
|
|
||||||
svc_run();
|
|
||||||
fprintf(stderr, "run_svc returned unexpectedly\n");
|
|
||||||
abort();
|
|
||||||
}
|
|
||||||
|
|
||||||
static struct pmaplist *
|
|
||||||
find_service(prog, vers, prot)
|
|
||||||
u_long prog;
|
|
||||||
u_long vers;
|
|
||||||
{
|
|
||||||
register struct pmaplist *hit = NULL;
|
|
||||||
register struct pmaplist *pml;
|
|
||||||
|
|
||||||
for (pml = pmaplist; pml != NULL; pml = pml->pml_next) {
|
|
||||||
if ((pml->pml_map.pm_prog != prog) ||
|
|
||||||
(pml->pml_map.pm_prot != prot))
|
|
||||||
continue;
|
|
||||||
hit = pml;
|
|
||||||
if (pml->pml_map.pm_vers == vers)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return (hit);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* 1 OK, 0 not
|
|
||||||
*/
|
|
||||||
reg_service(rqstp, xprt)
|
|
||||||
struct svc_req *rqstp;
|
|
||||||
SVCXPRT *xprt;
|
|
||||||
{
|
|
||||||
struct pmap reg;
|
|
||||||
struct pmaplist *pml, *prevpml, *fnd;
|
|
||||||
int ans, port;
|
|
||||||
caddr_t t;
|
|
||||||
|
|
||||||
#ifdef DEBUG
|
|
||||||
fprintf(stderr, "server: about do a switch\n");
|
|
||||||
#endif
|
|
||||||
switch (rqstp->rq_proc) {
|
|
||||||
|
|
||||||
case PMAPPROC_NULL:
|
|
||||||
/*
|
|
||||||
* Null proc call
|
|
||||||
*/
|
|
||||||
if ((!svc_sendreply(xprt, xdr_void, NULL)) && debugging) {
|
|
||||||
abort();
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case PMAPPROC_SET:
|
|
||||||
/*
|
|
||||||
* Set a program,version to port mapping
|
|
||||||
*/
|
|
||||||
if (!svc_getargs(xprt, xdr_pmap, ®))
|
|
||||||
svcerr_decode(xprt);
|
|
||||||
else {
|
|
||||||
/*
|
|
||||||
* check to see if already used
|
|
||||||
* find_service returns a hit even if
|
|
||||||
* the versions don't match, so check for it
|
|
||||||
*/
|
|
||||||
fnd = find_service(reg.pm_prog, reg.pm_vers, reg.pm_prot);
|
|
||||||
if (fnd && fnd->pml_map.pm_vers == reg.pm_vers) {
|
|
||||||
if (fnd->pml_map.pm_port == reg.pm_port) {
|
|
||||||
ans = 1;
|
|
||||||
goto done;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
ans = 0;
|
|
||||||
goto done;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
/*
|
|
||||||
* add to END of list
|
|
||||||
*/
|
|
||||||
pml = (struct pmaplist *)
|
|
||||||
malloc((u_int)sizeof(struct pmaplist));
|
|
||||||
pml->pml_map = reg;
|
|
||||||
pml->pml_next = 0;
|
|
||||||
if (pmaplist == 0) {
|
|
||||||
pmaplist = pml;
|
|
||||||
} else {
|
|
||||||
for (fnd= pmaplist; fnd->pml_next != 0;
|
|
||||||
fnd = fnd->pml_next);
|
|
||||||
fnd->pml_next = pml;
|
|
||||||
}
|
|
||||||
ans = 1;
|
|
||||||
}
|
|
||||||
done:
|
|
||||||
if ((!svc_sendreply(xprt, xdr_long, (caddr_t)&ans)) &&
|
|
||||||
debugging) {
|
|
||||||
fprintf(stderr, "svc_sendreply\n");
|
|
||||||
abort();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case PMAPPROC_UNSET:
|
|
||||||
/*
|
|
||||||
* Remove a program,version to port mapping.
|
|
||||||
*/
|
|
||||||
if (!svc_getargs(xprt, xdr_pmap, ®))
|
|
||||||
svcerr_decode(xprt);
|
|
||||||
else {
|
|
||||||
ans = 0;
|
|
||||||
for (prevpml = NULL, pml = pmaplist; pml != NULL; ) {
|
|
||||||
if ((pml->pml_map.pm_prog != reg.pm_prog) ||
|
|
||||||
(pml->pml_map.pm_vers != reg.pm_vers)) {
|
|
||||||
/* both pml & prevpml move forwards */
|
|
||||||
prevpml = pml;
|
|
||||||
pml = pml->pml_next;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
/* found it; pml moves forward, prevpml stays */
|
|
||||||
ans = 1;
|
|
||||||
t = (caddr_t)pml;
|
|
||||||
pml = pml->pml_next;
|
|
||||||
if (prevpml == NULL)
|
|
||||||
pmaplist = pml;
|
|
||||||
else
|
|
||||||
prevpml->pml_next = pml;
|
|
||||||
free(t);
|
|
||||||
}
|
|
||||||
if ((!svc_sendreply(xprt, xdr_long, (caddr_t)&ans)) &&
|
|
||||||
debugging) {
|
|
||||||
fprintf(stderr, "svc_sendreply\n");
|
|
||||||
abort();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case PMAPPROC_GETPORT:
|
|
||||||
/*
|
|
||||||
* Lookup the mapping for a program,version and return its port
|
|
||||||
*/
|
|
||||||
if (!svc_getargs(xprt, xdr_pmap, ®))
|
|
||||||
svcerr_decode(xprt);
|
|
||||||
else {
|
|
||||||
fnd = find_service(reg.pm_prog, reg.pm_vers, reg.pm_prot);
|
|
||||||
if (fnd)
|
|
||||||
port = fnd->pml_map.pm_port;
|
|
||||||
else
|
|
||||||
port = 0;
|
|
||||||
if ((!svc_sendreply(xprt, xdr_long, (caddr_t)&port)) &&
|
|
||||||
debugging) {
|
|
||||||
fprintf(stderr, "svc_sendreply\n");
|
|
||||||
abort();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case PMAPPROC_DUMP:
|
|
||||||
/*
|
|
||||||
* Return the current set of mapped program,version
|
|
||||||
*/
|
|
||||||
if (!svc_getargs(xprt, xdr_void, NULL))
|
|
||||||
svcerr_decode(xprt);
|
|
||||||
else {
|
|
||||||
if ((!svc_sendreply(xprt, xdr_pmaplist,
|
|
||||||
(caddr_t)&pmaplist)) && debugging) {
|
|
||||||
fprintf(stderr, "svc_sendreply\n");
|
|
||||||
abort();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case PMAPPROC_CALLIT:
|
|
||||||
/*
|
|
||||||
* Calls a procedure on the local machine. If the requested
|
|
||||||
* procedure is not registered this procedure does not return
|
|
||||||
* error information!!
|
|
||||||
* This procedure is only supported on rpc/udp and calls via
|
|
||||||
* rpc/udp. It passes null authentication parameters.
|
|
||||||
*/
|
|
||||||
callit(rqstp, xprt);
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
svcerr_noproc(xprt);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Stuff for the rmtcall service
|
|
||||||
*/
|
|
||||||
#define ARGSIZE 9000
|
|
||||||
|
|
||||||
typedef struct encap_parms {
|
|
||||||
u_long arglen;
|
|
||||||
char *args;
|
|
||||||
};
|
|
||||||
|
|
||||||
static bool_t
|
|
||||||
xdr_encap_parms(xdrs, epp)
|
|
||||||
XDR *xdrs;
|
|
||||||
struct encap_parms *epp;
|
|
||||||
{
|
|
||||||
|
|
||||||
return (xdr_bytes(xdrs, &(epp->args), &(epp->arglen), ARGSIZE));
|
|
||||||
}
|
|
||||||
|
|
||||||
typedef struct rmtcallargs {
|
|
||||||
u_long rmt_prog;
|
|
||||||
u_long rmt_vers;
|
|
||||||
u_long rmt_port;
|
|
||||||
u_long rmt_proc;
|
|
||||||
struct encap_parms rmt_args;
|
|
||||||
};
|
|
||||||
|
|
||||||
static bool_t
|
|
||||||
xdr_rmtcall_args(xdrs, cap)
|
|
||||||
register XDR *xdrs;
|
|
||||||
register struct rmtcallargs *cap;
|
|
||||||
{
|
|
||||||
|
|
||||||
/* does not get a port number */
|
|
||||||
if (xdr_u_long(xdrs, &(cap->rmt_prog)) &&
|
|
||||||
xdr_u_long(xdrs, &(cap->rmt_vers)) &&
|
|
||||||
xdr_u_long(xdrs, &(cap->rmt_proc))) {
|
|
||||||
return (xdr_encap_parms(xdrs, &(cap->rmt_args)));
|
|
||||||
}
|
|
||||||
return (FALSE);
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool_t
|
|
||||||
xdr_rmtcall_result(xdrs, cap)
|
|
||||||
register XDR *xdrs;
|
|
||||||
register struct rmtcallargs *cap;
|
|
||||||
{
|
|
||||||
if (xdr_u_long(xdrs, &(cap->rmt_port)))
|
|
||||||
return (xdr_encap_parms(xdrs, &(cap->rmt_args)));
|
|
||||||
return (FALSE);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* only worries about the struct encap_parms part of struct rmtcallargs.
|
|
||||||
* The arglen must already be set!!
|
|
||||||
*/
|
|
||||||
static bool_t
|
|
||||||
xdr_opaque_parms(xdrs, cap)
|
|
||||||
XDR *xdrs;
|
|
||||||
struct rmtcallargs *cap;
|
|
||||||
{
|
|
||||||
|
|
||||||
return (xdr_opaque(xdrs, cap->rmt_args.args, cap->rmt_args.arglen));
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This routine finds and sets the length of incoming opaque paraters
|
|
||||||
* and then calls xdr_opaque_parms.
|
|
||||||
*/
|
|
||||||
static bool_t
|
|
||||||
xdr_len_opaque_parms(xdrs, cap)
|
|
||||||
register XDR *xdrs;
|
|
||||||
struct rmtcallargs *cap;
|
|
||||||
{
|
|
||||||
register u_int beginpos, lowpos, highpos, currpos, pos;
|
|
||||||
|
|
||||||
beginpos = lowpos = pos = xdr_getpos(xdrs);
|
|
||||||
highpos = lowpos + ARGSIZE;
|
|
||||||
while ((int)(highpos - lowpos) >= 0) {
|
|
||||||
currpos = (lowpos + highpos) / 2;
|
|
||||||
if (xdr_setpos(xdrs, currpos)) {
|
|
||||||
pos = currpos;
|
|
||||||
lowpos = currpos + 1;
|
|
||||||
} else {
|
|
||||||
highpos = currpos - 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
xdr_setpos(xdrs, beginpos);
|
|
||||||
cap->rmt_args.arglen = pos - beginpos;
|
|
||||||
return (xdr_opaque_parms(xdrs, cap));
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Call a remote procedure service
|
|
||||||
* This procedure is very quiet when things go wrong.
|
|
||||||
* The proc is written to support broadcast rpc. In the broadcast case,
|
|
||||||
* a machine should shut-up instead of complain, less the requestor be
|
|
||||||
* overrun with complaints at the expense of not hearing a valid reply ...
|
|
||||||
*
|
|
||||||
* This now forks so that the program & process that it calls can call
|
|
||||||
* back to the portmapper.
|
|
||||||
*/
|
|
||||||
static
|
|
||||||
callit(rqstp, xprt)
|
|
||||||
struct svc_req *rqstp;
|
|
||||||
SVCXPRT *xprt;
|
|
||||||
{
|
|
||||||
struct rmtcallargs a;
|
|
||||||
struct pmaplist *pml;
|
|
||||||
u_short port;
|
|
||||||
struct sockaddr_in me;
|
|
||||||
int pid, socket = -1;
|
|
||||||
CLIENT *client;
|
|
||||||
struct authunix_parms *au = (struct authunix_parms *)rqstp->rq_clntcred;
|
|
||||||
struct timeval timeout;
|
|
||||||
char buf[ARGSIZE];
|
|
||||||
|
|
||||||
timeout.tv_sec = 5;
|
|
||||||
timeout.tv_usec = 0;
|
|
||||||
a.rmt_args.args = buf;
|
|
||||||
if (!svc_getargs(xprt, xdr_rmtcall_args, &a))
|
|
||||||
return;
|
|
||||||
if ((pml = find_service(a.rmt_prog, a.rmt_vers, IPPROTO_UDP)) == NULL)
|
|
||||||
return;
|
|
||||||
/*
|
|
||||||
* fork a child to do the work. Parent immediately returns.
|
|
||||||
* Child exits upon completion.
|
|
||||||
*/
|
|
||||||
if ((pid = fork()) != 0) {
|
|
||||||
if (debugging && (pid < 0)) {
|
|
||||||
fprintf(stderr, "portmap CALLIT: cannot fork.\n");
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
port = pml->pml_map.pm_port;
|
|
||||||
get_myaddress(&me);
|
|
||||||
me.sin_port = htons(port);
|
|
||||||
client = clntudp_create(&me, a.rmt_prog, a.rmt_vers, timeout, &socket);
|
|
||||||
if (client != (CLIENT *)NULL) {
|
|
||||||
if (rqstp->rq_cred.oa_flavor == AUTH_UNIX) {
|
|
||||||
client->cl_auth = authunix_create(au->aup_machname,
|
|
||||||
au->aup_uid, au->aup_gid, au->aup_len, au->aup_gids);
|
|
||||||
}
|
|
||||||
a.rmt_port = (u_long)port;
|
|
||||||
if (clnt_call(client, a.rmt_proc, xdr_opaque_parms, &a,
|
|
||||||
xdr_len_opaque_parms, &a, timeout) == RPC_SUCCESS) {
|
|
||||||
svc_sendreply(xprt, xdr_rmtcall_result, &a);
|
|
||||||
}
|
|
||||||
AUTH_DESTROY(client->cl_auth);
|
|
||||||
clnt_destroy(client);
|
|
||||||
}
|
|
||||||
(void)close(socket);
|
|
||||||
exit(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
reap()
|
|
||||||
{
|
|
||||||
while (wait3(NULL, WNOHANG, NULL) > 0);
|
|
||||||
}
|
|
@ -1,33 +0,0 @@
|
|||||||
#
|
|
||||||
# rpc 88/08/01 4.0 RPCSRC; from 1.12 88/02/07 SMI
|
|
||||||
#
|
|
||||||
portmapper 100000 portmap sunrpc
|
|
||||||
rstatd 100001 rstat rstat_svc rup perfmeter
|
|
||||||
rusersd 100002 rusers
|
|
||||||
nfs 100003 nfsprog
|
|
||||||
ypserv 100004 ypprog
|
|
||||||
mountd 100005 mount showmount
|
|
||||||
ypbind 100007
|
|
||||||
walld 100008 rwall shutdown
|
|
||||||
yppasswdd 100009 yppasswd
|
|
||||||
etherstatd 100010 etherstat
|
|
||||||
rquotad 100011 rquotaprog quota rquota
|
|
||||||
sprayd 100012 spray
|
|
||||||
3270_mapper 100013
|
|
||||||
rje_mapper 100014
|
|
||||||
selection_svc 100015 selnsvc
|
|
||||||
database_svc 100016
|
|
||||||
rexd 100017 rex
|
|
||||||
alis 100018
|
|
||||||
sched 100019
|
|
||||||
llockmgr 100020
|
|
||||||
nlockmgr 100021
|
|
||||||
x25.inr 100022
|
|
||||||
statmon 100023
|
|
||||||
status 100024
|
|
||||||
bootparam 100026
|
|
||||||
ypupdated 100028 ypupdate
|
|
||||||
keyserv 100029 keyserver
|
|
||||||
tfsd 100037
|
|
||||||
nsed 100038
|
|
||||||
nsemntd 100039
|
|
@ -1,665 +0,0 @@
|
|||||||
/* @(#)rpcinfo.c 2.2 88/08/11 4.0 RPCSRC */
|
|
||||||
#ifndef lint
|
|
||||||
static char sccsid[] = "@(#)rpcinfo.c 1.22 87/08/12 SMI";
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright (C) 1986, Sun Microsystems, Inc.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* rpcinfo: ping a particular rpc program
|
|
||||||
* or dump the portmapper
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for
|
|
||||||
* unrestricted use provided that this legend is included on all tape
|
|
||||||
* media and as a part of the software program in whole or part. Users
|
|
||||||
* may copy or modify Sun RPC without charge, but are not authorized
|
|
||||||
* to license or distribute it to anyone else except as part of a product or
|
|
||||||
* program developed by the user.
|
|
||||||
*
|
|
||||||
* SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
|
|
||||||
* WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
|
|
||||||
* PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
|
|
||||||
*
|
|
||||||
* Sun RPC is provided with no support and without any obligation on the
|
|
||||||
* part of Sun Microsystems, Inc. to assist in its use, correction,
|
|
||||||
* modification or enhancement.
|
|
||||||
*
|
|
||||||
* SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
|
|
||||||
* INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
|
|
||||||
* OR ANY PART THEREOF.
|
|
||||||
*
|
|
||||||
* In no event will Sun Microsystems, Inc. be liable for any lost revenue
|
|
||||||
* or profits or other special, indirect and consequential damages, even if
|
|
||||||
* Sun has been advised of the possibility of such damages.
|
|
||||||
*
|
|
||||||
* Sun Microsystems, Inc.
|
|
||||||
* 2550 Garcia Avenue
|
|
||||||
* Mountain View, California 94043
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <rpc/rpc.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <sys/socket.h>
|
|
||||||
#include <netdb.h>
|
|
||||||
#include <rpc/pmap_prot.h>
|
|
||||||
#include <rpc/pmap_clnt.h>
|
|
||||||
#include <signal.h>
|
|
||||||
#include <ctype.h>
|
|
||||||
|
|
||||||
#define MAXHOSTLEN 256
|
|
||||||
|
|
||||||
#define MIN_VERS ((u_long) 0)
|
|
||||||
#define MAX_VERS ((u_long) 4294967295L)
|
|
||||||
|
|
||||||
static void udpping(/*u_short portflag, int argc, char **argv*/);
|
|
||||||
static void tcpping(/*u_short portflag, int argc, char **argv*/);
|
|
||||||
static int pstatus(/*CLIENT *client, u_long prognum, u_long vers*/);
|
|
||||||
static void pmapdump(/*int argc, char **argv*/);
|
|
||||||
static bool_t reply_proc(/*void *res, struct sockaddr_in *who*/);
|
|
||||||
static void brdcst(/*int argc, char **argv*/);
|
|
||||||
static void deletereg(/* int argc, char **argv */) ;
|
|
||||||
static void usage(/*void*/);
|
|
||||||
static u_long getprognum(/*char *arg*/);
|
|
||||||
static u_long getvers(/*char *arg*/);
|
|
||||||
static void get_inet_address(/*struct sockaddr_in *addr, char *host*/);
|
|
||||||
extern u_long inet_addr(); /* in 4.2BSD, arpa/inet.h called that a in_addr */
|
|
||||||
extern char *inet_ntoa();
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Functions to be performed.
|
|
||||||
*/
|
|
||||||
#define NONE 0 /* no function */
|
|
||||||
#define PMAPDUMP 1 /* dump portmapper registrations */
|
|
||||||
#define TCPPING 2 /* ping TCP service */
|
|
||||||
#define UDPPING 3 /* ping UDP service */
|
|
||||||
#define BRDCST 4 /* ping broadcast UDP service */
|
|
||||||
#define DELETES 5 /* delete registration for the service */
|
|
||||||
|
|
||||||
int
|
|
||||||
main(argc, argv)
|
|
||||||
int argc;
|
|
||||||
char **argv;
|
|
||||||
{
|
|
||||||
register int c;
|
|
||||||
extern char *optarg;
|
|
||||||
extern int optind;
|
|
||||||
int errflg;
|
|
||||||
int function;
|
|
||||||
u_short portnum;
|
|
||||||
|
|
||||||
function = NONE;
|
|
||||||
portnum = 0;
|
|
||||||
errflg = 0;
|
|
||||||
while ((c = getopt(argc, argv, "ptubdn:")) != EOF) {
|
|
||||||
switch (c) {
|
|
||||||
|
|
||||||
case 'p':
|
|
||||||
if (function != NONE)
|
|
||||||
errflg = 1;
|
|
||||||
else
|
|
||||||
function = PMAPDUMP;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 't':
|
|
||||||
if (function != NONE)
|
|
||||||
errflg = 1;
|
|
||||||
else
|
|
||||||
function = TCPPING;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'u':
|
|
||||||
if (function != NONE)
|
|
||||||
errflg = 1;
|
|
||||||
else
|
|
||||||
function = UDPPING;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'b':
|
|
||||||
if (function != NONE)
|
|
||||||
errflg = 1;
|
|
||||||
else
|
|
||||||
function = BRDCST;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'n':
|
|
||||||
portnum = (u_short) atoi(optarg); /* hope we don't get bogus # */
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'd':
|
|
||||||
if (function != NONE)
|
|
||||||
errflg = 1;
|
|
||||||
else
|
|
||||||
function = DELETES;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case '?':
|
|
||||||
errflg = 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (errflg || function == NONE) {
|
|
||||||
usage();
|
|
||||||
return (1);
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (function) {
|
|
||||||
|
|
||||||
case PMAPDUMP:
|
|
||||||
if (portnum != 0) {
|
|
||||||
usage();
|
|
||||||
return (1);
|
|
||||||
}
|
|
||||||
pmapdump(argc - optind, argv + optind);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case UDPPING:
|
|
||||||
udpping(portnum, argc - optind, argv + optind);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case TCPPING:
|
|
||||||
tcpping(portnum, argc - optind, argv + optind);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case BRDCST:
|
|
||||||
if (portnum != 0) {
|
|
||||||
usage();
|
|
||||||
return (1);
|
|
||||||
}
|
|
||||||
brdcst(argc - optind, argv + optind);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case DELETES:
|
|
||||||
deletereg(argc - optind, argv + optind);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return (0);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
udpping(portnum, argc, argv)
|
|
||||||
u_short portnum;
|
|
||||||
int argc;
|
|
||||||
char **argv;
|
|
||||||
{
|
|
||||||
struct timeval to;
|
|
||||||
struct sockaddr_in addr;
|
|
||||||
enum clnt_stat rpc_stat;
|
|
||||||
CLIENT *client;
|
|
||||||
u_long prognum, vers, minvers, maxvers;
|
|
||||||
int sock = RPC_ANYSOCK;
|
|
||||||
struct rpc_err rpcerr;
|
|
||||||
int failure;
|
|
||||||
|
|
||||||
if (argc < 2 || argc > 3) {
|
|
||||||
usage();
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
prognum = getprognum(argv[1]);
|
|
||||||
get_inet_address(&addr, argv[0]);
|
|
||||||
/* Open the socket here so it will survive calls to clnt_destroy */
|
|
||||||
sock = socket( AF_INET, SOCK_DGRAM, IPPROTO_UDP);
|
|
||||||
if (sock < 0) {
|
|
||||||
perror("rpcinfo: socket");
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
failure = 0;
|
|
||||||
if (argc == 2) {
|
|
||||||
/*
|
|
||||||
* A call to version 0 should fail with a program/version
|
|
||||||
* mismatch, and give us the range of versions supported.
|
|
||||||
*/
|
|
||||||
addr.sin_port = htons(portnum);
|
|
||||||
to.tv_sec = 5;
|
|
||||||
to.tv_usec = 0;
|
|
||||||
if ((client = clntudp_create(&addr, prognum, (u_long)0,
|
|
||||||
to, &sock)) == NULL) {
|
|
||||||
clnt_pcreateerror("rpcinfo");
|
|
||||||
printf("program %lu is not available\n",
|
|
||||||
prognum);
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
to.tv_sec = 10;
|
|
||||||
to.tv_usec = 0;
|
|
||||||
rpc_stat = clnt_call(client, NULLPROC, xdr_void, (char *)NULL,
|
|
||||||
xdr_void, (char *)NULL, to);
|
|
||||||
if (rpc_stat == RPC_PROGVERSMISMATCH) {
|
|
||||||
clnt_geterr(client, &rpcerr);
|
|
||||||
minvers = rpcerr.re_vers.low;
|
|
||||||
maxvers = rpcerr.re_vers.high;
|
|
||||||
} else if (rpc_stat == RPC_SUCCESS) {
|
|
||||||
/*
|
|
||||||
* Oh dear, it DOES support version 0.
|
|
||||||
* Let's try version MAX_VERS.
|
|
||||||
*/
|
|
||||||
addr.sin_port = htons(portnum);
|
|
||||||
to.tv_sec = 5;
|
|
||||||
to.tv_usec = 0;
|
|
||||||
if ((client = clntudp_create(&addr, prognum, MAX_VERS,
|
|
||||||
to, &sock)) == NULL) {
|
|
||||||
clnt_pcreateerror("rpcinfo");
|
|
||||||
printf("program %lu version %lu is not available\n",
|
|
||||||
prognum, MAX_VERS);
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
to.tv_sec = 10;
|
|
||||||
to.tv_usec = 0;
|
|
||||||
rpc_stat = clnt_call(client, NULLPROC, xdr_void,
|
|
||||||
(char *)NULL, xdr_void, (char *)NULL, to);
|
|
||||||
if (rpc_stat == RPC_PROGVERSMISMATCH) {
|
|
||||||
clnt_geterr(client, &rpcerr);
|
|
||||||
minvers = rpcerr.re_vers.low;
|
|
||||||
maxvers = rpcerr.re_vers.high;
|
|
||||||
} else if (rpc_stat == RPC_SUCCESS) {
|
|
||||||
/*
|
|
||||||
* It also supports version MAX_VERS.
|
|
||||||
* Looks like we have a wise guy.
|
|
||||||
* OK, we give them information on all
|
|
||||||
* 4 billion versions they support...
|
|
||||||
*/
|
|
||||||
minvers = 0;
|
|
||||||
maxvers = MAX_VERS;
|
|
||||||
} else {
|
|
||||||
(void) pstatus(client, prognum, MAX_VERS);
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
(void) pstatus(client, prognum, (u_long)0);
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
clnt_destroy(client);
|
|
||||||
for (vers = minvers; vers <= maxvers; vers++) {
|
|
||||||
addr.sin_port = htons(portnum);
|
|
||||||
to.tv_sec = 5;
|
|
||||||
to.tv_usec = 0;
|
|
||||||
if ((client = clntudp_create(&addr, prognum, vers,
|
|
||||||
to, &sock)) == NULL) {
|
|
||||||
clnt_pcreateerror("rpcinfo");
|
|
||||||
printf("program %lu version %lu is not available\n",
|
|
||||||
prognum, vers);
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
to.tv_sec = 10;
|
|
||||||
to.tv_usec = 0;
|
|
||||||
rpc_stat = clnt_call(client, NULLPROC, xdr_void,
|
|
||||||
(char *)NULL, xdr_void, (char *)NULL, to);
|
|
||||||
if (pstatus(client, prognum, vers) < 0)
|
|
||||||
failure = 1;
|
|
||||||
clnt_destroy(client);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
vers = getvers(argv[2]);
|
|
||||||
addr.sin_port = htons(portnum);
|
|
||||||
to.tv_sec = 5;
|
|
||||||
to.tv_usec = 0;
|
|
||||||
if ((client = clntudp_create(&addr, prognum, vers,
|
|
||||||
to, &sock)) == NULL) {
|
|
||||||
clnt_pcreateerror("rpcinfo");
|
|
||||||
printf("program %lu version %lu is not available\n",
|
|
||||||
prognum, vers);
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
to.tv_sec = 10;
|
|
||||||
to.tv_usec = 0;
|
|
||||||
rpc_stat = clnt_call(client, 0, xdr_void, (char *)NULL,
|
|
||||||
xdr_void, (char *)NULL, to);
|
|
||||||
if (pstatus(client, prognum, vers) < 0)
|
|
||||||
failure = 1;
|
|
||||||
}
|
|
||||||
(void) close(sock); /* Close it up again */
|
|
||||||
if (failure)
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
tcpping(portnum, argc, argv)
|
|
||||||
u_short portnum;
|
|
||||||
int argc;
|
|
||||||
char **argv;
|
|
||||||
{
|
|
||||||
struct timeval to;
|
|
||||||
struct sockaddr_in addr;
|
|
||||||
enum clnt_stat rpc_stat;
|
|
||||||
CLIENT *client;
|
|
||||||
u_long prognum, vers, minvers, maxvers;
|
|
||||||
int sock = RPC_ANYSOCK;
|
|
||||||
struct rpc_err rpcerr;
|
|
||||||
int failure;
|
|
||||||
|
|
||||||
if (argc < 2 || argc > 3) {
|
|
||||||
usage();
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
prognum = getprognum(argv[1]);
|
|
||||||
get_inet_address(&addr, argv[0]);
|
|
||||||
failure = 0;
|
|
||||||
if (argc == 2) {
|
|
||||||
/*
|
|
||||||
* A call to version 0 should fail with a program/version
|
|
||||||
* mismatch, and give us the range of versions supported.
|
|
||||||
*/
|
|
||||||
addr.sin_port = htons(portnum);
|
|
||||||
if ((client = clnttcp_create(&addr, prognum, MIN_VERS,
|
|
||||||
&sock, 0, 0)) == NULL) {
|
|
||||||
clnt_pcreateerror("rpcinfo");
|
|
||||||
printf("program %lu is not available\n",
|
|
||||||
prognum);
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
to.tv_sec = 10;
|
|
||||||
to.tv_usec = 0;
|
|
||||||
rpc_stat = clnt_call(client, NULLPROC, xdr_void, (char *)NULL,
|
|
||||||
xdr_void, (char *)NULL, to);
|
|
||||||
if (rpc_stat == RPC_PROGVERSMISMATCH) {
|
|
||||||
clnt_geterr(client, &rpcerr);
|
|
||||||
minvers = rpcerr.re_vers.low;
|
|
||||||
maxvers = rpcerr.re_vers.high;
|
|
||||||
} else if (rpc_stat == RPC_SUCCESS) {
|
|
||||||
/*
|
|
||||||
* Oh dear, it DOES support version 0.
|
|
||||||
* Let's try version MAX_VERS.
|
|
||||||
*/
|
|
||||||
addr.sin_port = htons(portnum);
|
|
||||||
if ((client = clnttcp_create(&addr, prognum, MAX_VERS,
|
|
||||||
&sock, 0, 0)) == NULL) {
|
|
||||||
clnt_pcreateerror("rpcinfo");
|
|
||||||
printf("program %lu version %lu is not available\n",
|
|
||||||
prognum, MAX_VERS);
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
to.tv_sec = 10;
|
|
||||||
to.tv_usec = 0;
|
|
||||||
rpc_stat = clnt_call(client, NULLPROC, xdr_void,
|
|
||||||
(char *)NULL, xdr_void, (char *)NULL, to);
|
|
||||||
if (rpc_stat == RPC_PROGVERSMISMATCH) {
|
|
||||||
clnt_geterr(client, &rpcerr);
|
|
||||||
minvers = rpcerr.re_vers.low;
|
|
||||||
maxvers = rpcerr.re_vers.high;
|
|
||||||
} else if (rpc_stat == RPC_SUCCESS) {
|
|
||||||
/*
|
|
||||||
* It also supports version MAX_VERS.
|
|
||||||
* Looks like we have a wise guy.
|
|
||||||
* OK, we give them information on all
|
|
||||||
* 4 billion versions they support...
|
|
||||||
*/
|
|
||||||
minvers = 0;
|
|
||||||
maxvers = MAX_VERS;
|
|
||||||
} else {
|
|
||||||
(void) pstatus(client, prognum, MAX_VERS);
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
(void) pstatus(client, prognum, MIN_VERS);
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
clnt_destroy(client);
|
|
||||||
(void) close(sock);
|
|
||||||
sock = RPC_ANYSOCK; /* Re-initialize it for later */
|
|
||||||
for (vers = minvers; vers <= maxvers; vers++) {
|
|
||||||
addr.sin_port = htons(portnum);
|
|
||||||
if ((client = clnttcp_create(&addr, prognum, vers,
|
|
||||||
&sock, 0, 0)) == NULL) {
|
|
||||||
clnt_pcreateerror("rpcinfo");
|
|
||||||
printf("program %lu version %lu is not available\n",
|
|
||||||
prognum, vers);
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
to.tv_usec = 0;
|
|
||||||
to.tv_sec = 10;
|
|
||||||
rpc_stat = clnt_call(client, 0, xdr_void, (char *)NULL,
|
|
||||||
xdr_void, (char *)NULL, to);
|
|
||||||
if (pstatus(client, prognum, vers) < 0)
|
|
||||||
failure = 1;
|
|
||||||
clnt_destroy(client);
|
|
||||||
(void) close(sock);
|
|
||||||
sock = RPC_ANYSOCK;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
vers = getvers(argv[2]);
|
|
||||||
addr.sin_port = htons(portnum);
|
|
||||||
if ((client = clnttcp_create(&addr, prognum, vers, &sock,
|
|
||||||
0, 0)) == NULL) {
|
|
||||||
clnt_pcreateerror("rpcinfo");
|
|
||||||
printf("program %lu version %lu is not available\n",
|
|
||||||
prognum, vers);
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
to.tv_usec = 0;
|
|
||||||
to.tv_sec = 10;
|
|
||||||
rpc_stat = clnt_call(client, 0, xdr_void, (char *)NULL,
|
|
||||||
xdr_void, (char *)NULL, to);
|
|
||||||
if (pstatus(client, prognum, vers) < 0)
|
|
||||||
failure = 1;
|
|
||||||
}
|
|
||||||
if (failure)
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This routine should take a pointer to an "rpc_err" structure, rather than
|
|
||||||
* a pointer to a CLIENT structure, but "clnt_perror" takes a pointer to
|
|
||||||
* a CLIENT structure rather than a pointer to an "rpc_err" structure.
|
|
||||||
* As such, we have to keep the CLIENT structure around in order to print
|
|
||||||
* a good error message.
|
|
||||||
*/
|
|
||||||
static int
|
|
||||||
pstatus(client, prognum, vers)
|
|
||||||
register CLIENT *client;
|
|
||||||
u_long prognum;
|
|
||||||
u_long vers;
|
|
||||||
{
|
|
||||||
struct rpc_err rpcerr;
|
|
||||||
|
|
||||||
clnt_geterr(client, &rpcerr);
|
|
||||||
if (rpcerr.re_status != RPC_SUCCESS) {
|
|
||||||
clnt_perror(client, "rpcinfo");
|
|
||||||
printf("program %lu version %lu is not available\n",
|
|
||||||
prognum, vers);
|
|
||||||
return (-1);
|
|
||||||
} else {
|
|
||||||
printf("program %lu version %lu ready and waiting\n",
|
|
||||||
prognum, vers);
|
|
||||||
return (0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
pmapdump(argc, argv)
|
|
||||||
int argc;
|
|
||||||
char **argv;
|
|
||||||
{
|
|
||||||
struct sockaddr_in server_addr;
|
|
||||||
register struct hostent *hp;
|
|
||||||
struct pmaplist *head = NULL;
|
|
||||||
int socket = RPC_ANYSOCK;
|
|
||||||
struct timeval minutetimeout;
|
|
||||||
register CLIENT *client;
|
|
||||||
struct rpcent *rpc;
|
|
||||||
|
|
||||||
if (argc > 1) {
|
|
||||||
usage();
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
if (argc == 1)
|
|
||||||
get_inet_address(&server_addr, argv[0]);
|
|
||||||
else {
|
|
||||||
bzero((char *)&server_addr, sizeof server_addr);
|
|
||||||
server_addr.sin_family = AF_INET;
|
|
||||||
if ((hp = gethostbyname("localhost")) != NULL)
|
|
||||||
bcopy(hp->h_addr, (caddr_t)&server_addr.sin_addr,
|
|
||||||
hp->h_length);
|
|
||||||
else
|
|
||||||
server_addr.sin_addr.s_addr = inet_addr("0.0.0.0");
|
|
||||||
}
|
|
||||||
minutetimeout.tv_sec = 60;
|
|
||||||
minutetimeout.tv_usec = 0;
|
|
||||||
server_addr.sin_port = htons(PMAPPORT);
|
|
||||||
if ((client = clnttcp_create(&server_addr, PMAPPROG,
|
|
||||||
PMAPVERS, &socket, 50, 500)) == NULL) {
|
|
||||||
clnt_pcreateerror("rpcinfo: can't contact portmapper");
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
if (clnt_call(client, PMAPPROC_DUMP, xdr_void, NULL,
|
|
||||||
xdr_pmaplist, &head, minutetimeout) != RPC_SUCCESS) {
|
|
||||||
fprintf(stderr, "rpcinfo: can't contact portmapper: ");
|
|
||||||
clnt_perror(client, "rpcinfo");
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
if (head == NULL) {
|
|
||||||
printf("No remote programs registered.\n");
|
|
||||||
} else {
|
|
||||||
printf(" program vers proto port\n");
|
|
||||||
for (; head != NULL; head = head->pml_next) {
|
|
||||||
printf("%10ld%5ld",
|
|
||||||
head->pml_map.pm_prog,
|
|
||||||
head->pml_map.pm_vers);
|
|
||||||
if (head->pml_map.pm_prot == IPPROTO_UDP)
|
|
||||||
printf("%6s", "udp");
|
|
||||||
else if (head->pml_map.pm_prot == IPPROTO_TCP)
|
|
||||||
printf("%6s", "tcp");
|
|
||||||
else
|
|
||||||
printf("%6ld", head->pml_map.pm_prot);
|
|
||||||
printf("%7ld", head->pml_map.pm_port);
|
|
||||||
rpc = getrpcbynumber(head->pml_map.pm_prog);
|
|
||||||
if (rpc)
|
|
||||||
printf(" %s\n", rpc->r_name);
|
|
||||||
else
|
|
||||||
printf("\n");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* reply_proc collects replies from the broadcast.
|
|
||||||
* to get a unique list of responses the output of rpcinfo should
|
|
||||||
* be piped through sort(1) and then uniq(1).
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*ARGSUSED*/
|
|
||||||
static bool_t
|
|
||||||
reply_proc(res, who)
|
|
||||||
void *res; /* Nothing comes back */
|
|
||||||
struct sockaddr_in *who; /* Who sent us the reply */
|
|
||||||
{
|
|
||||||
register struct hostent *hp;
|
|
||||||
|
|
||||||
hp = gethostbyaddr((char *) &who->sin_addr, sizeof who->sin_addr,
|
|
||||||
AF_INET);
|
|
||||||
printf("%s %s\n", inet_ntoa(who->sin_addr),
|
|
||||||
(hp == NULL) ? "(unknown)" : hp->h_name);
|
|
||||||
return(FALSE);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
brdcst(argc, argv)
|
|
||||||
int argc;
|
|
||||||
char **argv;
|
|
||||||
{
|
|
||||||
enum clnt_stat rpc_stat;
|
|
||||||
u_long prognum, vers;
|
|
||||||
|
|
||||||
if (argc != 2) {
|
|
||||||
usage();
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
prognum = getprognum(argv[0]);
|
|
||||||
vers = getvers(argv[1]);
|
|
||||||
rpc_stat = clnt_broadcast(prognum, vers, NULLPROC, xdr_void,
|
|
||||||
(char *)NULL, xdr_void, (char *)NULL, reply_proc);
|
|
||||||
if ((rpc_stat != RPC_SUCCESS) && (rpc_stat != RPC_TIMEDOUT)) {
|
|
||||||
fprintf(stderr, "rpcinfo: broadcast failed: %s\n",
|
|
||||||
clnt_sperrno(rpc_stat));
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
exit(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
deletereg(argc, argv)
|
|
||||||
int argc;
|
|
||||||
char **argv;
|
|
||||||
{ u_long prog_num, version_num ;
|
|
||||||
|
|
||||||
if (argc != 2) {
|
|
||||||
usage() ;
|
|
||||||
exit(1) ;
|
|
||||||
}
|
|
||||||
if (getuid()) { /* This command allowed only to root */
|
|
||||||
fprintf(stderr, "Sorry. You are not root\n") ;
|
|
||||||
exit(1) ;
|
|
||||||
}
|
|
||||||
prog_num = getprognum(argv[0]);
|
|
||||||
version_num = getvers(argv[1]);
|
|
||||||
if ((pmap_unset(prog_num, version_num)) == 0) {
|
|
||||||
fprintf(stderr, "rpcinfo: Could not delete registration for prog %s version %s\n",
|
|
||||||
argv[0], argv[1]) ;
|
|
||||||
exit(1) ;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
usage()
|
|
||||||
{
|
|
||||||
fprintf(stderr, "Usage: rpcinfo [ -n portnum ] -u host prognum [ versnum ]\n");
|
|
||||||
fprintf(stderr, " rpcinfo [ -n portnum ] -t host prognum [ versnum ]\n");
|
|
||||||
fprintf(stderr, " rpcinfo -p [ host ]\n");
|
|
||||||
fprintf(stderr, " rpcinfo -b prognum versnum\n");
|
|
||||||
fprintf(stderr, " rpcinfo -d prognum versnum\n") ;
|
|
||||||
}
|
|
||||||
|
|
||||||
static u_long
|
|
||||||
getprognum(arg)
|
|
||||||
char *arg;
|
|
||||||
{
|
|
||||||
register struct rpcent *rpc;
|
|
||||||
register u_long prognum;
|
|
||||||
|
|
||||||
if (isalpha(*arg)) {
|
|
||||||
rpc = getrpcbyname(arg);
|
|
||||||
if (rpc == NULL) {
|
|
||||||
fprintf(stderr, "rpcinfo: %s is unknown service\n",
|
|
||||||
arg);
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
prognum = rpc->r_number;
|
|
||||||
} else {
|
|
||||||
prognum = (u_long) atoi(arg);
|
|
||||||
}
|
|
||||||
|
|
||||||
return (prognum);
|
|
||||||
}
|
|
||||||
|
|
||||||
static u_long
|
|
||||||
getvers(arg)
|
|
||||||
char *arg;
|
|
||||||
{
|
|
||||||
register u_long vers;
|
|
||||||
|
|
||||||
vers = (int) atoi(arg);
|
|
||||||
return (vers);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
get_inet_address(addr, host)
|
|
||||||
struct sockaddr_in *addr;
|
|
||||||
char *host;
|
|
||||||
{
|
|
||||||
register struct hostent *hp;
|
|
||||||
|
|
||||||
bzero((char *)addr, sizeof *addr);
|
|
||||||
addr->sin_addr.s_addr = (u_long) inet_addr(host);
|
|
||||||
if (addr->sin_addr.s_addr == -1 || addr->sin_addr.s_addr == 0) {
|
|
||||||
if ((hp = gethostbyname(host)) == NULL) {
|
|
||||||
fprintf(stderr, "rpcinfo: %s is unknown host\n", host);
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
bcopy(hp->h_addr, (char *)&addr->sin_addr, hp->h_length);
|
|
||||||
}
|
|
||||||
addr->sin_family = AF_INET;
|
|
||||||
}
|
|
@ -1,197 +0,0 @@
|
|||||||
.\" Copyright 1991 The Regents of the University of California.
|
|
||||||
.\" All rights reserved.
|
|
||||||
.\"
|
|
||||||
.\" Derived from Sun Microsystems rpcgen.1 2.2 88/08/02 4.0 RPCSRC
|
|
||||||
.\"
|
|
||||||
.\" 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.
|
|
||||||
.\"
|
|
||||||
.\" @(#)rpcgen.1 5.4 (Berkeley) 12/30/93
|
|
||||||
.\"
|
|
||||||
.Dd December 30, 1993
|
|
||||||
.Dt RPCGEN 1
|
|
||||||
.Sh NAME
|
|
||||||
.Nm rpcgen
|
|
||||||
.Nd an
|
|
||||||
.Tn RPC
|
|
||||||
protocol compiler
|
|
||||||
.Sh SYNOPSIS
|
|
||||||
.Nm rpcgen Ar infile
|
|
||||||
.Nm rpcgen
|
|
||||||
.Fl c | Fl h | Fl l |
|
|
||||||
.Fl m
|
|
||||||
.Op Fl o Ar outfile
|
|
||||||
.Op Ar infile
|
|
||||||
.Nm rpcgen Fl s Ar transport
|
|
||||||
.Op Fl o Ar outfile
|
|
||||||
.Op Ar infile
|
|
||||||
.Sh DESCRIPTION
|
|
||||||
.Nm rpcgen
|
|
||||||
is a tool that generates
|
|
||||||
.Tn \&C
|
|
||||||
code to implement an
|
|
||||||
.Tn RPC
|
|
||||||
protocol. The input to
|
|
||||||
.Nm rpcgen
|
|
||||||
is a language similar to C
|
|
||||||
known as
|
|
||||||
.Tn RPC
|
|
||||||
Language (Remote Procedure Call Language). Information
|
|
||||||
about the syntax of
|
|
||||||
.Tn RPC
|
|
||||||
Language is available in the
|
|
||||||
.Rs
|
|
||||||
.%T "Rpcgen Programming Guide"
|
|
||||||
.Re
|
|
||||||
.Pp
|
|
||||||
Available options:
|
|
||||||
.Bl -tag -width indent
|
|
||||||
.It Fl c
|
|
||||||
Compile into
|
|
||||||
.Dv XDR
|
|
||||||
routines.
|
|
||||||
.It Fl h
|
|
||||||
Compile into
|
|
||||||
.Tn \&C
|
|
||||||
data-definitions (a header file)
|
|
||||||
.It Fl l
|
|
||||||
Compile into client-side stubs.
|
|
||||||
.It Fl m
|
|
||||||
Compile into server-side stubs, but do not generate a
|
|
||||||
.Em main
|
|
||||||
routine.
|
|
||||||
This option is useful for doing callback-routines and for people who
|
|
||||||
need to write their own
|
|
||||||
.Em main
|
|
||||||
routine to do initialization.
|
|
||||||
.It Fl o Ar outfile
|
|
||||||
Specify the name of the output file.
|
|
||||||
If none is specified, standard output is used
|
|
||||||
.Pf ( Fl c ,
|
|
||||||
.Fl h ,
|
|
||||||
.Fl l
|
|
||||||
and
|
|
||||||
.Fl s
|
|
||||||
modes only).
|
|
||||||
.It Fl s Ar transport
|
|
||||||
Compile into server-side stubs, using the given transport. The
|
|
||||||
supported transports
|
|
||||||
are
|
|
||||||
.Tn UDP
|
|
||||||
and
|
|
||||||
.Tn TCP .
|
|
||||||
This option may be invoked more than once
|
|
||||||
so as to compile a server that serves multiple transports.
|
|
||||||
.El
|
|
||||||
.Pp
|
|
||||||
.Nm rpcgen
|
|
||||||
is normally used as in the first synopsis where it takes an input file
|
|
||||||
and generates four output files. If the
|
|
||||||
.Ar infile
|
|
||||||
is named
|
|
||||||
.Pa proto.x ,
|
|
||||||
then
|
|
||||||
.Nm rpcgen
|
|
||||||
will generate a header file in
|
|
||||||
.Pa proto.h ,
|
|
||||||
.Dv XDR
|
|
||||||
routines in
|
|
||||||
.Pa proto_xdr.c ,
|
|
||||||
server-side stubs in
|
|
||||||
.Pa proto_svc.c ,
|
|
||||||
and client-side stubs in
|
|
||||||
.Pa proto_clnt.c .
|
|
||||||
.Pp
|
|
||||||
The other synopses shown above are used when one does not want to
|
|
||||||
generate all the output files, but only a particular one. Their
|
|
||||||
usage is described in the
|
|
||||||
.Sx USAGE
|
|
||||||
section below.
|
|
||||||
.Pp
|
|
||||||
The C-preprocessor,
|
|
||||||
.Xr cpp 1 ,
|
|
||||||
is run on all input files before they are actually
|
|
||||||
interpreted by
|
|
||||||
.Nm rpcgen ,
|
|
||||||
so all the
|
|
||||||
.Xr cpp
|
|
||||||
directives are legal within an
|
|
||||||
.Nm rpcgen
|
|
||||||
input file. For each type of output file,
|
|
||||||
.Nm rpcgen
|
|
||||||
defines a special
|
|
||||||
.Xr cpp
|
|
||||||
symbol for use by the
|
|
||||||
.Nm rpcgen
|
|
||||||
programmer:
|
|
||||||
.Pp
|
|
||||||
.Bl -tag -width "RPC_CLNT"
|
|
||||||
.It Dv RPC_HDR
|
|
||||||
defined when compiling into header files
|
|
||||||
.It Dv RPC_XDR
|
|
||||||
defined when compiling into
|
|
||||||
.Dv XDR
|
|
||||||
routines
|
|
||||||
.It Dv RPC_SVC
|
|
||||||
defined when compiling into server-side stubs
|
|
||||||
.It Dv RPC_CLNT
|
|
||||||
defined when compiling into client-side stubs
|
|
||||||
.El
|
|
||||||
.Pp
|
|
||||||
In addition,
|
|
||||||
.Nm rpcgen
|
|
||||||
does a little preprocessing of its own.
|
|
||||||
Any line beginning with
|
|
||||||
.Ql \&%
|
|
||||||
is passed directly into the output file, uninterpreted by
|
|
||||||
.Nm rpcgen .
|
|
||||||
.Pp
|
|
||||||
You can customize some of your
|
|
||||||
.Dv XDR
|
|
||||||
routines by leaving those data
|
|
||||||
types undefined. For every data type that is undefined,
|
|
||||||
.Nm rpcgen
|
|
||||||
will assume that there exists a routine with the name
|
|
||||||
.Em xdr_
|
|
||||||
prepended to the name of the undefined type.
|
|
||||||
.Sh SEE ALSO
|
|
||||||
.Xr cpp 1
|
|
||||||
.Rs
|
|
||||||
.%T "Rpcgen Programming Guide"
|
|
||||||
.%I "Sun Microsystems"
|
|
||||||
.Re
|
|
||||||
.Sh BUGS
|
|
||||||
.Pp
|
|
||||||
Nesting is not supported.
|
|
||||||
As a work-around, structures can be declared at
|
|
||||||
top-level, and their name used inside other structures in order to achieve
|
|
||||||
the same effect.
|
|
||||||
.Pp
|
|
||||||
Name clashes can occur when using program definitions, since the apparent
|
|
||||||
scoping does not really apply. Most of these can be avoided by giving
|
|
||||||
unique names for programs, versions, procedures and types.
|
|
@ -1,57 +0,0 @@
|
|||||||
.\" @(#)rstat.1 2.1 88/08/03 4.0 RPCSRC
|
|
||||||
.TH RSTAT 1 "3 August 1988"
|
|
||||||
.SH NAME
|
|
||||||
rstat \- remote status display
|
|
||||||
.SH SYNOPSIS
|
|
||||||
.B rstat
|
|
||||||
.B host
|
|
||||||
.SH DESCRIPTION
|
|
||||||
.LP
|
|
||||||
.B rstat
|
|
||||||
displays a summary of the current system status of a particular
|
|
||||||
.BR host .
|
|
||||||
The output shows the current time of day, how long the system has
|
|
||||||
been up,
|
|
||||||
and the load averages.
|
|
||||||
The load average numbers give the number of jobs in the run queue
|
|
||||||
averaged over 1, 5 and 15 minutes.
|
|
||||||
.PP
|
|
||||||
The
|
|
||||||
.B rstat_svc(8c)
|
|
||||||
daemon must be running on the remote host for this command to
|
|
||||||
work.
|
|
||||||
.B rstat
|
|
||||||
uses an RPC protocol defined in /usr/include/rpcsvc/rstat.x.
|
|
||||||
.SH EXAMPLE
|
|
||||||
.RS
|
|
||||||
.ft B
|
|
||||||
.nf
|
|
||||||
example% rstat otherhost
|
|
||||||
7:36am up 6 days, 16:45, load average: 0.20, 0.23, 0.18
|
|
||||||
example%
|
|
||||||
.ft R
|
|
||||||
.fi
|
|
||||||
.RE
|
|
||||||
.SH DIAGNOSTICS
|
|
||||||
.LP
|
|
||||||
rstat: RPC: Program not registered
|
|
||||||
.IP
|
|
||||||
The
|
|
||||||
.B rstat_svc
|
|
||||||
daemon has not been started on the remote host.
|
|
||||||
.LP
|
|
||||||
rstat: RPC: Timed out
|
|
||||||
.IP
|
|
||||||
A communication error occurred. Either the network is
|
|
||||||
excessively congested, or the
|
|
||||||
.B rstat_svc
|
|
||||||
daemon has terminated on the remote host.
|
|
||||||
.LP
|
|
||||||
rstat: RPC: Port mapper failure - RPC: Timed out
|
|
||||||
.IP
|
|
||||||
The remote host is not running the portmapper (see
|
|
||||||
.BR portmap(8c) ),
|
|
||||||
and cannot accommodate any RPC-based services. The host may be down.
|
|
||||||
.SH "SEE ALSO"
|
|
||||||
.BR portmap (8c),
|
|
||||||
.BR rstat_svc (8c)
|
|
@ -1,27 +0,0 @@
|
|||||||
.\" @(#)bindresvport.3n 2.2 88/08/02 4.0 RPCSRC; from 1.7 88/03/14 SMI
|
|
||||||
.TH BINDRESVPORT 3N "22 november 1987"
|
|
||||||
.SH NAME
|
|
||||||
bindresvport \- bind a socket to a privileged IP port
|
|
||||||
.SH SYNOPSIS
|
|
||||||
.nf
|
|
||||||
.B #include <sys/types.h>
|
|
||||||
.B #include <netinet/in.h>
|
|
||||||
.LP
|
|
||||||
.B int bindresvport(sd, sin)
|
|
||||||
.B int sd;
|
|
||||||
.B struct sockaddr_in \(**sin;
|
|
||||||
.fi
|
|
||||||
.SH DESCRIPTION
|
|
||||||
.LP
|
|
||||||
.B bindresvport(\|)
|
|
||||||
is used to bind a socket descriptor to a privileged
|
|
||||||
.SM IP
|
|
||||||
port, that is, a
|
|
||||||
port number in the range 0-1023.
|
|
||||||
The routine returns 0 if it is successful,
|
|
||||||
otherwise \-1 is returned and
|
|
||||||
.B errno
|
|
||||||
set to reflect the cause of the error.
|
|
||||||
.LP
|
|
||||||
Only root can bind to a privileged port; this call will fail for any
|
|
||||||
other users.
|
|
@ -1,109 +0,0 @@
|
|||||||
.\" @(#)getrpcent.3n 2.2 88/08/02 4.0 RPCSRC; from 1.11 88/03/14 SMI
|
|
||||||
.TH GETRPCENT 3N "14 December 1987"
|
|
||||||
.SH NAME
|
|
||||||
getrpcent, getrpcbyname, getrpcbynumber \- get RPC entry
|
|
||||||
.SH SYNOPSIS
|
|
||||||
.nf
|
|
||||||
.ft B
|
|
||||||
#include <netdb.h>
|
|
||||||
.LP
|
|
||||||
.ft B
|
|
||||||
struct rpcent *getrpcent(\|)
|
|
||||||
.LP
|
|
||||||
.ft B
|
|
||||||
struct rpcent *getrpcbyname(name)
|
|
||||||
char *name;
|
|
||||||
.LP
|
|
||||||
.ft B
|
|
||||||
struct rpcent *getrpcbynumber(number)
|
|
||||||
int number;
|
|
||||||
.LP
|
|
||||||
.ft B
|
|
||||||
setrpcent (stayopen)
|
|
||||||
int stayopen
|
|
||||||
.LP
|
|
||||||
.ft B
|
|
||||||
endrpcent (\|)
|
|
||||||
.fi
|
|
||||||
.SH DESCRIPTION
|
|
||||||
.LP
|
|
||||||
.BR getrpcent(\|) ,
|
|
||||||
.BR getrpcbyname(\|) ,
|
|
||||||
and
|
|
||||||
.B getrpcbynumber(\|)
|
|
||||||
each return a pointer to an object with the
|
|
||||||
following structure
|
|
||||||
containing the broken-out
|
|
||||||
fields of a line in the rpc program number data base,
|
|
||||||
.BR /etc/rpc .
|
|
||||||
.RS
|
|
||||||
.LP
|
|
||||||
.nf
|
|
||||||
.ft B
|
|
||||||
struct rpcent {
|
|
||||||
char *r_name; /* name of server for this rpc program */
|
|
||||||
char **r_aliases; /* alias list */
|
|
||||||
long r_number; /* rpc program number */
|
|
||||||
};
|
|
||||||
.ft R
|
|
||||||
.fi
|
|
||||||
.RE
|
|
||||||
.LP
|
|
||||||
The members of this structure are:
|
|
||||||
.RS
|
|
||||||
.PD 0
|
|
||||||
.TP 20
|
|
||||||
.B r_name
|
|
||||||
The name of the server for this rpc program.
|
|
||||||
.TP 20
|
|
||||||
.B r_aliases
|
|
||||||
A zero terminated list of alternate names for the rpc program.
|
|
||||||
.TP 20
|
|
||||||
.B r_number
|
|
||||||
The rpc program number for this service.
|
|
||||||
.PD
|
|
||||||
.RE
|
|
||||||
.LP
|
|
||||||
.B getrpcent(\|)
|
|
||||||
reads the next line of the file, opening the file if necessary.
|
|
||||||
.LP
|
|
||||||
.B getrpcent(\|)
|
|
||||||
opens and rewinds the file. If the
|
|
||||||
.I stayopen
|
|
||||||
flag is non-zero,
|
|
||||||
the net data base will not be closed after each call to
|
|
||||||
.B getrpcent(\|)
|
|
||||||
(either directly, or indirectly through one of
|
|
||||||
the other \*(lqgetrpc\*(rq calls).
|
|
||||||
.LP
|
|
||||||
.B endrpcent
|
|
||||||
closes the file.
|
|
||||||
.LP
|
|
||||||
.B getrpcbyname(\|)
|
|
||||||
and
|
|
||||||
.B getrpcbynumber(\|)
|
|
||||||
sequentially search from the beginning
|
|
||||||
of the file until a matching rpc program name or
|
|
||||||
program number is found, or until end-of-file is encountered.
|
|
||||||
.SH FILES
|
|
||||||
.PD 0
|
|
||||||
.TP 20
|
|
||||||
.B /etc/rpc
|
|
||||||
.PD
|
|
||||||
.SH "SEE ALSO"
|
|
||||||
.BR rpc (5),
|
|
||||||
.BR rpcinfo (8C),
|
|
||||||
.BR ypserv (8)
|
|
||||||
.SH DIAGNOSTICS
|
|
||||||
.LP
|
|
||||||
A
|
|
||||||
.SM NULL
|
|
||||||
pointer is returned on
|
|
||||||
.SM EOF
|
|
||||||
or error.
|
|
||||||
.SH BUGS
|
|
||||||
.LP
|
|
||||||
All information
|
|
||||||
is contained in a static area
|
|
||||||
so it must be copied if it is
|
|
||||||
to be saved.
|
|
@ -1,31 +0,0 @@
|
|||||||
.\" @(#)getrpcport.3r 2.2 88/08/02 4.0 RPCSRC; from 1.12 88/02/26 SMI
|
|
||||||
.TH GETRPCPORT 3R "6 October 1987"
|
|
||||||
.SH NAME
|
|
||||||
getrpcport \- get RPC port number
|
|
||||||
.SH SYNOPSIS
|
|
||||||
.ft B
|
|
||||||
.nf
|
|
||||||
int getrpcport(host, prognum, versnum, proto)
|
|
||||||
char *host;
|
|
||||||
int prognum, versnum, proto;
|
|
||||||
.fi
|
|
||||||
.SH DESCRIPTION
|
|
||||||
.IX getrpcport "" "\fLgetrpcport\fR \(em get RPC port number"
|
|
||||||
.B getrpcport(\|)
|
|
||||||
returns the port number for version
|
|
||||||
.I versnum
|
|
||||||
of the RPC program
|
|
||||||
.I prognum
|
|
||||||
running on
|
|
||||||
.I host
|
|
||||||
and using protocol
|
|
||||||
.IR proto .
|
|
||||||
It returns 0 if it cannot contact the portmapper, or if
|
|
||||||
.I prognum
|
|
||||||
is not registered. If
|
|
||||||
.I prognum
|
|
||||||
is registered but not with version
|
|
||||||
.IR versnum ,
|
|
||||||
it will still return a port number (for some version of the program)
|
|
||||||
indicating that the program is indeed registered.
|
|
||||||
The version mismatch will be detected upon the first call to the service.
|
|
File diff suppressed because it is too large
Load Diff
@ -1,823 +0,0 @@
|
|||||||
.\" @(#)xdr.3n 2.2 88/08/03 4.0 RPCSRC; from 1.16 88/03/14 SMI
|
|
||||||
.TH XDR 3N "16 February 1988"
|
|
||||||
.SH NAME
|
|
||||||
xdr \- library routines for external data representation
|
|
||||||
.SH SYNOPSIS AND DESCRIPTION
|
|
||||||
.LP
|
|
||||||
These routines allow C programmers to describe
|
|
||||||
arbitrary data structures in a machine-independent fashion.
|
|
||||||
Data for remote procedure calls are transmitted using these
|
|
||||||
routines.
|
|
||||||
.LP
|
|
||||||
.ft B
|
|
||||||
.nf
|
|
||||||
.sp .5
|
|
||||||
xdr_array(xdrs, arrp, sizep, maxsize, elsize, elproc)
|
|
||||||
\s-1XDR\s0 *xdrs;
|
|
||||||
char **arrp;
|
|
||||||
u_int *sizep, maxsize, elsize;
|
|
||||||
xdrproc_t elproc;
|
|
||||||
.fi
|
|
||||||
.ft R
|
|
||||||
.IP
|
|
||||||
A filter primitive that translates between variable-length
|
|
||||||
arrays
|
|
||||||
and their corresponding external representations. The
|
|
||||||
parameter
|
|
||||||
.I arrp
|
|
||||||
is the address of the pointer to the array, while
|
|
||||||
.I sizep
|
|
||||||
is the address of the element count of the array;
|
|
||||||
this element count cannot exceed
|
|
||||||
.IR maxsize .
|
|
||||||
The parameter
|
|
||||||
.I elsize
|
|
||||||
is the
|
|
||||||
.I sizeof
|
|
||||||
each of the array's elements, and
|
|
||||||
.I elproc
|
|
||||||
is an
|
|
||||||
.SM XDR
|
|
||||||
filter that translates between
|
|
||||||
the array elements' C form, and their external
|
|
||||||
representation.
|
|
||||||
This routine returns one if it succeeds, zero otherwise.
|
|
||||||
.br
|
|
||||||
.if t .ne 8
|
|
||||||
.LP
|
|
||||||
.ft B
|
|
||||||
.nf
|
|
||||||
.sp .5
|
|
||||||
xdr_bool(xdrs, bp)
|
|
||||||
\s-1XDR\s0 *xdrs;
|
|
||||||
bool_t *bp;
|
|
||||||
.fi
|
|
||||||
.ft R
|
|
||||||
.IP
|
|
||||||
A filter primitive that translates between booleans (C
|
|
||||||
integers)
|
|
||||||
and their external representations. When encoding data, this
|
|
||||||
filter produces values of either one or zero.
|
|
||||||
This routine returns one if it succeeds, zero otherwise.
|
|
||||||
.br
|
|
||||||
.if t .ne 10
|
|
||||||
.LP
|
|
||||||
.ft B
|
|
||||||
.nf
|
|
||||||
.sp .5
|
|
||||||
xdr_bytes(xdrs, sp, sizep, maxsize)
|
|
||||||
\s-1XDR\s0 *xdrs;
|
|
||||||
char **sp;
|
|
||||||
u_int *sizep, maxsize;
|
|
||||||
.fi
|
|
||||||
.ft R
|
|
||||||
.IP
|
|
||||||
A filter primitive that translates between counted byte
|
|
||||||
strings and their external representations.
|
|
||||||
The parameter
|
|
||||||
.I sp
|
|
||||||
is the address of the string pointer. The length of the
|
|
||||||
string is located at address
|
|
||||||
.IR sizep ;
|
|
||||||
strings cannot be longer than
|
|
||||||
.IR maxsize .
|
|
||||||
This routine returns one if it succeeds, zero otherwise.
|
|
||||||
.br
|
|
||||||
.if t .ne 7
|
|
||||||
.LP
|
|
||||||
.ft B
|
|
||||||
.nf
|
|
||||||
.sp .5
|
|
||||||
xdr_char(xdrs, cp)
|
|
||||||
\s-1XDR\s0 *xdrs;
|
|
||||||
char *cp;
|
|
||||||
.fi
|
|
||||||
.ft R
|
|
||||||
.IP
|
|
||||||
A filter primitive that translates between C characters
|
|
||||||
and their external representations.
|
|
||||||
This routine returns one if it succeeds, zero otherwise.
|
|
||||||
Note: encoded characters are not packed, and occupy 4 bytes
|
|
||||||
each. For arrays of characters, it is worthwhile to
|
|
||||||
consider
|
|
||||||
.BR xdr_bytes(\|) ,
|
|
||||||
.B xdr_opaque(\|)
|
|
||||||
or
|
|
||||||
.BR xdr_string(\|) .
|
|
||||||
.br
|
|
||||||
.if t .ne 8
|
|
||||||
.LP
|
|
||||||
.ft B
|
|
||||||
.nf
|
|
||||||
.sp .5
|
|
||||||
void
|
|
||||||
xdr_destroy(xdrs)
|
|
||||||
\s-1XDR\s0 *xdrs;
|
|
||||||
.fi
|
|
||||||
.ft R
|
|
||||||
.IP
|
|
||||||
A macro that invokes the destroy routine associated with the
|
|
||||||
.SM XDR
|
|
||||||
stream,
|
|
||||||
.IR xdrs .
|
|
||||||
Destruction usually involves freeing private data structures
|
|
||||||
associated with the stream. Using
|
|
||||||
.I xdrs
|
|
||||||
after invoking
|
|
||||||
.B xdr_destroy(\|)
|
|
||||||
is undefined.
|
|
||||||
.br
|
|
||||||
.if t .ne 7
|
|
||||||
.LP
|
|
||||||
.ft B
|
|
||||||
.nf
|
|
||||||
.sp .5
|
|
||||||
xdr_double(xdrs, dp)
|
|
||||||
\s-1XDR\s0 *xdrs;
|
|
||||||
double *dp;
|
|
||||||
.fi
|
|
||||||
.ft R
|
|
||||||
.IP
|
|
||||||
A filter primitive that translates between C
|
|
||||||
.B double
|
|
||||||
precision numbers and their external representations.
|
|
||||||
This routine returns one if it succeeds, zero otherwise.
|
|
||||||
.br
|
|
||||||
.if t .ne 7
|
|
||||||
.LP
|
|
||||||
.ft B
|
|
||||||
.nf
|
|
||||||
.sp .5
|
|
||||||
xdr_enum(xdrs, ep)
|
|
||||||
\s-1XDR\s0 *xdrs;
|
|
||||||
enum_t *ep;
|
|
||||||
.fi
|
|
||||||
.ft R
|
|
||||||
.IP
|
|
||||||
A filter primitive that translates between C
|
|
||||||
.BR enum s
|
|
||||||
(actually integers) and their external representations.
|
|
||||||
This routine returns one if it succeeds, zero otherwise.
|
|
||||||
.br
|
|
||||||
.if t .ne 8
|
|
||||||
.LP
|
|
||||||
.ft B
|
|
||||||
.nf
|
|
||||||
.sp .5
|
|
||||||
xdr_float(xdrs, fp)
|
|
||||||
\s-1XDR\s0 *xdrs;
|
|
||||||
float *fp;
|
|
||||||
.fi
|
|
||||||
.ft R
|
|
||||||
.IP
|
|
||||||
A filter primitive that translates between C
|
|
||||||
.BR float s
|
|
||||||
and their external representations.
|
|
||||||
This routine returns one if it succeeds, zero otherwise.
|
|
||||||
.br
|
|
||||||
.if t .ne 9
|
|
||||||
.LP
|
|
||||||
.ft B
|
|
||||||
.nf
|
|
||||||
.sp .5
|
|
||||||
void
|
|
||||||
xdr_free(proc, objp)
|
|
||||||
xdrproc_t proc;
|
|
||||||
char *objp;
|
|
||||||
.fi
|
|
||||||
.ft R
|
|
||||||
.IP
|
|
||||||
Generic freeing routine. The first argument is the
|
|
||||||
.SM XDR
|
|
||||||
routine for the object being freed. The second argument
|
|
||||||
is a pointer to the object itself. Note: the pointer passed
|
|
||||||
to this routine is
|
|
||||||
.I not
|
|
||||||
freed, but what it points to
|
|
||||||
.I is
|
|
||||||
freed (recursively).
|
|
||||||
.br
|
|
||||||
.if t .ne 8
|
|
||||||
.LP
|
|
||||||
.ft B
|
|
||||||
.nf
|
|
||||||
.sp .5
|
|
||||||
u_int
|
|
||||||
xdr_getpos(xdrs)
|
|
||||||
\s-1XDR\s0 *xdrs;
|
|
||||||
.fi
|
|
||||||
.ft R
|
|
||||||
.IP
|
|
||||||
A macro that invokes the get-position routine
|
|
||||||
associated with the
|
|
||||||
.SM XDR
|
|
||||||
stream,
|
|
||||||
.IR xdrs .
|
|
||||||
The routine returns an unsigned integer,
|
|
||||||
which indicates the position of the
|
|
||||||
.SM XDR
|
|
||||||
byte stream.
|
|
||||||
A desirable feature of
|
|
||||||
.SM XDR
|
|
||||||
streams is that simple arithmetic works with this number,
|
|
||||||
although the
|
|
||||||
.SM XDR
|
|
||||||
stream instances need not guarantee this.
|
|
||||||
.br
|
|
||||||
.if t .ne 4
|
|
||||||
.LP
|
|
||||||
.ft B
|
|
||||||
.nf
|
|
||||||
.sp .5
|
|
||||||
.br
|
|
||||||
long *
|
|
||||||
xdr_inline(xdrs, len)
|
|
||||||
\s-1XDR\s0 *xdrs;
|
|
||||||
int len;
|
|
||||||
.fi
|
|
||||||
.ft R
|
|
||||||
.IP
|
|
||||||
A macro that invokes the in-line routine associated with the
|
|
||||||
.SM XDR
|
|
||||||
stream,
|
|
||||||
.IR xdrs .
|
|
||||||
The routine returns a pointer
|
|
||||||
to a contiguous piece of the stream's buffer;
|
|
||||||
.I len
|
|
||||||
is the byte length of the desired buffer.
|
|
||||||
Note: pointer is cast to
|
|
||||||
.BR "long *" .
|
|
||||||
.IP
|
|
||||||
Warning:
|
|
||||||
.B xdr_inline(\|)
|
|
||||||
may return
|
|
||||||
.SM NULL
|
|
||||||
(0)
|
|
||||||
if it cannot allocate a contiguous piece of a buffer.
|
|
||||||
Therefore the behavior may vary among stream instances;
|
|
||||||
it exists for the sake of efficiency.
|
|
||||||
.br
|
|
||||||
.if t .ne 7
|
|
||||||
.LP
|
|
||||||
.ft B
|
|
||||||
.nf
|
|
||||||
.sp .5
|
|
||||||
xdr_int(xdrs, ip)
|
|
||||||
\s-1XDR\s0 *xdrs;
|
|
||||||
int *ip;
|
|
||||||
.fi
|
|
||||||
.ft R
|
|
||||||
.IP
|
|
||||||
A filter primitive that translates between C integers
|
|
||||||
and their external representations.
|
|
||||||
This routine returns one if it succeeds, zero otherwise.
|
|
||||||
.br
|
|
||||||
.if t .ne 7
|
|
||||||
.LP
|
|
||||||
.ft B
|
|
||||||
.nf
|
|
||||||
.sp .5
|
|
||||||
xdr_long(xdrs, lp)
|
|
||||||
\s-1XDR\s0 *xdrs;
|
|
||||||
long *lp;
|
|
||||||
.fi
|
|
||||||
.ft R
|
|
||||||
.IP
|
|
||||||
A filter primitive that translates between C
|
|
||||||
.B long
|
|
||||||
integers and their external representations.
|
|
||||||
This routine returns one if it succeeds, zero otherwise.
|
|
||||||
.br
|
|
||||||
.if t .ne 12
|
|
||||||
.LP
|
|
||||||
.ft B
|
|
||||||
.nf
|
|
||||||
.sp .5
|
|
||||||
void
|
|
||||||
xdrmem_create(xdrs, addr, size, op)
|
|
||||||
\s-1XDR\s0 *xdrs;
|
|
||||||
char *addr;
|
|
||||||
u_int size;
|
|
||||||
enum xdr_op op;
|
|
||||||
.fi
|
|
||||||
.ft R
|
|
||||||
.IP
|
|
||||||
This routine initializes the
|
|
||||||
.SM XDR
|
|
||||||
stream object pointed to by
|
|
||||||
.IR xdrs .
|
|
||||||
The stream's data is written to, or read from,
|
|
||||||
a chunk of memory at location
|
|
||||||
.I addr
|
|
||||||
whose length is no more than
|
|
||||||
.I size
|
|
||||||
bytes long. The
|
|
||||||
.I op
|
|
||||||
determines the direction of the
|
|
||||||
.SM XDR
|
|
||||||
stream
|
|
||||||
(either
|
|
||||||
.BR \s-1XDR_ENCODE\s0 ,
|
|
||||||
.BR \s-1XDR_DECODE\s0 ,
|
|
||||||
or
|
|
||||||
.BR \s-1XDR_FREE\s0 ).
|
|
||||||
.br
|
|
||||||
.if t .ne 10
|
|
||||||
.LP
|
|
||||||
.ft B
|
|
||||||
.nf
|
|
||||||
.sp .5
|
|
||||||
xdr_opaque(xdrs, cp, cnt)
|
|
||||||
\s-1XDR\s0 *xdrs;
|
|
||||||
char *cp;
|
|
||||||
u_int cnt;
|
|
||||||
.fi
|
|
||||||
.ft R
|
|
||||||
.IP
|
|
||||||
A filter primitive that translates between fixed size opaque
|
|
||||||
data
|
|
||||||
and its external representation.
|
|
||||||
The parameter
|
|
||||||
.I cp
|
|
||||||
is the address of the opaque object, and
|
|
||||||
.I cnt
|
|
||||||
is its size in bytes.
|
|
||||||
This routine returns one if it succeeds, zero otherwise.
|
|
||||||
.br
|
|
||||||
.if t .ne 10
|
|
||||||
.LP
|
|
||||||
.ft B
|
|
||||||
.nf
|
|
||||||
.sp .5
|
|
||||||
xdr_pointer(xdrs, objpp, objsize, xdrobj)
|
|
||||||
\s-1XDR\s0 *xdrs;
|
|
||||||
char **objpp;
|
|
||||||
u_int objsize;
|
|
||||||
xdrproc_t xdrobj;
|
|
||||||
.fi
|
|
||||||
.ft R
|
|
||||||
.IP
|
|
||||||
Like
|
|
||||||
.B xdr_reference(\|)
|
|
||||||
execpt that it serializes
|
|
||||||
.SM NULL
|
|
||||||
pointers, whereas
|
|
||||||
.B xdr_reference(\|)
|
|
||||||
does not. Thus,
|
|
||||||
.B xdr_pointer(\|)
|
|
||||||
can represent
|
|
||||||
recursive data structures, such as binary trees or
|
|
||||||
linked lists.
|
|
||||||
.br
|
|
||||||
.if t .ne 15
|
|
||||||
.LP
|
|
||||||
.ft B
|
|
||||||
.nf
|
|
||||||
.sp .5
|
|
||||||
void
|
|
||||||
xdrrec_create(xdrs, sendsize, recvsize, handle, readit, writeit)
|
|
||||||
\s-1XDR\s0 *xdrs;
|
|
||||||
u_int sendsize, recvsize;
|
|
||||||
char *handle;
|
|
||||||
int (*readit) (\|), (*writeit) (\|);
|
|
||||||
.fi
|
|
||||||
.ft R
|
|
||||||
.IP
|
|
||||||
This routine initializes the
|
|
||||||
.SM XDR
|
|
||||||
stream object pointed to by
|
|
||||||
.IR xdrs .
|
|
||||||
The stream's data is written to a buffer of size
|
|
||||||
.IR sendsize ;
|
|
||||||
a value of zero indicates the system should use a suitable
|
|
||||||
default. The stream's data is read from a buffer of size
|
|
||||||
.IR recvsize ;
|
|
||||||
it too can be set to a suitable default by passing a zero
|
|
||||||
value.
|
|
||||||
When a stream's output buffer is full,
|
|
||||||
.I writeit
|
|
||||||
is called. Similarly, when a stream's input buffer is empty,
|
|
||||||
.I readit
|
|
||||||
is called. The behavior of these two routines is similar to
|
|
||||||
the
|
|
||||||
system calls
|
|
||||||
.B read
|
|
||||||
and
|
|
||||||
.BR write ,
|
|
||||||
except that
|
|
||||||
.I handle
|
|
||||||
is passed to the former routines as the first parameter.
|
|
||||||
Note: the
|
|
||||||
.SM XDR
|
|
||||||
stream's
|
|
||||||
.I op
|
|
||||||
field must be set by the caller.
|
|
||||||
.IP
|
|
||||||
Warning: this
|
|
||||||
.SM XDR
|
|
||||||
stream implements an intermediate record stream.
|
|
||||||
Therefore there are additional bytes in the stream
|
|
||||||
to provide record boundary information.
|
|
||||||
.br
|
|
||||||
.if t .ne 9
|
|
||||||
.LP
|
|
||||||
.ft B
|
|
||||||
.nf
|
|
||||||
.sp .5
|
|
||||||
xdrrec_endofrecord(xdrs, sendnow)
|
|
||||||
\s-1XDR\s0 *xdrs;
|
|
||||||
int sendnow;
|
|
||||||
.fi
|
|
||||||
.ft R
|
|
||||||
.IP
|
|
||||||
This routine can be invoked only on
|
|
||||||
streams created by
|
|
||||||
.BR xdrrec_create(\|) .
|
|
||||||
The data in the output buffer is marked as a completed
|
|
||||||
record,
|
|
||||||
and the output buffer is optionally written out if
|
|
||||||
.I sendnow
|
|
||||||
is non-zero. This routine returns one if it succeeds, zero
|
|
||||||
otherwise.
|
|
||||||
.br
|
|
||||||
.if t .ne 8
|
|
||||||
.LP
|
|
||||||
.ft B
|
|
||||||
.nf
|
|
||||||
.sp .5
|
|
||||||
xdrrec_eof(xdrs)
|
|
||||||
\s-1XDR\s0 *xdrs;
|
|
||||||
int empty;
|
|
||||||
.fi
|
|
||||||
.ft R
|
|
||||||
.IP
|
|
||||||
This routine can be invoked only on
|
|
||||||
streams created by
|
|
||||||
.BR xdrrec_create(\|) .
|
|
||||||
After consuming the rest of the current record in the stream,
|
|
||||||
this routine returns one if the stream has no more input,
|
|
||||||
zero otherwise.
|
|
||||||
.br
|
|
||||||
.if t .ne 3
|
|
||||||
.LP
|
|
||||||
.ft B
|
|
||||||
.nf
|
|
||||||
.sp .5
|
|
||||||
xdrrec_skiprecord(xdrs)
|
|
||||||
\s-1XDR\s0 *xdrs;
|
|
||||||
.fi
|
|
||||||
.ft R
|
|
||||||
.IP
|
|
||||||
This routine can be invoked only on
|
|
||||||
streams created by
|
|
||||||
.BR xdrrec_create(\|) .
|
|
||||||
It tells the
|
|
||||||
.SM XDR
|
|
||||||
implementation that the rest of the current record
|
|
||||||
in the stream's input buffer should be discarded.
|
|
||||||
This routine returns one if it succeeds, zero otherwise.
|
|
||||||
.br
|
|
||||||
.if t .ne 11
|
|
||||||
.LP
|
|
||||||
.ft B
|
|
||||||
.nf
|
|
||||||
.sp .5
|
|
||||||
xdr_reference(xdrs, pp, size, proc)
|
|
||||||
\s-1XDR\s0 *xdrs;
|
|
||||||
char **pp;
|
|
||||||
u_int size;
|
|
||||||
xdrproc_t proc;
|
|
||||||
.fi
|
|
||||||
.ft R
|
|
||||||
.IP
|
|
||||||
A primitive that provides pointer chasing within structures.
|
|
||||||
The parameter
|
|
||||||
.I pp
|
|
||||||
is the address of the pointer;
|
|
||||||
.I size
|
|
||||||
is the
|
|
||||||
.I sizeof
|
|
||||||
the structure that
|
|
||||||
.I *pp
|
|
||||||
points to; and
|
|
||||||
.I proc
|
|
||||||
is an
|
|
||||||
.SM XDR
|
|
||||||
procedure that filters the structure
|
|
||||||
between its C form and its external representation.
|
|
||||||
This routine returns one if it succeeds, zero otherwise.
|
|
||||||
.IP
|
|
||||||
Warning: this routine does not understand
|
|
||||||
.SM NULL
|
|
||||||
pointers. Use
|
|
||||||
.B xdr_pointer(\|)
|
|
||||||
instead.
|
|
||||||
.br
|
|
||||||
.if t .ne 10
|
|
||||||
.LP
|
|
||||||
.ft B
|
|
||||||
.nf
|
|
||||||
.sp .5
|
|
||||||
xdr_setpos(xdrs, pos)
|
|
||||||
\s-1XDR\s0 *xdrs;
|
|
||||||
u_int pos;
|
|
||||||
.fi
|
|
||||||
.ft R
|
|
||||||
.IP
|
|
||||||
A macro that invokes the set position routine associated with
|
|
||||||
the
|
|
||||||
.SM XDR
|
|
||||||
stream
|
|
||||||
.IR xdrs .
|
|
||||||
The parameter
|
|
||||||
.I pos
|
|
||||||
is a position value obtained from
|
|
||||||
.BR xdr_getpos(\|) .
|
|
||||||
This routine returns one if the
|
|
||||||
.SM XDR
|
|
||||||
stream could be repositioned,
|
|
||||||
and zero otherwise.
|
|
||||||
.IP
|
|
||||||
Warning: it is difficult to reposition some types of
|
|
||||||
.SM XDR
|
|
||||||
streams, so this routine may fail with one
|
|
||||||
type of stream and succeed with another.
|
|
||||||
.br
|
|
||||||
.if t .ne 8
|
|
||||||
.LP
|
|
||||||
.ft B
|
|
||||||
.nf
|
|
||||||
.sp .5
|
|
||||||
xdr_short(xdrs, sp)
|
|
||||||
\s-1XDR\s0 *xdrs;
|
|
||||||
short *sp;
|
|
||||||
.fi
|
|
||||||
.ft R
|
|
||||||
.IP
|
|
||||||
A filter primitive that translates between C
|
|
||||||
.B short
|
|
||||||
integers and their external representations.
|
|
||||||
This routine returns one if it succeeds, zero otherwise.
|
|
||||||
.br
|
|
||||||
.if t .ne 10
|
|
||||||
.LP
|
|
||||||
.ft B
|
|
||||||
.nf
|
|
||||||
.sp .5
|
|
||||||
void
|
|
||||||
xdrstdio_create(xdrs, file, op)
|
|
||||||
\s-1XDR\s0 *xdrs;
|
|
||||||
\s-1FILE\s0 *file;
|
|
||||||
enum xdr_op op;
|
|
||||||
.fi
|
|
||||||
.ft R
|
|
||||||
.IP
|
|
||||||
This routine initializes the
|
|
||||||
.SM XDR
|
|
||||||
stream object pointed to by
|
|
||||||
.IR xdrs .
|
|
||||||
The
|
|
||||||
.SM XDR
|
|
||||||
stream data is written to, or read from, the Standard
|
|
||||||
.B I/O
|
|
||||||
stream
|
|
||||||
.IR file .
|
|
||||||
The parameter
|
|
||||||
.I op
|
|
||||||
determines the direction of the
|
|
||||||
.SM XDR
|
|
||||||
stream (either
|
|
||||||
.BR \s-1XDR_ENCODE\s0 ,
|
|
||||||
.BR \s-1XDR_DECODE\s0 ,
|
|
||||||
or
|
|
||||||
.BR \s-1XDR_FREE\s0 ).
|
|
||||||
.IP
|
|
||||||
Warning: the destroy routine associated with such
|
|
||||||
.SM XDR
|
|
||||||
streams calls
|
|
||||||
.B fflush(\|)
|
|
||||||
on the
|
|
||||||
.I file
|
|
||||||
stream, but never
|
|
||||||
.BR fclose(\|) .
|
|
||||||
.br
|
|
||||||
.if t .ne 9
|
|
||||||
.LP
|
|
||||||
.ft B
|
|
||||||
.nf
|
|
||||||
.sp .5
|
|
||||||
xdr_string(xdrs, sp, maxsize)
|
|
||||||
\s-1XDR\s0
|
|
||||||
*xdrs;
|
|
||||||
char **sp;
|
|
||||||
u_int maxsize;
|
|
||||||
.fi
|
|
||||||
.ft R
|
|
||||||
.IP
|
|
||||||
A filter primitive that translates between C strings and
|
|
||||||
their
|
|
||||||
corresponding external representations.
|
|
||||||
Strings cannot be longer than
|
|
||||||
.IR maxsize .
|
|
||||||
Note:
|
|
||||||
.I sp
|
|
||||||
is the address of the string's pointer.
|
|
||||||
This routine returns one if it succeeds, zero otherwise.
|
|
||||||
.br
|
|
||||||
.if t .ne 8
|
|
||||||
.LP
|
|
||||||
.ft B
|
|
||||||
.nf
|
|
||||||
.sp .5
|
|
||||||
xdr_u_char(xdrs, ucp)
|
|
||||||
\s-1XDR\s0 *xdrs;
|
|
||||||
unsigned char *ucp;
|
|
||||||
.fi
|
|
||||||
.ft R
|
|
||||||
.IP
|
|
||||||
A filter primitive that translates between
|
|
||||||
.B unsigned
|
|
||||||
C characters and their external representations.
|
|
||||||
This routine returns one if it succeeds, zero otherwise.
|
|
||||||
.br
|
|
||||||
.if t .ne 9
|
|
||||||
.LP
|
|
||||||
.ft B
|
|
||||||
.nf
|
|
||||||
.sp .5
|
|
||||||
xdr_u_int(xdrs, up)
|
|
||||||
\s-1XDR\s0 *xdrs;
|
|
||||||
unsigned *up;
|
|
||||||
.fi
|
|
||||||
.ft R
|
|
||||||
.IP
|
|
||||||
A filter primitive that translates between C
|
|
||||||
.B unsigned
|
|
||||||
integers and their external representations.
|
|
||||||
This routine returns one if it succeeds, zero otherwise.
|
|
||||||
.br
|
|
||||||
.if t .ne 7
|
|
||||||
.LP
|
|
||||||
.ft B
|
|
||||||
.nf
|
|
||||||
.sp .5
|
|
||||||
xdr_u_long(xdrs, ulp)
|
|
||||||
\s-1XDR\s0 *xdrs;
|
|
||||||
unsigned long *ulp;
|
|
||||||
.fi
|
|
||||||
.ft R
|
|
||||||
.IP
|
|
||||||
A filter primitive that translates between C
|
|
||||||
.B "unsigned long"
|
|
||||||
integers and their external representations.
|
|
||||||
This routine returns one if it succeeds, zero otherwise.
|
|
||||||
.br
|
|
||||||
.if t .ne 7
|
|
||||||
.LP
|
|
||||||
.ft B
|
|
||||||
.nf
|
|
||||||
.sp .5
|
|
||||||
xdr_u_short(xdrs, usp)
|
|
||||||
\s-1XDR\s0 *xdrs;
|
|
||||||
unsigned short *usp;
|
|
||||||
.fi
|
|
||||||
.ft R
|
|
||||||
.IP
|
|
||||||
A filter primitive that translates between C
|
|
||||||
.B "unsigned short"
|
|
||||||
integers and their external representations.
|
|
||||||
This routine returns one if it succeeds, zero otherwise.
|
|
||||||
.br
|
|
||||||
.if t .ne 16
|
|
||||||
.LP
|
|
||||||
.ft B
|
|
||||||
.nf
|
|
||||||
.sp .5
|
|
||||||
xdr_union(xdrs, dscmp, unp, choices, dfault)
|
|
||||||
\s-1XDR\s0 *xdrs;
|
|
||||||
int *dscmp;
|
|
||||||
char *unp;
|
|
||||||
struct xdr_discrim *choices;
|
|
||||||
bool_t (*defaultarm) (\|); /* may equal \s-1NULL\s0 */
|
|
||||||
.fi
|
|
||||||
.ft R
|
|
||||||
.IP
|
|
||||||
A filter primitive that translates between a discriminated C
|
|
||||||
.B union
|
|
||||||
and its corresponding external representation. It first
|
|
||||||
translates the discriminant of the union located at
|
|
||||||
.IR dscmp .
|
|
||||||
This discriminant is always an
|
|
||||||
.BR enum_t .
|
|
||||||
Next the union located at
|
|
||||||
.I unp
|
|
||||||
is translated. The parameter
|
|
||||||
.I choices
|
|
||||||
is a pointer to an array of
|
|
||||||
.B xdr_discrim(\|)
|
|
||||||
structures. Each structure contains an ordered pair of
|
|
||||||
.RI [ value , proc ].
|
|
||||||
If the union's discriminant is equal to the associated
|
|
||||||
.IR value ,
|
|
||||||
then the
|
|
||||||
.I proc
|
|
||||||
is called to translate the union. The end of the
|
|
||||||
.B xdr_discrim(\|)
|
|
||||||
structure array is denoted by a routine of value
|
|
||||||
.SM NULL\s0.
|
|
||||||
If the discriminant is not found in the
|
|
||||||
.I choices
|
|
||||||
array, then the
|
|
||||||
.I defaultarm
|
|
||||||
procedure is called (if it is not
|
|
||||||
.SM NULL\s0).
|
|
||||||
Returns one if it succeeds, zero otherwise.
|
|
||||||
.br
|
|
||||||
.if t .ne 6
|
|
||||||
.LP
|
|
||||||
.ft B
|
|
||||||
.nf
|
|
||||||
.sp .5
|
|
||||||
xdr_vector(xdrs, arrp, size, elsize, elproc)
|
|
||||||
\s-1XDR\s0 *xdrs;
|
|
||||||
char *arrp;
|
|
||||||
u_int size, elsize;
|
|
||||||
xdrproc_t elproc;
|
|
||||||
.fi
|
|
||||||
.ft R
|
|
||||||
.IP
|
|
||||||
A filter primitive that translates between fixed-length
|
|
||||||
arrays
|
|
||||||
and their corresponding external representations. The
|
|
||||||
parameter
|
|
||||||
.I arrp
|
|
||||||
is the address of the pointer to the array, while
|
|
||||||
.I size
|
|
||||||
is is the element count of the array. The parameter
|
|
||||||
.I elsize
|
|
||||||
is the
|
|
||||||
.I sizeof
|
|
||||||
each of the array's elements, and
|
|
||||||
.I elproc
|
|
||||||
is an
|
|
||||||
.SM XDR
|
|
||||||
filter that translates between
|
|
||||||
the array elements' C form, and their external
|
|
||||||
representation.
|
|
||||||
This routine returns one if it succeeds, zero otherwise.
|
|
||||||
.br
|
|
||||||
.if t .ne 5
|
|
||||||
.LP
|
|
||||||
.ft B
|
|
||||||
.nf
|
|
||||||
.sp .5
|
|
||||||
xdr_void(\|)
|
|
||||||
.fi
|
|
||||||
.ft R
|
|
||||||
.IP
|
|
||||||
This routine always returns one.
|
|
||||||
It may be passed to
|
|
||||||
.SM RPC
|
|
||||||
routines that require a function parameter,
|
|
||||||
where nothing is to be done.
|
|
||||||
.br
|
|
||||||
.if t .ne 10
|
|
||||||
.LP
|
|
||||||
.ft B
|
|
||||||
.nf
|
|
||||||
.sp .5
|
|
||||||
xdr_wrapstring(xdrs, sp)
|
|
||||||
\s-1XDR\s0 *xdrs;
|
|
||||||
char **sp;
|
|
||||||
.fi
|
|
||||||
.ft R
|
|
||||||
.IP
|
|
||||||
A primitive that calls
|
|
||||||
.B "xdr_string(xdrs, sp,\s-1MAXUN.UNSIGNED\s0 );"
|
|
||||||
where
|
|
||||||
.B
|
|
||||||
.SM MAXUN.UNSIGNED
|
|
||||||
is the maximum value of an unsigned integer.
|
|
||||||
.B xdr_wrapstring(\|)
|
|
||||||
is handy because the
|
|
||||||
.SM RPC
|
|
||||||
package passes a maximum of two
|
|
||||||
.SM XDR
|
|
||||||
routines as parameters, and
|
|
||||||
.BR xdr_string(\|) ,
|
|
||||||
one of the most frequently used primitives, requires three.
|
|
||||||
Returns one if it succeeds, zero otherwise.
|
|
||||||
.SH SEE ALSO
|
|
||||||
.BR rpc (3N)
|
|
||||||
.LP
|
|
||||||
The following manuals:
|
|
||||||
.RS
|
|
||||||
.ft I
|
|
||||||
eXternal Data Representation Standard: Protocol Specification
|
|
||||||
.br
|
|
||||||
eXternal Data Representation: Sun Technical Notes
|
|
||||||
.ft R
|
|
||||||
.br
|
|
||||||
.IR "\s-1XDR\s0: External Data Representation Standard" ,
|
|
||||||
.SM RFC1014, Sun Microsystems, Inc.,
|
|
||||||
.SM USC-ISI\s0.
|
|
@ -1,71 +0,0 @@
|
|||||||
.\" @(#)rpc.5 2.2 88/08/03 4.0 RPCSRC; from 1.4 87/11/27 SMI;
|
|
||||||
.TH RPC 5 "26 September 1985"
|
|
||||||
.SH NAME
|
|
||||||
rpc \- rpc program number data base
|
|
||||||
.SH SYNOPSIS
|
|
||||||
.B /etc/rpc
|
|
||||||
.SH DESCRIPTION
|
|
||||||
The
|
|
||||||
.I rpc
|
|
||||||
file contains user readable names that
|
|
||||||
can be used in place of rpc program numbers.
|
|
||||||
Each line has the following information:
|
|
||||||
.HP 10
|
|
||||||
name of server for the rpc program
|
|
||||||
.br
|
|
||||||
.ns
|
|
||||||
.HP 10
|
|
||||||
rpc program number
|
|
||||||
.br
|
|
||||||
.ns
|
|
||||||
.HP 10
|
|
||||||
aliases
|
|
||||||
.LP
|
|
||||||
Items are separated by any number of blanks and/or
|
|
||||||
tab characters.
|
|
||||||
A ``#'' indicates the beginning of a comment; characters up to the end of
|
|
||||||
the line are not interpreted by routines which search the file.
|
|
||||||
.LP
|
|
||||||
Here is an example of the \fI/etc/rpc\fP file from the Sun RPC Source
|
|
||||||
distribution.
|
|
||||||
.nf
|
|
||||||
.ta 1.5i +0.5i +1.0i +1.0i
|
|
||||||
#
|
|
||||||
# rpc 88/08/01 4.0 RPCSRC; from 1.12 88/02/07 SMI
|
|
||||||
#
|
|
||||||
portmapper 100000 portmap sunrpc
|
|
||||||
rstatd 100001 rstat rstat_svc rup perfmeter
|
|
||||||
rusersd 100002 rusers
|
|
||||||
nfs 100003 nfsprog
|
|
||||||
ypserv 100004 ypprog
|
|
||||||
mountd 100005 mount showmount
|
|
||||||
ypbind 100007
|
|
||||||
walld 100008 rwall shutdown
|
|
||||||
yppasswdd 100009 yppasswd
|
|
||||||
etherstatd 100010 etherstat
|
|
||||||
rquotad 100011 rquotaprog quota rquota
|
|
||||||
sprayd 100012 spray
|
|
||||||
3270_mapper 100013
|
|
||||||
rje_mapper 100014
|
|
||||||
selection_svc 100015 selnsvc
|
|
||||||
database_svc 100016
|
|
||||||
rexd 100017 rex
|
|
||||||
alis 100018
|
|
||||||
sched 100019
|
|
||||||
llockmgr 100020
|
|
||||||
nlockmgr 100021
|
|
||||||
x25.inr 100022
|
|
||||||
statmon 100023
|
|
||||||
status 100024
|
|
||||||
bootparam 100026
|
|
||||||
ypupdated 100028 ypupdate
|
|
||||||
keyserv 100029 keyserver
|
|
||||||
tfsd 100037
|
|
||||||
nsed 100038
|
|
||||||
nsemntd 100039
|
|
||||||
.fi
|
|
||||||
.DT
|
|
||||||
.SH FILES
|
|
||||||
/etc/rpc
|
|
||||||
.SH "SEE ALSO"
|
|
||||||
getrpcent(3N)
|
|
@ -1,53 +0,0 @@
|
|||||||
.\" @(#)portmap.8c 2.2 88/08/03 4.0 RPCSRC; from 1.10 88/03/14 SMI
|
|
||||||
.TH PORTMAP 8C "9 September 1987"
|
|
||||||
.SH NAME
|
|
||||||
portmap \- DARPA port to RPC program number mapper
|
|
||||||
.SH SYNOPSIS
|
|
||||||
.B /usr/etc/rpc.portmap
|
|
||||||
.SH DESCRIPTION
|
|
||||||
.IX "portmap command" "" "\fLportmap\fP \(em DARPA to RPC mapper"
|
|
||||||
.IX DARPA "to RPC mapper \(em \fLportmap\fP"
|
|
||||||
.B portmap
|
|
||||||
is a server that converts
|
|
||||||
.SM RPC
|
|
||||||
program numbers into
|
|
||||||
.SM DARPA
|
|
||||||
protocol port numbers.
|
|
||||||
It must be running in order to make
|
|
||||||
.SM RPC
|
|
||||||
calls.
|
|
||||||
.LP
|
|
||||||
When an
|
|
||||||
.SM RPC
|
|
||||||
server is started, it will tell
|
|
||||||
.B portmap
|
|
||||||
what port number it is listening to, and what
|
|
||||||
.SM RPC
|
|
||||||
program numbers it is prepared to serve.
|
|
||||||
When a client wishes to make an
|
|
||||||
.SM RPC
|
|
||||||
call to a given program number,
|
|
||||||
it will first contact
|
|
||||||
.B portmap
|
|
||||||
on the server machine to determine
|
|
||||||
the port number where
|
|
||||||
.SM RPC
|
|
||||||
packets should be sent.
|
|
||||||
.LP
|
|
||||||
Normally, standard
|
|
||||||
.SM RPC
|
|
||||||
servers are started by
|
|
||||||
.BR inetd (8C),
|
|
||||||
so
|
|
||||||
.B portmap
|
|
||||||
must be started before
|
|
||||||
.B inetd
|
|
||||||
is invoked.
|
|
||||||
.SH "SEE ALSO"
|
|
||||||
.BR inetd.conf (5),
|
|
||||||
.BR rpcinfo (8),
|
|
||||||
.BR inetd (8)
|
|
||||||
.SH BUGS
|
|
||||||
If
|
|
||||||
.B portmap
|
|
||||||
crashes, all servers must be restarted.
|
|
@ -1,183 +0,0 @@
|
|||||||
.\" @(#)rpcinfo.8c 2.2 88/08/03 4.0 RPCSRC; from 1.24 88/02/25 SMI
|
|
||||||
.TH RPCINFO 8C "17 December 1987"
|
|
||||||
.SH NAME
|
|
||||||
rpcinfo \- report RPC information
|
|
||||||
.SH SYNOPSIS
|
|
||||||
.B "rpcinfo \-p"
|
|
||||||
[
|
|
||||||
.I host
|
|
||||||
]
|
|
||||||
.LP
|
|
||||||
.B "rpcinfo"
|
|
||||||
[
|
|
||||||
.B \-n
|
|
||||||
.I portnum
|
|
||||||
]
|
|
||||||
.B \-u
|
|
||||||
.I host
|
|
||||||
.I program
|
|
||||||
[
|
|
||||||
.I version
|
|
||||||
]
|
|
||||||
.LP
|
|
||||||
.B "rpcinfo"
|
|
||||||
[
|
|
||||||
.B \-n
|
|
||||||
.I portnum
|
|
||||||
]
|
|
||||||
.B \-t
|
|
||||||
.I host
|
|
||||||
.I program
|
|
||||||
[
|
|
||||||
.I version
|
|
||||||
]
|
|
||||||
.LP
|
|
||||||
.B "rpcinfo \-b"
|
|
||||||
.I program
|
|
||||||
.I version
|
|
||||||
.LP
|
|
||||||
.B "rpcinfo \-d"
|
|
||||||
.I program
|
|
||||||
.I version
|
|
||||||
.SH DESCRIPTION
|
|
||||||
.B rpcinfo
|
|
||||||
makes an
|
|
||||||
.SM RPC
|
|
||||||
call to an
|
|
||||||
.SM RPC
|
|
||||||
server and reports what it finds.
|
|
||||||
.SH OPTIONS
|
|
||||||
.TP
|
|
||||||
.B \-p
|
|
||||||
Probe the portmapper on
|
|
||||||
.IR host ,
|
|
||||||
and print a list of all registered
|
|
||||||
.SM RPC
|
|
||||||
programs. If
|
|
||||||
.I host
|
|
||||||
is not specified, it defaults to the value returned by
|
|
||||||
.BR hostname (1).
|
|
||||||
.TP
|
|
||||||
.B \-u
|
|
||||||
Make an
|
|
||||||
.SM RPC
|
|
||||||
call to procedure 0 of
|
|
||||||
.I program
|
|
||||||
on the specified
|
|
||||||
.I host
|
|
||||||
using
|
|
||||||
.SM UDP\s0,
|
|
||||||
and report whether a response was received.
|
|
||||||
.TP
|
|
||||||
.B \-t
|
|
||||||
Make an
|
|
||||||
.SM RPC
|
|
||||||
call to procedure 0 of
|
|
||||||
.I program
|
|
||||||
on the specified
|
|
||||||
.I host
|
|
||||||
using
|
|
||||||
.SM TCP\s0,
|
|
||||||
and report whether a response was received.
|
|
||||||
.TP
|
|
||||||
.B \-n
|
|
||||||
Use
|
|
||||||
.I portnum
|
|
||||||
as the port number for the
|
|
||||||
.I \-t
|
|
||||||
and
|
|
||||||
.I \-u
|
|
||||||
options instead of the port number given by the portmapper.
|
|
||||||
.TP
|
|
||||||
.B \-b
|
|
||||||
Make an
|
|
||||||
.SM RPC
|
|
||||||
broadcast to procedure 0 of the specified
|
|
||||||
.I program
|
|
||||||
and
|
|
||||||
.I version
|
|
||||||
using
|
|
||||||
.SM UDP
|
|
||||||
and report all hosts that respond.
|
|
||||||
.TP
|
|
||||||
.B \-d
|
|
||||||
Delete registration for the
|
|
||||||
.SM RPC
|
|
||||||
service of the specified
|
|
||||||
.I program
|
|
||||||
and
|
|
||||||
.IR version .
|
|
||||||
This option can be exercised only by the super-user.
|
|
||||||
.LP
|
|
||||||
The
|
|
||||||
.I program
|
|
||||||
argument can be either a name or a number.
|
|
||||||
.LP
|
|
||||||
If a
|
|
||||||
.I version
|
|
||||||
is specified,
|
|
||||||
.B rpcinfo
|
|
||||||
attempts to call that version of the specified
|
|
||||||
.IR program .
|
|
||||||
Otherwise,
|
|
||||||
.B rpcinfo
|
|
||||||
attempts to find all the registered version
|
|
||||||
numbers for the specified
|
|
||||||
.I program
|
|
||||||
by calling version 0 (which is presumed not
|
|
||||||
to exist; if it does exist,
|
|
||||||
.B rpcinfo
|
|
||||||
attempts to obtain this information by calling
|
|
||||||
an extremely high version
|
|
||||||
number instead) and attempts to call each registered version.
|
|
||||||
Note: the version number is required for
|
|
||||||
.B \-b
|
|
||||||
and
|
|
||||||
.B \-d
|
|
||||||
options.
|
|
||||||
.SH EXAMPLES
|
|
||||||
To show all of the
|
|
||||||
.SM RPC
|
|
||||||
services registered on the local machine use:
|
|
||||||
.IP
|
|
||||||
.B example% rpcinfo -p
|
|
||||||
.LP
|
|
||||||
To show all of the
|
|
||||||
.SM RPC
|
|
||||||
services registered on the machine named
|
|
||||||
.B klaxon
|
|
||||||
use:
|
|
||||||
.IP
|
|
||||||
.B example% rpcinfo -p klaxon
|
|
||||||
.LP
|
|
||||||
To show all machines on the local net that are running the Yellow Pages
|
|
||||||
service use:
|
|
||||||
.IP
|
|
||||||
.B "example% rpcinfo -b ypserv 'version' | uniq"
|
|
||||||
.LP
|
|
||||||
where 'version' is the current Yellow Pages version obtained from the
|
|
||||||
results of the
|
|
||||||
.B \-p
|
|
||||||
switch above.
|
|
||||||
.LP
|
|
||||||
To delete the registration for version 1 of the
|
|
||||||
.B walld
|
|
||||||
service use:
|
|
||||||
.IP
|
|
||||||
.B example% rpcinfo -d walld 1
|
|
||||||
.SH "SEE ALSO"
|
|
||||||
.BR rpc (5),
|
|
||||||
.BR portmap (8C)
|
|
||||||
.LP
|
|
||||||
.I "\s-1RPC\s0 Programming Guide"
|
|
||||||
.SH BUGS
|
|
||||||
In releases prior to Sun\s-1OS\s0
|
|
||||||
3.0, the Network File System (\s-1NFS\s0) did not
|
|
||||||
register itself with the
|
|
||||||
portmapper;
|
|
||||||
.B rpcinfo
|
|
||||||
cannot be used to make
|
|
||||||
.SM RPC
|
|
||||||
calls to the
|
|
||||||
.SM NFS
|
|
||||||
server on hosts running such releases.
|
|
@ -1,21 +0,0 @@
|
|||||||
.\" @(#)rstat_svc.8c 2.2 88/08/03 4.0 RPCSRC; from 1.10 87/09/09 SMI
|
|
||||||
.TH RSTAT_SVC 8C "24 November 1987"
|
|
||||||
.SH NAME
|
|
||||||
rstat_svc \- kernel statistics server
|
|
||||||
.SH SYNOPSIS
|
|
||||||
.B /etc/rstat_svc
|
|
||||||
.SH DESCRIPTION
|
|
||||||
.LP
|
|
||||||
.B rstat_svc
|
|
||||||
is a server which returns performance statistics
|
|
||||||
obtained from the kernel.
|
|
||||||
These statistics are graphically displayed by the Sun Microsystems program,
|
|
||||||
.BR perfmeter (1).
|
|
||||||
The
|
|
||||||
.B rstat_svc
|
|
||||||
daemon is normally invoked at boot time through /etc/rc.local.
|
|
||||||
.PP
|
|
||||||
.B rstat_svc
|
|
||||||
uses an RPC protocol defined in /usr/include/rpcsvc/rstat.x.
|
|
||||||
.SH "SEE ALSO"
|
|
||||||
.BR rstat (1),
|
|
@ -1,166 +0,0 @@
|
|||||||
/* @(#)auth.h 2.3 88/08/07 4.0 RPCSRC; from 1.17 88/02/08 SMI */
|
|
||||||
/*
|
|
||||||
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for
|
|
||||||
* unrestricted use provided that this legend is included on all tape
|
|
||||||
* media and as a part of the software program in whole or part. Users
|
|
||||||
* may copy or modify Sun RPC without charge, but are not authorized
|
|
||||||
* to license or distribute it to anyone else except as part of a product or
|
|
||||||
* program developed by the user.
|
|
||||||
*
|
|
||||||
* SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
|
|
||||||
* WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
|
|
||||||
* PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
|
|
||||||
*
|
|
||||||
* Sun RPC is provided with no support and without any obligation on the
|
|
||||||
* part of Sun Microsystems, Inc. to assist in its use, correction,
|
|
||||||
* modification or enhancement.
|
|
||||||
*
|
|
||||||
* SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
|
|
||||||
* INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
|
|
||||||
* OR ANY PART THEREOF.
|
|
||||||
*
|
|
||||||
* In no event will Sun Microsystems, Inc. be liable for any lost revenue
|
|
||||||
* or profits or other special, indirect and consequential damages, even if
|
|
||||||
* Sun has been advised of the possibility of such damages.
|
|
||||||
*
|
|
||||||
* Sun Microsystems, Inc.
|
|
||||||
* 2550 Garcia Avenue
|
|
||||||
* Mountain View, California 94043
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* auth.h, Authentication interface.
|
|
||||||
*
|
|
||||||
* Copyright (C) 1984, Sun Microsystems, Inc.
|
|
||||||
*
|
|
||||||
* The data structures are completely opaque to the client. The client
|
|
||||||
* is required to pass a AUTH * to routines that create rpc
|
|
||||||
* "sessions".
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
#define MAX_AUTH_BYTES 400
|
|
||||||
#define MAXNETNAMELEN 255 /* maximum length of network user's name */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Status returned from authentication check
|
|
||||||
*/
|
|
||||||
enum auth_stat {
|
|
||||||
AUTH_OK=0,
|
|
||||||
/*
|
|
||||||
* failed at remote end
|
|
||||||
*/
|
|
||||||
AUTH_BADCRED=1, /* bogus credentials (seal broken) */
|
|
||||||
AUTH_REJECTEDCRED=2, /* client should begin new session */
|
|
||||||
AUTH_BADVERF=3, /* bogus verifier (seal broken) */
|
|
||||||
AUTH_REJECTEDVERF=4, /* verifier expired or was replayed */
|
|
||||||
AUTH_TOOWEAK=5, /* rejected due to security reasons */
|
|
||||||
/*
|
|
||||||
* failed locally
|
|
||||||
*/
|
|
||||||
AUTH_INVALIDRESP=6, /* bogus response verifier */
|
|
||||||
AUTH_FAILED=7 /* some unknown reason */
|
|
||||||
};
|
|
||||||
|
|
||||||
#if (mc68000 || sparc || vax || i386 || tahoe || luna68k || hp300 || mips)
|
|
||||||
typedef u_long u_int32; /* 32-bit unsigned integers */
|
|
||||||
#endif
|
|
||||||
|
|
||||||
union des_block {
|
|
||||||
struct {
|
|
||||||
u_int32 high;
|
|
||||||
u_int32 low;
|
|
||||||
} key;
|
|
||||||
char c[8];
|
|
||||||
};
|
|
||||||
typedef union des_block des_block;
|
|
||||||
extern bool_t xdr_des_block();
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Authentication info. Opaque to client.
|
|
||||||
*/
|
|
||||||
struct opaque_auth {
|
|
||||||
enum_t oa_flavor; /* flavor of auth */
|
|
||||||
caddr_t oa_base; /* address of more auth stuff */
|
|
||||||
u_int oa_length; /* not to exceed MAX_AUTH_BYTES */
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Auth handle, interface to client side authenticators.
|
|
||||||
*/
|
|
||||||
typedef struct {
|
|
||||||
struct opaque_auth ah_cred;
|
|
||||||
struct opaque_auth ah_verf;
|
|
||||||
union des_block ah_key;
|
|
||||||
struct auth_ops {
|
|
||||||
void (*ah_nextverf)();
|
|
||||||
int (*ah_marshal)(); /* nextverf & serialize */
|
|
||||||
int (*ah_validate)(); /* validate varifier */
|
|
||||||
int (*ah_refresh)(); /* refresh credentials */
|
|
||||||
void (*ah_destroy)(); /* destroy this structure */
|
|
||||||
} *ah_ops;
|
|
||||||
caddr_t ah_private;
|
|
||||||
} AUTH;
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Authentication ops.
|
|
||||||
* The ops and the auth handle provide the interface to the authenticators.
|
|
||||||
*
|
|
||||||
* AUTH *auth;
|
|
||||||
* XDR *xdrs;
|
|
||||||
* struct opaque_auth verf;
|
|
||||||
*/
|
|
||||||
#define AUTH_NEXTVERF(auth) \
|
|
||||||
((*((auth)->ah_ops->ah_nextverf))(auth))
|
|
||||||
#define auth_nextverf(auth) \
|
|
||||||
((*((auth)->ah_ops->ah_nextverf))(auth))
|
|
||||||
|
|
||||||
#define AUTH_MARSHALL(auth, xdrs) \
|
|
||||||
((*((auth)->ah_ops->ah_marshal))(auth, xdrs))
|
|
||||||
#define auth_marshall(auth, xdrs) \
|
|
||||||
((*((auth)->ah_ops->ah_marshal))(auth, xdrs))
|
|
||||||
|
|
||||||
#define AUTH_VALIDATE(auth, verfp) \
|
|
||||||
((*((auth)->ah_ops->ah_validate))((auth), verfp))
|
|
||||||
#define auth_validate(auth, verfp) \
|
|
||||||
((*((auth)->ah_ops->ah_validate))((auth), verfp))
|
|
||||||
|
|
||||||
#define AUTH_REFRESH(auth) \
|
|
||||||
((*((auth)->ah_ops->ah_refresh))(auth))
|
|
||||||
#define auth_refresh(auth) \
|
|
||||||
((*((auth)->ah_ops->ah_refresh))(auth))
|
|
||||||
|
|
||||||
#define AUTH_DESTROY(auth) \
|
|
||||||
((*((auth)->ah_ops->ah_destroy))(auth))
|
|
||||||
#define auth_destroy(auth) \
|
|
||||||
((*((auth)->ah_ops->ah_destroy))(auth))
|
|
||||||
|
|
||||||
|
|
||||||
extern struct opaque_auth _null_auth;
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* These are the various implementations of client side authenticators.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Unix style authentication
|
|
||||||
* AUTH *authunix_create(machname, uid, gid, len, aup_gids)
|
|
||||||
* char *machname;
|
|
||||||
* int uid;
|
|
||||||
* int gid;
|
|
||||||
* int len;
|
|
||||||
* int *aup_gids;
|
|
||||||
*/
|
|
||||||
extern AUTH *authunix_create();
|
|
||||||
extern AUTH *authunix_create_default(); /* takes no parameters */
|
|
||||||
extern AUTH *authnone_create(); /* takes no parameters */
|
|
||||||
extern AUTH *authdes_create();
|
|
||||||
|
|
||||||
#define AUTH_NONE 0 /* no authentication */
|
|
||||||
#define AUTH_NULL 0 /* backward compatibility */
|
|
||||||
#define AUTH_UNIX 1 /* unix style (uid, gids) */
|
|
||||||
#define AUTH_SHORT 2 /* short hand unix style */
|
|
||||||
#define AUTH_DES 3 /* des style (encrypted timestamps) */
|
|
@ -1,133 +0,0 @@
|
|||||||
/* @(#)auth_none.c 2.1 88/07/29 4.0 RPCSRC */
|
|
||||||
/*
|
|
||||||
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for
|
|
||||||
* unrestricted use provided that this legend is included on all tape
|
|
||||||
* media and as a part of the software program in whole or part. Users
|
|
||||||
* may copy or modify Sun RPC without charge, but are not authorized
|
|
||||||
* to license or distribute it to anyone else except as part of a product or
|
|
||||||
* program developed by the user.
|
|
||||||
*
|
|
||||||
* SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
|
|
||||||
* WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
|
|
||||||
* PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
|
|
||||||
*
|
|
||||||
* Sun RPC is provided with no support and without any obligation on the
|
|
||||||
* part of Sun Microsystems, Inc. to assist in its use, correction,
|
|
||||||
* modification or enhancement.
|
|
||||||
*
|
|
||||||
* SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
|
|
||||||
* INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
|
|
||||||
* OR ANY PART THEREOF.
|
|
||||||
*
|
|
||||||
* In no event will Sun Microsystems, Inc. be liable for any lost revenue
|
|
||||||
* or profits or other special, indirect and consequential damages, even if
|
|
||||||
* Sun has been advised of the possibility of such damages.
|
|
||||||
*
|
|
||||||
* Sun Microsystems, Inc.
|
|
||||||
* 2550 Garcia Avenue
|
|
||||||
* Mountain View, California 94043
|
|
||||||
*/
|
|
||||||
#if !defined(lint) && defined(SCCSIDS)
|
|
||||||
static char sccsid[] = "@(#)auth_none.c 1.19 87/08/11 Copyr 1984 Sun Micro";
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
|
||||||
* auth_none.c
|
|
||||||
* Creates a client authentication handle for passing "null"
|
|
||||||
* credentials and verifiers to remote systems.
|
|
||||||
*
|
|
||||||
* Copyright (C) 1984, Sun Microsystems, Inc.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <rpc/types.h>
|
|
||||||
#include <rpc/xdr.h>
|
|
||||||
#include <rpc/auth.h>
|
|
||||||
#define MAX_MARSHEL_SIZE 20
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Authenticator operations routines
|
|
||||||
*/
|
|
||||||
static void authnone_verf();
|
|
||||||
static void authnone_destroy();
|
|
||||||
static bool_t authnone_marshal();
|
|
||||||
static bool_t authnone_validate();
|
|
||||||
static bool_t authnone_refresh();
|
|
||||||
|
|
||||||
static struct auth_ops ops = {
|
|
||||||
authnone_verf,
|
|
||||||
authnone_marshal,
|
|
||||||
authnone_validate,
|
|
||||||
authnone_refresh,
|
|
||||||
authnone_destroy
|
|
||||||
};
|
|
||||||
|
|
||||||
static struct authnone_private {
|
|
||||||
AUTH no_client;
|
|
||||||
char marshalled_client[MAX_MARSHEL_SIZE];
|
|
||||||
u_int mcnt;
|
|
||||||
} *authnone_private;
|
|
||||||
|
|
||||||
AUTH *
|
|
||||||
authnone_create()
|
|
||||||
{
|
|
||||||
register struct authnone_private *ap = authnone_private;
|
|
||||||
XDR xdr_stream;
|
|
||||||
register XDR *xdrs;
|
|
||||||
|
|
||||||
if (ap == 0) {
|
|
||||||
ap = (struct authnone_private *)calloc(1, sizeof (*ap));
|
|
||||||
if (ap == 0)
|
|
||||||
return (0);
|
|
||||||
authnone_private = ap;
|
|
||||||
}
|
|
||||||
if (!ap->mcnt) {
|
|
||||||
ap->no_client.ah_cred = ap->no_client.ah_verf = _null_auth;
|
|
||||||
ap->no_client.ah_ops = &ops;
|
|
||||||
xdrs = &xdr_stream;
|
|
||||||
xdrmem_create(xdrs, ap->marshalled_client, (u_int)MAX_MARSHEL_SIZE,
|
|
||||||
XDR_ENCODE);
|
|
||||||
(void)xdr_opaque_auth(xdrs, &ap->no_client.ah_cred);
|
|
||||||
(void)xdr_opaque_auth(xdrs, &ap->no_client.ah_verf);
|
|
||||||
ap->mcnt = XDR_GETPOS(xdrs);
|
|
||||||
XDR_DESTROY(xdrs);
|
|
||||||
}
|
|
||||||
return (&ap->no_client);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*ARGSUSED*/
|
|
||||||
static bool_t
|
|
||||||
authnone_marshal(client, xdrs)
|
|
||||||
AUTH *client;
|
|
||||||
XDR *xdrs;
|
|
||||||
{
|
|
||||||
register struct authnone_private *ap = authnone_private;
|
|
||||||
|
|
||||||
if (ap == 0)
|
|
||||||
return (0);
|
|
||||||
return ((*xdrs->x_ops->x_putbytes)(xdrs,
|
|
||||||
ap->marshalled_client, ap->mcnt));
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
authnone_verf()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool_t
|
|
||||||
authnone_validate()
|
|
||||||
{
|
|
||||||
|
|
||||||
return (TRUE);
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool_t
|
|
||||||
authnone_refresh()
|
|
||||||
{
|
|
||||||
|
|
||||||
return (FALSE);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
authnone_destroy()
|
|
||||||
{
|
|
||||||
}
|
|
@ -1,337 +0,0 @@
|
|||||||
/* @(#)auth_unix.c 2.2 88/08/01 4.0 RPCSRC */
|
|
||||||
/*
|
|
||||||
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for
|
|
||||||
* unrestricted use provided that this legend is included on all tape
|
|
||||||
* media and as a part of the software program in whole or part. Users
|
|
||||||
* may copy or modify Sun RPC without charge, but are not authorized
|
|
||||||
* to license or distribute it to anyone else except as part of a product or
|
|
||||||
* program developed by the user.
|
|
||||||
*
|
|
||||||
* SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
|
|
||||||
* WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
|
|
||||||
* PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
|
|
||||||
*
|
|
||||||
* Sun RPC is provided with no support and without any obligation on the
|
|
||||||
* part of Sun Microsystems, Inc. to assist in its use, correction,
|
|
||||||
* modification or enhancement.
|
|
||||||
*
|
|
||||||
* SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
|
|
||||||
* INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
|
|
||||||
* OR ANY PART THEREOF.
|
|
||||||
*
|
|
||||||
* In no event will Sun Microsystems, Inc. be liable for any lost revenue
|
|
||||||
* or profits or other special, indirect and consequential damages, even if
|
|
||||||
* Sun has been advised of the possibility of such damages.
|
|
||||||
*
|
|
||||||
* Sun Microsystems, Inc.
|
|
||||||
* 2550 Garcia Avenue
|
|
||||||
* Mountain View, California 94043
|
|
||||||
*/
|
|
||||||
#if !defined(lint) && defined(SCCSIDS)
|
|
||||||
static char sccsid[] = "@(#)auth_unix.c 1.19 87/08/11 Copyr 1984 Sun Micro";
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
|
||||||
* auth_unix.c, Implements UNIX style authentication parameters.
|
|
||||||
*
|
|
||||||
* Copyright (C) 1984, Sun Microsystems, Inc.
|
|
||||||
*
|
|
||||||
* The system is very weak. The client uses no encryption for it's
|
|
||||||
* credentials and only sends null verifiers. The server sends backs
|
|
||||||
* null verifiers or optionally a verifier that suggests a new short hand
|
|
||||||
* for the credentials.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
#include <rpc/types.h>
|
|
||||||
#include <rpc/xdr.h>
|
|
||||||
#include <rpc/auth.h>
|
|
||||||
#include <rpc/auth_unix.h>
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Unix authenticator operations vector
|
|
||||||
*/
|
|
||||||
static void authunix_nextverf();
|
|
||||||
static bool_t authunix_marshal();
|
|
||||||
static bool_t authunix_validate();
|
|
||||||
static bool_t authunix_refresh();
|
|
||||||
static void authunix_destroy();
|
|
||||||
|
|
||||||
static struct auth_ops auth_unix_ops = {
|
|
||||||
authunix_nextverf,
|
|
||||||
authunix_marshal,
|
|
||||||
authunix_validate,
|
|
||||||
authunix_refresh,
|
|
||||||
authunix_destroy
|
|
||||||
};
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This struct is pointed to by the ah_private field of an auth_handle.
|
|
||||||
*/
|
|
||||||
struct audata {
|
|
||||||
struct opaque_auth au_origcred; /* original credentials */
|
|
||||||
struct opaque_auth au_shcred; /* short hand cred */
|
|
||||||
u_long au_shfaults; /* short hand cache faults */
|
|
||||||
char au_marshed[MAX_AUTH_BYTES];
|
|
||||||
u_int au_mpos; /* xdr pos at end of marshed */
|
|
||||||
};
|
|
||||||
#define AUTH_PRIVATE(auth) ((struct audata *)auth->ah_private)
|
|
||||||
|
|
||||||
static bool_t marshal_new_auth();
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Create a unix style authenticator.
|
|
||||||
* Returns an auth handle with the given stuff in it.
|
|
||||||
*/
|
|
||||||
AUTH *
|
|
||||||
authunix_create(machname, uid, gid, len, aup_gids)
|
|
||||||
char *machname;
|
|
||||||
int uid;
|
|
||||||
int gid;
|
|
||||||
register int len;
|
|
||||||
int *aup_gids;
|
|
||||||
{
|
|
||||||
struct authunix_parms aup;
|
|
||||||
char mymem[MAX_AUTH_BYTES];
|
|
||||||
struct timeval now;
|
|
||||||
XDR xdrs;
|
|
||||||
register AUTH *auth;
|
|
||||||
register struct audata *au;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Allocate and set up auth handle
|
|
||||||
*/
|
|
||||||
auth = (AUTH *)mem_alloc(sizeof(*auth));
|
|
||||||
#ifndef KERNEL
|
|
||||||
if (auth == NULL) {
|
|
||||||
(void)fprintf(stderr, "authunix_create: out of memory\n");
|
|
||||||
return (NULL);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
au = (struct audata *)mem_alloc(sizeof(*au));
|
|
||||||
#ifndef KERNEL
|
|
||||||
if (au == NULL) {
|
|
||||||
(void)fprintf(stderr, "authunix_create: out of memory\n");
|
|
||||||
return (NULL);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
auth->ah_ops = &auth_unix_ops;
|
|
||||||
auth->ah_private = (caddr_t)au;
|
|
||||||
auth->ah_verf = au->au_shcred = _null_auth;
|
|
||||||
au->au_shfaults = 0;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* fill in param struct from the given params
|
|
||||||
*/
|
|
||||||
(void)gettimeofday(&now, (struct timezone *)0);
|
|
||||||
aup.aup_time = now.tv_sec;
|
|
||||||
aup.aup_machname = machname;
|
|
||||||
aup.aup_uid = uid;
|
|
||||||
aup.aup_gid = gid;
|
|
||||||
aup.aup_len = (u_int)len;
|
|
||||||
aup.aup_gids = aup_gids;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Serialize the parameters into origcred
|
|
||||||
*/
|
|
||||||
xdrmem_create(&xdrs, mymem, MAX_AUTH_BYTES, XDR_ENCODE);
|
|
||||||
if (! xdr_authunix_parms(&xdrs, &aup))
|
|
||||||
abort();
|
|
||||||
au->au_origcred.oa_length = len = XDR_GETPOS(&xdrs);
|
|
||||||
au->au_origcred.oa_flavor = AUTH_UNIX;
|
|
||||||
#ifdef KERNEL
|
|
||||||
au->au_origcred.oa_base = mem_alloc((u_int) len);
|
|
||||||
#else
|
|
||||||
if ((au->au_origcred.oa_base = mem_alloc((u_int) len)) == NULL) {
|
|
||||||
(void)fprintf(stderr, "authunix_create: out of memory\n");
|
|
||||||
return (NULL);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
bcopy(mymem, au->au_origcred.oa_base, (u_int)len);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* set auth handle to reflect new cred.
|
|
||||||
*/
|
|
||||||
auth->ah_cred = au->au_origcred;
|
|
||||||
marshal_new_auth(auth);
|
|
||||||
return (auth);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Some servers will refuse mounts if the group list is larger
|
|
||||||
* than it expects (like 8). This allows the application to set
|
|
||||||
* the maximum size of the group list that will be sent.
|
|
||||||
*/
|
|
||||||
|
|
||||||
static maxgrplist = NGRPS;
|
|
||||||
|
|
||||||
set_rpc_maxgrouplist(num)
|
|
||||||
int num;
|
|
||||||
{
|
|
||||||
|
|
||||||
if (num < NGRPS)
|
|
||||||
maxgrplist = num;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Returns an auth handle with parameters determined by doing lots of
|
|
||||||
* syscalls.
|
|
||||||
*/
|
|
||||||
AUTH *
|
|
||||||
authunix_create_default()
|
|
||||||
{
|
|
||||||
register int len;
|
|
||||||
char machname[MAX_MACHINE_NAME + 1];
|
|
||||||
register int uid;
|
|
||||||
register int gid;
|
|
||||||
int gids[NGRPS];
|
|
||||||
|
|
||||||
if (gethostname(machname, MAX_MACHINE_NAME) == -1)
|
|
||||||
abort();
|
|
||||||
machname[MAX_MACHINE_NAME] = 0;
|
|
||||||
uid = geteuid();
|
|
||||||
gid = getegid();
|
|
||||||
if ((len = getgroups(NGRPS, gids)) < 0)
|
|
||||||
abort();
|
|
||||||
if (len > maxgrplist)
|
|
||||||
len = maxgrplist;
|
|
||||||
return (authunix_create(machname, uid, gid, len, gids));
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* authunix operations
|
|
||||||
*/
|
|
||||||
|
|
||||||
static void
|
|
||||||
authunix_nextverf(auth)
|
|
||||||
AUTH *auth;
|
|
||||||
{
|
|
||||||
/* no action necessary */
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool_t
|
|
||||||
authunix_marshal(auth, xdrs)
|
|
||||||
AUTH *auth;
|
|
||||||
XDR *xdrs;
|
|
||||||
{
|
|
||||||
register struct audata *au = AUTH_PRIVATE(auth);
|
|
||||||
|
|
||||||
return (XDR_PUTBYTES(xdrs, au->au_marshed, au->au_mpos));
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool_t
|
|
||||||
authunix_validate(auth, verf)
|
|
||||||
register AUTH *auth;
|
|
||||||
struct opaque_auth verf;
|
|
||||||
{
|
|
||||||
register struct audata *au;
|
|
||||||
XDR xdrs;
|
|
||||||
|
|
||||||
if (verf.oa_flavor == AUTH_SHORT) {
|
|
||||||
au = AUTH_PRIVATE(auth);
|
|
||||||
xdrmem_create(&xdrs, verf.oa_base, verf.oa_length, XDR_DECODE);
|
|
||||||
|
|
||||||
if (au->au_shcred.oa_base != NULL) {
|
|
||||||
mem_free(au->au_shcred.oa_base,
|
|
||||||
au->au_shcred.oa_length);
|
|
||||||
au->au_shcred.oa_base = NULL;
|
|
||||||
}
|
|
||||||
if (xdr_opaque_auth(&xdrs, &au->au_shcred)) {
|
|
||||||
auth->ah_cred = au->au_shcred;
|
|
||||||
} else {
|
|
||||||
xdrs.x_op = XDR_FREE;
|
|
||||||
(void)xdr_opaque_auth(&xdrs, &au->au_shcred);
|
|
||||||
au->au_shcred.oa_base = NULL;
|
|
||||||
auth->ah_cred = au->au_origcred;
|
|
||||||
}
|
|
||||||
marshal_new_auth(auth);
|
|
||||||
}
|
|
||||||
return (TRUE);
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool_t
|
|
||||||
authunix_refresh(auth)
|
|
||||||
register AUTH *auth;
|
|
||||||
{
|
|
||||||
register struct audata *au = AUTH_PRIVATE(auth);
|
|
||||||
struct authunix_parms aup;
|
|
||||||
struct timeval now;
|
|
||||||
XDR xdrs;
|
|
||||||
register int stat;
|
|
||||||
|
|
||||||
if (auth->ah_cred.oa_base == au->au_origcred.oa_base) {
|
|
||||||
/* there is no hope. Punt */
|
|
||||||
return (FALSE);
|
|
||||||
}
|
|
||||||
au->au_shfaults ++;
|
|
||||||
|
|
||||||
/* first deserialize the creds back into a struct authunix_parms */
|
|
||||||
aup.aup_machname = NULL;
|
|
||||||
aup.aup_gids = (int *)NULL;
|
|
||||||
xdrmem_create(&xdrs, au->au_origcred.oa_base,
|
|
||||||
au->au_origcred.oa_length, XDR_DECODE);
|
|
||||||
stat = xdr_authunix_parms(&xdrs, &aup);
|
|
||||||
if (! stat)
|
|
||||||
goto done;
|
|
||||||
|
|
||||||
/* update the time and serialize in place */
|
|
||||||
(void)gettimeofday(&now, (struct timezone *)0);
|
|
||||||
aup.aup_time = now.tv_sec;
|
|
||||||
xdrs.x_op = XDR_ENCODE;
|
|
||||||
XDR_SETPOS(&xdrs, 0);
|
|
||||||
stat = xdr_authunix_parms(&xdrs, &aup);
|
|
||||||
if (! stat)
|
|
||||||
goto done;
|
|
||||||
auth->ah_cred = au->au_origcred;
|
|
||||||
marshal_new_auth(auth);
|
|
||||||
done:
|
|
||||||
/* free the struct authunix_parms created by deserializing */
|
|
||||||
xdrs.x_op = XDR_FREE;
|
|
||||||
(void)xdr_authunix_parms(&xdrs, &aup);
|
|
||||||
XDR_DESTROY(&xdrs);
|
|
||||||
return (stat);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
authunix_destroy(auth)
|
|
||||||
register AUTH *auth;
|
|
||||||
{
|
|
||||||
register struct audata *au = AUTH_PRIVATE(auth);
|
|
||||||
|
|
||||||
mem_free(au->au_origcred.oa_base, au->au_origcred.oa_length);
|
|
||||||
|
|
||||||
if (au->au_shcred.oa_base != NULL)
|
|
||||||
mem_free(au->au_shcred.oa_base, au->au_shcred.oa_length);
|
|
||||||
|
|
||||||
mem_free(auth->ah_private, sizeof(struct audata));
|
|
||||||
|
|
||||||
if (auth->ah_verf.oa_base != NULL)
|
|
||||||
mem_free(auth->ah_verf.oa_base, auth->ah_verf.oa_length);
|
|
||||||
|
|
||||||
mem_free((caddr_t)auth, sizeof(*auth));
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Marshals (pre-serializes) an auth struct.
|
|
||||||
* sets private data, au_marshed and au_mpos
|
|
||||||
*/
|
|
||||||
static bool_t
|
|
||||||
marshal_new_auth(auth)
|
|
||||||
register AUTH *auth;
|
|
||||||
{
|
|
||||||
XDR xdr_stream;
|
|
||||||
register XDR *xdrs = &xdr_stream;
|
|
||||||
register struct audata *au = AUTH_PRIVATE(auth);
|
|
||||||
|
|
||||||
xdrmem_create(xdrs, au->au_marshed, MAX_AUTH_BYTES, XDR_ENCODE);
|
|
||||||
if ((! xdr_opaque_auth(xdrs, &(auth->ah_cred))) ||
|
|
||||||
(! xdr_opaque_auth(xdrs, &(auth->ah_verf)))) {
|
|
||||||
perror("auth_none.c - Fatal marshalling problem");
|
|
||||||
} else {
|
|
||||||
au->au_mpos = XDR_GETPOS(xdrs);
|
|
||||||
}
|
|
||||||
XDR_DESTROY(xdrs);
|
|
||||||
}
|
|
@ -1,72 +0,0 @@
|
|||||||
/* @(#)auth_unix.h 2.2 88/07/29 4.0 RPCSRC; from 1.8 88/02/08 SMI */
|
|
||||||
/*
|
|
||||||
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for
|
|
||||||
* unrestricted use provided that this legend is included on all tape
|
|
||||||
* media and as a part of the software program in whole or part. Users
|
|
||||||
* may copy or modify Sun RPC without charge, but are not authorized
|
|
||||||
* to license or distribute it to anyone else except as part of a product or
|
|
||||||
* program developed by the user.
|
|
||||||
*
|
|
||||||
* SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
|
|
||||||
* WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
|
|
||||||
* PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
|
|
||||||
*
|
|
||||||
* Sun RPC is provided with no support and without any obligation on the
|
|
||||||
* part of Sun Microsystems, Inc. to assist in its use, correction,
|
|
||||||
* modification or enhancement.
|
|
||||||
*
|
|
||||||
* SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
|
|
||||||
* INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
|
|
||||||
* OR ANY PART THEREOF.
|
|
||||||
*
|
|
||||||
* In no event will Sun Microsystems, Inc. be liable for any lost revenue
|
|
||||||
* or profits or other special, indirect and consequential damages, even if
|
|
||||||
* Sun has been advised of the possibility of such damages.
|
|
||||||
*
|
|
||||||
* Sun Microsystems, Inc.
|
|
||||||
* 2550 Garcia Avenue
|
|
||||||
* Mountain View, California 94043
|
|
||||||
*/
|
|
||||||
/* @(#)auth_unix.h 1.5 86/07/16 SMI */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* auth_unix.h, Protocol for UNIX style authentication parameters for RPC
|
|
||||||
*
|
|
||||||
* Copyright (C) 1984, Sun Microsystems, Inc.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* The system is very weak. The client uses no encryption for it
|
|
||||||
* credentials and only sends null verifiers. The server sends backs
|
|
||||||
* null verifiers or optionally a verifier that suggests a new short hand
|
|
||||||
* for the credentials.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* The machine name is part of a credential; it may not exceed 255 bytes */
|
|
||||||
#define MAX_MACHINE_NAME 255
|
|
||||||
|
|
||||||
/* gids compose part of a credential; there may not be more than 16 of them */
|
|
||||||
#define NGRPS 16
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Unix style credentials.
|
|
||||||
*/
|
|
||||||
struct authunix_parms {
|
|
||||||
u_long aup_time;
|
|
||||||
char *aup_machname;
|
|
||||||
int aup_uid;
|
|
||||||
int aup_gid;
|
|
||||||
u_int aup_len;
|
|
||||||
int *aup_gids;
|
|
||||||
};
|
|
||||||
|
|
||||||
extern bool_t xdr_authunix_parms();
|
|
||||||
|
|
||||||
/*
|
|
||||||
* If a response verifier has flavor AUTH_SHORT,
|
|
||||||
* then the body of the response verifier encapsulates the following structure;
|
|
||||||
* again it is serialized in the obvious fashion.
|
|
||||||
*/
|
|
||||||
struct short_hand_verf {
|
|
||||||
struct opaque_auth new_cred;
|
|
||||||
};
|
|
@ -1,66 +0,0 @@
|
|||||||
/* @(#)authunix_prot.c 2.1 88/07/29 4.0 RPCSRC */
|
|
||||||
/*
|
|
||||||
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for
|
|
||||||
* unrestricted use provided that this legend is included on all tape
|
|
||||||
* media and as a part of the software program in whole or part. Users
|
|
||||||
* may copy or modify Sun RPC without charge, but are not authorized
|
|
||||||
* to license or distribute it to anyone else except as part of a product or
|
|
||||||
* program developed by the user.
|
|
||||||
*
|
|
||||||
* SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
|
|
||||||
* WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
|
|
||||||
* PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
|
|
||||||
*
|
|
||||||
* Sun RPC is provided with no support and without any obligation on the
|
|
||||||
* part of Sun Microsystems, Inc. to assist in its use, correction,
|
|
||||||
* modification or enhancement.
|
|
||||||
*
|
|
||||||
* SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
|
|
||||||
* INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
|
|
||||||
* OR ANY PART THEREOF.
|
|
||||||
*
|
|
||||||
* In no event will Sun Microsystems, Inc. be liable for any lost revenue
|
|
||||||
* or profits or other special, indirect and consequential damages, even if
|
|
||||||
* Sun has been advised of the possibility of such damages.
|
|
||||||
*
|
|
||||||
* Sun Microsystems, Inc.
|
|
||||||
* 2550 Garcia Avenue
|
|
||||||
* Mountain View, California 94043
|
|
||||||
*/
|
|
||||||
#if !defined(lint) && defined(SCCSIDS)
|
|
||||||
static char sccsid[] = "@(#)authunix_prot.c 1.15 87/08/11 Copyr 1984 Sun Micro";
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
|
||||||
* authunix_prot.c
|
|
||||||
* XDR for UNIX style authentication parameters for RPC
|
|
||||||
*
|
|
||||||
* Copyright (C) 1984, Sun Microsystems, Inc.
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
#include <rpc/types.h>
|
|
||||||
#include <rpc/xdr.h>
|
|
||||||
#include <rpc/auth.h>
|
|
||||||
#include <rpc/auth_unix.h>
|
|
||||||
|
|
||||||
/*
|
|
||||||
* XDR for unix authentication parameters.
|
|
||||||
*/
|
|
||||||
bool_t
|
|
||||||
xdr_authunix_parms(xdrs, p)
|
|
||||||
register XDR *xdrs;
|
|
||||||
register struct authunix_parms *p;
|
|
||||||
{
|
|
||||||
|
|
||||||
if (xdr_u_long(xdrs, &(p->aup_time))
|
|
||||||
&& xdr_string(xdrs, &(p->aup_machname), MAX_MACHINE_NAME)
|
|
||||||
&& xdr_int(xdrs, &(p->aup_uid))
|
|
||||||
&& xdr_int(xdrs, &(p->aup_gid))
|
|
||||||
&& xdr_array(xdrs, (caddr_t *)&(p->aup_gids),
|
|
||||||
&(p->aup_len), NGRPS, sizeof(int), xdr_int) ) {
|
|
||||||
return (TRUE);
|
|
||||||
}
|
|
||||||
return (FALSE);
|
|
||||||
}
|
|
||||||
|
|
@ -1,79 +0,0 @@
|
|||||||
static char sccsid[] = "@(#)bindresvport.c 2.2 88/07/29 4.0 RPCSRC 1.8 88/02/08 SMI";
|
|
||||||
/*
|
|
||||||
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for
|
|
||||||
* unrestricted use provided that this legend is included on all tape
|
|
||||||
* media and as a part of the software program in whole or part. Users
|
|
||||||
* may copy or modify Sun RPC without charge, but are not authorized
|
|
||||||
* to license or distribute it to anyone else except as part of a product or
|
|
||||||
* program developed by the user.
|
|
||||||
*
|
|
||||||
* SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
|
|
||||||
* WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
|
|
||||||
* PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
|
|
||||||
*
|
|
||||||
* Sun RPC is provided with no support and without any obligation on the
|
|
||||||
* part of Sun Microsystems, Inc. to assist in its use, correction,
|
|
||||||
* modification or enhancement.
|
|
||||||
*
|
|
||||||
* SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
|
|
||||||
* INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
|
|
||||||
* OR ANY PART THEREOF.
|
|
||||||
*
|
|
||||||
* In no event will Sun Microsystems, Inc. be liable for any lost revenue
|
|
||||||
* or profits or other special, indirect and consequential damages, even if
|
|
||||||
* Sun has been advised of the possibility of such damages.
|
|
||||||
*
|
|
||||||
* Sun Microsystems, Inc.
|
|
||||||
* 2550 Garcia Avenue
|
|
||||||
* Mountain View, California 94043
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright (c) 1987 by Sun Microsystems, Inc.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <sys/errno.h>
|
|
||||||
#include <sys/socket.h>
|
|
||||||
#include <netinet/in.h>
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Bind a socket to a privileged IP port
|
|
||||||
*/
|
|
||||||
bindresvport(sd, sin)
|
|
||||||
int sd;
|
|
||||||
struct sockaddr_in *sin;
|
|
||||||
{
|
|
||||||
int res;
|
|
||||||
static short port;
|
|
||||||
struct sockaddr_in myaddr;
|
|
||||||
extern int errno;
|
|
||||||
int i;
|
|
||||||
|
|
||||||
#define STARTPORT 600
|
|
||||||
#define ENDPORT (IPPORT_RESERVED - 1)
|
|
||||||
#define NPORTS (ENDPORT - STARTPORT + 1)
|
|
||||||
|
|
||||||
if (sin == (struct sockaddr_in *)0) {
|
|
||||||
sin = &myaddr;
|
|
||||||
bzero(sin, sizeof (*sin));
|
|
||||||
sin->sin_family = AF_INET;
|
|
||||||
} else if (sin->sin_family != AF_INET) {
|
|
||||||
errno = EPFNOSUPPORT;
|
|
||||||
return (-1);
|
|
||||||
}
|
|
||||||
if (port == 0) {
|
|
||||||
port = (getpid() % NPORTS) + STARTPORT;
|
|
||||||
}
|
|
||||||
res = -1;
|
|
||||||
errno = EADDRINUSE;
|
|
||||||
for (i = 0; i < NPORTS && res < 0 && errno == EADDRINUSE; i++) {
|
|
||||||
sin->sin_port = htons(port++);
|
|
||||||
if (port > ENDPORT) {
|
|
||||||
port = STARTPORT;
|
|
||||||
}
|
|
||||||
res = bind(sd,
|
|
||||||
(struct sockaddr *)sin, sizeof(struct sockaddr_in));
|
|
||||||
}
|
|
||||||
return (res);
|
|
||||||
}
|
|
@ -1,331 +0,0 @@
|
|||||||
/* @(#)clnt.h 2.1 88/07/29 4.0 RPCSRC; from 1.31 88/02/08 SMI*/
|
|
||||||
/*
|
|
||||||
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for
|
|
||||||
* unrestricted use provided that this legend is included on all tape
|
|
||||||
* media and as a part of the software program in whole or part. Users
|
|
||||||
* may copy or modify Sun RPC without charge, but are not authorized
|
|
||||||
* to license or distribute it to anyone else except as part of a product or
|
|
||||||
* program developed by the user.
|
|
||||||
*
|
|
||||||
* SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
|
|
||||||
* WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
|
|
||||||
* PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
|
|
||||||
*
|
|
||||||
* Sun RPC is provided with no support and without any obligation on the
|
|
||||||
* part of Sun Microsystems, Inc. to assist in its use, correction,
|
|
||||||
* modification or enhancement.
|
|
||||||
*
|
|
||||||
* SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
|
|
||||||
* INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
|
|
||||||
* OR ANY PART THEREOF.
|
|
||||||
*
|
|
||||||
* In no event will Sun Microsystems, Inc. be liable for any lost revenue
|
|
||||||
* or profits or other special, indirect and consequential damages, even if
|
|
||||||
* Sun has been advised of the possibility of such damages.
|
|
||||||
*
|
|
||||||
* Sun Microsystems, Inc.
|
|
||||||
* 2550 Garcia Avenue
|
|
||||||
* Mountain View, California 94043
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* clnt.h - Client side remote procedure call interface.
|
|
||||||
*
|
|
||||||
* Copyright (C) 1984, Sun Microsystems, Inc.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _CLNT_
|
|
||||||
#define _CLNT_
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Rpc calls return an enum clnt_stat. This should be looked at more,
|
|
||||||
* since each implementation is required to live with this (implementation
|
|
||||||
* independent) list of errors.
|
|
||||||
*/
|
|
||||||
enum clnt_stat {
|
|
||||||
RPC_SUCCESS=0, /* call succeeded */
|
|
||||||
/*
|
|
||||||
* local errors
|
|
||||||
*/
|
|
||||||
RPC_CANTENCODEARGS=1, /* can't encode arguments */
|
|
||||||
RPC_CANTDECODERES=2, /* can't decode results */
|
|
||||||
RPC_CANTSEND=3, /* failure in sending call */
|
|
||||||
RPC_CANTRECV=4, /* failure in receiving result */
|
|
||||||
RPC_TIMEDOUT=5, /* call timed out */
|
|
||||||
/*
|
|
||||||
* remote errors
|
|
||||||
*/
|
|
||||||
RPC_VERSMISMATCH=6, /* rpc versions not compatible */
|
|
||||||
RPC_AUTHERROR=7, /* authentication error */
|
|
||||||
RPC_PROGUNAVAIL=8, /* program not available */
|
|
||||||
RPC_PROGVERSMISMATCH=9, /* program version mismatched */
|
|
||||||
RPC_PROCUNAVAIL=10, /* procedure unavailable */
|
|
||||||
RPC_CANTDECODEARGS=11, /* decode arguments error */
|
|
||||||
RPC_SYSTEMERROR=12, /* generic "other problem" */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* callrpc & clnt_create errors
|
|
||||||
*/
|
|
||||||
RPC_UNKNOWNHOST=13, /* unknown host name */
|
|
||||||
RPC_UNKNOWNPROTO=17, /* unkown protocol */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* _ create errors
|
|
||||||
*/
|
|
||||||
RPC_PMAPFAILURE=14, /* the pmapper failed in its call */
|
|
||||||
RPC_PROGNOTREGISTERED=15, /* remote program is not registered */
|
|
||||||
/*
|
|
||||||
* unspecified error
|
|
||||||
*/
|
|
||||||
RPC_FAILED=16
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Error info.
|
|
||||||
*/
|
|
||||||
struct rpc_err {
|
|
||||||
enum clnt_stat re_status;
|
|
||||||
union {
|
|
||||||
int RE_errno; /* realated system error */
|
|
||||||
enum auth_stat RE_why; /* why the auth error occurred */
|
|
||||||
struct {
|
|
||||||
u_long low; /* lowest verion supported */
|
|
||||||
u_long high; /* highest verion supported */
|
|
||||||
} RE_vers;
|
|
||||||
struct { /* maybe meaningful if RPC_FAILED */
|
|
||||||
long s1;
|
|
||||||
long s2;
|
|
||||||
} RE_lb; /* life boot & debugging only */
|
|
||||||
} ru;
|
|
||||||
#define re_errno ru.RE_errno
|
|
||||||
#define re_why ru.RE_why
|
|
||||||
#define re_vers ru.RE_vers
|
|
||||||
#define re_lb ru.RE_lb
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Client rpc handle.
|
|
||||||
* Created by individual implementations, see e.g. rpc_udp.c.
|
|
||||||
* Client is responsible for initializing auth, see e.g. auth_none.c.
|
|
||||||
*/
|
|
||||||
typedef struct {
|
|
||||||
AUTH *cl_auth; /* authenticator */
|
|
||||||
struct clnt_ops {
|
|
||||||
enum clnt_stat (*cl_call)(); /* call remote procedure */
|
|
||||||
void (*cl_abort)(); /* abort a call */
|
|
||||||
void (*cl_geterr)(); /* get specific error code */
|
|
||||||
bool_t (*cl_freeres)(); /* frees results */
|
|
||||||
void (*cl_destroy)();/* destroy this structure */
|
|
||||||
bool_t (*cl_control)();/* the ioctl() of rpc */
|
|
||||||
} *cl_ops;
|
|
||||||
caddr_t cl_private; /* private stuff */
|
|
||||||
} CLIENT;
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* client side rpc interface ops
|
|
||||||
*
|
|
||||||
* Parameter types are:
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* enum clnt_stat
|
|
||||||
* CLNT_CALL(rh, proc, xargs, argsp, xres, resp, timeout)
|
|
||||||
* CLIENT *rh;
|
|
||||||
* u_long proc;
|
|
||||||
* xdrproc_t xargs;
|
|
||||||
* caddr_t argsp;
|
|
||||||
* xdrproc_t xres;
|
|
||||||
* caddr_t resp;
|
|
||||||
* struct timeval timeout;
|
|
||||||
*/
|
|
||||||
#define CLNT_CALL(rh, proc, xargs, argsp, xres, resp, secs) \
|
|
||||||
((*(rh)->cl_ops->cl_call)(rh, proc, xargs, argsp, xres, resp, secs))
|
|
||||||
#define clnt_call(rh, proc, xargs, argsp, xres, resp, secs) \
|
|
||||||
((*(rh)->cl_ops->cl_call)(rh, proc, xargs, argsp, xres, resp, secs))
|
|
||||||
|
|
||||||
/*
|
|
||||||
* void
|
|
||||||
* CLNT_ABORT(rh);
|
|
||||||
* CLIENT *rh;
|
|
||||||
*/
|
|
||||||
#define CLNT_ABORT(rh) ((*(rh)->cl_ops->cl_abort)(rh))
|
|
||||||
#define clnt_abort(rh) ((*(rh)->cl_ops->cl_abort)(rh))
|
|
||||||
|
|
||||||
/*
|
|
||||||
* struct rpc_err
|
|
||||||
* CLNT_GETERR(rh);
|
|
||||||
* CLIENT *rh;
|
|
||||||
*/
|
|
||||||
#define CLNT_GETERR(rh,errp) ((*(rh)->cl_ops->cl_geterr)(rh, errp))
|
|
||||||
#define clnt_geterr(rh,errp) ((*(rh)->cl_ops->cl_geterr)(rh, errp))
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* bool_t
|
|
||||||
* CLNT_FREERES(rh, xres, resp);
|
|
||||||
* CLIENT *rh;
|
|
||||||
* xdrproc_t xres;
|
|
||||||
* caddr_t resp;
|
|
||||||
*/
|
|
||||||
#define CLNT_FREERES(rh,xres,resp) ((*(rh)->cl_ops->cl_freeres)(rh,xres,resp))
|
|
||||||
#define clnt_freeres(rh,xres,resp) ((*(rh)->cl_ops->cl_freeres)(rh,xres,resp))
|
|
||||||
|
|
||||||
/*
|
|
||||||
* bool_t
|
|
||||||
* CLNT_CONTROL(cl, request, info)
|
|
||||||
* CLIENT *cl;
|
|
||||||
* u_int request;
|
|
||||||
* char *info;
|
|
||||||
*/
|
|
||||||
#define CLNT_CONTROL(cl,rq,in) ((*(cl)->cl_ops->cl_control)(cl,rq,in))
|
|
||||||
#define clnt_control(cl,rq,in) ((*(cl)->cl_ops->cl_control)(cl,rq,in))
|
|
||||||
|
|
||||||
/*
|
|
||||||
* control operations that apply to both udp and tcp transports
|
|
||||||
*/
|
|
||||||
#define CLSET_TIMEOUT 1 /* set timeout (timeval) */
|
|
||||||
#define CLGET_TIMEOUT 2 /* get timeout (timeval) */
|
|
||||||
#define CLGET_SERVER_ADDR 3 /* get server's address (sockaddr) */
|
|
||||||
/*
|
|
||||||
* udp only control operations
|
|
||||||
*/
|
|
||||||
#define CLSET_RETRY_TIMEOUT 4 /* set retry timeout (timeval) */
|
|
||||||
#define CLGET_RETRY_TIMEOUT 5 /* get retry timeout (timeval) */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* void
|
|
||||||
* CLNT_DESTROY(rh);
|
|
||||||
* CLIENT *rh;
|
|
||||||
*/
|
|
||||||
#define CLNT_DESTROY(rh) ((*(rh)->cl_ops->cl_destroy)(rh))
|
|
||||||
#define clnt_destroy(rh) ((*(rh)->cl_ops->cl_destroy)(rh))
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* RPCTEST is a test program which is accessable on every rpc
|
|
||||||
* transport/port. It is used for testing, performance evaluation,
|
|
||||||
* and network administration.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#define RPCTEST_PROGRAM ((u_long)1)
|
|
||||||
#define RPCTEST_VERSION ((u_long)1)
|
|
||||||
#define RPCTEST_NULL_PROC ((u_long)2)
|
|
||||||
#define RPCTEST_NULL_BATCH_PROC ((u_long)3)
|
|
||||||
|
|
||||||
/*
|
|
||||||
* By convention, procedure 0 takes null arguments and returns them
|
|
||||||
*/
|
|
||||||
|
|
||||||
#define NULLPROC ((u_long)0)
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Below are the client handle creation routines for the various
|
|
||||||
* implementations of client side rpc. They can return NULL if a
|
|
||||||
* creation failure occurs.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Memory based rpc (for speed check and testing)
|
|
||||||
* CLIENT *
|
|
||||||
* clntraw_create(prog, vers)
|
|
||||||
* u_long prog;
|
|
||||||
* u_long vers;
|
|
||||||
*/
|
|
||||||
extern CLIENT *clntraw_create();
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Generic client creation routine. Supported protocols are "udp" and "tcp"
|
|
||||||
*/
|
|
||||||
extern CLIENT *
|
|
||||||
clnt_create(/*host, prog, vers, prot*/); /*
|
|
||||||
char *host; -- hostname
|
|
||||||
u_long prog; -- program number
|
|
||||||
u_long vers; -- version number
|
|
||||||
char *prot; -- protocol
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* TCP based rpc
|
|
||||||
* CLIENT *
|
|
||||||
* clnttcp_create(raddr, prog, vers, sockp, sendsz, recvsz)
|
|
||||||
* struct sockaddr_in *raddr;
|
|
||||||
* u_long prog;
|
|
||||||
* u_long version;
|
|
||||||
* register int *sockp;
|
|
||||||
* u_int sendsz;
|
|
||||||
* u_int recvsz;
|
|
||||||
*/
|
|
||||||
extern CLIENT *clnttcp_create();
|
|
||||||
|
|
||||||
/*
|
|
||||||
* UDP based rpc.
|
|
||||||
* CLIENT *
|
|
||||||
* clntudp_create(raddr, program, version, wait, sockp)
|
|
||||||
* struct sockaddr_in *raddr;
|
|
||||||
* u_long program;
|
|
||||||
* u_long version;
|
|
||||||
* struct timeval wait;
|
|
||||||
* int *sockp;
|
|
||||||
*
|
|
||||||
* Same as above, but you specify max packet sizes.
|
|
||||||
* CLIENT *
|
|
||||||
* clntudp_bufcreate(raddr, program, version, wait, sockp, sendsz, recvsz)
|
|
||||||
* struct sockaddr_in *raddr;
|
|
||||||
* u_long program;
|
|
||||||
* u_long version;
|
|
||||||
* struct timeval wait;
|
|
||||||
* int *sockp;
|
|
||||||
* u_int sendsz;
|
|
||||||
* u_int recvsz;
|
|
||||||
*/
|
|
||||||
extern CLIENT *clntudp_create();
|
|
||||||
extern CLIENT *clntudp_bufcreate();
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Print why creation failed
|
|
||||||
*/
|
|
||||||
void clnt_pcreateerror(/* char *msg */); /* stderr */
|
|
||||||
char *clnt_spcreateerror(/* char *msg */); /* string */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Like clnt_perror(), but is more verbose in its output
|
|
||||||
*/
|
|
||||||
void clnt_perrno(/* enum clnt_stat num */); /* stderr */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Print an English error message, given the client error code
|
|
||||||
*/
|
|
||||||
void clnt_perror(/* CLIENT *clnt, char *msg */); /* stderr */
|
|
||||||
char *clnt_sperror(/* CLIENT *clnt, char *msg */); /* string */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* If a creation fails, the following allows the user to figure out why.
|
|
||||||
*/
|
|
||||||
struct rpc_createerr {
|
|
||||||
enum clnt_stat cf_stat;
|
|
||||||
struct rpc_err cf_error; /* useful when cf_stat == RPC_PMAPFAILURE */
|
|
||||||
};
|
|
||||||
|
|
||||||
extern struct rpc_createerr rpc_createerr;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Copy error message to buffer.
|
|
||||||
*/
|
|
||||||
char *clnt_sperrno(/* enum clnt_stat num */); /* string */
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#define UDPMSGSIZE 8800 /* rpc imposed limit on udp msg size */
|
|
||||||
#define RPCSMALLMSGSIZE 400 /* a more reasonable packet size */
|
|
||||||
|
|
||||||
#endif /*!_CLNT_*/
|
|
@ -1,110 +0,0 @@
|
|||||||
/* @(#)clnt_generic.c 2.2 88/08/01 4.0 RPCSRC */
|
|
||||||
/*
|
|
||||||
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for
|
|
||||||
* unrestricted use provided that this legend is included on all tape
|
|
||||||
* media and as a part of the software program in whole or part. Users
|
|
||||||
* may copy or modify Sun RPC without charge, but are not authorized
|
|
||||||
* to license or distribute it to anyone else except as part of a product or
|
|
||||||
* program developed by the user.
|
|
||||||
*
|
|
||||||
* SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
|
|
||||||
* WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
|
|
||||||
* PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
|
|
||||||
*
|
|
||||||
* Sun RPC is provided with no support and without any obligation on the
|
|
||||||
* part of Sun Microsystems, Inc. to assist in its use, correction,
|
|
||||||
* modification or enhancement.
|
|
||||||
*
|
|
||||||
* SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
|
|
||||||
* INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
|
|
||||||
* OR ANY PART THEREOF.
|
|
||||||
*
|
|
||||||
* In no event will Sun Microsystems, Inc. be liable for any lost revenue
|
|
||||||
* or profits or other special, indirect and consequential damages, even if
|
|
||||||
* Sun has been advised of the possibility of such damages.
|
|
||||||
*
|
|
||||||
* Sun Microsystems, Inc.
|
|
||||||
* 2550 Garcia Avenue
|
|
||||||
* Mountain View, California 94043
|
|
||||||
*/
|
|
||||||
#if !defined(lint) && defined(SCCSIDS)
|
|
||||||
static char sccsid[] = "@(#)clnt_generic.c 1.4 87/08/11 (C) 1987 SMI";
|
|
||||||
#endif
|
|
||||||
/*
|
|
||||||
* Copyright (C) 1987, Sun Microsystems, Inc.
|
|
||||||
*/
|
|
||||||
#include <rpc/rpc.h>
|
|
||||||
#include <sys/socket.h>
|
|
||||||
#include <sys/errno.h>
|
|
||||||
#include <netdb.h>
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Generic client creation: takes (hostname, program-number, protocol) and
|
|
||||||
* returns client handle. Default options are set, which the user can
|
|
||||||
* change using the rpc equivalent of ioctl()'s.
|
|
||||||
*/
|
|
||||||
CLIENT *
|
|
||||||
clnt_create(hostname, prog, vers, proto)
|
|
||||||
char *hostname;
|
|
||||||
unsigned prog;
|
|
||||||
unsigned vers;
|
|
||||||
char *proto;
|
|
||||||
{
|
|
||||||
struct hostent *h;
|
|
||||||
struct protoent *p;
|
|
||||||
struct sockaddr_in sin;
|
|
||||||
int sock;
|
|
||||||
struct timeval tv;
|
|
||||||
CLIENT *client;
|
|
||||||
|
|
||||||
h = gethostbyname(hostname);
|
|
||||||
if (h == NULL) {
|
|
||||||
rpc_createerr.cf_stat = RPC_UNKNOWNHOST;
|
|
||||||
return (NULL);
|
|
||||||
}
|
|
||||||
if (h->h_addrtype != AF_INET) {
|
|
||||||
/*
|
|
||||||
* Only support INET for now
|
|
||||||
*/
|
|
||||||
rpc_createerr.cf_stat = RPC_SYSTEMERROR;
|
|
||||||
rpc_createerr.cf_error.re_errno = EAFNOSUPPORT;
|
|
||||||
return (NULL);
|
|
||||||
}
|
|
||||||
sin.sin_family = h->h_addrtype;
|
|
||||||
sin.sin_port = 0;
|
|
||||||
bzero(sin.sin_zero, sizeof(sin.sin_zero));
|
|
||||||
bcopy(h->h_addr, (char*)&sin.sin_addr, h->h_length);
|
|
||||||
p = getprotobyname(proto);
|
|
||||||
if (p == NULL) {
|
|
||||||
rpc_createerr.cf_stat = RPC_UNKNOWNPROTO;
|
|
||||||
rpc_createerr.cf_error.re_errno = EPFNOSUPPORT;
|
|
||||||
return (NULL);
|
|
||||||
}
|
|
||||||
sock = RPC_ANYSOCK;
|
|
||||||
switch (p->p_proto) {
|
|
||||||
case IPPROTO_UDP:
|
|
||||||
tv.tv_sec = 5;
|
|
||||||
tv.tv_usec = 0;
|
|
||||||
client = clntudp_create(&sin, prog, vers, tv, &sock);
|
|
||||||
if (client == NULL) {
|
|
||||||
return (NULL);
|
|
||||||
}
|
|
||||||
tv.tv_sec = 25;
|
|
||||||
clnt_control(client, CLSET_TIMEOUT, &tv);
|
|
||||||
break;
|
|
||||||
case IPPROTO_TCP:
|
|
||||||
client = clnttcp_create(&sin, prog, vers, &sock, 0, 0);
|
|
||||||
if (client == NULL) {
|
|
||||||
return (NULL);
|
|
||||||
}
|
|
||||||
tv.tv_sec = 25;
|
|
||||||
tv.tv_usec = 0;
|
|
||||||
clnt_control(client, CLSET_TIMEOUT, &tv);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
rpc_createerr.cf_stat = RPC_SYSTEMERROR;
|
|
||||||
rpc_createerr.cf_error.re_errno = EPFNOSUPPORT;
|
|
||||||
return (NULL);
|
|
||||||
}
|
|
||||||
return (client);
|
|
||||||
}
|
|
@ -1,302 +0,0 @@
|
|||||||
/* @(#)clnt_perror.c 2.1 88/07/29 4.0 RPCSRC */
|
|
||||||
/*
|
|
||||||
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for
|
|
||||||
* unrestricted use provided that this legend is included on all tape
|
|
||||||
* media and as a part of the software program in whole or part. Users
|
|
||||||
* may copy or modify Sun RPC without charge, but are not authorized
|
|
||||||
* to license or distribute it to anyone else except as part of a product or
|
|
||||||
* program developed by the user.
|
|
||||||
*
|
|
||||||
* SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
|
|
||||||
* WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
|
|
||||||
* PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
|
|
||||||
*
|
|
||||||
* Sun RPC is provided with no support and without any obligation on the
|
|
||||||
* part of Sun Microsystems, Inc. to assist in its use, correction,
|
|
||||||
* modification or enhancement.
|
|
||||||
*
|
|
||||||
* SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
|
|
||||||
* INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
|
|
||||||
* OR ANY PART THEREOF.
|
|
||||||
*
|
|
||||||
* In no event will Sun Microsystems, Inc. be liable for any lost revenue
|
|
||||||
* or profits or other special, indirect and consequential damages, even if
|
|
||||||
* Sun has been advised of the possibility of such damages.
|
|
||||||
*
|
|
||||||
* Sun Microsystems, Inc.
|
|
||||||
* 2550 Garcia Avenue
|
|
||||||
* Mountain View, California 94043
|
|
||||||
*/
|
|
||||||
#if !defined(lint) && defined(SCCSIDS)
|
|
||||||
static char sccsid[] = "@(#)clnt_perror.c 1.15 87/10/07 Copyr 1984 Sun Micro";
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
|
||||||
* clnt_perror.c
|
|
||||||
*
|
|
||||||
* Copyright (C) 1984, Sun Microsystems, Inc.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
#include <rpc/types.h>
|
|
||||||
#include <rpc/auth.h>
|
|
||||||
#include <rpc/clnt.h>
|
|
||||||
|
|
||||||
static char *auth_errmsg();
|
|
||||||
|
|
||||||
extern char *strcpy();
|
|
||||||
|
|
||||||
static char *buf;
|
|
||||||
|
|
||||||
static char *
|
|
||||||
_buf()
|
|
||||||
{
|
|
||||||
|
|
||||||
if (buf == 0)
|
|
||||||
buf = (char *)malloc(256);
|
|
||||||
return (buf);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Print reply error info
|
|
||||||
*/
|
|
||||||
char *
|
|
||||||
clnt_sperror(rpch, s)
|
|
||||||
CLIENT *rpch;
|
|
||||||
char *s;
|
|
||||||
{
|
|
||||||
struct rpc_err e;
|
|
||||||
void clnt_perrno();
|
|
||||||
char *err;
|
|
||||||
char *str = _buf();
|
|
||||||
char *strstart = str;
|
|
||||||
|
|
||||||
if (str == 0)
|
|
||||||
return (0);
|
|
||||||
CLNT_GETERR(rpch, &e);
|
|
||||||
|
|
||||||
(void) sprintf(str, "%s: ", s);
|
|
||||||
str += strlen(str);
|
|
||||||
|
|
||||||
(void) strcpy(str, clnt_sperrno(e.re_status));
|
|
||||||
str += strlen(str);
|
|
||||||
|
|
||||||
switch (e.re_status) {
|
|
||||||
case RPC_SUCCESS:
|
|
||||||
case RPC_CANTENCODEARGS:
|
|
||||||
case RPC_CANTDECODERES:
|
|
||||||
case RPC_TIMEDOUT:
|
|
||||||
case RPC_PROGUNAVAIL:
|
|
||||||
case RPC_PROCUNAVAIL:
|
|
||||||
case RPC_CANTDECODEARGS:
|
|
||||||
case RPC_SYSTEMERROR:
|
|
||||||
case RPC_UNKNOWNHOST:
|
|
||||||
case RPC_UNKNOWNPROTO:
|
|
||||||
case RPC_PMAPFAILURE:
|
|
||||||
case RPC_PROGNOTREGISTERED:
|
|
||||||
case RPC_FAILED:
|
|
||||||
break;
|
|
||||||
|
|
||||||
case RPC_CANTSEND:
|
|
||||||
case RPC_CANTRECV:
|
|
||||||
(void) sprintf(str, "; errno = %s",
|
|
||||||
strerror(e.re_errno));
|
|
||||||
str += strlen(str);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case RPC_VERSMISMATCH:
|
|
||||||
(void) sprintf(str,
|
|
||||||
"; low version = %lu, high version = %lu",
|
|
||||||
e.re_vers.low, e.re_vers.high);
|
|
||||||
str += strlen(str);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case RPC_AUTHERROR:
|
|
||||||
err = auth_errmsg(e.re_why);
|
|
||||||
(void) sprintf(str,"; why = ");
|
|
||||||
str += strlen(str);
|
|
||||||
if (err != NULL) {
|
|
||||||
(void) sprintf(str, "%s",err);
|
|
||||||
} else {
|
|
||||||
(void) sprintf(str,
|
|
||||||
"(unknown authentication error - %d)",
|
|
||||||
(int) e.re_why);
|
|
||||||
}
|
|
||||||
str += strlen(str);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case RPC_PROGVERSMISMATCH:
|
|
||||||
(void) sprintf(str,
|
|
||||||
"; low version = %lu, high version = %lu",
|
|
||||||
e.re_vers.low, e.re_vers.high);
|
|
||||||
str += strlen(str);
|
|
||||||
break;
|
|
||||||
|
|
||||||
default: /* unknown */
|
|
||||||
(void) sprintf(str,
|
|
||||||
"; s1 = %lu, s2 = %lu",
|
|
||||||
e.re_lb.s1, e.re_lb.s2);
|
|
||||||
str += strlen(str);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
(void) sprintf(str, "\n");
|
|
||||||
return(strstart) ;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
clnt_perror(rpch, s)
|
|
||||||
CLIENT *rpch;
|
|
||||||
char *s;
|
|
||||||
{
|
|
||||||
(void) fprintf(stderr,"%s",clnt_sperror(rpch,s));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
struct rpc_errtab {
|
|
||||||
enum clnt_stat status;
|
|
||||||
char *message;
|
|
||||||
};
|
|
||||||
|
|
||||||
static struct rpc_errtab rpc_errlist[] = {
|
|
||||||
{ RPC_SUCCESS,
|
|
||||||
"RPC: Success" },
|
|
||||||
{ RPC_CANTENCODEARGS,
|
|
||||||
"RPC: Can't encode arguments" },
|
|
||||||
{ RPC_CANTDECODERES,
|
|
||||||
"RPC: Can't decode result" },
|
|
||||||
{ RPC_CANTSEND,
|
|
||||||
"RPC: Unable to send" },
|
|
||||||
{ RPC_CANTRECV,
|
|
||||||
"RPC: Unable to receive" },
|
|
||||||
{ RPC_TIMEDOUT,
|
|
||||||
"RPC: Timed out" },
|
|
||||||
{ RPC_VERSMISMATCH,
|
|
||||||
"RPC: Incompatible versions of RPC" },
|
|
||||||
{ RPC_AUTHERROR,
|
|
||||||
"RPC: Authentication error" },
|
|
||||||
{ RPC_PROGUNAVAIL,
|
|
||||||
"RPC: Program unavailable" },
|
|
||||||
{ RPC_PROGVERSMISMATCH,
|
|
||||||
"RPC: Program/version mismatch" },
|
|
||||||
{ RPC_PROCUNAVAIL,
|
|
||||||
"RPC: Procedure unavailable" },
|
|
||||||
{ RPC_CANTDECODEARGS,
|
|
||||||
"RPC: Server can't decode arguments" },
|
|
||||||
{ RPC_SYSTEMERROR,
|
|
||||||
"RPC: Remote system error" },
|
|
||||||
{ RPC_UNKNOWNHOST,
|
|
||||||
"RPC: Unknown host" },
|
|
||||||
{ RPC_UNKNOWNPROTO,
|
|
||||||
"RPC: Unknown protocol" },
|
|
||||||
{ RPC_PMAPFAILURE,
|
|
||||||
"RPC: Port mapper failure" },
|
|
||||||
{ RPC_PROGNOTREGISTERED,
|
|
||||||
"RPC: Program not registered"},
|
|
||||||
{ RPC_FAILED,
|
|
||||||
"RPC: Failed (unspecified error)"}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This interface for use by clntrpc
|
|
||||||
*/
|
|
||||||
char *
|
|
||||||
clnt_sperrno(stat)
|
|
||||||
enum clnt_stat stat;
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
|
|
||||||
for (i = 0; i < sizeof(rpc_errlist)/sizeof(struct rpc_errtab); i++) {
|
|
||||||
if (rpc_errlist[i].status == stat) {
|
|
||||||
return (rpc_errlist[i].message);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return ("RPC: (unknown error code)");
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
clnt_perrno(num)
|
|
||||||
enum clnt_stat num;
|
|
||||||
{
|
|
||||||
(void) fprintf(stderr,"%s",clnt_sperrno(num));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
char *
|
|
||||||
clnt_spcreateerror(s)
|
|
||||||
char *s;
|
|
||||||
{
|
|
||||||
extern int sys_nerr;
|
|
||||||
char *str = _buf();
|
|
||||||
|
|
||||||
if (str == 0)
|
|
||||||
return(0);
|
|
||||||
(void) sprintf(str, "%s: ", s);
|
|
||||||
(void) strcat(str, clnt_sperrno(rpc_createerr.cf_stat));
|
|
||||||
switch (rpc_createerr.cf_stat) {
|
|
||||||
case RPC_PMAPFAILURE:
|
|
||||||
(void) strcat(str, " - ");
|
|
||||||
(void) strcat(str,
|
|
||||||
clnt_sperrno(rpc_createerr.cf_error.re_status));
|
|
||||||
break;
|
|
||||||
|
|
||||||
case RPC_SYSTEMERROR:
|
|
||||||
(void) strcat(str, " - ");
|
|
||||||
if (rpc_createerr.cf_error.re_errno > 0
|
|
||||||
&& rpc_createerr.cf_error.re_errno < sys_nerr)
|
|
||||||
(void) strcat(str,
|
|
||||||
strerror(rpc_createerr.cf_error.re_errno));
|
|
||||||
else
|
|
||||||
(void) sprintf(&str[strlen(str)], "Error %d",
|
|
||||||
rpc_createerr.cf_error.re_errno);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
(void) strcat(str, "\n");
|
|
||||||
return (str);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
clnt_pcreateerror(s)
|
|
||||||
char *s;
|
|
||||||
{
|
|
||||||
(void) fprintf(stderr,"%s",clnt_spcreateerror(s));
|
|
||||||
}
|
|
||||||
|
|
||||||
struct auth_errtab {
|
|
||||||
enum auth_stat status;
|
|
||||||
char *message;
|
|
||||||
};
|
|
||||||
|
|
||||||
static struct auth_errtab auth_errlist[] = {
|
|
||||||
{ AUTH_OK,
|
|
||||||
"Authentication OK" },
|
|
||||||
{ AUTH_BADCRED,
|
|
||||||
"Invalid client credential" },
|
|
||||||
{ AUTH_REJECTEDCRED,
|
|
||||||
"Server rejected credential" },
|
|
||||||
{ AUTH_BADVERF,
|
|
||||||
"Invalid client verifier" },
|
|
||||||
{ AUTH_REJECTEDVERF,
|
|
||||||
"Server rejected verifier" },
|
|
||||||
{ AUTH_TOOWEAK,
|
|
||||||
"Client credential too weak" },
|
|
||||||
{ AUTH_INVALIDRESP,
|
|
||||||
"Invalid server verifier" },
|
|
||||||
{ AUTH_FAILED,
|
|
||||||
"Failed (unspecified error)" },
|
|
||||||
};
|
|
||||||
|
|
||||||
static char *
|
|
||||||
auth_errmsg(stat)
|
|
||||||
enum auth_stat stat;
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
|
|
||||||
for (i = 0; i < sizeof(auth_errlist)/sizeof(struct auth_errtab); i++) {
|
|
||||||
if (auth_errlist[i].status == stat) {
|
|
||||||
return(auth_errlist[i].message);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return(NULL);
|
|
||||||
}
|
|
@ -1,238 +0,0 @@
|
|||||||
/* @(#)clnt_raw.c 2.2 88/08/01 4.0 RPCSRC */
|
|
||||||
/*
|
|
||||||
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for
|
|
||||||
* unrestricted use provided that this legend is included on all tape
|
|
||||||
* media and as a part of the software program in whole or part. Users
|
|
||||||
* may copy or modify Sun RPC without charge, but are not authorized
|
|
||||||
* to license or distribute it to anyone else except as part of a product or
|
|
||||||
* program developed by the user.
|
|
||||||
*
|
|
||||||
* SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
|
|
||||||
* WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
|
|
||||||
* PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
|
|
||||||
*
|
|
||||||
* Sun RPC is provided with no support and without any obligation on the
|
|
||||||
* part of Sun Microsystems, Inc. to assist in its use, correction,
|
|
||||||
* modification or enhancement.
|
|
||||||
*
|
|
||||||
* SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
|
|
||||||
* INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
|
|
||||||
* OR ANY PART THEREOF.
|
|
||||||
*
|
|
||||||
* In no event will Sun Microsystems, Inc. be liable for any lost revenue
|
|
||||||
* or profits or other special, indirect and consequential damages, even if
|
|
||||||
* Sun has been advised of the possibility of such damages.
|
|
||||||
*
|
|
||||||
* Sun Microsystems, Inc.
|
|
||||||
* 2550 Garcia Avenue
|
|
||||||
* Mountain View, California 94043
|
|
||||||
*/
|
|
||||||
#if !defined(lint) && defined(SCCSIDS)
|
|
||||||
static char sccsid[] = "@(#)clnt_raw.c 1.22 87/08/11 Copyr 1984 Sun Micro";
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
|
||||||
* clnt_raw.c
|
|
||||||
*
|
|
||||||
* Copyright (C) 1984, Sun Microsystems, Inc.
|
|
||||||
*
|
|
||||||
* Memory based rpc for simple testing and timing.
|
|
||||||
* Interface to create an rpc client and server in the same process.
|
|
||||||
* This lets us similate rpc and get round trip overhead, without
|
|
||||||
* any interference from the kernal.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <rpc/rpc.h>
|
|
||||||
|
|
||||||
#define MCALL_MSG_SIZE 24
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This is the "network" we will be moving stuff over.
|
|
||||||
*/
|
|
||||||
static struct clntraw_private {
|
|
||||||
CLIENT client_object;
|
|
||||||
XDR xdr_stream;
|
|
||||||
char _raw_buf[UDPMSGSIZE];
|
|
||||||
char mashl_callmsg[MCALL_MSG_SIZE];
|
|
||||||
u_int mcnt;
|
|
||||||
} *clntraw_private;
|
|
||||||
|
|
||||||
static enum clnt_stat clntraw_call();
|
|
||||||
static void clntraw_abort();
|
|
||||||
static void clntraw_geterr();
|
|
||||||
static bool_t clntraw_freeres();
|
|
||||||
static bool_t clntraw_control();
|
|
||||||
static void clntraw_destroy();
|
|
||||||
|
|
||||||
static struct clnt_ops client_ops = {
|
|
||||||
clntraw_call,
|
|
||||||
clntraw_abort,
|
|
||||||
clntraw_geterr,
|
|
||||||
clntraw_freeres,
|
|
||||||
clntraw_destroy,
|
|
||||||
clntraw_control
|
|
||||||
};
|
|
||||||
|
|
||||||
void svc_getreq();
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Create a client handle for memory based rpc.
|
|
||||||
*/
|
|
||||||
CLIENT *
|
|
||||||
clntraw_create(prog, vers)
|
|
||||||
u_long prog;
|
|
||||||
u_long vers;
|
|
||||||
{
|
|
||||||
register struct clntraw_private *clp = clntraw_private;
|
|
||||||
struct rpc_msg call_msg;
|
|
||||||
XDR *xdrs = &clp->xdr_stream;
|
|
||||||
CLIENT *client = &clp->client_object;
|
|
||||||
|
|
||||||
if (clp == 0) {
|
|
||||||
clp = (struct clntraw_private *)calloc(1, sizeof (*clp));
|
|
||||||
if (clp == 0)
|
|
||||||
return (0);
|
|
||||||
clntraw_private = clp;
|
|
||||||
}
|
|
||||||
/*
|
|
||||||
* pre-serialize the staic part of the call msg and stash it away
|
|
||||||
*/
|
|
||||||
call_msg.rm_direction = CALL;
|
|
||||||
call_msg.rm_call.cb_rpcvers = RPC_MSG_VERSION;
|
|
||||||
call_msg.rm_call.cb_prog = prog;
|
|
||||||
call_msg.rm_call.cb_vers = vers;
|
|
||||||
xdrmem_create(xdrs, clp->mashl_callmsg, MCALL_MSG_SIZE, XDR_ENCODE);
|
|
||||||
if (! xdr_callhdr(xdrs, &call_msg)) {
|
|
||||||
perror("clnt_raw.c - Fatal header serialization error.");
|
|
||||||
}
|
|
||||||
clp->mcnt = XDR_GETPOS(xdrs);
|
|
||||||
XDR_DESTROY(xdrs);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Set xdrmem for client/server shared buffer
|
|
||||||
*/
|
|
||||||
xdrmem_create(xdrs, clp->_raw_buf, UDPMSGSIZE, XDR_FREE);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* create client handle
|
|
||||||
*/
|
|
||||||
client->cl_ops = &client_ops;
|
|
||||||
client->cl_auth = authnone_create();
|
|
||||||
return (client);
|
|
||||||
}
|
|
||||||
|
|
||||||
static enum clnt_stat
|
|
||||||
clntraw_call(h, proc, xargs, argsp, xresults, resultsp, timeout)
|
|
||||||
CLIENT *h;
|
|
||||||
u_long proc;
|
|
||||||
xdrproc_t xargs;
|
|
||||||
caddr_t argsp;
|
|
||||||
xdrproc_t xresults;
|
|
||||||
caddr_t resultsp;
|
|
||||||
struct timeval timeout;
|
|
||||||
{
|
|
||||||
register struct clntraw_private *clp = clntraw_private;
|
|
||||||
register XDR *xdrs = &clp->xdr_stream;
|
|
||||||
struct rpc_msg msg;
|
|
||||||
enum clnt_stat status;
|
|
||||||
struct rpc_err error;
|
|
||||||
|
|
||||||
if (clp == 0)
|
|
||||||
return (RPC_FAILED);
|
|
||||||
call_again:
|
|
||||||
/*
|
|
||||||
* send request
|
|
||||||
*/
|
|
||||||
xdrs->x_op = XDR_ENCODE;
|
|
||||||
XDR_SETPOS(xdrs, 0);
|
|
||||||
((struct rpc_msg *)clp->mashl_callmsg)->rm_xid ++ ;
|
|
||||||
if ((! XDR_PUTBYTES(xdrs, clp->mashl_callmsg, clp->mcnt)) ||
|
|
||||||
(! XDR_PUTLONG(xdrs, (long *)&proc)) ||
|
|
||||||
(! AUTH_MARSHALL(h->cl_auth, xdrs)) ||
|
|
||||||
(! (*xargs)(xdrs, argsp))) {
|
|
||||||
return (RPC_CANTENCODEARGS);
|
|
||||||
}
|
|
||||||
(void)XDR_GETPOS(xdrs); /* called just to cause overhead */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* We have to call server input routine here because this is
|
|
||||||
* all going on in one process. Yuk.
|
|
||||||
*/
|
|
||||||
svc_getreq(1);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* get results
|
|
||||||
*/
|
|
||||||
xdrs->x_op = XDR_DECODE;
|
|
||||||
XDR_SETPOS(xdrs, 0);
|
|
||||||
msg.acpted_rply.ar_verf = _null_auth;
|
|
||||||
msg.acpted_rply.ar_results.where = resultsp;
|
|
||||||
msg.acpted_rply.ar_results.proc = xresults;
|
|
||||||
if (! xdr_replymsg(xdrs, &msg))
|
|
||||||
return (RPC_CANTDECODERES);
|
|
||||||
_seterr_reply(&msg, &error);
|
|
||||||
status = error.re_status;
|
|
||||||
|
|
||||||
if (status == RPC_SUCCESS) {
|
|
||||||
if (! AUTH_VALIDATE(h->cl_auth, &msg.acpted_rply.ar_verf)) {
|
|
||||||
status = RPC_AUTHERROR;
|
|
||||||
}
|
|
||||||
} /* end successful completion */
|
|
||||||
else {
|
|
||||||
if (AUTH_REFRESH(h->cl_auth))
|
|
||||||
goto call_again;
|
|
||||||
} /* end of unsuccessful completion */
|
|
||||||
|
|
||||||
if (status == RPC_SUCCESS) {
|
|
||||||
if (! AUTH_VALIDATE(h->cl_auth, &msg.acpted_rply.ar_verf)) {
|
|
||||||
status = RPC_AUTHERROR;
|
|
||||||
}
|
|
||||||
if (msg.acpted_rply.ar_verf.oa_base != NULL) {
|
|
||||||
xdrs->x_op = XDR_FREE;
|
|
||||||
(void)xdr_opaque_auth(xdrs, &(msg.acpted_rply.ar_verf));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return (status);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
clntraw_geterr()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static bool_t
|
|
||||||
clntraw_freeres(cl, xdr_res, res_ptr)
|
|
||||||
CLIENT *cl;
|
|
||||||
xdrproc_t xdr_res;
|
|
||||||
caddr_t res_ptr;
|
|
||||||
{
|
|
||||||
register struct clntraw_private *clp = clntraw_private;
|
|
||||||
register XDR *xdrs = &clp->xdr_stream;
|
|
||||||
bool_t rval;
|
|
||||||
|
|
||||||
if (clp == 0)
|
|
||||||
{
|
|
||||||
rval = (bool_t) RPC_FAILED;
|
|
||||||
return (rval);
|
|
||||||
}
|
|
||||||
xdrs->x_op = XDR_FREE;
|
|
||||||
return ((*xdr_res)(xdrs, res_ptr));
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
clntraw_abort()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool_t
|
|
||||||
clntraw_control()
|
|
||||||
{
|
|
||||||
return (FALSE);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
clntraw_destroy()
|
|
||||||
{
|
|
||||||
}
|
|
@ -1,112 +0,0 @@
|
|||||||
/* @(#)clnt_simple.c 2.2 88/08/01 4.0 RPCSRC */
|
|
||||||
/*
|
|
||||||
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for
|
|
||||||
* unrestricted use provided that this legend is included on all tape
|
|
||||||
* media and as a part of the software program in whole or part. Users
|
|
||||||
* may copy or modify Sun RPC without charge, but are not authorized
|
|
||||||
* to license or distribute it to anyone else except as part of a product or
|
|
||||||
* program developed by the user.
|
|
||||||
*
|
|
||||||
* SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
|
|
||||||
* WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
|
|
||||||
* PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
|
|
||||||
*
|
|
||||||
* Sun RPC is provided with no support and without any obligation on the
|
|
||||||
* part of Sun Microsystems, Inc. to assist in its use, correction,
|
|
||||||
* modification or enhancement.
|
|
||||||
*
|
|
||||||
* SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
|
|
||||||
* INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
|
|
||||||
* OR ANY PART THEREOF.
|
|
||||||
*
|
|
||||||
* In no event will Sun Microsystems, Inc. be liable for any lost revenue
|
|
||||||
* or profits or other special, indirect and consequential damages, even if
|
|
||||||
* Sun has been advised of the possibility of such damages.
|
|
||||||
*
|
|
||||||
* Sun Microsystems, Inc.
|
|
||||||
* 2550 Garcia Avenue
|
|
||||||
* Mountain View, California 94043
|
|
||||||
*/
|
|
||||||
#if !defined(lint) && defined(SCCSIDS)
|
|
||||||
static char sccsid[] = "@(#)clnt_simple.c 1.35 87/08/11 Copyr 1984 Sun Micro";
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
|
||||||
* clnt_simple.c
|
|
||||||
* Simplified front end to rpc.
|
|
||||||
*
|
|
||||||
* Copyright (C) 1984, Sun Microsystems, Inc.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <rpc/rpc.h>
|
|
||||||
#include <sys/socket.h>
|
|
||||||
#include <netdb.h>
|
|
||||||
#include <strings.h>
|
|
||||||
|
|
||||||
static struct callrpc_private {
|
|
||||||
CLIENT *client;
|
|
||||||
int socket;
|
|
||||||
int oldprognum, oldversnum, valid;
|
|
||||||
char *oldhost;
|
|
||||||
} *callrpc_private;
|
|
||||||
|
|
||||||
callrpc(host, prognum, versnum, procnum, inproc, in, outproc, out)
|
|
||||||
char *host;
|
|
||||||
xdrproc_t inproc, outproc;
|
|
||||||
char *in, *out;
|
|
||||||
{
|
|
||||||
register struct callrpc_private *crp = callrpc_private;
|
|
||||||
struct sockaddr_in server_addr;
|
|
||||||
enum clnt_stat clnt_stat;
|
|
||||||
struct hostent *hp;
|
|
||||||
struct timeval timeout, tottimeout;
|
|
||||||
|
|
||||||
if (crp == 0) {
|
|
||||||
crp = (struct callrpc_private *)calloc(1, sizeof (*crp));
|
|
||||||
if (crp == 0)
|
|
||||||
return (0);
|
|
||||||
callrpc_private = crp;
|
|
||||||
}
|
|
||||||
if (crp->oldhost == NULL) {
|
|
||||||
crp->oldhost = malloc(256);
|
|
||||||
crp->oldhost[0] = 0;
|
|
||||||
crp->socket = RPC_ANYSOCK;
|
|
||||||
}
|
|
||||||
if (crp->valid && crp->oldprognum == prognum && crp->oldversnum == versnum
|
|
||||||
&& strcmp(crp->oldhost, host) == 0) {
|
|
||||||
/* reuse old client */
|
|
||||||
} else {
|
|
||||||
crp->valid = 0;
|
|
||||||
(void)close(crp->socket);
|
|
||||||
crp->socket = RPC_ANYSOCK;
|
|
||||||
if (crp->client) {
|
|
||||||
clnt_destroy(crp->client);
|
|
||||||
crp->client = NULL;
|
|
||||||
}
|
|
||||||
if ((hp = gethostbyname(host)) == NULL)
|
|
||||||
return ((int) RPC_UNKNOWNHOST);
|
|
||||||
timeout.tv_usec = 0;
|
|
||||||
timeout.tv_sec = 5;
|
|
||||||
bcopy(hp->h_addr, (char *)&server_addr.sin_addr, hp->h_length);
|
|
||||||
server_addr.sin_family = AF_INET;
|
|
||||||
server_addr.sin_port = 0;
|
|
||||||
if ((crp->client = clntudp_create(&server_addr, (u_long)prognum,
|
|
||||||
(u_long)versnum, timeout, &crp->socket)) == NULL)
|
|
||||||
return ((int) rpc_createerr.cf_stat);
|
|
||||||
crp->valid = 1;
|
|
||||||
crp->oldprognum = prognum;
|
|
||||||
crp->oldversnum = versnum;
|
|
||||||
(void) strcpy(crp->oldhost, host);
|
|
||||||
}
|
|
||||||
tottimeout.tv_sec = 25;
|
|
||||||
tottimeout.tv_usec = 0;
|
|
||||||
clnt_stat = clnt_call(crp->client, procnum, inproc, in,
|
|
||||||
outproc, out, tottimeout);
|
|
||||||
/*
|
|
||||||
* if call failed, empty cache
|
|
||||||
*/
|
|
||||||
if (clnt_stat != RPC_SUCCESS)
|
|
||||||
crp->valid = 0;
|
|
||||||
return ((int) clnt_stat);
|
|
||||||
}
|
|
@ -1,466 +0,0 @@
|
|||||||
/* @(#)clnt_tcp.c 2.2 88/08/01 4.0 RPCSRC */
|
|
||||||
/*
|
|
||||||
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for
|
|
||||||
* unrestricted use provided that this legend is included on all tape
|
|
||||||
* media and as a part of the software program in whole or part. Users
|
|
||||||
* may copy or modify Sun RPC without charge, but are not authorized
|
|
||||||
* to license or distribute it to anyone else except as part of a product or
|
|
||||||
* program developed by the user.
|
|
||||||
*
|
|
||||||
* SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
|
|
||||||
* WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
|
|
||||||
* PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
|
|
||||||
*
|
|
||||||
* Sun RPC is provided with no support and without any obligation on the
|
|
||||||
* part of Sun Microsystems, Inc. to assist in its use, correction,
|
|
||||||
* modification or enhancement.
|
|
||||||
*
|
|
||||||
* SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
|
|
||||||
* INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
|
|
||||||
* OR ANY PART THEREOF.
|
|
||||||
*
|
|
||||||
* In no event will Sun Microsystems, Inc. be liable for any lost revenue
|
|
||||||
* or profits or other special, indirect and consequential damages, even if
|
|
||||||
* Sun has been advised of the possibility of such damages.
|
|
||||||
*
|
|
||||||
* Sun Microsystems, Inc.
|
|
||||||
* 2550 Garcia Avenue
|
|
||||||
* Mountain View, California 94043
|
|
||||||
*/
|
|
||||||
#if !defined(lint) && defined(SCCSIDS)
|
|
||||||
static char sccsid[] = "@(#)clnt_tcp.c 1.37 87/10/05 Copyr 1984 Sun Micro";
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
|
||||||
* clnt_tcp.c, Implements a TCP/IP based, client side RPC.
|
|
||||||
*
|
|
||||||
* Copyright (C) 1984, Sun Microsystems, Inc.
|
|
||||||
*
|
|
||||||
* TCP based RPC supports 'batched calls'.
|
|
||||||
* A sequence of calls may be batched-up in a send buffer. The rpc call
|
|
||||||
* return immediately to the client even though the call was not necessarily
|
|
||||||
* sent. The batching occurs if the results' xdr routine is NULL (0) AND
|
|
||||||
* the rpc timeout value is zero (see clnt.h, rpc).
|
|
||||||
*
|
|
||||||
* Clients should NOT casually batch calls that in fact return results; that is,
|
|
||||||
* the server side should be aware that a call is batched and not produce any
|
|
||||||
* return message. Batched calls that produce many result messages can
|
|
||||||
* deadlock (netlock) the client and the server....
|
|
||||||
*
|
|
||||||
* Now go hang yourself.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <rpc/rpc.h>
|
|
||||||
#include <sys/socket.h>
|
|
||||||
#include <netdb.h>
|
|
||||||
#include <errno.h>
|
|
||||||
#include <rpc/pmap_clnt.h>
|
|
||||||
|
|
||||||
#define MCALL_MSG_SIZE 24
|
|
||||||
|
|
||||||
extern int errno;
|
|
||||||
|
|
||||||
static int readtcp();
|
|
||||||
static int writetcp();
|
|
||||||
|
|
||||||
static enum clnt_stat clnttcp_call();
|
|
||||||
static void clnttcp_abort();
|
|
||||||
static void clnttcp_geterr();
|
|
||||||
static bool_t clnttcp_freeres();
|
|
||||||
static bool_t clnttcp_control();
|
|
||||||
static void clnttcp_destroy();
|
|
||||||
|
|
||||||
static struct clnt_ops tcp_ops = {
|
|
||||||
clnttcp_call,
|
|
||||||
clnttcp_abort,
|
|
||||||
clnttcp_geterr,
|
|
||||||
clnttcp_freeres,
|
|
||||||
clnttcp_destroy,
|
|
||||||
clnttcp_control
|
|
||||||
};
|
|
||||||
|
|
||||||
struct ct_data {
|
|
||||||
int ct_sock;
|
|
||||||
bool_t ct_closeit;
|
|
||||||
struct timeval ct_wait;
|
|
||||||
bool_t ct_waitset; /* wait set by clnt_control? */
|
|
||||||
struct sockaddr_in ct_addr;
|
|
||||||
struct rpc_err ct_error;
|
|
||||||
char ct_mcall[MCALL_MSG_SIZE]; /* marshalled callmsg */
|
|
||||||
u_int ct_mpos; /* pos after marshal */
|
|
||||||
XDR ct_xdrs;
|
|
||||||
};
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Create a client handle for a tcp/ip connection.
|
|
||||||
* If *sockp<0, *sockp is set to a newly created TCP socket and it is
|
|
||||||
* connected to raddr. If *sockp non-negative then
|
|
||||||
* raddr is ignored. The rpc/tcp package does buffering
|
|
||||||
* similar to stdio, so the client must pick send and receive buffer sizes,];
|
|
||||||
* 0 => use the default.
|
|
||||||
* If raddr->sin_port is 0, then a binder on the remote machine is
|
|
||||||
* consulted for the right port number.
|
|
||||||
* NB: *sockp is copied into a private area.
|
|
||||||
* NB: It is the clients responsibility to close *sockp.
|
|
||||||
* NB: The rpch->cl_auth is set null authentication. Caller may wish to set this
|
|
||||||
* something more useful.
|
|
||||||
*/
|
|
||||||
CLIENT *
|
|
||||||
clnttcp_create(raddr, prog, vers, sockp, sendsz, recvsz)
|
|
||||||
struct sockaddr_in *raddr;
|
|
||||||
u_long prog;
|
|
||||||
u_long vers;
|
|
||||||
register int *sockp;
|
|
||||||
u_int sendsz;
|
|
||||||
u_int recvsz;
|
|
||||||
{
|
|
||||||
CLIENT *h;
|
|
||||||
register struct ct_data *ct;
|
|
||||||
struct timeval now;
|
|
||||||
struct rpc_msg call_msg;
|
|
||||||
|
|
||||||
h = (CLIENT *)mem_alloc(sizeof(*h));
|
|
||||||
if (h == NULL) {
|
|
||||||
(void)fprintf(stderr, "clnttcp_create: out of memory\n");
|
|
||||||
rpc_createerr.cf_stat = RPC_SYSTEMERROR;
|
|
||||||
rpc_createerr.cf_error.re_errno = errno;
|
|
||||||
goto fooy;
|
|
||||||
}
|
|
||||||
ct = (struct ct_data *)mem_alloc(sizeof(*ct));
|
|
||||||
if (ct == NULL) {
|
|
||||||
(void)fprintf(stderr, "clnttcp_create: out of memory\n");
|
|
||||||
rpc_createerr.cf_stat = RPC_SYSTEMERROR;
|
|
||||||
rpc_createerr.cf_error.re_errno = errno;
|
|
||||||
goto fooy;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* If no port number given ask the pmap for one
|
|
||||||
*/
|
|
||||||
if (raddr->sin_port == 0) {
|
|
||||||
u_short port;
|
|
||||||
if ((port = pmap_getport(raddr, prog, vers, IPPROTO_TCP)) == 0) {
|
|
||||||
mem_free((caddr_t)ct, sizeof(struct ct_data));
|
|
||||||
mem_free((caddr_t)h, sizeof(CLIENT));
|
|
||||||
return ((CLIENT *)NULL);
|
|
||||||
}
|
|
||||||
raddr->sin_port = htons(port);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* If no socket given, open one
|
|
||||||
*/
|
|
||||||
if (*sockp < 0) {
|
|
||||||
*sockp = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
|
|
||||||
(void)bindresvport(*sockp, (struct sockaddr_in *)0);
|
|
||||||
if ((*sockp < 0)
|
|
||||||
|| (connect(*sockp, (struct sockaddr *)raddr,
|
|
||||||
sizeof(*raddr)) < 0)) {
|
|
||||||
rpc_createerr.cf_stat = RPC_SYSTEMERROR;
|
|
||||||
rpc_createerr.cf_error.re_errno = errno;
|
|
||||||
(void)close(*sockp);
|
|
||||||
goto fooy;
|
|
||||||
}
|
|
||||||
ct->ct_closeit = TRUE;
|
|
||||||
} else {
|
|
||||||
ct->ct_closeit = FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Set up private data struct
|
|
||||||
*/
|
|
||||||
ct->ct_sock = *sockp;
|
|
||||||
ct->ct_wait.tv_usec = 0;
|
|
||||||
ct->ct_waitset = FALSE;
|
|
||||||
ct->ct_addr = *raddr;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Initialize call message
|
|
||||||
*/
|
|
||||||
(void)gettimeofday(&now, (struct timezone *)0);
|
|
||||||
call_msg.rm_xid = getpid() ^ now.tv_sec ^ now.tv_usec;
|
|
||||||
call_msg.rm_direction = CALL;
|
|
||||||
call_msg.rm_call.cb_rpcvers = RPC_MSG_VERSION;
|
|
||||||
call_msg.rm_call.cb_prog = prog;
|
|
||||||
call_msg.rm_call.cb_vers = vers;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* pre-serialize the staic part of the call msg and stash it away
|
|
||||||
*/
|
|
||||||
xdrmem_create(&(ct->ct_xdrs), ct->ct_mcall, MCALL_MSG_SIZE,
|
|
||||||
XDR_ENCODE);
|
|
||||||
if (! xdr_callhdr(&(ct->ct_xdrs), &call_msg)) {
|
|
||||||
if (ct->ct_closeit) {
|
|
||||||
(void)close(*sockp);
|
|
||||||
}
|
|
||||||
goto fooy;
|
|
||||||
}
|
|
||||||
ct->ct_mpos = XDR_GETPOS(&(ct->ct_xdrs));
|
|
||||||
XDR_DESTROY(&(ct->ct_xdrs));
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Create a client handle which uses xdrrec for serialization
|
|
||||||
* and authnone for authentication.
|
|
||||||
*/
|
|
||||||
xdrrec_create(&(ct->ct_xdrs), sendsz, recvsz,
|
|
||||||
(caddr_t)ct, readtcp, writetcp);
|
|
||||||
h->cl_ops = &tcp_ops;
|
|
||||||
h->cl_private = (caddr_t) ct;
|
|
||||||
h->cl_auth = authnone_create();
|
|
||||||
return (h);
|
|
||||||
|
|
||||||
fooy:
|
|
||||||
/*
|
|
||||||
* Something goofed, free stuff and barf
|
|
||||||
*/
|
|
||||||
mem_free((caddr_t)ct, sizeof(struct ct_data));
|
|
||||||
mem_free((caddr_t)h, sizeof(CLIENT));
|
|
||||||
return ((CLIENT *)NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
static enum clnt_stat
|
|
||||||
clnttcp_call(h, proc, xdr_args, args_ptr, xdr_results, results_ptr, timeout)
|
|
||||||
register CLIENT *h;
|
|
||||||
u_long proc;
|
|
||||||
xdrproc_t xdr_args;
|
|
||||||
caddr_t args_ptr;
|
|
||||||
xdrproc_t xdr_results;
|
|
||||||
caddr_t results_ptr;
|
|
||||||
struct timeval timeout;
|
|
||||||
{
|
|
||||||
register struct ct_data *ct = (struct ct_data *) h->cl_private;
|
|
||||||
register XDR *xdrs = &(ct->ct_xdrs);
|
|
||||||
struct rpc_msg reply_msg;
|
|
||||||
u_long x_id;
|
|
||||||
u_long *msg_x_id = (u_long *)(ct->ct_mcall); /* yuk */
|
|
||||||
register bool_t shipnow;
|
|
||||||
int refreshes = 2;
|
|
||||||
|
|
||||||
if (!ct->ct_waitset) {
|
|
||||||
ct->ct_wait = timeout;
|
|
||||||
}
|
|
||||||
|
|
||||||
shipnow =
|
|
||||||
(xdr_results == (xdrproc_t)0 && timeout.tv_sec == 0
|
|
||||||
&& timeout.tv_usec == 0) ? FALSE : TRUE;
|
|
||||||
|
|
||||||
call_again:
|
|
||||||
xdrs->x_op = XDR_ENCODE;
|
|
||||||
ct->ct_error.re_status = RPC_SUCCESS;
|
|
||||||
x_id = ntohl(--(*msg_x_id));
|
|
||||||
if ((! XDR_PUTBYTES(xdrs, ct->ct_mcall, ct->ct_mpos)) ||
|
|
||||||
(! XDR_PUTLONG(xdrs, (long *)&proc)) ||
|
|
||||||
(! AUTH_MARSHALL(h->cl_auth, xdrs)) ||
|
|
||||||
(! (*xdr_args)(xdrs, args_ptr))) {
|
|
||||||
if (ct->ct_error.re_status == RPC_SUCCESS)
|
|
||||||
ct->ct_error.re_status = RPC_CANTENCODEARGS;
|
|
||||||
(void)xdrrec_endofrecord(xdrs, TRUE);
|
|
||||||
return (ct->ct_error.re_status);
|
|
||||||
}
|
|
||||||
if (! xdrrec_endofrecord(xdrs, shipnow))
|
|
||||||
return (ct->ct_error.re_status = RPC_CANTSEND);
|
|
||||||
if (! shipnow)
|
|
||||||
return (RPC_SUCCESS);
|
|
||||||
/*
|
|
||||||
* Hack to provide rpc-based message passing
|
|
||||||
*/
|
|
||||||
if (timeout.tv_sec == 0 && timeout.tv_usec == 0) {
|
|
||||||
return(ct->ct_error.re_status = RPC_TIMEDOUT);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Keep receiving until we get a valid transaction id
|
|
||||||
*/
|
|
||||||
xdrs->x_op = XDR_DECODE;
|
|
||||||
while (TRUE) {
|
|
||||||
reply_msg.acpted_rply.ar_verf = _null_auth;
|
|
||||||
reply_msg.acpted_rply.ar_results.where = NULL;
|
|
||||||
reply_msg.acpted_rply.ar_results.proc = xdr_void;
|
|
||||||
if (! xdrrec_skiprecord(xdrs))
|
|
||||||
return (ct->ct_error.re_status);
|
|
||||||
/* now decode and validate the response header */
|
|
||||||
if (! xdr_replymsg(xdrs, &reply_msg)) {
|
|
||||||
if (ct->ct_error.re_status == RPC_SUCCESS)
|
|
||||||
continue;
|
|
||||||
return (ct->ct_error.re_status);
|
|
||||||
}
|
|
||||||
if (reply_msg.rm_xid == x_id)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* process header
|
|
||||||
*/
|
|
||||||
_seterr_reply(&reply_msg, &(ct->ct_error));
|
|
||||||
if (ct->ct_error.re_status == RPC_SUCCESS) {
|
|
||||||
if (! AUTH_VALIDATE(h->cl_auth, &reply_msg.acpted_rply.ar_verf)) {
|
|
||||||
ct->ct_error.re_status = RPC_AUTHERROR;
|
|
||||||
ct->ct_error.re_why = AUTH_INVALIDRESP;
|
|
||||||
} else if (! (*xdr_results)(xdrs, results_ptr)) {
|
|
||||||
if (ct->ct_error.re_status == RPC_SUCCESS)
|
|
||||||
ct->ct_error.re_status = RPC_CANTDECODERES;
|
|
||||||
}
|
|
||||||
/* free verifier ... */
|
|
||||||
if (reply_msg.acpted_rply.ar_verf.oa_base != NULL) {
|
|
||||||
xdrs->x_op = XDR_FREE;
|
|
||||||
(void)xdr_opaque_auth(xdrs, &(reply_msg.acpted_rply.ar_verf));
|
|
||||||
}
|
|
||||||
} /* end successful completion */
|
|
||||||
else {
|
|
||||||
/* maybe our credentials need to be refreshed ... */
|
|
||||||
if (refreshes-- && AUTH_REFRESH(h->cl_auth))
|
|
||||||
goto call_again;
|
|
||||||
} /* end of unsuccessful completion */
|
|
||||||
return (ct->ct_error.re_status);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
clnttcp_geterr(h, errp)
|
|
||||||
CLIENT *h;
|
|
||||||
struct rpc_err *errp;
|
|
||||||
{
|
|
||||||
register struct ct_data *ct =
|
|
||||||
(struct ct_data *) h->cl_private;
|
|
||||||
|
|
||||||
*errp = ct->ct_error;
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool_t
|
|
||||||
clnttcp_freeres(cl, xdr_res, res_ptr)
|
|
||||||
CLIENT *cl;
|
|
||||||
xdrproc_t xdr_res;
|
|
||||||
caddr_t res_ptr;
|
|
||||||
{
|
|
||||||
register struct ct_data *ct = (struct ct_data *)cl->cl_private;
|
|
||||||
register XDR *xdrs = &(ct->ct_xdrs);
|
|
||||||
|
|
||||||
xdrs->x_op = XDR_FREE;
|
|
||||||
return ((*xdr_res)(xdrs, res_ptr));
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
clnttcp_abort()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool_t
|
|
||||||
clnttcp_control(cl, request, info)
|
|
||||||
CLIENT *cl;
|
|
||||||
int request;
|
|
||||||
char *info;
|
|
||||||
{
|
|
||||||
register struct ct_data *ct = (struct ct_data *)cl->cl_private;
|
|
||||||
|
|
||||||
switch (request) {
|
|
||||||
case CLSET_TIMEOUT:
|
|
||||||
ct->ct_wait = *(struct timeval *)info;
|
|
||||||
ct->ct_waitset = TRUE;
|
|
||||||
break;
|
|
||||||
case CLGET_TIMEOUT:
|
|
||||||
*(struct timeval *)info = ct->ct_wait;
|
|
||||||
break;
|
|
||||||
case CLGET_SERVER_ADDR:
|
|
||||||
*(struct sockaddr_in *)info = ct->ct_addr;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
return (FALSE);
|
|
||||||
}
|
|
||||||
return (TRUE);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static void
|
|
||||||
clnttcp_destroy(h)
|
|
||||||
CLIENT *h;
|
|
||||||
{
|
|
||||||
register struct ct_data *ct =
|
|
||||||
(struct ct_data *) h->cl_private;
|
|
||||||
|
|
||||||
if (ct->ct_closeit) {
|
|
||||||
(void)close(ct->ct_sock);
|
|
||||||
}
|
|
||||||
XDR_DESTROY(&(ct->ct_xdrs));
|
|
||||||
mem_free((caddr_t)ct, sizeof(struct ct_data));
|
|
||||||
mem_free((caddr_t)h, sizeof(CLIENT));
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Interface between xdr serializer and tcp connection.
|
|
||||||
* Behaves like the system calls, read & write, but keeps some error state
|
|
||||||
* around for the rpc level.
|
|
||||||
*/
|
|
||||||
static int
|
|
||||||
readtcp(ct, buf, len)
|
|
||||||
register struct ct_data *ct;
|
|
||||||
caddr_t buf;
|
|
||||||
register int len;
|
|
||||||
{
|
|
||||||
#ifdef FD_SETSIZE
|
|
||||||
fd_set mask;
|
|
||||||
fd_set readfds;
|
|
||||||
|
|
||||||
if (len == 0)
|
|
||||||
return (0);
|
|
||||||
FD_ZERO(&mask);
|
|
||||||
FD_SET(ct->ct_sock, &mask);
|
|
||||||
#else
|
|
||||||
register int mask = 1 << (ct->ct_sock);
|
|
||||||
int readfds;
|
|
||||||
|
|
||||||
if (len == 0)
|
|
||||||
return (0);
|
|
||||||
|
|
||||||
#endif /* def FD_SETSIZE */
|
|
||||||
while (TRUE) {
|
|
||||||
readfds = mask;
|
|
||||||
switch (select(_rpc_dtablesize(), &readfds, (int*)NULL, (int*)NULL,
|
|
||||||
&(ct->ct_wait))) {
|
|
||||||
case 0:
|
|
||||||
ct->ct_error.re_status = RPC_TIMEDOUT;
|
|
||||||
return (-1);
|
|
||||||
|
|
||||||
case -1:
|
|
||||||
if (errno == EINTR)
|
|
||||||
continue;
|
|
||||||
ct->ct_error.re_status = RPC_CANTRECV;
|
|
||||||
ct->ct_error.re_errno = errno;
|
|
||||||
return (-1);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
switch (len = read(ct->ct_sock, buf, len)) {
|
|
||||||
|
|
||||||
case 0:
|
|
||||||
/* premature eof */
|
|
||||||
ct->ct_error.re_errno = ECONNRESET;
|
|
||||||
ct->ct_error.re_status = RPC_CANTRECV;
|
|
||||||
len = -1; /* it's really an error */
|
|
||||||
break;
|
|
||||||
|
|
||||||
case -1:
|
|
||||||
ct->ct_error.re_errno = errno;
|
|
||||||
ct->ct_error.re_status = RPC_CANTRECV;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return (len);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
|
||||||
writetcp(ct, buf, len)
|
|
||||||
struct ct_data *ct;
|
|
||||||
caddr_t buf;
|
|
||||||
int len;
|
|
||||||
{
|
|
||||||
register int i, cnt;
|
|
||||||
|
|
||||||
for (cnt = len; cnt > 0; cnt -= i, buf += i) {
|
|
||||||
if ((i = write(ct->ct_sock, buf, cnt)) == -1) {
|
|
||||||
ct->ct_error.re_errno = errno;
|
|
||||||
ct->ct_error.re_status = RPC_CANTSEND;
|
|
||||||
return (-1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return (len);
|
|
||||||
}
|
|
@ -1,442 +0,0 @@
|
|||||||
/* @(#)clnt_udp.c 2.2 88/08/01 4.0 RPCSRC */
|
|
||||||
/*
|
|
||||||
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for
|
|
||||||
* unrestricted use provided that this legend is included on all tape
|
|
||||||
* media and as a part of the software program in whole or part. Users
|
|
||||||
* may copy or modify Sun RPC without charge, but are not authorized
|
|
||||||
* to license or distribute it to anyone else except as part of a product or
|
|
||||||
* program developed by the user.
|
|
||||||
*
|
|
||||||
* SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
|
|
||||||
* WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
|
|
||||||
* PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
|
|
||||||
*
|
|
||||||
* Sun RPC is provided with no support and without any obligation on the
|
|
||||||
* part of Sun Microsystems, Inc. to assist in its use, correction,
|
|
||||||
* modification or enhancement.
|
|
||||||
*
|
|
||||||
* SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
|
|
||||||
* INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
|
|
||||||
* OR ANY PART THEREOF.
|
|
||||||
*
|
|
||||||
* In no event will Sun Microsystems, Inc. be liable for any lost revenue
|
|
||||||
* or profits or other special, indirect and consequential damages, even if
|
|
||||||
* Sun has been advised of the possibility of such damages.
|
|
||||||
*
|
|
||||||
* Sun Microsystems, Inc.
|
|
||||||
* 2550 Garcia Avenue
|
|
||||||
* Mountain View, California 94043
|
|
||||||
*/
|
|
||||||
#if !defined(lint) && defined(SCCSIDS)
|
|
||||||
static char sccsid[] = "@(#)clnt_udp.c 1.39 87/08/11 Copyr 1984 Sun Micro";
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
|
||||||
* clnt_udp.c, Implements a UDP/IP based, client side RPC.
|
|
||||||
*
|
|
||||||
* Copyright (C) 1984, Sun Microsystems, Inc.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <rpc/rpc.h>
|
|
||||||
#include <sys/socket.h>
|
|
||||||
#include <sys/ioctl.h>
|
|
||||||
#include <netdb.h>
|
|
||||||
#include <errno.h>
|
|
||||||
#include <rpc/pmap_clnt.h>
|
|
||||||
|
|
||||||
extern int errno;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* UDP bases client side rpc operations
|
|
||||||
*/
|
|
||||||
static enum clnt_stat clntudp_call();
|
|
||||||
static void clntudp_abort();
|
|
||||||
static void clntudp_geterr();
|
|
||||||
static bool_t clntudp_freeres();
|
|
||||||
static bool_t clntudp_control();
|
|
||||||
static void clntudp_destroy();
|
|
||||||
|
|
||||||
static struct clnt_ops udp_ops = {
|
|
||||||
clntudp_call,
|
|
||||||
clntudp_abort,
|
|
||||||
clntudp_geterr,
|
|
||||||
clntudp_freeres,
|
|
||||||
clntudp_destroy,
|
|
||||||
clntudp_control
|
|
||||||
};
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Private data kept per client handle
|
|
||||||
*/
|
|
||||||
struct cu_data {
|
|
||||||
int cu_sock;
|
|
||||||
bool_t cu_closeit;
|
|
||||||
struct sockaddr_in cu_raddr;
|
|
||||||
int cu_rlen;
|
|
||||||
struct timeval cu_wait;
|
|
||||||
struct timeval cu_total;
|
|
||||||
struct rpc_err cu_error;
|
|
||||||
XDR cu_outxdrs;
|
|
||||||
u_int cu_xdrpos;
|
|
||||||
u_int cu_sendsz;
|
|
||||||
char *cu_outbuf;
|
|
||||||
u_int cu_recvsz;
|
|
||||||
char cu_inbuf[1];
|
|
||||||
};
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Create a UDP based client handle.
|
|
||||||
* If *sockp<0, *sockp is set to a newly created UPD socket.
|
|
||||||
* If raddr->sin_port is 0 a binder on the remote machine
|
|
||||||
* is consulted for the correct port number.
|
|
||||||
* NB: It is the clients responsibility to close *sockp.
|
|
||||||
* NB: The rpch->cl_auth is initialized to null authentication.
|
|
||||||
* Caller may wish to set this something more useful.
|
|
||||||
*
|
|
||||||
* wait is the amount of time used between retransmitting a call if
|
|
||||||
* no response has been heard; retransmition occurs until the actual
|
|
||||||
* rpc call times out.
|
|
||||||
*
|
|
||||||
* sendsz and recvsz are the maximum allowable packet sizes that can be
|
|
||||||
* sent and received.
|
|
||||||
*/
|
|
||||||
CLIENT *
|
|
||||||
clntudp_bufcreate(raddr, program, version, wait, sockp, sendsz, recvsz)
|
|
||||||
struct sockaddr_in *raddr;
|
|
||||||
u_long program;
|
|
||||||
u_long version;
|
|
||||||
struct timeval wait;
|
|
||||||
register int *sockp;
|
|
||||||
u_int sendsz;
|
|
||||||
u_int recvsz;
|
|
||||||
{
|
|
||||||
CLIENT *cl;
|
|
||||||
register struct cu_data *cu;
|
|
||||||
struct timeval now;
|
|
||||||
struct rpc_msg call_msg;
|
|
||||||
|
|
||||||
cl = (CLIENT *)mem_alloc(sizeof(CLIENT));
|
|
||||||
if (cl == NULL) {
|
|
||||||
(void) fprintf(stderr, "clntudp_create: out of memory\n");
|
|
||||||
rpc_createerr.cf_stat = RPC_SYSTEMERROR;
|
|
||||||
rpc_createerr.cf_error.re_errno = errno;
|
|
||||||
goto fooy;
|
|
||||||
}
|
|
||||||
sendsz = ((sendsz + 3) / 4) * 4;
|
|
||||||
recvsz = ((recvsz + 3) / 4) * 4;
|
|
||||||
cu = (struct cu_data *)mem_alloc(sizeof(*cu) + sendsz + recvsz);
|
|
||||||
if (cu == NULL) {
|
|
||||||
(void) fprintf(stderr, "clntudp_create: out of memory\n");
|
|
||||||
rpc_createerr.cf_stat = RPC_SYSTEMERROR;
|
|
||||||
rpc_createerr.cf_error.re_errno = errno;
|
|
||||||
goto fooy;
|
|
||||||
}
|
|
||||||
cu->cu_outbuf = &cu->cu_inbuf[recvsz];
|
|
||||||
|
|
||||||
(void)gettimeofday(&now, (struct timezone *)0);
|
|
||||||
if (raddr->sin_port == 0) {
|
|
||||||
u_short port;
|
|
||||||
if ((port =
|
|
||||||
pmap_getport(raddr, program, version, IPPROTO_UDP)) == 0) {
|
|
||||||
goto fooy;
|
|
||||||
}
|
|
||||||
raddr->sin_port = htons(port);
|
|
||||||
}
|
|
||||||
cl->cl_ops = &udp_ops;
|
|
||||||
cl->cl_private = (caddr_t)cu;
|
|
||||||
cu->cu_raddr = *raddr;
|
|
||||||
cu->cu_rlen = sizeof (cu->cu_raddr);
|
|
||||||
cu->cu_wait = wait;
|
|
||||||
cu->cu_total.tv_sec = -1;
|
|
||||||
cu->cu_total.tv_usec = -1;
|
|
||||||
cu->cu_sendsz = sendsz;
|
|
||||||
cu->cu_recvsz = recvsz;
|
|
||||||
call_msg.rm_xid = getpid() ^ now.tv_sec ^ now.tv_usec;
|
|
||||||
call_msg.rm_direction = CALL;
|
|
||||||
call_msg.rm_call.cb_rpcvers = RPC_MSG_VERSION;
|
|
||||||
call_msg.rm_call.cb_prog = program;
|
|
||||||
call_msg.rm_call.cb_vers = version;
|
|
||||||
xdrmem_create(&(cu->cu_outxdrs), cu->cu_outbuf,
|
|
||||||
sendsz, XDR_ENCODE);
|
|
||||||
if (! xdr_callhdr(&(cu->cu_outxdrs), &call_msg)) {
|
|
||||||
goto fooy;
|
|
||||||
}
|
|
||||||
cu->cu_xdrpos = XDR_GETPOS(&(cu->cu_outxdrs));
|
|
||||||
if (*sockp < 0) {
|
|
||||||
int dontblock = 1;
|
|
||||||
|
|
||||||
*sockp = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
|
|
||||||
if (*sockp < 0) {
|
|
||||||
rpc_createerr.cf_stat = RPC_SYSTEMERROR;
|
|
||||||
rpc_createerr.cf_error.re_errno = errno;
|
|
||||||
goto fooy;
|
|
||||||
}
|
|
||||||
/* attempt to bind to prov port */
|
|
||||||
(void)bindresvport(*sockp, (struct sockaddr_in *)0);
|
|
||||||
/* the sockets rpc controls are non-blocking */
|
|
||||||
(void)ioctl(*sockp, FIONBIO, (char *) &dontblock);
|
|
||||||
cu->cu_closeit = TRUE;
|
|
||||||
} else {
|
|
||||||
cu->cu_closeit = FALSE;
|
|
||||||
}
|
|
||||||
cu->cu_sock = *sockp;
|
|
||||||
cl->cl_auth = authnone_create();
|
|
||||||
return (cl);
|
|
||||||
fooy:
|
|
||||||
if (cu)
|
|
||||||
mem_free((caddr_t)cu, sizeof(*cu) + sendsz + recvsz);
|
|
||||||
if (cl)
|
|
||||||
mem_free((caddr_t)cl, sizeof(CLIENT));
|
|
||||||
return ((CLIENT *)NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
CLIENT *
|
|
||||||
clntudp_create(raddr, program, version, wait, sockp)
|
|
||||||
struct sockaddr_in *raddr;
|
|
||||||
u_long program;
|
|
||||||
u_long version;
|
|
||||||
struct timeval wait;
|
|
||||||
register int *sockp;
|
|
||||||
{
|
|
||||||
|
|
||||||
return(clntudp_bufcreate(raddr, program, version, wait, sockp,
|
|
||||||
UDPMSGSIZE, UDPMSGSIZE));
|
|
||||||
}
|
|
||||||
|
|
||||||
static enum clnt_stat
|
|
||||||
clntudp_call(cl, proc, xargs, argsp, xresults, resultsp, utimeout)
|
|
||||||
register CLIENT *cl; /* client handle */
|
|
||||||
u_long proc; /* procedure number */
|
|
||||||
xdrproc_t xargs; /* xdr routine for args */
|
|
||||||
caddr_t argsp; /* pointer to args */
|
|
||||||
xdrproc_t xresults; /* xdr routine for results */
|
|
||||||
caddr_t resultsp; /* pointer to results */
|
|
||||||
struct timeval utimeout; /* seconds to wait before giving up */
|
|
||||||
{
|
|
||||||
register struct cu_data *cu = (struct cu_data *)cl->cl_private;
|
|
||||||
register XDR *xdrs;
|
|
||||||
register int outlen;
|
|
||||||
register int inlen;
|
|
||||||
int fromlen;
|
|
||||||
#ifdef FD_SETSIZE
|
|
||||||
fd_set readfds;
|
|
||||||
fd_set mask;
|
|
||||||
#else
|
|
||||||
int readfds;
|
|
||||||
register int mask;
|
|
||||||
#endif /* def FD_SETSIZE */
|
|
||||||
struct sockaddr_in from;
|
|
||||||
struct rpc_msg reply_msg;
|
|
||||||
XDR reply_xdrs;
|
|
||||||
struct timeval time_waited;
|
|
||||||
bool_t ok;
|
|
||||||
int nrefreshes = 2; /* number of times to refresh cred */
|
|
||||||
struct timeval timeout;
|
|
||||||
|
|
||||||
if (cu->cu_total.tv_usec == -1) {
|
|
||||||
timeout = utimeout; /* use supplied timeout */
|
|
||||||
} else {
|
|
||||||
timeout = cu->cu_total; /* use default timeout */
|
|
||||||
}
|
|
||||||
|
|
||||||
time_waited.tv_sec = 0;
|
|
||||||
time_waited.tv_usec = 0;
|
|
||||||
call_again:
|
|
||||||
xdrs = &(cu->cu_outxdrs);
|
|
||||||
xdrs->x_op = XDR_ENCODE;
|
|
||||||
XDR_SETPOS(xdrs, cu->cu_xdrpos);
|
|
||||||
/*
|
|
||||||
* the transaction is the first thing in the out buffer
|
|
||||||
*/
|
|
||||||
(*(u_short *)(cu->cu_outbuf))++;
|
|
||||||
if ((! XDR_PUTLONG(xdrs, (long *)&proc)) ||
|
|
||||||
(! AUTH_MARSHALL(cl->cl_auth, xdrs)) ||
|
|
||||||
(! (*xargs)(xdrs, argsp)))
|
|
||||||
return (cu->cu_error.re_status = RPC_CANTENCODEARGS);
|
|
||||||
outlen = (int)XDR_GETPOS(xdrs);
|
|
||||||
|
|
||||||
send_again:
|
|
||||||
if (sendto(cu->cu_sock, cu->cu_outbuf, outlen, 0,
|
|
||||||
(struct sockaddr *)&(cu->cu_raddr), cu->cu_rlen)
|
|
||||||
!= outlen) {
|
|
||||||
cu->cu_error.re_errno = errno;
|
|
||||||
return (cu->cu_error.re_status = RPC_CANTSEND);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Hack to provide rpc-based message passing
|
|
||||||
*/
|
|
||||||
if (timeout.tv_sec == 0 && timeout.tv_usec == 0) {
|
|
||||||
return (cu->cu_error.re_status = RPC_TIMEDOUT);
|
|
||||||
}
|
|
||||||
/*
|
|
||||||
* sub-optimal code appears here because we have
|
|
||||||
* some clock time to spare while the packets are in flight.
|
|
||||||
* (We assume that this is actually only executed once.)
|
|
||||||
*/
|
|
||||||
reply_msg.acpted_rply.ar_verf = _null_auth;
|
|
||||||
reply_msg.acpted_rply.ar_results.where = resultsp;
|
|
||||||
reply_msg.acpted_rply.ar_results.proc = xresults;
|
|
||||||
#ifdef FD_SETSIZE
|
|
||||||
FD_ZERO(&mask);
|
|
||||||
FD_SET(cu->cu_sock, &mask);
|
|
||||||
#else
|
|
||||||
mask = 1 << cu->cu_sock;
|
|
||||||
#endif /* def FD_SETSIZE */
|
|
||||||
for (;;) {
|
|
||||||
readfds = mask;
|
|
||||||
switch (select(_rpc_dtablesize(), &readfds, (int *)NULL,
|
|
||||||
(int *)NULL, &(cu->cu_wait))) {
|
|
||||||
|
|
||||||
case 0:
|
|
||||||
time_waited.tv_sec += cu->cu_wait.tv_sec;
|
|
||||||
time_waited.tv_usec += cu->cu_wait.tv_usec;
|
|
||||||
while (time_waited.tv_usec >= 1000000) {
|
|
||||||
time_waited.tv_sec++;
|
|
||||||
time_waited.tv_usec -= 1000000;
|
|
||||||
}
|
|
||||||
if ((time_waited.tv_sec < timeout.tv_sec) ||
|
|
||||||
((time_waited.tv_sec == timeout.tv_sec) &&
|
|
||||||
(time_waited.tv_usec < timeout.tv_usec)))
|
|
||||||
goto send_again;
|
|
||||||
return (cu->cu_error.re_status = RPC_TIMEDOUT);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* buggy in other cases because time_waited is not being
|
|
||||||
* updated.
|
|
||||||
*/
|
|
||||||
case -1:
|
|
||||||
if (errno == EINTR)
|
|
||||||
continue;
|
|
||||||
cu->cu_error.re_errno = errno;
|
|
||||||
return (cu->cu_error.re_status = RPC_CANTRECV);
|
|
||||||
}
|
|
||||||
do {
|
|
||||||
fromlen = sizeof(struct sockaddr);
|
|
||||||
inlen = recvfrom(cu->cu_sock, cu->cu_inbuf,
|
|
||||||
(int) cu->cu_recvsz, 0,
|
|
||||||
(struct sockaddr *)&from, &fromlen);
|
|
||||||
} while (inlen < 0 && errno == EINTR);
|
|
||||||
if (inlen < 0) {
|
|
||||||
if (errno == EWOULDBLOCK)
|
|
||||||
continue;
|
|
||||||
cu->cu_error.re_errno = errno;
|
|
||||||
return (cu->cu_error.re_status = RPC_CANTRECV);
|
|
||||||
}
|
|
||||||
if (inlen < sizeof(u_long))
|
|
||||||
continue;
|
|
||||||
/* see if reply transaction id matches sent id */
|
|
||||||
if (*((u_long *)(cu->cu_inbuf)) != *((u_long *)(cu->cu_outbuf)))
|
|
||||||
continue;
|
|
||||||
/* we now assume we have the proper reply */
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* now decode and validate the response
|
|
||||||
*/
|
|
||||||
xdrmem_create(&reply_xdrs, cu->cu_inbuf, (u_int)inlen, XDR_DECODE);
|
|
||||||
ok = xdr_replymsg(&reply_xdrs, &reply_msg);
|
|
||||||
/* XDR_DESTROY(&reply_xdrs); save a few cycles on noop destroy */
|
|
||||||
if (ok) {
|
|
||||||
_seterr_reply(&reply_msg, &(cu->cu_error));
|
|
||||||
if (cu->cu_error.re_status == RPC_SUCCESS) {
|
|
||||||
if (! AUTH_VALIDATE(cl->cl_auth,
|
|
||||||
&reply_msg.acpted_rply.ar_verf)) {
|
|
||||||
cu->cu_error.re_status = RPC_AUTHERROR;
|
|
||||||
cu->cu_error.re_why = AUTH_INVALIDRESP;
|
|
||||||
}
|
|
||||||
if (reply_msg.acpted_rply.ar_verf.oa_base != NULL) {
|
|
||||||
xdrs->x_op = XDR_FREE;
|
|
||||||
(void)xdr_opaque_auth(xdrs,
|
|
||||||
&(reply_msg.acpted_rply.ar_verf));
|
|
||||||
}
|
|
||||||
} /* end successful completion */
|
|
||||||
else {
|
|
||||||
/* maybe our credentials need to be refreshed ... */
|
|
||||||
if (nrefreshes > 0 && AUTH_REFRESH(cl->cl_auth)) {
|
|
||||||
nrefreshes--;
|
|
||||||
goto call_again;
|
|
||||||
}
|
|
||||||
} /* end of unsuccessful completion */
|
|
||||||
} /* end of valid reply message */
|
|
||||||
else {
|
|
||||||
cu->cu_error.re_status = RPC_CANTDECODERES;
|
|
||||||
}
|
|
||||||
return (cu->cu_error.re_status);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
clntudp_geterr(cl, errp)
|
|
||||||
CLIENT *cl;
|
|
||||||
struct rpc_err *errp;
|
|
||||||
{
|
|
||||||
register struct cu_data *cu = (struct cu_data *)cl->cl_private;
|
|
||||||
|
|
||||||
*errp = cu->cu_error;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static bool_t
|
|
||||||
clntudp_freeres(cl, xdr_res, res_ptr)
|
|
||||||
CLIENT *cl;
|
|
||||||
xdrproc_t xdr_res;
|
|
||||||
caddr_t res_ptr;
|
|
||||||
{
|
|
||||||
register struct cu_data *cu = (struct cu_data *)cl->cl_private;
|
|
||||||
register XDR *xdrs = &(cu->cu_outxdrs);
|
|
||||||
|
|
||||||
xdrs->x_op = XDR_FREE;
|
|
||||||
return ((*xdr_res)(xdrs, res_ptr));
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
clntudp_abort(/*h*/)
|
|
||||||
/*CLIENT *h;*/
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool_t
|
|
||||||
clntudp_control(cl, request, info)
|
|
||||||
CLIENT *cl;
|
|
||||||
int request;
|
|
||||||
char *info;
|
|
||||||
{
|
|
||||||
register struct cu_data *cu = (struct cu_data *)cl->cl_private;
|
|
||||||
|
|
||||||
switch (request) {
|
|
||||||
case CLSET_TIMEOUT:
|
|
||||||
cu->cu_total = *(struct timeval *)info;
|
|
||||||
break;
|
|
||||||
case CLGET_TIMEOUT:
|
|
||||||
*(struct timeval *)info = cu->cu_total;
|
|
||||||
break;
|
|
||||||
case CLSET_RETRY_TIMEOUT:
|
|
||||||
cu->cu_wait = *(struct timeval *)info;
|
|
||||||
break;
|
|
||||||
case CLGET_RETRY_TIMEOUT:
|
|
||||||
*(struct timeval *)info = cu->cu_wait;
|
|
||||||
break;
|
|
||||||
case CLGET_SERVER_ADDR:
|
|
||||||
*(struct sockaddr_in *)info = cu->cu_raddr;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
return (FALSE);
|
|
||||||
}
|
|
||||||
return (TRUE);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
clntudp_destroy(cl)
|
|
||||||
CLIENT *cl;
|
|
||||||
{
|
|
||||||
register struct cu_data *cu = (struct cu_data *)cl->cl_private;
|
|
||||||
|
|
||||||
if (cu->cu_closeit) {
|
|
||||||
(void)close(cu->cu_sock);
|
|
||||||
}
|
|
||||||
XDR_DESTROY(&(cu->cu_outxdrs));
|
|
||||||
mem_free((caddr_t)cu, (sizeof(*cu) + cu->cu_sendsz + cu->cu_recvsz));
|
|
||||||
mem_free((caddr_t)cl, sizeof(CLIENT));
|
|
||||||
}
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user