aboutsummaryrefslogtreecommitdiff
path: root/release/picobsd/tinyware
diff options
context:
space:
mode:
authorKyle Evans <kevans@FreeBSD.org>2019-11-05 02:30:41 +0000
committerKyle Evans <kevans@FreeBSD.org>2019-11-05 02:30:41 +0000
commit6d180b1360b19930587764af836c009419cc3365 (patch)
tree621f0a5101f7b09d6254a2c0e641bda3d385d86c /release/picobsd/tinyware
parent74954211d655f782278bea06fe59f42baeb06634 (diff)
downloadsrc-6d180b1360b19930587764af836c009419cc3365.tar.gz
src-6d180b1360b19930587764af836c009419cc3365.zip
Remove picobsd build scripts and the remaining tinyware
Postings were sent to -arch@ on 2019/09/13 and 2019/10/01, proposing and confirming a removal of these scripts on 2019/10/31, due to significant work needed to bring this into the modern world and nobody having done this work in the past couple of years. No objections or proposed work was raised in response to these postings. The tinyware may see a resurrection into a separate repo for archival purposes if any users of it show interest in doing so. MFC after: never
Notes
Notes: svn path=/head/; revision=354346
Diffstat (limited to 'release/picobsd/tinyware')
-rw-r--r--release/picobsd/tinyware/aps/Makefile9
-rw-r--r--release/picobsd/tinyware/aps/README19
-rw-r--r--release/picobsd/tinyware/aps/main.c101
-rw-r--r--release/picobsd/tinyware/help/Makefile9
-rw-r--r--release/picobsd/tinyware/help/README8
-rw-r--r--release/picobsd/tinyware/help/help.c157
-rw-r--r--release/picobsd/tinyware/login/Makefile25
-rw-r--r--release/picobsd/tinyware/login/README6
-rw-r--r--release/picobsd/tinyware/login/pathnames.h45
-rw-r--r--release/picobsd/tinyware/login/pico-login.c1095
-rw-r--r--release/picobsd/tinyware/msg/Makefile9
-rw-r--r--release/picobsd/tinyware/msg/README15
-rw-r--r--release/picobsd/tinyware/msg/msg.c75
-rw-r--r--release/picobsd/tinyware/msh/Makefile8
-rw-r--r--release/picobsd/tinyware/msh/README13
-rw-r--r--release/picobsd/tinyware/msh/msh.1260
-rw-r--r--release/picobsd/tinyware/msh/sh.h388
-rw-r--r--release/picobsd/tinyware/msh/sh1.c953
-rw-r--r--release/picobsd/tinyware/msh/sh2.c801
-rw-r--r--release/picobsd/tinyware/msh/sh3.c1143
-rw-r--r--release/picobsd/tinyware/msh/sh4.c767
-rw-r--r--release/picobsd/tinyware/msh/sh5.c675
-rw-r--r--release/picobsd/tinyware/msh/sh6.c9
-rw-r--r--release/picobsd/tinyware/ns/Makefile9
-rw-r--r--release/picobsd/tinyware/ns/README43
-rw-r--r--release/picobsd/tinyware/ns/ns.c831
-rw-r--r--release/picobsd/tinyware/oinit/Makefile22
-rw-r--r--release/picobsd/tinyware/oinit/README123
-rw-r--r--release/picobsd/tinyware/oinit/oinit.c947
-rw-r--r--release/picobsd/tinyware/passwd/Makefile68
-rw-r--r--release/picobsd/tinyware/passwd/extern.h40
-rw-r--r--release/picobsd/tinyware/passwd/local_passwd.c239
-rw-r--r--release/picobsd/tinyware/passwd/passwd.c195
-rw-r--r--release/picobsd/tinyware/passwd/pw_copy.c306
-rw-r--r--release/picobsd/tinyware/passwd/pw_util.c260
-rw-r--r--release/picobsd/tinyware/passwd/pw_util.h46
-rw-r--r--release/picobsd/tinyware/sps/Makefile9
-rw-r--r--release/picobsd/tinyware/sps/README11
-rw-r--r--release/picobsd/tinyware/sps/sps.c122
-rw-r--r--release/picobsd/tinyware/view/Makefile9
-rw-r--r--release/picobsd/tinyware/view/README86
-rw-r--r--release/picobsd/tinyware/view/fbsd.pngbin7386 -> 0 bytes
-rw-r--r--release/picobsd/tinyware/view/picobsd.vu9
-rw-r--r--release/picobsd/tinyware/view/view.c619
-rw-r--r--release/picobsd/tinyware/vm/Makefile10
-rw-r--r--release/picobsd/tinyware/vm/README10
-rw-r--r--release/picobsd/tinyware/vm/vm.c112
47 files changed, 0 insertions, 10716 deletions
diff --git a/release/picobsd/tinyware/aps/Makefile b/release/picobsd/tinyware/aps/Makefile
deleted file mode 100644
index d3e4792ff40f..000000000000
--- a/release/picobsd/tinyware/aps/Makefile
+++ /dev/null
@@ -1,9 +0,0 @@
-# $FreeBSD$
-#
-PROG=ps
-SRCS+=main.c
-MAN=
-
-.include <bsd.prog.mk>
-
-
diff --git a/release/picobsd/tinyware/aps/README b/release/picobsd/tinyware/aps/README
deleted file mode 100644
index f455c7bae307..000000000000
--- a/release/picobsd/tinyware/aps/README
+++ /dev/null
@@ -1,19 +0,0 @@
-1998.07.12
-
-This is a small 'ps' replacement, which uses information available via
-procfs(5) interface. It's primitive, but gives you the most important
-informations, i.e. how many processes are running and on which vty, and the
-pid number to kill some of them. :-)
-
-When I have some time, I'll add usual switches and other functions that normal
-'ps' has...
-
-Also, what I'm now inclined to think is that it should be reworked to use
-more general (and less complicated) sysctl(3).
-
-<abial@freebsd.org>
-
-(As of 1998.07.31 this program is no longer used in PicoBSD. See sps(1) in
-TinyWare collection).
-
-$FreeBSD$
diff --git a/release/picobsd/tinyware/aps/main.c b/release/picobsd/tinyware/aps/main.c
deleted file mode 100644
index eece247af3bd..000000000000
--- a/release/picobsd/tinyware/aps/main.c
+++ /dev/null
@@ -1,101 +0,0 @@
-/*-
- * Copyright (c) 1998 Andrzej Bialecki
- * 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.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
- *
- * $FreeBSD$
- *
- */
-
-#include <stdio.h>
-#include <string.h>
-#include <sys/types.h>
-#include <dirent.h>
-
-/*
- * Ok, I could extract almost anything from /proc, but I'm too lazy...
- * I think it will suffice for now.
- */
-
-int
-main(int argc, char *argv[])
-{
- DIR *d;
- struct dirent *e;
- FILE *fd;
- char buf[100];
- char *tok, *sep=" ", *sep1=",";
- char *name, *pid, *ppid, *uid, *gid;
- char *pgid, *sid, *tty, *cred;
- char *major, *minor;
- char con[10];
-
- d=opendir("/proc");
- printf(" PID PPID TTY COMMAND\n");
- while((e=readdir(d))!=NULL) {
- /* Skip '.' and '..' */
- if(e->d_name[0]=='.') continue;
- /* Skip 'curproc' - it's us */
- if(e->d_name[0]=='c') continue;
- sprintf(buf,"/proc/%s/status",e->d_name);
- fd=fopen(buf,"r");
- fgets(buf,99,fd);
- fclose(fd);
- name=strtok(buf,sep);
- pid=strtok(NULL,sep);
- ppid=strtok(NULL,sep);
- pgid=strtok(NULL,sep);
- sid=strtok(NULL,sep);
- tty=strtok(NULL,sep);
- tok=strtok(NULL,sep); /* flags */
- tok=strtok(NULL,sep); /* start */
- tok=strtok(NULL,sep); /* user time */
- tok=strtok(NULL,sep); /* system time */
- tok=strtok(NULL,sep); /* wchan */
- cred=strtok(NULL,sep); /* credentials */
- major=strtok(tty,sep1);
- minor=strtok(NULL,sep1);
- if(strcmp(minor,"-1")==0) {
- minor="?";
- }
- if(strcmp(major,"-1")==0) {
- major="?";
- } else if(strcmp(major,"12")==0) {
- major="v";
- } else if(strcmp(major,"0")==0) {
- major="con";
- minor="-";
- } else if(strcmp(major,"5")==0) {
- major="p";
- } else major="x";
- if((strcmp(major,"v")==0) && (strcmp(minor,"255")==0)) {
- major="con";
- minor="-";
- }
- sprintf(con,"%s%s",major,minor);
- printf("%5s %5s %4s (%s)\n",pid,ppid,con,name);
-
- }
- closedir(d);
- exit(0);
-}
diff --git a/release/picobsd/tinyware/help/Makefile b/release/picobsd/tinyware/help/Makefile
deleted file mode 100644
index 5c0753654eb3..000000000000
--- a/release/picobsd/tinyware/help/Makefile
+++ /dev/null
@@ -1,9 +0,0 @@
-# $FreeBSD$
-#
-PROG=help
-SRCS+=help.c
-MAN=
-
-.include <bsd.prog.mk>
-
-
diff --git a/release/picobsd/tinyware/help/README b/release/picobsd/tinyware/help/README
deleted file mode 100644
index 9c9900feba3f..000000000000
--- a/release/picobsd/tinyware/help/README
+++ /dev/null
@@ -1,8 +0,0 @@
-1998.02.20
-
-This is work in progress. Eventually I'll prepare the help system for newbies,
-and these files are just the beginning of it...
-
-<abial@freebsd.org>
-
-$FreeBSD$
diff --git a/release/picobsd/tinyware/help/help.c b/release/picobsd/tinyware/help/help.c
deleted file mode 100644
index b57b4f6f1557..000000000000
--- a/release/picobsd/tinyware/help/help.c
+++ /dev/null
@@ -1,157 +0,0 @@
-/*-
- * Copyright (c) 1998 Eric P. Scott <eps@sirius.com>
- * Copyright (c) 1998 Andrzej Bialecki <abial@freebsd.org>
- * 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.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-
-
-#include <stdio.h>
-#include <string.h>
-#include <ar.h>
-#include <sys/ioctl.h>
-
-int display(FILE *, const char *);
-
-static int cnt, crt=-1;
-
-int
-main(int argc, char *argv[])
-{
- register int i, s;
- FILE *fd;
- struct ttysize ts;
-
- if (!(fd=fopen("/help.a", "r"))) {
- (void)fputs("Couldn't open help archive.\n", stderr);
- exit(1);
- }
- cnt=0;
- if (ioctl(fileno(stdout), TIOCGWINSZ, &ts)>=0) {
- crt=ts.ts_lines-1;
- }
- if (crt<3) crt=23;
- s=display(fd, argc>1 ? argv[1] : "help");
- if (s<0) s=0;
- else for (i=2;i<argc;) {
- rewind(fd);
- s|=display(fd, argv[i++]);
- if (s<0) {
- s=0;
- break;
- }
- }
- (void)fclose(fd);
- exit(s);
-}
-
-int
-more(void)
-{
- char buf[8];
-
- (void)fflush(stdout);
- (void)fputs("\033[7mPress Enter to continue\033[m", stderr);
- (void)fflush(stderr);
- cnt=0;
- if (fgets(buf, sizeof buf, stdin)) return 0;
- (void)fputc('\n', stderr);
- return 1;
-}
-
-int
-display(FILE *fd, const char *fname)
-{
- register char *p;
- register int c, n, o;
- struct ar_hdr ar;
- char aname[20];
-
- if (!fgets(aname, sizeof aname, fd)) {
- return 1;
- }
- if (strncmp(aname, ARMAG, SARMAG)) return 1;
- (void)snprintf(aname, sizeof(aname), "%s/", fname);
- for (;;) {
- if (fread((void *)&ar, sizeof ar, 1, fd)!=1) return 1;
- if (strncmp(ar.ar_fmag, ARFMAG, 2)) return 1;
- n=0;
- p=ar.ar_size;
- do {
- if ((c=(int)(*p++-'0'))<0||c>9) break;
- n*=10; n+=c;
- } while (p<&ar.ar_size[sizeof ar.ar_size]);
- if (!strncmp(ar.ar_name, aname, strlen(aname))) break;
- if (fseek(fd, (long)n, SEEK_CUR)<0) return 1;
- if ((n&1)&&fgetc(fd)!='\n') return 1;
- }
- if (cnt>=crt&&more()) return -1;
- (void)fputc('\n', stdout);
- cnt++;
- o=0; while (o<n&&(c=fgetc(fd))!=EOF) {
- per:
- o++;
- (void)fputc(c, stdout);
- if (c!='\n') continue;
- if (++cnt<crt) continue;
- if (o>=n||(c=fgetc(fd))==EOF) break;
- if (more()) return -1;
- goto per;
- }
- if (cnt>=crt&&more()) return -1;
- (void)fputc('\n', stdout);
- cnt++;
- if (!strcmp(fname, "help")) {
- rewind(fd);
- (void)fgets(aname, sizeof aname, fd);
- if (cnt>=crt&&more()) return -1;
- (void)fputs("The following help items are available:\n",
- stdout);
- cnt++;
- o=0;
- while (fread((void *)&ar, sizeof ar, 1, fd)==1) {
- if (strncmp(ar.ar_fmag, ARFMAG, 2)) break;
- if ((o%6)==0) {
- (void)fputc('\n', stdout);
- if (++cnt>=crt&&more()) return -1;
- }
- *(index(ar.ar_name,'/'))=' ';
- (void)printf("%.13s", ar.ar_name);
- ++o;
- n=0;
- p=ar.ar_size;
- do {
- if ((c=(int)(*p++-'0'))<0||c>9) break;
- n*=10; n+=c;
- } while (p<&ar.ar_size[sizeof ar.ar_size]);
- if (fseek(fd, (long)n, SEEK_CUR)<0) break;
- if ((n&1)&&fgetc(fd)!='\n') break;
- }
- if (cnt>=crt&&more()) return -1;
- (void)fputc('\n', stdout);
- cnt++;
- }
- return 0;
-}
diff --git a/release/picobsd/tinyware/login/Makefile b/release/picobsd/tinyware/login/Makefile
deleted file mode 100644
index bc6156c8ac51..000000000000
--- a/release/picobsd/tinyware/login/Makefile
+++ /dev/null
@@ -1,25 +0,0 @@
-# From: @(#)Makefile 8.1 (Berkeley) 7/19/93
-# $FreeBSD$
-
-.include <src.opts.mk>
-
-.PATH: ${.CURDIR}/../../../../usr.bin/login
-
-PROG= login
-SRCS= pico-login.c login_fbtab.c
-MAN= login.1
-
-CFLAGS+=-DLOGALL
-
-LIBADD= util crypt
-
-.if ${MK_PAM_SUPPORT} != "no"
-CFLAGS+= -DUSE_PAM
-LIBADD+= pam
-.endif
-
-BINOWN= root
-BINMODE=4555
-PRECIOUSPROG=
-
-.include <bsd.prog.mk>
diff --git a/release/picobsd/tinyware/login/README b/release/picobsd/tinyware/login/README
deleted file mode 100644
index 4dba3344e6da..000000000000
--- a/release/picobsd/tinyware/login/README
+++ /dev/null
@@ -1,6 +0,0 @@
-$FreeBSD$
-
-This is a modified login version for PicoBSD purposes, which does
-not demand PAM.
-The "login.c" file is replaced by pico-login.c in this directory,
-the remaining files are taken from usr.bin/login/
diff --git a/release/picobsd/tinyware/login/pathnames.h b/release/picobsd/tinyware/login/pathnames.h
deleted file mode 100644
index 23780fc227e6..000000000000
--- a/release/picobsd/tinyware/login/pathnames.h
+++ /dev/null
@@ -1,45 +0,0 @@
-/*-
- * SPDX-License-Identifier: BSD-4-Clause
- *
- * 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.
- *
- * @(#)pathnames.h 8.1 (Berkeley) 6/9/93
- * $FreeBSD$
- */
-
-#include <paths.h>
-
-#define _PATH_HUSHLOGIN ".hushlogin"
-#define _PATH_MOTDFILE "/var/run/motd"
-#define _PATH_LOGACCESS "/etc/login.access"
-#define _PATH_FBTAB "/etc/fbtab"
-#define _PATH_LOGINDEVPERM "/etc/logindevperm"
diff --git a/release/picobsd/tinyware/login/pico-login.c b/release/picobsd/tinyware/login/pico-login.c
deleted file mode 100644
index 080954c8bfcd..000000000000
--- a/release/picobsd/tinyware/login/pico-login.c
+++ /dev/null
@@ -1,1095 +0,0 @@
-/*-
- * SPDX-License-Identifier: BSD-4-Clause
- *
- * Copyright (c) 1980, 1987, 1988, 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.
- */
-
-#if 0
-static char copyright[] =
-"@(#) Copyright (c) 1980, 1987, 1988, 1991, 1993, 1994\n\
- The Regents of the University of California. All rights reserved.\n";
-#endif
-
-#ifndef lint
-#if 0
-static char sccsid[] = "@(#)login.c 8.4 (Berkeley) 4/2/94";
-#endif
-static const char rcsid[] =
- "$FreeBSD$";
-#endif /* not lint */
-
-/*
- * login [ name ]
- * login -h hostname (for telnetd, etc.)
- * login -f name (for pre-authenticated login: datakit, xterm, etc.)
- */
-
-#include <sys/copyright.h>
-#include <sys/param.h>
-#include <sys/stat.h>
-#include <sys/socket.h>
-#include <sys/time.h>
-#include <sys/resource.h>
-#include <sys/file.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-
-#include <err.h>
-#include <errno.h>
-#include <grp.h>
-#include <libutil.h>
-#include <login_cap.h>
-#include <netdb.h>
-#include <pwd.h>
-#include <setjmp.h>
-#include <signal.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <syslog.h>
-#include <ttyent.h>
-#include <unistd.h>
-#include <utmpx.h>
-
-#ifdef USE_PAM
-#include <security/pam_appl.h>
-#include <security/openpam.h>
-#include <sys/wait.h>
-#endif /* USE_PAM */
-
-#include "pathnames.h"
-
-void badlogin(char *);
-void checknologin(void);
-void dolastlog(int);
-void getloginname(void);
-void motd(const char *);
-int rootterm(char *);
-void sigint(int);
-void sleepexit(int);
-void refused(char *,char *,int);
-char *stypeof(char *);
-void timedout(int);
-int login_access(char *, char *);
-void login_fbtab(char *, uid_t, gid_t);
-
-#ifdef USE_PAM
-static int auth_pam(void);
-static int export_pam_environment(void);
-static int ok_to_export(const char *);
-
-static pam_handle_t *pamh = NULL;
-static char **environ_pam;
-
-#define PAM_END { \
- if ((e = pam_setcred(pamh, PAM_DELETE_CRED)) != PAM_SUCCESS) \
- syslog(LOG_ERR, "pam_setcred: %s", pam_strerror(pamh, e)); \
- if ((e = pam_close_session(pamh,0)) != PAM_SUCCESS) \
- syslog(LOG_ERR, "pam_close_session: %s", pam_strerror(pamh, e)); \
- if ((e = pam_end(pamh, e)) != PAM_SUCCESS) \
- syslog(LOG_ERR, "pam_end: %s", pam_strerror(pamh, e)); \
-}
-#endif
-
-static int auth_traditional(void);
-static void usage(void);
-
-#define TTYGRPNAME "tty" /* name of group to own ttys */
-#define DEFAULT_BACKOFF 3
-#define DEFAULT_RETRIES 10
-#define DEFAULT_PROMPT "login: "
-#define DEFAULT_PASSWD_PROMPT "Password:"
-
-/*
- * This bounds the time given to login. Not a define so it can
- * be patched on machines where it's too small.
- */
-u_int timeout = 300;
-
-/* Buffer for signal handling of timeout */
-jmp_buf timeout_buf;
-
-struct passwd *pwd;
-int failures;
-char *term, *envinit[1], *hostname, *tty, *username;
-const char *passwd_prompt, *prompt;
-char full_hostname[MAXHOSTNAMELEN];
-
-int
-main(argc, argv)
- int argc;
- char *argv[];
-{
- extern char **environ;
- struct group *gr;
- struct stat st;
- struct utmpx utmp;
- int rootok, retries, backoff;
- int ask, ch, cnt, fflag, hflag, pflag, quietlog, rootlogin, rval;
- int changepass;
- time_t now, warntime;
- uid_t uid, euid;
- gid_t egid;
- char *p, *ttyn;
- char tbuf[MAXPATHLEN + 2];
- char tname[sizeof(_PATH_TTY) + 10];
- const char *shell = NULL;
- login_cap_t *lc = NULL;
- int UT_HOSTSIZE = sizeof(utmp.ut_host);
- int UT_NAMESIZE = sizeof(utmp.ut_user);
-#ifdef USE_PAM
- pid_t pid;
- int e;
-#endif /* USE_PAM */
-
- (void)signal(SIGQUIT, SIG_IGN);
- (void)signal(SIGINT, SIG_IGN);
- (void)signal(SIGHUP, SIG_IGN);
- if (setjmp(timeout_buf)) {
- if (failures)
- badlogin(tbuf);
- (void)fprintf(stderr, "Login timed out after %d seconds\n",
- timeout);
- exit(0);
- }
- (void)signal(SIGALRM, timedout);
- (void)alarm(timeout);
- (void)setpriority(PRIO_PROCESS, 0, 0);
-
- openlog("login", LOG_ODELAY, LOG_AUTH);
-
- /*
- * -p is used by getty to tell login not to destroy the environment
- * -f is used to skip a second login authentication
- * -h is used by other servers to pass the name of the remote
- * host to login so that it may be placed in utmp and wtmp
- */
- *full_hostname = '\0';
- term = NULL;
-
- fflag = hflag = pflag = 0;
- uid = getuid();
- euid = geteuid();
- egid = getegid();
- while ((ch = getopt(argc, argv, "fh:p")) != -1)
- switch (ch) {
- case 'f':
- fflag = 1;
- break;
- case 'h':
- if (uid)
- errx(1, "-h option: %s", strerror(EPERM));
- hflag = 1;
- if (strlcpy(full_hostname, optarg,
- sizeof(full_hostname)) >= sizeof(full_hostname))
- errx(1, "-h option: %s: exceeds maximum "
- "hostname size", optarg);
-
- trimdomain(optarg, UT_HOSTSIZE);
-
- if (strlen(optarg) > UT_HOSTSIZE) {
- struct addrinfo hints, *res;
- int ga_err;
-
- memset(&hints, 0, sizeof(hints));
- hints.ai_family = AF_UNSPEC;
- ga_err = getaddrinfo(optarg, NULL, &hints,
- &res);
- if (ga_err == 0) {
- char hostbuf[MAXHOSTNAMELEN];
-
- getnameinfo(res->ai_addr,
- res->ai_addrlen,
- hostbuf,
- sizeof(hostbuf), NULL, 0,
- NI_NUMERICHOST);
- optarg = strdup(hostbuf);
- if (optarg == NULL) {
- syslog(LOG_NOTICE,
- "strdup(): %m");
- sleepexit(1);
- }
- } else
- optarg = "invalid hostname";
- if (res != NULL)
- freeaddrinfo(res);
- }
- hostname = optarg;
- break;
- case 'p':
- pflag = 1;
- break;
- case '?':
- default:
- if (!uid)
- syslog(LOG_ERR, "invalid flag %c", ch);
- usage();
- }
- argc -= optind;
- argv += optind;
-
- if (*argv) {
- username = *argv;
- ask = 0;
- } else
- ask = 1;
-
- for (cnt = getdtablesize(); cnt > 2; cnt--)
- (void)close(cnt);
-
- ttyn = ttyname(STDIN_FILENO);
- if (ttyn == NULL || *ttyn == '\0') {
- (void)snprintf(tname, sizeof(tname), "%s??", _PATH_TTY);
- ttyn = tname;
- }
- if ((tty = strrchr(ttyn, '/')) != NULL)
- ++tty;
- else
- tty = ttyn;
-
- /*
- * Get "login-retries" & "login-backoff" from default class
- */
- lc = login_getclass(NULL);
- prompt = login_getcapstr(lc, "login_prompt",
- DEFAULT_PROMPT, DEFAULT_PROMPT);
- passwd_prompt = login_getcapstr(lc, "passwd_prompt",
- DEFAULT_PASSWD_PROMPT, DEFAULT_PASSWD_PROMPT);
- retries = login_getcapnum(lc, "login-retries", DEFAULT_RETRIES,
- DEFAULT_RETRIES);
- backoff = login_getcapnum(lc, "login-backoff", DEFAULT_BACKOFF,
- DEFAULT_BACKOFF);
- login_close(lc);
- lc = NULL;
-
- for (cnt = 0;; ask = 1) {
- if (ask) {
- fflag = 0;
- getloginname();
- }
- rootlogin = 0;
- rootok = rootterm(tty); /* Default (auth may change) */
-
- if (strlen(username) > UT_NAMESIZE)
- username[UT_NAMESIZE] = '\0';
-
- /*
- * Note if trying multiple user names; log failures for
- * previous user name, but don't bother logging one failure
- * for nonexistent name (mistyped username).
- */
- if (failures && strcmp(tbuf, username)) {
- if (failures > (pwd ? 0 : 1))
- badlogin(tbuf);
- }
- (void)strlcpy(tbuf, username, sizeof(tbuf));
-
- pwd = getpwnam(username);
-
- /*
- * if we have a valid account name, and it doesn't have a
- * password, or the -f option was specified and the caller
- * is root or the caller isn't changing their uid, don't
- * authenticate.
- */
- if (pwd != NULL) {
- if (pwd->pw_uid == 0)
- rootlogin = 1;
-
- if (fflag && (uid == (uid_t)0 ||
- uid == (uid_t)pwd->pw_uid)) {
- /* already authenticated */
- break;
- } else if (pwd->pw_passwd[0] == '\0') {
- if (!rootlogin || rootok) {
- /* pretend password okay */
- rval = 0;
- goto ttycheck;
- }
- }
- }
-
- fflag = 0;
-
- (void)setpriority(PRIO_PROCESS, 0, -4);
-
-#ifdef USE_PAM
- /*
- * Try to authenticate using PAM. If a PAM system error
- * occurs, perhaps because of a botched configuration,
- * then fall back to using traditional Unix authentication.
- */
- if ((rval = auth_pam()) == -1)
-#endif /* USE_PAM */
- rval = auth_traditional();
-
- (void)setpriority(PRIO_PROCESS, 0, 0);
-
-#ifdef USE_PAM
- /*
- * PAM authentication may have changed "pwd" to the
- * entry for the template user. Check again to see if
- * this is a root login after all.
- */
- if (pwd != NULL && pwd->pw_uid == 0)
- rootlogin = 1;
-#endif /* USE_PAM */
-
- ttycheck:
- /*
- * If trying to log in as root without Kerberos,
- * but with insecure terminal, refuse the login attempt.
- */
- if (pwd && !rval) {
- if (rootlogin && !rootok)
- refused(NULL, "NOROOT", 0);
- else /* valid password & authenticated */
- break;
- }
-
- (void)printf("Login incorrect\n");
- failures++;
-
- /*
- * we allow up to 'retry' (10) tries,
- * but after 'backoff' (3) we start backing off
- */
- if (++cnt > backoff) {
- if (cnt >= retries) {
- badlogin(username);
- sleepexit(1);
- }
- sleep((u_int)((cnt - backoff) * 5));
- }
- }
-
- /* committed to login -- turn off timeout */
- (void)alarm((u_int)0);
- (void)signal(SIGHUP, SIG_DFL);
-
- endpwent();
-
- /*
- * Establish the login class.
- */
- lc = login_getpwclass(pwd);
-
- /* if user not super-user, check for disabled logins */
- if (!rootlogin)
- auth_checknologin(lc);
-
- quietlog = login_getcapbool(lc, "hushlogin", 0);
- /*
- * Switching needed for NFS with root access disabled.
- *
- * XXX: This change fails to modify the additional groups for the
- * process, and as such, may restrict rights normally granted
- * through those groups.
- */
- (void)setegid(pwd->pw_gid);
- (void)seteuid(rootlogin ? 0 : pwd->pw_uid);
- if (!*pwd->pw_dir || chdir(pwd->pw_dir) < 0) {
- if (login_getcapbool(lc, "requirehome", 0))
- refused("Home directory not available", "HOMEDIR", 1);
- if (chdir("/") < 0)
- refused("Cannot find root directory", "ROOTDIR", 1);
- if (!quietlog || *pwd->pw_dir)
- printf("No home directory.\nLogging in with home = \"/\".\n");
- pwd->pw_dir = "/";
- }
- (void)seteuid(euid);
- (void)setegid(egid);
- if (!quietlog)
- quietlog = access(_PATH_HUSHLOGIN, F_OK) == 0;
-
- now = time(NULL);
-
-#define DEFAULT_WARN (2L * 7L * 86400L) /* Two weeks */
-
- warntime = login_getcaptime(lc, "warnexpire", DEFAULT_WARN,
- DEFAULT_WARN);
-
- if (pwd->pw_expire) {
- if (now >= pwd->pw_expire) {
- refused("Sorry -- your account has expired", "EXPIRED",
- 1);
- } else if (pwd->pw_expire - now < warntime && !quietlog)
- (void)printf("Warning: your account expires on %s",
- ctime(&pwd->pw_expire));
- }
-
- warntime = login_getcaptime(lc, "warnpassword", DEFAULT_WARN,
- DEFAULT_WARN);
-
- changepass = 0;
- if (pwd->pw_change) {
- if (now >= pwd->pw_change) {
- (void)printf("Sorry -- your password has expired.\n");
- changepass = 1;
- syslog(LOG_INFO, "%s Password expired - forcing change",
- pwd->pw_name);
- } else if (pwd->pw_change - now < warntime && !quietlog)
- (void)printf("Warning: your password expires on %s",
- ctime(&pwd->pw_change));
- }
-
- if (lc != NULL) {
- if (hostname) {
- struct addrinfo hints, *res;
- int ga_err;
-
- memset(&hints, 0, sizeof(hints));
- hints.ai_family = AF_UNSPEC;
- ga_err = getaddrinfo(full_hostname, NULL, &hints,
- &res);
- if (ga_err == 0) {
- char hostbuf[MAXHOSTNAMELEN];
-
- getnameinfo(res->ai_addr, res->ai_addrlen,
- hostbuf, sizeof(hostbuf), NULL, 0,
- NI_NUMERICHOST);
- if ((optarg = strdup(hostbuf)) == NULL) {
- syslog(LOG_NOTICE, "strdup(): %m");
- sleepexit(1);
- }
- } else
- optarg = NULL;
- if (res != NULL)
- freeaddrinfo(res);
- if (!auth_hostok(lc, full_hostname, optarg))
- refused("Permission denied", "HOST", 1);
- }
-
- if (!auth_ttyok(lc, tty))
- refused("Permission denied", "TTY", 1);
-
- if (!auth_timeok(lc, time(NULL)))
- refused("Logins not available right now", "TIME", 1);
- }
- shell = login_getcapstr(lc, "shell", pwd->pw_shell, pwd->pw_shell);
- if (*pwd->pw_shell == '\0')
- pwd->pw_shell = _PATH_BSHELL;
- if (*shell == '\0') /* Not overridden */
- shell = pwd->pw_shell;
- if ((shell = strdup(shell)) == NULL) {
- syslog(LOG_NOTICE, "strdup(): %m");
- sleepexit(1);
- }
-
-#ifdef LOGIN_ACCESS
- if (login_access(pwd->pw_name, hostname ? full_hostname : tty) == 0)
- refused("Permission denied", "ACCESS", 1);
-#endif /* LOGIN_ACCESS */
-
-#if 1
- ulog_login(tty, username, hostname);
-#else
- /* Nothing else left to fail -- really log in. */
- memset((void *)&utmp, 0, sizeof(utmp));
- (void)gettimeofday(&utmp.ut_tv, NULL);
- (void)strncpy(utmp.ut_user, username, sizeof(utmp.ut_user));
- if (hostname)
- (void)strncpy(utmp.ut_host, hostname, sizeof(utmp.ut_host));
- (void)strncpy(utmp.ut_line, tty, sizeof(utmp.ut_line));
- login(&utmp);
-#endif
-
- dolastlog(quietlog);
-
- /*
- * Set device protections, depending on what terminal the
- * user is logged in. This feature is used on Suns to give
- * console users better privacy.
- */
- login_fbtab(tty, pwd->pw_uid, pwd->pw_gid);
-
- /*
- * Clear flags of the tty. None should be set, and when the
- * user sets them otherwise, this can cause the chown to fail.
- * Since it isn't clear that flags are useful on character
- * devices, we just clear them.
- */
- if (chflags(ttyn, 0) && errno != EOPNOTSUPP)
- syslog(LOG_ERR, "chflags(%s): %m", ttyn);
- if (chown(ttyn, pwd->pw_uid,
- (gr = getgrnam(TTYGRPNAME)) ? gr->gr_gid : pwd->pw_gid))
- syslog(LOG_ERR, "chown(%s): %m", ttyn);
-
-
- /*
- * Preserve TERM if it happens to be already set.
- */
- if ((term = getenv("TERM")) != NULL) {
- if ((term = strdup(term)) == NULL) {
- syslog(LOG_NOTICE,
- "strdup(): %m");
- sleepexit(1);
- }
- }
-
- /*
- * Exclude cons/vt/ptys only, assume dialup otherwise
- * TODO: Make dialup tty determination a library call
- * for consistency (finger etc.)
- */
- if (hostname==NULL && isdialuptty(tty))
- syslog(LOG_INFO, "DIALUP %s, %s", tty, pwd->pw_name);
-
-#ifdef LOGALL
- /*
- * Syslog each successful login, so we don't have to watch hundreds
- * of wtmp or lastlogin files.
- */
- if (hostname)
- syslog(LOG_INFO, "login from %s on %s as %s",
- full_hostname, tty, pwd->pw_name);
- else
- syslog(LOG_INFO, "login on %s as %s",
- tty, pwd->pw_name);
-#endif
-
- /*
- * If fflag is on, assume caller/authenticator has logged root login.
- */
- if (rootlogin && fflag == 0)
- {
- if (hostname)
- syslog(LOG_NOTICE, "ROOT LOGIN (%s) ON %s FROM %s",
- username, tty, full_hostname);
- else
- syslog(LOG_NOTICE, "ROOT LOGIN (%s) ON %s",
- username, tty);
- }
-
- /*
- * Destroy environment unless user has requested its preservation.
- * We need to do this before setusercontext() because that may
- * set or reset some environment variables.
- */
- if (!pflag)
- environ = envinit;
-
- /*
- * PAM modules might add supplementary groups during pam_setcred().
- */
- if (setusercontext(lc, pwd, pwd->pw_uid, LOGIN_SETGROUP) != 0) {
- syslog(LOG_ERR, "setusercontext() failed - exiting");
- exit(1);
- }
-
-#ifdef USE_PAM
- if (pamh) {
- if ((e = pam_open_session(pamh, 0)) != PAM_SUCCESS) {
- syslog(LOG_ERR, "pam_open_session: %s",
- pam_strerror(pamh, e));
- } else if ((e = pam_setcred(pamh, PAM_ESTABLISH_CRED))
- != PAM_SUCCESS) {
- syslog(LOG_ERR, "pam_setcred: %s",
- pam_strerror(pamh, e));
- }
-
- /*
- * Add any environmental variables that the
- * PAM modules may have set.
- * Call *after* opening session!
- */
- if (pamh) {
- environ_pam = pam_getenvlist(pamh);
- if (environ_pam)
- export_pam_environment();
- }
-
- /*
- * We must fork() before setuid() because we need to call
- * pam_close_session() as root.
- */
- pid = fork();
- if (pid < 0) {
- err(1, "fork");
- PAM_END;
- exit(0);
- } else if (pid) {
- /* parent - wait for child to finish, then cleanup
- session */
- wait(NULL);
- PAM_END;
- exit(0);
- } else {
- if ((e = pam_end(pamh, 0)) != PAM_SUCCESS)
- syslog(LOG_ERR, "pam_end: %s",
- pam_strerror(pamh, e));
- }
- }
-#endif /* USE_PAM */
-
- /*
- * We don't need to be root anymore, so
- * set the user and session context
- */
- if (setlogin(username) != 0) {
- syslog(LOG_ERR, "setlogin(%s): %m - exiting", username);
- exit(1);
- }
- if (setusercontext(lc, pwd, pwd->pw_uid,
- LOGIN_SETALL & ~(LOGIN_SETLOGIN|LOGIN_SETGROUP)) != 0) {
- syslog(LOG_ERR, "setusercontext() failed - exiting");
- exit(1);
- }
-
- (void)setenv("SHELL", pwd->pw_shell, 1);
- (void)setenv("HOME", pwd->pw_dir, 1);
- if (term != NULL && *term != '\0')
- (void)setenv("TERM", term, 1); /* Preset overrides */
- else {
- (void)setenv("TERM", stypeof(tty), 0); /* Fallback doesn't */
- }
- (void)setenv("LOGNAME", username, 1);
- (void)setenv("USER", username, 1);
- (void)setenv("PATH", rootlogin ? _PATH_STDPATH : _PATH_DEFPATH, 0);
-
- if (!quietlog) {
- const char *cw;
-
- cw = login_getcapstr(lc, "copyright", NULL, NULL);
- if (cw != NULL && access(cw, F_OK) == 0)
- motd(cw);
- else
- (void)printf("%s\n\t%s %s\n",
- "Copyright (c) 1980, 1983, 1986, 1988, 1990, 1991, 1993, 1994",
- "The Regents of the University of California. ",
- "All rights reserved.");
-
- (void)printf("\n");
-
- cw = login_getcapstr(lc, "welcome", NULL, NULL);
- if (cw == NULL || access(cw, F_OK) != 0)
- cw = _PATH_MOTDFILE;
- motd(cw);
-
- cw = getenv("MAIL"); /* $MAIL may have been set by class */
- if (cw != NULL)
- strlcpy(tbuf, cw, sizeof(tbuf));
- else
- snprintf(tbuf, sizeof(tbuf), "%s/%s", _PATH_MAILDIR,
- pwd->pw_name);
- if (stat(tbuf, &st) == 0 && st.st_size != 0)
- (void)printf("You have %smail.\n",
- (st.st_mtime > st.st_atime) ? "new " : "");
- }
-
- login_close(lc);
-
- (void)signal(SIGALRM, SIG_DFL);
- (void)signal(SIGQUIT, SIG_DFL);
- (void)signal(SIGINT, SIG_DFL);
- (void)signal(SIGTSTP, SIG_IGN);
-
- /*
- * Login shells have a leading '-' in front of argv[0]
- */
- if (snprintf(tbuf, sizeof(tbuf), "-%s",
- (p = strrchr(pwd->pw_shell, '/')) ? p + 1 : pwd->pw_shell) >=
- sizeof(tbuf)) {
- syslog(LOG_ERR, "user: %s: shell exceeds maximum pathname size",
- username);
- errx(1, "shell exceeds maximum pathname size");
- }
-
- execlp(shell, tbuf, (char *)0);
- err(1, "%s", shell);
-}
-
-static int
-auth_traditional()
-{
- int rval;
- char *p;
- char *ep;
- char *salt;
-
- rval = 1;
- salt = pwd != NULL ? pwd->pw_passwd : "xx";
-
- p = getpass(passwd_prompt);
- ep = crypt(p, salt);
-
- if (pwd) {
- if (!p[0] && pwd->pw_passwd[0])
- ep = ":";
- if (strcmp(ep, pwd->pw_passwd) == 0)
- rval = 0;
- }
-
- /* clear entered password */
- memset(p, 0, strlen(p));
- return rval;
-}
-
-#ifdef USE_PAM
-/*
- * Attempt to authenticate the user using PAM. Returns 0 if the user is
- * authenticated, or 1 if not authenticated. If some sort of PAM system
- * error occurs (e.g., the "/etc/pam.conf" file is missing) then this
- * function returns -1. This can be used as an indication that we should
- * fall back to a different authentication mechanism.
- */
-static int
-auth_pam()
-{
- const char *tmpl_user;
- const void *item;
- int rval;
- int e;
- static struct pam_conv conv = { openpam_ttyconv, NULL };
-
- if ((e = pam_start("login", username, &conv, &pamh)) != PAM_SUCCESS) {
- syslog(LOG_ERR, "pam_start: %s", pam_strerror(pamh, e));
- return -1;
- }
- if ((e = pam_set_item(pamh, PAM_TTY, tty)) != PAM_SUCCESS) {
- syslog(LOG_ERR, "pam_set_item(PAM_TTY): %s",
- pam_strerror(pamh, e));
- return -1;
- }
- if (hostname != NULL &&
- (e = pam_set_item(pamh, PAM_RHOST, full_hostname)) != PAM_SUCCESS) {
- syslog(LOG_ERR, "pam_set_item(PAM_RHOST): %s",
- pam_strerror(pamh, e));
- return -1;
- }
- e = pam_authenticate(pamh, 0);
- switch (e) {
-
- case PAM_SUCCESS:
- /*
- * With PAM we support the concept of a "template"
- * user. The user enters a login name which is
- * authenticated by PAM, usually via a remote service
- * such as RADIUS or TACACS+. If authentication
- * succeeds, a different but related "template" name
- * is used for setting the credentials, shell, and
- * home directory. The name the user enters need only
- * exist on the remote authentication server, but the
- * template name must be present in the local password
- * database.
- *
- * This is supported by two various mechanisms in the
- * individual modules. However, from the application's
- * point of view, the template user is always passed
- * back as a changed value of the PAM_USER item.
- */
- if ((e = pam_get_item(pamh, PAM_USER, &item)) ==
- PAM_SUCCESS) {
- tmpl_user = (const char *) item;
- if (strcmp(username, tmpl_user) != 0)
- pwd = getpwnam(tmpl_user);
- } else
- syslog(LOG_ERR, "Couldn't get PAM_USER: %s",
- pam_strerror(pamh, e));
- rval = 0;
- break;
-
- case PAM_AUTH_ERR:
- case PAM_USER_UNKNOWN:
- case PAM_MAXTRIES:
- rval = 1;
- break;
-
- default:
- syslog(LOG_ERR, "pam_authenticate: %s", pam_strerror(pamh, e));
- rval = -1;
- break;
- }
-
- if (rval == 0) {
- e = pam_acct_mgmt(pamh, 0);
- if (e == PAM_NEW_AUTHTOK_REQD) {
- e = pam_chauthtok(pamh, PAM_CHANGE_EXPIRED_AUTHTOK);
- if (e != PAM_SUCCESS) {
- syslog(LOG_ERR, "pam_chauthtok: %s",
- pam_strerror(pamh, e));
- rval = 1;
- }
- } else if (e != PAM_SUCCESS) {
- rval = 1;
- }
- }
-
- if (rval != 0) {
- if ((e = pam_end(pamh, e)) != PAM_SUCCESS) {
- syslog(LOG_ERR, "pam_end: %s", pam_strerror(pamh, e));
- }
- pamh = NULL;
- }
- return rval;
-}
-
-static int
-export_pam_environment()
-{
- char **pp;
-
- for (pp = environ_pam; *pp != NULL; pp++) {
- if (ok_to_export(*pp))
- (void) putenv(*pp);
- free(*pp);
- }
- return PAM_SUCCESS;
-}
-
-/*
- * Sanity checks on PAM environmental variables:
- * - Make sure there is an '=' in the string.
- * - Make sure the string doesn't run on too long.
- * - Do not export certain variables. This list was taken from the
- * Solaris pam_putenv(3) man page.
- */
-static int
-ok_to_export(s)
- const char *s;
-{
- static const char *noexport[] = {
- "SHELL", "HOME", "LOGNAME", "MAIL", "CDPATH",
- "IFS", "PATH", NULL
- };
- const char **pp;
- size_t n;
-
- if (strlen(s) > 1024 || strchr(s, '=') == NULL)
- return 0;
- if (strncmp(s, "LD_", 3) == 0)
- return 0;
- for (pp = noexport; *pp != NULL; pp++) {
- n = strlen(*pp);
- if (s[n] == '=' && strncmp(s, *pp, n) == 0)
- return 0;
- }
- return 1;
-}
-#endif /* USE_PAM */
-
-static void
-usage()
-{
-
- (void)fprintf(stderr, "usage: login [-fp] [-h hostname] [username]\n");
- exit(1);
-}
-
-/*
- * Allow for authentication style and/or kerberos instance
- */
-
-#define NBUFSIZ 128 // XXX was UT_NAMESIZE + 64
-
-void
-getloginname()
-{
- int ch;
- char *p;
- static char nbuf[NBUFSIZ];
-
- for (;;) {
- (void)printf("%s", prompt);
- for (p = nbuf; (ch = getchar()) != '\n'; ) {
- if (ch == EOF) {
- badlogin(username);
- exit(0);
- }
- if (p < nbuf + (NBUFSIZ - 1))
- *p++ = ch;
- }
- if (p > nbuf) {
- if (nbuf[0] == '-')
- (void)fprintf(stderr,
- "login names may not start with '-'.\n");
- else {
- *p = '\0';
- username = nbuf;
- break;
- }
- }
- }
-}
-
-int
-rootterm(ttyn)
- char *ttyn;
-{
- struct ttyent *t;
-
- return ((t = getttynam(ttyn)) && t->ty_status & TTY_SECURE);
-}
-
-volatile int motdinterrupt;
-
-void
-sigint(signo)
- int signo __unused;
-{
- motdinterrupt = 1;
-}
-
-void
-motd(motdfile)
- const char *motdfile;
-{
- int fd, nchars;
- sig_t oldint;
- char tbuf[256];
-
- if ((fd = open(motdfile, O_RDONLY, 0)) < 0)
- return;
- motdinterrupt = 0;
- oldint = signal(SIGINT, sigint);
- while ((nchars = read(fd, tbuf, sizeof(tbuf))) > 0 && !motdinterrupt)
- (void)write(fileno(stdout), tbuf, nchars);
- (void)signal(SIGINT, oldint);
- (void)close(fd);
-}
-
-/* ARGSUSED */
-void
-timedout(signo)
- int signo;
-{
-
- longjmp(timeout_buf, signo);
-}
-
-
-void
-dolastlog(quiet)
- int quiet;
-{
-#if 0 /* XXX not implemented after utmp->utmpx change */
- struct lastlog ll;
- int fd;
-
- if ((fd = open(_PATH_LASTLOG, O_RDWR, 0)) >= 0) {
- (void)lseek(fd, (off_t)pwd->pw_uid * sizeof(ll), L_SET);
- if (!quiet) {
- if (read(fd, (char *)&ll, sizeof(ll)) == sizeof(ll) &&
- ll.ll_time != 0) {
- (void)printf("Last login: %.*s ",
- 24-5, (char *)ctime(&ll.ll_time));
- if (*ll.ll_host != '\0')
- (void)printf("from %.*s\n",
- (int)sizeof(ll.ll_host),
- ll.ll_host);
- else
- (void)printf("on %.*s\n",
- (int)sizeof(ll.ll_line),
- ll.ll_line);
- }
- (void)lseek(fd, (off_t)pwd->pw_uid * sizeof(ll), L_SET);
- }
- memset((void *)&ll, 0, sizeof(ll));
- (void)time(&ll.ll_time);
- (void)strncpy(ll.ll_line, tty, sizeof(ll.ll_line));
- if (hostname)
- (void)strncpy(ll.ll_host, hostname, sizeof(ll.ll_host));
- (void)write(fd, (char *)&ll, sizeof(ll));
- (void)close(fd);
- } else {
- syslog(LOG_ERR, "cannot open %s: %m", _PATH_LASTLOG);
- }
-#endif
-}
-
-void
-badlogin(name)
- char *name;
-{
-
- if (failures == 0)
- return;
- if (hostname) {
- syslog(LOG_NOTICE, "%d LOGIN FAILURE%s FROM %s",
- failures, failures > 1 ? "S" : "", full_hostname);
- syslog(LOG_AUTHPRIV|LOG_NOTICE,
- "%d LOGIN FAILURE%s FROM %s, %s",
- failures, failures > 1 ? "S" : "", full_hostname, name);
- } else {
- syslog(LOG_NOTICE, "%d LOGIN FAILURE%s ON %s",
- failures, failures > 1 ? "S" : "", tty);
- syslog(LOG_AUTHPRIV|LOG_NOTICE,
- "%d LOGIN FAILURE%s ON %s, %s",
- failures, failures > 1 ? "S" : "", tty, name);
- }
- failures = 0;
-}
-
-#undef UNKNOWN
-#define UNKNOWN "su"
-
-char *
-stypeof(ttyid)
- char *ttyid;
-{
- struct ttyent *t;
-
- if (ttyid != NULL && *ttyid != '\0') {
- t = getttynam(ttyid);
- if (t != NULL && t->ty_type != NULL)
- return (t->ty_type);
- }
- return (UNKNOWN);
-}
-
-void
-refused(msg, rtype, lout)
- char *msg;
- char *rtype;
- int lout;
-{
-
- if (msg != NULL)
- printf("%s.\n", msg);
- if (hostname)
- syslog(LOG_NOTICE, "LOGIN %s REFUSED (%s) FROM %s ON TTY %s",
- pwd->pw_name, rtype, full_hostname, tty);
- else
- syslog(LOG_NOTICE, "LOGIN %s REFUSED (%s) ON TTY %s",
- pwd->pw_name, rtype, tty);
- if (lout)
- sleepexit(1);
-}
-
-void
-sleepexit(eval)
- int eval;
-{
-
- (void)sleep(5);
- exit(eval);
-}
diff --git a/release/picobsd/tinyware/msg/Makefile b/release/picobsd/tinyware/msg/Makefile
deleted file mode 100644
index ab0ad2bf9614..000000000000
--- a/release/picobsd/tinyware/msg/Makefile
+++ /dev/null
@@ -1,9 +0,0 @@
-# $FreeBSD$
-#
-PROG=msg
-SRCS= msg.c
-MAN=
-
-.include <bsd.prog.mk>
-
-
diff --git a/release/picobsd/tinyware/msg/README b/release/picobsd/tinyware/msg/README
deleted file mode 100644
index d26e38326a9e..000000000000
--- a/release/picobsd/tinyware/msg/README
+++ /dev/null
@@ -1,15 +0,0 @@
-1998.09.14, Warsaw
-
-This program replaces 'dmesg' utility, aand allows you to retrieve the
-system's message buffer without resorting to such dirty tricks as normal
-'dmesg' uses (using libkvm and /dev/kmem to directly read kernel
-memory.. *shudder*).
-
-This utility uses sysctl(3) interface. The mib variable it uses was
-recently added to the kernel sources, so if you don't mind patching your
-kernel tree, contact me directly - the patches are very small and simple.
-
-Andrzej Bialecki
-<abial@freebsd.org>
-
-$FreeBSD$
diff --git a/release/picobsd/tinyware/msg/msg.c b/release/picobsd/tinyware/msg/msg.c
deleted file mode 100644
index 4d0c3c1f935f..000000000000
--- a/release/picobsd/tinyware/msg/msg.c
+++ /dev/null
@@ -1,75 +0,0 @@
-/*-
- * Copyright (c) 1998 Andrzej Bialecki <abial@freebsd.org>
- * 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.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-
-/*
- * Small replacement for 'dmesg'. It doesn't need libkvm nor /dev/kmem.
- */
-
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <sys/types.h>
-#include <sys/sysctl.h>
-
-int
-main(int argc, char *argv[])
-{
- int len,i;
- char *buf,*p;
- char *mib="kern.msgbuf";
-
- /* We use sysctlbyname, because the oid is unknown (OID_AUTO) */
-
- /* get the buffer size */
- i=sysctlbyname(mib,NULL,&len,NULL,0);
- if(i) {
- perror("buffer sizing");
- exit(-1);
- }
- buf=(char *)malloc(len*sizeof(char));
- i=sysctlbyname(mib,buf,&len,NULL,0);
- if(i) {
- perror("retrieving data");
- exit(-1);
- }
- p=buf;
- i=0;
- while(p<(buf+len)) {
- switch(*p) {
- case '\0':
- /* skip initial NULLs */
- break;
- default:
- putchar(*p);
- }
- p++;
- }
- if(*--p!='\n') putchar('\n');
- free(buf);
- exit(0);
-}
diff --git a/release/picobsd/tinyware/msh/Makefile b/release/picobsd/tinyware/msh/Makefile
deleted file mode 100644
index e1a1b541ca35..000000000000
--- a/release/picobsd/tinyware/msh/Makefile
+++ /dev/null
@@ -1,8 +0,0 @@
-# $FreeBSD$
-#
-PROG=msh
-SRCS= sh1.c sh2.c sh3.c sh4.c sh5.c sh6.c
-
-.include <bsd.prog.mk>
-
-
diff --git a/release/picobsd/tinyware/msh/README b/release/picobsd/tinyware/msh/README
deleted file mode 100644
index 1b95b8271c8a..000000000000
--- a/release/picobsd/tinyware/msh/README
+++ /dev/null
@@ -1,13 +0,0 @@
-This is a port of Minix /bin/sh shell.
-
-It's quite limited, but also quite small. One of most serious
-limitations is lack of support for user-defined functions. Also,
-globbing should be implemented with our glob(3) - the version in
-sh4.c is rather primitive.
-
-This version is under BSD license.
-
-Andrzej Bialecki
-<abial@FreeBSD.org>
-
-$Id$
diff --git a/release/picobsd/tinyware/msh/msh.1 b/release/picobsd/tinyware/msh/msh.1
deleted file mode 100644
index bbfa2556f2a1..000000000000
--- a/release/picobsd/tinyware/msh/msh.1
+++ /dev/null
@@ -1,260 +0,0 @@
-.TH SH 1
-.SH NAME
-sh, ., break, case, cd, continue, eval, exec, exit, export, for, if, read, readonly, set, shift, trap, umask, wait, while \- shell
-.SH SYNOPSIS
-\fBsh\fR [\fB\-eiknqstvxu\fR] [\fB\-c \fIstr\fR] \fB[\fIfile\fR]\fR
-.br
-.de FL
-.TP
-\\fB\\$1\\fR
-\\$2
-..
-.de EX
-.TP 20
-\\fB\\$1\\fR
-# \\$2
-..
-.SH OPTIONS
-.FL "\-c" "Execute the commands in \fIstr\fR"
-.FL "\-e" "Quit on error"
-.FL "\-i" "Interactive mode; ignore QUIT, TERMINATE, INTERRUPT"
-.FL "\-k" "Look for name=value everywhere on command line"
-.FL "\-n" "Do not execute commands"
-.FL "\-q" "Change qflag from sig_ign to sig_del"
-.FL "\-s" "Read commands from standard input"
-.FL "\-t" "Exit after reading and executing one command"
-.FL "\-v" "Echo input lines as they are read"
-.FL "\-x" "Trace"
-.FL "\-u" "Unset variables"
-.SH EXAMPLES
-.EX "sh script" "Run a shell script"
-.SH DESCRIPTION
-.I Sh
-is the shell, which forms the user's main interface with the system.
-On startup, the shell reads /etc/profile and $HOME/.profile, if they exist,
-and executes any commands they contain. The Minix shell has most of the
-features of the V7 (Bourne) shell, including redirection of input and output,
-pipes, magic characters, background processes, and shell scripts. A brief
-summary follows, but whole books have been written on shell programming alone.
-.LP
-Some of the more common notations are:
-.PP
-.in +2.45i
-.ta 2i 2.2i
-.ti -2.2i
-date # Regular command
-.ti -2.2i
-sort <file # Redirect \fIstdin\fR (standard input)
-.ti -2.2i
-sort <file1 >file2 # Redirect \fIstdin\fR and \fIstdout\fR
-.ti -2.2i
-cc file.c 2>error # Redirect \fIstderr\fR
-.ti -2.2i
-a.out >f 2>&1 # Combine standard output and standard error
-.ti -2.2i
-sort <file1 >>file2 # Append output to \fIfile2\fR
-.ti -2.2i
-sort <file1 >file2 & # Background job
-.ti -2.2i
-(ls \-l; a.out) & # Run two background commands sequentially
-.ti -2.2i
-sort <file | wc # Two-process pipeline
-.ti -2.2i
-sort <f | uniq | wc # Three-process pipeline
-.ti -2.2i
-ls \-l *.c # List all files ending in \fI.c\fR
-.ti -2.2i
-ls \-l [\fIa-c\fR]* # List all files beginning with \fIa\fR, \fIb\fR, or \fIc\fR
-.ti -2.2i
-ls \-l ? # List all one-character file names
-.ti -2.2i
-ls \e? # List the file whose name is question mark
-.ti -2.2i
-ls \(fm???\(fm # List the file whose name is three question marks
-.ti -2.2i
-v=/usr/ast # Set shell variable \fIv\fR
-.ti -2.2i
-ls \-l $v # Use shell variable \fIv\fR
-.ti -2.2i
-PS1=\(fmHi! \(fm # Change the primary prompt to \fIHi!\fR
-.ti -2.2i
-PS2=\(fmMore: \(fm # Change the secondary prompt to \fIMore:\fR
-.ti -2.2i
-ls \-l $HOME # List the home directory
-.ti -2.2i
-echo $PATH # Echo the search path
-.ti -2.2i
-echo $? # Echo exit status of previous command in decimal
-.ti -2.2i
-echo $$ # Echo shell's pid in decimal
-.ti -2.2i
-echo $! # Echo PID of last background process
-.ti -2.2i
-echo $# # Echo number of parameters (shell script)
-.ti -2.2i
-echo $2 # Echo second parameter (shell script)
-.ti -2.2i
-echo "$2" # Echo second parameter without expanding spaces
-.ti -2.2i
-echo $* # Echo all parameters (shell script)
-.ti -2.2i
-echo $@ # Echo all parameters (shell script)
-.ti -2.2i
-echo "$@" # Echo all parameters without expanding spaces
-.in -2.45i
-.LP
-The shell uses the following variables for specific purposes:
-.PP
-.in +2.25i
-.ta 2i
-.ti -2i
-SHELL the path of the current shell
-.ti -2i
-HOME the default value for the cd(1) command
-.ti -2i
-PATH the directories to be searched to find commands
-.ti -2i
-IFS the internal field separators for command strings
-.ti -2i
-PS1 the primary shell prompt
-.ti -2i
-PS2 the secondary shell prompt
-.in -2.25i
-.LP
-There are various forms of substitution on the shell command line:
-.PP
-.in +2.25i
-.ta 2i
-.ti -2i
-`...` Command string between back-quotes is replaced by its output
-.ti -2i
-"..." Permits variable substitution between quotes
-.ti -2i
-\&'...' Inhibits variable substitution between quotes
-.ti -2i
-$VAR Replaced by contents of variable VAR
-.ti -2i
-${VAR} Delimits variable VAR from any following string
-.in -2.25i
-.LP
-The expressions below depend on whether or not VAR has ever been set.
-If VAR has been set, they give:
-.PP
-.in +2.25i
-.ta 2i
-.ti -2i
-${VAR-str} Replace expression by VAR, else by str
-.ti -2i
-${VAR=str} Replace expression by VAR, else by str and set VAR to str
-.ti -2i
-${VAR?str} Replace expression by VAR, else print str and exit shell
-.ti -2i
-${VAR+str} Replace expression by str, else by null string
-.in -2.25i
-.LP
-If a colon is placed after VAR, the expressions depend on whether or not
-VAR is currently set and non-null.
-.LP
-The shell has a number of built-in commands:
-.PP
-.in +2.25i
-.ta 2i
-.ti -2i
-: return true status
-.ti -2i
-\&. fn execute shell script fn on current path
-.ti -2i
-break [n] break from a for, until or while loop; exit n levels
-.ti -2i
-continue [n] continue a for, until or while loop; resume nth loop
-.ti -2i
-cd [dir] change current working directory; move to $HOME
-.ti -2i
-eval cmd rescan cmd, performing substitutions
-.ti -2i
-eval rescan the current command line
-.ti -2i
-exec cmd execute cmd without creating a new process
-.ti -2i
-exec <|> with no command name, modify shell I/O
-.ti -2i
-exit [n] exit a shell program, with exit value n
-.ti -2i
-export [var] export var to shell's children; list exported variables
-.ti -2i
-pwd print the name of the current working directory
-.ti -2i
-read var read a line from stdin and assign to var
-.ti -2i
-readonly [var] make var readonly; list readonly variables
-.ti -2i
-set -f set shell flag (+f unsets flag)
-.ti -2i
-set str set positional parameter to str
-.ti -2i
-set show the current shell variables
-.ti -2i
-shift reassign positional parameters (except ${0}) one left
-.ti -2i
-times print accumulated user and system times for processes
-.ti -2i
-trap arg sigs trap signals sigs and run arg on receipt
-.ti -2i
-trap list trapped signals
-.ti -2i
-umask [n] set the user file creation mask; show the current umask
-.ti -2i
-wait [n] wait for process pid n; wait for all processes
-.in -2.25i
-.LP
-The shell also contains a programming language, which has the following
-operators and flow control statements:
-.PP
-.in +3.50i
-.ta 2i 3.25i
-.ti -3.25i
-# Comment The rest of the line is ignored
-.ti -3.25i
-= Assignment Set a shell variable
-.ti -3.25i
-&& Logical AND Execute second command only if first succeeds
-.ti -3.25i
-|| Logical OR Execute second command only if first fails
-.ti -3.25i
-(...) Group Execute enclosed commands before continuing
-.in -3.50i
-.PP
-.in +2.25i
-.ta 2i
-.ti -2i
-for For loop (for ... in ... do ... done)
-.ti -2i
-case Case statement ((case ... ) ... ;; ... esac)
-.ti -2i
-esac Case statement end
-.ti -2i
-while While loop (while ... do ... done)
-.ti -2i
-do Do/For/While loop start (do ... until ...)
-.ti -2i
-done For/While loop end
-.ti -2i
-if Conditional statement (if ... else ... elif ... fi)
-.ti -2i
-in For loop selection
-.ti -2i
-then Conditional statement start
-.ti -2i
-else Conditional statement alternative
-.ti -2i
-elif Conditional statement end
-.ti -2i
-until Do loop end
-.ti -2i
-fi Conditional statement end
-.in -2.25i
-.SH "SEE ALSO"
-.BR echo (1),
-.BR expr (1),
-.BR pwd (1),
-.BR true (1).
diff --git a/release/picobsd/tinyware/msh/sh.h b/release/picobsd/tinyware/msh/sh.h
deleted file mode 100644
index 223761eb18c7..000000000000
--- a/release/picobsd/tinyware/msh/sh.h
+++ /dev/null
@@ -1,388 +0,0 @@
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-#include <fcntl.h>
-
-/* Need a way to have void used for ANSI, nothing for K&R. */
-#ifndef _ANSI
-#undef _VOID
-#define _VOID
-#endif
-
-/* -------- sh.h -------- */
-/*
- * shell
- */
-
-#define LINELIM 2100
-#define NPUSH 8 /* limit to input nesting */
-
-#define NOFILE 20 /* Number of open files */
-#define NUFILE 10 /* Number of user-accessible files */
-#define FDBASE 10 /* First file usable by Shell */
-
-/*
- * values returned by wait
- */
-#define WAITSIG(s) ((s)&0177)
-#define WAITVAL(s) (((s)>>8)&0377)
-#define WAITCORE(s) (((s)&0200)!=0)
-
-/*
- * library and system defintions
- */
-#ifdef __STDC__
-typedef void xint; /* base type of jmp_buf, for not broken compilers */
-#else
-typedef char * xint; /* base type of jmp_buf, for broken compilers */
-#endif
-
-/*
- * shell components
- */
-/* #include "area.h" */
-/* #include "word.h" */
-/* #include "io.h" */
-/* #include "var.h" */
-
-#define QUOTE 0200
-
-#define NOBLOCK ((struct op *)NULL)
-#define NOWORD ((char *)NULL)
-#define NOWORDS ((char **)NULL)
-#define NOPIPE ((int *)NULL)
-
-/*
- * Description of a command or an operation on commands.
- * Might eventually use a union.
- */
-struct op {
- int type; /* operation type, see below */
- char **words; /* arguments to a command */
- struct ioword **ioact; /* IO actions (eg, < > >>) */
- struct op *left;
- struct op *right;
- char *str; /* identifier for case and for */
-};
-
-#define TCOM 1 /* command */
-#define TPAREN 2 /* (c-list) */
-#define TPIPE 3 /* a | b */
-#define TLIST 4 /* a [&;] b */
-#define TOR 5 /* || */
-#define TAND 6 /* && */
-#define TFOR 7
-#define TDO 8
-#define TCASE 9
-#define TIF 10
-#define TWHILE 11
-#define TUNTIL 12
-#define TELIF 13
-#define TPAT 14 /* pattern in case */
-#define TBRACE 15 /* {c-list} */
-#define TASYNC 16 /* c & */
-
-/*
- * actions determining the environment of a process
- */
-#define BIT(i) (1<<(i))
-#define FEXEC BIT(0) /* execute without forking */
-
-/*
- * flags to control evaluation of words
- */
-#define DOSUB 1 /* interpret $, `, and quotes */
-#define DOBLANK 2 /* perform blank interpretation */
-#define DOGLOB 4 /* interpret [?* */
-#define DOKEY 8 /* move words with `=' to 2nd arg. list */
-#define DOTRIM 16 /* trim resulting string */
-
-#define DOALL (DOSUB|DOBLANK|DOGLOB|DOKEY|DOTRIM)
-
-Extern char **dolv;
-Extern int dolc;
-Extern int exstat;
-Extern char gflg;
-Extern int talking; /* interactive (talking-type wireless) */
-Extern int execflg;
-Extern int multiline; /* \n changed to ; */
-Extern struct op *outtree; /* result from parser */
-
-Extern xint *failpt;
-Extern xint *errpt;
-
-struct brkcon {
- jmp_buf brkpt;
- struct brkcon *nextlev;
-} ;
-Extern struct brkcon *brklist;
-Extern int isbreak;
-
-/*
- * redirection
- */
-struct ioword {
- short io_unit; /* unit affected */
- short io_flag; /* action (below) */
- char *io_name; /* file name */
-};
-#define IOREAD 1 /* < */
-#define IOHERE 2 /* << (here file) */
-#define IOWRITE 4 /* > */
-#define IOCAT 8 /* >> */
-#define IOXHERE 16 /* ${}, ` in << */
-#define IODUP 32 /* >&digit */
-#define IOCLOSE 64 /* >&- */
-
-#define IODEFAULT (-1) /* token for default IO unit */
-
-Extern struct wdblock *wdlist;
-Extern struct wdblock *iolist;
-
-/*
- * parsing & execution environment
- */
-extern struct env {
- char *linep;
- struct io *iobase;
- struct io *iop;
- xint *errpt;
- int iofd;
- struct env *oenv;
-} e;
-
-/*
- * flags:
- * -e: quit on error
- * -k: look for name=value everywhere on command line
- * -n: no execution
- * -t: exit after reading and executing one command
- * -v: echo as read
- * -x: trace
- * -u: unset variables net diagnostic
- */
-extern char *flag;
-
-extern char *null; /* null value for variable */
-extern int intr; /* interrupt pending */
-
-Extern char *trap[_NSIG+1];
-Extern char ourtrap[_NSIG+1];
-Extern int trapset; /* trap pending */
-
-extern int heedint; /* heed interrupt signals */
-
-Extern int yynerrs; /* yacc */
-
-Extern char line[LINELIM];
-extern char *elinep;
-
-/*
- * other functions
- */
-#ifdef __STDC__
-int (*inbuilt(char *s ))(void);
-#else
-int (*inbuilt())();
-#endif
-
-#ifdef __FreeBSD__
-#define _PROTOTYPE(x,y) x ## y
-#endif
-
-_PROTOTYPE(char *rexecve , (char *c , char **v , char **envp ));
-_PROTOTYPE(char *space , (int n ));
-_PROTOTYPE(char *strsave , (char *s , int a ));
-_PROTOTYPE(char *evalstr , (char *cp , int f ));
-_PROTOTYPE(char *putn , (int n ));
-_PROTOTYPE(char *itoa , (unsigned u , int n ));
-_PROTOTYPE(char *unquote , (char *as ));
-_PROTOTYPE(struct var *lookup , (char *n ));
-_PROTOTYPE(int rlookup , (char *n ));
-_PROTOTYPE(struct wdblock *glob , (char *cp , struct wdblock *wb ));
-_PROTOTYPE(int subgetc , (int ec , int quoted ));
-_PROTOTYPE(char **makenv , (void));
-_PROTOTYPE(char **eval , (char **ap , int f ));
-_PROTOTYPE(int setstatus , (int s ));
-_PROTOTYPE(int waitfor , (int lastpid , int canintr ));
-
-_PROTOTYPE(void onintr , (int s )); /* SIGINT handler */
-
-_PROTOTYPE(int newenv , (int f ));
-_PROTOTYPE(void quitenv , (void));
-_PROTOTYPE(void err , (char *s ));
-_PROTOTYPE(int anys , (char *s1 , char *s2 ));
-_PROTOTYPE(int any , (int c , char *s ));
-_PROTOTYPE(void next , (int f ));
-_PROTOTYPE(void setdash , (void));
-_PROTOTYPE(void onecommand , (void));
-_PROTOTYPE(void runtrap , (int i ));
-_PROTOTYPE(void xfree , (char *s ));
-_PROTOTYPE(int letter , (int c ));
-_PROTOTYPE(int digit , (int c ));
-_PROTOTYPE(int letnum , (int c ));
-_PROTOTYPE(int gmatch , (char *s , char *p ));
-
-/*
- * error handling
- */
-_PROTOTYPE(void leave , (void)); /* abort shell (or fail in subshell) */
-_PROTOTYPE(void fail , (void)); /* fail but return to process next command */
-_PROTOTYPE(void warn , (char *s ));
-_PROTOTYPE(void sig , (int i )); /* default signal handler */
-
-/* -------- var.h -------- */
-
-struct var {
- char *value;
- char *name;
- struct var *next;
- char status;
-};
-#define COPYV 1 /* flag to setval, suggesting copy */
-#define RONLY 01 /* variable is read-only */
-#define EXPORT 02 /* variable is to be exported */
-#define GETCELL 04 /* name & value space was got with getcell */
-
-Extern struct var *vlist; /* dictionary */
-
-Extern struct var *homedir; /* home directory */
-Extern struct var *prompt; /* main prompt */
-Extern struct var *cprompt; /* continuation prompt */
-Extern struct var *path; /* search path for commands */
-Extern struct var *shell; /* shell to interpret command files */
-Extern struct var *ifs; /* field separators */
-
-_PROTOTYPE(int yyparse , (void));
-_PROTOTYPE(struct var *lookup , (char *n ));
-_PROTOTYPE(void setval , (struct var *vp , char *val ));
-_PROTOTYPE(void nameval , (struct var *vp , char *val , char *name ));
-_PROTOTYPE(void export , (struct var *vp ));
-_PROTOTYPE(void ronly , (struct var *vp ));
-_PROTOTYPE(int isassign , (char *s ));
-_PROTOTYPE(int checkname , (char *cp ));
-_PROTOTYPE(int assign , (char *s , int cf ));
-_PROTOTYPE(void putvlist , (int f , int out ));
-_PROTOTYPE(int eqname , (char *n1 , char *n2 ));
-
-_PROTOTYPE(int execute , (struct op *t , int *pin , int *pout , int act ));
-
-/* -------- io.h -------- */
-/* io buffer */
-struct iobuf {
- unsigned id; /* buffer id */
- char buf[512]; /* buffer */
- char *bufp; /* pointer into buffer */
- char *ebufp; /* pointer to end of buffer */
-};
-
-/* possible arguments to an IO function */
-struct ioarg {
- char *aword;
- char **awordlist;
- int afile; /* file descriptor */
- unsigned afid; /* buffer id */
- long afpos; /* file position */
- struct iobuf *afbuf; /* buffer for this file */
-};
-Extern struct ioarg ioargstack[NPUSH];
-#define AFID_NOBUF (~0)
-#define AFID_ID 0
-
-/* an input generator's state */
-struct io {
- int (*iofn)(_VOID);
- struct ioarg *argp;
- int peekc;
- char prev; /* previous character read by readc() */
- char nlcount; /* for `'s */
- char xchar; /* for `'s */
- char task; /* reason for pushed IO */
-};
-Extern struct io iostack[NPUSH];
-#define XOTHER 0 /* none of the below */
-#define XDOLL 1 /* expanding ${} */
-#define XGRAVE 2 /* expanding `'s */
-#define XIO 3 /* file IO */
-
-/* in substitution */
-#define INSUB() (e.iop->task == XGRAVE || e.iop->task == XDOLL)
-
-/*
- * input generators for IO structure
- */
-_PROTOTYPE(int nlchar , (struct ioarg *ap ));
-_PROTOTYPE(int strchar , (struct ioarg *ap ));
-_PROTOTYPE(int qstrchar , (struct ioarg *ap ));
-_PROTOTYPE(int filechar , (struct ioarg *ap ));
-_PROTOTYPE(int herechar , (struct ioarg *ap ));
-_PROTOTYPE(int linechar , (struct ioarg *ap ));
-_PROTOTYPE(int gravechar , (struct ioarg *ap , struct io *iop ));
-_PROTOTYPE(int qgravechar , (struct ioarg *ap , struct io *iop ));
-_PROTOTYPE(int dolchar , (struct ioarg *ap ));
-_PROTOTYPE(int wdchar , (struct ioarg *ap ));
-_PROTOTYPE(void scraphere , (void));
-_PROTOTYPE(void freehere , (int area ));
-_PROTOTYPE(void gethere , (void));
-_PROTOTYPE(void markhere , (char *s , struct ioword *iop ));
-_PROTOTYPE(int herein , (char *hname , int xdoll ));
-_PROTOTYPE(int run , (struct ioarg *argp , int (*f)(_VOID)));
-
-/*
- * IO functions
- */
-_PROTOTYPE(int eofc , (void));
-_PROTOTYPE(int getc , (int ec ));
-_PROTOTYPE(int readc , (void));
-_PROTOTYPE(void unget , (int c ));
-_PROTOTYPE(void ioecho , (int c ));
-_PROTOTYPE(void prs , (char *s ));
-_PROTOTYPE(void putc , (int c ));
-_PROTOTYPE(void prn , (unsigned u ));
-_PROTOTYPE(void closef , (int i ));
-_PROTOTYPE(void closeall , (void));
-
-/*
- * IO control
- */
-_PROTOTYPE(void pushio , (struct ioarg *argp , int (*fn)(_VOID)));
-_PROTOTYPE(int remap , (int fd ));
-_PROTOTYPE(int openpipe , (int *pv ));
-_PROTOTYPE(void closepipe , (int *pv ));
-_PROTOTYPE(struct io *setbase , (struct io *ip ));
-
-extern struct ioarg temparg; /* temporary for PUSHIO */
-#define PUSHIO(what,arg,gen) ((temparg.what = (arg)),pushio(&temparg,(gen)))
-#define RUN(what,arg,gen) ((temparg.what = (arg)), run(&temparg,(gen)))
-
-/* -------- word.h -------- */
-#ifndef WORD_H
-#define WORD_H 1
-struct wdblock {
- short w_bsize;
- short w_nword;
- /* bounds are arbitrary */
- char *w_words[1];
-};
-
-_PROTOTYPE(struct wdblock *addword , (char *wd , struct wdblock *wb ));
-_PROTOTYPE(struct wdblock *newword , (int nw ));
-_PROTOTYPE(char **getwords , (struct wdblock *wb ));
-#endif
-
-/* -------- area.h -------- */
-
-/*
- * storage allocation
- */
-_PROTOTYPE(char *getcell , (unsigned nbytes ));
-_PROTOTYPE(void garbage , (void));
-_PROTOTYPE(void setarea , (char *cp , int a ));
-_PROTOTYPE(int getarea , (char *cp ));
-_PROTOTYPE(void freearea , (int a ));
-_PROTOTYPE(void freecell , (char *cp ));
-
-Extern int areanum; /* current allocation area */
-
-#define NEW(type) (type *)getcell(sizeof(type))
-#define DELETE(obj) freecell((char *)obj)
diff --git a/release/picobsd/tinyware/msh/sh1.c b/release/picobsd/tinyware/msh/sh1.c
deleted file mode 100644
index 34b024df9c51..000000000000
--- a/release/picobsd/tinyware/msh/sh1.c
+++ /dev/null
@@ -1,953 +0,0 @@
-#define Extern extern
-#include <sys/types.h>
-#include <signal.h>
-#define _NSIG NSIG
-#include <errno.h>
-#include <setjmp.h>
-#include "sh.h"
-/* -------- sh.c -------- */
-/*
- * shell
- */
-
-/* #include "sh.h" */
-
-int intr;
-int inparse;
-char flags['z'-'a'+1];
-char *flag = flags-'a';
-char *elinep = line+sizeof(line)-5;
-char *null = "";
-int heedint =1;
-struct env e ={line, iostack, iostack-1,
- (xint *)NULL, FDBASE, (struct env *)NULL};
-
-extern char **environ; /* environment pointer */
-
-/*
- * default shell, search rules
- */
-char shellname[] = "/bin/sh";
-char search[] = ":/bin:/usr/bin";
-
-_PROTOTYPE(void (*qflag), (int)) = SIG_IGN;
-
-_PROTOTYPE(int main, (int argc, char **argv ));
-_PROTOTYPE(int newfile, (char *s ));
-_PROTOTYPE(static char *findeq, (char *cp ));
-_PROTOTYPE(static char *cclass, (char *p, int sub ));
-_PROTOTYPE(void initarea, (void));
-
-int main(argc, argv)
-int argc;
-register char **argv;
-{
- register int f;
- register char *s;
- int cflag;
- char *name, **ap;
- int (*iof)();
-
- initarea();
- if ((ap = environ) != NULL) {
- while (*ap)
- assign(*ap++, !COPYV);
- for (ap = environ; *ap;)
- export(lookup(*ap++));
- }
- closeall();
- areanum = 1;
-
- shell = lookup("SHELL");
- if (shell->value == null)
- setval(shell, shellname);
- export(shell);
-
- homedir = lookup("HOME");
- if (homedir->value == null)
- setval(homedir, "/");
- export(homedir);
-
- setval(lookup("$"), itoa(getpid(), 5));
-
- path = lookup("PATH");
- if (path->value == null)
- setval(path, search);
- export(path);
-
- ifs = lookup("IFS");
- if (ifs->value == null)
- setval(ifs, " \t\n");
-
- prompt = lookup("PS1");
- if (prompt->value == null)
-#ifndef UNIXSHELL
- setval(prompt, "$ ");
-#else
- setval(prompt, "% ");
-#endif
-
- if (geteuid() == 0) {
- setval(prompt, "# ");
- prompt->status &= ~EXPORT;
- }
- cprompt = lookup("PS2");
- if (cprompt->value == null)
- setval(cprompt, "> ");
-
- iof = filechar;
- cflag = 0;
- name = *argv++;
- if (--argc >= 1) {
- if(argv[0][0] == '-' && argv[0][1] != '\0') {
- for (s = argv[0]+1; *s; s++)
- switch (*s) {
- case 'c':
- prompt->status &= ~EXPORT;
- cprompt->status &= ~EXPORT;
- setval(prompt, "");
- setval(cprompt, "");
- cflag = 1;
- if (--argc > 0)
- PUSHIO(aword, *++argv, iof = nlchar);
- break;
-
- case 'q':
- qflag = SIG_DFL;
- break;
-
- case 's':
- /* standard input */
- break;
-
- case 't':
- prompt->status &= ~EXPORT;
- setval(prompt, "");
- iof = linechar;
- break;
-
- case 'i':
- talking++;
- default:
- if (*s>='a' && *s<='z')
- flag[*s]++;
- }
- } else {
- argv--;
- argc++;
- }
- if (iof == filechar && --argc > 0) {
- setval(prompt, "");
- setval(cprompt, "");
- prompt->status &= ~EXPORT;
- cprompt->status &= ~EXPORT;
- if (newfile(name = *++argv))
- exit(1);
- }
- }
- setdash();
- if (e.iop < iostack) {
- PUSHIO(afile, 0, iof);
- if (isatty(0) && isatty(1) && !cflag)
- talking++;
- }
- signal(SIGQUIT, qflag);
- if (name && name[0] == '-') {
- talking++;
- if ((f = open(".profile", 0)) >= 0)
- next(remap(f));
- if ((f = open("/etc/profile", 0)) >= 0)
- next(remap(f));
- }
- if (talking)
- signal(SIGTERM, sig);
- if (signal(SIGINT, SIG_IGN) != SIG_IGN)
- signal(SIGINT, onintr);
- dolv = argv;
- dolc = argc;
- dolv[0] = name;
- if (dolc > 1)
- for (ap = ++argv; --argc > 0;)
- if (assign(*ap = *argv++, !COPYV))
- dolc--; /* keyword */
- else
- ap++;
- setval(lookup("#"), putn((--dolc < 0) ? (dolc = 0) : dolc));
-
- for (;;) {
- if (talking && e.iop <= iostack)
- prs(prompt->value);
- onecommand();
- }
-}
-
-void
-setdash()
-{
- register char *cp, c;
- char m['z'-'a'+1];
-
- cp = m;
- for (c='a'; c<='z'; c++)
- if (flag[c])
- *cp++ = c;
- *cp = 0;
- setval(lookup("-"), m);
-}
-
-int
-newfile(s)
-register char *s;
-{
- register f;
-
- if (strcmp(s, "-") != 0) {
- f = open(s, 0);
- if (f < 0) {
- prs(s);
- err(": cannot open");
- return(1);
- }
- } else
- f = 0;
- next(remap(f));
- return(0);
-}
-
-void
-onecommand()
-{
- register i;
- jmp_buf m1;
-
- while (e.oenv)
- quitenv();
- areanum = 1;
- freehere(areanum);
- freearea(areanum);
- garbage();
- wdlist = 0;
- iolist = 0;
- e.errpt = 0;
- e.linep = line;
- yynerrs = 0;
- multiline = 0;
- inparse = 1;
- intr = 0;
- execflg = 0;
- setjmp(failpt = m1); /* Bruce Evans' fix */
- if (setjmp(failpt = m1) || yyparse() || intr) {
- while (e.oenv)
- quitenv();
- scraphere();
- if (!talking && intr)
- leave();
- inparse = 0;
- intr = 0;
- return;
- }
- inparse = 0;
- brklist = 0;
- intr = 0;
- execflg = 0;
- if (!flag['n'])
- execute(outtree, NOPIPE, NOPIPE, 0);
- if (!talking && intr) {
- execflg = 0;
- leave();
- }
- if ((i = trapset) != 0) {
- trapset = 0;
- runtrap(i);
- }
-}
-
-void
-fail()
-{
- longjmp(failpt, 1);
- /* NOTREACHED */
-}
-
-void
-leave()
-{
- if (execflg)
- fail();
- scraphere();
- freehere(1);
- runtrap(0);
- exit(exstat);
- /* NOTREACHED */
-}
-
-void
-warn(s)
-register char *s;
-{
- if(*s) {
- prs(s);
- exstat = -1;
- }
- prs("\n");
- if (flag['e'])
- leave();
-}
-
-void
-err(s)
-char *s;
-{
- warn(s);
- if (flag['n'])
- return;
- if (!talking)
- leave();
- if (e.errpt)
- longjmp(e.errpt, 1);
- closeall();
- e.iop = e.iobase = iostack;
-}
-
-int
-newenv(f)
-int f;
-{
- register struct env *ep;
-
- if (f) {
- quitenv();
- return(1);
- }
- ep = (struct env *) space(sizeof(*ep));
- if (ep == NULL) {
- while (e.oenv)
- quitenv();
- fail();
- }
- *ep = e;
- e.oenv = ep;
- e.errpt = errpt;
- return(0);
-}
-
-void
-quitenv()
-{
- register struct env *ep;
- register fd;
-
- if ((ep = e.oenv) != NULL) {
- fd = e.iofd;
- e = *ep;
- /* should close `'d files */
- DELETE(ep);
- while (--fd >= e.iofd)
- close(fd);
- }
-}
-
-/*
- * Is any character from s1 in s2?
- */
-int
-anys(s1, s2)
-register char *s1, *s2;
-{
- while (*s1)
- if (any(*s1++, s2))
- return(1);
- return(0);
-}
-
-/*
- * Is character c in s?
- */
-int
-any(c, s)
-register int c;
-register char *s;
-{
- while (*s)
- if (*s++ == c)
- return(1);
- return(0);
-}
-
-char *
-putn(n)
-register int n;
-{
- return(itoa(n, -1));
-}
-
-char *
-itoa(u, n)
-register unsigned u;
-int n;
-{
- register char *cp;
- static char s[20];
- int m;
-
- m = 0;
- if (n < 0 && (int) u < 0) {
- m++;
- u = -u;
- }
- cp = s+sizeof(s);
- *--cp = 0;
- do {
- *--cp = u%10 + '0';
- u /= 10;
- } while (--n > 0 || u);
- if (m)
- *--cp = '-';
- return(cp);
-}
-
-void
-next(f)
-int f;
-{
- PUSHIO(afile, f, filechar);
-}
-
-void
-onintr(s)
-int s; /* ANSI C requires a parameter */
-{
- signal(SIGINT, onintr);
- intr = 1;
- if (talking) {
- if (inparse) {
- prs("\n");
- fail();
- }
- }
- else if (heedint) {
- execflg = 0;
- leave();
- }
-}
-
-int
-letter(c)
-register c;
-{
- return((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || c == '_');
-}
-
-int
-digit(c)
-register c;
-{
- return(c >= '0' && c <= '9');
-}
-
-int
-letnum(c)
-register c;
-{
- return(letter(c) || digit(c));
-}
-
-char *
-space(n)
-int n;
-{
- register char *cp;
-
- if ((cp = getcell(n)) == 0)
- err("out of string space");
- return(cp);
-}
-
-char *
-strsave(s, a)
-register char *s;
-int a;
-{
- register char *cp, *xp;
-
- if ((cp = space(strlen(s)+1)) != NULL) {
- setarea((char *)cp, a);
- for (xp = cp; (*xp++ = *s++) != '\0';)
- ;
- return(cp);
- }
- return("");
-}
-
-void
-xfree(s)
-register char *s;
-{
- DELETE(s);
-}
-
-/*
- * trap handling
- */
-void
-sig(i)
-register int i;
-{
- trapset = i;
- signal(i, sig);
-}
-
-void runtrap(i)
-int i;
-{
- char *trapstr;
-
- if ((trapstr = trap[i]) == NULL)
- return;
- if (i == 0)
- trap[i] = 0;
- RUN(aword, trapstr, nlchar);
-}
-
-/* -------- var.c -------- */
-/* #include "sh.h" */
-
-/*
- * Find the given name in the dictionary
- * and return its value. If the name was
- * not previously there, enter it now and
- * return a null value.
- */
-struct var *
-lookup(n)
-register char *n;
-{
- register struct var *vp;
- register char *cp;
- register int c;
- static struct var dummy;
-
- if (digit(*n)) {
- dummy.name = n;
- for (c = 0; digit(*n) && c < 1000; n++)
- c = c*10 + *n-'0';
- dummy.status = RONLY;
- dummy.value = c <= dolc? dolv[c]: null;
- return(&dummy);
- }
- for (vp = vlist; vp; vp = vp->next)
- if (eqname(vp->name, n))
- return(vp);
- cp = findeq(n);
- vp = (struct var *)space(sizeof(*vp));
- if (vp == 0 || (vp->name = space((int)(cp-n)+2)) == 0) {
- dummy.name = dummy.value = "";
- return(&dummy);
- }
- for (cp = vp->name; (*cp = *n++) && *cp != '='; cp++)
- ;
- if (*cp == 0)
- *cp = '=';
- *++cp = 0;
- setarea((char *)vp, 0);
- setarea((char *)vp->name, 0);
- vp->value = null;
- vp->next = vlist;
- vp->status = GETCELL;
- vlist = vp;
- return(vp);
-}
-
-/*
- * give variable at `vp' the value `val'.
- */
-void
-setval(vp, val)
-struct var *vp;
-char *val;
-{
- nameval(vp, val, (char *)NULL);
-}
-
-/*
- * if name is not NULL, it must be
- * a prefix of the space `val',
- * and end with `='.
- * this is all so that exporting
- * values is reasonably painless.
- */
-void
-nameval(vp, val, name)
-register struct var *vp;
-char *val, *name;
-{
- register char *cp, *xp;
- char *nv;
- int fl;
-
- if (vp->status & RONLY) {
- for (xp = vp->name; *xp && *xp != '=';)
- putc(*xp++);
- err(" is read-only");
- return;
- }
- fl = 0;
- if (name == NULL) {
- xp = space(strlen(vp->name)+strlen(val)+2);
- if (xp == 0)
- return;
- /* make string: name=value */
- setarea((char *)xp, 0);
- name = xp;
- for (cp = vp->name; (*xp = *cp++) && *xp!='='; xp++)
- ;
- if (*xp++ == 0)
- xp[-1] = '=';
- nv = xp;
- for (cp = val; (*xp++ = *cp++) != '\0';)
- ;
- val = nv;
- fl = GETCELL;
- }
- if (vp->status & GETCELL)
- xfree(vp->name); /* form new string `name=value' */
- vp->name = name;
- vp->value = val;
- vp->status |= fl;
-}
-
-void
-export(vp)
-struct var *vp;
-{
- vp->status |= EXPORT;
-}
-
-void
-ronly(vp)
-struct var *vp;
-{
- if (letter(vp->name[0])) /* not an internal symbol ($# etc) */
- vp->status |= RONLY;
-}
-
-int
-isassign(s)
-register char *s;
-{
- if (!letter((int)*s))
- return(0);
- for (; *s != '='; s++)
- if (*s == 0 || !letnum(*s))
- return(0);
- return(1);
-}
-
-int
-assign(s, cf)
-register char *s;
-int cf;
-{
- register char *cp;
- struct var *vp;
-
- if (!letter(*s))
- return(0);
- for (cp = s; *cp != '='; cp++)
- if (*cp == 0 || !letnum(*cp))
- return(0);
- vp = lookup(s);
- nameval(vp, ++cp, cf == COPYV? (char *)NULL: s);
- if (cf != COPYV)
- vp->status &= ~GETCELL;
- return(1);
-}
-
-int
-checkname(cp)
-register char *cp;
-{
- if (!letter(*cp++))
- return(0);
- while (*cp)
- if (!letnum(*cp++))
- return(0);
- return(1);
-}
-
-void
-putvlist(f, out)
-register int f, out;
-{
- register struct var *vp;
-
- for (vp = vlist; vp; vp = vp->next)
- if (vp->status & f && letter(*vp->name)) {
- if (vp->status & EXPORT)
- write(out, "export ", 7);
- if (vp->status & RONLY)
- write(out, "readonly ", 9);
- write(out, vp->name, (int)(findeq(vp->name) - vp->name));
- write(out, "\n", 1);
- }
-}
-
-int
-eqname(n1, n2)
-register char *n1, *n2;
-{
- for (; *n1 != '=' && *n1 != 0; n1++)
- if (*n2++ != *n1)
- return(0);
- return(*n2 == 0 || *n2 == '=');
-}
-
-static char *
-findeq(cp)
-register char *cp;
-{
- while (*cp != '\0' && *cp != '=')
- cp++;
- return(cp);
-}
-
-/* -------- gmatch.c -------- */
-/*
- * int gmatch(string, pattern)
- * char *string, *pattern;
- *
- * Match a pattern as in sh(1).
- */
-
-#define CMASK 0377
-#define QUOTE 0200
-#define QMASK (CMASK&~QUOTE)
-#define NOT '!' /* might use ^ */
-
-int
-gmatch(s, p)
-register char *s, *p;
-{
- register int sc, pc;
-
- if (s == NULL || p == NULL)
- return(0);
- while ((pc = *p++ & CMASK) != '\0') {
- sc = *s++ & QMASK;
- switch (pc) {
- case '[':
- if ((p = cclass(p, sc)) == NULL)
- return(0);
- break;
-
- case '?':
- if (sc == 0)
- return(0);
- break;
-
- case '*':
- s--;
- do {
- if (*p == '\0' || gmatch(s, p))
- return(1);
- } while (*s++ != '\0');
- return(0);
-
- default:
- if (sc != (pc&~QUOTE))
- return(0);
- }
- }
- return(*s == 0);
-}
-
-static char *
-cclass(p, sub)
-register char *p;
-register int sub;
-{
- register int c, d, not, found;
-
- if ((not = *p == NOT) != 0)
- p++;
- found = not;
- do {
- if (*p == '\0')
- return((char *)NULL);
- c = *p & CMASK;
- if (p[1] == '-' && p[2] != ']') {
- d = p[2] & CMASK;
- p++;
- } else
- d = c;
- if (c == sub || (c <= sub && sub <= d))
- found = !not;
- } while (*++p != ']');
- return(found? p+1: (char *)NULL);
-}
-
-/* -------- area.c -------- */
-#define REGSIZE sizeof(struct region)
-#define GROWBY 256
-#undef SHRINKBY 64
-#define FREE 32767
-#define BUSY 0
-#define ALIGN (sizeof(int)-1)
-
-/* #include "area.h" */
-
-struct region {
- struct region *next;
- int area;
-};
-
-/*
- * All memory between (char *)areabot and (char *)(areatop+1) is
- * exclusively administered by the area management routines.
- * It is assumed that sbrk() and brk() manipulate the high end.
- */
-static struct region *areabot; /* bottom of area */
-static struct region *areatop; /* top of area */
-static struct region *areanxt; /* starting point of scan */
-
-void
-initarea()
-{
- while ((int)sbrk(0) & ALIGN)
- sbrk(1);
- areabot = (struct region *)sbrk(REGSIZE);
- areabot->next = areabot;
- areabot->area = BUSY;
- areatop = areabot;
- areanxt = areabot;
-}
-
-char *
-getcell(nbytes)
-unsigned nbytes;
-{
- register int nregio;
- register struct region *p, *q;
- register i;
-
- if (nbytes == 0)
- abort(); /* silly and defeats the algorithm */
- /*
- * round upwards and add administration area
- */
- nregio = (nbytes+(REGSIZE-1))/REGSIZE + 1;
- for (p = areanxt;;) {
- if (p->area > areanum) {
- /*
- * merge free cells
- */
- while ((q = p->next)->area > areanum && q != areanxt)
- p->next = q->next;
- /*
- * exit loop if cell big enough
- */
- if (q >= p + nregio)
- goto found;
- }
- p = p->next;
- if (p == areanxt)
- break;
- }
- i = nregio >= GROWBY ? nregio : GROWBY;
- p = (struct region *)sbrk(i * REGSIZE);
- if (p == (struct region *)-1)
- return((char *)NULL);
- p--;
- if (p != areatop)
- abort(); /* allocated areas are contiguous */
- q = p + i;
- p->next = q;
- p->area = FREE;
- q->next = areabot;
- q->area = BUSY;
- areatop = q;
-found:
- /*
- * we found a FREE area big enough, pointed to by 'p', and up to 'q'
- */
- areanxt = p + nregio;
- if (areanxt < q) {
- /*
- * split into requested area and rest
- */
- if (areanxt+1 > q)
- abort(); /* insufficient space left for admin */
- areanxt->next = q;
- areanxt->area = FREE;
- p->next = areanxt;
- }
- p->area = areanum;
- return((char *)(p+1));
-}
-
-void
-freecell(cp)
-char *cp;
-{
- register struct region *p;
-
- if ((p = (struct region *)cp) != NULL) {
- p--;
- if (p < areanxt)
- areanxt = p;
- p->area = FREE;
- }
-}
-
-void
-freearea(a)
-register int a;
-{
- register struct region *p, *top;
-
- top = areatop;
- for (p = areabot; p != top; p = p->next)
- if (p->area >= a)
- p->area = FREE;
-}
-
-void
-setarea(cp,a)
-char *cp;
-int a;
-{
- register struct region *p;
-
- if ((p = (struct region *)cp) != NULL)
- (p-1)->area = a;
-}
-
-int
-getarea(cp)
-char *cp;
-{
- return ((struct region*)cp-1)->area;
-}
-
-void
-garbage()
-{
- register struct region *p, *q, *top;
-
- top = areatop;
- for (p = areabot; p != top; p = p->next) {
- if (p->area > areanum) {
- while ((q = p->next)->area > areanum)
- p->next = q->next;
- areanxt = p;
- }
- }
-#ifdef SHRINKBY
- if (areatop >= q + SHRINKBY && q->area > areanum) {
- brk((char *)(q+1));
- q->next = areabot;
- q->area = BUSY;
- areatop = q;
- }
-#endif
-}
diff --git a/release/picobsd/tinyware/msh/sh2.c b/release/picobsd/tinyware/msh/sh2.c
deleted file mode 100644
index f7eaf017f5ec..000000000000
--- a/release/picobsd/tinyware/msh/sh2.c
+++ /dev/null
@@ -1,801 +0,0 @@
-#define Extern extern
-#include <sys/types.h>
-#include <signal.h>
-#define _NSIG NSIG
-#include <errno.h>
-#include <setjmp.h>
-#include "sh.h"
-
-/* -------- csyn.c -------- */
-/*
- * shell: syntax (C version)
- */
-
-typedef union {
- char *cp;
- char **wp;
- int i;
- struct op *o;
-} YYSTYPE;
-#define WORD 256
-#define LOGAND 257
-#define LOGOR 258
-#define BREAK 259
-#define IF 260
-#define THEN 261
-#define ELSE 262
-#define ELIF 263
-#define FI 264
-#define CASE 265
-#define ESAC 266
-#define FOR 267
-#define WHILE 268
-#define UNTIL 269
-#define DO 270
-#define DONE 271
-#define IN 272
-#define YYERRCODE 300
-
-/* flags to yylex */
-#define CONTIN 01 /* skip new lines to complete command */
-
-/* #include "sh.h" */
-#define SYNTAXERR zzerr()
-static int startl;
-static int peeksym;
-static int nlseen;
-static int iounit = IODEFAULT;
-
-static YYSTYPE yylval;
-
-_PROTOTYPE(static struct op *pipeline, (int cf ));
-_PROTOTYPE(static struct op *andor, (void));
-_PROTOTYPE(static struct op *c_list, (void));
-_PROTOTYPE(static int synio, (int cf ));
-_PROTOTYPE(static void musthave, (int c, int cf ));
-_PROTOTYPE(static struct op *simple, (void));
-_PROTOTYPE(static struct op *nested, (int type, int mark ));
-_PROTOTYPE(static struct op *command, (int cf ));
-_PROTOTYPE(static struct op *dogroup, (int onlydone ));
-_PROTOTYPE(static struct op *thenpart, (void));
-_PROTOTYPE(static struct op *elsepart, (void));
-_PROTOTYPE(static struct op *caselist, (void));
-_PROTOTYPE(static struct op *casepart, (void));
-_PROTOTYPE(static char **pattern, (void));
-_PROTOTYPE(static char **wordlist, (void));
-_PROTOTYPE(static struct op *list, (struct op *t1, struct op *t2 ));
-_PROTOTYPE(static struct op *block, (int type, struct op *t1, struct op *t2, char **wp ));
-_PROTOTYPE(static struct op *newtp, (void));
-_PROTOTYPE(static struct op *namelist, (struct op *t ));
-_PROTOTYPE(static char **copyw, (void));
-_PROTOTYPE(static void word, (char *cp ));
-_PROTOTYPE(static struct ioword **copyio, (void));
-_PROTOTYPE(static struct ioword *io, (int u, int f, char *cp ));
-_PROTOTYPE(static void zzerr, (void));
-_PROTOTYPE(void yyerror, (char *s ));
-_PROTOTYPE(static int yylex, (int cf ));
-_PROTOTYPE(int collect, (int c, int c1 ));
-_PROTOTYPE(int dual, (int c ));
-_PROTOTYPE(static void diag, (int ec ));
-_PROTOTYPE(static char *tree, (unsigned size ));
-_PROTOTYPE(void printf, (char *s ));
-
-int
-yyparse()
-{
- startl = 1;
- peeksym = 0;
- yynerrs = 0;
- outtree = c_list();
- musthave('\n', 0);
- return(yynerrs!=0);
-}
-
-static struct op *
-pipeline(cf)
-int cf;
-{
- register struct op *t, *p;
- register int c;
-
- t = command(cf);
- if (t != NULL) {
- while ((c = yylex(0)) == '|') {
- if ((p = command(CONTIN)) == NULL)
- SYNTAXERR;
- if (t->type != TPAREN && t->type != TCOM) {
- /* shell statement */
- t = block(TPAREN, t, NOBLOCK, NOWORDS);
- }
- t = block(TPIPE, t, p, NOWORDS);
- }
- peeksym = c;
- }
- return(t);
-}
-
-static struct op *
-andor()
-{
- register struct op *t, *p;
- register int c;
-
- t = pipeline(0);
- if (t != NULL) {
- while ((c = yylex(0)) == LOGAND || c == LOGOR) {
- if ((p = pipeline(CONTIN)) == NULL)
- SYNTAXERR;
- t = block(c == LOGAND? TAND: TOR, t, p, NOWORDS);
- }
- peeksym = c;
- }
- return(t);
-}
-
-static struct op *
-c_list()
-{
- register struct op *t, *p;
- register int c;
-
- t = andor();
- if (t != NULL) {
- if((peeksym = yylex(0)) == '&')
- t = block(TASYNC, t, NOBLOCK, NOWORDS);
- while ((c = yylex(0)) == ';' || c == '&' || (multiline && c == '\n')) {
- if ((p = andor()) == NULL)
- return(t);
- if((peeksym = yylex(0)) == '&')
- p = block(TASYNC, p, NOBLOCK, NOWORDS);
- t = list(t, p);
- }
- peeksym = c;
- }
- return(t);
-}
-
-
-static int
-synio(cf)
-int cf;
-{
- register struct ioword *iop;
- register int i;
- register int c;
-
- if ((c = yylex(cf)) != '<' && c != '>') {
- peeksym = c;
- return(0);
- }
- i = yylval.i;
- musthave(WORD, 0);
- iop = io(iounit, i, yylval.cp);
- iounit = IODEFAULT;
- if (i & IOHERE)
- markhere(yylval.cp, iop);
- return(1);
-}
-
-static void
-musthave(c, cf)
-int c, cf;
-{
- if ((peeksym = yylex(cf)) != c)
- SYNTAXERR;
- peeksym = 0;
-}
-
-static struct op *
-simple()
-{
- register struct op *t;
-
- t = NULL;
- for (;;) {
- switch (peeksym = yylex(0)) {
- case '<':
- case '>':
- (void) synio(0);
- break;
-
- case WORD:
- if (t == NULL) {
- t = newtp();
- t->type = TCOM;
- }
- peeksym = 0;
- word(yylval.cp);
- break;
-
- default:
- return(t);
- }
- }
-}
-
-static struct op *
-nested(type, mark)
-int type, mark;
-{
- register struct op *t;
-
- multiline++;
- t = c_list();
- musthave(mark, 0);
- multiline--;
- return(block(type, t, NOBLOCK, NOWORDS));
-}
-
-static struct op *
-command(cf)
-int cf;
-{
- register struct op *t;
- struct wdblock *iosave;
- register int c;
-
- iosave = iolist;
- iolist = NULL;
- if (multiline)
- cf |= CONTIN;
- while (synio(cf))
- cf = 0;
- switch (c = yylex(cf)) {
- default:
- peeksym = c;
- if ((t = simple()) == NULL) {
- if (iolist == NULL)
- return((struct op *)NULL);
- t = newtp();
- t->type = TCOM;
- }
- break;
-
- case '(':
- t = nested(TPAREN, ')');
- break;
-
- case '{':
- t = nested(TBRACE, '}');
- break;
-
- case FOR:
- t = newtp();
- t->type = TFOR;
- musthave(WORD, 0);
- startl = 1;
- t->str = yylval.cp;
- multiline++;
- t->words = wordlist();
- if ((c = yylex(0)) != '\n' && c != ';')
- peeksym = c;
- t->left = dogroup(0);
- multiline--;
- break;
-
- case WHILE:
- case UNTIL:
- multiline++;
- t = newtp();
- t->type = c == WHILE? TWHILE: TUNTIL;
- t->left = c_list();
- t->right = dogroup(1);
- t->words = NULL;
- multiline--;
- break;
-
- case CASE:
- t = newtp();
- t->type = TCASE;
- musthave(WORD, 0);
- t->str = yylval.cp;
- startl++;
- multiline++;
- musthave(IN, CONTIN);
- startl++;
- t->left = caselist();
- musthave(ESAC, 0);
- multiline--;
- break;
-
- case IF:
- multiline++;
- t = newtp();
- t->type = TIF;
- t->left = c_list();
- t->right = thenpart();
- musthave(FI, 0);
- multiline--;
- break;
- }
- while (synio(0))
- ;
- t = namelist(t);
- iolist = iosave;
- return(t);
-}
-
-static struct op *
-dogroup(onlydone)
-int onlydone;
-{
- register int c;
- register struct op *list;
-
- c = yylex(CONTIN);
- if (c == DONE && onlydone)
- return((struct op *)NULL);
- if (c != DO)
- SYNTAXERR;
- list = c_list();
- musthave(DONE, 0);
- return(list);
-}
-
-static struct op *
-thenpart()
-{
- register int c;
- register struct op *t;
-
- if ((c = yylex(0)) != THEN) {
- peeksym = c;
- return((struct op *)NULL);
- }
- t = newtp();
- t->type = 0;
- t->left = c_list();
- if (t->left == NULL)
- SYNTAXERR;
- t->right = elsepart();
- return(t);
-}
-
-static struct op *
-elsepart()
-{
- register int c;
- register struct op *t;
-
- switch (c = yylex(0)) {
- case ELSE:
- if ((t = c_list()) == NULL)
- SYNTAXERR;
- return(t);
-
- case ELIF:
- t = newtp();
- t->type = TELIF;
- t->left = c_list();
- t->right = thenpart();
- return(t);
-
- default:
- peeksym = c;
- return((struct op *)NULL);
- }
-}
-
-static struct op *
-caselist()
-{
- register struct op *t;
-
- t = NULL;
- while ((peeksym = yylex(CONTIN)) != ESAC)
- t = list(t, casepart());
- return(t);
-}
-
-static struct op *
-casepart()
-{
- register struct op *t;
-
- t = newtp();
- t->type = TPAT;
- t->words = pattern();
- musthave(')', 0);
- t->left = c_list();
- if ((peeksym = yylex(CONTIN)) != ESAC)
- musthave(BREAK, CONTIN);
- return(t);
-}
-
-static char **
-pattern()
-{
- register int c, cf;
-
- cf = CONTIN;
- do {
- musthave(WORD, cf);
- word(yylval.cp);
- cf = 0;
- } while ((c = yylex(0)) == '|');
- peeksym = c;
- word(NOWORD);
- return(copyw());
-}
-
-static char **
-wordlist()
-{
- register int c;
-
- if ((c = yylex(0)) != IN) {
- peeksym = c;
- return((char **)NULL);
- }
- startl = 0;
- while ((c = yylex(0)) == WORD)
- word(yylval.cp);
- word(NOWORD);
- peeksym = c;
- return(copyw());
-}
-
-/*
- * supporting functions
- */
-static struct op *
-list(t1, t2)
-register struct op *t1, *t2;
-{
- if (t1 == NULL)
- return(t2);
- if (t2 == NULL)
- return(t1);
- return(block(TLIST, t1, t2, NOWORDS));
-}
-
-static struct op *
-block(type, t1, t2, wp)
-int type;
-struct op *t1, *t2;
-char **wp;
-{
- register struct op *t;
-
- t = newtp();
- t->type = type;
- t->left = t1;
- t->right = t2;
- t->words = wp;
- return(t);
-}
-
-struct res {
- char *r_name;
- int r_val;
-} restab[] = {
- "for", FOR,
- "case", CASE,
- "esac", ESAC,
- "while", WHILE,
- "do", DO,
- "done", DONE,
- "if", IF,
- "in", IN,
- "then", THEN,
- "else", ELSE,
- "elif", ELIF,
- "until", UNTIL,
- "fi", FI,
-
- ";;", BREAK,
- "||", LOGOR,
- "&&", LOGAND,
- "{", '{',
- "}", '}',
-
- 0,
-};
-
-int
-rlookup(n)
-register char *n;
-{
- register struct res *rp;
-
- for (rp = restab; rp->r_name; rp++)
- if (strcmp(rp->r_name, n) == 0)
- return(rp->r_val);
- return(0);
-}
-
-static struct op *
-newtp()
-{
- register struct op *t;
-
- t = (struct op *)tree(sizeof(*t));
- t->type = 0;
- t->words = NULL;
- t->ioact = NULL;
- t->left = NULL;
- t->right = NULL;
- t->str = NULL;
- return(t);
-}
-
-static struct op *
-namelist(t)
-register struct op *t;
-{
- if (iolist) {
- iolist = addword((char *)NULL, iolist);
- t->ioact = copyio();
- } else
- t->ioact = NULL;
- if (t->type != TCOM) {
- if (t->type != TPAREN && t->ioact != NULL) {
- t = block(TPAREN, t, NOBLOCK, NOWORDS);
- t->ioact = t->left->ioact;
- t->left->ioact = NULL;
- }
- return(t);
- }
- word(NOWORD);
- t->words = copyw();
- return(t);
-}
-
-static char **
-copyw()
-{
- register char **wd;
-
- wd = getwords(wdlist);
- wdlist = 0;
- return(wd);
-}
-
-static void
-word(cp)
-char *cp;
-{
- wdlist = addword(cp, wdlist);
-}
-
-static struct ioword **
-copyio()
-{
- register struct ioword **iop;
-
- iop = (struct ioword **) getwords(iolist);
- iolist = 0;
- return(iop);
-}
-
-static struct ioword *
-io(u, f, cp)
-int u;
-int f;
-char *cp;
-{
- register struct ioword *iop;
-
- iop = (struct ioword *) tree(sizeof(*iop));
- iop->io_unit = u;
- iop->io_flag = f;
- iop->io_name = cp;
- iolist = addword((char *)iop, iolist);
- return(iop);
-}
-
-static void
-zzerr()
-{
- yyerror("syntax error");
-}
-
-void
-yyerror(s)
-char *s;
-{
- yynerrs++;
- if (talking && e.iop <= iostack) {
- multiline = 0;
- while (eofc() == 0 && yylex(0) != '\n')
- ;
- }
- err(s);
- fail();
-}
-
-static int
-yylex(cf)
-int cf;
-{
- register int c, c1;
- int atstart;
-
- if ((c = peeksym) > 0) {
- peeksym = 0;
- if (c == '\n')
- startl = 1;
- return(c);
- }
- nlseen = 0;
- e.linep = line;
- atstart = startl;
- startl = 0;
- yylval.i = 0;
-
-loop:
- while ((c = getc(0)) == ' ' || c == '\t')
- ;
- switch (c) {
- default:
- if (any(c, "0123456789")) {
- unget(c1 = getc(0));
- if (c1 == '<' || c1 == '>') {
- iounit = c - '0';
- goto loop;
- }
- *e.linep++ = c;
- c = c1;
- }
- break;
-
- case '#':
- while ((c = getc(0)) != 0 && c != '\n')
- ;
- unget(c);
- goto loop;
-
- case 0:
- return(c);
-
- case '$':
- *e.linep++ = c;
- if ((c = getc(0)) == '{') {
- if ((c = collect(c, '}')) != '\0')
- return(c);
- goto pack;
- }
- break;
-
- case '`':
- case '\'':
- case '"':
- if ((c = collect(c, c)) != '\0')
- return(c);
- goto pack;
-
- case '|':
- case '&':
- case ';':
- if ((c1 = dual(c)) != '\0') {
- startl = 1;
- return(c1);
- }
- startl = 1;
- return(c);
- case '^':
- startl = 1;
- return('|');
- case '>':
- case '<':
- diag(c);
- return(c);
-
- case '\n':
- nlseen++;
- gethere();
- startl = 1;
- if (multiline || cf & CONTIN) {
- if (talking && e.iop <= iostack)
- prs(cprompt->value);
- if (cf & CONTIN)
- goto loop;
- }
- return(c);
-
- case '(':
- case ')':
- startl = 1;
- return(c);
- }
-
- unget(c);
-
-pack:
- while ((c = getc(0)) != 0 && !any(c, "`$ '\"\t;&<>()|^\n"))
- if (e.linep >= elinep)
- err("word too long");
- else
- *e.linep++ = c;
- unget(c);
- if(any(c, "\"'`$"))
- goto loop;
- *e.linep++ = '\0';
- if (atstart && (c = rlookup(line))!=0) {
- startl = 1;
- return(c);
- }
- yylval.cp = strsave(line, areanum);
- return(WORD);
-}
-
-int
-collect(c, c1)
-register c, c1;
-{
- char s[2];
-
- *e.linep++ = c;
- while ((c = getc(c1)) != c1) {
- if (c == 0) {
- unget(c);
- s[0] = c1;
- s[1] = 0;
- prs("no closing "); yyerror(s);
- return(YYERRCODE);
- }
- if (talking && c == '\n' && e.iop <= iostack)
- prs(cprompt->value);
- *e.linep++ = c;
- }
- *e.linep++ = c;
- return(0);
-}
-
-int
-dual(c)
-register c;
-{
- char s[3];
- register char *cp = s;
-
- *cp++ = c;
- *cp++ = getc(0);
- *cp = 0;
- if ((c = rlookup(s)) == 0)
- unget(*--cp);
- return(c);
-}
-
-static void
-diag(ec)
-register int ec;
-{
- register int c;
-
- c = getc(0);
- if (c == '>' || c == '<') {
- if (c != ec)
- zzerr();
- yylval.i = ec == '>'? IOWRITE|IOCAT: IOHERE;
- c = getc(0);
- } else
- yylval.i = ec == '>'? IOWRITE: IOREAD;
- if (c != '&' || yylval.i == IOHERE)
- unget(c);
- else
- yylval.i |= IODUP;
-}
-
-static char *
-tree(size)
-unsigned size;
-{
- register char *t;
-
- if ((t = getcell(size)) == NULL) {
- prs("command line too complicated\n");
- fail();
- /* NOTREACHED */
- }
- return(t);
-}
-
-/* VARARGS1 */
-/* ARGSUSED */
-void
-printf(s) /* yyparse calls it */
-char *s;
-{
-}
-
diff --git a/release/picobsd/tinyware/msh/sh3.c b/release/picobsd/tinyware/msh/sh3.c
deleted file mode 100644
index 9aa61d2abf39..000000000000
--- a/release/picobsd/tinyware/msh/sh3.c
+++ /dev/null
@@ -1,1143 +0,0 @@
-#define Extern extern
-#include <sys/types.h>
-#include <signal.h>
-#define _NSIG NSIG
-#include <errno.h>
-#include <setjmp.h>
-#include <stddef.h>
-#include <time.h>
-#include <sys/times.h>
-#include <sys/stat.h>
-#include <sys/wait.h>
-#undef NULL
-#include "sh.h"
-
-/* -------- exec.c -------- */
-/* #include "sh.h" */
-
-/*
- * execute tree
- */
-
-static char *signame[] = {
- "Signal 0",
- "Hangup",
- (char *)NULL, /* interrupt */
- "Quit",
- "Illegal instruction",
- "Trace/BPT trap",
- "Abort",
- "EMT trap",
- "Floating exception",
- "Killed",
- "Bus error",
- "Memory fault",
- "Bad system call",
- (char *)NULL, /* broken pipe */
- "Alarm clock",
- "Terminated",
-};
-#define NSIGNAL (sizeof(signame)/sizeof(signame[0]))
-
-
-_PROTOTYPE(static int forkexec, (struct op *t, int *pin, int *pout, int act, char **wp, int *pforked ));
-_PROTOTYPE(static int parent, (void));
-_PROTOTYPE(int iosetup, (struct ioword *iop, int pipein, int pipeout ));
-_PROTOTYPE(static void echo, (char **wp ));
-_PROTOTYPE(static struct op **find1case, (struct op *t, char *w ));
-_PROTOTYPE(static struct op *findcase, (struct op *t, char *w ));
-_PROTOTYPE(static void brkset, (struct brkcon *bc ));
-_PROTOTYPE(int dolabel, (void));
-_PROTOTYPE(int dochdir, (struct op *t ));
-_PROTOTYPE(int doshift, (struct op *t ));
-_PROTOTYPE(int dologin, (struct op *t ));
-_PROTOTYPE(int doumask, (struct op *t ));
-_PROTOTYPE(int doexec, (struct op *t ));
-_PROTOTYPE(int dodot, (struct op *t ));
-_PROTOTYPE(int dowait, (struct op *t ));
-_PROTOTYPE(int doread, (struct op *t ));
-_PROTOTYPE(int doeval, (struct op *t ));
-_PROTOTYPE(int dotrap, (struct op *t ));
-_PROTOTYPE(int getsig, (char *s ));
-_PROTOTYPE(void setsig, (int n, void (*f)()));
-_PROTOTYPE(int getn, (char *as ));
-_PROTOTYPE(int dobreak, (struct op *t ));
-_PROTOTYPE(int docontinue, (struct op *t ));
-_PROTOTYPE(static int brkcontin, (char *cp, int val ));
-_PROTOTYPE(int doexit, (struct op *t ));
-_PROTOTYPE(int doexport, (struct op *t ));
-_PROTOTYPE(int doreadonly, (struct op *t ));
-_PROTOTYPE(static void rdexp, (char **wp, void (*f)(), int key));
-_PROTOTYPE(static void badid, (char *s ));
-_PROTOTYPE(int doset, (struct op *t ));
-_PROTOTYPE(void varput, (char *s, int out ));
-_PROTOTYPE(int dotimes, (void));
-
-int
-execute(t, pin, pout, act)
-register struct op *t;
-int *pin, *pout;
-int act;
-{
- register struct op *t1;
- int i, pv[2], rv, child, a;
- char *cp, **wp, **wp2;
- struct var *vp;
- struct brkcon bc;
-
- if (t == NULL)
- return(0);
- rv = 0;
- a = areanum++;
- wp = (wp2 = t->words) != NULL
- ? eval(wp2, t->type == TCOM ? DOALL : DOALL & ~DOKEY)
- : NULL;
-
- switch(t->type) {
- case TPAREN:
- case TCOM:
- rv = forkexec(t, pin, pout, act, wp, &child);
- if (child) {
- exstat = rv;
- leave();
- }
- break;
-
- case TPIPE:
- if ((rv = openpipe(pv)) < 0)
- break;
- pv[0] = remap(pv[0]);
- pv[1] = remap(pv[1]);
- (void) execute(t->left, pin, pv, 0);
- rv = execute(t->right, pv, pout, 0);
- break;
-
- case TLIST:
- (void) execute(t->left, pin, pout, 0);
- rv = execute(t->right, pin, pout, 0);
- break;
-
- case TASYNC:
- i = parent();
- if (i != 0) {
- if (i != -1) {
- setval(lookup("!"), putn(i));
- if (pin != NULL)
- closepipe(pin);
- if (talking) {
- prs(putn(i));
- prs("\n");
- }
- } else
- rv = -1;
- setstatus(rv);
- } else {
- signal(SIGINT, SIG_IGN);
- signal(SIGQUIT, SIG_IGN);
- if (talking)
- signal(SIGTERM, SIG_DFL);
- talking = 0;
- if (pin == NULL) {
- close(0);
- open("/dev/null", 0);
- }
- exit(execute(t->left, pin, pout, FEXEC));
- }
- break;
-
- case TOR:
- case TAND:
- rv = execute(t->left, pin, pout, 0);
- if ((t1 = t->right)!=NULL && (rv == 0) == (t->type == TAND))
- rv = execute(t1, pin, pout, 0);
- break;
-
- case TFOR:
- if (wp == NULL) {
- wp = dolv+1;
- if ((i = dolc) < 0)
- i = 0;
- } else {
- i = -1;
- while (*wp++ != NULL)
- ;
- }
- vp = lookup(t->str);
- while (setjmp(bc.brkpt))
- if (isbreak)
- goto broken;
- brkset(&bc);
- for (t1 = t->left; i-- && *wp != NULL;) {
- setval(vp, *wp++);
- rv = execute(t1, pin, pout, 0);
- }
- brklist = brklist->nextlev;
- break;
-
- case TWHILE:
- case TUNTIL:
- while (setjmp(bc.brkpt))
- if (isbreak)
- goto broken;
- brkset(&bc);
- t1 = t->left;
- while ((execute(t1, pin, pout, 0) == 0) == (t->type == TWHILE))
- rv = execute(t->right, pin, pout, 0);
- brklist = brklist->nextlev;
- break;
-
- case TIF:
- case TELIF:
- if (t->right != NULL) {
- rv = !execute(t->left, pin, pout, 0) ?
- execute(t->right->left, pin, pout, 0):
- execute(t->right->right, pin, pout, 0);
- }
- break;
-
- case TCASE:
- if ((cp = evalstr(t->str, DOSUB|DOTRIM)) == 0)
- cp = "";
- if ((t1 = findcase(t->left, cp)) != NULL)
- rv = execute(t1, pin, pout, 0);
- break;
-
- case TBRACE:
-/*
- if (iopp = t->ioact)
- while (*iopp)
- if (iosetup(*iopp++, pin!=NULL, pout!=NULL)) {
- rv = -1;
- break;
- }
-*/
- if (rv >= 0 && (t1 = t->left))
- rv = execute(t1, pin, pout, 0);
- break;
- }
-
-broken:
- t->words = wp2;
- isbreak = 0;
- freehere(areanum);
- freearea(areanum);
- areanum = a;
- if (talking && intr) {
- closeall();
- fail();
- }
- if ((i = trapset) != 0) {
- trapset = 0;
- runtrap(i);
- }
- return(rv);
-}
-
-static int
-forkexec(t, pin, pout, act, wp, pforked)
-register struct op *t;
-int *pin, *pout;
-int act;
-char **wp;
-int *pforked;
-{
- int i, rv, (*shcom)();
- register int f;
- char *cp;
- struct ioword **iopp;
- int resetsig;
- char **owp;
-
- owp = wp;
- resetsig = 0;
- *pforked = 0;
- shcom = NULL;
- rv = -1; /* system-detected error */
- if (t->type == TCOM) {
- while ((cp = *wp++) != NULL)
- ;
- cp = *wp;
-
- /* strip all initial assignments */
- /* not correct wrt PATH=yyy command etc */
- if (flag['x'])
- echo (cp ? wp: owp);
- if (cp == NULL && t->ioact == NULL) {
- while ((cp = *owp++) != NULL && assign(cp, COPYV))
- ;
- return(setstatus(0));
- }
- else if (cp != NULL)
- shcom = inbuilt(cp);
- }
- t->words = wp;
- f = act;
- if (shcom == NULL && (f & FEXEC) == 0) {
- i = parent();
- if (i != 0) {
- if (i == -1)
- return(rv);
- if (pin != NULL)
- closepipe(pin);
- return(pout==NULL? setstatus(waitfor(i,0)): 0);
- }
- if (talking) {
- signal(SIGINT, SIG_IGN);
- signal(SIGQUIT, SIG_IGN);
- resetsig = 1;
- }
- talking = 0;
- intr = 0;
- (*pforked)++;
- brklist = 0;
- execflg = 0;
- }
- if (owp != NULL)
- while ((cp = *owp++) != NULL && assign(cp, COPYV))
- if (shcom == NULL)
- export(lookup(cp));
-#ifdef COMPIPE
- if ((pin != NULL || pout != NULL) && shcom != NULL && shcom != doexec) {
- err("piping to/from shell builtins not yet done");
- return(-1);
- }
-#endif
- if (pin != NULL) {
- dup2(pin[0], 0);
- closepipe(pin);
- }
- if (pout != NULL) {
- dup2(pout[1], 1);
- closepipe(pout);
- }
- if ((iopp = t->ioact) != NULL) {
- if (shcom != NULL && shcom != doexec) {
- prs(cp);
- err(": cannot redirect shell command");
- return(-1);
- }
- while (*iopp)
- if (iosetup(*iopp++, pin!=NULL, pout!=NULL))
- return(rv);
- }
- if (shcom)
- return(setstatus((*shcom)(t)));
- /* should use FIOCEXCL */
- for (i=FDBASE; i<NOFILE; i++)
- close(i);
- if (resetsig) {
- signal(SIGINT, SIG_DFL);
- signal(SIGQUIT, SIG_DFL);
- }
- if (t->type == TPAREN)
- exit(execute(t->left, NOPIPE, NOPIPE, FEXEC));
- if (wp[0] == NULL)
- exit(0);
- cp = rexecve(wp[0], wp, makenv());
- prs(wp[0]); prs(": "); warn(cp);
- if (!execflg)
- trap[0] = NULL;
- leave();
- /* NOTREACHED */
-}
-
-/*
- * common actions when creating a new child
- */
-static int
-parent()
-{
- register int i;
-
- i = fork();
- if (i != 0) {
- if (i == -1)
- warn("try again");
- }
- return(i);
-}
-
-/*
- * 0< 1> are ignored as required
- * within pipelines.
- */
-int
-iosetup(iop, pipein, pipeout)
-register struct ioword *iop;
-int pipein, pipeout;
-{
- register u;
- char *cp, *msg;
-
- if (iop->io_unit == IODEFAULT) /* take default */
- iop->io_unit = iop->io_flag&(IOREAD|IOHERE)? 0: 1;
- if (pipein && iop->io_unit == 0)
- return(0);
- if (pipeout && iop->io_unit == 1)
- return(0);
- msg = iop->io_flag&(IOREAD|IOHERE)? "open": "create";
- if ((iop->io_flag & IOHERE) == 0) {
- cp = iop->io_name;
- if ((cp = evalstr(cp, DOSUB|DOTRIM)) == NULL)
- return(1);
- }
- if (iop->io_flag & IODUP) {
- if (cp[1] || (!digit(*cp) && *cp != '-')) {
- prs(cp);
- err(": illegal >& argument");
- return(1);
- }
- if (*cp == '-')
- iop->io_flag = IOCLOSE;
- iop->io_flag &= ~(IOREAD|IOWRITE);
- }
- switch (iop->io_flag) {
- case IOREAD:
- u = open(cp, 0);
- break;
-
- case IOHERE:
- case IOHERE|IOXHERE:
- u = herein(iop->io_name, iop->io_flag&IOXHERE);
- cp = "here file";
- break;
-
- case IOWRITE|IOCAT:
- if ((u = open(cp, 1)) >= 0) {
- lseek(u, (long)0, 2);
- break;
- }
- case IOWRITE:
- u = creat(cp, 0666);
- break;
-
- case IODUP:
- u = dup2(*cp-'0', iop->io_unit);
- break;
-
- case IOCLOSE:
- close(iop->io_unit);
- return(0);
- }
- if (u < 0) {
- prs(cp);
- prs(": cannot ");
- warn(msg);
- return(1);
- } else {
- if (u != iop->io_unit) {
- dup2(u, iop->io_unit);
- close(u);
- }
- }
- return(0);
-}
-
-static void
-echo(wp)
-register char **wp;
-{
- register i;
-
- prs("+");
- for (i=0; wp[i]; i++) {
- if (i)
- prs(" ");
- prs(wp[i]);
- }
- prs("\n");
-}
-
-static struct op **
-find1case(t, w)
-struct op *t;
-char *w;
-{
- register struct op *t1;
- struct op **tp;
- register char **wp, *cp;
-
- if (t == NULL)
- return((struct op **)NULL);
- if (t->type == TLIST) {
- if ((tp = find1case(t->left, w)) != NULL)
- return(tp);
- t1 = t->right; /* TPAT */
- } else
- t1 = t;
- for (wp = t1->words; *wp;)
- if ((cp = evalstr(*wp++, DOSUB)) && gmatch(w, cp))
- return(&t1->left);
- return((struct op **)NULL);
-}
-
-static struct op *
-findcase(t, w)
-struct op *t;
-char *w;
-{
- register struct op **tp;
-
- return((tp = find1case(t, w)) != NULL? *tp: (struct op *)NULL);
-}
-
-/*
- * Enter a new loop level (marked for break/continue).
- */
-static void
-brkset(bc)
-struct brkcon *bc;
-{
- bc->nextlev = brklist;
- brklist = bc;
-}
-
-/*
- * Wait for the last process created.
- * Print a message for each process found
- * that was killed by a signal.
- * Ignore interrupt signals while waiting
- * unless `canintr' is true.
- */
-int
-waitfor(lastpid, canintr)
-register int lastpid;
-int canintr;
-{
- register int pid, rv;
- int s;
- int oheedint = heedint;
-
- heedint = 0;
- rv = 0;
- do {
- pid = wait(&s);
- if (pid == -1) {
- if (errno != EINTR || canintr)
- break;
- } else {
- if ((rv = WAITSIG(s)) != 0) {
- if (rv < NSIGNAL) {
- if (signame[rv] != NULL) {
- if (pid != lastpid) {
- prn(pid);
- prs(": ");
- }
- prs(signame[rv]);
- }
- } else {
- if (pid != lastpid) {
- prn(pid);
- prs(": ");
- }
- prs("Signal "); prn(rv); prs(" ");
- }
- if (WAITCORE(s))
- prs(" - core dumped");
- if (rv >= NSIGNAL || signame[rv])
- prs("\n");
- rv = -1;
- } else
- rv = WAITVAL(s);
- }
- } while (pid != lastpid);
- heedint = oheedint;
- if (intr)
- if (talking) {
- if (canintr)
- intr = 0;
- } else {
- if (exstat == 0) exstat = rv;
- onintr(0);
- }
- return(rv);
-}
-
-int
-setstatus(s)
-register int s;
-{
- exstat = s;
- setval(lookup("?"), putn(s));
- return(s);
-}
-
-/*
- * PATH-searching interface to execve.
- * If getenv("PATH") were kept up-to-date,
- * execvp might be used.
- */
-char *
-rexecve(c, v, envp)
-char *c, **v, **envp;
-{
- register int i;
- register char *sp, *tp;
- int eacces = 0, asis = 0;
-
- sp = any('/', c)? "": path->value;
- asis = *sp == '\0';
- while (asis || *sp != '\0') {
- asis = 0;
- tp = e.linep;
- for (; *sp != '\0'; tp++)
- if ((*tp = *sp++) == ':') {
- asis = *sp == '\0';
- break;
- }
- if (tp != e.linep)
- *tp++ = '/';
- for (i = 0; (*tp++ = c[i++]) != '\0';)
- ;
- execve(e.linep, v, envp);
- switch (errno) {
- case ENOEXEC:
- *v = e.linep;
- tp = *--v;
- *v = e.linep;
- execve("/bin/sh", v, envp);
- *v = tp;
- return("no Shell");
-
- case ENOMEM:
- return("program too big");
-
- case E2BIG:
- return("argument list too long");
-
- case EACCES:
- eacces++;
- break;
- }
- }
- return(errno==ENOENT ? "not found" : "cannot execute");
-}
-
-/*
- * Run the command produced by generator `f'
- * applied to stream `arg'.
- */
-int
-run(argp, f)
-struct ioarg *argp;
-int (*f)();
-{
- struct op *otree;
- struct wdblock *swdlist;
- struct wdblock *siolist;
- jmp_buf ev, rt;
- xint *ofail;
- int rv;
-
- areanum++;
- swdlist = wdlist;
- siolist = iolist;
- otree = outtree;
- ofail = failpt;
- rv = -1;
- if (newenv(setjmp(errpt = ev)) == 0) {
- wdlist = 0;
- iolist = 0;
- pushio(argp, f);
- e.iobase = e.iop;
- yynerrs = 0;
- if (setjmp(failpt = rt) == 0 && yyparse() == 0)
- rv = execute(outtree, NOPIPE, NOPIPE, 0);
- quitenv();
- }
- wdlist = swdlist;
- iolist = siolist;
- failpt = ofail;
- outtree = otree;
- freearea(areanum--);
- return(rv);
-}
-
-/* -------- do.c -------- */
-/* #include "sh.h" */
-
-/*
- * built-in commands: doX
- */
-
-int
-dolabel()
-{
- return(0);
-}
-
-int
-dochdir(t)
-register struct op *t;
-{
- register char *cp, *er;
-
- if ((cp = t->words[1]) == NULL && (cp = homedir->value) == NULL)
- er = ": no home directory";
- else if(chdir(cp) < 0)
- er = ": bad directory";
- else
- return(0);
- prs(cp != NULL? cp: "cd");
- err(er);
- return(1);
-}
-
-int
-doshift(t)
-register struct op *t;
-{
- register n;
-
- n = t->words[1]? getn(t->words[1]): 1;
- if(dolc < n) {
- err("nothing to shift");
- return(1);
- }
- dolv[n] = dolv[0];
- dolv += n;
- dolc -= n;
- setval(lookup("#"), putn(dolc));
- return(0);
-}
-
-/*
- * execute login and newgrp directly
- */
-int
-dologin(t)
-struct op *t;
-{
- register char *cp;
-
- if (talking) {
- signal(SIGINT, SIG_DFL);
- signal(SIGQUIT, SIG_DFL);
- }
- cp = rexecve(t->words[0], t->words, makenv());
- prs(t->words[0]); prs(": "); err(cp);
- return(1);
-}
-
-int
-doumask(t)
-register struct op *t;
-{
- register int i, n;
- register char *cp;
-
- if ((cp = t->words[1]) == NULL) {
- i = umask(0);
- umask(i);
- for (n=3*4; (n-=3) >= 0;)
- putc('0'+((i>>n)&07));
- putc('\n');
- } else {
- for (n=0; *cp>='0' && *cp<='9'; cp++)
- n = n*8 + (*cp-'0');
- umask(n);
- }
- return(0);
-}
-
-int
-doexec(t)
-register struct op *t;
-{
- register i;
- jmp_buf ex;
- xint *ofail;
-
- t->ioact = NULL;
- for(i = 0; (t->words[i]=t->words[i+1]) != NULL; i++)
- ;
- if (i == 0)
- return(1);
- execflg = 1;
- ofail = failpt;
- if (setjmp(failpt = ex) == 0)
- execute(t, NOPIPE, NOPIPE, FEXEC);
- failpt = ofail;
- execflg = 0;
- return(1);
-}
-
-int
-dodot(t)
-struct op *t;
-{
- register i;
- register char *sp, *tp;
- char *cp;
-
- if ((cp = t->words[1]) == NULL)
- return(0);
- sp = any('/', cp)? ":": path->value;
- while (*sp) {
- tp = e.linep;
- while (*sp && (*tp = *sp++) != ':')
- tp++;
- if (tp != e.linep)
- *tp++ = '/';
- for (i = 0; (*tp++ = cp[i++]) != '\0';)
- ;
- if ((i = open(e.linep, 0)) >= 0) {
- exstat = 0;
- next(remap(i));
- return(exstat);
- }
- }
- prs(cp);
- err(": not found");
- return(-1);
-}
-
-int
-dowait(t)
-struct op *t;
-{
- register i;
- register char *cp;
-
- if ((cp = t->words[1]) != NULL) {
- i = getn(cp);
- if (i == 0)
- return(0);
- } else
- i = -1;
- setstatus(waitfor(i, 1));
- return(0);
-}
-
-int
-doread(t)
-struct op *t;
-{
- register char *cp, **wp;
- register nb;
- register int nl = 0;
-
- if (t->words[1] == NULL) {
- err("usage: read name ...");
- return(1);
- }
- for (wp = t->words+1; *wp; wp++) {
- for (cp = e.linep; !nl && cp < elinep-1; cp++)
- if ((nb = read(0, cp, sizeof(*cp))) != sizeof(*cp) ||
- (nl = (*cp == '\n')) ||
- (wp[1] && any(*cp, ifs->value)))
- break;
- *cp = 0;
- if (nb <= 0)
- break;
- setval(lookup(*wp), e.linep);
- }
- return(nb <= 0);
-}
-
-int
-doeval(t)
-register struct op *t;
-{
- return(RUN(awordlist, t->words+1, wdchar));
-}
-
-int
-dotrap(t)
-register struct op *t;
-{
- register int n, i;
- register int resetsig;
-
- if (t->words[1] == NULL) {
- for (i=0; i<=_NSIG; i++)
- if (trap[i]) {
- prn(i);
- prs(": ");
- prs(trap[i]);
- prs("\n");
- }
- return(0);
- }
- resetsig = digit(*t->words[1]);
- for (i = resetsig ? 1 : 2; t->words[i] != NULL; ++i) {
- n = getsig(t->words[i]);
- xfree(trap[n]);
- trap[n] = 0;
- if (!resetsig) {
- if (*t->words[1] != '\0') {
- trap[n] = strsave(t->words[1], 0);
- setsig(n, sig);
- } else
- setsig(n, SIG_IGN);
- } else {
- if (talking)
- if (n == SIGINT)
- setsig(n, onintr);
- else
- setsig(n, n == SIGQUIT ? SIG_IGN
- : SIG_DFL);
- else
- setsig(n, SIG_DFL);
- }
- }
- return(0);
-}
-
-int
-getsig(s)
-char *s;
-{
- register int n;
-
- if ((n = getn(s)) < 0 || n > _NSIG) {
- err("trap: bad signal number");
- n = 0;
- }
- return(n);
-}
-
-void
-setsig(n, f)
-register n;
-_PROTOTYPE(void (*f), (int));
-{
- if (n == 0)
- return;
- if (signal(n, SIG_IGN) != SIG_IGN || ourtrap[n]) {
- ourtrap[n] = 1;
- signal(n, f);
- }
-}
-
-int
-getn(as)
-char *as;
-{
- register char *s;
- register n, m;
-
- s = as;
- m = 1;
- if (*s == '-') {
- m = -1;
- s++;
- }
- for (n = 0; digit(*s); s++)
- n = (n*10) + (*s-'0');
- if (*s) {
- prs(as);
- err(": bad number");
- }
- return(n*m);
-}
-
-int
-dobreak(t)
-struct op *t;
-{
- return(brkcontin(t->words[1], 1));
-}
-
-int
-docontinue(t)
-struct op *t;
-{
- return(brkcontin(t->words[1], 0));
-}
-
-static int
-brkcontin(cp, val)
-register char *cp;
-int val;
-{
- register struct brkcon *bc;
- register nl;
-
- nl = cp == NULL? 1: getn(cp);
- if (nl <= 0)
- nl = 999;
- do {
- if ((bc = brklist) == NULL)
- break;
- brklist = bc->nextlev;
- } while (--nl);
- if (nl) {
- err("bad break/continue level");
- return(1);
- }
- isbreak = val;
- longjmp(bc->brkpt, 1);
- /* NOTREACHED */
-}
-
-int
-doexit(t)
-struct op *t;
-{
- register char *cp;
-
- execflg = 0;
- if ((cp = t->words[1]) != NULL)
- setstatus(getn(cp));
- leave();
- /* NOTREACHED */
-}
-
-int
-doexport(t)
-struct op *t;
-{
- rdexp(t->words+1, export, EXPORT);
- return(0);
-}
-
-int
-doreadonly(t)
-struct op *t;
-{
- rdexp(t->words+1, ronly, RONLY);
- return(0);
-}
-
-static void
-rdexp(wp, f, key)
-register char **wp;
-void (*f)();
-int key;
-{
- if (*wp != NULL) {
- for (; *wp != NULL; wp++)
- if (checkname(*wp))
- (*f)(lookup(*wp));
- else
- badid(*wp);
- } else
- putvlist(key, 1);
-}
-
-static void
-badid(s)
-register char *s;
-{
- prs(s);
- err(": bad identifier");
-}
-
-int
-doset(t)
-register struct op *t;
-{
- register struct var *vp;
- register char *cp;
- register n;
-
- if ((cp = t->words[1]) == NULL) {
- for (vp = vlist; vp; vp = vp->next)
- varput(vp->name, 1);
- return(0);
- }
- if (*cp == '-') {
- /* bad: t->words++; */
- for(n = 0; (t->words[n]=t->words[n+1]) != NULL; n++)
- ;
- if (*++cp == 0)
- flag['x'] = flag['v'] = 0;
- else
- for (; *cp; cp++)
- switch (*cp) {
- case 'e':
- if (!talking)
- flag['e']++;
- break;
-
- default:
- if (*cp>='a' && *cp<='z')
- flag[*cp]++;
- break;
- }
- setdash();
- }
- if (t->words[1]) {
- t->words[0] = dolv[0];
- for (n=1; t->words[n]; n++)
- setarea((char *)t->words[n], 0);
- dolc = n-1;
- dolv = t->words;
- setval(lookup("#"), putn(dolc));
- setarea((char *)(dolv-1), 0);
- }
- return(0);
-}
-
-void
-varput(s, out)
-register char *s;
-int out;
-{
- if (letnum(*s)) {
- write(out, s, strlen(s));
- write(out, "\n", 1);
- }
-}
-
-
-#define SECS 60L
-#define MINS 3600L
-
-int
-dotimes()
-{
- struct tms tbuf;
-
- times(&tbuf);
-
- prn((int)(tbuf.tms_cutime / MINS));
- prs("m");
- prn((int)((tbuf.tms_cutime % MINS) / SECS));
- prs("s ");
- prn((int)(tbuf.tms_cstime / MINS));
- prs("m");
- prn((int)((tbuf.tms_cstime % MINS) / SECS));
- prs("s\n");
- return(0);
-}
-
-struct builtin {
- char *command;
- int (*fn)();
-};
-static struct builtin builtin[] = {
- ":", dolabel,
- "cd", dochdir,
- "shift", doshift,
- "exec", doexec,
- "wait", dowait,
- "read", doread,
- "eval", doeval,
- "trap", dotrap,
- "break", dobreak,
- "continue", docontinue,
- "exit", doexit,
- "export", doexport,
- "readonly", doreadonly,
- "set", doset,
- ".", dodot,
- "umask", doumask,
- "login", dologin,
- "newgrp", dologin,
- "times", dotimes,
- 0,
-};
-
-int (*inbuilt(s))()
-register char *s;
-{
- register struct builtin *bp;
-
- for (bp = builtin; bp->command != NULL; bp++)
- if (strcmp(bp->command, s) == 0)
- return(bp->fn);
- return((int(*)())NULL);
-}
-
diff --git a/release/picobsd/tinyware/msh/sh4.c b/release/picobsd/tinyware/msh/sh4.c
deleted file mode 100644
index ac2a5827aeea..000000000000
--- a/release/picobsd/tinyware/msh/sh4.c
+++ /dev/null
@@ -1,767 +0,0 @@
-#define Extern extern
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <dirent.h>
-#include <limits.h>
-#include <signal.h>
-#define _NSIG NSIG
-#include <errno.h>
-#include <setjmp.h>
-#include "sh.h"
-
-/* -------- eval.c -------- */
-/* #include "sh.h" */
-/* #include "word.h" */
-
-/*
- * ${}
- * `command`
- * blank interpretation
- * quoting
- * glob
- */
-
-_PROTOTYPE(static int expand, (char *cp, struct wdblock **wbp, int f ));
-_PROTOTYPE(static char *blank, (int f ));
-_PROTOTYPE(static int dollar, (int quoted ));
-_PROTOTYPE(static int grave, (int quoted ));
-_PROTOTYPE(void globname, (char *we, char *pp ));
-_PROTOTYPE(static char *generate, (char *start1, char *end1, char *middle, char *end ));
-_PROTOTYPE(static int anyspcl, (struct wdblock *wb ));
-_PROTOTYPE(static int xstrcmp, (char *p1, char *p2 ));
-_PROTOTYPE(void glob0, (char *a0, unsigned int a1, int a2, int (*a3)(char *, char *)));
-_PROTOTYPE(void glob1, (char *base, char *lim ));
-_PROTOTYPE(void glob2, (char *i, char *j ));
-_PROTOTYPE(void glob3, (char *i, char *j, char *k ));
-_PROTOTYPE(char *memcopy, (char *ato, char *from, int nb ));
-
-char **
-eval(ap, f)
-register char **ap;
-int f;
-{
- struct wdblock *wb;
- char **wp;
- char **wf;
- jmp_buf ev;
-
- wp = NULL;
- wb = NULL;
- wf = NULL;
- if (newenv(setjmp(errpt = ev)) == 0) {
- while (*ap && isassign(*ap))
- expand(*ap++, &wb, f & ~DOGLOB);
- if (flag['k']) {
- for (wf = ap; *wf; wf++) {
- if (isassign(*wf))
- expand(*wf, &wb, f & ~DOGLOB);
- }
- }
- for (wb = addword((char *)0, wb); *ap; ap++) {
- if (!flag['k'] || !isassign(*ap))
- expand(*ap, &wb, f & ~DOKEY);
- }
- wb = addword((char *)0, wb);
- wp = getwords(wb);
- quitenv();
- } else
- gflg = 1;
- return(gflg? (char **)NULL: wp);
-}
-
-/*
- * Make the exported environment from the exported
- * names in the dictionary. Keyword assignments
- * will already have been done.
- */
-char **
-makenv()
-
-{
- register struct wdblock *wb;
- register struct var *vp;
-
- wb = NULL;
- for (vp = vlist; vp; vp = vp->next)
- if (vp->status & EXPORT)
- wb = addword(vp->name, wb);
- wb = addword((char *)0, wb);
- return(getwords(wb));
-}
-
-char *
-evalstr(cp, f)
-register char *cp;
-int f;
-{
- struct wdblock *wb;
-
- wb = NULL;
- if (expand(cp, &wb, f)) {
- if (wb == NULL || wb->w_nword == 0 || (cp = wb->w_words[0]) == NULL)
- cp = "";
- DELETE(wb);
- } else
- cp = NULL;
- return(cp);
-}
-
-static int
-expand(cp, wbp, f)
-register char *cp;
-register struct wdblock **wbp;
-int f;
-{
- jmp_buf ev;
-
- gflg = 0;
- if (cp == NULL)
- return(0);
- if (!anys("$`'\"", cp) &&
- !anys(ifs->value, cp) &&
- ((f&DOGLOB)==0 || !anys("[*?", cp))) {
- cp = strsave(cp, areanum);
- if (f & DOTRIM)
- unquote(cp);
- *wbp = addword(cp, *wbp);
- return(1);
- }
- if (newenv(setjmp(errpt = ev)) == 0) {
- PUSHIO(aword, cp, strchar);
- e.iobase = e.iop;
- while ((cp = blank(f)) && gflg == 0) {
- e.linep = cp;
- cp = strsave(cp, areanum);
- if ((f&DOGLOB) == 0) {
- if (f & DOTRIM)
- unquote(cp);
- *wbp = addword(cp, *wbp);
- } else
- *wbp = glob(cp, *wbp);
- }
- quitenv();
- } else
- gflg = 1;
- return(gflg == 0);
-}
-
-/*
- * Blank interpretation and quoting
- */
-static char *
-blank(f)
-int f;
-{
- register c, c1;
- register char *sp;
- int scanequals, foundequals;
-
- sp = e.linep;
- scanequals = f & DOKEY;
- foundequals = 0;
-
-loop:
- switch (c = subgetc('"', foundequals)) {
- case 0:
- if (sp == e.linep)
- return(0);
- *e.linep++ = 0;
- return(sp);
-
- default:
- if (f & DOBLANK && any(c, ifs->value))
- goto loop;
- break;
-
- case '"':
- case '\'':
- scanequals = 0;
- if (INSUB())
- break;
- for (c1 = c; (c = subgetc(c1, 1)) != c1;) {
- if (c == 0)
- break;
- if (c == '\'' || !any(c, "$`\""))
- c |= QUOTE;
- *e.linep++ = c;
- }
- c = 0;
- }
- unget(c);
- if (!letter(c))
- scanequals = 0;
- for (;;) {
- c = subgetc('"', foundequals);
- if (c == 0 ||
- f & (DOBLANK && any(c, ifs->value)) ||
- (!INSUB() && any(c, "\"'"))) {
- scanequals = 0;
- unget(c);
- if (any(c, "\"'"))
- goto loop;
- break;
- }
- if (scanequals)
- if (c == '=') {
- foundequals = 1;
- scanequals = 0;
- }
- else if (!letnum(c))
- scanequals = 0;
- *e.linep++ = c;
- }
- *e.linep++ = 0;
- return(sp);
-}
-
-/*
- * Get characters, substituting for ` and $
- */
-int
-subgetc(ec, quoted)
-register char ec;
-int quoted;
-{
- register char c;
-
-again:
- c = getc(ec);
- if (!INSUB() && ec != '\'') {
- if (c == '`') {
- if (grave(quoted) == 0)
- return(0);
- e.iop->task = XGRAVE;
- goto again;
- }
- if (c == '$' && (c = dollar(quoted)) == 0) {
- e.iop->task = XDOLL;
- goto again;
- }
- }
- return(c);
-}
-
-/*
- * Prepare to generate the string returned by ${} substitution.
- */
-static int
-dollar(quoted)
-int quoted;
-{
- int otask;
- struct io *oiop;
- char *dolp;
- register char *s, c, *cp;
- struct var *vp;
-
- c = readc();
- s = e.linep;
- if (c != '{') {
- *e.linep++ = c;
- if (letter(c)) {
- while ((c = readc())!=0 && letnum(c))
- if (e.linep < elinep)
- *e.linep++ = c;
- unget(c);
- }
- c = 0;
- } else {
- oiop = e.iop;
- otask = e.iop->task;
- e.iop->task = XOTHER;
- while ((c = subgetc('"', 0))!=0 && c!='}' && c!='\n')
- if (e.linep < elinep)
- *e.linep++ = c;
- if (oiop == e.iop)
- e.iop->task = otask;
- if (c != '}') {
- err("unclosed ${");
- gflg++;
- return(c);
- }
- }
- if (e.linep >= elinep) {
- err("string in ${} too long");
- gflg++;
- e.linep -= 10;
- }
- *e.linep = 0;
- if (*s)
- for (cp = s+1; *cp; cp++)
- if (any(*cp, "=-+?")) {
- c = *cp;
- *cp++ = 0;
- break;
- }
- if (s[1] == 0 && (*s == '*' || *s == '@')) {
- if (dolc > 1) {
- /* currently this does not distinguish $* and $@ */
- /* should check dollar */
- e.linep = s;
- PUSHIO(awordlist, dolv+1, dolchar);
- return(0);
- } else { /* trap the nasty ${=} */
- s[0] = '1';
- s[1] = 0;
- }
- }
- vp = lookup(s);
- if ((dolp = vp->value) == null) {
- switch (c) {
- case '=':
- if (digit(*s)) {
- err("cannot use ${...=...} with $n");
- gflg++;
- break;
- }
- setval(vp, cp);
- dolp = vp->value;
- break;
-
- case '-':
- dolp = strsave(cp, areanum);
- break;
-
- case '?':
- if (*cp == 0) {
- prs("missing value for ");
- err(s);
- } else
- err(cp);
- gflg++;
- break;
- }
- } else if (c == '+')
- dolp = strsave(cp, areanum);
- if (flag['u'] && dolp == null) {
- prs("unset variable: ");
- err(s);
- gflg++;
- }
- e.linep = s;
- PUSHIO(aword, dolp, quoted ? qstrchar : strchar);
- return(0);
-}
-
-/*
- * Run the command in `...` and read its output.
- */
-static int
-grave(quoted)
-int quoted;
-{
- register char *cp;
- register int i;
- int pf[2];
-
- for (cp = e.iop->argp->aword; *cp != '`'; cp++)
- if (*cp == 0) {
- err("no closing `");
- return(0);
- }
- if (openpipe(pf) < 0)
- return(0);
- if ((i = fork()) == -1) {
- closepipe(pf);
- err("try again");
- return(0);
- }
- if (i != 0) {
- e.iop->argp->aword = ++cp;
- close(pf[1]);
- PUSHIO(afile, remap(pf[0]), quoted? qgravechar: gravechar);
- return(1);
- }
- *cp = 0;
- /* allow trapped signals */
- for (i=0; i<=_NSIG; i++)
- if (ourtrap[i] && signal(i, SIG_IGN) != SIG_IGN)
- signal(i, SIG_DFL);
- dup2(pf[1], 1);
- closepipe(pf);
- flag['e'] = 0;
- flag['v'] = 0;
- flag['n'] = 0;
- cp = strsave(e.iop->argp->aword, 0);
- areanum = 1;
- freehere(areanum);
- freearea(areanum); /* free old space */
- e.oenv = NULL;
- e.iop = (e.iobase = iostack) - 1;
- unquote(cp);
- talking = 0;
- PUSHIO(aword, cp, nlchar);
- onecommand();
- exit(1);
-}
-
-char *
-unquote(as)
-register char *as;
-{
- register char *s;
-
- if ((s = as) != NULL)
- while (*s)
- *s++ &= ~QUOTE;
- return(as);
-}
-
-/* -------- glob.c -------- */
-/* #include "sh.h" */
-
-/*
- * glob
- */
-
-#define scopy(x) strsave((x), areanum)
-#define BLKSIZ 512
-#define NDENT ((BLKSIZ+sizeof(struct dirent)-1)/sizeof(struct dirent))
-
-static struct wdblock *cl, *nl;
-static char spcl[] = "[?*";
-
-struct wdblock *
-glob(cp, wb)
-char *cp;
-struct wdblock *wb;
-{
- register i;
- register char *pp;
-
- if (cp == 0)
- return(wb);
- i = 0;
- for (pp = cp; *pp; pp++)
- if (any(*pp, spcl))
- i++;
- else if (!any(*pp & ~QUOTE, spcl))
- *pp &= ~QUOTE;
- if (i != 0) {
- for (cl = addword(scopy(cp), (struct wdblock *)0); anyspcl(cl); cl = nl) {
- nl = newword(cl->w_nword*2);
- for(i=0; i<cl->w_nword; i++) { /* for each argument */
- for (pp = cl->w_words[i]; *pp; pp++)
- if (any(*pp, spcl)) {
- globname(cl->w_words[i], pp);
- break;
- }
- if (*pp == '\0')
- nl = addword(scopy(cl->w_words[i]), nl);
- }
- for(i=0; i<cl->w_nword; i++)
- DELETE(cl->w_words[i]);
- DELETE(cl);
- }
- for(i=0; i<cl->w_nword; i++)
- unquote(cl->w_words[i]);
- glob0((char *)cl->w_words, cl->w_nword, sizeof(char *), xstrcmp);
- if (cl->w_nword) {
- for (i=0; i<cl->w_nword; i++)
- wb = addword(cl->w_words[i], wb);
- DELETE(cl);
- return(wb);
- }
- }
- wb = addword(unquote(cp), wb);
- return(wb);
-}
-
-void
-globname(we, pp)
-char *we;
-register char *pp;
-{
- register char *np, *cp;
- char *name, *gp, *dp;
- int dn, j, n, k;
- DIR *dirp;
- struct dirent *de;
- char dname[NAME_MAX+1];
- struct stat dbuf;
-
- for (np = we; np != pp; pp--)
- if (pp[-1] == '/')
- break;
- for (dp = cp = space((int)(pp-np)+3); np < pp;)
- *cp++ = *np++;
- *cp++ = '.';
- *cp = '\0';
- for (gp = cp = space(strlen(pp)+1); *np && *np != '/';)
- *cp++ = *np++;
- *cp = '\0';
- dirp = opendir(dp);
- if (dirp == 0) {
- DELETE(dp);
- DELETE(gp);
- return;
- }
- dname[NAME_MAX] = '\0';
- while ((de=readdir(dirp))!=NULL) {
- /* XXX Hmmm... What this could be? (abial) */
- /*
- if (ent[j].d_ino == 0)
- continue;
- */
- strncpy(dname, de->d_name, NAME_MAX);
- if (dname[0] == '.')
- if (*gp != '.')
- continue;
- for(k=0; k<NAME_MAX; k++)
- if (any(dname[k], spcl))
- dname[k] |= QUOTE;
- if (gmatch(dname, gp)) {
- name = generate(we, pp, dname, np);
- if (*np && !anys(np, spcl)) {
- if (stat(name,&dbuf)) {
- DELETE(name);
- continue;
- }
- }
- nl = addword(name, nl);
- }
- }
- closedir(dirp);
- DELETE(dp);
- DELETE(gp);
-}
-
-/*
- * generate a pathname as below.
- * start..end1 / middle end
- * the slashes come for free
- */
-static char *
-generate(start1, end1, middle, end)
-char *start1;
-register char *end1;
-char *middle, *end;
-{
- char *p;
- register char *op, *xp;
-
- p = op = space((int)(end1-start1)+strlen(middle)+strlen(end)+2);
- for (xp = start1; xp != end1;)
- *op++ = *xp++;
- for (xp = middle; (*op++ = *xp++) != '\0';)
- ;
- op--;
- for (xp = end; (*op++ = *xp++) != '\0';)
- ;
- return(p);
-}
-
-static int
-anyspcl(wb)
-register struct wdblock *wb;
-{
- register i;
- register char **wd;
-
- wd = wb->w_words;
- for (i=0; i<wb->w_nword; i++)
- if (anys(spcl, *wd++))
- return(1);
- return(0);
-}
-
-static int
-xstrcmp(p1, p2)
-char *p1, *p2;
-{
- return(strcmp(*(char **)p1, *(char **)p2));
-}
-
-/* -------- word.c -------- */
-/* #include "sh.h" */
-/* #include "word.h" */
-
-#define NSTART 16 /* default number of words to allow for initially */
-
-struct wdblock *
-newword(nw)
-register int nw;
-{
- register struct wdblock *wb;
-
- wb = (struct wdblock *) space(sizeof(*wb) + nw*sizeof(char *));
- wb->w_bsize = nw;
- wb->w_nword = 0;
- return(wb);
-}
-
-struct wdblock *
-addword(wd, wb)
-char *wd;
-register struct wdblock *wb;
-{
- register struct wdblock *wb2;
- register nw;
-
- if (wb == NULL)
- wb = newword(NSTART);
- if ((nw = wb->w_nword) >= wb->w_bsize) {
- wb2 = newword(nw * 2);
- memcopy((char *)wb2->w_words, (char *)wb->w_words, nw*sizeof(char *));
- wb2->w_nword = nw;
- DELETE(wb);
- wb = wb2;
- }
- wb->w_words[wb->w_nword++] = wd;
- return(wb);
-}
-
-char **
-getwords(wb)
-register struct wdblock *wb;
-{
- register char **wd;
- register nb;
-
- if (wb == NULL)
- return((char **)NULL);
- if (wb->w_nword == 0) {
- DELETE(wb);
- return((char **)NULL);
- }
- wd = (char **) space(nb = sizeof(*wd) * wb->w_nword);
- memcopy((char *)wd, (char *)wb->w_words, nb);
- DELETE(wb); /* perhaps should done by caller */
- return(wd);
-}
-
-_PROTOTYPE(int (*func), (char *, char *));
-int globv;
-
-void
-glob0(a0, a1, a2, a3)
-char *a0;
-unsigned a1;
-int a2;
-_PROTOTYPE(int (*a3), (char *, char *));
-{
- func = a3;
- globv = a2;
- glob1(a0, a0 + a1 * a2);
-}
-
-void
-glob1(base, lim)
-char *base, *lim;
-{
- register char *i, *j;
- int v2;
- char *lptr, *hptr;
- int c;
- unsigned n;
-
-
- v2 = globv;
-
-top:
- if ((n=(int)(lim-base)) <= v2)
- return;
- n = v2 * (n / (2*v2));
- hptr = lptr = base+n;
- i = base;
- j = lim-v2;
- for(;;) {
- if (i < lptr) {
- if ((c = (*func)(i, lptr)) == 0) {
- glob2(i, lptr -= v2);
- continue;
- }
- if (c < 0) {
- i += v2;
- continue;
- }
- }
-
-begin:
- if (j > hptr) {
- if ((c = (*func)(hptr, j)) == 0) {
- glob2(hptr += v2, j);
- goto begin;
- }
- if (c > 0) {
- if (i == lptr) {
- glob3(i, hptr += v2, j);
- i = lptr += v2;
- goto begin;
- }
- glob2(i, j);
- j -= v2;
- i += v2;
- continue;
- }
- j -= v2;
- goto begin;
- }
-
-
- if (i == lptr) {
- if (lptr-base >= lim-hptr) {
- glob1(hptr+v2, lim);
- lim = lptr;
- } else {
- glob1(base, lptr);
- base = hptr+v2;
- }
- goto top;
- }
-
-
- glob3(j, lptr -= v2, i);
- j = hptr -= v2;
- }
-}
-
-void
-glob2(i, j)
-char *i, *j;
-{
- register char *index1, *index2, c;
- int m;
-
- m = globv;
- index1 = i;
- index2 = j;
- do {
- c = *index1;
- *index1++ = *index2;
- *index2++ = c;
- } while(--m);
-}
-
-void
-glob3(i, j, k)
-char *i, *j, *k;
-{
- register char *index1, *index2, *index3;
- int c;
- int m;
-
- m = globv;
- index1 = i;
- index2 = j;
- index3 = k;
- do {
- c = *index1;
- *index1++ = *index3;
- *index3++ = *index2;
- *index2++ = c;
- } while(--m);
-}
-
-char *
-memcopy(ato, from, nb)
-register char *ato, *from;
-register int nb;
-{
- register char *to;
-
- to = ato;
- while (--nb >= 0)
- *to++ = *from++;
- return(ato);
-}
diff --git a/release/picobsd/tinyware/msh/sh5.c b/release/picobsd/tinyware/msh/sh5.c
deleted file mode 100644
index 74feac9cebce..000000000000
--- a/release/picobsd/tinyware/msh/sh5.c
+++ /dev/null
@@ -1,675 +0,0 @@
-#define Extern extern
-#include <sys/types.h>
-#include <signal.h>
-#define _NSIG NSIG
-#include <errno.h>
-#include <setjmp.h>
-#include "sh.h"
-
-/* -------- io.c -------- */
-/* #include "sh.h" */
-
-/*
- * shell IO
- */
-
-static struct iobuf sharedbuf = {AFID_NOBUF};
-static struct iobuf mainbuf = {AFID_NOBUF};
-static unsigned bufid = AFID_ID; /* buffer id counter */
-
-struct ioarg temparg = {0, 0, 0, AFID_NOBUF, 0};
-
-_PROTOTYPE(static void readhere, (char **name, char *s, int ec ));
-_PROTOTYPE(void pushio, (struct ioarg *argp, int (*fn)()));
-_PROTOTYPE(static int xxchar, (struct ioarg *ap ));
-_PROTOTYPE(void tempname, (char *tname ));
-
-int
-getc(ec)
-register int ec;
-{
- register int c;
-
- if(e.linep > elinep) {
- while((c=readc()) != '\n' && c)
- ;
- err("input line too long");
- gflg++;
- return(c);
- }
- c = readc();
- if (ec != '\'' && e.iop->task != XGRAVE) {
- if(c == '\\') {
- c = readc();
- if (c == '\n' && ec != '\"')
- return(getc(ec));
- c |= QUOTE;
- }
- }
- return(c);
-}
-
-void
-unget(c)
-int c;
-{
- if (e.iop >= e.iobase)
- e.iop->peekc = c;
-}
-
-int
-eofc()
-
-{
- return e.iop < e.iobase || (e.iop->peekc == 0 && e.iop->prev == 0);
-}
-
-int
-readc()
-{
- register c;
-
- for (; e.iop >= e.iobase; e.iop--)
- if ((c = e.iop->peekc) != '\0') {
- e.iop->peekc = 0;
- return(c);
- }
- else {
- if (e.iop->prev != 0) {
- if ((c = (*e.iop->iofn)(e.iop->argp, e.iop)) != '\0') {
- if (c == -1) {
- e.iop++;
- continue;
- }
- if (e.iop == iostack)
- ioecho(c);
- return(e.iop->prev = c);
- }
- else if (e.iop->task == XIO && e.iop->prev != '\n') {
- e.iop->prev = 0;
- if (e.iop == iostack)
- ioecho('\n');
- return '\n';
- }
- }
- if (e.iop->task == XIO) {
- if (multiline)
- return e.iop->prev = 0;
- if (talking && e.iop == iostack+1)
- prs(prompt->value);
- }
- }
- if (e.iop >= iostack)
- return(0);
- leave();
- /* NOTREACHED */
-}
-
-void
-ioecho(c)
-char c;
-{
- if (flag['v'])
- write(2, &c, sizeof c);
-}
-
-void
-pushio(argp, fn)
-struct ioarg *argp;
-int (*fn)();
-{
- if (++e.iop >= &iostack[NPUSH]) {
- e.iop--;
- err("Shell input nested too deeply");
- gflg++;
- return;
- }
- e.iop->iofn = fn;
-
- if (argp->afid != AFID_NOBUF)
- e.iop->argp = argp;
- else {
- e.iop->argp = ioargstack + (e.iop - iostack);
- *e.iop->argp = *argp;
- e.iop->argp->afbuf = e.iop == &iostack[0] ? &mainbuf : &sharedbuf;
- if (isatty(e.iop->argp->afile) == 0 &&
- (e.iop == &iostack[0] ||
- lseek(e.iop->argp->afile, 0L, 1) != -1)) {
- if (++bufid == AFID_NOBUF)
- bufid = AFID_ID;
- e.iop->argp->afid = bufid;
- }
- }
-
- e.iop->prev = ~'\n';
- e.iop->peekc = 0;
- e.iop->xchar = 0;
- e.iop->nlcount = 0;
- if (fn == filechar || fn == linechar)
- e.iop->task = XIO;
- else if (fn == gravechar || fn == qgravechar)
- e.iop->task = XGRAVE;
- else
- e.iop->task = XOTHER;
-}
-
-struct io *
-setbase(ip)
-struct io *ip;
-{
- register struct io *xp;
-
- xp = e.iobase;
- e.iobase = ip;
- return(xp);
-}
-
-/*
- * Input generating functions
- */
-
-/*
- * Produce the characters of a string, then a newline, then EOF.
- */
-int
-nlchar(ap)
-register struct ioarg *ap;
-{
- register int c;
-
- if (ap->aword == NULL)
- return(0);
- if ((c = *ap->aword++) == 0) {
- ap->aword = NULL;
- return('\n');
- }
- return(c);
-}
-
-/*
- * Given a list of words, produce the characters
- * in them, with a space after each word.
- */
-int
-wdchar(ap)
-register struct ioarg *ap;
-{
- register char c;
- register char **wl;
-
- if ((wl = ap->awordlist) == NULL)
- return(0);
- if (*wl != NULL) {
- if ((c = *(*wl)++) != 0)
- return(c & 0177);
- ap->awordlist++;
- return(' ');
- }
- ap->awordlist = NULL;
- return('\n');
-}
-
-/*
- * Return the characters of a list of words,
- * producing a space between them.
- */
-int
-dolchar(ap)
-register struct ioarg *ap;
-{
- register char *wp;
-
- if ((wp = *ap->awordlist++) != NULL) {
- PUSHIO(aword, wp, *ap->awordlist == NULL? strchar: xxchar);
- return(-1);
- }
- return(0);
-}
-
-static int
-xxchar(ap)
-register struct ioarg *ap;
-{
- register int c;
-
- if (ap->aword == NULL)
- return(0);
- if ((c = *ap->aword++) == '\0') {
- ap->aword = NULL;
- return(' ');
- }
- return(c);
-}
-
-/*
- * Produce the characters from a single word (string).
- */
-int
-strchar(ap)
-register struct ioarg *ap;
-{
- register int c;
-
- if (ap->aword == NULL || (c = *ap->aword++) == 0)
- return(0);
- return(c);
-}
-
-/*
- * Produce quoted characters from a single word (string).
- */
-int
-qstrchar(ap)
-register struct ioarg *ap;
-{
- register int c;
-
- if (ap->aword == NULL || (c = *ap->aword++) == 0)
- return(0);
- return(c|QUOTE);
-}
-
-/*
- * Return the characters from a file.
- */
-int
-filechar(ap)
-register struct ioarg *ap;
-{
- register int i;
- char c;
- struct iobuf *bp = ap->afbuf;
-
- if (ap->afid != AFID_NOBUF) {
- if ((i = ap->afid != bp->id) || bp->bufp == bp->ebufp) {
- if (i)
- lseek(ap->afile, ap->afpos, 0);
- do {
- i = read(ap->afile, bp->buf, sizeof(bp->buf));
- } while (i < 0 && errno == EINTR);
- if (i <= 0) {
- closef(ap->afile);
- return 0;
- }
- bp->id = ap->afid;
- bp->ebufp = (bp->bufp = bp->buf) + i;
- }
- ap->afpos++;
- return *bp->bufp++ & 0177;
- }
-
- do {
- i = read(ap->afile, &c, sizeof(c));
- } while (i < 0 && errno == EINTR);
- return(i == sizeof(c)? c&0177: (closef(ap->afile), 0));
-}
-
-/*
- * Return the characters from a here temp file.
- */
-int
-herechar(ap)
-register struct ioarg *ap;
-{
- char c;
-
-
- if (read(ap->afile, &c, sizeof(c)) != sizeof(c)) {
- close(ap->afile);
- c = 0;
- }
- return (c);
-
-}
-
-/*
- * Return the characters produced by a process (`...`).
- * Quote them if required, and remove any trailing newline characters.
- */
-int
-gravechar(ap, iop)
-struct ioarg *ap;
-struct io *iop;
-{
- register int c;
-
- if ((c = qgravechar(ap, iop)&~QUOTE) == '\n')
- c = ' ';
- return(c);
-}
-
-int
-qgravechar(ap, iop)
-register struct ioarg *ap;
-struct io *iop;
-{
- register int c;
-
- if (iop->xchar) {
- if (iop->nlcount) {
- iop->nlcount--;
- return('\n'|QUOTE);
- }
- c = iop->xchar;
- iop->xchar = 0;
- } else if ((c = filechar(ap)) == '\n') {
- iop->nlcount = 1;
- while ((c = filechar(ap)) == '\n')
- iop->nlcount++;
- iop->xchar = c;
- if (c == 0)
- return(c);
- iop->nlcount--;
- c = '\n';
- }
- return(c!=0? c|QUOTE: 0);
-}
-
-/*
- * Return a single command (usually the first line) from a file.
- */
-int
-linechar(ap)
-register struct ioarg *ap;
-{
- register int c;
-
- if ((c = filechar(ap)) == '\n') {
- if (!multiline) {
- closef(ap->afile);
- ap->afile = -1; /* illegal value */
- }
- }
- return(c);
-}
-
-void
-prs(s)
-register char *s;
-{
- if (*s)
- write(2, s, strlen(s));
-}
-
-void
-putc(c)
-char c;
-{
- write(2, &c, sizeof c);
-}
-
-void
-prn(u)
-unsigned u;
-{
- prs(itoa(u, 0));
-}
-
-void
-closef(i)
-register int i;
-{
- if (i > 2)
- close(i);
-}
-
-void
-closeall()
-{
- register u;
-
- for (u=NUFILE; u<NOFILE;)
- close(u++);
-}
-
-/*
- * remap fd into Shell's fd space
- */
-int
-remap(fd)
-register int fd;
-{
- register int i;
- int map[NOFILE];
-
- if (fd < e.iofd) {
- for (i=0; i<NOFILE; i++)
- map[i] = 0;
- do {
- map[fd] = 1;
- fd = dup(fd);
- } while (fd >= 0 && fd < e.iofd);
- for (i=0; i<NOFILE; i++)
- if (map[i])
- close(i);
- if (fd < 0)
- err("too many files open in shell");
- }
- return(fd);
-}
-
-int
-openpipe(pv)
-register int *pv;
-{
- register int i;
-
- if ((i = pipe(pv)) < 0)
- err("can't create pipe - try again");
- return(i);
-}
-
-void
-closepipe(pv)
-register int *pv;
-{
- if (pv != NULL) {
- close(*pv++);
- close(*pv);
- }
-}
-
-/* -------- here.c -------- */
-/* #include "sh.h" */
-
-/*
- * here documents
- */
-
-struct here {
- char *h_tag;
- int h_dosub;
- struct ioword *h_iop;
- struct here *h_next;
-};
-
-static struct here *inhere; /* list of hear docs while parsing */
-static struct here *acthere; /* list of active here documents */
-
-void
-markhere(s, iop)
-register char *s;
-struct ioword *iop;
-{
- register struct here *h, *lh;
-
- h = (struct here *) space(sizeof(struct here));
- if (h == 0)
- return;
- h->h_tag = evalstr(s, DOSUB);
- if (h->h_tag == 0)
- return;
- h->h_iop = iop;
- iop->io_name = 0;
- h->h_next = NULL;
- if (inhere == 0)
- inhere = h;
- else
- for (lh = inhere; lh!=NULL; lh = lh->h_next)
- if (lh->h_next == 0) {
- lh->h_next = h;
- break;
- }
- iop->io_flag |= IOHERE|IOXHERE;
- for (s = h->h_tag; *s; s++)
- if (*s & QUOTE) {
- iop->io_flag &= ~ IOXHERE;
- *s &= ~ QUOTE;
- }
- h->h_dosub = iop->io_flag & IOXHERE;
-}
-
-void
-gethere()
-{
- register struct here *h, *hp;
-
- /* Scan here files first leaving inhere list in place */
- for (hp = h = inhere; h != NULL; hp = h, h = h->h_next)
- readhere(&h->h_iop->io_name, h->h_tag, h->h_dosub? 0: '\'');
-
- /* Make inhere list active - keep list intact for scraphere */
- if (hp != NULL) {
- hp->h_next = acthere;
- acthere = inhere;
- inhere = NULL;
- }
-}
-
-static void
-readhere(name, s, ec)
-char **name;
-register char *s;
-int ec;
-{
- int tf;
- char tname[30];
- register c;
- jmp_buf ev;
- char line [LINELIM+1];
- char *next;
-
- tempname(tname);
- *name = strsave(tname, areanum);
- tf = creat(tname, 0600);
- if (tf < 0)
- return;
- if (newenv(setjmp(errpt = ev)) != 0)
- unlink(tname);
- else {
- pushio(e.iop->argp, e.iop->iofn);
- e.iobase = e.iop;
- for (;;) {
- if (talking && e.iop <= iostack)
- prs(cprompt->value);
- next = line;
- while ((c = getc(ec)) != '\n' && c) {
- if (ec == '\'')
- c &= ~ QUOTE;
- if (next >= &line[LINELIM]) {
- c = 0;
- break;
- }
- *next++ = c;
- }
- *next = 0;
- if (strcmp(s, line) == 0 || c == 0)
- break;
- *next++ = '\n';
- write (tf, line, (int)(next-line));
- }
- if (c == 0) {
- prs("here document `"); prs(s); err("' unclosed");
- }
- quitenv();
- }
- close(tf);
-}
-
-/*
- * open here temp file.
- * if unquoted here, expand here temp file into second temp file.
- */
-int
-herein(hname, xdoll)
-char *hname;
-int xdoll;
-{
- register hf, tf;
-
- if (hname == 0)
- return(-1);
- hf = open(hname, 0);
- if (hf < 0)
- return (-1);
- if (xdoll) {
- char c;
- char tname[30];
- jmp_buf ev;
-
- tempname(tname);
- if ((tf = creat(tname, 0600)) < 0)
- return (-1);
- if (newenv(setjmp(errpt = ev)) == 0) {
- PUSHIO(afile, hf, herechar);
- setbase(e.iop);
- while ((c = subgetc(0, 0)) != 0) {
- c &= ~ QUOTE;
- write(tf, &c, sizeof c);
- }
- quitenv();
- } else
- unlink(tname);
- close(tf);
- tf = open(tname, 0);
- unlink(tname);
- return (tf);
- } else
- return (hf);
-}
-
-void
-scraphere()
-{
- register struct here *h;
-
- for (h = inhere; h != NULL; h = h->h_next) {
- if (h->h_iop && h->h_iop->io_name)
- unlink(h->h_iop->io_name);
- }
- inhere = NULL;
-}
-
-/* unlink here temp files before a freearea(area) */
-void
-freehere(area)
-int area;
-{
- register struct here *h, *hl;
-
- hl = NULL;
- for (h = acthere; h != NULL; h = h->h_next)
- if (getarea((char *) h) >= area) {
- if (h->h_iop->io_name != NULL)
- unlink(h->h_iop->io_name);
- if (hl == NULL)
- acthere = h->h_next;
- else
- hl->h_next = h->h_next;
- } else
- hl = h;
-}
-
-void
-tempname(tname)
-char *tname;
-{
- static int inc;
- register char *cp, *lp;
-
- for (cp = tname, lp = "/tmp/shtm"; (*cp = *lp++) != '\0'; cp++)
- ;
- lp = putn(getpid()*1000 + inc++);
- for (; (*cp = *lp++) != '\0'; cp++)
- ;
-}
diff --git a/release/picobsd/tinyware/msh/sh6.c b/release/picobsd/tinyware/msh/sh6.c
deleted file mode 100644
index bd3ba05aeab3..000000000000
--- a/release/picobsd/tinyware/msh/sh6.c
+++ /dev/null
@@ -1,9 +0,0 @@
-#define Extern
-
-#include <sys/types.h>
-#include <signal.h>
-#define _NSIG NSIG
-#include <errno.h>
-#include <setjmp.h>
-#include "sh.h"
-
diff --git a/release/picobsd/tinyware/ns/Makefile b/release/picobsd/tinyware/ns/Makefile
deleted file mode 100644
index bf8a27096c77..000000000000
--- a/release/picobsd/tinyware/ns/Makefile
+++ /dev/null
@@ -1,9 +0,0 @@
-# $FreeBSD$
-
-PROG= ns
-SRCS= ns.c
-
-CFLAGS+= -DBRIDGING
-MAN=
-
-.include <bsd.prog.mk>
diff --git a/release/picobsd/tinyware/ns/README b/release/picobsd/tinyware/ns/README
deleted file mode 100644
index 8d5f50358415..000000000000
--- a/release/picobsd/tinyware/ns/README
+++ /dev/null
@@ -1,43 +0,0 @@
-Warsaw, 1998.07.20
-
- Small replacement for netstat
- -----------------------------
-
-This program implements some basic functionality subset of normal netstat -
-it can display the routing table and protocol statistics.
-
-Large part of the code dealing with retrieving the routing table via sysctl(3)
-was taken from code examples written by Richard Stevens to accompany his
-excellent book.
-
-Usage
------
-
- ns [-rsi] [-p proto] [-w wait]
-
-where
-
- -r print routing table (default)
- -s print protocol statistics
- -i print interface statistics
- -p proto display only statistics related to this
- protocol, where 'proto' is one of:
- - ip
- - tcp
- - udp
- - icmp
- - bdg - bridging stats, if 'ns' was compiled with
- bridging support (flag BRIDGING in Makefile)
- -w wait continuous display, repeat every 'wait' seconds.
-
-Bugs
-----
-
-* 'ns' doesn't resolve IP addresses to names
-* well, real netstat provides _much_ more information... but this one needs
- to be small, right? :-)
-
-Andrzej Bialecki
-<abial@freebsd.org>
-
-$FreeBSD$
diff --git a/release/picobsd/tinyware/ns/ns.c b/release/picobsd/tinyware/ns/ns.c
deleted file mode 100644
index ac8e6fa28e41..000000000000
--- a/release/picobsd/tinyware/ns/ns.c
+++ /dev/null
@@ -1,831 +0,0 @@
-/*-
- * Copyright (c) 1998 Andrzej Bialecki
- * 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.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-
-
-/*
- * Small replacement for netstat. Uses only sysctl(3) to get the info.
- */
-
-#include <sys/types.h>
-#include <sys/time.h>
-#include <sys/sysctl.h>
-#include <sys/socket.h>
-#include <sys/un.h>
-
-#include <net/if.h>
-#include <net/route.h>
-#include <net/if_dl.h>
-#include <netinet/in_systm.h>
-#include <netinet/in.h>
-#include <netinet/ip.h>
-#include <netinet/ip_icmp.h>
-#include <netinet/icmp_var.h>
-#include <netinet/ip_var.h>
-#include <netinet/tcp.h>
-#include <netinet/tcp_timer.h>
-#include <netinet/tcp_var.h>
-#include <netinet/udp.h>
-#include <netinet/udp_var.h>
-#include <arpa/inet.h>
-
-#include <err.h>
-#include <errno.h>
-#include <osreldate.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-
-char *progname;
-int iflag = 0;
-int lflag = 0; /* print cpu load info */
-int rflag = 0;
-int sflag = 0;
-int pflag = 0;
-int wflag = 0; /* repeat every wait seconds */
-int delta = 0 ;
-
-extern char *optarg;
-extern int optind;
-
-void print_load_stats(void);
-
-void
-usage()
-{
- fprintf(stderr, "\n%s [-nrsil] [-p proto] [-w wait]\n", progname);
- fprintf(stderr, " proto: {ip|tcp|udp|icmp}\n\n");
-}
-
-
-/*
- * The following parts related to retrieving the routing table and
- * interface information, were borrowed from R. Stevens' code examples
- * accompanying his excellent book. Thanks!
- */
-char *
-sock_ntop(const struct sockaddr *sa, size_t salen)
-{
- char portstr[7];
- static char str[128]; /* Unix domain is largest */
-
- switch (sa->sa_family) {
- case 255: {
- int i = 0;
- u_long mask;
- u_int index = 1 << 31;
- u_short new_mask = 0;
-
- mask = ntohl(((struct sockaddr_in *)sa)->sin_addr.s_addr);
-
- while (mask & index) {
- new_mask++;
- index >>= 1;
- }
- sprintf(str, "/%hu", new_mask);
- return (str);
- }
- case AF_UNSPEC:
- case AF_INET: {
- struct sockaddr_in *sin = (struct sockaddr_in *)sa;
-
- if (inet_ntop(AF_INET, &sin->sin_addr, str, sizeof(str))
- == NULL)
- return (NULL);
- if (ntohs(sin->sin_port) != 0) {
- snprintf(portstr, sizeof(portstr), ".%d",
- ntohs(sin->sin_port));
- strcat(str, portstr);
- }
- if (strcmp(str, "0.0.0.0") == 0)
- sprintf(str, "default");
- return (str);
- }
-
- case AF_UNIX: {
- struct sockaddr_un *unp = (struct sockaddr_un *)sa;
-
- /*
- * OK to have no pathname bound to the socket:
- * happens on every connect() unless client calls
- * bind() first.
- */
- if (unp->sun_path[0] == 0)
- strcpy(str, "(no pathname bound)");
- else
- snprintf(str, sizeof(str), "%s", unp->sun_path);
- return (str);
- }
-
- case AF_LINK: {
- struct sockaddr_dl *sdl = (struct sockaddr_dl *)sa;
-
- if (sdl->sdl_nlen > 0) {
- bcopy(&sdl->sdl_data[0], str, sdl->sdl_nlen);
- str[sdl->sdl_nlen] = '\0';
- } else
- snprintf(str, sizeof(str), "link#%d", sdl->sdl_index);
- return (str);
- }
-
- default:
- snprintf(str, sizeof(str),
- "sock_ntop: unknown AF_xxx: %d, len %d", sa->sa_family,
- salen);
- return (str);
- }
- return (NULL);
-}
-
-char *
-Sock_ntop(const struct sockaddr *sa, size_t salen)
-{
- char *ptr;
-
- if ((ptr = sock_ntop(sa, salen)) == NULL)
- err(1, "sock_ntop error"); /* inet_ntop() sets errno */
- return (ptr);
-}
-
-
-#define ROUNDUP(a,size) (((a) & ((size)-1))?(1+((a)|((size)-1))):(a))
-
-#define NEXT_SA(ap) \
- ap=(struct sockaddr *) \
- ((caddr_t)ap+(ap->sa_len?ROUNDUP(ap->sa_len,sizeof(u_long)):\
- sizeof(u_long)))
-
-void
-get_rtaddrs(int addrs, struct sockaddr *sa, struct sockaddr **rti_info)
-{
- int i;
-
- for (i = 0; i < RTAX_MAX; i++) {
- if (addrs & (1 << i)) {
- rti_info[i] = sa;
- NEXT_SA(sa);
- } else
- rti_info[i] = NULL;
- }
-}
-
-void
-get_flags(char *buf, int flags)
-{
- if (flags & 0x1)
- strcat(buf, "U");
- if (flags & 0x2)
- strcat(buf, "G");
- if (flags & 0x4)
- strcat(buf, "H");
- if (flags & 0x8)
- strcat(buf, "r");
- if (flags & 0x10)
- strcat(buf, "d");
-#ifdef NEVER
- if (flags & 0x20)
- strcat(buf, "mod,");
-#endif /*NEVER*/
- if (flags & 0x100)
- strcat(buf, "C");
- if (flags & 0x400)
- strcat(buf, "L");
- if (flags & 0x800)
- strcat(buf, "S");
- if (flags & 0x10000)
- strcat(buf, "c");
- if (flags & 0x20000)
- strcat(buf, "W");
-#ifdef NEVER
- if (flags & 0x200000)
- strcat(buf, ",LOC");
-#endif /*NEVER*/
- if (flags & 0x400000)
- strcat(buf, "b");
-#ifdef NEVER
- if (flags & 0x800000)
- strcat(buf, ",MCA");
-#endif /*NEVER*/
-}
-
-void
-print_routing(char *proto)
-{
- int mib[6];
- int i = 0;
- int rt_len;
- int if_len;
- int if_num;
- char *rt_buf;
- char *if_buf;
- char *next;
- char *lim;
- struct rt_msghdr *rtm;
- struct if_msghdr *ifm;
- struct if_msghdr **ifm_table;
- struct ifa_msghdr *ifam;
- struct sockaddr *sa;
- struct sockaddr *sa1;
- struct sockaddr *rti_info[RTAX_MAX];
- struct sockaddr **if_table;
- struct rt_metrics rm;
- char fbuf[50];
-
- /* keep a copy of statistics here for future use */
- static unsigned *base_stats = NULL ;
- static unsigned base_len = 0 ;
-
- /* Get the routing table */
- mib[0] = CTL_NET;
- mib[1] = PF_ROUTE;
- mib[2] = 0;
- mib[3] = 0;
- mib[4] = NET_RT_DUMP;
- mib[5] = 0;
-
- /*Estimate the size of table */
- if (sysctl(mib, 6, NULL, &rt_len, NULL, 0) == -1) {
- perror("sysctl size");
- exit(-1);
- }
- if ((rt_buf = (char *)malloc(rt_len)) == NULL) {
- perror("malloc");
- exit(-1);
- }
-
- /* Now get it. */
- if (sysctl(mib, 6, rt_buf, &rt_len, NULL, 0) == -1) {
- perror("sysctl get");
- exit(-1);
- }
-
- /* Get the interfaces table */
- mib[0] = CTL_NET;
- mib[1] = PF_ROUTE;
- mib[2] = 0;
- mib[3] = 0;
- mib[4] = NET_RT_IFLIST;
- mib[5] = 0;
-
- /* Estimate the size of table */
- if (sysctl(mib, 6, NULL, &if_len, NULL, 0) == -1) {
- perror("sysctl size");
- exit(-1);
- }
- if ((if_buf = (char *)malloc(if_len)) == NULL) {
- perror("malloc");
- exit(-1);
- }
-
- /* Now get it. */
- if (sysctl(mib, 6, if_buf, &if_len, NULL, 0) == -1) {
- perror("sysctl get");
- exit(-1);
- }
- lim = if_buf + if_len;
- i = 0;
- for (next = if_buf, i = 0; next < lim; next += ifm->ifm_msglen) {
- ifm = (struct if_msghdr *)next;
- i++;
- }
- if_num = i;
- if_table = (struct sockaddr **)calloc(i, sizeof(struct sockaddr));
- ifm_table = (struct if_msghdr **)calloc(i, sizeof(struct if_msghdr));
- if (iflag) {
- printf("\nInterface table:\n");
- printf("----------------\n");
- printf("Name Mtu Network Address "
- "Ipkts Ierrs Opkts Oerrs Coll\n");
- }
- /* scan the list and store base values */
- i = 0 ;
- for (next = if_buf; next < lim; next += ifm->ifm_msglen) {
- ifm = (struct if_msghdr *)next;
- i++ ;
- }
- if (base_stats == NULL || i != base_len) {
- base_stats = calloc(i*5, sizeof(unsigned));
- base_len = i ;
- }
- i = 0;
- for (next = if_buf; next < lim; next += ifm->ifm_msglen) {
- ifm = (struct if_msghdr *)next;
- if_table[i] = (struct sockaddr *)(ifm + 1);
- ifm_table[i] = ifm;
-
- sa = if_table[i];
- if (iflag && sa->sa_family == AF_LINK) {
- struct sockaddr_dl *sdl = (struct sockaddr_dl *)sa;
- unsigned *bp = &base_stats[i*5];
-
- printf("%-4s %-5d <Link> ",
- sock_ntop(if_table[i], if_table[i]->sa_len),
- ifm->ifm_data.ifi_mtu);
- if (sdl->sdl_alen == 6) {
- unsigned char *p =
- sdl->sdl_data + sdl->sdl_nlen;
- printf("%02x:%02x:%02x:%02x:%02x:%02x ",
- p[0], p[1], p[2], p[3], p[4], p[5]);
- } else
- printf(" ");
- printf("%9d%6d%9d%6d%6d\n",
- ifm->ifm_data.ifi_ipackets - bp[0],
- ifm->ifm_data.ifi_ierrors - bp[1],
- ifm->ifm_data.ifi_opackets - bp[2],
- ifm->ifm_data.ifi_oerrors - bp[3],
- ifm->ifm_data.ifi_collisions -bp[4]);
- if (delta > 0) {
- bp[0] = ifm->ifm_data.ifi_ipackets ;
- bp[1] = ifm->ifm_data.ifi_ierrors ;
- bp[2] = ifm->ifm_data.ifi_opackets ;
- bp[3] = ifm->ifm_data.ifi_oerrors ;
- bp[4] = ifm->ifm_data.ifi_collisions ;
- }
- }
- i++;
- }
- if (!rflag) {
- free(rt_buf);
- free(if_buf);
- free(if_table);
- free(ifm_table);
- return;
- }
-
- /* Now dump the routing table */
- printf("\nRouting table:\n");
- printf("--------------\n");
- printf
- ("Destination Gateway Flags Netif Use\n");
- lim = rt_buf + rt_len;
- for (next = rt_buf; next < lim; next += rtm->rtm_msglen) {
- rtm = (struct rt_msghdr *)next;
- sa = (struct sockaddr *)(rtm + 1);
- get_rtaddrs(rtm->rtm_addrs, sa, rti_info);
- if ((sa = rti_info[RTAX_DST]) != NULL) {
- sprintf(fbuf, "%s", sock_ntop(sa, sa->sa_len));
- if (((sa1 = rti_info[RTAX_NETMASK]) != NULL)
- && sa1->sa_family == 255) {
- strcat(fbuf, sock_ntop(sa1, sa1->sa_len));
- }
- printf("%-19s", fbuf);
- }
- if ((sa = rti_info[RTAX_GATEWAY]) != NULL) {
- printf("%-19s", sock_ntop(sa, sa->sa_len));
- }
- memset(fbuf, 0, sizeof(fbuf));
- get_flags(fbuf, rtm->rtm_flags);
- printf("%-10s", fbuf);
- for (i = 0; i < if_num; i++) {
- ifm = ifm_table[i];
- if ((ifm->ifm_index == rtm->rtm_index) &&
- (ifm->ifm_data.ifi_type > 0)) {
- sa = if_table[i];
- break;
- }
- }
- if (ifm->ifm_type == RTM_IFINFO) {
- get_rtaddrs(ifm->ifm_addrs, sa, rti_info);
- printf(" %s", Sock_ntop(sa, sa->sa_len));
- } else if (ifm->ifm_type == RTM_NEWADDR) {
- ifam =
- (struct ifa_msghdr *)ifm_table[rtm->rtm_index - 1];
- sa = (struct sockaddr *)(ifam + 1);
- get_rtaddrs(ifam->ifam_addrs, sa, rti_info);
- printf(" %s", Sock_ntop(sa, sa->sa_len));
- }
- /* printf(" %u", rtm->rtm_use); */
- printf("\n");
- }
- free(rt_buf);
- free(if_buf);
- free(if_table);
- free(ifm_table);
-}
-
-void
-print_ip_stats(void)
-{
- int mib[4];
- int len;
- struct ipstat s;
-
- mib[0] = CTL_NET;
- mib[1] = PF_INET;
- mib[2] = IPPROTO_IP;
-#ifndef IPCTL_STATS
- printf("sorry, ip stats not available\n");
- return -1;
-#else
- mib[3] = IPCTL_STATS;
- len = sizeof(struct ipstat);
- if (sysctl(mib, 4, &s, &len, NULL, 0) < 0) {
- perror("sysctl");
- return;
- }
- printf("\nIP statistics:\n");
- printf("--------------\n");
- printf(" %10lu total packets received\n", s.ips_total);
- printf("* Packets ok:\n");
- printf(" %10lu fragments received\n", s.ips_fragments);
- printf(" %10lu forwarded\n", s.ips_forward);
-#if __FreeBSD_version > 300001
- printf(" %10lu fast forwarded\n", s.ips_fastforward);
-#endif
- printf(" %10lu forwarded on same net (redirect)\n",
- s.ips_redirectsent);
- printf(" %10lu delivered to upper level\n", s.ips_delivered);
- printf(" %10lu total ip packets generated here\n", s.ips_localout);
- printf(" %10lu total packets reassembled ok\n", s.ips_reassembled);
- printf(" %10lu total datagrams successfully fragmented\n",
- s.ips_fragmented);
- printf(" %10lu output fragments created\n", s.ips_ofragments);
- printf(" %10lu total raw IP packets generated\n", s.ips_rawout);
- printf("\n* Bad packets:\n");
- printf(" %10lu bad checksum\n", s.ips_badsum);
- printf(" %10lu too short\n", s.ips_tooshort);
- printf(" %10lu not enough data (too small)\n", s.ips_toosmall);
- printf(" %10lu more data than declared in header\n", s.ips_badhlen);
- printf(" %10lu less data than declared in header\n", s.ips_badlen);
- printf(" %10lu fragments dropped (dups, no mbuf)\n",
- s.ips_fragdropped);
- printf(" %10lu fragments timed out in reassembly\n",
- s.ips_fragtimeout);
- printf(" %10lu received for unreachable dest.\n", s.ips_cantforward);
- printf(" %10lu unknown or unsupported protocol\n", s.ips_noproto);
- printf(" %10lu lost due to no bufs etc.\n", s.ips_odropped);
- printf(" %10lu couldn't fragment (DF set, etc.)\n", s.ips_cantfrag);
- printf(" %10lu error in IP options processing\n", s.ips_badoptions);
- printf(" %10lu dropped due to no route\n", s.ips_noroute);
- printf(" %10lu bad IP version\n", s.ips_badvers);
- printf(" %10lu too long (more than max IP size)\n", s.ips_toolong);
-#if __FreeBSD_version > 300001
- printf(" %10lu multicast for unregistered groups\n", s.ips_notmember);
-#endif
-#endif
-}
-
-void
-print_tcp_stats(void)
-{
- int mib[4];
- int len;
- struct tcpstat s;
-
- mib[0] = CTL_NET;
- mib[1] = PF_INET;
- mib[2] = IPPROTO_TCP;
-#ifndef TCPCTL_STATS
- printf("sorry, tcp stats not available\n");
- return;
-#else
- mib[3] = TCPCTL_STATS;
- len = sizeof(struct tcpstat);
- if (sysctl(mib, 4, &s, &len, NULL, 0) < 0) {
- perror("sysctl");
- return;
- }
- printf("\nTCP statistics:\n");
- printf("---------------\n");
- printf("* Connections:\n");
- printf(" %10lu initiated\n", s.tcps_connattempt);
- printf(" %10lu accepted\n", s.tcps_accepts);
- printf(" %10lu established\n", s.tcps_connects);
- printf(" %10lu dropped\n", s.tcps_drops);
- printf(" %10lu embryonic connections dropped\n", s.tcps_conndrops);
- printf(" %10lu closed (includes dropped)\n", s.tcps_closed);
- printf(" %10lu segments where we tried to get RTT\n",
- s.tcps_segstimed);
- printf(" %10lu times RTT successfully updated\n", s.tcps_rttupdated);
- printf(" %10lu delayed ACKs sent\n", s.tcps_delack);
- printf(" %10lu dropped in rxmt timeout\n", s.tcps_timeoutdrop);
- printf(" %10lu retrasmit timeouts\n", s.tcps_rexmttimeo);
- printf(" %10lu persist timeouts\n", s.tcps_persisttimeo);
- printf(" %10lu keepalive timeouts\n", s.tcps_keeptimeo);
- printf(" %10lu keepalive probes sent\n", s.tcps_keepprobe);
- printf(" %10lu dropped in keepalive\n", s.tcps_keepdrops);
-
- printf("* Packets sent:\n");
- printf(" %10lu total packets sent\n", s.tcps_sndtotal);
- printf(" %10lu data packets sent\n", s.tcps_sndpack);
- printf(" %10lu data bytes sent\n", s.tcps_sndbyte);
- printf(" %10lu data packets retransmitted\n", s.tcps_sndrexmitpack);
- printf(" %10lu data bytes retransmitted\n", s.tcps_sndrexmitbyte);
- printf(" %10lu ACK-only packets sent\n", s.tcps_sndacks);
- printf(" %10lu window probes sent\n", s.tcps_sndprobe);
- printf(" %10lu URG-only packets sent\n", s.tcps_sndurg);
- printf(" %10lu window update-only packets sent\n", s.tcps_sndwinup);
- printf(" %10lu control (SYN,FIN,RST) packets sent\n", s.tcps_sndctrl);
- printf("* Packets received:\n");
- printf(" %10lu total packets received\n", s.tcps_rcvtotal);
- printf(" %10lu packets in sequence\n", s.tcps_rcvpack);
- printf(" %10lu bytes in sequence\n", s.tcps_rcvbyte);
- printf(" %10lu packets with bad checksum\n", s.tcps_rcvbadsum);
- printf(" %10lu packets with bad offset\n", s.tcps_rcvbadoff);
- printf(" %10lu packets too short\n", s.tcps_rcvshort);
- printf(" %10lu duplicate-only packets\n", s.tcps_rcvduppack);
- printf(" %10lu duplicate-only bytes\n", s.tcps_rcvdupbyte);
- printf(" %10lu packets with some duplicate data\n",
- s.tcps_rcvpartduppack);
- printf(" %10lu duplicate bytes in partially dup. packets\n",
- s.tcps_rcvpartdupbyte);
- printf(" %10lu out-of-order packets\n", s.tcps_rcvoopack);
- printf(" %10lu out-of-order bytes\n", s.tcps_rcvoobyte);
- printf(" %10lu packets with data after window\n",
- s.tcps_rcvpackafterwin);
- printf(" %10lu bytes received after window\n",
- s.tcps_rcvbyteafterwin);
- printf(" %10lu packets received after 'close'\n",
- s.tcps_rcvafterclose);
- printf(" %10lu window probe packets\n", s.tcps_rcvwinprobe);
- printf(" %10lu duplicate ACKs\n", s.tcps_rcvdupack);
- printf(" %10lu ACKs for unsent data\n", s.tcps_rcvacktoomuch);
- printf(" %10lu ACK packets\n", s.tcps_rcvackpack);
- printf(" %10lu bytes ACKed by received ACKs\n", s.tcps_rcvackbyte);
- printf(" %10lu window update packets\n", s.tcps_rcvwinupd);
- printf(" %10lu segments dropped due to PAWS\n", s.tcps_pawsdrop);
- printf(" %10lu times header predict ok for ACKs\n", s.tcps_predack);
- printf(" %10lu times header predict ok for data packets\n",
- s.tcps_preddat);
- printf(" %10lu PCB cache misses\n", s.tcps_pcbcachemiss);
- printf(" %10lu times cached RTT in route updated\n",
- s.tcps_cachedrtt);
- printf(" %10lu times cached RTTVAR updated\n", s.tcps_cachedrttvar);
- printf(" %10lu times ssthresh updated\n", s.tcps_cachedssthresh);
- printf(" %10lu times RTT initialized from route\n", s.tcps_usedrtt);
- printf(" %10lu times RTTVAR initialized from route\n",
- s.tcps_usedrttvar);
- printf(" %10lu times ssthresh initialized from route\n",
- s.tcps_usedssthresh);
- printf(" %10lu timeout in persist state\n", s.tcps_persistdrop);
- printf(" %10lu bogus SYN, e.g. premature ACK\n", s.tcps_badsyn);
- printf(" %10lu resends due to MTU discovery\n", s.tcps_mturesent);
- printf(" %10lu listen queue overflows\n", s.tcps_listendrop);
-#endif
-}
-
-void
-print_udp_stats(void)
-{
- int mib[4];
- int len;
- struct udpstat s;
-
- mib[0] = CTL_NET;
- mib[1] = PF_INET;
- mib[2] = IPPROTO_UDP;
- mib[3] = UDPCTL_STATS;
- len = sizeof(struct udpstat);
- if (sysctl(mib, 4, &s, &len, NULL, 0) < 0) {
- perror("sysctl");
- return;
- }
- printf("\nUDP statistics:\n");
- printf("---------------\n");
- printf("* Packets received:\n");
- printf(" %10lu total input packets\n", s.udps_ipackets);
- printf(" %10lu packets shorter than header (dropped)\n",
- s.udps_hdrops);
- printf(" %10lu bad checksum\n", s.udps_badsum);
- printf(" %10lu data length larger than packet\n", s.udps_badlen);
- printf(" %10lu no socket on specified port\n", s.udps_noport);
- printf(" %10lu of above, arrived as broadcast\n", s.udps_noportbcast);
- printf(" %10lu not delivered, input socket full\n", s.udps_fullsock);
- printf(" %10lu packets missing PCB cache\n", s.udpps_pcbcachemiss);
- printf(" %10lu packets not for hashed PCBs\n", s.udpps_pcbhashmiss);
- printf("* Packets sent:\n");
- printf(" %10lu total output packets\n", s.udps_opackets);
-#if __FreeBSD_version > 300001
- printf(" %10lu output packets on fast path\n", s.udps_fastout);
-#endif
-}
-
-char *icmp_names[] = {
- "echo reply",
- "#1",
- "#2",
- "destination unreachable",
- "source quench",
- "routing redirect",
- "#6",
- "#7",
- "echo",
- "router advertisement",
- "router solicitation",
- "time exceeded",
- "parameter problem",
- "time stamp",
- "time stamp reply",
- "information request",
- "information request reply",
- "address mask request",
- "address mask reply",
-};
-
-print_icmp_stats()
-{
- int mib[4];
- int len;
- int i;
- struct icmpstat s;
-
- mib[0] = CTL_NET;
- mib[1] = PF_INET;
- mib[2] = IPPROTO_ICMP;
- mib[3] = ICMPCTL_STATS;
- len = sizeof(struct icmpstat);
- if (sysctl(mib, 4, &s, &len, NULL, 0) < 0) {
- perror("sysctl");
- return (-1);
- }
- printf("\nICMP statistics:\n");
- printf("----------------\n");
- printf("* Output histogram:\n");
- for (i = 0; i < (ICMP_MAXTYPE + 1); i++) {
- if (s.icps_outhist[i] > 0)
- printf("\t%10lu %s\n",
- s.icps_outhist[i], icmp_names[i]);
- }
- printf("* Input histogram:\n");
- for (i = 0; i < (ICMP_MAXTYPE + 1); i++) {
- if (s.icps_inhist[i] > 0)
- printf("\t%10lu %s\n",
- s.icps_inhist[i], icmp_names[i]);
- }
- printf("* Other stats:\n");
- printf(" %10lu calls to icmp_error\n", s.icps_error);
- printf(" %10lu no error 'cuz old ip too short\n", s.icps_oldshort);
- printf(" %10lu no error 'cuz old was icmp\n", s.icps_oldicmp);
-
- printf(" %10lu icmp code out of range\n", s.icps_badcode);
- printf(" %10lu packets shorter than min length\n", s.icps_tooshort);
- printf(" %10lu bad checksum\n", s.icps_checksum);
- printf(" %10lu calculated bound mismatch\n", s.icps_badlen);
- printf(" %10lu number of responses\n", s.icps_reflect);
- printf(" %10lu broad/multi-cast echo requests dropped\n",
- s.icps_bmcastecho);
- printf(" %10lu broad/multi-cast timestamp requests dropped\n",
- s.icps_bmcasttstamp);
-}
-
-int
-stats(char *proto)
-{
- if (!sflag)
- return 0;
- if (pflag) {
- if (proto == NULL) {
- fprintf(stderr, "Option '-p' requires parameter.\n");
- usage();
- exit(-1);
- }
- if (strcmp(proto, "ip") == 0)
- print_ip_stats();
- if (strcmp(proto, "icmp") == 0)
- print_icmp_stats();
- if (strcmp(proto, "udp") == 0)
- print_udp_stats();
- if (strcmp(proto, "tcp") == 0)
- print_tcp_stats();
- return (0);
- }
- print_ip_stats();
- print_icmp_stats();
- print_udp_stats();
- print_tcp_stats();
- return (0);
-}
-
-int
-main(int argc, char *argv[])
-{
- char c;
- char *proto = NULL;
-
- progname = argv[0];
-
- while ((c = getopt(argc, argv, "dilnrsp:w:")) != -1) {
- switch (c) {
- case 'd': /* print deltas in stats every w seconds */
- delta++ ;
- break;
- case 'w':
- wflag = atoi(optarg);
- break;
- case 'n': /* ignored, just for compatibility with std netstat */
- break;
- case 'r':
- rflag++;
- break;
- case 'i':
- iflag++;
- break;
- case 'l':
- lflag++;
- break;
- case 's':
- sflag++;
- rflag = 0;
- break;
- case 'p':
- pflag++;
- sflag++;
- proto = optarg;
- break;
- case '?':
- default:
- usage();
- exit(0);
- break;
- }
- }
- if (rflag == 0 && sflag == 0 && iflag == 0)
- rflag = 1;
- argc -= optind;
-
- if (argc > 0) {
- usage();
- exit(-1);
- }
- if (wflag)
- printf("\033[H\033[J");
-again:
- if (wflag) {
- struct timeval t;
-
- gettimeofday(&t, NULL);
- printf("\033[H%s", ctime(&t.tv_sec));
- }
- print_routing(proto);
- print_load_stats();
- stats(proto);
- if (wflag) {
- sleep(wflag);
- goto again;
- }
- exit(0);
-}
-
-void
-print_load_stats(void)
-{
- static u_int32_t cp_time[5];
- u_int32_t new_cp_time[5];
- int l;
- int shz;
- static int stathz ;
-
- if (!lflag || !wflag)
- return;
- l = sizeof(new_cp_time) ;
- bzero(new_cp_time, l);
- if (sysctlbyname("kern.cp_time", new_cp_time, &l, NULL, 0) < 0) {
- warn("sysctl: retrieving cp_time length");
- return;
- }
- if (stathz == 0) {
- struct clockinfo ci;
-
- bzero (&ci, sizeof(ci));
- l = sizeof(ci) ;
- if (sysctlbyname("kern.clockrate", &ci, &l, NULL, 0) < 0) {
- warn("sysctl: retrieving clockinfo length");
- return;
- }
- stathz = ci.stathz ;
- bcopy(new_cp_time, cp_time, sizeof(cp_time));
- }
- shz = stathz * wflag ;
- if (shz == 0)
- shz = 1;
-#define X(i) ( (double)(new_cp_time[i] - cp_time[i])*100/shz )
- printf("\nUSER %5.2f%% NICE %5.2f%% SYS %5.2f%% "
- "INTR %5.2f%% IDLE %5.2f%%\n",
- X(0), X(1), X(2), X(3), X(4) );
- bcopy(new_cp_time, cp_time, sizeof(cp_time));
-}
diff --git a/release/picobsd/tinyware/oinit/Makefile b/release/picobsd/tinyware/oinit/Makefile
deleted file mode 100644
index 072bbba8a840..000000000000
--- a/release/picobsd/tinyware/oinit/Makefile
+++ /dev/null
@@ -1,22 +0,0 @@
-# $FreeBSD$
-#
-PROG= oinit
-
-SH_PATH?= /bin/sh
-SH_NAME?= -sh
-SH_ARG?= /etc/rc
-
-CFLAGS= -DSH_PATH=\"${SH_PATH}\" -DSH_NAME=\"${SH_NAME}\" \
- -DSH_ARG=\"${SH_ARG}\"
-
-
-#CFLAGS+= -DUSE_HISTORY
-#CFLAGS+= -DOINIT_RC=\"/etc/oinit.rc\"
-
-#LDADD= -lutil -ledit -ltermcap
-LIBADD= util
-MAN=
-
-.include <bsd.prog.mk>
-
-
diff --git a/release/picobsd/tinyware/oinit/README b/release/picobsd/tinyware/oinit/README
deleted file mode 100644
index e34c404f4a8d..000000000000
--- a/release/picobsd/tinyware/oinit/README
+++ /dev/null
@@ -1,123 +0,0 @@
-Warsaw, 1998.07.07
-
-This README shortly describes the features of "oinit" - a very simplistic
-version of init(8) combined with a shell.
-
-Features
---------
-
-* oinit is able to run system in multi- and single-user modes,
-* it can be started on system with DEVFS/SLICE (i.e. empty /dev),
-* provides minimalistic user interface, called "shell()",
-* it can run the system startup script (/etc/rc),
-* it can be compiled with -DOINIT_RC to use its own startup script
- (*very* primitive, but doesn't require any real shell to run it!),
-* doesn't require the whole chain of init->getty->login->shell to be run,
-* it is extremely small, and is ideally suited for situations when
- there is little memory.
-
-As an additional bonus you receive some obvious and some hidden bugs... :-))
-This code is at most alpha quality yet.
-
-
-How it works
-------------
-
-Unlike normal init(8), it forks itself on given number of vty's immediately
-providing shell() interface. Currently it doesn't require (and is unable to
-perform) any authentication, but this is easy to add if needed.
-
-Standard version of FreeBSD kernel looks for /sbin/init first, and then
-tries to execute it. If it fails, it tries to find:
- /sbin/oinit
- /sbin/init.bak
- /stand/sysinstall
-
-So it is easy to make use of it even on standard system - just put it in
-/sbin/oinit and rename /sbin/init to something else, e.g. /sbin/init.bak.
-
-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
-!!! WARNING !!! WARNING !!! WARNING !!! WARNING !!! WARNING !!! WARNING !!!
-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
-Init (or oinit) plays crucial role in the system. If you plan to do any
-changes to your system's init, make sure you have a boot floppy with working
-version of statically compiled init(8) on it - you can very easily put your
-system in unusable state when fiddling with it.
-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
-
-Shell() interface
------------------
-
-It allows you to issue built-in and external commands. Built-in commands
-are listed below. For each command there is short help available, with
-example of usage.
-
- cd change working directory
- pwd print working directory
- set set environment variable (no expansion)
- unset unset environment variable
- env print all environment variables
- echo echo arguments on stdout
- exit exit from shell (oinit will start a new one after some delay)
- . source-in a file with commands
- ? help
-
-Any other command is passed to execvp(3) as it is.
-
-EXCEPTION: if you end the command line with a '&', the command is started
-as daemon. This is NOT the same as in normal shell, where the '&' puts a
-process in background. Here the newly started process is totally dissociated
-from terminal.
-
-Prompt tells you:
-* your `pwd`
-* your PID
-* and that you are root ('#').
-
-WARNING: this pseudo-shell doesn't do any expansion whatsoever.
-
-To do list
-----------
-
-- oinit proper:
- * fix signal handling and transitions,
- * invent a one-file configuration database (combining as many files
- from /etc as possible into one) able to properly handle inter-
- dependencies in running various daemons,
- * allow for interpreting of such database, and running various
- programs ourselves (this would eventually allow to make /bin/sh
- an option, not necessity),
- * better hooks for incorporating other modules into oinit (see e.g.
- the telnet() below),
- * add optional authentication,
-
-- shell():
- * more built-ins: perhaps 'kill' and 'ps',
- * variable expansion,
- * globbing,
- * conditionals,
- * history? (it depends on how much memory it needs).
- * programmatic hooks for easy customisation of user interface (like
- hierarchy of commands and contexts),
- * ...
-
-- implement as a routine (like shell()) a small remote login daemon telnet(),
- as a built-in module to oinit. It would implement the simplest options of
- normal telnet, and would itself handle authentication, passing control to
- shell() on success. The authentication routine would be the same as for
- checking console access.
-
-And allow me for a moment of day-dreaming: I'd like to rewrite oinit one day
-to be a monolithic one-in-all application, non-forking but multithreaded... It
-would contain all the modules, such as shell(), telnet(), ifconfig() etc...
-started as threads, not separate processes.
-
-Credits
--------
-
-The overall framework was taken from FreeBSD /sbin/init.
-
-Andrzej Bialecki
-<abial@freebsd.org>
-
-$FreeBSD$
diff --git a/release/picobsd/tinyware/oinit/oinit.c b/release/picobsd/tinyware/oinit/oinit.c
deleted file mode 100644
index 7715f3e67a5b..000000000000
--- a/release/picobsd/tinyware/oinit/oinit.c
+++ /dev/null
@@ -1,947 +0,0 @@
-/*-
- * Copyright (c) 1998 Andrzej Bialecki
- * 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.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-
-/*
- * A primitive version of init(8) with simplistic user interface
- */
-
-#include <sys/types.h>
-#include <sys/param.h>
-#include <sys/mount.h>
-#include <sys/reboot.h>
-#include <sys/time.h>
-#include <sys/resource.h>
-#include <sys/wait.h>
-#include <ctype.h>
-#include <err.h>
-
-#ifdef USE_HISTORY
-#error "Not yet. But it's quite simple to add - patches are welcome!"
-#endif
-
-#include <errno.h>
-#include <fcntl.h>
-#include <libutil.h>
-#include <paths.h>
-#include <setjmp.h>
-#include <signal.h>
-#include <stdio.h>
-#include <string.h>
-#include <syslog.h>
-#include <unistd.h>
-#include <varargs.h>
-
-#define BUFSIZE 1024
-#define MAX_CONS 12
-
-#define NONE 0
-#define SINGLE 1
-#define MULTI 2
-#define DEATH 3
-
-#define FALSE 0
-#define TRUE 1
-
-char cwd[BUFSIZE];
-char vty[]="0123456789abcdef";
-char *progname;
-char *motd=NULL;
-int ncons=MAX_CONS;
-int Reboot=FALSE;
-int transition=MULTI;
-int prevtrans=SINGLE;
-jmp_buf machine;
-
-char *trans[]={ "NONE", "SINGLE", "MULTI", "DEATH" };
-
-extern char **environ;
-
-/* Struct for holding session state */
-struct sess {
- char tty[16]; /* vty device path */
- pid_t pid; /* pid of process running on it */
- int (*func)(int argc, char **argv);
- /* internal function to run on it (after forking) */
-} ttys[MAX_CONS];
-
-/* Struct for built-in command */
-struct command {
- char *cmd; /* command name */
- char *descr; /* command description */
- char *usage; /* usage */
- char *example; /* example of usage */
- int (*func)(char *); /* callback function */
-};
-
-/* Prototypes */
-int cd(char *);
-int pwd(char *);
-int echo(char *);
-int xit(char *);
-int set(char *);
-int unset(char *);
-int env(char *);
-int help(char *);
-int sourcer(char *);
-void do_command(int shell, char *cmdline);
-void transition_handler(int);
-
-/* Table of built-in functions */
-struct command bltins[]={
- {"cd","Change working directory","cd [dir]","cd /etc",cd},
- {"pwd","Print current directory","pwd","pwd",pwd},
- {"exit","Exit from shell()","exit","exit",xit},
- {"set","Set environment variable","set [VAR=value]","set TERM=xterm",set},
- {"unset","Unset environment variable","unset VAR","unset EDITOR",unset},
- {"echo","Echo arguments on stdout","echo arg1 arg2 ...","echo Hello World!",echo},
- {"env","Print all environment variables","env","env",env},
- {".","Source-in a file with commands",". filename",". /etc/rc",sourcer},
- {"?","Print this help :-)","? [command]","? set",help},
- {NULL,NULL,NULL,NULL,NULL}
-};
-
-/*
- * Built-in 'cd <path>' handler
- */
-int
-cd(char *path)
-{
- if(chdir(path)) return(-1);
- getcwd(cwd,BUFSIZE);
- return(0);
-}
-
-/*
- * Built-in 'pwd' handler
- */
-int
-pwd(char *dummy)
-{
-
- if(getcwd(cwd,BUFSIZE)==NULL) return(-1);
- printf("%s\n",cwd);
- return(0);
-}
-
-/*
- * Built-in 'exit' handler
- */
-int
-xit(char *dummy)
-{
- _exit(0);
-}
-
-/*
- * Built-in 'echo' handler
- */
-int
-echo(char *args)
-{
- int i=0,j;
- int len;
- char c;
- int s_quote=0,d_quote=0;
- int sep=0,no_lf=0;
-
- if(args==NULL) {
- printf("\n");
- return;
- }
- len=strlen(args);
- if(len>=2) {
- if(args[0]=='-' && args[1]=='n') {
- no_lf++;
- i=2;
- while(i<len && (args[i]==' ' || args[i]=='\t')) i++;
- }
- }
- while(i<len) {
- c=args[i];
- switch(c) {
- case ' ':
- case '\t':
- if(s_quote||d_quote) {
- putchar(c);
- } else if(!sep) {
- putchar(' ');
- sep=1;
- }
- break;
- case '\\':
- i++;
- c=args[i];
- switch(c) {
- case 'n':
- putchar('\n');
- break;
- case 'b':
- putchar('\b');
- break;
- case 't':
- putchar('\t');
- break;
- case 'r':
- putchar('\r');
- break;
- default:
- putchar(c);
- break;
- }
- break;
- case '"':
- if(!d_quote) {
- d_quote=1;
- for(j=i+1;j<len;j++) {
- if(args[j]=='\\') {
- j++;
- continue;
- }
- if(args[j]=='"') {
- d_quote=2;
- break;
- }
- }
- if(d_quote!=2) {
- printf("\necho(): unmatched \"\n");
- return;
- }
- } else d_quote=0;
- break;
- case '\'':
- if(!s_quote) {
- s_quote=1;
- for(j=i+1;j<len;j++) {
- if(args[j]=='\\') {
- j++;
- continue;
- }
- if(args[j]=='\'') {
- s_quote=2;
- break;
- }
- }
- if(s_quote!=2) {
- printf("\necho(): unmatched '\n");
- return;
- }
- } else s_quote=0;
- break;
- case '`':
- printf("echo(): backquote not implemented yet!\n");
- break;
- default:
- sep=0;
- putchar(c);
- break;
- }
- i++;
- }
- if(!no_lf) putchar('\n');
- fflush(stdout);
-}
-
-/*
- * Built-in 'set VAR=value' handler
- */
-int
-set(char *var)
-{
- int res;
-
- if(var==NULL) return(env(NULL));
- res=putenv(var);
- if(res) printf("set: %s\n",strerror(errno));
- return(res);
-}
-
-/*
- * Built-in 'env' handler
- */
-int
-env(char *dummy)
-{
- char **e;
-
- e=environ;
- while(*e!=NULL) {
- printf("%s\n",*e++);
- }
- return(0);
-}
-
-/*
- * Built-in 'unset VAR' handler
- */
-int
-unset(char *var)
-{
- if(var==NULL) {
- printf("%s: parameter required.\n",progname);
- return(-1);
- }
- return(unsetenv(var));
-}
-
-/*
- * Built-in '?' handler
- */
-int
-help(char *cmd)
-{
- struct command *x;
- int found=0;
-
- if(cmd==NULL) {
- printf("\nBuilt-in commands:\n");
- printf("-------------------\n");
- x=bltins;
- while(x->cmd!=NULL) {
- printf("%s\t%s\n",x->cmd,x->descr);
- x++;
- }
- printf("\nEnter '? <cmd>' for details.\n\n");
- return(0);
- } else {
- x=bltins;
- while(x->cmd!=NULL) {
- if(strcmp(x->cmd,cmd)==0) {
- found++;
- break;
- }
- x++;
- }
- if(found) {
- printf("\n%s\t%s:\n",x->cmd,x->descr);
- printf("\tUsage:\n\t\t%s\n",x->usage);
- printf("\te.g:\n\t\t%s\n\n",x->example);
- return(0);
- } else {
- printf("\n%s: no such command.\n\n",cmd);
- return(-1);
- }
- }
-}
-
-/*
- * Signal handler for shell()
- */
-void
-shell_sig(int sig)
-{
- switch(sig) {
- case SIGINT:
- case SIGQUIT:
- case SIGTERM:
- /* ignore ? */
- break;
- default:
- break;
- }
-}
-
-/*
- * Built-in '.' handler (read-in and execute commands from file)
- */
-int
-sourcer(char *fname)
-{
- FILE *fd;
- char buf[512],*tok,*arg,**av;
- int ac,len,f,res,i;
- pid_t pid;
- char *sep=" \t";
-
- fd=fopen(fname,"r");
- if(fd==NULL) {
- printf("Couldn't open file '%s'\n",fname);
- return(-1);
- }
- while(!feof(fd)) {
- memset(buf,0,512);
- if(fgets(buf,512,fd)==NULL) continue;
- if((*buf=='#') || (*buf=='\n')) continue;
- len=strlen(buf);
- buf[len-1]='\0';
- if(strncmp(buf,"ncons",5)==0) {
- tok=strtok(buf,sep);
- tok=strtok(NULL,sep);
- ncons=atoi(tok);
- if((ncons<1)||(ncons>MAX_CONS)) {
- syslog(LOG_EMERG,"%s: bad ncons value; defaulting to %d\n",fname,MAX_CONS);
- ncons=MAX_CONS;
- }
- continue;
- } else if(strncmp(buf,"motd",4)==0) {
- tok=strtok(buf,sep);
- motd=strdup(strtok(NULL,sep));
- continue;
- } else {
- do_command(0,buf);
- }
- /* Next command, please. */
- }
- fclose(fd);
- syslog(LOG_EMERG,"Done with %s",fname);
-}
-
-void
-do_command(int shell, char *cmdline)
-{
- char *tok,*c,*sep=" \t";
- char **av;
- struct command *x;
- int found,len;
- int ac,i,f,res;
- int bg=0;
- pid_t pid;
-
- len=strlen(cmdline);
- if(cmdline[len-1]=='&') {
- bg++;
- cmdline[len-1]='\0';
- len--;
- } else bg=0;
- tok=strtok(cmdline,sep);
- x=bltins;
- found=0;
- while(x->cmd!=NULL) {
- if(strcmp(x->cmd,tok)==0) {
- found++;
- break;
- }
- x++;
- }
- if(found) {
- tok=cmdline+strlen(x->cmd)+1;
- while(*tok && isblank(*tok) && (tok<(cmdline+len))) tok++;
- if(*tok==NULL) tok=NULL;
- x->func(tok);
- return;
- }
- ac=0;
- av=(char **)calloc(((len+1)/2+1),sizeof(char *));
- av[ac++]=tok;
- while((av[ac++]=strtok(NULL,sep))!=NULL)
- continue;
- switch((pid=fork())) {
- case 0:
- if(shell) {
- signal(SIGINT,SIG_DFL);
- signal(SIGQUIT,SIG_DFL);
- signal(SIGTERM,SIG_DFL);
- signal(SIGHUP,SIG_DFL);
- } else {
- close(0);
- close(1);
- close(2);
- f=open(_PATH_CONSOLE,O_RDWR);
- dup2(f,0);
- dup2(f,1);
- dup2(f,2);
- if(f>2) close(f);
- }
- if(bg) {
- if(daemon(0,0)) {
- printf("do_command(%s): failed to run bg: %s\n",
- av[0],strerror(errno));
- _exit(100);
- }
- }
- execvp(av[0],av);
- /* Something went wrong... */
- printf("do_command(%s): %s\n",av[0],strerror(errno));
- _exit(100);
- break;
- case -1:
- printf("do_command(): %s\n",strerror(errno));
- break;
- default:
- while(waitpid(pid,&res,0)!=pid) continue;
- if(WEXITSTATUS(res)) {
- printf("do_command(%s): exit code=%d\n",
- av[0],WEXITSTATUS(res));
- }
- break;
- }
- free(av);
- return;
-}
-
-/*
- * This is the user interface. This routine gets executed on each
- * virtual console serviced by init.
- *
- * It works as normal shell does - for each external command it forks
- * and execs, for each internal command just executes a function.
- */
-
-int
-shell(int argc, char **argv)
-{
- char buf[BUFSIZE];
- char *prompt=" # ";
- int fd;
- int res;
- pid_t mypid;
-
- if(motd!=NULL) {
- if((fd=open(motd,O_RDONLY))!=-1) {
- do {
- res=read(fd,buf,BUFSIZE);
- res=write(1,buf,res);
- } while(res>0);
- close(fd);
- }
- }
-
- printf("\n\n+=========================================================+\n");
- printf("| Built-in shell() (enter '?' for short help on commands) |\n");
- printf("+=========================================================+\n\n");
- getcwd(cwd,BUFSIZE);
- mypid=getpid();
- signal(SIGINT,shell_sig);
- signal(SIGQUIT,shell_sig);
- signal(SIGTERM,shell_sig);
- while(!feof(stdin)) {
- memset(buf,0,BUFSIZE);
- printf("(%d)%s%s",mypid,cwd,prompt);
- fflush(stdout);
- if(fgets(buf,BUFSIZE-1,stdin)==NULL) continue;
- buf[strlen(buf)-1]='\0';
- if(strlen(buf)==0) continue;
- do_command(1,buf);
- }
- return(0);
-}
-
-/*
- * Stub for executing some external program on a console. This is called
- * from previously forked copy of our process, so that exec is ok.
- */
-int
-external_cmd(int argc, char **argv)
-{
- execvp(argv[0],argv);
-}
-
-/*
- * Acquire vty and properly attach ourselves to it.
- * Also, build basic environment for running user interface.
- */
-
-int
-start_session(int vty, int argc, char **argv)
-{
- int fd;
- char *t;
-
- close(0);
- close(1);
- close(2);
- revoke(ttys[vty].tty);
- fd=open(ttys[vty].tty,O_RDWR);
- dup2(fd,0);
- dup2(fd,1);
- dup2(fd,2);
- if(fd>2) close(fd);
- login_tty(fd);
- setpgid(0,getpid());
- putenv("TERM=xterm");
- putenv("HOME=/");
- putenv("PATH=/stand:/bin:/usr/bin:/sbin:.");
- signal(SIGHUP,SIG_DFL);
- signal(SIGINT,SIG_DFL);
- signal(SIGQUIT,SIG_DFL);
- signal(SIGTERM,SIG_DFL);
- chdir("/");
- t=(char *)(rindex(ttys[vty].tty,'/')+1);
- printf("\n\n\nStarting session on %s.\n",t);
- ttys[vty].func(argc,argv);
- _exit(0);
-}
-
-/*
- * Execute system startup script /etc/rc
- *
- * (Of course if you don't like it - I don't - you can run anything you
- * want here. Perhaps it would be useful just to read some config DB and
- * do these things ourselves, avoiding forking lots of shells and scripts.)
- */
-
-/* If OINIT_RC is defined, oinit will use it's own configuration file,
- * /etc/oinit.rc. It's format is described below. Otherwise, it will use
- * normal /etc/rc interpreted by Bourne shell.
- */
-#ifndef OINIT_RC
-#ifndef SH_NAME
-#define SH_NAME "-sh"
-#endif
-#ifndef SH_PATH
-#define SH_PATH _PATH_BSHELL
-#endif
-#ifndef SH_ARG
-#define SH_ARG "/etc/rc"
-#endif
-void
-runcom()
-{
- char *argv[3];
- pid_t pid;
- int st;
- int fd;
-
- if((pid=fork())==0) {
- /* child */
- close(0);
- close(1);
- close(2);
- fd=open(_PATH_CONSOLE,O_RDWR);
- dup2(fd,0);
- dup2(fd,1);
- dup2(fd,2);
- if(fd>2) close(fd);
- argv[0]=SH_NAME;
- argv[1]=SH_ARG;
- argv[2]=0;
- execvp(SH_PATH,argv);
- printf("runcom(): %s\n",strerror(errno));
- _exit(1);
- }
- /* Wait for child to exit */
- while(pid!=waitpid(pid,(int *)0,0)) continue;
- return;
-}
-#else
-/* Alternative /etc/rc - default is /etc/oinit.rc. Its format is as follows:
- * - each empty line or line beginning with a '#' is discarded
- * - any other line must contain a keyword, or a (nonblocking) command to run.
- *
- * Thus far, the following keywords are defined:
- * ncons <number> number of virtual consoles to open
- * motd <pathname> full path to motd file
- *
- * Examples of commands to run:
- *
- * ifconfig lo0 inet 127.0.0.1 netmask 255.0.0.0
- * ifconfig ed0 inet 148.81.168.10 netmask 255.255.255.0
- * kbdcontrol -l /usr/share/syscons/my_map.kbd
- */
-void
-runcom(char *fname)
-{
- int fd;
-
- close(0);
- close(1);
- close(2);
- fd=open(_PATH_CONSOLE,O_RDWR);
- dup2(fd,0);
- dup2(fd,1);
- dup2(fd,2);
- if(fd>2) close(fd);
- sourcer(fname);
-}
-#endif
-
-int
-run_multi()
-{
- int i,j;
- pid_t pid;
- int found;
-
- /* Run /etc/rc if not in single user */
-#ifndef OINIT_RC
- if(prevtrans==SINGLE) runcom();
-#else
- if(prevtrans==SINGLE) runcom(OINIT_RC);
-#endif
- if(transition!=MULTI) return(-1);
-
- syslog(LOG_EMERG,"*** Starting multi-user mode ***");
-
- /* Fork shell interface for each console */
- for(i=0;i<ncons;i++) {
- if(ttys[i].pid==0) {
- switch(pid=fork()) {
- case 0:
- start_session(i,0,NULL);
- break;
- case -1:
- printf("%s: %s\n",progname,strerror(errno));
- break;
- default:
- ttys[i].pid=pid;
- break;
- }
- }
- }
- /* Initialize any other services we'll use - most probably this will
- * be a 'telnet' service (some day...).
- */
- /* */
-
- /* Emulate multi-user */
- while(transition==MULTI) {
- /* XXX Modify this to allow for checking for the input on
- * XXX listening sockets, and forking a 'telnet' service.
- */
- /* */
-
- /* Wait for any process to exit */
- pid=waitpid(-1,(int *)0,0);
- if(pid==-1) continue;
- found=0;
- j=-1;
- /* search if it's one of our sessions */
- for(i=0;i<ncons;i++) {
- if(ttys[i].pid==pid) {
- found++;
- j=i;
- ttys[j].pid=0;
- break;
- }
- }
- if(!found) {
- /* Just collect the process's status */
- continue;
- } else {
- /* restart shell() on a console, if it died */
- if(transition!=MULTI) return(0);
- switch(pid=fork()) {
- case 0:
- sleep(1);
- start_session(j,0,NULL);
- break;
- case -1:
- printf("%s: %s\n",progname,strerror(errno));
- break;
- default:
- ttys[j].pid=pid;
- break;
- }
- }
- }
-}
-
-int clang;
-
-void
-kill_timer(int sig)
-{
- clang=1;
-}
-
-kill_ttys()
-{
-}
-
-/*
- * Start a shell on ttyv0 (i.e. the console).
- */
-
-int
-run_single()
-{
- int i;
- pid_t pid,wpid;
- static int sigs[2]={SIGTERM,SIGKILL};
-
- syslog(LOG_EMERG,"*** Starting single-user mode ***");
- /* Kill all existing sessions */
- syslog(LOG_EMERG,"Killing all existing sessions...");
- for(i=0;i<MAX_CONS;i++) {
- kill(ttys[i].pid,SIGHUP);
- ttys[i].pid=0;
- }
- for(i=0;i<2;i++) {
- if(kill(-1,sigs[i])==-1 && errno==ESRCH) break;
- clang=0;
- alarm(10);
- do {
- pid=waitpid(-1,(int *)0,WUNTRACED);
- if(errno==EINTR) continue;
- else break;
- } while (clang==0);
- }
- if(errno!=ECHILD) {
- syslog(LOG_EMERG,"Some processes would not die; ps -axl advised");
- }
- /* Single-user */
- switch(pid=fork()) {
- case 0:
- start_session(0,0,NULL);
- break;
- case -1:
- printf("%s: %s\n",progname,strerror(errno));
- printf("The system is seriously hosed. I'm dying...\n");
- transition=DEATH;
- return(-1);
- break;
- default:
- do {
- wpid=waitpid(pid,(int *)0,WUNTRACED);
- } while(wpid!=pid && transition==SINGLE);
- if(transition!=DEATH) {
- prevtrans=transition;
- transition=MULTI;
- }
- break;
- }
- return(0);
-}
-
-/*
- * Transition handler - installed as signal handler.
- */
-
-void
-transition_handler(int sig)
-{
-
- switch(sig) {
- case SIGHUP:
- case SIGTERM:
- prevtrans=transition;
- transition=SINGLE;
- syslog(LOG_EMERG,"*** Going from %s -> %s\n",trans[prevtrans],trans[transition]);
- if(prevtrans!=transition) longjmp(machine,sig);
- break;
- case SIGINT:
- case SIGQUIT:
- prevtrans=transition;
- transition=DEATH;
- syslog(LOG_EMERG,"*** Going from %s -> %s\n",trans[prevtrans],trans[transition]);
- if(prevtrans!=transition) longjmp(machine,sig);
- break;
- default:
- syslog(LOG_EMERG,"pid=%d sig=%s (ignored)\n",getpid(),sys_siglist[sig]);
- break;
- }
-}
-
-/*
- * Change system state appropriately to the signals
- */
-
-int
-transition_machine()
-{
- int i;
-
- while(transition!=DEATH) {
- switch(transition) {
- case MULTI:
- run_multi();
- break;
- case SINGLE:
- run_single();
- break;
- }
- }
- syslog(LOG_EMERG,"Killing all existing sessions...");
- /* Kill all sessions */
- kill(-1,SIGKILL);
- /* Be nice and wait for them */
- while(waitpid(-1,(int *)0,WNOHANG|WUNTRACED)>0) continue;
- unmount("/",0);
- reboot(RB_AUTOBOOT);
- /* NOTREACHED */
-}
-
-int
-main(int argc, char **argv)
-{
- int devfs=0,c,i;
-
- /* These are copied from real init(8) */
- if(getuid()!=0)
- errx(1,"%s",strerror(EPERM));
- openlog("init",LOG_CONS|LOG_ODELAY,LOG_AUTH);
- if(setsid()<0)
- warn("initial setsid() failed");
- if(setlogin("root")<0)
- warn("setlogin() failed");
-
- close(0);
- close(1);
- close(2);
- chdir("/");
-
- progname=rindex(argv[0],'/');
- if(progname==NULL) {
- progname=argv[0];
- } else progname++;
-
- transition=MULTI;
-
- /* We must recognize the same options as real init does */
- while((c=getopt(argc,argv,"dsf"))!=-1) {
- switch(c) {
- case 'd':
- devfs=1;
- break;
- case 's':
- transition=SINGLE;
- break;
- case 'f':
- break;
- default:
- printf("%s: unrecognized flag '-%c'\n",progname,c);
- break;
- }
- }
- if(devfs)
- mount("devfs",_PATH_DEV,MNT_NOEXEC|MNT_RDONLY,0);
-
- /* Fill in the sess structures. */
- /* XXX Really, should be filled based upon config file. */
- for(i=0;i<MAX_CONS;i++) {
- if(i==0) {
- sprintf(ttys[i].tty,_PATH_CONSOLE);
- } else {
- sprintf(ttys[i].tty,"%sv%c",_PATH_TTY,vty[i]);
- }
- ttys[i].pid=0;
- ttys[i].func=shell;
- }
-
- getcwd(cwd,BUFSIZE);
-
- signal(SIGINT,transition_handler);
- signal(SIGQUIT,transition_handler);
- signal(SIGTERM,transition_handler);
- signal(SIGHUP,transition_handler);
- signal(SIGALRM,kill_timer);
-
- setjmp(machine);
- transition_machine(transition);
- /* NOTREACHED */
- exit(100);
-}
diff --git a/release/picobsd/tinyware/passwd/Makefile b/release/picobsd/tinyware/passwd/Makefile
deleted file mode 100644
index 806836c4fea3..000000000000
--- a/release/picobsd/tinyware/passwd/Makefile
+++ /dev/null
@@ -1,68 +0,0 @@
-# From: @(#)Makefile 8.3 (Berkeley) 4/2/94
-# $FreeBSD$
-
-# Only NO_PAM is used by PicoBSD and supported here
-
-
-PROG= passwd
-SRCS= local_passwd.c passwd.c pw_copy.c pw_util.c
-
-GENSRCS=yp.h yp_clnt.c yppasswd.h yppasswd_clnt.c \
- yppasswd_private.h yppasswd_private_clnt.c yppasswd_private_xdr.c
-CFLAGS+=-Wall
-
-LIBADD= crypt util
-.PATH: ${.CURDIR}/../../../../usr.bin/chpass \
-# ${.CURDIR}/../../../../usr.sbin/vipw \
-# ${.CURDIR}/../../../../usr.bin/passwd
-
-CFLAGS+= -DLOGIN_CAP -DCRYPT -I. -I${.CURDIR} \
-# -I${.CURDIR}/../../../../usr.bin/passwd \
-# -I${.CURDIR}/../../../../usr.sbin/vipw \
-# -I${.CURDIR}/../../../../usr.bin/chpass \
-# -I${.CURDIR}/../../../../lib/libc/gen \
-# -Dyp_error=warnx -DLOGGING
-
-CLEANFILES= ${GENSRCS}
-
-RPCGEN= RPCGEN_CPP=${CPP:Q} rpcgen -C
-RPCSRC= ${DESTDIR}/usr/include/rpcsvc/yp.x
-RPCSRC_PW= ${DESTDIR}/usr/include/rpcsvc/yppasswd.x
-RPCSRC_PRIV= ${.CURDIR}/../../usr.sbin/rpc.yppasswdd/yppasswd_private.x
-
-yp.h: ${RPCSRC}
- ${RPCGEN} -h -o ${.TARGET} ${RPCSRC}
-
-yp_clnt.c: ${RPCSRC} yp.h
- ${RPCGEN} -l -o ${.TARGET} ${RPCSRC}
-
-yppasswd.h: ${RPCSRC_PW}
- ${RPCGEN} -h -o ${.TARGET} ${RPCSRC_PW}
-
-yppasswd_clnt.c: ${RPCSRC_PW}
- ${RPCGEN} -l -o ${.TARGET} ${RPCSRC_PW}
-
-yppasswd_private.h: ${RPCSRC_PRIV}
- ${RPCGEN} -h -o ${.TARGET} ${RPCSRC_PRIV}
-
-yppasswd_private_xdr.c: ${RPCSRC_PRIV}
- ${RPCGEN} -c -o ${.TARGET} ${RPCSRC_PRIV}
-
-yppasswd_private_clnt.c: ${RPCSRC_PRIV}
- ${RPCGEN} -l -o ${.TARGET} ${RPCSRC_PRIV}
-
-BINOWN= root
-BINMODE=4555
-LINKS=${BINDIR}/passwd ${BINDIR}/yppasswd
-MLINKS=passwd.1 yppasswd.1
-
-beforeinstall:
-.for i in passwd yppasswd
- [ ! -e ${DESTDIR}${BINDIR}/$i ] || \
- chflags noschg ${DESTDIR}${BINDIR}/$i || true
-.endfor
-
-afterinstall:
- -chflags schg ${DESTDIR}${BINDIR}/passwd
-
-.include <bsd.prog.mk>
diff --git a/release/picobsd/tinyware/passwd/extern.h b/release/picobsd/tinyware/passwd/extern.h
deleted file mode 100644
index 0c6c9f505ec6..000000000000
--- a/release/picobsd/tinyware/passwd/extern.h
+++ /dev/null
@@ -1,40 +0,0 @@
-/*-
- * SPDX-License-Identifier: BSD-4-Clause
- *
- * Copyright (c) 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.
- *
- * From: @(#)extern.h 8.1 (Berkeley) 4/2/94
- * $FreeBSD$
- */
-
-int krb_passwd(char *, char *, char *, char *);
-int local_passwd(char *);
diff --git a/release/picobsd/tinyware/passwd/local_passwd.c b/release/picobsd/tinyware/passwd/local_passwd.c
deleted file mode 100644
index 41b6fe998443..000000000000
--- a/release/picobsd/tinyware/passwd/local_passwd.c
+++ /dev/null
@@ -1,239 +0,0 @@
-/*-
- * SPDX-License-Identifier: BSD-4-Clause
- *
- * Copyright (c) 1990, 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.
- */
-
-#ifndef lint
-static const char sccsid[] = "@(#)local_passwd.c 8.3 (Berkeley) 4/2/94";
-#endif /* not lint */
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
-#include <sys/types.h>
-#include <sys/time.h>
-
-#include <ctype.h>
-#include <err.h>
-#include <errno.h>
-#include <pwd.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <time.h>
-#include <unistd.h>
-
-#include <pw_util.h>
-#ifdef YP
-#include <pw_yp.h>
-#endif
-
-#ifdef LOGGING
-#include <syslog.h>
-#endif
-
-#ifdef LOGIN_CAP
-#ifdef AUTH_NONE /* multiple defs :-( */
-#undef AUTH_NONE
-#endif
-#include <login_cap.h>
-#endif
-
-#include "extern.h"
-
-static uid_t uid;
-int randinit;
-
-extern void
-pw_copy(int ffd, int tfd, struct passwd *pw, struct passwd *old_pw);
-
-char *tempname;
-
-static unsigned char itoa64[] = /* 0 ... 63 => ascii - 64 */
- "./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
-
-void
-to64(s, v, n)
- char *s;
- long v;
- int n;
-{
- while (--n >= 0) {
- *s++ = itoa64[v&0x3f];
- v >>= 6;
- }
-}
-
-char *
-getnewpasswd(pw, nis)
- struct passwd *pw;
- int nis;
-{
- int tries, min_length = 6;
- int force_mix_case = 1;
- char *p, *t;
-#ifdef LOGIN_CAP
- login_cap_t * lc;
-#endif
- char buf[_PASSWORD_LEN+1], salt[32];
- struct timeval tv;
-
- if (!nis)
- (void)printf("Changing local password for %s.\n", pw->pw_name);
-
- if (uid && pw->pw_passwd[0] &&
- strcmp(crypt(getpass("Old password:"), pw->pw_passwd),
- pw->pw_passwd)) {
- errno = EACCES;
- pw_error(NULL, 1, 1);
- }
-
-#ifdef LOGIN_CAP
- /*
- * Determine minimum password length, next password change date,
- * and whether or not to force mixed case passwords.
- * Note that even for NIS passwords, login_cap is still used.
- */
- if ((lc = login_getpwclass(pw)) != NULL) {
- time_t period;
-
- /* minpasswordlen capablity */
- min_length = (int)login_getcapnum(lc, "minpasswordlen",
- min_length, min_length);
- /* passwordtime capability */
- period = login_getcaptime(lc, "passwordtime", 0, 0);
- if (period > (time_t)0) {
- pw->pw_change = time(NULL) + period;
- }
- /* mixpasswordcase capability */
- force_mix_case = login_getcapbool(lc, "mixpasswordcase", 1);
- }
-#endif
-
- for (buf[0] = '\0', tries = 0;;) {
- p = getpass("New password:");
- if (!*p) {
- (void)printf("Password unchanged.\n");
- pw_error(NULL, 0, 0);
- }
- if (strlen(p) < min_length && (uid != 0 || ++tries < 2)) {
- (void)printf("Please enter a password at least %d characters in length.\n", min_length);
- continue;
- }
-
- if (force_mix_case) {
- for (t = p; *t && islower(*t); ++t);
- if (!*t && (uid != 0 || ++tries < 2)) {
- (void)printf("Please don't use an all-lower case password.\nUnusual capitalization, control characters or digits are suggested.\n");
- continue;
- }
- }
- (void)strcpy(buf, p);
- if (!strcmp(buf, getpass("Retype new password:")))
- break;
- (void)printf("Mismatch; try again, EOF to quit.\n");
- }
- /* grab a random printable character that isn't a colon */
- if (!randinit) {
- randinit = 1;
- srandomdev();
- }
-#ifdef NEWSALT
- salt[0] = _PASSWORD_EFMT1;
- to64(&salt[1], (long)(29 * 25), 4);
- to64(&salt[5], random(), 4);
- salt[9] = '\0';
-#else
- /* Make a good size salt for algorithms that can use it. */
- gettimeofday(&tv,0);
-#ifdef LOGIN_CAP
- if (login_setcryptfmt(lc, "md5", NULL) == NULL)
- pw_error("cannot set password cipher", 1, 1);
- login_close(lc);
-#else
- (void)crypt_set_format("md5");
-#endif
- /* Salt suitable for anything */
- to64(&salt[0], random(), 3);
- to64(&salt[3], tv.tv_usec, 3);
- to64(&salt[6], tv.tv_sec, 2);
- to64(&salt[8], random(), 5);
- to64(&salt[13], random(), 5);
- to64(&salt[17], random(), 5);
- to64(&salt[22], random(), 5);
- salt[27] = '\0';
-#endif
- return (crypt(buf, salt));
-}
-
-int
-local_passwd(uname)
- char *uname;
-{
- struct passwd *pw;
- int pfd, tfd;
-
- if (!(pw = getpwnam(uname)))
- errx(1, "unknown user %s", uname);
-
-#ifdef YP
- /* Use the right password information. */
- pw = (struct passwd *)&local_password;
-#endif
- uid = getuid();
- if (uid && uid != pw->pw_uid)
- errx(1, "%s", strerror(EACCES));
-
- pw_init();
-
- /*
- * Get the new password. Reset passwd change time to zero by
- * default. If the user has a valid login class (or the default
- * fallback exists), then the next password change date is set
- * by getnewpasswd() according to the "passwordtime" capability
- * if one has been specified.
- */
- pw->pw_change = 0;
- pw->pw_passwd = getnewpasswd(pw, 0);
-
- pfd = pw_lock();
- tfd = pw_tmp();
- pw_copy(pfd, tfd, pw, NULL);
-
- if (!pw_mkdb(uname))
- pw_error((char *)NULL, 0, 1);
-#ifdef LOGGING
- syslog(LOG_DEBUG, "user %s changed their local password\n", uname);
-#endif
- return (0);
-}
diff --git a/release/picobsd/tinyware/passwd/passwd.c b/release/picobsd/tinyware/passwd/passwd.c
deleted file mode 100644
index 419396390afe..000000000000
--- a/release/picobsd/tinyware/passwd/passwd.c
+++ /dev/null
@@ -1,195 +0,0 @@
-/*-
- * SPDX-License-Identifier: BSD-4-Clause
- *
- * Copyright (c) 1988, 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.
- */
-
-#ifndef lint
-static const char copyright[] =
-"@(#) Copyright (c) 1988, 1993, 1994\n\
- The Regents of the University of California. All rights reserved.\n";
-#endif /* not lint */
-
-#ifndef lint
-#if 0
-static char sccsid[] = "@(#)passwd.c 8.3 (Berkeley) 4/2/94";
-#endif
-static const char rcsid[] =
- "$FreeBSD$";
-#endif /* not lint */
-
-#include <sys/types.h>
-
-#include <err.h>
-#include <errno.h>
-#include <libutil.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-
-#ifdef YP
-#include <pwd.h>
-#include <pw_yp.h>
-#include <rpcsvc/yp.h>
-int __use_yp = 0;
-int yp_errno = YP_TRUE;
-extern int yp_passwd( char * );
-#endif
-
-#include "extern.h"
-
-static void usage(void);
-
-int use_local_passwd = 0;
-
-int
-main(argc, argv)
- int argc;
- char **argv;
-{
- int ch;
- char *uname;
-
-#ifdef YP
-#define OPTIONS "d:h:lysfo"
-#else
-#define OPTIONS "l"
-#endif
-
-#ifdef YP
- int res = 0;
-
- if (strstr(argv[0], "yppasswd")) __use_yp = 1;
-#endif
-
- while ((ch = getopt(argc, argv, OPTIONS)) != -1) {
- switch (ch) {
- case 'l': /* change local password file */
- use_local_passwd = 1;
- break;
-#ifdef YP
- case 'y': /* Change NIS password */
- __use_yp = 1;
- break;
- case 'd': /* Specify NIS domain. */
-#ifdef PARANOID
- if (!getuid()) {
-#endif
- yp_domain = optarg;
- if (yp_server == NULL)
- yp_server = "localhost";
-#ifdef PARANOID
- } else {
- warnx("only the super-user may use the -d flag");
- }
-#endif
- break;
- case 'h': /* Specify NIS server. */
-#ifdef PARANOID
- if (!getuid()) {
-#endif
- yp_server = optarg;
-#ifdef PARANOID
- } else {
- warnx("only the super-user may use the -h flag");
- }
-#endif
- break;
- case 'o':
- force_old++;
- break;
-#endif
- default:
- case '?':
- usage();
- }
- }
-
- argc -= optind;
- argv += optind;
-
- if ((uname = getlogin()) == NULL)
- err(1, "getlogin");
-
- switch(argc) {
- case 0:
- break;
- case 1:
- uname = argv[0];
- break;
- default:
- usage();
- }
-
-#ifdef YP
- /*
- * If NIS is turned on in the password database, use it, else punt.
- */
- res = use_yp(uname, 0, 0);
- if (res == USER_YP_ONLY) {
- if (!use_local_passwd) {
- exit(yp_passwd(uname));
- } else {
- /*
- * Reject -l flag if NIS is turned on and the user
- * doesn't exist in the local password database.
- */
- errx(1, "unknown local user: %s", uname);
- }
- } else if (res == USER_LOCAL_ONLY) {
- /*
- * Reject -y flag if user only exists locally.
- */
- if (__use_yp)
- errx(1, "unknown NIS user: %s", uname);
- } else if (res == USER_YP_AND_LOCAL) {
- if (!use_local_passwd && (yp_in_pw_file || __use_yp))
- exit(yp_passwd(uname));
- }
-#endif
-
- exit(local_passwd(uname));
-}
-
-static void
-usage()
-{
-
-#ifdef YP
- (void)fprintf(stderr,
- "usage: passwd [-l] [-y] [-o] [-d domain [-h host]] [user]\n");
-#else
- (void)fprintf(stderr, "usage: passwd [-l] user\n");
-#endif
- exit(1);
-}
diff --git a/release/picobsd/tinyware/passwd/pw_copy.c b/release/picobsd/tinyware/passwd/pw_copy.c
deleted file mode 100644
index 7586980e4a55..000000000000
--- a/release/picobsd/tinyware/passwd/pw_copy.c
+++ /dev/null
@@ -1,306 +0,0 @@
-/*-
- * SPDX-License-Identifier: BSD-4-Clause
- *
- * Copyright (c) 1990, 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.
- */
-
-#ifndef lint
-static const char sccsid[] = "@(#)pw_copy.c 8.4 (Berkeley) 4/2/94";
-#endif /* not lint */
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
-/*
- * This module is used to copy the master password file, replacing a single
- * record, by chpass(1) and passwd(1).
- */
-
-#include <err.h>
-#include <pwd.h>
-#include <stdio.h>
-#include <string.h>
-#include <unistd.h>
-
-#if 0
-#include <pw_scan.h>
-#endif
-extern int pw_big_ids_warning;
-extern int pw_scan(char *, struct passwd *);
-
-#include <pw_util.h>
-
-extern char *tempname;
-
-/* for use in pw_copy(). Compare a pw entry to a pw struct. */
-static int
-pw_equal(char *buf, struct passwd *pw)
-{
- struct passwd buf_pw;
- int len;
-
- len = strlen (buf);
- if (buf[len-1] == '\n')
- buf[len-1] = '\0';
- return (strcmp(pw->pw_name, buf_pw.pw_name) == 0
- && pw->pw_uid == buf_pw.pw_uid
- && pw->pw_gid == buf_pw.pw_gid
- && strcmp(pw->pw_class, buf_pw.pw_class) == 0
- && (long)pw->pw_change == (long)buf_pw.pw_change
- && (long)pw->pw_expire == (long)buf_pw.pw_expire
- && strcmp(pw->pw_gecos, buf_pw.pw_gecos) == 0
- && strcmp(pw->pw_dir, buf_pw.pw_dir) == 0
- && strcmp(pw->pw_shell, buf_pw.pw_shell) == 0);
-}
-
-void
-pw_copy(int ffd, int tfd, struct passwd *pw, struct passwd *old_pw)
-{
- FILE *from, *to;
- int done;
- char *p, buf[8192];
- char uidstr[20];
- char gidstr[20];
- char chgstr[20];
- char expstr[20];
-
- snprintf(uidstr, sizeof(uidstr), "%lu", (unsigned long)pw->pw_uid);
- snprintf(gidstr, sizeof(gidstr), "%lu", (unsigned long)pw->pw_gid);
- snprintf(chgstr, sizeof(chgstr), "%ld", (long)pw->pw_change);
- snprintf(expstr, sizeof(expstr), "%ld", (long)pw->pw_expire);
-
- if (!(from = fdopen(ffd, "r")))
- pw_error(_PATH_MASTERPASSWD, 1, 1);
- if (!(to = fdopen(tfd, "w")))
- pw_error(tempname, 1, 1);
-
- for (done = 0; fgets(buf, sizeof(buf), from);) {
- if (!strchr(buf, '\n')) {
- warnx("%s: line too long", _PATH_MASTERPASSWD);
- pw_error(NULL, 0, 1);
- }
- if (done) {
- (void)fprintf(to, "%s", buf);
- if (ferror(to))
- goto err;
- continue;
- }
- for (p = buf; *p != '\n'; p++)
- if (*p != ' ' && *p != '\t')
- break;
- if (*p == '#' || *p == '\n') {
- (void)fprintf(to, "%s", buf);
- if (ferror(to))
- goto err;
- continue;
- }
- if (!(p = strchr(buf, ':'))) {
- warnx("%s: corrupted entry", _PATH_MASTERPASSWD);
- pw_error(NULL, 0, 1);
- }
- *p = '\0';
- if (strcmp(buf, pw->pw_name)) {
- *p = ':';
- (void)fprintf(to, "%s", buf);
- if (ferror(to))
- goto err;
- continue;
- }
- *p = ':';
- if (old_pw && !pw_equal(buf, old_pw)) {
- warnx("%s: entry for %s has changed",
- _PATH_MASTERPASSWD, pw->pw_name);
- pw_error(NULL, 0, 1);
- }
- (void)fprintf(to, "%s:%s:%s:%s:%s:%s:%s:%s:%s:%s\n",
- pw->pw_name, pw->pw_passwd,
- pw->pw_fields & _PWF_UID ? uidstr : "",
- pw->pw_fields & _PWF_GID ? gidstr : "",
- pw->pw_class,
- pw->pw_fields & _PWF_CHANGE ? chgstr : "",
- pw->pw_fields & _PWF_EXPIRE ? expstr : "",
- pw->pw_gecos, pw->pw_dir, pw->pw_shell);
- done = 1;
- if (ferror(to))
- goto err;
- }
- if (!done) {
-#ifdef YP
- /* Ultra paranoid: shouldn't happen. */
- if (getuid()) {
- warnx("%s: not found in %s -- permission denied",
- pw->pw_name, _PATH_MASTERPASSWD);
- pw_error(NULL, 0, 1);
- } else
-#endif /* YP */
- (void)fprintf(to, "%s:%s:%s:%s:%s:%s:%s:%s:%s:%s\n",
- pw->pw_name, pw->pw_passwd,
- pw->pw_fields & _PWF_UID ? uidstr : "",
- pw->pw_fields & _PWF_GID ? gidstr : "",
- pw->pw_class,
- pw->pw_fields & _PWF_CHANGE ? chgstr : "",
- pw->pw_fields & _PWF_EXPIRE ? expstr : "",
- pw->pw_gecos, pw->pw_dir, pw->pw_shell);
- }
-
- if (ferror(to))
-err: pw_error(NULL, 1, 1);
- (void)fclose(to);
-}
-
-#include <sys/param.h>
-
-#include <err.h>
-#include <errno.h>
-#include <fcntl.h>
-#include <pwd.h>
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-#include <unistd.h>
-
-
-/*
- * Some software assumes that IDs are short. We should emit warnings
- * for id's which can not be stored in a short, but we are more liberal
- * by default, warning for IDs greater than USHRT_MAX.
- *
- * If pw_big_ids_warning is anything other than -1 on entry to pw_scan()
- * it will be set based on the existence of PW_SCAN_BIG_IDS in the
- * environment.
- */
-int pw_big_ids_warning = -1;
-
-int
-pw_scan(bp, pw)
- char *bp;
- struct passwd *pw;
-{
- uid_t id;
- int root;
- char *p, *sh;
-
- if (pw_big_ids_warning == -1)
- pw_big_ids_warning = getenv("PW_SCAN_BIG_IDS") == NULL ? 1 : 0;
-
- pw->pw_fields = 0;
- if (!(pw->pw_name = strsep(&bp, ":"))) /* login */
- goto fmt;
- root = !strcmp(pw->pw_name, "root");
- if(pw->pw_name[0] && (pw->pw_name[0] != '+' || pw->pw_name[1] == '\0'))
- pw->pw_fields |= _PWF_NAME;
-
- if (!(pw->pw_passwd = strsep(&bp, ":"))) /* passwd */
- goto fmt;
- if(pw->pw_passwd[0]) pw->pw_fields |= _PWF_PASSWD;
-
- if (!(p = strsep(&bp, ":"))) /* uid */
- goto fmt;
- if (p[0])
- pw->pw_fields |= _PWF_UID;
- else {
- if (pw->pw_name[0] != '+' && pw->pw_name[0] != '-') {
- warnx("no uid for user %s", pw->pw_name);
- return (0);
- }
- }
- id = strtoul(p, (char **)NULL, 10);
- if (errno == ERANGE) {
- warnx("%s > max uid value (%lu)", p, ULONG_MAX);
- return (0);
- }
- if (root && id) {
- warnx("root uid should be 0");
- return (0);
- }
- if (pw_big_ids_warning && id > USHRT_MAX) {
- warnx("%s > recommended max uid value (%u)", p, USHRT_MAX);
- /*return (0);*/ /* THIS SHOULD NOT BE FATAL! */
- }
- pw->pw_uid = id;
-
- if (!(p = strsep(&bp, ":"))) /* gid */
- goto fmt;
- if(p[0]) pw->pw_fields |= _PWF_GID;
- id = strtoul(p, (char **)NULL, 10);
- if (errno == ERANGE) {
- warnx("%s > max gid value (%u)", p, ULONG_MAX);
- return (0);
- }
- if (pw_big_ids_warning && id > USHRT_MAX) {
- warnx("%s > recommended max gid value (%u)", p, USHRT_MAX);
- /* return (0); This should not be fatal! */
- }
- pw->pw_gid = id;
-
- pw->pw_class = strsep(&bp, ":"); /* class */
- if(pw->pw_class[0]) pw->pw_fields |= _PWF_CLASS;
-
- if (!(p = strsep(&bp, ":"))) /* change */
- goto fmt;
- if(p[0]) pw->pw_fields |= _PWF_CHANGE;
- pw->pw_change = atol(p);
-
- if (!(p = strsep(&bp, ":"))) /* expire */
- goto fmt;
- if(p[0]) pw->pw_fields |= _PWF_EXPIRE;
- pw->pw_expire = atol(p);
-
- if (!(pw->pw_gecos = strsep(&bp, ":"))) /* gecos */
- goto fmt;
- if(pw->pw_gecos[0]) pw->pw_fields |= _PWF_GECOS;
-
- if (!(pw->pw_dir = strsep(&bp, ":"))) /* directory */
- goto fmt;
- if(pw->pw_dir[0]) pw->pw_fields |= _PWF_DIR;
-
- if (!(pw->pw_shell = strsep(&bp, ":"))) /* shell */
- goto fmt;
-
- p = pw->pw_shell;
- if (root && *p) /* empty == /bin/sh */
- for (setusershell();;) {
- if (!(sh = getusershell())) {
- warnx("warning, unknown root shell");
- break;
- }
- if (!strcmp(p, sh))
- break;
- }
- if(p[0]) pw->pw_fields |= _PWF_SHELL;
-
- if ((p = strsep(&bp, ":"))) { /* too many */
-fmt: warnx("corrupted entry");
- return (0);
- }
- return (1);
-}
diff --git a/release/picobsd/tinyware/passwd/pw_util.c b/release/picobsd/tinyware/passwd/pw_util.c
deleted file mode 100644
index cfab6e115269..000000000000
--- a/release/picobsd/tinyware/passwd/pw_util.c
+++ /dev/null
@@ -1,260 +0,0 @@
-/*-
- * SPDX-License-Identifier: BSD-4-Clause
- *
- * Copyright (c) 1990, 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.
- */
-
-#ifndef lint
-#if 0
-static const char sccsid[] = "@(#)pw_util.c 8.3 (Berkeley) 4/2/94";
-#endif
-static const char rcsid[] =
- "$FreeBSD$";
-#endif /* not lint */
-
-/*
- * This file is used by all the "password" programs; vipw(8), chpass(1),
- * and passwd(1).
- */
-
-#include <sys/param.h>
-#include <sys/errno.h>
-#include <sys/time.h>
-#include <sys/resource.h>
-#include <sys/stat.h>
-#include <sys/wait.h>
-
-#include <err.h>
-#include <fcntl.h>
-#include <paths.h>
-#include <pwd.h>
-#include <signal.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-
-#include "pw_util.h"
-
-extern char *tempname;
-static pid_t editpid = -1;
-static int lockfd;
-static char _default_editor[] = _PATH_VI;
-static char _default_mppath[] = _PATH_PWD;
-static char _default_masterpasswd[] = _PATH_MASTERPASSWD;
-char *mppath = _default_mppath;
-char *masterpasswd = _default_masterpasswd;
-
-void pw_cont(int);
-
-void
-pw_cont(int sig)
-{
-
- if (editpid != -1)
- kill(editpid, sig);
-}
-
-void
-pw_init(void)
-{
- struct rlimit rlim;
-
- /* Unlimited resource limits. */
- rlim.rlim_cur = rlim.rlim_max = RLIM_INFINITY;
- (void)setrlimit(RLIMIT_CPU, &rlim);
- (void)setrlimit(RLIMIT_FSIZE, &rlim);
- (void)setrlimit(RLIMIT_STACK, &rlim);
- (void)setrlimit(RLIMIT_DATA, &rlim);
- (void)setrlimit(RLIMIT_RSS, &rlim);
-
- /* Don't drop core (not really necessary, but GP's). */
- rlim.rlim_cur = rlim.rlim_max = 0;
- (void)setrlimit(RLIMIT_CORE, &rlim);
-
- /* Turn off signals. */
- (void)signal(SIGALRM, SIG_IGN);
- (void)signal(SIGHUP, SIG_IGN);
- (void)signal(SIGINT, SIG_IGN);
- (void)signal(SIGPIPE, SIG_IGN);
- (void)signal(SIGQUIT, SIG_IGN);
- (void)signal(SIGTERM, SIG_IGN);
- (void)signal(SIGCONT, pw_cont);
-
- /* Create with exact permissions. */
- (void)umask(0);
-}
-
-int
-pw_lock(void)
-{
- /*
- * If the master password file doesn't exist, the system is hosed.
- * Might as well try to build one. Set the close-on-exec bit so
- * that users can't get at the encrypted passwords while editing.
- * Open should allow flock'ing the file; see 4.4BSD. XXX
- */
- for (;;) {
- struct stat st;
-
- lockfd = open(masterpasswd, O_RDONLY, 0);
- if (lockfd < 0 || fcntl(lockfd, F_SETFD, 1) == -1)
- err(1, "%s", masterpasswd);
- if (flock(lockfd, LOCK_EX|LOCK_NB))
- errx(1, "the password db file is busy");
-
- /*
- * If the password file was replaced while we were trying to
- * get the lock, our hardlink count will be 0 and we have to
- * close and retry.
- */
- if (fstat(lockfd, &st) < 0)
- errx(1, "fstat() failed");
- if (st.st_nlink != 0)
- break;
- close(lockfd);
- lockfd = -1;
- }
- return (lockfd);
-}
-
-int
-pw_tmp(void)
-{
- static char path[MAXPATHLEN];
- int fd;
- char *p;
-
- strncpy(path, masterpasswd, MAXPATHLEN - 1);
- path[MAXPATHLEN] = '\0';
-
- if ((p = strrchr(path, '/')))
- ++p;
- else
- p = path;
- strcpy(p, "pw.XXXXXX");
- if ((fd = mkstemp(path)) == -1)
- err(1, "%s", path);
- tempname = path;
- return (fd);
-}
-
-int
-pw_mkdb(const char *username)
-{
- int pstat;
- pid_t pid;
-
- (void)fflush(stderr);
- if (!(pid = fork())) {
- if(!username) {
- warnx("rebuilding the database...");
- execl(_PATH_PWD_MKDB, "pwd_mkdb", "-p", "-d", mppath,
- tempname, (char *)NULL);
- } else {
- warnx("updating the database...");
- execl(_PATH_PWD_MKDB, "pwd_mkdb", "-p", "-d", mppath,
- "-u", username, tempname, (char *)NULL);
- }
- pw_error(_PATH_PWD_MKDB, 1, 1);
- }
- pid = waitpid(pid, &pstat, 0);
- if (pid == -1 || !WIFEXITED(pstat) || WEXITSTATUS(pstat) != 0)
- return (0);
- warnx("done");
- return (1);
-}
-
-void
-pw_edit(int notsetuid)
-{
- int pstat;
- char *p, *editor;
-
- if (!(editor = getenv("EDITOR")))
- editor = _default_editor;
- if ((p = strrchr(editor, '/')))
- ++p;
- else
- p = editor;
-
- if (!(editpid = fork())) {
- if (notsetuid) {
- (void)setgid(getgid());
- (void)setuid(getuid());
- }
- errno = 0;
- execlp(editor, p, tempname, (char *)NULL);
- _exit(errno);
- }
- for (;;) {
- editpid = waitpid(editpid, (int *)&pstat, WUNTRACED);
- errno = WEXITSTATUS(pstat);
- if (editpid == -1)
- pw_error(editor, 1, 1);
- else if (WIFSTOPPED(pstat))
- raise(WSTOPSIG(pstat));
- else if (WIFEXITED(pstat) && errno == 0)
- break;
- else
- pw_error(editor, 1, 1);
- }
- editpid = -1;
-}
-
-void
-pw_prompt(void)
-{
- int c, first;
-
- (void)printf("re-edit the password file? [y]: ");
- (void)fflush(stdout);
- first = c = getchar();
- while (c != '\n' && c != EOF)
- c = getchar();
- if (first == 'n')
- pw_error(NULL, 0, 0);
-}
-
-void
-pw_error(const char *name, int error, int eval)
-{
- if (error) {
- if (name != NULL)
- warn("%s", name);
- else
- warn(NULL);
- }
- warnx("password information unchanged");
- (void)unlink(tempname);
- exit(eval);
-}
diff --git a/release/picobsd/tinyware/passwd/pw_util.h b/release/picobsd/tinyware/passwd/pw_util.h
deleted file mode 100644
index d441b1907966..000000000000
--- a/release/picobsd/tinyware/passwd/pw_util.h
+++ /dev/null
@@ -1,46 +0,0 @@
-/*-
- * SPDX-License-Identifier: BSD-4-Clause
- *
- * Copyright (c) 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.
- *
- * @(#)pw_util.h 8.2 (Berkeley) 4/1/94
- *
- * $FreeBSD$
- */
-
-void pw_edit(int);
-void pw_error(const char *, int, int);
-void pw_init(void);
-int pw_lock(void);
-int pw_mkdb(const char *);
-void pw_prompt(void);
-int pw_tmp(void);
diff --git a/release/picobsd/tinyware/sps/Makefile b/release/picobsd/tinyware/sps/Makefile
deleted file mode 100644
index a1bcf457e3ba..000000000000
--- a/release/picobsd/tinyware/sps/Makefile
+++ /dev/null
@@ -1,9 +0,0 @@
-# $FreeBSD$
-#
-PROG=sps
-SRCS= sps.c
-MAN=
-
-.include <bsd.prog.mk>
-
-
diff --git a/release/picobsd/tinyware/sps/README b/release/picobsd/tinyware/sps/README
deleted file mode 100644
index 2357113bf2ca..000000000000
--- a/release/picobsd/tinyware/sps/README
+++ /dev/null
@@ -1,11 +0,0 @@
-This is a small 'ps' replacement, which uses information available via
-sysctl(3) interface (contrary to the 'aps', which requires you to mount
-procfs(5) to be able to get exactly the same info, so I think that 'sps'
-is superior solution).
-
-When I have some time, I'll add usual switches and other functions that normal
-'ps' has...
-
-<abial@freebsd.org>
-
-$FreeBSD$
diff --git a/release/picobsd/tinyware/sps/sps.c b/release/picobsd/tinyware/sps/sps.c
deleted file mode 100644
index f79d01983b9f..000000000000
--- a/release/picobsd/tinyware/sps/sps.c
+++ /dev/null
@@ -1,122 +0,0 @@
-/*-
- * Copyright (c) 1998 Andrzej Bialecki
- * 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.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-
-/*
- * Small replacement for ps(1) - uses only sysctl(3) to retrieve info
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sys/param.h>
-#include <sys/sysctl.h>
-#include <sys/stat.h>
-#include <sys/user.h>
-
-char p_stat[] = "?iRSTZWM";
-
-int
-main(int argc, char *argv[])
-{
- int mib[4], i, num, len, j, plen;
- char buf[MAXPATHLEN], vty[5], pst[5], wmesg[10];
- struct kinfo_proc *ki;
- char *t;
- int ma, mi;
-
- mib[0] = CTL_KERN;
- mib[1] = KERN_PROC;
- mib[2] = KERN_PROC_ALL;
- if (sysctl(mib, 3, NULL, &len, NULL, 0) != 0) {
- perror("sysctl sizing");
- exit(1);
- }
- t = (char *)malloc(len);
- if (sysctl(mib, 3, t, &len, NULL, 0) != 0) {
- perror("sysctl info");
- exit(1);
- }
- mib[2] = KERN_PROC_ARGS;
- num = len / KINFO_PROC_SIZE;
- i = 0;
- printf("USERNAME PID PPID PRI NICE TTY STAT WCHAN COMMAND\n");
- while(i < num) {
- ki = (struct kinfo_proc *)(t + (num - i - 1) * KINFO_PROC_SIZE);
- mib[3] = ki->ki_pid;
- plen = MAXPATHLEN;
- if (sysctl(mib, 4, buf, &plen, NULL, 0) != 0) {
- perror("sysctl cmd info");
- exit(1);
- }
- if (plen == 0) {
- sprintf(buf, "(%s)", ki->ki_comm);
- } else {
- for (j = 0; j < plen - 1; j++) {
- if (buf[j] == '\0') buf[j] = ' ';
- }
- }
- if (strcmp(ki->ki_wmesg, "") == 0) {
- sprintf(wmesg, "-");
- } else {
- strcpy(wmesg, ki->ki_wmesg);
- }
- ma = major(ki->ki_tdev);
- mi = minor(ki->ki_tdev);
- switch(ma) {
- case 255:
- strcpy(vty, "??");
- break;
- case 12:
- if(mi != 255) {
- sprintf(vty, "v%d", mi);
- break;
- }
- /* FALLTHROUGH */
- case 0:
- strcpy(vty, "con");
- break;
- case 5:
- sprintf(vty, "p%d", mi);
- break;
- }
- sprintf(pst, "%c", p_stat[ki->ki_stat]);
- printf("%8s %5u %5u %3d %4d %3s %-4s %-7s %s\n",
- ki->ki_login,
- ki->ki_pid,
- ki->ki_ppid,
- ki->ki_pri.pri_level, /* XXX check this */
- ki->ki_nice,
- vty,
- pst,
- wmesg,
- buf);
- i++;
- }
- free((void *)t);
- exit(0);
-}
diff --git a/release/picobsd/tinyware/view/Makefile b/release/picobsd/tinyware/view/Makefile
deleted file mode 100644
index b668613a5248..000000000000
--- a/release/picobsd/tinyware/view/Makefile
+++ /dev/null
@@ -1,9 +0,0 @@
-# $FreeBSD$
-
-PROG=view
-SRCS=view.c
-CFLAGS+=-I/usr/local/include
-LDADD+=-L/usr/local/lib -lpng -lvgl -lz -lm
-MAN=
-
-.include <bsd.prog.mk>
diff --git a/release/picobsd/tinyware/view/README b/release/picobsd/tinyware/view/README
deleted file mode 100644
index df5f774a95f6..000000000000
--- a/release/picobsd/tinyware/view/README
+++ /dev/null
@@ -1,86 +0,0 @@
-Warsaw, 1998.08.18
-
- VIEW - small PNG viewer
- -----------------------
-
-This program is intended to serve as a simple console viewer for PNG
-graphics. It also features some scripting abilities, which allow you to
-build simple presentation.
-
-In fact, using even this initial version I was able to build a nice
-presentation of PicoBSD abilities which I used in real-life situation (you
-can see for yourself one of the presentation's screens, fbsd.png).
-
-The audience was impressed :-), especially when I asked them politely what
-are requirements and cost to make that kind of presentation using M$
-products...
-
-Simple Viewing
---------------
-
-Usage is as follows:
-
- view [-g nnn.nnn] [-r x] filename.png
-
-where
- -g nnn.nnn screen gamma (you can adjust how bright is the
- picture)
- -r x resolution:
- 0 - 640x480x16
- 1 - 640x200x256
- 2 - 320x240x256
-
-Under right mouse button you can find a simple menu, which tells you also
-the hotkeys. You can shift, rotate and zoom the picture.
-
-Presentation
-------------
-
-Usage is as above, but the file you give as argument is a (unix) text file
-of the following format:
-
- 1 VIEW SCRIPT
- 2 5
- 3 welcome.png
- 4 /home/clipart/logo.png
- 5 /home/present/title.png
- 6 /home/present/outline.png
- 7 /home/present/end.png
-
-(of course without the line numbering or the leading space!). The line number
-1 is magic, and must be present in order to recognize the file properly.
-
-The second line tells how many pictures consist the presentation. The
-following lines tell the file names containing the images themselves.
-
-See the example in file picobsd.vu.
-
-Command line arguments (gamma and resolution) are as above. You can also use
-the pop-up menu to adjust image parameters, as well as go forward or
-backward in the presentation.
-
-Bugs, caveats, missing features
--------------------------------
-
-* there are some bugs in libvgl which require strange workarounds, and even
- then it doesn't work quite right. See the source for the 'XXX' comments...
-
-* I didn't have time to add gamma adjustment to the pop-up menu. It's
- simple, though, and I leave it as an exercise for the reader :-))
-
-* it would be great if someone would add GIF and jpeg support.
-
-* the error checking is probably weak. A bad PNG file or script file will
- probably cause a coredump.
-
-* pop-up menu facilities need more abstraction to be usable in other cases.
-
-Anyway, as it is even now it's quite usable.
-
-Have fun!
-
-Andrzej Bialecki
-
-<abial@freebsd.org>
-
-$FreeBSD$
diff --git a/release/picobsd/tinyware/view/fbsd.png b/release/picobsd/tinyware/view/fbsd.png
deleted file mode 100644
index 0c5d3ed7887a..000000000000
--- a/release/picobsd/tinyware/view/fbsd.png
+++ /dev/null
Binary files differ
diff --git a/release/picobsd/tinyware/view/picobsd.vu b/release/picobsd/tinyware/view/picobsd.vu
deleted file mode 100644
index 16a3630fa2d0..000000000000
--- a/release/picobsd/tinyware/view/picobsd.vu
+++ /dev/null
@@ -1,9 +0,0 @@
-VIEW SCRIPT
-7
-/png/logo.png
-/png/1.png
-/png/2.png
-/png/p1.png
-/png/p2.png
-/png/p3.png
-/png/p4.png
diff --git a/release/picobsd/tinyware/view/view.c b/release/picobsd/tinyware/view/view.c
deleted file mode 100644
index 2727ebe24426..000000000000
--- a/release/picobsd/tinyware/view/view.c
+++ /dev/null
@@ -1,619 +0,0 @@
-/*-
- * Copyright (c) 1998 Andrzej Bialecki
- * 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.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-
-/*
- * Small PNG viewer with scripting abilities
- */
-
-#include <stdio.h>
-#include <errno.h>
-#include <fcntl.h>
-#include <signal.h>
-#include <termios.h>
-#include <sys/types.h>
-#include <sys/fbio.h>
-#include <sys/consio.h>
-#include <sys/mouse.h>
-#include <vgl.h>
-#include <png.h>
-
-#define NUMBER 8
-
-extern char *optarg;
-extern int optind;
-
-/* Prototypes */
-int kbd_action(int x, int y, char hotkey);
-
-struct action {
- int zoom;
- int rotate;
- int Xshift,Yshift;
-};
-
-struct menu_item {
- char *descr;
- char hotkey;
- int (*func)(int x, int y, char hotkey);
-};
-
-struct menu_item std_menu[]= {
- {"q Quit",'q',kbd_action},
- {"n Next",'n',kbd_action},
- {"p Previous",'p',kbd_action},
- {"Z Zoom in",'Z',kbd_action},
- {"z Zoom out",'z',kbd_action},
- {"r Rotate",'r',kbd_action},
- {"R Refresh",'R',kbd_action},
- {"l Left",'l',kbd_action},
- {"h Right",'h',kbd_action},
- {"j Up",'j',kbd_action},
- {"k Down",'k',kbd_action},
- {NULL,0,NULL}
-};
-
-char *progname;
-VGLBitmap pic,bkg;
-struct action a;
-byte pal_red[256];
-byte pal_green[256];
-byte pal_blue[256];
-byte pal_colors;
-double screen_gamma;
-int max_screen_colors=15;
-int quit,changed;
-char **pres;
-int nimg=0;
-int auto_chg=0;
-int cur_img=0;
-char act;
-FILE *log;
-
-void
-usage()
-{
- fprintf(stderr,"\nVGL graphics viewer, 1.0 (c) Andrzej Bialecki.\n");
- fprintf(stderr,"\nUsage:\n");
- fprintf(stderr,"\t%s [-r n] [-g n.n] filename\n",progname);
- fprintf(stderr,"\nwhere:\n");
- fprintf(stderr,"\t-r n\tchoose resolution:\n");
- fprintf(stderr,"\t\t0 - 640x480x16 (default)\n");
- fprintf(stderr,"\t\t1 - 640x200x256\n");
- fprintf(stderr,"\t\t2 - 320x240x256\n");
- fprintf(stderr,"\t-g n.n\tset screen gamma (1.3 by default)\n");
- fprintf(stderr,"\n");
-}
-
-int
-pop_up(char *title,int x, int y)
-{
- VGLBitmap sav,clr;
- int x1,y1,width,height,i,j;
- int last_pos,cur_pos,max_item;
- char buttons;
- char *t;
-
- sav.Type=VGLDisplay->Type;
- clr.Type=VGLDisplay->Type;
- width=0;
- height=0;
- max_item=0;
- i=0;
- while(std_menu[i].descr!=NULL) {
- height++;
- max_item++;
- if(strlen(std_menu[i].descr)>width) width=strlen(std_menu[i].descr);
- i++;
- }
- width=width*8+2;
- height=height*9+4+8;
- sav.Xsize=width;
- sav.Ysize=height;
- clr.Xsize=width;
- clr.Ysize=height;
- sav.Bitmap=(byte *)calloc(width*height,1);
- clr.Bitmap=(byte *)calloc(width*height,1);
- if(x>(VGLDisplay->Xsize-width)) x1=VGLDisplay->Xsize-width;
- else x1=x;
- if(y>(VGLDisplay->Ysize-height)) y1=VGLDisplay->Ysize-height;
- else y1=y;
- VGLMouseMode(VGL_MOUSEHIDE);
- VGLBitmapCopy(VGLDisplay,x1,y1,&sav,0,0,width,height);
- VGLFilledBox(VGLDisplay,x1,y1,x1+width-1,y1+height-1,pal_colors-1);
- VGLBitmapString(VGLDisplay,x1+1,y1+1,title,0,pal_colors-1,0,0);
- VGLLine(VGLDisplay,x1,y1+9,x1+width,y1+9,0);
- i=0;
- while(std_menu[i].descr!=NULL) {
- VGLBitmapString(VGLDisplay,x1+1,y1+11+i*9,std_menu[i].descr,0,pal_colors-1,0,0);
- i++;
- }
- last_pos=-1;
- VGLMouseMode(VGL_MOUSESHOW);
- do {
- pause();
- VGLMouseStatus(&x,&y,&buttons);
- cur_pos=(y-y1-11)/9;
- if((cur_pos<0)||(cur_pos>max_item-1)) {
- if(last_pos==-1) last_pos=0;
- VGLBitmapString(VGLDisplay,x1+1,y1+11+last_pos*9,std_menu[last_pos].descr,0,pal_colors-1,0,0);
- last_pos=-1;
- } else if(last_pos!=cur_pos) {
- if(last_pos==-1) last_pos=0;
- VGLBitmapString(VGLDisplay,x1+1,y1+11+last_pos*9,std_menu[last_pos].descr,0,pal_colors-1,0,0);
- VGLBitmapString(VGLDisplay,x1+1,y1+11+cur_pos*9,std_menu[cur_pos].descr,pal_colors/2+1,pal_colors-1,0,0);
- last_pos=cur_pos;
- }
- } while (buttons & MOUSE_BUTTON3DOWN);
- VGLMouseMode(VGL_MOUSEHIDE);
- /* XXX Screws up totally when r==3. Libvgl bug! */
- VGLBitmapCopy(&clr,0,0,VGLDisplay,x1,y1,width,height);
- VGLBitmapCopy(&sav,0,0,VGLDisplay,x1,y1,width,height);
- VGLMouseMode(VGL_MOUSESHOW);
- free(sav.Bitmap);
- free(clr.Bitmap);
- changed++;
- if((cur_pos>=0) && (cur_pos<max_item)) {
- std_menu[cur_pos].func(x,y,std_menu[cur_pos].hotkey);
- }
- changed++;
- return(0);
-}
-
-void
-display( VGLBitmap *pic,
- byte *red,
- byte *green,
- byte *blue,
- struct action *e)
-{
- VGLBitmap target;
- int x,y,i=0,j=0;
-
- VGLMouseMode(VGL_MOUSEHIDE);
- VGLRestorePalette();
- /* XXX Broken in r!=2. Libvgl bug. */
- //VGLClear(VGLDisplay,0);
- VGLBitmapCopy(&bkg,0,0,VGLDisplay,0,0,bkg.Xsize,bkg.Ysize);
-
- if(e!=NULL) {
- if(e->zoom!=1 || e->rotate) {
- target.Bitmap=(byte *)calloc(pic->Xsize*pic->Ysize*e->zoom*e->zoom,1);
- if(e->rotate) {
- target.Xsize=pic->Ysize*e->zoom;
- target.Ysize=pic->Xsize*e->zoom;
- } else {
- target.Xsize=pic->Xsize*e->zoom;
- target.Ysize=pic->Ysize*e->zoom;
- }
- target.Type=pic->Type;
- for(x=0;x<pic->Xsize;x++) {
- for(y=0;y<pic->Ysize;y++) {
- for(i=0;i<e->zoom;i++) {
- for(j=0;j<e->zoom;j++) {
- if(e->rotate) {
- VGLSetXY(&target,target.Xsize-(e->zoom*y+i),e->zoom*x+j,VGLGetXY(pic,x,y));
- } else {
- VGLSetXY(&target,e->zoom*x+i,e->zoom*y+j,VGLGetXY(pic,x,y));
- }
- }
- }
- }
- }
- } else {
- target.Bitmap=(byte *)calloc(pic->Xsize*pic->Ysize,sizeof(byte));
- target.Xsize=pic->Xsize;
- target.Ysize=pic->Ysize;
- target.Type=pic->Type;
- VGLBitmapCopy(pic,0,0,&target,0,0,pic->Xsize,pic->Ysize);
- }
- } else {
- target.Bitmap=(byte *)calloc(pic->Xsize*pic->Ysize,sizeof(byte));
- target.Xsize=pic->Xsize;
- target.Ysize=pic->Ysize;
- target.Type=pic->Type;
- VGLBitmapCopy(pic,0,0,&target,0,0,pic->Xsize,pic->Ysize);
- }
- VGLSetPalette(red, green, blue);
- if(e!=NULL) {
- VGLBitmapCopy(&target,0,0,VGLDisplay,e->Xshift,e->Yshift,target.Xsize,target.Ysize);
- } else {
- VGLBitmapCopy(&target,0,0,VGLDisplay,0,0,target.Xsize,target.Ysize);
- }
- VGLMouseMode(VGL_MOUSESHOW);
- free(target.Bitmap);
-}
-
-int
-png_load(char *filename)
-{
- int i,j,k;
- FILE *fd;
- u_char header[NUMBER];
- png_structp png_ptr;
- png_infop info_ptr,end_info;
- png_uint_32 width,height;
- int bit_depth,color_type,interlace_type;
- int compression_type,filter_type;
- int channels,rowbytes;
- double gamma;
- png_colorp palette;
- int num_palette;
- png_bytep *row_pointers;
- char c;
- int res=0;
-
- fd=fopen(filename,"rb");
-
- if(fd==NULL) {
- VGLEnd();
- perror("fopen");
- exit(1);
- }
- fread(header,1,NUMBER,fd);
- if(!png_check_sig(header,NUMBER)) {
- fprintf(stderr,"Not a PNG file.\n");
- return(-1);
- }
- png_ptr=png_create_read_struct(PNG_LIBPNG_VER_STRING,(void *)NULL,
- NULL,NULL);
- info_ptr=png_create_info_struct(png_ptr);
- end_info=png_create_info_struct(png_ptr);
- if(!png_ptr || !info_ptr || !end_info) {
- VGLEnd();
- fprintf(stderr,"failed to allocate needed structs!\n");
- png_destroy_read_struct(&png_ptr,&info_ptr,&end_info);
- return(-1);
- }
- png_set_sig_bytes(png_ptr,NUMBER);
- png_init_io(png_ptr,fd);
- png_read_info(png_ptr,info_ptr);
- png_get_IHDR(png_ptr,info_ptr,&width,&height,&bit_depth,
- &color_type,&interlace_type,&compression_type,&filter_type);
- png_get_PLTE(png_ptr,info_ptr,&palette,&num_palette);
- channels=png_get_channels(png_ptr,info_ptr);
- rowbytes=png_get_rowbytes(png_ptr,info_ptr);
- if(bit_depth==16)
- png_set_strip_16(png_ptr);
- if(color_type & PNG_COLOR_MASK_ALPHA)
- png_set_strip_alpha(png_ptr);
- if(png_get_gAMA(png_ptr,info_ptr,&gamma))
- png_set_gamma(png_ptr,screen_gamma,gamma);
- else
- png_set_gamma(png_ptr,screen_gamma,0.45);
- if(res==0) {
- /* Dither */
- if(color_type & PNG_COLOR_MASK_COLOR) {
- if(png_get_valid(png_ptr,info_ptr,PNG_INFO_PLTE)) {
- png_uint_16p histogram;
- png_get_hIST(png_ptr,info_ptr,&histogram);
- png_set_dither(png_ptr,palette,num_palette,max_screen_colors,histogram,0);
- } else {
- png_color std_color_cube[16]={
- {0x00,0x00,0x00},
- {0x02,0x02,0x02},
- {0x04,0x04,0x04},
- {0x06,0x06,0x06},
- {0x08,0x08,0x08},
- {0x0a,0x0a,0x0a},
- {0x0c,0x0c,0x0c},
- {0x0e,0x0e,0x0e},
- {0x10,0x10,0x10},
- {0x12,0x12,0x12},
- {0x14,0x14,0x14},
- {0x16,0x16,0x16},
- {0x18,0x18,0x18},
- {0x1a,0x1a,0x1a},
- {0x1d,0x1d,0x1d},
- {0xff,0xff,0xff},
- };
- png_set_dither(png_ptr,std_color_cube,max_screen_colors,max_screen_colors,NULL,0);
- }
- }
- }
- png_set_packing(png_ptr);
- if(png_get_valid(png_ptr,info_ptr,PNG_INFO_sBIT)) {
- png_color_8p sig_bit;
-
- png_get_sBIT(png_ptr,info_ptr,&sig_bit);
- png_set_shift(png_ptr,sig_bit);
- }
- png_read_update_info(png_ptr,info_ptr);
- png_get_IHDR(png_ptr,info_ptr,&width,&height,&bit_depth,
- &color_type,&interlace_type,&compression_type,&filter_type);
- png_get_PLTE(png_ptr,info_ptr,&palette,&num_palette);
- channels=png_get_channels(png_ptr,info_ptr);
- rowbytes=png_get_rowbytes(png_ptr,info_ptr);
- row_pointers=malloc(height*sizeof(png_bytep));
- for(i=0;i<height;i++) {
- row_pointers[i]=malloc(rowbytes);
- }
- png_read_image(png_ptr,row_pointers);
- png_read_end(png_ptr,end_info);
- png_destroy_read_struct(&png_ptr,&info_ptr,&end_info);
- fclose(fd);
- /* Set palette */
- if(res) k=2;
- else k=2;
- for(i=0;i<256;i++) {
- pal_red[i]=255;
- pal_green[i]=255;
- pal_blue[i]=255;
- }
- for(i=0;i<num_palette;i++) {
- pal_red[i]=(palette+i)->red>>k;
- pal_green[i]=(palette+i)->green>>k;
- pal_blue[i]=(palette+i)->blue>>k;
- }
- pal_colors=num_palette;
- if(pic.Bitmap!=NULL) free(pic.Bitmap);
- pic.Bitmap=(byte *)calloc(rowbytes*height,sizeof(byte));
- pic.Type=MEMBUF;
- pic.Xsize=rowbytes;
- pic.Ysize=height;
- for(i=0;i<rowbytes;i++) {
- for(j=0;j<height;j++) {
- VGLSetXY(&pic,
- i,j,row_pointers[j][i]);
- }
- }
- a.zoom=1;
- a.Xshift=(VGLDisplay->Xsize-pic.Xsize)/2;
- a.Yshift=(VGLDisplay->Ysize-pic.Ysize)/2;
- a.rotate=0;
- return(0);
-}
-
-void
-kbd_handler(int sig)
-{
- u_char buf[10];
- int res;
-
- res=read(0,&buf,10);
- changed++;
- act=buf[res-1];
-}
-
-int
-kbd_action(int x, int y, char key)
-{
- changed=0;
- if(key!='n') auto_chg=0;
- switch(key) {
- case 'q':
- quit=1;
- break;
- case 'Z':
- a.zoom++;
- changed++;
- break;
- case 'z':
- a.zoom--;
- if(a.zoom<1) a.zoom=1;
- changed++;
- break;
- case 'l':
- a.Xshift+=VGLDisplay->Xsize/5;
- changed++;
- break;
- case 'h':
- a.Xshift-=VGLDisplay->Xsize/5;
- changed++;
- break;
- case 'k':
- a.Yshift+=VGLDisplay->Ysize/5;
- changed++;
- break;
- case 'j':
- a.Yshift-=VGLDisplay->Ysize/5;
- changed++;
- break;
- case 'R':
- changed++;
- break;
- case 'r':
- if(a.rotate) a.rotate=0;
- else a.rotate=1;
- changed++;
- break;
- case '\n':
- case 'n':
- if(nimg>0) {
- if(cur_img<nimg-1) {
- cur_img++;
- } else {
- cur_img=0;
- }
- png_load(pres[cur_img]);
- changed++;
- }
- break;
- case 'p':
- if(nimg>0) {
- if(cur_img>0) {
- cur_img--;
- } else {
- cur_img=nimg-1;
- }
- png_load(pres[cur_img]);
- changed++;
- }
- break;
- }
- act=0;
-}
-
-int
-main(int argc, char *argv[])
-{
- int i,j,k;
- char c;
- int res=0;
- int x,y;
- char buttons;
- struct termios t_new,t_old;
- FILE *fsc;
-
- char buf[100];
-
- progname=argv[0];
- screen_gamma=1.5;
-#ifdef DEBUG
- log=fopen("/png/view.log","w");
-#endif
- while((c=getopt(argc,argv,"r:g:"))!=-1) {
- switch(c) {
- case 'r':
- res=atoi(optarg);
- if(res>0) max_screen_colors=256;
- break;
- case 'g':
- screen_gamma=atof(optarg);
- break;
- case '?':
- default:
- usage();
- exit(0);
- }
- }
- switch(res) {
- case 0:
- VGLInit(SW_CG640x480);
- break;
- case 1:
- VGLInit(SW_VGA_CG320);
- break;
- case 2:
- VGLInit(SW_VGA_MODEX);
- break;
- default:
- fprintf(stderr,"No such resolution!\n");
- usage();
- exit(-1);
- }
-#ifdef DEBUG
- fprintf(log,"VGL initialised\n");
-#endif
- VGLSavePalette();
- if(argc>optind) {
- res=png_load(argv[optind]);
- } else {
- VGLEnd();
- usage();
- exit(0);
- }
- if(res) {
- /* Hmm... Script? */
- fsc=fopen(argv[optind],"r");
-#ifdef DEBUG
- fprintf(log,"Trying script %s\n",argv[optind]);
-#endif
- fgets(buf,99,fsc);
- buf[strlen(buf)-1]='\0';
- if(strncmp("VIEW SCRIPT",buf,11)!=NULL) {
- VGLEnd();
- usage();
- }
- if(strlen(buf)>12) {
- auto_chg=atoi(buf+12);
- }
- fgets(buf,99,fsc);
- buf[strlen(buf)-1]='\0';
- nimg=atoi(buf);
- if(nimg==0) {
- VGLEnd();
- usage();
- }
- pres=(char **)calloc(nimg,sizeof(char *));
- for(i=0;i<nimg;i++) {
- fgets(buf,99,fsc);
- buf[strlen(buf)-1]='\0';
- pres[i]=strdup(buf);
- }
- fclose(fsc);
- cur_img=0;
-#ifdef DEBUG
- fprintf(log,"Script with %d entries\n",nimg);
-#endif
- png_load(pres[cur_img]);
- }
- VGLMouseInit(VGL_MOUSEHIDE);
- /* Prepare the keyboard */
- tcgetattr(0,&t_old);
- memcpy(&t_new,&t_old,sizeof(struct termios));
- cfmakeraw(&t_new);
- tcsetattr(0,TCSAFLUSH,&t_new);
- fcntl(0,F_SETFL,O_ASYNC);
- /* XXX VGLClear doesn't work.. :-(( Prepare a blank background */
- bkg.Bitmap=(byte *)calloc(VGLDisplay->Xsize*VGLDisplay->Ysize,1);
- bkg.Xsize=VGLDisplay->Xsize;
- bkg.Ysize=VGLDisplay->Ysize;
- bkg.Type=VGLDisplay->Type;
- signal(SIGIO,kbd_handler);
- a.zoom=1;
- a.Xshift=(VGLDisplay->Xsize-pic.Xsize)/2;
- a.Yshift=(VGLDisplay->Ysize-pic.Ysize)/2;
- a.rotate=0;
- quit=0;
- changed=0;
- display(&pic,pal_red,pal_green,pal_blue,&a);
- while(!quit) {
- if(act) {
-#ifdef DEBUG
- fprintf(log,"kbd_action(%c)\n",act);
-#endif
- kbd_action(x,y,act);
- }
- if(quit) break;
- if(changed) {
-#ifdef DEBUG
- fprintf(log,"changed, redisplaying\n");
-#endif
- display(&pic,pal_red,pal_green,pal_blue,&a);
- changed=0;
- }
- if(auto_chg) {
- sleep(auto_chg);
- kbd_action(x,y,'n');
- } else {
- pause();
- }
- VGLMouseStatus(&x,&y,&buttons);
- if(buttons & MOUSE_BUTTON3DOWN) {
-#ifdef DEBUG
- fprintf(log,"pop_up called\n");
-#endif
- pop_up("View",x,y);
- }
- }
- VGLEnd();
-#ifdef DEBUG
- fclose(log);
-#endif
- exit(0);
-}
diff --git a/release/picobsd/tinyware/vm/Makefile b/release/picobsd/tinyware/vm/Makefile
deleted file mode 100644
index 193710e1bc1c..000000000000
--- a/release/picobsd/tinyware/vm/Makefile
+++ /dev/null
@@ -1,10 +0,0 @@
-# $FreeBSD$
-#
-PROG=vm
-#CFLAGS+=
-SRCS= vm.c
-MAN=
-
-.include <bsd.prog.mk>
-
-
diff --git a/release/picobsd/tinyware/vm/README b/release/picobsd/tinyware/vm/README
deleted file mode 100644
index c4a940c629e8..000000000000
--- a/release/picobsd/tinyware/vm/README
+++ /dev/null
@@ -1,10 +0,0 @@
-1998.02.12
-
-This is a small replacement for vmstat(8) program. It allows you to measure
-current memory utilisation. The same info is available via sysctl(8) program,
-but unfortunately this particular variable doesn't have its handler, and
-consequently it is not displayed in stock version of sysctl(8).
-
-<abial@freebsd.org>
-
-$FreeBSD$
diff --git a/release/picobsd/tinyware/vm/vm.c b/release/picobsd/tinyware/vm/vm.c
deleted file mode 100644
index 90bb8ddd388d..000000000000
--- a/release/picobsd/tinyware/vm/vm.c
+++ /dev/null
@@ -1,112 +0,0 @@
-/*-
- * Copyright (c) 1998 Andrzej Bialecki
- * 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.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-
-#include <stdio.h>
-#include <sys/types.h>
-#include <sys/sysctl.h>
-#include <sys/vmmeter.h>
-#include <vm/vm_param.h>
-
-#define pgtok(a) ((a) * (u_int) pagesize >> 10)
-
-int
-vm_i()
-{
-#define CNT 49
- int cnt[CNT];
- char names[CNT*16];
- char *a, *namep[CNT*16];
- int i,len;
- long long inttotal=0;
- long uptime=1;
-
- len=sizeof(cnt);
- i = sysctlbyname("hw.intrcnt", &cnt, &len, NULL, 0);
- if (i != 0)
- return i ;
- len=sizeof(names);
- i = sysctlbyname("hw.intrnames", &names, &len, NULL, 0);
- if (i != 0)
- return i ;
-
- for( i=0, a = names ; i < CNT && a < names+sizeof(names) ; ) {
- namep[i++] = a++;
- while (a < names+sizeof(names) && *a)
- a++ ;
- a++ ; /* skip \0 */
- }
- printf("interrupt total rate\n");
- inttotal = 0;
- for (i=0; i< CNT ; i++)
- if (cnt[i] >0) {
- printf("%-12s %20lu %10lu\n", namep[i], cnt[i], cnt[i]/uptime);
- inttotal += cnt[i];
- }
- printf("Total %20llu %10llu\n", inttotal,
- inttotal / (u_int64_t) uptime);
- return 0;
-}
-int
-main(int argc, char *argv[])
-{
- int mib[2],i=0,len;
- int pagesize, pagesize_len;
- struct vmtotal v;
-
- if (argc > 1 && !strcmp(argv[1], "-i")) {
- if (vm_i())
- fprintf(stderr, "vm -i stats not available via sysctl\n");
- return 0 ;
- }
- pagesize_len = sizeof(int);
- sysctlbyname("vm.stats.vm.v_page_size",&pagesize,&pagesize_len,NULL,0);
-
- len=sizeof(struct vmtotal);
- mib[0]=CTL_VM;
- mib[1]=VM_METER;
- for(;;) {
- sysctl(mib,2,&v,&len,NULL,0);
- if(i==0) {
- printf(" procs kB virt mem real mem shared vm shared real free\n");
- printf(" r w l s tot act tot act tot act tot act\n");
- }
- printf("%2hd%2hd%2hd%2hd",v.t_rq-1,v.t_dw+v.t_pw,v.t_sl,v.t_sw);
- printf("%7d %7d %7d%7d",
- pgtok(v.t_vm),pgtok(v.t_avm),
- pgtok(v.t_rm),pgtok(v.t_arm));
- printf("%7d%7d%7d%7d%7d\n",
- pgtok(v.t_vmshr),pgtok(v.t_avmshr),
- pgtok(v.t_rmshr),pgtok(v.t_armshr),
- pgtok(v.t_free));
- sleep(5);
- i++;
- if(i>22) i=0;
- }
- exit(0);
-
-}