sam: rm dregs
This commit is contained in:
parent
7f6458b045
commit
0a513e6560
4 changed files with 0 additions and 293 deletions
|
|
@ -1,29 +0,0 @@
|
||||||
This is sam (not including samterm) from the 4th edition of Plan 9,
|
|
||||||
with changes so that it can be compiled under unix.
|
|
||||||
(Tested on Solaris 7 and Debian 3.0r1.)
|
|
||||||
|
|
||||||
Some extra libraries are needed. First, fetch libutf-2.0 and libfmt-2.0
|
|
||||||
from
|
|
||||||
http://pdos.lcs.mit.edu/~rsc/software/
|
|
||||||
|
|
||||||
(Beware that in libfmt/fmt.c there is a line that says:
|
|
||||||
'u', __ifmt, /* in Plan 9, __flagfmt */
|
|
||||||
Thus, sam will have to fmtinstall the other thing. Other ported programs
|
|
||||||
may have to do the same. The fmt library should probably print messages
|
|
||||||
about bad format characters to stderr, since no one seems to check the
|
|
||||||
return codes.)
|
|
||||||
|
|
||||||
Compile and install those two libraries.
|
|
||||||
Set PREFIX in the Makefile to match, then compile sam.
|
|
||||||
|
|
||||||
Your C compiler will emit many complaints of the form:
|
|
||||||
sam.c:496: warning: passing arg 1 of `bufread' from incompatible pointer type
|
|
||||||
|
|
||||||
This is because the Plan 9 compiler has a slightly different (better,
|
|
||||||
ala Oberon) type system than ISO C. Popular compilers generate the right
|
|
||||||
code, so in an act of civil disobediance I changed just enough to get
|
|
||||||
it to compile, but left the type errors in. Now the next C standard can
|
|
||||||
adopt this extension, because at least one important C program uses it!
|
|
||||||
|
|
||||||
-- Scott Schwartz, 4 July 2003
|
|
||||||
|
|
||||||
|
|
@ -1,40 +0,0 @@
|
||||||
#define __USE_UNIX98 // for pread/pwrite, supposedly
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <stdarg.h>
|
|
||||||
#include <setjmp.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <sys/stat.h>
|
|
||||||
#include <fcntl.h>
|
|
||||||
#include <errno.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
#include "utf.h"
|
|
||||||
#include "fmt.h"
|
|
||||||
|
|
||||||
#define nil 0
|
|
||||||
#define dup dup2
|
|
||||||
#define exec execv
|
|
||||||
#define seek lseek
|
|
||||||
#define getwd getcwd
|
|
||||||
#define USED(a)
|
|
||||||
#define SET(a)
|
|
||||||
|
|
||||||
enum {
|
|
||||||
OREAD = 0,
|
|
||||||
OWRITE = 1,
|
|
||||||
ORDWR = 2,
|
|
||||||
OCEXEC = 4,
|
|
||||||
ORCLOSE = 8
|
|
||||||
};
|
|
||||||
|
|
||||||
enum {
|
|
||||||
ERRMAX = 255
|
|
||||||
};
|
|
||||||
|
|
||||||
void exits(const char *);
|
|
||||||
void _exits(const char *);
|
|
||||||
int notify (void(*f)(void *, char *));
|
|
||||||
int create(char *, int, int);
|
|
||||||
int errstr(char *, int);
|
|
||||||
|
|
@ -1,39 +0,0 @@
|
||||||
address.c: In function `filematch':
|
|
||||||
address.c:159: warning: passing arg 1 of `bufreset' from incompatible pointer type
|
|
||||||
address.c:160: warning: passing arg 1 of `bufinsert' from incompatible pointer type
|
|
||||||
file.c: In function `mergeextend':
|
|
||||||
file.c:117: warning: passing arg 1 of `bufread' from incompatible pointer type
|
|
||||||
file.c: In function `fileinsert':
|
|
||||||
file.c:275: warning: passing arg 1 of `bufinsert' from incompatible pointer type
|
|
||||||
file.c: In function `filedelete':
|
|
||||||
file.c:301: warning: passing arg 1 of `bufdelete' from incompatible pointer type
|
|
||||||
file.c: In function `fileundelete':
|
|
||||||
file.c:324: warning: passing arg 1 of `bufread' from incompatible pointer type
|
|
||||||
file.c: In function `filereadc':
|
|
||||||
file.c:339: warning: passing arg 1 of `bufread' from incompatible pointer type
|
|
||||||
file.c: In function `fileload':
|
|
||||||
file.c:405: warning: passing arg 1 of `bufload' from incompatible pointer type
|
|
||||||
file.c: In function `fileundo':
|
|
||||||
file.c:528: warning: passing arg 1 of `bufdelete' from incompatible pointer type
|
|
||||||
file.c:546: warning: passing arg 1 of `bufinsert' from incompatible pointer type
|
|
||||||
file.c: In function `fileclose':
|
|
||||||
file.c:604: warning: passing arg 1 of `bufclose' from incompatible pointer type
|
|
||||||
io.c: In function `readio':
|
|
||||||
io.c:90: warning: passing arg 1 of `bufload' from incompatible pointer type
|
|
||||||
io.c: In function `writeio':
|
|
||||||
io.c:152: warning: passing arg 1 of `bufread' from incompatible pointer type
|
|
||||||
mesg.c: In function `inmesg':
|
|
||||||
mesg.c:248: warning: passing arg 1 of `bufread' from incompatible pointer type
|
|
||||||
mesg.c: In function `snarf':
|
|
||||||
mesg.c:568: warning: passing arg 1 of `bufread' from incompatible pointer type
|
|
||||||
mesg.c: In function `setgenstr':
|
|
||||||
mesg.c:612: warning: passing arg 1 of `bufread' from incompatible pointer type
|
|
||||||
sam.c: In function `readcmd':
|
|
||||||
sam.c:496: warning: passing arg 1 of `bufread' from incompatible pointer type
|
|
||||||
sam.c: In function `copy':
|
|
||||||
sam.c:676: warning: passing arg 1 of `bufread' from incompatible pointer type
|
|
||||||
xec.c: In function `s_cmd':
|
|
||||||
xec.c:234: warning: passing arg 1 of `bufread' from incompatible pointer type
|
|
||||||
xec.c:243: warning: passing arg 1 of `bufread' from incompatible pointer type
|
|
||||||
xec.c: In function `display':
|
|
||||||
xec.c:401: warning: passing arg 1 of `bufread' from incompatible pointer type
|
|
||||||
|
|
@ -1,185 +0,0 @@
|
||||||
#include "sam.h"
|
|
||||||
|
|
||||||
Rune samname[] = L"~~sam~~";
|
|
||||||
|
|
||||||
Rune *left[]= {
|
|
||||||
L"{[(<«",
|
|
||||||
L"\n",
|
|
||||||
L"'\"`",
|
|
||||||
0
|
|
||||||
};
|
|
||||||
Rune *right[]= {
|
|
||||||
L"}])>»",
|
|
||||||
L"\n",
|
|
||||||
L"'\"`",
|
|
||||||
0
|
|
||||||
};
|
|
||||||
|
|
||||||
char RSAM[] = "sam";
|
|
||||||
char SAMTERM[] = "/bin/aux/samterm";
|
|
||||||
char HOME[] = "HOME";
|
|
||||||
char TMPDIR[] = "/tmp";
|
|
||||||
char SH[] = "rc";
|
|
||||||
char SHPATH[] = "/bin/rc";
|
|
||||||
char RX[] = "rx";
|
|
||||||
char RXPATH[] = "/bin/rx";
|
|
||||||
char SAMSAVECMD[] = "/bin/rc\n/sys/lib/samsave";
|
|
||||||
|
|
||||||
void
|
|
||||||
dprint(char *z, ...)
|
|
||||||
{
|
|
||||||
char buf[BLOCKSIZE];
|
|
||||||
va_list arg;
|
|
||||||
|
|
||||||
va_start(arg, z);
|
|
||||||
vseprint(buf, &buf[BLOCKSIZE], z, arg);
|
|
||||||
va_end(arg);
|
|
||||||
termwrite(buf);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
print_ss(char *s, String *a, String *b)
|
|
||||||
{
|
|
||||||
dprint("?warning: %s: `%.*S' and `%.*S'\n", s, a->n, a->s, b->n, b->s);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
print_s(char *s, String *a)
|
|
||||||
{
|
|
||||||
dprint("?warning: %s `%.*S'\n", s, a->n, a->s);
|
|
||||||
}
|
|
||||||
|
|
||||||
char*
|
|
||||||
getuser(void)
|
|
||||||
{
|
|
||||||
static char user[64];
|
|
||||||
int fd;
|
|
||||||
|
|
||||||
if(user[0] == 0){
|
|
||||||
fd = open("/dev/user", 0);
|
|
||||||
if(fd<0 || read(fd, user, sizeof user-1)<=0)
|
|
||||||
strcpy(user, "none");
|
|
||||||
close(fd);
|
|
||||||
}
|
|
||||||
return user;
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
statfile(char *name, ulong *dev, uvlong *id, long *time, long *length, long *appendonly)
|
|
||||||
{
|
|
||||||
Dir *dirb;
|
|
||||||
|
|
||||||
dirb = dirstat(name);
|
|
||||||
if(dirb == nil)
|
|
||||||
return -1;
|
|
||||||
if(dev)
|
|
||||||
*dev = dirb->type|(dirb->dev<<16);
|
|
||||||
if(id)
|
|
||||||
*id = dirb->qid.path;
|
|
||||||
if(time)
|
|
||||||
*time = dirb->mtime;
|
|
||||||
if(length)
|
|
||||||
*length = dirb->length;
|
|
||||||
if(appendonly)
|
|
||||||
*appendonly = dirb->mode & DMAPPEND;
|
|
||||||
free(dirb);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
statfd(int fd, ulong *dev, uvlong *id, long *time, long *length, long *appendonly)
|
|
||||||
{
|
|
||||||
Dir *dirb;
|
|
||||||
|
|
||||||
dirb = dirfstat(fd);
|
|
||||||
if(dirb == nil)
|
|
||||||
return -1;
|
|
||||||
if(dev)
|
|
||||||
*dev = dirb->type|(dirb->dev<<16);
|
|
||||||
if(id)
|
|
||||||
*id = dirb->qid.path;
|
|
||||||
if(time)
|
|
||||||
*time = dirb->mtime;
|
|
||||||
if(length)
|
|
||||||
*length = dirb->length;
|
|
||||||
if(appendonly)
|
|
||||||
*appendonly = dirb->mode & DMAPPEND;
|
|
||||||
free(dirb);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
notifyf(void *a, char *s)
|
|
||||||
{
|
|
||||||
USED(a);
|
|
||||||
if(bpipeok && strcmp(s, "sys: write on closed pipe") == 0)
|
|
||||||
noted(NCONT);
|
|
||||||
if(strcmp(s, "interrupt") == 0)
|
|
||||||
noted(NCONT);
|
|
||||||
panicking = 1;
|
|
||||||
rescue();
|
|
||||||
noted(NDFLT);
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
newtmp(int num)
|
|
||||||
{
|
|
||||||
int i, fd;
|
|
||||||
static char tempnam[30];
|
|
||||||
|
|
||||||
i = getpid();
|
|
||||||
do
|
|
||||||
snprint(tempnam, sizeof tempnam, "%s/%d%.4s%dsam", TMPDIR, num, getuser(), i++);
|
|
||||||
while(access(tempnam, 0) == 0);
|
|
||||||
fd = create(tempnam, ORDWR|OCEXEC|ORCLOSE, 0000);
|
|
||||||
if(fd < 0){
|
|
||||||
remove(tempnam);
|
|
||||||
fd = create(tempnam, ORDWR|OCEXEC|ORCLOSE, 0000);
|
|
||||||
}
|
|
||||||
return fd;
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
waitfor(int pid)
|
|
||||||
{
|
|
||||||
int msg;
|
|
||||||
Waitmsg *w;
|
|
||||||
|
|
||||||
while((w = wait()) != nil){
|
|
||||||
if(w->pid != pid){
|
|
||||||
free(w);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
msg = (w->msg[0] != '\0');
|
|
||||||
free(w);
|
|
||||||
return msg;
|
|
||||||
}
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
samerr(char *buf)
|
|
||||||
{
|
|
||||||
sprint(buf, "%s/sam.err", TMPDIR);
|
|
||||||
}
|
|
||||||
|
|
||||||
void*
|
|
||||||
emalloc(ulong n)
|
|
||||||
{
|
|
||||||
void *p;
|
|
||||||
|
|
||||||
p = malloc(n);
|
|
||||||
if(p == 0)
|
|
||||||
panic("malloc fails");
|
|
||||||
memset(p, 0, n);
|
|
||||||
return p;
|
|
||||||
}
|
|
||||||
|
|
||||||
void*
|
|
||||||
erealloc(void *p, ulong n)
|
|
||||||
{
|
|
||||||
p = realloc(p, n);
|
|
||||||
if(p == 0)
|
|
||||||
panic("realloc fails");
|
|
||||||
return p;
|
|
||||||
}
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue