Split all exec*() functions out of exec.c into their own files.

This commit is contained in:
jtc 1996-07-03 21:41:46 +00:00
parent a174b58e2c
commit 614420255a
6 changed files with 315 additions and 116 deletions

View File

@ -1,4 +1,4 @@
# $NetBSD: Makefile.inc,v 1.71 1996/04/15 23:44:53 jtc Exp $
# $NetBSD: Makefile.inc,v 1.72 1996/07/03 21:41:46 jtc Exp $
# @(#)Makefile.inc 8.3 (Berkeley) 4/16/94
# gen sources
@ -6,7 +6,8 @@
SRCS+= alarm.c assert.c clock.c closedir.c confstr.c ctermid.c \
ctype_.c daemon.c devname.c disklabel.c err.c errx.c errlist.c \
errno.c exec.c fnmatch.c fstab.c ftok.c fts.c getbsize.c getcap.c \
errno.c execl.c execle.c execlp.c execv.c execvp.c fnmatch.c fstab.c \
ftok.c fts.c getbsize.c getcap.c \
getcwd.c getdomainname.c getgrent.c getgrouplist.c gethostname.c \
getloadavg.c getlogin.c getmntinfo.c getnetgrent.c getpagesize.c \
getpass.c getpwent.c getsubopt.c getttyent.c getusershell.c glob.c \

85
lib/libc/gen/execl.c Normal file
View File

@ -0,0 +1,85 @@
/* $NetBSD: execl.c,v 1.1 1996/07/03 21:41:49 jtc Exp $ */
/*-
* 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.
*/
#if defined(LIBC_SCCS) && !defined(lint)
#if 0
static char sccsid[] = "@(#)exec.c 8.1 (Berkeley) 6/4/93";
#else
static char rcsid[] = "$NetBSD: execl.c,v 1.1 1996/07/03 21:41:49 jtc Exp $";
#endif
#endif /* LIBC_SCCS and not lint */
#include <stdlib.h>
#include <unistd.h>
#if __STDC__
#include <stdarg.h>
#define VA_START(ap, last) va_start(ap, last)
#else
#include <varargs.h>
#define VA_START(ap, last) va_start(ap)
#endif
extern char **environ;
int
#if __STDC__
execl(const char *name, const char *arg, ...)
#else
execl(name, arg, va_alist)
const char *name;
const char *arg;
va_dcl
#endif
{
va_list ap;
char **argv;
int i;
VA_START(ap, arg);
for (i = 1; va_arg(ap, char *) != NULL; i++)
;
va_end(ap);
argv = alloca (i * sizeof (char *));
VA_START(ap, arg);
argv[0] = (char *) arg;
for (i = 1; (argv[i] = (char *) va_arg(ap, char *)) != NULL; i++)
;
va_end(ap);
return execve(name, argv, environ);
}

84
lib/libc/gen/execle.c Normal file
View File

@ -0,0 +1,84 @@
/* $NetBSD: execle.c,v 1.1 1996/07/03 21:41:51 jtc Exp $ */
/*-
* 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.
*/
#if defined(LIBC_SCCS) && !defined(lint)
#if 0
static char sccsid[] = "@(#)exec.c 8.1 (Berkeley) 6/4/93";
#else
static char rcsid[] = "$NetBSD: execle.c,v 1.1 1996/07/03 21:41:51 jtc Exp $";
#endif
#endif /* LIBC_SCCS and not lint */
#include <stdlib.h>
#include <unistd.h>
#if __STDC__
#include <stdarg.h>
#define VA_START(ap, last) va_start(ap, last)
#else
#include <varargs.h>
#define VA_START(ap, last) va_start(ap)
#endif
int
#if __STDC__
execle(const char *name, const char *arg, ...)
#else
execle(name, arg, va_alist)
const char *name;
const char *arg;
va_dcl
#endif
{
va_list ap;
char **argv, **envp;
int i;
VA_START(ap, arg);
for (i = 1; va_arg(ap, char *) != NULL; i++)
;
va_end(ap);
argv = alloca (i * sizeof (char *));
VA_START(ap, arg);
argv[0] = (char *) arg;
for (i = 1; (argv[i] = (char *) va_arg(ap, char *)) != NULL; i++)
;
envp = (char **) va_arg(ap, char **);
va_end(ap);
return execve(name, argv, envp);
}

83
lib/libc/gen/execlp.c Normal file
View File

