ag@cbmvax.UUCP (Keith Gabryelski) (05/03/89)
I have been receiving a steady reply for these since I posted the message.
Here are the diffs/coff unexec code to bring adventure up on a
SysV system.
Pax, Keith
#! /bin/sh
# This is a shell archive, meaning:
# 1. Remove everything above the #! /bin/sh line.
# 2. Save the resulting text in a file.
# 3. Execute the file with /bin/sh (not csh) to create the files:
# README
# DIFFS
# unexec.c
# This archive created: Wed Apr 26 20:42:57 1989
export PATH; PATH=/bin:$PATH
if test -f 'README'
then
echo shar: will not over-write existing file "'README'"
else
cat << \SHAR_EOF > 'README'
Apply the diffs in the file DIFFS and add `-DAMIX' to CFLAGS in
the makefile.
Pax, Keith
SHAR_EOF
fi # end of overwriting check
if test -f 'DIFFS'
then
echo shar: will not over-write existing file "'DIFFS'"
else
cat << \SHAR_EOF > 'DIFFS'
*** /p/tahoe/usr/src/games/adventure/Makefile Thu Jul 14 21:24:46 1988
--- Makefile Thu Apr 6 17:56:55 1989
***************
*** 5,14
#
# @(#)Makefile 4.7 (Berkeley) 9/21/87
#
! CFLAGS= -O
! LIBC= /lib/libc.a
! SRCS= done.c init.c io.c main.c save.c subr.c vocab.c wizard.c
! OBJS= done.o init.o io.o main.o save.o subr.o vocab.o wizard.o
advent: ${OBJS} ${LIBC}
${CC} -n ${CFLAGS} ${OBJS}
--- 5,16 -----
#
# @(#)Makefile 4.7 (Berkeley) 9/21/87
#
! CFLAGS= -g
! SHELL=/bin/sh
! GAMESDIR=$(ROOT)/usr/games
! LIBC= $(ROOT)/lib/libc.a
! SRCS= done.c init.c io.c main.c save.c subr.c vocab.c wizard.c unexec.c
! OBJS= done.o init.o io.o main.o save.o subr.o vocab.o wizard.o unexec.o
advent: ${OBJS} ${LIBC}
${CC} -n ${CFLAGS} ${OBJS}
***************
*** 16,22
echo y | ./a.out
save.o: save.c # vax C optimizer bug - infinite loop
! ${CC} -c save.c
clean: FRC
rm -f ${OBJS} core advent a.out
--- 18,24 -----
echo y | ./a.out
save.o: save.c # vax C optimizer bug - infinite loop
! ${CC} $(CFLAGS) -Dindex=strchr -c save.c
clean: FRC
rm -f ${OBJS} core advent a.out
***************
*** 24,32
depend: FRC
mkdep ${CFLAGS} ${SRCS}
! install: FRC
! install -s -o games -g bin -m 700 advent ${DESTDIR}/usr/games/hide/adventure
! (cd ${DESTDIR}/usr/games; rm -f adventure; ln -s dm adventure; chown games.bin adventure)
lint: FRC
lint ${CFLAGS} ${SRCS}
--- 26,34 -----
depend: FRC
mkdep ${CFLAGS} ${SRCS}
! install: advent
! cpset advent $(GAMESDIR) 755 games games
! strip $(GAMESDIR)/advent
lint: FRC
lint ${CFLAGS} ${SRCS}
***************
*** 34,39
tags: FRC
ctags ${SRCS}
FRC:
# DO NOT DELETE THIS LINE -- mkdep uses it.
--- 36,44 -----
tags: FRC
ctags ${SRCS}
+ TAGS: FRC
+ etags ${SRCS}
+
FRC:
# DO NOT DELETE THIS LINE -- mkdep uses it.
***************
*** 41,47
done.o: done.c hdr.h
init.o: init.c hdr.h
! io.o: io.c hdr.h /usr/include/stdio.h
main.o: main.c hdr.h
save.o: save.c /usr/include/a.out.h /usr/include/sys/exec.h
subr.o: subr.c hdr.h
--- 46,52 -----
done.o: done.c hdr.h
init.o: init.c hdr.h
! io.o: io.c hdr.h
main.o: main.c hdr.h
save.o: save.c
subr.o: subr.c hdr.h
***************
*** 43,49
init.o: init.c hdr.h
io.o: io.c hdr.h /usr/include/stdio.h
main.o: main.c hdr.h
! save.o: save.c /usr/include/a.out.h /usr/include/sys/exec.h
subr.o: subr.c hdr.h
vocab.o: vocab.c hdr.h
wizard.o: wizard.c hdr.h
--- 48,54 -----
init.o: init.c hdr.h
io.o: io.c hdr.h
main.o: main.c hdr.h
! save.o: save.c
subr.o: subr.c hdr.h
vocab.o: vocab.c hdr.h
wizard.o: wizard.c hdr.h
*** /p/tahoe/usr/src/games/adventure/hdr.h Tue Jun 8 22:36:25 1982
--- hdr.h Wed Mar 22 11:38:20 1989
***************
*** 18,24
/* hdr.h: included by c advent files */
extern int setup; /* changed by savec & init */
! int datfd; /* message file descriptor */
int delhit;
int yea;
--- 18,24 -----
/* hdr.h: included by c advent files */
extern int setup; /* changed by savec & init */
! extern int datfd; /* message file descriptor */
int delhit;
int yea;
*** /p/tahoe/usr/src/games/adventure/init.c Tue Jun 8 22:36:22 1982
--- init.c Thu Apr 6 18:45:13 1989
***************
*** 27,42
}
else exit(0);
printf("Save succeeded. Adding messages.\n");
! adfd=open("advent",1);
! lseek(adfd,0L,2);
! close(datfd);
! if (fork()==0) /* child process */
! { close(1);
! dup(adfd); /* output goes to advent file */
! execl("/bin/cat","cat",TMPFILE,0);
! printf("unable to find /bin/cat\n");
! }
! wait(&stat);
unlink(TMPFILE);
printf("Advent is ready.\n");
exit(0);
--- 27,33 -----
}
else exit(0);
printf("Save succeeded. Adding messages.\n");
! system("cat tmp.foo.baz >> advent");
unlink(TMPFILE);
printf("Advent is ready.\n");
exit(0);
*** /p/tahoe/usr/src/games/adventure/main.c Tue Jun 8 22:36:23 1982
--- main.c Mon Mar 27 23:49:14 1989
***************
*** 306,311
case 30: /* suspend=8300 */
spk=201;
if (demo) goto l2011;
printf("I can suspend your adventure for you so");
printf(" you can resume later, but\n");
printf("you will have to wait at least");
--- 306,312 -----
case 30: /* suspend=8300 */
spk=201;
if (demo) goto l2011;
+ #ifdef BOGUS_LATENCY_CHECK_THAT_TWAS_MADE_FOR_WIMPS_BY_WIMPS
printf("I can suspend your adventure for you so");
printf(" you can resume later, but\n");
printf("you will have to wait at least");
***************
*** 311,316
printf("you will have to wait at least");
printf(" %d minutes before continuing.",latncy);
if (!yes(200,54,54)) goto l2012;
datime(&saved,&savet);
setup = -1;
ciao(argv[0]);
--- 312,318 -----
printf("you will have to wait at least");
printf(" %d minutes before continuing.",latncy);
if (!yes(200,54,54)) goto l2012;
+ #endif
datime(&saved,&savet);
setup = -1;
ciao(argv[0]);
*** /p/tahoe/usr/src/games/adventure/save.c Mon Nov 17 20:52:28 1986
--- save.c Mon Mar 27 23:36:22 1989
***************
*** 15,21
save(cmdfile,outfile) /* save core image */
char *cmdfile,*outfile;
! { register char *c;
register int i,fd;
int fdaout;
struct exec header;
--- 15,25 -----
save(cmdfile,outfile) /* save core image */
char *cmdfile,*outfile;
! {
! #ifdef AMIX
! unexec(cmdfile, outfile);
! #else /* !AMIX */
! register char *c;
register int i,fd;
int fdaout;
struct exec header;
***************
*** 95,100
write(fd,buff,counter);
write(fd,c,header.a_data); /* write all data in 1 glob */
close(fd);
}
#define NULL 0
--- 99,105 -----
write(fd,buff,counter);
write(fd,c,header.a_data); /* write all data in 1 glob */
close(fd);
+ #endif /* !AMIX */
}
#define NULL 0
***************
*** 105,111
char *command;
{
char *pathstr;
- register char *cp;
char fname[128];
int fd;
--- 110,115 -----
char *command;
{
char *pathstr;
char fname[128];
register char *cp;
int fd;
***************
*** 107,112
char *pathstr;
register char *cp;
char fname[128];
int fd;
if ((pathstr = getenv("PATH")) == NULL)
--- 111,117 -----
{
char *pathstr;
char fname[128];
+ register char *cp;
int fd;
if ((pathstr = getenv("PATH")) == NULL)
***************
*** 110,116
int fd;
if ((pathstr = getenv("PATH")) == NULL)
! pathstr = ":/bin:/usr/bin";
cp = index(command, '/')? "": pathstr;
do {
--- 115,121 -----
int fd;
if ((pathstr = getenv("PATH")) == NULL)
! pathstr = ":/bin:/usr/bin:/usr/games";
cp = index(command, '/')? "": pathstr;
do {
*** /p/tahoe/usr/src/games/adventure/wizard.c Tue Jun 8 22:36:25 1982
--- wizard.c Mon Mar 27 23:46:07 1989
***************
*** 26,32
}
start(n)
! { int d,t,delay;
datime(&d,&t);
delay=(d-saved)*1440+(t-savet); /* good for about a month */
if (delay>=latncy || setup >= 0)
--- 26,34 -----
}
start(n)
! {
! #ifdef BOGUS_LATENCY_CHECK_THAT_WAS_MADE_FOR_WIMPS_BY_WIMPS
! int d,t,delay;
datime(&d,&t);
delay=(d-saved)*1440+(t-savet); /* good for about a month */
if (delay>=latncy || setup >= 0)
***************
*** 43,48
{ mspeak(9);
exit(0);
}
saved = -1;
return(FALSE);
}
--- 45,51 -----
{ mspeak(9);
exit(0);
}
+ #endif
saved = -1;
return(FALSE);
}
SHAR_EOF
fi # end of overwriting check
if test -f 'unexec.c'
then
echo shar: will not over-write existing file "'unexec.c'"
else
cat << \SHAR_EOF > 'unexec.c'
#include <a.out.h>
#include <fcntl.h>
extern filesize;
unexec(oldname, newname)
char *oldname, *newname;
{
int ifd, ofd, i;
long text_vaddr, data_vaddr;
struct filehdr filehdr;
struct aouthdr aouthdr;
struct scnhdr scnhdr;
if((ifd=open(oldname, O_RDONLY)) < 0)
{
char foo[512];
sprintf(foo, "/usr/games/%s", oldname);
if((ifd=open(foo, O_RDONLY)) < 0)
{
perror("open");
return 1;
}
}
if (read(ifd, &filehdr, sizeof filehdr) < sizeof filehdr)
{
perror("read");
return 1;
}
if (filehdr.f_opthdr != sizeof (struct aouthdr))
{
perror("weird optional header; lseek help");
return 1;
}
filehdr.f_symptr = 0;
filehdr.f_nsyms = 0;
if((ofd=open(newname, O_WRONLY|O_CREAT|O_TRUNC, 0755)) < 0)
{
perror("open");
return 1;
}
if (write(ofd, &filehdr, sizeof filehdr) < sizeof filehdr)
{
perror("write");
return 1;
}
if (read(ifd, &aouthdr, sizeof aouthdr) < sizeof aouthdr)
{
perror("read");
return 1;
}
aouthdr.bsize = 0;
aouthdr.dsize = sbrk(0) - aouthdr.data_start;
if (write(ofd, &aouthdr, sizeof aouthdr) < sizeof aouthdr)
{
perror("write");
return 1;
}
for (i=0; i < filehdr.f_nscns; ++i)
{
if (read(ifd, &scnhdr, sizeof scnhdr) < sizeof scnhdr)
{
perror("read");
return 1;
}
if (!strncmp(scnhdr.s_name, _TEXT, sizeof (scnhdr.s_name)))
text_vaddr = scnhdr.s_vaddr;
else if (!strncmp(scnhdr.s_name, _DATA, sizeof (scnhdr.s_name)))
{
data_vaddr = scnhdr.s_vaddr;
filesize = scnhdr.s_scnptr+aouthdr.dsize;
scnhdr.s_size = aouthdr.dsize;
} else if (!strncmp(scnhdr.s_name, _BSS, sizeof (scnhdr.s_name)))
scnhdr.s_size = 0;
scnhdr.s_relptr = scnhdr.s_lnnoptr = 0;
scnhdr.s_nreloc = scnhdr.s_nlnno = 0;
if (write(ofd, &scnhdr, sizeof scnhdr) < sizeof scnhdr)
{
perror("write");
return 1;
}
}
lseek(ofd, aouthdr.text_start, 0);
if (write(ofd, text_vaddr, aouthdr.tsize) < aouthdr.tsize)
{
perror("text write");
return 1;
}
lseek(ofd, aouthdr.data_start, 0);
if (write(ofd, data_vaddr, aouthdr.dsize) < aouthdr.dsize)
{
perror("data write");
return 1;
}
close(ofd);
close(ifd);
return 0;
}
SHAR_EOF
fi # end of overwriting check
# End of shell archive
exit 0
--
This article is freely ditributable under the terms of the GNU License.
Keith Gabryelski ag@cbmvax.commodore.com