@ -0,0 +1,83 @@
/* $NetBSD: execlp.c,v 1.1 1996/07/03 21:41:52 jtc Exp $ */
/*-
* 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.
*/
#if defined(LIBC_SCCS) && !defined(lint)
#if 0
static char sccsid[] = "@(#)exec.c 8.1 (Berkeley) 6/4/93";
#else
static char rcsid[] = "$NetBSD: execlp.c,v 1.1 1996/07/03 21:41:52 jtc Exp $";
#endif
#endif /* LIBC_SCCS and not lint */
#include <stdlib.h>
#include <unistd.h>
#if __STDC__
#include <stdarg.h>
#define VA_START(ap, last) va_start(ap, last)
#else
#include <varargs.h>
#define VA_START(ap, last) va_start(ap)
#endif
int
#if __STDC__
execlp(const char *name, const char *arg, ...)
#else
execlp(name, arg, va_alist)
const char *name;
const char *arg;
va_dcl
#endif
{
va_list ap;
char **argv;
int i;
VA_START(ap, arg);
for (i = 1; va_arg(ap, char *) != NULL; i++)
;
va_end(ap);
argv = alloca (i * sizeof (char *));
VA_START(ap, arg);
argv[0] = (char *) arg;
for (i = 1; (argv[i] = va_arg(ap, char *)) != NULL; i++)
;
va_end(ap);
return execvp(name, argv);
}

54
lib/libc/gen/execv.c Normal file
View File

@ -0,0 +1,54 @@
/* $NetBSD: execv.c,v 1.1 1996/07/03 21:41:53 jtc Exp $ */
/*-
* 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.
*/
#if defined(LIBC_SCCS) && !defined(lint)
#if 0
static char sccsid[] = "@(#)exec.c 8.1 (Berkeley) 6/4/93";
#else
static char rcsid[] = "$NetBSD: execv.c,v 1.1 1996/07/03 21:41:53 jtc Exp $";
#endif
#endif /* LIBC_SCCS and not lint */
#include <unistd.h>
extern char **environ;
int
execv(name, argv)
const char *name;
char * const *argv;
{
return execve(name, argv, environ);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: exec.c,v 1.8 1996/07/03 19:53:46 jtc Exp $ */
/* $NetBSD: execvp.c,v 1.1 1996/07/03 21:41:54 jtc Exp $ */
/*-
* Copyright (c) 1991, 1993
@ -37,128 +37,20 @@
#if 0
static char sccsid[] = "@(#)exec.c 8.1 (Berkeley) 6/4/93";
#else
static char rcsid[] = "$NetBSD: exec.c,v 1.8 1996/07/03 19:53:46 jtc Exp $";
static char rcsid[] = "$NetBSD: execvp.c,v 1.1 1996/07/03 21:41:54 jtc Exp $";
#endif
#endif /* LIBC_SCCS and not lint */
#include <sys/param.h>
#include <sys/types.h>
#include <errno.h>
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <limits.h>
#include <unistd.h>
#include <paths.h>
#if __STDC__
#include <stdarg.h>
#define VA_START(ap, last) va_start(ap, last)
#else
#include <varargs.h>
#define VA_START(ap, last) va_start(ap)
#endif
extern char **environ;
int
#if __STDC__
execl(const char *name, const char *arg, ...)
#else
execl(name, arg, va_alist)
const char *name;
const char *arg;
va_dcl
#endif
{
va_list ap;
char **argv;
int i;
VA_START(ap, arg);
for (i = 1; va_arg(ap, char *) != NULL; i++)
;
va_end(ap);
argv = alloca (i * sizeof (char *));
VA_START(ap, arg);
argv[0] = (char *) arg;
for (i = 1; (argv[i] = (char *) va_arg(ap, char *)) != NULL; i++)
;
va_end(ap);
return execve(name, argv, environ);
}
int
#if __STDC__
execle(const char *name, const char *arg, ...)
#else
execle(name, arg, va_alist)
const char *name;
const char *arg;
va_dcl
#endif
{
va_list ap;
char **argv, **envp;
int i;
VA_START(ap, arg);
for (i = 1; va_arg(ap, char *) != NULL; i++)
;
va_end(ap);
argv = alloca (i * sizeof (char *));
VA_START(ap, arg);
argv[0] = (char *) arg;
for (i = 1; (argv[i] = (char *) va_arg(ap, char *)) != NULL; i++)
;
envp = (char **) va_arg(ap, char **);
va_end(ap);
return execve(name, argv, envp);
}
int
#if __STDC__
execlp(const char *name, const char *arg, ...)
#else
execlp(name, arg, va_alist)
const char *name;
const char *arg;
va_dcl
#endif
{
va_list ap;
char **argv;
int i;
VA_START(ap, arg);
for (i = 1; va_arg(ap, char *) != NULL; i++)
;
va_end(ap);
argv = alloca (i * sizeof (char *));
VA_START(ap, arg);
argv[0] = (char *) arg;
for (i = 1; (argv[i] = va_arg(ap, char *)) != NULL; i++)
;
va_end(ap);
return execvp(name, argv);
}
int
execv(name, argv)
const char *name;
char * const *argv;
{
return execve(name, argv, environ);
}
int
execvp(name, argv)
const char *name;
@ -169,7 +61,7 @@ execvp(name, argv)
register int cnt, lp, ln;
register char *p;
int eacces = 0, etxtbsy = 0;
char *bp, *cur, *path, buf[MAXPATHLEN];
char *bp, *cur, *path, buf[PATH_MAX];
/* If it's an absolute or relative path name, it's easy. */
if (strchr(name, '/')) {