Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2ec255bb5e | ||
|
|
cd445fe22a | ||
|
|
64b1205e6c | ||
|
|
94881e6d4a | ||
|
|
6677a8c8e0 | ||
|
|
255ad2ab37 | ||
|
|
7dc782dd1a | ||
|
|
e9eb2c4f8b |
76
Makefile
76
Makefile
@@ -16,7 +16,6 @@ usage:
|
||||
@echo " make depend # Generate required .depend files"
|
||||
@echo " make gnu-includes # Install include files for GCC"
|
||||
@echo " make gnu-libraries # Compile and install libraries for GCC"
|
||||
@echo " make clang-libraries # Compile and install libraries for GCC with clang"
|
||||
@echo " make clean # Remove all compiler results"
|
||||
@echo ""
|
||||
@echo "Run 'make' in tools/ to create a new MINIX configuration."
|
||||
@@ -31,72 +30,63 @@ usage:
|
||||
#
|
||||
# etcfiles has to be done first.
|
||||
.if ${COMPILER_TYPE} == "ack"
|
||||
world: mkfiles includes depend libraries install etcforce
|
||||
world: mkfiles includes depend libraries install
|
||||
.elif ${COMPILER_TYPE} == "gnu"
|
||||
world: mkfiles includes depend gnu-libraries install etcforce
|
||||
world: mkfiles includes depend gnu-libraries install
|
||||
.endif
|
||||
|
||||
mkfiles:
|
||||
make -C share/mk install
|
||||
cp etc/mk/*.mk /etc/mk/
|
||||
|
||||
includes:
|
||||
$(MAKE) -C include includes
|
||||
$(MAKE) -C lib includes
|
||||
cd include && $(MAKE) includes
|
||||
|
||||
libraries: includes
|
||||
$(MAKE) -C lib build_ack
|
||||
libraries:
|
||||
cd lib && sh ack_build.sh obj depend all install
|
||||
|
||||
MKHEADERS411=/usr/gnu/libexec/gcc/i386-pc-minix/4.1.1/install-tools/mkheaders
|
||||
MKHEADERS443=/usr/gnu/libexec/gcc/i686-pc-minix/4.4.3/install-tools/mkheaders
|
||||
MKHEADERS443_PKGSRC=/usr/pkg/gcc44/libexec/gcc/i686-pc-minix/4.4.3/install-tools/mkheaders
|
||||
gnu-includes: includes
|
||||
SHELL=/bin/sh; if [ -f $(MKHEADERS411) ] ; then sh -e $(MKHEADERS411) ; fi
|
||||
SHELL=/bin/sh; if [ -f $(MKHEADERS443) ] ; then sh -e $(MKHEADERS443) ; fi
|
||||
SHELL=/bin/sh; if [ -f $(MKHEADERS443_PKGSRC) ] ; then sh -e $(MKHEADERS443_PKGSRC) ; fi
|
||||
|
||||
gnu-libraries: gnu-includes
|
||||
$(MAKE) -C lib build_gnu
|
||||
gnu-libraries:
|
||||
cd lib && sh gnu_build.sh obj depend all install
|
||||
|
||||
clang-libraries: includes
|
||||
$(MAKE) -C lib build_clang
|
||||
|
||||
commands: includes libraries
|
||||
$(MAKE) -C commands all
|
||||
commands:
|
||||
cd commands && $(MAKE) all
|
||||
|
||||
depend::
|
||||
$(MAKE) -C boot depend
|
||||
$(MAKE) -C commands depend
|
||||
$(MAKE) -C kernel depend
|
||||
$(MAKE) -C servers depend
|
||||
$(MAKE) -C drivers depend
|
||||
cd boot && $(MAKE) depend
|
||||
cd commands && $(MAKE) depend
|
||||
cd kernel && $(MAKE) depend
|
||||
cd servers && $(MAKE) depend
|
||||
cd drivers && $(MAKE) depend
|
||||
|
||||
etcfiles::
|
||||
$(MAKE) -C etc install
|
||||
|
||||
etcforce::
|
||||
$(MAKE) -C etc installforce
|
||||
cd etc && $(MAKE) install
|
||||
|
||||
all::
|
||||
$(MAKE) -C boot all
|
||||
$(MAKE) -C commands all
|
||||
$(MAKE) -C tools all
|
||||
cd boot && $(MAKE) all
|
||||
cd commands && $(MAKE) all
|
||||
cd tools && $(MAKE) all
|
||||
|
||||
install::
|
||||
$(MAKE) -C boot install
|
||||
$(MAKE) -C man install makedb
|
||||
$(MAKE) -C commands install
|
||||
$(MAKE) -C share install
|
||||
$(MAKE) -C tools install
|
||||
cd boot && $(MAKE) install
|
||||
cd man && $(MAKE) install makedb
|
||||
cd commands && $(MAKE) install
|
||||
cd share && $(MAKE) install
|
||||
cd tools && $(MAKE) install
|
||||
|
||||
clean::
|
||||
$(MAKE) -C boot clean
|
||||
$(MAKE) -C commands clean
|
||||
$(MAKE) -C tools clean
|
||||
$(MAKE) -C lib clean_gnu
|
||||
$(MAKE) -C lib clean_ack
|
||||
$(MAKE) -C test clean
|
||||
cd boot && $(MAKE) clean
|
||||
cd commands && $(MAKE) clean
|
||||
cd tools && $(MAKE) clean
|
||||
cd lib && sh ack_build.sh clean
|
||||
cd lib && sh gnu_build.sh clean
|
||||
cd test && $(MAKE) clean
|
||||
|
||||
cleandepend::
|
||||
$(MAKE) -C boot cleandepend
|
||||
$(MAKE) -C commands cleandepend
|
||||
$(MAKE) -C tools cleandepend
|
||||
cd boot && $(MAKE) cleandepend
|
||||
cd commands && $(MAKE) cleandepend
|
||||
cd tools && $(MAKE) cleandepend
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
CC:=${CC:C/^gcc/cc/}
|
||||
COMPILER_TYPE:=ack
|
||||
|
||||
PROGS= bootblock cdbootblock boot masterboot \
|
||||
jumpboot installboot edparams dosboot mkfile
|
||||
PROGS= bootblock cdbootblock bootexec boot masterboot \
|
||||
jumpboot installboot edparams
|
||||
|
||||
SRCS.bootblock= bootblock.s
|
||||
CPPFLAGS.bootblock.s= ${I86CPPFLAGS}
|
||||
@@ -19,20 +19,19 @@ LDFLAGS.cdbootblock= ${I86LDFLAGS}
|
||||
BINDIR.cdbootblock= /usr/mdec
|
||||
MAN.cdbootblock=
|
||||
|
||||
SRCS.boot= boothead.s boot.c bootimage.c rawfs86.c
|
||||
SRCS.bootexec= boothead.s boot.c bootimage.c rawfs86.c
|
||||
CPPFLAGS.boothead.s= ${I86CPPFLAGS}
|
||||
CPPFLAGS.boot.c= ${I86CPPFLAGS}
|
||||
CPPFLAGS.bootimage.c= ${I86CPPFLAGS}
|
||||
CPPFLAGS.rawfs86.c= ${I86CPPFLAGS}
|
||||
LDFLAGS.boot= ${I86LDFLAGS}
|
||||
DPADD.boot= ${LIBSYS}
|
||||
LDADD.boot= -lsys
|
||||
BINDIR.boot= /usr/mdec
|
||||
MAN.boot=
|
||||
LDFLAGS.bootexec= ${I86LDFLAGS}
|
||||
DPADD.bootexec= ${LIBSYS}
|
||||
LDADD.bootexec= -lsys
|
||||
BINDIR.bootexec= /usr/mdec
|
||||
MAN.bootexec=
|
||||
|
||||
realall: .PHONY bootsize
|
||||
bootsize: boot
|
||||
${INSTALL} -S 22kb boot
|
||||
BINDIR.boot= /usr/mdec
|
||||
MAN.boot=
|
||||
|
||||
SRCS.masterboot= masterboot.s
|
||||
CPPFLAGS.masterboot.s= ${I86CPPFLAGS}
|
||||
@@ -55,35 +54,18 @@ CPPFLAGS.edparams.c= -DUNIX
|
||||
BINDIR.edparams= /usr/bin
|
||||
MAN.edparams=
|
||||
|
||||
SRCS.dosboot= doshead.s dosboot.o bootimage.o rawfs86.o
|
||||
CPPFLAGS.dosboot.c= -DDOS $(I86CPPFLAGS)
|
||||
LDADD.dosboot= ${I86LDFLAGS} -lsys
|
||||
BINDIR.dosboot= /usr/mdec
|
||||
CPPFLAGS.doshead.s= -mi386
|
||||
MAN.dosboot=
|
||||
|
||||
SRCS.mkfile= mkfhead.s mkfile.c
|
||||
CPPFLAGS.mkfile.s= ${I86CPPFLAGS}
|
||||
LDADD.mkfile= ${I86LDFLAGS} -lsys
|
||||
BINDIR.mkfile= /usr/mdec
|
||||
MAN.mkfile=
|
||||
|
||||
rawfs86.c: rawfs.c
|
||||
ln -f rawfs.c rawfs86.c
|
||||
|
||||
edparams.c: boot.c
|
||||
ln -f boot.c edparams.c
|
||||
|
||||
dosboot.c: boot.c
|
||||
ln -f boot.c dosboot.c
|
||||
|
||||
cdbootblock.s: bootblock.s
|
||||
ln -f bootblock.s cdbootblock.s
|
||||
|
||||
mkfile.com: mkfile
|
||||
|
||||
boot.com: dosboot
|
||||
./a.out2com dosboot boot.com
|
||||
boot: bootexec
|
||||
install -S 22kb bootexec
|
||||
cp bootexec boot
|
||||
|
||||
CPPFLAGS= -I${MINIXSRCDIR}
|
||||
AFLAGS= -I${MINIXSRCDIR}
|
||||
@@ -92,6 +74,6 @@ I86LDFLAGS= -mi86 -Was-ncc -.o -com
|
||||
|
||||
STRIPFLAG= -s
|
||||
|
||||
CLEANFILES+= rawfs86.c edparams.c cdbootblock.s dosboot.c
|
||||
CLEANFILES+= rawfs86.c edparams.c cdbootblock.s
|
||||
|
||||
.include <bsd.prog.mk>
|
||||
.include <minix.prog.mk>
|
||||
|
||||
66
boot/boot.c
66
boot/boot.c
@@ -194,7 +194,7 @@ void readblock(off_t blk, char *buf, int block_size)
|
||||
}
|
||||
|
||||
#define istty (1)
|
||||
#define alarm(n) do { } while(0)
|
||||
#define alarm(n) (0)
|
||||
|
||||
#endif /* BIOS */
|
||||
|
||||
@@ -538,30 +538,11 @@ static void initialize(void)
|
||||
* done to get out of the way of Minix, and to put the data area
|
||||
* cleanly inside a 64K chunk if using BIOS I/O (no DMA problems).
|
||||
*/
|
||||
u32_t oldaddr;
|
||||
u32_t memend;
|
||||
u32_t newaddr;
|
||||
u32_t oldaddr= caddr;
|
||||
u32_t memend= mem[0].base + mem[0].size;
|
||||
u32_t newaddr= (memend - runsize) & ~0x0000FL;
|
||||
#if !DOS
|
||||
u32_t dma64k;
|
||||
#endif
|
||||
|
||||
if (mem_entries) {
|
||||
int i, j;
|
||||
j = 0;
|
||||
for(i = 0; i < mem_entries ; i++) {
|
||||
if (j < 3 && emem[i].type == 1 && !emem[i].base_hi) {
|
||||
mem[j].base = emem[i].base_lo;
|
||||
mem[j].size = emem[i].size_lo;
|
||||
j++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
oldaddr= caddr;
|
||||
memend= mem[0].base + mem[0].size;
|
||||
newaddr= (memend - runsize) & ~0x0000FL;
|
||||
#if !DOS
|
||||
dma64k= (memend - 1) & ~0x0FFFFL;
|
||||
u32_t dma64k= (memend - 1) & ~0x0FFFFL;
|
||||
|
||||
|
||||
/* Check if data segment crosses a 64K boundary. */
|
||||
@@ -591,7 +572,7 @@ static void initialize(void)
|
||||
* and also keep the BIOS data area safe (1.5K), plus a bit extra for
|
||||
* where we may have to put a.out headers for older kernels.
|
||||
*/
|
||||
if ((mon_return = (mem[1].size > 512*1024L))) mem[0].size = newaddr;
|
||||
if (mon_return = (mem[1].size > 512*1024L)) mem[0].size = newaddr;
|
||||
mem[0].base += 2048;
|
||||
mem[0].size -= 2048;
|
||||
|
||||
@@ -1270,10 +1251,10 @@ static void apm_perror(char *label, u16_t ax)
|
||||
printf("%s: %s\n", label, str);
|
||||
}
|
||||
|
||||
#define apm_printf(args) printf args
|
||||
#define apm_printf printf
|
||||
#else
|
||||
#define apm_perror(label, ax) ((void)0)
|
||||
#define apm_printf(args)
|
||||
#define apm_printf
|
||||
#endif
|
||||
|
||||
static void off(void)
|
||||
@@ -1295,7 +1276,7 @@ static void off(void)
|
||||
}
|
||||
if (be.bx != (('P' << 8) | 'M'))
|
||||
{
|
||||
apm_printf(("APM signature not found (got 0x%04x)\n", be.bx));
|
||||
apm_printf("APM signature not found (got 0x%04x)\n", be.bx);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1305,13 +1286,13 @@ static void off(void)
|
||||
al= be.ax & 0xff;
|
||||
if (al > 9)
|
||||
al= (al >> 4)*10 + (al & 0xf);
|
||||
apm_printf(("APM version %u.%u%s%s%s%s%s\n",
|
||||
apm_printf("APM version %u.%u%s%s%s%s%s\n",
|
||||
ah, al,
|
||||
(be.cx & 0x1) ? ", 16-bit PM" : "",
|
||||
(be.cx & 0x2) ? ", 32-bit PM" : "",
|
||||
(be.cx & 0x4) ? ", CPU-Idle" : "",
|
||||
(be.cx & 0x8) ? ", APM-disabled" : "",
|
||||
(be.cx & 0x10) ? ", APM-disengaged" : ""));
|
||||
(be.cx & 0x10) ? ", APM-disengaged" : "");
|
||||
|
||||
/* Connect */
|
||||
be.ax= 0x5301; /* APM, Real mode interface connect */
|
||||
@@ -1343,7 +1324,7 @@ static void off(void)
|
||||
al= be.ax & 0xff;
|
||||
if (al > 9)
|
||||
al= (al >> 4)*10 + (al & 0xf);
|
||||
apm_printf(("Got APM connection version %u.%u\n", ah, al));
|
||||
apm_printf("Got APM connection version %u.%u\n", ah, al);
|
||||
|
||||
/* Enable */
|
||||
be.ax= 0x5308; /* APM, Enable/disable power management */
|
||||
@@ -1373,8 +1354,8 @@ static void off(void)
|
||||
goto disco;
|
||||
}
|
||||
|
||||
apm_printf(("Power off sequence successfully completed.\n\n"));
|
||||
apm_printf(("Ha, ha, just kidding!\n"));
|
||||
apm_printf("Power off sequence successfully completed.\n\n");
|
||||
apm_printf("Ha, ha, just kidding!\n");
|
||||
|
||||
disco:
|
||||
/* Disconnect */
|
||||
@@ -1491,11 +1472,6 @@ static void ctty(char *line)
|
||||
printf("No serial line support under DOS\n");
|
||||
}
|
||||
|
||||
reset()
|
||||
{
|
||||
printf("No reset support under DOS\n");
|
||||
}
|
||||
|
||||
#endif /* DOS */
|
||||
#endif /* BIOS */
|
||||
|
||||
@@ -1631,8 +1607,6 @@ void menu(void)
|
||||
case USERFUN:
|
||||
case SELECT:
|
||||
if (c == e->arg[0]) choice= e->value;
|
||||
case NOFUN:
|
||||
break;
|
||||
}
|
||||
}
|
||||
} while (choice == nil);
|
||||
@@ -1831,7 +1805,7 @@ static void execute(void)
|
||||
putch('\n');
|
||||
break;
|
||||
case 'v':
|
||||
printf("%s", version);
|
||||
printf(version);
|
||||
break;
|
||||
case 'c':
|
||||
clear_screen();
|
||||
@@ -1904,13 +1878,6 @@ static void execute(void)
|
||||
case R_OFF: off(); ok= 1; break;
|
||||
case R_CTTY: ctty(nil); ok= 1; break;
|
||||
case R_RESET: reset(); ok= 1; break;
|
||||
|
||||
case R_NULL:
|
||||
case R_ECHO:
|
||||
case R_TRAP:
|
||||
case R_UNSET:
|
||||
/* Handled after the switch. */
|
||||
break;
|
||||
}
|
||||
|
||||
/* Command to check bootparams: */
|
||||
@@ -1990,7 +1957,7 @@ void boot(void)
|
||||
|
||||
#if UNIX
|
||||
|
||||
int main(int argc, char **argv)
|
||||
void main(int argc, char **argv)
|
||||
/* Do not load or start anything, just edit parameters. */
|
||||
{
|
||||
int i;
|
||||
@@ -2062,7 +2029,6 @@ int main(int argc, char **argv)
|
||||
monitor();
|
||||
}
|
||||
exit(0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
reset() { }
|
||||
|
||||
11
boot/boot.h
11
boot/boot.h
@@ -67,18 +67,7 @@ typedef struct { /* One chunk of free memory. */
|
||||
u32_t size; /* Number of bytes. */
|
||||
} memory;
|
||||
|
||||
typedef struct { /* One chunk of free memory. */
|
||||
u32_t base_lo; /* Start byte. */
|
||||
u32_t base_hi;
|
||||
u32_t size_lo; /* Number of bytes. */
|
||||
u32_t size_hi; /* Number of bytes. */
|
||||
u32_t type;
|
||||
u32_t acpi_attrs;
|
||||
} e820_memory;
|
||||
|
||||
EXTERN memory mem[3]; /* List of available memory. */
|
||||
EXTERN e820_memory emem[16]; /* List of available memory. */
|
||||
EXTERN int mem_entries;
|
||||
EXTERN int mon_return; /* Monitor stays in memory? */
|
||||
EXTERN int cdbooted; /* Did we boot from CD? (Set by boothead.s.) */
|
||||
|
||||
|
||||
@@ -41,8 +41,6 @@
|
||||
.extern _rem_part ! To pass partition info
|
||||
.extern _k_flags ! Special kernel flags
|
||||
.extern _mem ! Free memory list
|
||||
.extern _emem ! Free memory list for E820
|
||||
.extern _mem_entries ! Free memory E820 list entries
|
||||
.extern _cdbooted ! Whether we booted from CD
|
||||
.extern _cddevice ! Whether we booted from CD
|
||||
|
||||
@@ -145,64 +143,6 @@ sepID:
|
||||
mov _runsize+0, ax
|
||||
mov _runsize+2, dx ! 32 bit size of this process
|
||||
|
||||
!Determine memory using the 0xE820 BIOS function if available
|
||||
mov di, #_emem
|
||||
mov 20(di), #1 ! force a valid ACPI 3.X entry
|
||||
|
||||
.data1 o32
|
||||
xor bx, bx ! zero EBX
|
||||
xor bp, bp !zero bp
|
||||
.data1 o32
|
||||
mov dx, e820_magic
|
||||
.data1 o32
|
||||
mov cx, const_24 ! request 24 bytes
|
||||
|
||||
.data1 o32
|
||||
mov ax, const_0xe820
|
||||
int 0x15
|
||||
jc e820_failed
|
||||
|
||||
.data1 o32
|
||||
mov dx, e820_magic
|
||||
.data1 o32
|
||||
cmp dx, ax
|
||||
jne e820_failed
|
||||
|
||||
.data1 o32
|
||||
test bx, bx
|
||||
je e820_failed
|
||||
jmp e820_gotit
|
||||
|
||||
e820_next:
|
||||
.data1 o32
|
||||
mov ax, const_0xe820
|
||||
mov 20(di), #1 ! force a valid ACPI 3.X entry
|
||||
|
||||
.data1 o32
|
||||
mov cx, const_24 ! request 24 bytes
|
||||
int 0x15
|
||||
jc e820_done
|
||||
.data1 o32
|
||||
mov dx, e820_magic
|
||||
|
||||
|
||||
e820_gotit:
|
||||
jcxz e820_skip
|
||||
cmp bp, #16
|
||||
je e820_done ! we have only space for 16 entries
|
||||
inc bp
|
||||
add di, #24
|
||||
e820_skip:
|
||||
.data1 o32
|
||||
test bx, bx
|
||||
jne e820_next
|
||||
|
||||
e820_done:
|
||||
mov _mem_entries, bp
|
||||
jmp memory_detected
|
||||
|
||||
e820_failed:
|
||||
|
||||
! Determine available memory as a list of (base,size) pairs as follows:
|
||||
! mem[0] = low memory, mem[1] = memory between 1M and 16M, mem[2] = memory
|
||||
! above 16M. Last two coalesced into mem[1] if adjacent.
|
||||
@@ -245,8 +185,6 @@ adj_ext:
|
||||
add 14(di), bx ! Add ext mem above 16M to mem below 16M
|
||||
no_ext:
|
||||
|
||||
memory_detected:
|
||||
|
||||
|
||||
! Time to switch to a higher level language (not much higher)
|
||||
call _boot
|
||||
@@ -1596,15 +1534,6 @@ p_mcs_desc:
|
||||
.data2 0xFFFF, UNSET
|
||||
.data1 UNSET, 0x9A, 0x00, 0x00
|
||||
|
||||
e820_magic:
|
||||
! .data1 0x53, 0x4D, 0x41, 0x50
|
||||
.data1 0x50, 0x41, 0x4D, 0x53
|
||||
const_24:
|
||||
.data1 0x18, 0x0, 0x0, 0x0
|
||||
const_0xe820:
|
||||
.data2 0xe820
|
||||
|
||||
|
||||
.bss
|
||||
.comm old_vid_mode, 2 ! Video mode at startup
|
||||
.comm cur_vid_mode, 2 ! Current video mode
|
||||
|
||||
@@ -534,7 +534,7 @@ void exec_image(char *image)
|
||||
/* Save a copy of the header for the kernel, with a_syms
|
||||
* misused as the address where the process is loaded at.
|
||||
*/
|
||||
DEBUGEXTRA(("raw_copy(0x%lx, 0x%lx, 0x%x)... ",
|
||||
DEBUGEXTRA(("raw_copy(0x%x, 0x%lx, 0x%x)... ",
|
||||
aout + i * A_MINHDR, mon2abs(&hdr.process), A_MINHDR));
|
||||
hdr.process.a_syms= addr;
|
||||
raw_copy(aout + i * A_MINHDR, mon2abs(&hdr.process), A_MINHDR);
|
||||
@@ -653,7 +653,7 @@ void exec_image(char *image)
|
||||
}
|
||||
|
||||
if (verboseboot < VERBOSEBOOT_BASIC)
|
||||
printf("(%luk)\n", totalmem/1024);
|
||||
printf("(%dk)\n", totalmem/1024);
|
||||
|
||||
if ((n_procs= i) == 0) {
|
||||
printf("There are no programs in %s\n", image);
|
||||
@@ -842,7 +842,7 @@ void bootminix(void)
|
||||
printf("Not enough memory to load %s\n", image);
|
||||
break;
|
||||
case EIO:
|
||||
printf("Unexpected EOF on %s\n", image);
|
||||
printf("Unsuspected EOF on %s\n", image);
|
||||
case 0:
|
||||
/* No error or error already reported. */;
|
||||
}
|
||||
|
||||
@@ -634,19 +634,19 @@ _dev_boundary:
|
||||
xor ax, ax
|
||||
ret
|
||||
|
||||
! int biosreadsectors(u32_t bufaddr, u32_t sector, u8_t count)
|
||||
! int readsectors(u32_t bufaddr, u32_t sector, u8_t count)
|
||||
! int writesectors(u32_t bufaddr, u32_t sector, u8_t count)
|
||||
! Read/write several sectors from/to the Minix virtual disk. Count
|
||||
! must fit in a byte. The external variable vfd is the file handle.
|
||||
! Returns 0 for success, otherwise the DOS error code.
|
||||
!
|
||||
.define _biosreadsectors, _writesectors
|
||||
.define _readsectors, _writesectors
|
||||
_writesectors:
|
||||
push bp
|
||||
mov bp, sp
|
||||
movb 13(bp), 0x40 ! Code for a file write
|
||||
jmp rwsec
|
||||
_biosreadsectors:
|
||||
_readsectors:
|
||||
push bp
|
||||
mov bp, sp
|
||||
movb 13(bp), 0x3F ! Code for a file read
|
||||
|
||||
@@ -193,9 +193,6 @@ do
|
||||
17,0)
|
||||
des="hello" dev=hello
|
||||
;;
|
||||
18,0)
|
||||
des="UNIX domain socket" dev=uds
|
||||
;;
|
||||
BAD,BAD)
|
||||
des= dev=
|
||||
;;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
SCRIPTS= DESCRIBE.sh
|
||||
MAN=
|
||||
|
||||
.include <bsd.prog.mk>
|
||||
.include <minix.prog.mk>
|
||||
|
||||
@@ -4,4 +4,4 @@ MAN=
|
||||
|
||||
LINKS+= ${BINDIR}/M ${BINDIR}/U
|
||||
|
||||
.include <bsd.prog.mk>
|
||||
.include <minix.prog.mk>
|
||||
|
||||
@@ -23,7 +23,7 @@ case $#:$1 in
|
||||
ttypa ttypb ttypc ttypd ttype ttypf \
|
||||
ttyq0 ttyq1 ttyq2 ttyq3 ttyq4 ttyq5 ttyq6 ttyq7 ttyq8 ttyq9 \
|
||||
ttyqa ttyqb ttyqc ttyqd ttyqe ttyqf \
|
||||
eth klog random uds filter hello
|
||||
eth klog random filter hello
|
||||
;;
|
||||
0:|1:-\?)
|
||||
cat >&2 <<EOF
|
||||
@@ -45,7 +45,6 @@ Where key is one of the following:
|
||||
audio mixer # Make audio devices
|
||||
klog # Make /dev/klog
|
||||
random # Make /dev/random, /dev/urandom
|
||||
uds # Make /dev/uds
|
||||
kbd # Make /dev/kbd
|
||||
kbdaux # Make /dev/kbdaux
|
||||
filter # Make /dev/filter
|
||||
@@ -251,12 +250,6 @@ do
|
||||
$e mknod urandom c 16 0; $e chmod 644 urandom
|
||||
$e chgrp operator random urandom
|
||||
;;
|
||||
uds)
|
||||
# unix domain sockets device
|
||||
$e mknod uds c 18 0; $e chmod 644 random
|
||||
$e chgrp operator uds
|
||||
$e chmod 666 uds
|
||||
;;
|
||||
klog)
|
||||
# logging device.
|
||||
$e mknod klog c 15 0
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
SCRIPTS= MAKEDEV.sh
|
||||
MAN=
|
||||
|
||||
.include <bsd.prog.mk>
|
||||
.include <minix.prog.mk>
|
||||
|
||||
@@ -1,44 +1,44 @@
|
||||
# Makefile for commands.
|
||||
|
||||
.include <bsd.own.mk>
|
||||
.include <minix.own.mk>
|
||||
|
||||
SUBDIR= aal add_route adduser advent arp ash at autil awk \
|
||||
backup badblocks banner basename bigmake binpackage \
|
||||
binpackages binsizes bzip2 bzip2recover cal calendar \
|
||||
cat cawf cd cdprobe checkhier chmem \
|
||||
cat cawf cd cdiff cdprobe cgrep checkhier chmem \
|
||||
chmod chown chroot ci cksum cleantmp clear cmp co \
|
||||
comm compress cp crc cron crontab cut date \
|
||||
comm compress cp crc cron crontab cut datasizes date \
|
||||
dd de decomp16 DESCRIBE dev2name devsize df dhcpd \
|
||||
dhrystone diff dirname dis88 diskctl du dumpcore \
|
||||
ed eject elle elvis env expand factor file \
|
||||
find finger fingerd fix fold format fortune fsck.mfs \
|
||||
fsck1 ftp101 ftpd200 gcov-pull getty grep gomoku head hexdump host \
|
||||
dhrystone diff dirname dis88 du dumpcore easypack \
|
||||
ed eject elle elvis env expand factor fgrep file \
|
||||
find finger fingerd fix fold format fortune fsck \
|
||||
fsck1 ftp101 ftpd200 getty gomoku grep head host \
|
||||
hostaddr id ifconfig ifdef indent install \
|
||||
intr ipcrm ipcs irdpd isoread join kill last leave \
|
||||
less lex life loadkeys loadramdisk logger login look lp \
|
||||
lpd ls lspci M m4 mail make MAKEDEV man \
|
||||
mdb mdocml mesg mined mkdep mkdir mkdist mkfifo mkfs.mfs mknod \
|
||||
mkproto modem mount mt netconf newroot nice acknm nohup \
|
||||
nonamed od packman passwd paste patch pax \
|
||||
lex life loadkeys loadramdisk logger login look lp \
|
||||
lpd ls lspci M m4 mail make MAKEDEV makewhatis man \
|
||||
mdb mesg mined mkdep mkdir mkdist mkfifo mkfs mknod \
|
||||
mkproto modem mount mt netconf newroot nice nm nohup \
|
||||
nonamed od packit packman passwd paste patch pax \
|
||||
ping postinstall poweroff pr prep printf printroot \
|
||||
profile progressbar proto pr_routes ps pwd pwdauth \
|
||||
ramdisk rarpd rawspeed rcp rdate readall readclock \
|
||||
readfs reboot remsync rev rget rlogin rlogind rmdir \
|
||||
rotate rsh rshd sed service setup shar size \
|
||||
sleep slip sort spell split srccrc stat strings ackstrip \
|
||||
sleep slip sort spell split srccrc stat strings strip \
|
||||
stty su sum svclog swapfs swifi sync synctree sysenv \
|
||||
syslogd tail talk talkd tar tcpd tcpdp tcpstat tee telnet \
|
||||
syslogd tail talk talkd tcpd tcpdp tcpstat tee telnet \
|
||||
telnetd term termcap tget time tinyhalt top touch tr \
|
||||
truncate tsort ttt tty udpstat umount uname unexpand \
|
||||
uniq unstack update urlget uud uue version vol wc \
|
||||
whereis which who write writeisofs fetch \
|
||||
xargs yacc yes zdump zic zmodem pkg_install pkgin_cd
|
||||
whatis whereis which who whoami write writeisofs \
|
||||
xargs yacc yap yes zdump zic zmodem
|
||||
|
||||
.if ${ARCH} == "i386"
|
||||
SUBDIR+= atnormalize dosread fdisk loadfont \
|
||||
mixer autopart part partition playwave postmort \
|
||||
recwave repartition screendump padtext
|
||||
recwave repartition screendump
|
||||
SUBDIR+= acd asmconv gas2ack
|
||||
.endif
|
||||
|
||||
.include <bsd.subdir.mk>
|
||||
.include <minix.subdir.mk>
|
||||
|
||||
@@ -6,6 +6,7 @@ SRCS= archiver.c print.c rd.c rd_arhdr.c rd_unsig2.c sprint.c \
|
||||
format.c rd_bytes.c system.c write.c long2str.c
|
||||
CPPFLAGS+= -I${.CURDIR} -DAAL -DSTB -DNDEBUG -DDISTRIBUTION
|
||||
|
||||
LINKS+= ${BINDIR}/aal ${BINDIR}/ar
|
||||
MAN=
|
||||
|
||||
.include <bsd.prog.mk>
|
||||
.include <minix.prog.mk>
|
||||
|
||||
@@ -22,7 +22,4 @@ struct ar_hdr {
|
||||
#define AR_TOTAL 26
|
||||
#define AR_SIZE 22
|
||||
|
||||
extern int rd_arhdr(int fd, register struct ar_hdr arhdr[]);
|
||||
extern void wr_arhdr(int fd, struct ar_hdr arhdr[]);
|
||||
|
||||
#endif /* __ARCH_H_INCLUDED */
|
||||
|
||||
@@ -4,18 +4,7 @@
|
||||
*/
|
||||
/* ar - archiver Author: Michiel Huisjes */
|
||||
/* Made into arch/aal by Ceriel Jacobs
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
#include "rd.h"
|
||||
#include "wr_bytes.h"
|
||||
#include "wr_long.h"
|
||||
#include "wr_int2.h"
|
||||
#include "arch.h"
|
||||
#include "archiver.h"
|
||||
#include "print.h"
|
||||
*/
|
||||
|
||||
static char RcsId[] = "$Header$";
|
||||
|
||||
@@ -37,9 +26,6 @@ static char RcsId[] = "$Header$";
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#ifndef S_IREAD
|
||||
@@ -115,49 +101,9 @@ char *temp_arch = &temp_buf[0];
|
||||
extern char *mktemp();
|
||||
extern char *ctime();
|
||||
|
||||
/* Forward declarations. */
|
||||
static void enter_name(struct outname *namep);
|
||||
static void do_names(struct outhead *headp);
|
||||
static void do_object(int f, long size);
|
||||
static void show(char *s, char *name);
|
||||
static void write_symdef(void);
|
||||
static void mwrite(int fd, char *address, int bytes);
|
||||
static void extract(register MEMBER *member);
|
||||
static void copy_member(MEMBER *member, int from, int to, int extracting);
|
||||
static void add(char *name, int fd, char *mess);
|
||||
static void get(int argc, char *argv[]);
|
||||
|
||||
/*VARARGS2*/
|
||||
void error1(BOOL quit, char *str1)
|
||||
usage()
|
||||
{
|
||||
fputs(str1,stderr);
|
||||
if (quit) {
|
||||
unlink(temp_arch);
|
||||
_exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
void error2(BOOL quit, char *str1, char *str2)
|
||||
{
|
||||
fprintf(stderr,str1,str2);
|
||||
if (quit) {
|
||||
unlink(temp_arch);
|
||||
_exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
void error3(BOOL quit, char *str1, char *str2, char *str3)
|
||||
{
|
||||
fprintf(stderr,str1,str2,str3);
|
||||
if (quit) {
|
||||
unlink(temp_arch);
|
||||
_exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
void usage()
|
||||
{
|
||||
error3(TRUE, "usage: %s %s archive [file] ...\n",
|
||||
error(TRUE, "usage: %s %s archive [file] ...\n",
|
||||
progname,
|
||||
#ifdef AAL
|
||||
"[acdrtxvlu]"
|
||||
@@ -167,7 +113,23 @@ void usage()
|
||||
);
|
||||
}
|
||||
|
||||
char *basename(char *path)
|
||||
/*VARARGS2*/
|
||||
error(quit, str1, str2, str3, str4)
|
||||
BOOL quit;
|
||||
char *str1, *str2, *str3, *str4;
|
||||
{
|
||||
char errbuf[256];
|
||||
|
||||
sprint(errbuf, str1, str2, str3, str4);
|
||||
write(2, errbuf, strlen(errbuf));
|
||||
if (quit) {
|
||||
unlink(temp_arch);
|
||||
_exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
char *basename(path)
|
||||
char *path;
|
||||
{
|
||||
register char *ptr = path;
|
||||
register char *last = NULL;
|
||||
@@ -188,14 +150,16 @@ char *basename(char *path)
|
||||
|
||||
extern unsigned int rd_unsigned2();
|
||||
|
||||
int open_archive(char *name, int mode)
|
||||
open_archive(name, mode)
|
||||
register char *name;
|
||||
register int mode;
|
||||
{
|
||||
unsigned short magic = 0;
|
||||
int fd;
|
||||
|
||||
if (mode == CREATE) {
|
||||
if ((fd = creat(name, 0666)) < 0)
|
||||
error2(TRUE, "cannot creat %s\n", name);
|
||||
error(TRUE, "cannot creat %s\n", name);
|
||||
magic = MAGIC_NUMBER;
|
||||
wr_int2(fd, magic);
|
||||
return fd;
|
||||
@@ -204,15 +168,15 @@ int open_archive(char *name, int mode)
|
||||
if ((fd = open(name, mode)) < 0) {
|
||||
if (mode == APPEND) {
|
||||
close(open_archive(name, CREATE));
|
||||
if (!nocr_fl) error3(FALSE, "%s: creating %s\n", progname, name);
|
||||
if (!nocr_fl) error(FALSE, "%s: creating %s\n", progname, name);
|
||||
return open_archive(name, APPEND);
|
||||
}
|
||||
error2(TRUE, "cannot open %s\n", name);
|
||||
error(TRUE, "cannot open %s\n", name);
|
||||
}
|
||||
lseek(fd, 0L, 0);
|
||||
magic = rd_unsigned2(fd);
|
||||
if (magic != AALMAG && magic != ARMAG)
|
||||
error2(TRUE, "%s is not in ar format\n", name);
|
||||
error(TRUE, "%s is not in ar format\n", name);
|
||||
|
||||
return fd;
|
||||
}
|
||||
@@ -227,7 +191,9 @@ catch()
|
||||
_exit (2);
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
main(argc, argv)
|
||||
int argc;
|
||||
char *argv[];
|
||||
{
|
||||
register char *ptr;
|
||||
int needs_arg = 0;
|
||||
@@ -314,7 +280,7 @@ int main(int argc, char *argv[])
|
||||
#ifdef AAL
|
||||
tab = (struct ranlib *) malloc(512 * sizeof(struct ranlib));
|
||||
tstrtab = malloc(4096);
|
||||
if (!tab || !tstrtab) error1(TRUE,"Out of core\n");
|
||||
if (!tab || !tstrtab) error(TRUE,"Out of core\n");
|
||||
tabsz = 512;
|
||||
strtabsz = 4096;
|
||||
#endif
|
||||
@@ -334,7 +300,7 @@ again:
|
||||
if (rd_arhdr(ar_fd, &member) == 0)
|
||||
return NULL;
|
||||
if (member.ar_size < 0) {
|
||||
error1(TRUE, "archive has member with negative size\n");
|
||||
error(TRUE, "archive has member with negative size\n");
|
||||
}
|
||||
#ifdef AAL
|
||||
if (equal(SYMDEF, member.ar_name)) {
|
||||
@@ -347,7 +313,9 @@ again:
|
||||
|
||||
char *get_mode();
|
||||
|
||||
static void get(int argc, char *argv[])
|
||||
get(argc, argv)
|
||||
int argc;
|
||||
register char *argv[];
|
||||
{
|
||||
register MEMBER *member;
|
||||
int i = 0;
|
||||
@@ -489,7 +457,10 @@ static void get(int argc, char *argv[])
|
||||
close(ar_fd);
|
||||
}
|
||||
|
||||
static void add(char *name, int fd, char *mess)
|
||||
add(name, fd, mess)
|
||||
char *name;
|
||||
int fd;
|
||||
char *mess;
|
||||
{
|
||||
static MEMBER member;
|
||||
register int read_chars;
|
||||
@@ -497,15 +468,15 @@ static void add(char *name, int fd, char *mess)
|
||||
int src_fd;
|
||||
|
||||
if (stat(name, &status) < 0) {
|
||||
error2(FALSE, "cannot find %s\n", name);
|
||||
error(FALSE, "cannot find %s\n", name);
|
||||
return;
|
||||
}
|
||||
else if (S_ISDIR(status.st_mode)) {
|
||||
error2(FALSE, "%s is a directory (ignored)\n", name);
|
||||
error(FALSE, "%s is a directory (ignored)\n", name);
|
||||
return;
|
||||
}
|
||||
else if ((src_fd = open(name, 0)) < 0) {
|
||||
error2(FALSE, "cannot open %s\n", name);
|
||||
error(FALSE, "cannot open %s\n", name);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -541,7 +512,7 @@ static void add(char *name, int fd, char *mess)
|
||||
}
|
||||
else status.st_size -= x;
|
||||
if (read(src_fd, io_buffer, read_chars) != read_chars) {
|
||||
error2(FALSE,"%s seems to shrink\n", name);
|
||||
error(FALSE,"%s seems to shrink\n", name);
|
||||
break;
|
||||
}
|
||||
mwrite(fd, io_buffer, x);
|
||||
@@ -552,7 +523,8 @@ static void add(char *name, int fd, char *mess)
|
||||
close(src_fd);
|
||||
}
|
||||
|
||||
static void extract(register MEMBER *member)
|
||||
extract(member)
|
||||
register MEMBER *member;
|
||||
{
|
||||
int fd = 1;
|
||||
char buf[sizeof(member->ar_name) + 1];
|
||||
@@ -560,7 +532,7 @@ static void extract(register MEMBER *member)
|
||||
strncpy(buf, member->ar_name, sizeof(member->ar_name));
|
||||
buf[sizeof(member->ar_name)] = 0;
|
||||
if (pr_fl == FALSE && (fd = creat(buf, 0666)) < 0) {
|
||||
error2(FALSE, "cannot create %s\n", buf);
|
||||
error(FALSE, "cannot create %s\n", buf);
|
||||
fd = -1;
|
||||
}
|
||||
|
||||
@@ -576,7 +548,9 @@ static void extract(register MEMBER *member)
|
||||
if (pr_fl == FALSE) chmod(buf, member->ar_mode);
|
||||
}
|
||||
|
||||
static void copy_member(MEMBER *member, int from, int to, int extracting)
|
||||
copy_member(member, from, to, extracting)
|
||||
register MEMBER *member;
|
||||
int from, to;
|
||||
{
|
||||
register int rest;
|
||||
long mem_size = member->ar_size;
|
||||
@@ -598,7 +572,7 @@ static void copy_member(MEMBER *member, int from, int to, int extracting)
|
||||
|
||||
strncpy(buf, member->ar_name, sizeof(member->ar_name));
|
||||
buf[sizeof(member->ar_name)] = 0;
|
||||
error2(TRUE, "read error on %s\n", buf);
|
||||
error(TRUE, "read error on %s\n", buf);
|
||||
}
|
||||
if (to >= 0) mwrite(to, io_buffer, rest);
|
||||
mem_size -= (long) rest;
|
||||
@@ -633,23 +607,27 @@ register int mode;
|
||||
return mode_buf;
|
||||
}
|
||||
|
||||
void wr_fatal()
|
||||
wr_fatal()
|
||||
{
|
||||
error1(TRUE, "write error\n");
|
||||
error(TRUE, "write error\n");
|
||||
}
|
||||
|
||||
void rd_fatal()
|
||||
rd_fatal()
|
||||
{
|
||||
error1(TRUE, "read error\n");
|
||||
error(TRUE, "read error\n");
|
||||
}
|
||||
|
||||
static void mwrite(int fd, char *address, int bytes)
|
||||
mwrite(fd, address, bytes)
|
||||
int fd;
|
||||
register char *address;
|
||||
register int bytes;
|
||||
{
|
||||
if (write(fd, address, bytes) != bytes)
|
||||
error1(TRUE, "write error\n");
|
||||
error(TRUE, "write error\n");
|
||||
}
|
||||
|
||||
static void show(char *s, char *name)
|
||||
show(s, name)
|
||||
char *s, *name;
|
||||
{
|
||||
MEMBER x;
|
||||
char buf[sizeof(x.ar_name)+1];
|
||||
@@ -667,7 +645,7 @@ static void show(char *s, char *name)
|
||||
* then 4 bytes giving the size of the string table, followed by the string
|
||||
* table itself.
|
||||
*/
|
||||
static void write_symdef(void)
|
||||
write_symdef()
|
||||
{
|
||||
register struct ranlib *ran;
|
||||
register int i;
|
||||
@@ -712,12 +690,15 @@ static void write_symdef(void)
|
||||
* The header is put in `headp'.
|
||||
*/
|
||||
int
|
||||
is_outhead(register struct outhead *headp)
|
||||
is_outhead(headp)
|
||||
register struct outhead *headp;
|
||||
{
|
||||
|
||||
return !BADMAGIC(*headp) && headp->oh_nname != 0;
|
||||
}
|
||||
|
||||
static void do_object(int f, long size)
|
||||
do_object(f, size)
|
||||
long size;
|
||||
{
|
||||
struct outhead headbuf;
|
||||
|
||||
@@ -743,7 +724,8 @@ static void do_object(int f, long size)
|
||||
* name table and read and write the names one by one. Update the ranlib table
|
||||
* accordingly.
|
||||
*/
|
||||
static void do_names(struct outhead *headp)
|
||||
do_names(headp)
|
||||
struct outhead *headp;
|
||||
{
|
||||
register char *strings;
|
||||
register int nnames = headp->oh_nname;
|
||||
@@ -754,7 +736,7 @@ static void do_names(struct outhead *headp)
|
||||
if ( headp->oh_nchar != (unsigned int)headp->oh_nchar ||
|
||||
(strings = malloc((unsigned int)headp->oh_nchar)) == (char *)0
|
||||
) {
|
||||
error1(TRUE, "string table too big\n");
|
||||
error(TRUE, "string table too big\n");
|
||||
}
|
||||
rd_string(strings, headp->oh_nchar);
|
||||
while (nnames) {
|
||||
@@ -788,14 +770,15 @@ static void do_names(struct outhead *headp)
|
||||
free(strings);
|
||||
}
|
||||
|
||||
static void enter_name(struct outname *namep)
|
||||
enter_name(namep)
|
||||
struct outname *namep;
|
||||
{
|
||||
register char *cp;
|
||||
|
||||
if (tnum >= tabsz) {
|
||||
tab = (struct ranlib *)
|
||||
realloc((char *) tab, (tabsz += 512) * sizeof(struct ranlib));
|
||||
if (! tab) error1(TRUE, "Out of core\n");
|
||||
if (! tab) error(TRUE, "Out of core\n");
|
||||
}
|
||||
tab[tnum].ran_off = tssiz;
|
||||
tab[tnum].ran_pos = offset;
|
||||
@@ -803,7 +786,7 @@ static void enter_name(struct outname *namep)
|
||||
for (cp = namep->on_mptr;; cp++) {
|
||||
if (tssiz >= strtabsz) {
|
||||
tstrtab = realloc(tstrtab, (strtabsz += 4096));
|
||||
if (! tstrtab) error1(TRUE, "string table overflow\n");
|
||||
if (! tstrtab) error(TRUE, "string table overflow\n");
|
||||
}
|
||||
tstrtab[tssiz++] = *cp;
|
||||
if (!*cp) break;
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
|
||||
extern void rd_fatal();
|
||||
extern void wr_fatal();
|
||||
@@ -9,12 +9,11 @@
|
||||
#else
|
||||
#include <varargs.h>
|
||||
#endif
|
||||
#include <string.h>
|
||||
|
||||
extern char *long2str();
|
||||
|
||||
static int
|
||||
integral(int c)
|
||||
integral(c)
|
||||
{
|
||||
switch (c) {
|
||||
case 'b':
|
||||
@@ -40,14 +39,16 @@ integral(int c)
|
||||
%d = int
|
||||
$ */
|
||||
int
|
||||
_format(char *buf, char *fmt, va_list argp)
|
||||
_format(buf, fmt, argp)
|
||||
char *buf, *fmt;
|
||||
register va_list argp;
|
||||
{
|
||||
register char *pf = fmt;
|
||||
register char *pb = buf;
|
||||
|
||||
while (*pf) {
|
||||
if (*pf == '%') {
|
||||
register int width, base, pad, npad;
|
||||
register width, base, pad, npad;
|
||||
char *arg;
|
||||
char cbuf[2];
|
||||
char *badformat = "<bad format>";
|
||||
@@ -77,8 +78,7 @@ _format(char *buf, char *fmt, va_list argp)
|
||||
else
|
||||
if (*pf == 'l') {
|
||||
/* alignment ??? */
|
||||
base = integral(*++pf);
|
||||
if (base) {
|
||||
if (base = integral(*++pf)) {
|
||||
arg = long2str(va_arg(argp,long), base);
|
||||
}
|
||||
else {
|
||||
@@ -87,7 +87,7 @@ _format(char *buf, char *fmt, va_list argp)
|
||||
}
|
||||
}
|
||||
else
|
||||
if ((base = integral(*pf))) {
|
||||
if (base = integral(*pf)) {
|
||||
arg = long2str((long)va_arg(argp,int), base);
|
||||
}
|
||||
else
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
|
||||
extern int _format(char *buf, char *fmt, va_list argp);
|
||||
@@ -15,7 +15,7 @@
|
||||
char *
|
||||
long2str(val, base)
|
||||
register long val;
|
||||
register int base;
|
||||
register base;
|
||||
{
|
||||
static char numbuf[MAXWIDTH];
|
||||
static char vec[] = "0123456789ABCDEF";
|
||||
@@ -38,7 +38,7 @@ long2str(val, base)
|
||||
if (base < 0) { /* unsigned */
|
||||
base = -base;
|
||||
if (val < 0L) { /* taken from Amoeba src */
|
||||
register int mod, i;
|
||||
register mod, i;
|
||||
overflow:
|
||||
mod = 0;
|
||||
for (i = 0; i < 8 * sizeof val; i++) {
|
||||
|
||||
@@ -11,8 +11,6 @@
|
||||
#endif
|
||||
#include <system.h>
|
||||
#include "param.h"
|
||||
#include "format.h"
|
||||
#include "write.h"
|
||||
|
||||
/*VARARGS*/
|
||||
/*FORMAT0v $
|
||||
@@ -22,7 +20,7 @@
|
||||
%[uxbo] = unsigned int
|
||||
%d = int
|
||||
$ */
|
||||
void
|
||||
int
|
||||
#if __STDC__
|
||||
print(char *fmt, ...)
|
||||
#else
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
|
||||
extern void print(char *fmt, ...);
|
||||
@@ -31,6 +31,4 @@ struct ranlib {
|
||||
#define SZ_RAN 8
|
||||
#define SF_RAN "44"
|
||||
|
||||
extern void wr_ranlib(int fd, struct ranlib ran[], long cnt);
|
||||
#endif /* __RANLIB_H_INCLUDED */
|
||||
|
||||
|
||||
@@ -3,13 +3,8 @@
|
||||
* (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
|
||||
* See the copyright notice in the ACK home directory, in the file "Copyright".
|
||||
*/
|
||||
#include <sys/types.h>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include "out.h"
|
||||
#include <out.h>
|
||||
#include "object.h"
|
||||
#include "rd.h"
|
||||
#include "rd_bytes.h"
|
||||
|
||||
extern long lseek();
|
||||
|
||||
@@ -48,7 +43,9 @@ static long rd_base;
|
||||
static int sectionnr;
|
||||
|
||||
static
|
||||
void OUTREAD(int p, char *b, long n)
|
||||
OUTREAD(p, b, n)
|
||||
char *b;
|
||||
long n;
|
||||
{
|
||||
register long l = outseek[p];
|
||||
|
||||
@@ -65,17 +62,18 @@ void OUTREAD(int p, char *b, long n)
|
||||
* Open the output file according to the chosen strategy.
|
||||
*/
|
||||
int
|
||||
rd_open(char *f)
|
||||
rd_open(f)
|
||||
char *f;
|
||||
{
|
||||
int outfile = open(f, 0);
|
||||
if (outfile < 0)
|
||||
|
||||
if ((outfile = open(f, 0)) < 0)
|
||||
return 0;
|
||||
return rd_fdopen(outfile);
|
||||
}
|
||||
|
||||
static int offcnt;
|
||||
|
||||
int rd_fdopen(int fd)
|
||||
rd_fdopen(fd)
|
||||
{
|
||||
register int i;
|
||||
|
||||
@@ -92,19 +90,20 @@ int rd_fdopen(int fd)
|
||||
return 1;
|
||||
}
|
||||
|
||||
void rd_close()
|
||||
rd_close()
|
||||
{
|
||||
|
||||
close(outfile);
|
||||
outfile = -1;
|
||||
}
|
||||
|
||||
int rd_fd()
|
||||
rd_fd()
|
||||
{
|
||||
return outfile;
|
||||
}
|
||||
|
||||
void rd_ohead(register struct outhead *head)
|
||||
rd_ohead(head)
|
||||
register struct outhead *head;
|
||||
{
|
||||
register long off;
|
||||
|
||||
@@ -136,7 +135,7 @@ void rd_ohead(register struct outhead *head)
|
||||
#endif
|
||||
}
|
||||
|
||||
void rd_rew_relos(head)
|
||||
rd_rew_relos(head)
|
||||
register struct outhead *head;
|
||||
{
|
||||
register long off = OFF_RELO(*head) + rd_base;
|
||||
@@ -144,7 +143,7 @@ void rd_rew_relos(head)
|
||||
BEGINSEEK(PARTRELO, off);
|
||||
}
|
||||
|
||||
void rd_sect(sect, cnt)
|
||||
rd_sect(sect, cnt)
|
||||
register struct outsect *sect;
|
||||
register unsigned int cnt;
|
||||
{
|
||||
@@ -174,7 +173,7 @@ void rd_sect(sect, cnt)
|
||||
}
|
||||
}
|
||||
|
||||
void rd_outsect(int s)
|
||||
rd_outsect(s)
|
||||
{
|
||||
OUTSECT(s);
|
||||
sectionnr = s;
|
||||
@@ -183,7 +182,7 @@ void rd_outsect(int s)
|
||||
/*
|
||||
* We don't have to worry about byte order here.
|
||||
*/
|
||||
void rd_emit(emit, cnt)
|
||||
rd_emit(emit, cnt)
|
||||
char *emit;
|
||||
long cnt;
|
||||
{
|
||||
@@ -191,10 +190,11 @@ void rd_emit(emit, cnt)
|
||||
offset[sectionnr] += cnt;
|
||||
}
|
||||
|
||||
void rd_relo(relo, cnt)
|
||||
rd_relo(relo, cnt)
|
||||
register struct outrelo *relo;
|
||||
register unsigned int cnt;
|
||||
{
|
||||
|
||||
OUTREAD(PARTRELO, (char *) relo, (long) cnt * SZ_RELO);
|
||||
#if ! (BYTES_REVERSED || WORDS_REVERSED)
|
||||
if (sizeof(struct outrelo) != SZ_RELO)
|
||||
@@ -213,7 +213,9 @@ void rd_relo(relo, cnt)
|
||||
}
|
||||
}
|
||||
|
||||
void rd_name(struct outname *name, unsigned int cnt)
|
||||
rd_name(name, cnt)
|
||||
register struct outname *name;
|
||||
register unsigned int cnt;
|
||||
{
|
||||
|
||||
OUTREAD(PARTNAME, (char *) name, (long) cnt * SZ_NAME);
|
||||
@@ -234,13 +236,18 @@ void rd_name(struct outname *name, unsigned int cnt)
|
||||
}
|
||||
}
|
||||
|
||||
void rd_string(char *addr, long len)
|
||||
rd_string(addr, len)
|
||||
char *addr;
|
||||
long len;
|
||||
{
|
||||
|
||||
OUTREAD(PARTCHAR, addr, len);
|
||||
}
|
||||
|
||||
#ifdef SYMDBUG
|
||||
void rd_dbug(char *buf, long size)
|
||||
rd_dbug(buf, size)
|
||||
char *buf;
|
||||
long size;
|
||||
{
|
||||
OUTREAD(PARTDBUG, buf, size);
|
||||
}
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
/*
|
||||
* Headers for rd.c
|
||||
*/
|
||||
|
||||
#include "out.h"
|
||||
|
||||
extern void rd_string(char *addr, long len);
|
||||
extern void rd_name(struct outname name[], unsigned int cnt);
|
||||
extern int rd_fdopen(int fd);
|
||||
extern void rd_ohead(register struct outhead head[]);
|
||||
@@ -3,16 +3,12 @@
|
||||
* (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
|
||||
* See the copyright notice in the ACK home directory, in the file "Copyright".
|
||||
*/
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
#include <arch.h>
|
||||
#include "object.h"
|
||||
|
||||
#include "arch.h"
|
||||
#include "archiver.h"
|
||||
|
||||
int
|
||||
rd_arhdr(int fd, register struct ar_hdr *arhdr)
|
||||
rd_arhdr(fd, arhdr)
|
||||
register struct ar_hdr *arhdr;
|
||||
{
|
||||
char buf[AR_TOTAL];
|
||||
register char *c = buf;
|
||||
|
||||
@@ -9,19 +9,16 @@
|
||||
an int!
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "archiver.h"
|
||||
#include "rd_bytes.h"
|
||||
|
||||
static int maxchunk = MAXCHUNK;
|
||||
|
||||
/*
|
||||
* We don't have to worry about byte order here.
|
||||
* Just read "cnt" bytes from file-descriptor "fd".
|
||||
*/
|
||||
void rd_bytes(int fd, char *string, long cnt)
|
||||
int
|
||||
rd_bytes(fd, string, cnt)
|
||||
register char *string;
|
||||
register long cnt;
|
||||
{
|
||||
|
||||
while (cnt) {
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
|
||||
extern void rd_bytes(int fd, char *string, long cnt);
|
||||
@@ -4,10 +4,9 @@
|
||||
* See the copyright notice in the ACK home directory, in the file "Copyright".
|
||||
*/
|
||||
#include "object.h"
|
||||
#include "rd_bytes.h"
|
||||
|
||||
unsigned int
|
||||
rd_unsigned2(int fd)
|
||||
rd_unsigned2(fd)
|
||||
{
|
||||
char buf[2];
|
||||
|
||||
|
||||
@@ -11,7 +11,6 @@
|
||||
#endif
|
||||
#include <system.h>
|
||||
#include "param.h"
|
||||
#include "format.h"
|
||||
|
||||
/*VARARGS*/
|
||||
/*FORMAT1v $
|
||||
|
||||
@@ -43,7 +43,5 @@ extern File _sys_ftab[];
|
||||
#define ILL_BREAK ((char *)0)
|
||||
|
||||
/* system's idea of block */
|
||||
#ifndef BUFSIZ
|
||||
#define BUFSIZ 1024
|
||||
#endif
|
||||
#endif /* __SYSTEM_INCLUDED__ */
|
||||
|
||||
@@ -5,11 +5,9 @@
|
||||
*/
|
||||
#include <arch.h>
|
||||
#include "object.h"
|
||||
#include "arch.h"
|
||||
#include "write.h"
|
||||
#include "wr_bytes.h"
|
||||
|
||||
void wr_arhdr(int fd, struct ar_hdr *arhdr)
|
||||
wr_arhdr(fd, arhdr)
|
||||
register struct ar_hdr *arhdr;
|
||||
{
|
||||
char buf[AR_TOTAL];
|
||||
register char *c = buf;
|
||||
|
||||
@@ -9,17 +9,14 @@
|
||||
You have to put it in an int!
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
#include "wr_bytes.h"
|
||||
#include "archiver.h"
|
||||
|
||||
static int maxchunk = MAXCHUNK;
|
||||
|
||||
/*
|
||||
* Just write "cnt" bytes to file-descriptor "fd".
|
||||
*/
|
||||
void wr_bytes(int fd, register char *string, long cnt)
|
||||
wr_bytes(fd, string, cnt)
|
||||
register char *string;
|
||||
register long cnt;
|
||||
{
|
||||
|
||||
while (cnt) {
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
/*
|
||||
* Exported symbols of wr_bytes.c
|
||||
*/
|
||||
extern void wr_bytes(int fd, register char *string, long cnt);
|
||||
@@ -4,10 +4,8 @@
|
||||
* See the copyright notice in the ACK home directory, in the file "Copyright".
|
||||
*/
|
||||
#include "object.h"
|
||||
#include "wr_int2.h"
|
||||
#include "wr_bytes.h"
|
||||
|
||||
void wr_int2(int fd, int i)
|
||||
wr_int2(fd, i)
|
||||
{
|
||||
char buf[2];
|
||||
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
|
||||
extern void wr_int2(int fd, int i);
|
||||
@@ -4,10 +4,9 @@
|
||||
* See the copyright notice in the ACK home directory, in the file "Copyright".
|
||||
*/
|
||||
#include "object.h"
|
||||
#include "wr_bytes.h"
|
||||
#include "wr_long.h"
|
||||
|
||||
void wr_long(int fd, long l)
|
||||
wr_long(fd, l)
|
||||
long l;
|
||||
{
|
||||
char buf[4];
|
||||
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
|
||||
extern void wr_long(int fd, long l);
|
||||
@@ -5,10 +5,10 @@
|
||||
*/
|
||||
#include <ranlib.h>
|
||||
#include "object.h"
|
||||
#include "wr_bytes.h"
|
||||
#include "ranlib.h"
|
||||
|
||||
void wr_ranlib(int fd, struct ranlib *ran, long cnt)
|
||||
wr_ranlib(fd, ran, cnt)
|
||||
register struct ranlib *ran;
|
||||
register long cnt;
|
||||
{
|
||||
#if ! (BYTES_REVERSED || WORDS_REVERSED)
|
||||
if (sizeof (struct ranlib) != SZ_RAN)
|
||||
|
||||
@@ -4,13 +4,13 @@
|
||||
*/
|
||||
/* $Header$ */
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
#include <system.h>
|
||||
#include "write.h"
|
||||
|
||||
int
|
||||
sys_write(File *fp, char *bufptr, int nbytes)
|
||||
sys_write(fp, bufptr, nbytes)
|
||||
File *fp;
|
||||
char *bufptr;
|
||||
int nbytes;
|
||||
{
|
||||
if (! fp) return 0;
|
||||
return write(fp->o_fd, bufptr, nbytes) == nbytes;
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
|
||||
#include "system.h"
|
||||
extern int sys_write(File *fp, char *bufptr, int nbytes);
|
||||
@@ -1,6 +1,6 @@
|
||||
# Makefile for acd
|
||||
|
||||
.include <bsd.own.mk>
|
||||
.include <minix.own.mk>
|
||||
|
||||
PROG= acd
|
||||
CPPFLAGS+= -DARCH=\"`arch`\" -DDESCR=\"/usr/lib/descr\"
|
||||
@@ -10,4 +10,4 @@ FILES= acd.descr
|
||||
FILESNAME= descr
|
||||
MAN=
|
||||
|
||||
.include <bsd.prog.mk>
|
||||
.include <minix.prog.mk>
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
PROG= acknm
|
||||
MAN=
|
||||
|
||||
.include <bsd.prog.mk>
|
||||
@@ -1,4 +0,0 @@
|
||||
PROG= ackstrip
|
||||
MAN=
|
||||
|
||||
.include <bsd.prog.mk>
|
||||
@@ -3,4 +3,4 @@ MAN=
|
||||
|
||||
LINKS+= ${BINDIR}/add_route ${BINDIR}/del_route
|
||||
|
||||
.include <bsd.prog.mk>
|
||||
.include <minix.prog.mk>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
SCRIPTS= adduser.sh
|
||||
MAN=
|
||||
|
||||
.include <bsd.prog.mk>
|
||||
.include <minix.prog.mk>
|
||||
|
||||
@@ -15,20 +15,14 @@ MAN=
|
||||
database.o: advtext.h
|
||||
|
||||
setup: setup.c advent.h
|
||||
${CC} ${CPPFLAGS} ${LDFLAGS} -o $@ ${.CURDIR}/setup.c
|
||||
${CC} ${CPPFLAGS} ${LDFLAGS} -o setup setup.c
|
||||
|
||||
advtext.h advent1.dat advent2.dat advent3.dat advent4.dat: \
|
||||
setup advent1.txt advent2.txt advent3.txt advent4.txt
|
||||
./setup ${.CURDIR}
|
||||
|
||||
database.d: touch-genfiles
|
||||
|
||||
touch-genfiles:
|
||||
[ -e advtext.h ] || touch -t 197001010000.00 advtext.h
|
||||
./setup
|
||||
|
||||
CPPFLAGS.advent.c= -DTEXTDIR='"${TEXTDIR}"'
|
||||
|
||||
CLEANFILES+= ${DATFILES} advtext.h setup
|
||||
|
||||
.include <bsd.prog.mk>
|
||||
|
||||
.include <minix.prog.mk>
|
||||
|
||||
@@ -11,34 +11,28 @@
|
||||
#include <stdlib.h>
|
||||
#include "advent.h"
|
||||
|
||||
_PROTOTYPE(int main, (void));
|
||||
_PROTOTYPE(void file_error, (char *));
|
||||
_PROTOTYPE(void encode, (unsigned char *));
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
int main()
|
||||
{
|
||||
|
||||
FILE *isam, *src, *dest;
|
||||
char itxt[255];
|
||||
int cnt, i;
|
||||
long llen;
|
||||
char filename[100];
|
||||
char *inputprefix = ".";
|
||||
char filename[12];
|
||||
static char *headername[] = {
|
||||
"idx1[MAXLOC]", "idx2[MAXLOC]", "idx3[MAXOBJ]", "idx4[MAXMSG]",
|
||||
};
|
||||
|
||||
long x29 = (1L << 29), x30 = (1L << 30);
|
||||
|
||||
if(argc > 1) {
|
||||
inputprefix=argv[1];
|
||||
}
|
||||
|
||||
if (!(x30 / 2 == x29 && 0L < x30 && x29 < x30)) {
|
||||
fprintf(stderr, "Sorry, advent needs 32-bit `long int's.\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
sprintf(filename, "%s/advtext.h", inputprefix);
|
||||
isam = fopen(filename, "w");
|
||||
isam = fopen("advtext.h", "w");
|
||||
if (!isam) {
|
||||
fprintf(stderr, "Sorry, I can't open advtext.h...\n");
|
||||
exit(EXIT_FAILURE);
|
||||
@@ -48,7 +42,7 @@ int main(int argc, char *argv[])
|
||||
for (i = 1; i <= 4; i++) {
|
||||
cnt = -1;
|
||||
llen = 0L;
|
||||
sprintf(filename, "%s/advent%d.txt", inputprefix, i);
|
||||
sprintf(filename, "advent%d.txt", i);
|
||||
src = fopen(filename, "r");
|
||||
if (!src)
|
||||
file_error(filename);
|
||||
|
||||
@@ -2,4 +2,4 @@ PROG= arp
|
||||
BINMODE= 4755
|
||||
MAN=
|
||||
|
||||
.include <bsd.prog.mk>
|
||||
.include <minix.prog.mk>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# Makefile for ash.
|
||||
|
||||
.include <bsd.own.mk>
|
||||
.include <minix.own.mk>
|
||||
|
||||
YHEADER=1
|
||||
PROG= sh
|
||||
@@ -78,9 +78,9 @@ signames.c signames.h: mksignames
|
||||
|
||||
.ORDER: operators.c operators.h
|
||||
operators.c operators.h: mkexpr unary_op binary_op
|
||||
sh ${.CURDIR}/bltin/mkexpr ${.CURDIR}/bltin/unary_op ${.CURDIR}/bltin/binary_op
|
||||
sh bltin/mkexpr bltin/unary_op bltin/binary_op
|
||||
|
||||
arith.h: arith.c
|
||||
arith.c: arith.y
|
||||
|
||||
.include <bsd.prog.mk>
|
||||
.include <minix.prog.mk>
|
||||
|
||||
@@ -35,8 +35,8 @@
|
||||
static char sccsid[] = "@(#)alias.c 8.3 (Berkeley) 5/4/95";
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
#include <sys/cdefs.h>
|
||||
/*
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD: src/bin/sh/alias.c,v 1.18 2004/04/06 20:06:51 markm Exp $");
|
||||
*/
|
||||
|
||||
|
||||
@@ -11,7 +11,6 @@ AND2 & 2
|
||||
STREQ = 4 OP_STRING
|
||||
STRNE != 4 OP_STRING
|
||||
NEWER -newer 4 OP_STRING
|
||||
OLDER -ot 4 OP_STRING
|
||||
EQ -eq 4 OP_INT
|
||||
NE -ne 4 OP_INT
|
||||
GT -gt 4 OP_INT
|
||||
|
||||
@@ -279,9 +279,6 @@ expr_operator(op, sp, fs)
|
||||
sp->u.num = expr_is_false(sp);
|
||||
sp->type = BOOLEAN;
|
||||
break;
|
||||
case EXISTS:
|
||||
if (fs->rcode >= 0) goto true;
|
||||
goto false;
|
||||
case ISREAD:
|
||||
i = 04;
|
||||
goto permission;
|
||||
@@ -347,18 +344,13 @@ filebit:
|
||||
sp->u.num = fs->rcode >= 0? fs->stat.st_size : 0L;
|
||||
sp->type = INTEGER;
|
||||
break;
|
||||
case OLDER:
|
||||
case NEWER:
|
||||
if (stat(sp->u.string, &st1) != 0) {
|
||||
sp->u.num = 0;
|
||||
} else if (stat((sp + 1)->u.string, &st2) != 0) {
|
||||
sp->u.num = 1;
|
||||
} else {
|
||||
int isnewer = st1.st_mtime >= st2.st_mtime;
|
||||
if(op == NEWER)
|
||||
sp->u.num = isnewer;
|
||||
else
|
||||
sp->u.num = !isnewer;
|
||||
sp->u.num = st1.st_mtime >= st2.st_mtime;
|
||||
}
|
||||
sp->type = INTEGER;
|
||||
break;
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
# by the Ash General Public License. See the file named LICENSE.
|
||||
|
||||
NOT ! 3
|
||||
EXISTS -e 12 OP_FILE
|
||||
ISREAD -r 12 OP_FILE
|
||||
ISWRITE -w 12 OP_FILE
|
||||
ISEXEC -x 12 OP_FILE
|
||||
|
||||
@@ -35,8 +35,8 @@
|
||||
static char sccsid[] = "@(#)eval.c 8.9 (Berkeley) 6/8/95";
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
#include <sys/cdefs.h>
|
||||
/*
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD: src/bin/sh/eval.c,v 1.42 2004/04/06 20:06:51 markm Exp $");
|
||||
*/
|
||||
|
||||
|
||||
@@ -35,8 +35,8 @@
|
||||
static char sccsid[] = "@(#)exec.c 8.4 (Berkeley) 6/8/95";
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
#include <sys/cdefs.h>
|
||||
/*
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD: src/bin/sh/exec.c,v 1.24.2.1 2004/09/30 04:41:55 des Exp $");
|
||||
*/
|
||||
|
||||
|
||||
@@ -35,8 +35,8 @@
|
||||
static char sccsid[] = "@(#)expand.c 8.5 (Berkeley) 5/15/95";
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
#include <sys/cdefs.h>
|
||||
/*
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD: src/bin/sh/expand.c,v 1.46 2004/04/06 20:06:51 markm Exp $");
|
||||
*/
|
||||
|
||||
|
||||
@@ -35,8 +35,8 @@
|
||||
static char sccsid[] = "@(#)input.c 8.3 (Berkeley) 6/9/95";
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
#include <sys/cdefs.h>
|
||||
/*
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD: src/bin/sh/input.c,v 1.22 2004/04/06 20:06:51 markm Exp $");
|
||||
*/
|
||||
|
||||
|
||||
@@ -35,8 +35,8 @@
|
||||
static char sccsid[] = "@(#)jobs.c 8.5 (Berkeley) 5/4/95";
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
#include <sys/cdefs.h>
|
||||
/*
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD: src/bin/sh/jobs.c,v 1.67 2004/04/06 20:06:51 markm Exp $");
|
||||
*/
|
||||
|
||||
|
||||
@@ -35,8 +35,8 @@
|
||||
static char sccsid[] = "@(#)miscbltin.c 8.4 (Berkeley) 5/4/95";
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
#include <sys/cdefs.h>
|
||||
/*
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD: src/bin/sh/miscbltin.c,v 1.30 2004/04/06 20:06:51 markm Exp $");
|
||||
*/
|
||||
|
||||
|
||||
@@ -41,8 +41,8 @@ static char const copyright[] =
|
||||
static char sccsid[] = "@(#)mkinit.c 8.2 (Berkeley) 5/4/95";
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
#include <sys/cdefs.h>
|
||||
/*
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD: src/bin/sh/mkinit.c,v 1.17 2004/04/06 20:06:51 markm Exp $");
|
||||
*/
|
||||
|
||||
@@ -65,6 +65,10 @@ __FBSDID("$FreeBSD: src/bin/sh/mkinit.c,v 1.17 2004/04/06 20:06:51 markm Exp $")
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
|
||||
#ifdef __minix
|
||||
#define __unused
|
||||
#endif
|
||||
|
||||
/*
|
||||
* OUTFILE is the name of the output file. Output is initially written
|
||||
* to the file OUTTEMP, which is then moved to OUTFILE.
|
||||
|
||||
@@ -41,7 +41,6 @@ static char const copyright[] =
|
||||
static char sccsid[] = "@(#)mksyntax.c 8.2 (Berkeley) 5/4/95";
|
||||
#endif /* not lint */
|
||||
#endif
|
||||
#include <sys/cdefs.h>
|
||||
/*
|
||||
__FBSDID("$FreeBSD: src/bin/sh/mksyntax.c,v 1.23 2004/04/06 20:06:51 markm Exp $");
|
||||
*/
|
||||
@@ -55,6 +54,10 @@ __FBSDID("$FreeBSD: src/bin/sh/mksyntax.c,v 1.23 2004/04/06 20:06:51 markm Exp $
|
||||
#include <string.h>
|
||||
#include "parser.h"
|
||||
|
||||
#ifdef __minix
|
||||
#define __unused
|
||||
#endif
|
||||
|
||||
struct synclass {
|
||||
char *name;
|
||||
char *comment;
|
||||
|
||||
@@ -35,8 +35,8 @@
|
||||
static char sccsid[] = "@(#)parser.c 8.7 (Berkeley) 5/16/95";
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
#include <sys/cdefs.h>
|
||||
/*
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD: src/bin/sh/parser.c,v 1.51.2.1 2005/03/03 03:43:20 obrien Exp $");
|
||||
*/
|
||||
|
||||
|
||||
@@ -82,10 +82,15 @@ extern char nullstr[1]; /* null string */
|
||||
#endif
|
||||
|
||||
#ifdef __minix
|
||||
#define __unused
|
||||
|
||||
typedef long quad_t; /* XXX */
|
||||
typedef unsigned long u_quad_t; /* XXX */
|
||||
#endif
|
||||
|
||||
mode_t getmode(void *, int /* mode_t */);
|
||||
void *setmode(char *);
|
||||
|
||||
/*
|
||||
* $PchId: shell.h,v 1.7 2006/05/22 12:47:00 philip Exp $
|
||||
*/
|
||||
|
||||
@@ -35,8 +35,8 @@
|
||||
static char sccsid[] = "@(#)var.c 8.3 (Berkeley) 5/4/95";
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
#include <sys/cdefs.h>
|
||||
/*
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD: src/bin/sh/var.c,v 1.26.2.1 2004/09/30 04:41:55 des Exp $");
|
||||
*/
|
||||
|
||||
|
||||
@@ -5,4 +5,4 @@ SRCS= asm86.c asmconv.c parse_ack.c parse_gnu.c parse_bas.c \
|
||||
tokenize.c emit_ack.c emit_gnu.c
|
||||
MAN=
|
||||
|
||||
.include <bsd.prog.mk>
|
||||
.include <minix.prog.mk>
|
||||
|
||||
@@ -2,4 +2,4 @@ PROG= at
|
||||
BINMODE= 4755
|
||||
MAN=
|
||||
|
||||
.include <bsd.prog.mk>
|
||||
.include <minix.prog.mk>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
PROG= atnormalize
|
||||
MAN=
|
||||
|
||||
.include <bsd.prog.mk>
|
||||
.include <minix.prog.mk>
|
||||
|
||||
@@ -7,4 +7,4 @@ CPPFLAGS+= -I${.CURDIR}
|
||||
MAN.anm=
|
||||
MAN.asize=
|
||||
|
||||
.include <bsd.prog.mk>
|
||||
.include <minix.prog.mk>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
PROG= autopart
|
||||
MAN=
|
||||
|
||||
.include <bsd.prog.mk>
|
||||
.include <minix.prog.mk>
|
||||
|
||||
@@ -1,12 +1,10 @@
|
||||
.include <bsd.own.mk>
|
||||
.include <minix.own.mk>
|
||||
|
||||
PROG= awk
|
||||
SRCS= awkgram.y b.c lex.c lib.c main.c parse.c proctab.c run.c tran.c
|
||||
YHEADER= yes
|
||||
QUIET_YACC= yes
|
||||
|
||||
CPPFLAGS+= -I. -I${.CURDIR}
|
||||
|
||||
build-tools: maketab
|
||||
|
||||
proctab.c: maketab
|
||||
@@ -16,4 +14,4 @@ maketab: awkgram.h maketab.c
|
||||
|
||||
CLEANFILES= maketab proctab.c
|
||||
|
||||
.include <bsd.prog.mk>
|
||||
.include <minix.prog.mk>
|
||||
|
||||
@@ -3,4 +3,4 @@ MAN=
|
||||
|
||||
LINKS+= ${BINDIR}/backup ${BINDIR}/restore
|
||||
|
||||
.include <bsd.prog.mk>
|
||||
.include <minix.prog.mk>
|
||||
|
||||
@@ -2,4 +2,4 @@ PROG= badblocks
|
||||
CPPFLAGS+= -I${MINIXSRCDIR}/servers
|
||||
MAN=
|
||||
|
||||
.include <bsd.prog.mk>
|
||||
.include <minix.prog.mk>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
PROG= banner
|
||||
MAN=
|
||||
|
||||
.include <bsd.prog.mk>
|
||||
.include <minix.prog.mk>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
PROG= basename
|
||||
MAN=
|
||||
|
||||
.include <bsd.prog.mk>
|
||||
.include <minix.prog.mk>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
SCRIPTS= bigmake.sh
|
||||
MAN=
|
||||
|
||||
.include <bsd.prog.mk>
|
||||
.include <minix.prog.mk>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
SCRIPTS= binpackage.sh
|
||||
MAN=
|
||||
|
||||
.include <bsd.prog.mk>
|
||||
.include <minix.prog.mk>
|
||||
|
||||
@@ -38,18 +38,12 @@ tar=$srcdir/"`basename ${dir}`".tar
|
||||
tarbz=$tar.bz2
|
||||
|
||||
mkdir $pdir 2>/dev/null || true
|
||||
binsizes=big
|
||||
rc=$dir/.binpackage
|
||||
if [ -f $rc ]
|
||||
then . $rc
|
||||
fi
|
||||
|
||||
prunedirs="$srcdir dev tmp usr/bigports usr/src usr/tmp usr/log usr/adm usr/run home etc/utmp var/run var/log /var/spool"
|
||||
|
||||
for d in $prunedirs
|
||||
do pruneexpr="$pruneexpr $n -path /$d -prune"
|
||||
n="-o "
|
||||
done
|
||||
|
||||
binsizes $binsizes
|
||||
touch $packagestart
|
||||
sleep 1
|
||||
cd $dir
|
||||
@@ -66,13 +60,8 @@ fi
|
||||
|
||||
echo " * Building package"
|
||||
echo "Minix package $dir built `date`." >$INFO
|
||||
(
|
||||
echo $INFO
|
||||
if [ -f $PI ]
|
||||
then echo $PI
|
||||
fi
|
||||
find / \( $pruneexpr \) -o -cnewer $packagestart -print | fgrep -v /.svn
|
||||
) | pax -w -d | bzip2 >$tarbz
|
||||
( echo $INFO ; if [ -f $PI ]; then echo $PI; fi; find / -cnewer $packagestart | egrep -v "^($srcdir|/(dev|tmp)|/usr/(src|tmp|log|adm|run)|/home|/etc/utmp|/var/(run|log|spool))" | fgrep -v /.svn ) | pax -w -d | bzip2 >$tarbz
|
||||
rm -f $packagestart $findlist $tarcmd
|
||||
binsizes normal
|
||||
mv $tarbz $pdir
|
||||
exit 0
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
SCRIPTS= binpackages.sh
|
||||
MAN=
|
||||
|
||||
.include <bsd.prog.mk>
|
||||
.include <minix.prog.mk>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
SCRIPTS= binsizes.sh
|
||||
MAN=
|
||||
|
||||
.include <bsd.prog.mk>
|
||||
.include <minix.prog.mk>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
.include <bsd.own.mk>
|
||||
.include <minix.own.mk>
|
||||
|
||||
PROG= bzip2
|
||||
DPADD+= ${LIBBZ2}
|
||||
@@ -11,4 +11,4 @@ MLINKS+= bzip2.1 bunzip2.1\
|
||||
LINKS+= ${BINDIR}/bzip2 ${BINDIR}/bunzip2
|
||||
LINKS+= ${BINDIR}/bzip2 ${BINDIR}/bzcat
|
||||
|
||||
.include <bsd.prog.mk>
|
||||
.include <minix.prog.mk>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
NOMAN=
|
||||
|
||||
.include <bsd.own.mk>
|
||||
.include <minix.own.mk>
|
||||
|
||||
PROG= bzip2recover
|
||||
CPPFLAGS+= -I ${BZ2DIR}
|
||||
@@ -8,4 +8,4 @@ CPPFLAGS+= -I ${BZ2DIR}
|
||||
BZ2DIR= ${MINIXSRCDIR}/commands/bzip2
|
||||
.PATH: ${BZ2DIR}
|
||||
|
||||
.include <bsd.prog.mk>
|
||||
.include <minix.prog.mk>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
PROG= cal
|
||||
MAN=
|
||||
|
||||
.include <bsd.prog.mk>
|
||||
.include <minix.prog.mk>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
PROG= calendar
|
||||
MAN=
|
||||
|
||||
.include <bsd.prog.mk>
|
||||
.include <minix.prog.mk>
|
||||
|
||||
@@ -2,4 +2,4 @@ PROG= cat
|
||||
BINDIR= /bin
|
||||
MAN=
|
||||
|
||||
.include <bsd.prog.mk>
|
||||
.include <minix.prog.mk>
|
||||
|
||||
@@ -49,4 +49,4 @@ MAN.bsfilt=
|
||||
FILESDIR= /usr/lib/cawf
|
||||
FILES= common device.cf dumb.dev man.mac me.mac ms.mac mnx.mac
|
||||
|
||||
.include <bsd.prog.mk>
|
||||
.include <minix.prog.mk>
|
||||
|
||||
@@ -15,4 +15,4 @@ LINKS+= ${BINDIR}/cd ${BINDIR}/umask
|
||||
LINKS+= ${BINDIR}/cd ${BINDIR}/wait
|
||||
|
||||
|
||||
.include <bsd.prog.mk>
|
||||
.include <minix.prog.mk>
|
||||
|
||||
4
commands/cdiff/Makefile
Normal file
4
commands/cdiff/Makefile
Normal file
@@ -0,0 +1,4 @@
|
||||
PROG= cdiff
|
||||
MAN=
|
||||
|
||||
.include <minix.prog.mk>
|
||||
365
commands/cdiff/cdiff.c
Normal file
365
commands/cdiff/cdiff.c
Normal file
@@ -0,0 +1,365 @@
|
||||
/* cdiff - context diff Author: Larry Wall */
|
||||
|
||||
/* Cdiff - turns a regular diff into a new-style context diff
|
||||
*
|
||||
* Usage: cdiff file1 file2
|
||||
*/
|
||||
|
||||
#define PATCHLEVEL 2
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/wait.h>
|
||||
#include <ctype.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
#include <unistd.h>
|
||||
#include <limits.h>
|
||||
#include <stdio.h>
|
||||
|
||||
char buff[512];
|
||||
|
||||
FILE *inputfp, *oldfp, *newfp;
|
||||
|
||||
int oldmin, oldmax, newmin, newmax;
|
||||
int oldbeg, oldend, newbeg, newend;
|
||||
int preoldmax, prenewmax;
|
||||
int preoldbeg, preoldend, prenewbeg, prenewend;
|
||||
int oldwanted, newwanted;
|
||||
|
||||
char *oldhunk, *newhunk;
|
||||
char *progname;
|
||||
size_t oldsize, oldalloc, newsize, newalloc;
|
||||
|
||||
_PROTOTYPE(int main, (int argc, char **argv));
|
||||
_PROTOTYPE(void dumphunk, (void));
|
||||
_PROTOTYPE(char *getold, (int targ));
|
||||
_PROTOTYPE(char *getnew, (int targ));
|
||||
_PROTOTYPE(void *xmalloc, (size_t size));
|
||||
_PROTOTYPE(void *xrealloc, (void *ptr, size_t size));
|
||||
|
||||
#define Nullfp (FILE*)0
|
||||
#define Nullch (char*)0
|
||||
#define ENOUGH (NAME_MAX + PATH_MAX + 1)
|
||||
#define CRC_END 12
|
||||
|
||||
int main(argc, argv)
|
||||
int argc;
|
||||
char **argv;
|
||||
{
|
||||
FILE *crcfp;
|
||||
char *old, *new;
|
||||
int context = 3;
|
||||
struct stat statbuf;
|
||||
register char *s;
|
||||
char op;
|
||||
char *newmark, *oldmark;
|
||||
char sysbuf1[ENOUGH], sysbuf2[ENOUGH];
|
||||
int len;
|
||||
char *line;
|
||||
int i;
|
||||
int status;
|
||||
|
||||
progname = argv[0];
|
||||
oldalloc = 512;
|
||||
oldhunk = (char *) xmalloc(oldalloc);
|
||||
newalloc = 512;
|
||||
newhunk = (char *) xmalloc(newalloc);
|
||||
|
||||
for (argc--, argv++; argc; argc--, argv++) {
|
||||
if (argv[0][0] != '-') break;
|
||||
|
||||
if (argv[0][1] == 'c') context = atoi(argv[0] + 2);
|
||||
}
|
||||
|
||||
if (argc != 2) {
|
||||
fprintf(stderr, "Usage: cdiff old new\n");
|
||||
exit(2);
|
||||
}
|
||||
old = argv[0];
|
||||
new = argv[1];
|
||||
|
||||
oldfp = fopen(old, "r");
|
||||
if (!oldfp) {
|
||||
fprintf(stderr, "Can't open %s\n", old);
|
||||
exit(2);
|
||||
}
|
||||
newfp = fopen(new, "r");
|
||||
if (!newfp) {
|
||||
fprintf(stderr, "Can't open %s\n", new);
|
||||
exit(2);
|
||||
}
|
||||
|
||||
/* Compute crcs by popen()ing crc and reading the output. Do this before
|
||||
* popen()ing diff to do the work. popen() attempts to support multiple
|
||||
* clients, but the 1.3-1.6.24b versions don't succeed.
|
||||
*/
|
||||
sprintf(sysbuf1, "crc %s", old);
|
||||
crcfp = popen(sysbuf1, "r");
|
||||
if (!crcfp) {
|
||||
/* The only advantage of cdiff over diff is that it prints crcs, so
|
||||
* give up easily if crc fails.
|
||||
*/
|
||||
fprintf(stderr, "Can't execute crc %s\n", old);
|
||||
exit(2);
|
||||
}
|
||||
fgets(sysbuf1, sizeof(sysbuf1), crcfp);
|
||||
sysbuf1[CRC_END] = '\0';
|
||||
status = pclose(crcfp);
|
||||
if (status != 0) {
|
||||
fprintf(stderr, "crc %s returned bad status %d\n", old, status);
|
||||
exit(2);
|
||||
}
|
||||
sprintf(sysbuf2, "crc %s", new);
|
||||
crcfp = popen(sysbuf2, "r");
|
||||
if (!crcfp) {
|
||||
fprintf(stderr, "Can't execute crc %s\n", new);
|
||||
exit(2);
|
||||
}
|
||||
fgets(sysbuf2, sizeof(sysbuf2), crcfp);
|
||||
sysbuf2[CRC_END] = '\0';
|
||||
status = pclose(crcfp);
|
||||
if (status != 0) {
|
||||
fprintf(stderr, "crc %s returned bad status %d\n", new, status);
|
||||
exit(2);
|
||||
}
|
||||
|
||||
sprintf(buff, "diff %s %s 2>/dev/null", old, new);
|
||||
inputfp = popen(buff, "r");
|
||||
if (!inputfp) {
|
||||
fprintf(stderr, "Can't execute diff %s %s\n", old, new);
|
||||
exit(2);
|
||||
}
|
||||
|
||||
fstat(fileno(oldfp), &statbuf);
|
||||
printf("*** %s crc=%s\t%s", old, sysbuf1, ctime(&statbuf.st_mtime));
|
||||
fstat(fileno(newfp), &statbuf);
|
||||
printf("--- %s crc=%s\t%s", new, sysbuf2, ctime(&statbuf.st_mtime));
|
||||
|
||||
preoldend = -1000;
|
||||
|
||||
while (fgets(buff, sizeof buff, inputfp) != Nullch) {
|
||||
if (isdigit(*buff)) {
|
||||
oldmin = atoi(buff);
|
||||
for (s = buff; isdigit(*s); s++);
|
||||
if (*s == ',') {
|
||||
s++;
|
||||
oldmax = atoi(s);
|
||||
for (; isdigit(*s); s++);
|
||||
} else {
|
||||
oldmax = oldmin;
|
||||
}
|
||||
if (*s != 'a' && *s != 'd' && *s != 'c') {
|
||||
fprintf(stderr, "Unparseable input: %s\n", s);
|
||||
exit(2);
|
||||
}
|
||||
op = *s;
|
||||
s++;
|
||||
newmin = atoi(s);
|
||||
for (; isdigit(*s); s++);
|
||||
if (*s == ',') {
|
||||
s++;
|
||||
newmax = atoi(s);
|
||||
for (; isdigit(*s); s++);
|
||||
} else {
|
||||
newmax = newmin;
|
||||
}
|
||||
if (*s != '\n' && *s != ' ') {
|
||||
fprintf(stderr, "Unparseable input: %s\n", s);
|
||||
exit(2);
|
||||
}
|
||||
newmark = oldmark = "! ";
|
||||
if (op == 'a') {
|
||||
oldmin++;
|
||||
newmark = "+ ";
|
||||
}
|
||||
if (op == 'd') {
|
||||
newmin++;
|
||||
oldmark = "- ";
|
||||
}
|
||||
oldbeg = oldmin - context;
|
||||
oldend = oldmax + context;
|
||||
if (oldbeg < 1) oldbeg = 1;
|
||||
newbeg = newmin - context;
|
||||
newend = newmax + context;
|
||||
if (newbeg < 1) newbeg = 1;
|
||||
|
||||
if (preoldend < oldbeg - 1) {
|
||||
if (preoldend >= 0) {
|
||||
dumphunk();
|
||||
}
|
||||
preoldbeg = oldbeg;
|
||||
prenewbeg = newbeg;
|
||||
oldwanted = newwanted = 0;
|
||||
oldsize = newsize = 0;
|
||||
} else { /* we want to append to previous hunk */
|
||||
oldbeg = preoldmax + 1;
|
||||
newbeg = prenewmax + 1;
|
||||
}
|
||||
|
||||
for (i = oldbeg; i <= oldmax; i++) {
|
||||
line = getold(i);
|
||||
if (!line) {
|
||||
oldend = oldmax = i - 1;
|
||||
break;
|
||||
}
|
||||
len = strlen(line) + 2;
|
||||
if (oldsize + len + 1 >= oldalloc) {
|
||||
oldalloc *= 2;
|
||||
oldhunk = (char *) xrealloc(oldhunk, oldalloc);
|
||||
}
|
||||
if (i >= oldmin) {
|
||||
strcpy(oldhunk + oldsize, oldmark);
|
||||
oldwanted++;
|
||||
} else {
|
||||
strcpy(oldhunk + oldsize, " ");
|
||||
}
|
||||
strcpy(oldhunk + oldsize + 2, line);
|
||||
oldsize += len;
|
||||
}
|
||||
preoldmax = oldmax;
|
||||
preoldend = oldend;
|
||||
|
||||
for (i = newbeg; i <= newmax; i++) {
|
||||
line = getnew(i);
|
||||
if (!line) {
|
||||
newend = newmax = i - 1;
|
||||
break;
|
||||
}
|
||||
len = strlen(line) + 2;
|
||||
if (newsize + len + 1 >= newalloc) {
|
||||
newalloc *= 2;
|
||||
newhunk = (char *) xrealloc(newhunk, newalloc);
|
||||
}
|
||||
if (i >= newmin) {
|
||||
strcpy(newhunk + newsize, newmark);
|
||||
newwanted++;
|
||||
} else {
|
||||
strcpy(newhunk + newsize, " ");
|
||||
}
|
||||
strcpy(newhunk + newsize + 2, line);
|
||||
newsize += len;
|
||||
}
|
||||
prenewmax = newmax;
|
||||
prenewend = newend;
|
||||
}
|
||||
}
|
||||
|
||||
if (preoldend >= 0) {
|
||||
dumphunk();
|
||||
}
|
||||
status = pclose(inputfp);
|
||||
if (!WIFEXITED(status)) exit(2);
|
||||
status = WEXITSTATUS(status);
|
||||
return(status == 0 || status == 1 ? status : 2);
|
||||
}
|
||||
|
||||
void dumphunk()
|
||||
{
|
||||
int i;
|
||||
char *line;
|
||||
int len;
|
||||
|
||||
for (i = preoldmax + 1; i <= preoldend; i++) {
|
||||
line = getold(i);
|
||||
if (!line) {
|
||||
preoldend = i - 1;
|
||||
break;
|
||||
}
|
||||
len = strlen(line) + 2;
|
||||
if (oldsize + len + 1 >= oldalloc) {
|
||||
oldalloc *= 2;
|
||||
oldhunk = (char *) xrealloc(oldhunk, oldalloc);
|
||||
}
|
||||
strcpy(oldhunk + oldsize, " ");
|
||||
strcpy(oldhunk + oldsize + 2, line);
|
||||
oldsize += len;
|
||||
}
|
||||
for (i = prenewmax + 1; i <= prenewend; i++) {
|
||||
line = getnew(i);
|
||||
if (!line) {
|
||||
prenewend = i - 1;
|
||||
break;
|
||||
}
|
||||
len = strlen(line) + 2;
|
||||
if (newsize + len + 1 >= newalloc) {
|
||||
newalloc *= 2;
|
||||
newhunk = (char *) xrealloc(newhunk, newalloc);
|
||||
}
|
||||
strcpy(newhunk + newsize, " ");
|
||||
strcpy(newhunk + newsize + 2, line);
|
||||
newsize += len;
|
||||
}
|
||||
printf("***************\n");
|
||||
if (preoldbeg >= preoldend) {
|
||||
printf("*** %d ****\n", preoldend);
|
||||
} else {
|
||||
printf("*** %d,%d ****\n", preoldbeg, preoldend);
|
||||
}
|
||||
if (oldwanted) {
|
||||
printf("%s", oldhunk);
|
||||
}
|
||||
oldsize = 0;
|
||||
*oldhunk = '\0';
|
||||
if (prenewbeg >= prenewend) {
|
||||
printf("--- %d ----\n", prenewend);
|
||||
} else {
|
||||
printf("--- %d,%d ----\n", prenewbeg, prenewend);
|
||||
}
|
||||
if (newwanted) {
|
||||
printf("%s", newhunk);
|
||||
}
|
||||
newsize = 0;
|
||||
*newhunk = '\0';
|
||||
}
|
||||
|
||||
char *getold(targ)
|
||||
int targ;
|
||||
{
|
||||
static int oldline = 0;
|
||||
|
||||
while (fgets(buff, sizeof buff, oldfp) != Nullch) {
|
||||
oldline++;
|
||||
if (oldline == targ) return buff;
|
||||
}
|
||||
return Nullch;
|
||||
}
|
||||
|
||||
char *getnew(targ)
|
||||
int targ;
|
||||
{
|
||||
static int newline = 0;
|
||||
|
||||
while (fgets(buff, sizeof buff, newfp) != Nullch) {
|
||||
newline++;
|
||||
if (newline == targ) return buff;
|
||||
}
|
||||
return Nullch;
|
||||
}
|
||||
|
||||
void *xmalloc(size)
|
||||
size_t size;
|
||||
{
|
||||
void *ptr;
|
||||
|
||||
ptr = malloc(size);
|
||||
if (ptr == NULL) {
|
||||
fprintf(stderr, "%s: out of memory\n", progname);
|
||||
exit(2);
|
||||
}
|
||||
return(ptr);
|
||||
}
|
||||
|
||||
void *xrealloc(ptr, size)
|
||||
void *ptr;
|
||||
size_t size;
|
||||
{
|
||||
ptr = realloc(ptr, size);
|
||||
if (ptr == NULL) {
|
||||
fprintf(stderr, "%s: out of memory\n", progname);
|
||||
exit(2);
|
||||
}
|
||||
return(ptr);
|
||||
}
|
||||
@@ -2,4 +2,4 @@ PROG= cdprobe
|
||||
CPPFLAGS+= -I${MINIXSRCDIR}/servers
|
||||
MAN=
|
||||
|
||||
.include <bsd.prog.mk>
|
||||
.include <minix.prog.mk>
|
||||
|
||||
4
commands/cgrep/Makefile
Normal file
4
commands/cgrep/Makefile
Normal file
@@ -0,0 +1,4 @@
|
||||
PROG= cgrep
|
||||
MAN=
|
||||
|
||||
.include <minix.prog.mk>
|
||||
379
commands/cgrep/cgrep.c
Normal file
379
commands/cgrep/cgrep.c
Normal file
@@ -0,0 +1,379 @@
|
||||
/* cgrep - grep and display context Author: Mark Mallet */
|
||||
|
||||
/*
|
||||
Nov 19 1984 Mark Mallett (mem@zinn.MV.COM)
|
||||
|
||||
mem 860224 Modified to do r/e (regular expression) parsing on unix
|
||||
mem 860324 Added -f, -n; added code to number lines correctly on output.
|
||||
mem 870325 Added support for regcmp()/regex() style regular expression
|
||||
library; redid some conditionals to provide better mix'n'match.
|
||||
mem 870326 Don't try to print the filename if reading from stdin.
|
||||
Add -w option. Fix a small problem which occasionally allowed
|
||||
the separator to come out between adjacent lines of the file.
|
||||
mem 871119 Fix semantics of call to regcmp(): the NULL terminating the
|
||||
argument list was missing. It worked, but probably only
|
||||
due to some bizarre coincidence.
|
||||
dro 890109 Minor mods to compile under Minix
|
||||
|
||||
*/
|
||||
|
||||
#define OS_UNIX /* Define this for unix systems */
|
||||
/* #define REGEX *//* Define this for re_comp/re_exec library */
|
||||
#define REGCMP /* Define this to use regcmp/regex */
|
||||
/* #define OS_CPM *//* Define this for CP/M-80 */
|
||||
|
||||
|
||||
/* Don't touch these */
|
||||
#define NOREGEXP /* Set this for no regular expression */
|
||||
#ifdef REGEX
|
||||
#undef NOREGEXP
|
||||
#endif /* REGEX */
|
||||
|
||||
#ifdef REGCMP
|
||||
#undef NOREGEXP
|
||||
#endif /* REGCMP */
|
||||
|
||||
|
||||
#ifdef OS_CPM
|
||||
#include "stdio.h"
|
||||
#include "ctype.h"
|
||||
#endif /* OS_CPM */
|
||||
|
||||
#ifdef OS_UNIX
|
||||
#include <sys/types.h>
|
||||
#include <sys/dir.h> /* Either here or in sys directory - dro */
|
||||
#include <ctype.h>
|
||||
#include <limits.h> /* should have this - dro */
|
||||
#include <regexp.h> /* should have this - dro */
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#endif /* OS_UNIX */
|
||||
|
||||
|
||||
/* Local definitions */
|
||||
|
||||
#ifndef NULL
|
||||
#define NULL ((char *)0)
|
||||
#endif /* NULL */
|
||||
|
||||
#ifndef NUL
|
||||
#define NUL '\000'
|
||||
#endif
|
||||
|
||||
#ifndef TRUE
|
||||
#define TRUE 1
|
||||
#define FALSE 0
|
||||
#endif
|
||||
|
||||
|
||||
/* Internal data declared global */
|
||||
|
||||
|
||||
/* Internal routines */
|
||||
|
||||
_PROTOTYPE(int main, (int argc, char **argv));
|
||||
_PROTOTYPE(void dosrch, (char *ifnm));
|
||||
_PROTOTYPE(void shwlin, (char *fnm, int linnum, char *line));
|
||||
_PROTOTYPE(int matlin, (char *line));
|
||||
_PROTOTYPE(void regerror, (const char *s));
|
||||
|
||||
/* External data */
|
||||
|
||||
|
||||
/* Local data */
|
||||
|
||||
static int Debug = {FALSE}; /* Debug enabled flag */
|
||||
static int Lcur = {0}; /* Current line (in Lines array) */
|
||||
static char **Lines = {NULL}; /* Lines pointer array */
|
||||
static int Linlen = {100}; /* Line length */
|
||||
static int Lone = {0}; /* Line one (in Lines array) */
|
||||
static int Nmr = {0}; /* Number of matched regions */
|
||||
static char *Pat = {NULL}; /* Pattern */
|
||||
static char Shwfile = {TRUE}; /* Show file name... */
|
||||
static char Shwline = {TRUE}; /* Show line number */
|
||||
static int Waft = {0}; /* Window after */
|
||||
static int Wbef = {0}; /* Window before */
|
||||
static int Wsiz = {0}; /* Window size */
|
||||
|
||||
regexp *Re; /* Result from reg compilation */
|
||||
|
||||
int main(argc, argv)
|
||||
int argc; /* Argument count */
|
||||
char **argv; /* Argument values */
|
||||
|
||||
{
|
||||
int i; /* Scratch */
|
||||
int n; /* Scratch again */
|
||||
int c; /* A character */
|
||||
char *aptr; /* Argument pointer */
|
||||
int nf; /* number of files on command line */
|
||||
|
||||
nf = 0; /* No files on line */
|
||||
|
||||
for (i = 1; i < argc; i++) { /* Look at args */
|
||||
if (argv[i][0] != '-') {/* If option */
|
||||
if (Pat == NULL) { /* If no pattern yet given */
|
||||
Pat = argv[i]; /* point here */
|
||||
#ifdef REGEX
|
||||
if ((Re = re_comp(Pat)) != NULL) {
|
||||
fprintf(stderr, "cgrep: %s\n", re);
|
||||
exit(1);
|
||||
}
|
||||
#endif /* REGEX */
|
||||
|
||||
#ifdef REGCMP
|
||||
if ((Re = regcomp(Pat)) == NULL) {
|
||||
fprintf(stderr, "cgrep: error in regular expression.\n");
|
||||
exit(1);
|
||||
}
|
||||
#endif /* REGCMP */
|
||||
|
||||
} else { /* This must be a file to search */
|
||||
nf++; /* Count it */
|
||||
dosrch(argv[i]); /* Search */
|
||||
}
|
||||
} else { /* Option char */
|
||||
c = argv[i][1]; /* Get option char */
|
||||
if (isupper(c)) /* Trap idiot definition of tolower */
|
||||
c = tolower(c); /* Don't care about case */
|
||||
n = i;
|
||||
aptr = NULL; /* Find arg, if any */
|
||||
if (argv[i][2] != NUL) {
|
||||
aptr = &argv[i][2];
|
||||
n = i; /* Where to set i if we use this arg */
|
||||
} else if (i < argc - 1) { /* use next.. */
|
||||
n = i + 1;
|
||||
aptr = argv[n];
|
||||
}
|
||||
switch (c) { /* Process the option */
|
||||
case 'a': /* Lines after */
|
||||
Waft = atoi(aptr);
|
||||
Lines = NULL;
|
||||
i = n;
|
||||
break;
|
||||
|
||||
case 'b': /* Lines before */
|
||||
Wbef = atoi(aptr);
|
||||
Lines = NULL;
|
||||
i = n;
|
||||
break;
|
||||
|
||||
/* Disable debug output
|
||||
case 'd': Debug = TRUE; break;
|
||||
*/
|
||||
|
||||
case 'f': /* Suppress filename on output */
|
||||
Shwfile = FALSE;
|
||||
break;
|
||||
|
||||
case 'l': /* Line length */
|
||||
Linlen = atoi(aptr);
|
||||
Lines = NULL;
|
||||
i = n;
|
||||
break;
|
||||
|
||||
case 'n': /* Suppress line number on output */
|
||||
Shwline = FALSE;
|
||||
break;
|
||||
|
||||
case 'w': /* Window: lines before and after */
|
||||
Waft = Wbef = atoi(aptr);
|
||||
Lines = NULL;
|
||||
i = n;
|
||||
break;
|
||||
|
||||
default:
|
||||
fprintf(stderr, "Invalid option %s\n", argv[i]);
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (Pat == NULL) { /* If no pattern given */
|
||||
fprintf(stderr,
|
||||
"Usage: cgrep [-a n] [-b n] [-f] [-l n] [-n] [-w n] pattern [filename... ]\n");
|
||||
exit(1);
|
||||
}
|
||||
if (nf == 0) /* No files processed ? */
|
||||
dosrch((char *)NULL); /* Do standard input */
|
||||
return(0);
|
||||
}
|
||||
|
||||
/* Dosrch (ifnm) Perform the search
|
||||
* Accepts :
|
||||
*
|
||||
* ifn Input file name
|
||||
*
|
||||
*
|
||||
* Returns :
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
void dosrch(ifnm)
|
||||
char *ifnm; /* Input filelname */
|
||||
|
||||
{
|
||||
FILE *ifp; /* Input fp */
|
||||
char *lptr; /* Line pointer */
|
||||
int i; /* Scratch */
|
||||
int prtaft; /* Print-after count */
|
||||
int linnum; /* Line number */
|
||||
int nlb; /* Number of lines buffered */
|
||||
|
||||
if (ifnm != NULL) { /* If file name given */
|
||||
ifp = fopen(ifnm, "r"); /* Open it for read access */
|
||||
if (ifp == NULL) {
|
||||
fprintf(stderr, "Can not open file %s\n", ifnm);
|
||||
return;
|
||||
}
|
||||
} else
|
||||
ifp = stdin;
|
||||
|
||||
if (Lines == NULL) { /* If no line table allocated.. */
|
||||
Wsiz = Wbef + 2; /* Determine total window size */
|
||||
Lines = (char **) calloc((size_t)Wsiz, sizeof(char *));
|
||||
/* Allocate pointer table */
|
||||
for (i = 0; i < Wsiz; i++) /* Allocate line buffers */
|
||||
Lines[i] = (char *) calloc((size_t)Linlen, sizeof(char));
|
||||
}
|
||||
Lcur = Lone = 0; /* Setup line pointers */
|
||||
nlb = 0; /* No lines buffered */
|
||||
linnum = 0; /* Line number is zero */
|
||||
prtaft = -(Wbef + 1); /* Make sure separator given first time */
|
||||
|
||||
for (;;) { /* Loop through the file */
|
||||
lptr = Lines[Lcur]; /* Get pointer to current line */
|
||||
if (++Lcur == Wsiz) /* Bump curr pointer and wrap */
|
||||
Lcur = 0; /* if hit end */
|
||||
if (Lone == Lcur) /* If wrapped to beginning of window */
|
||||
if (++Lone == Wsiz) /* Bump beginning */
|
||||
Lone = 0; /* and wrap if hit end */
|
||||
|
||||
if (fgets(lptr, Linlen, ifp) != lptr) break; /* if end of file */
|
||||
|
||||
linnum++; /* Count line number */
|
||||
if (matlin(lptr)) { /* If matching line */
|
||||
if (prtaft < (-Wbef)) /* Check for separator needed */
|
||||
if ((Nmr++ > 0) && ((Wbef > 0) || (Waft > 0)))
|
||||
printf("----------------------------------------------------------------------------\n");
|
||||
while (Lone != Lcur) { /* Until we close the window */
|
||||
shwlin(ifnm, linnum - nlb, Lines[Lone]);
|
||||
/* Show the line */
|
||||
if (++Lone == Wsiz) Lone = 0;
|
||||
nlb--;
|
||||
}
|
||||
nlb = 0; /* No lines buffered */
|
||||
prtaft = Waft; /* Print n lines after */
|
||||
} else { /* Didn't match */
|
||||
if (prtaft-- > 0) { /* If must print lines after */
|
||||
shwlin(ifnm, linnum, lptr);
|
||||
/* Show the line */
|
||||
Lone = Lcur; /* Match pointers */
|
||||
} else if (nlb < Wbef) /* Count lines buffered */
|
||||
nlb++;
|
||||
}
|
||||
}
|
||||
|
||||
if (ifnm != NULL) fclose(ifp);
|
||||
}
|
||||
|
||||
/* Shwlin (fnm, linnum, line) Show a matching line
|
||||
*
|
||||
* Accepts :
|
||||
*
|
||||
* fnm File name
|
||||
*
|
||||
* linnum Line number
|
||||
*
|
||||
* line Line to show
|
||||
*
|
||||
*
|
||||
* Returns :
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
void shwlin(fnm, linnum, line)
|
||||
char *fnm; /* File name */
|
||||
int linnum; /* Line number */
|
||||
char *line; /* Line (with newline at end) to print */
|
||||
|
||||
{
|
||||
if (Shwfile && (fnm != NULL)) printf("%s%s", fnm, Shwline ? " " : ":");
|
||||
if (Shwline) printf("@%05d:", linnum);
|
||||
printf("%s", line);
|
||||
}
|
||||
|
||||
/* Matlin (line) Perform match against pattern and line
|
||||
*
|
||||
* Accepts :
|
||||
*
|
||||
* line Address of line to match
|
||||
*
|
||||
*
|
||||
* Returns :
|
||||
*
|
||||
* <value> TRUE if match FALSE if not
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
int matlin(line)
|
||||
char *line; /* Line to match */
|
||||
|
||||
{
|
||||
int rtncode; /* Return value from this routine */
|
||||
|
||||
|
||||
#ifdef NOREGEXP
|
||||
char *pptr, *lptr, *tlptr;
|
||||
int c1, c2;
|
||||
#endif /* NOREGEXP */
|
||||
|
||||
if (Debug) printf("Matching %s against %s", Pat, line);
|
||||
|
||||
#ifdef REGEX
|
||||
rtncode = re_exec(line); /* Hand off to r/e evaluator */
|
||||
#endif /* REGEX */
|
||||
|
||||
#ifdef REGCMP
|
||||
rtncode = (regexec(Re, line, TRUE) != 0);
|
||||
#endif /* REGCMP */
|
||||
|
||||
#ifdef NOREGEX /* Have to do menial comparison.. */
|
||||
lptr = line; /* Init line pointer */
|
||||
|
||||
for (rtncode = -1; rtncode < 0;) {
|
||||
tlptr = lptr++; /* Get temp ptr to line */
|
||||
pptr = Pat; /* Get ptr to pattern */
|
||||
while (TRUE) {
|
||||
if ((c1 = *pptr++) == NUL) {
|
||||
rtncode = 1; /* GOOD return value */
|
||||
break;
|
||||
}
|
||||
if ((c2 = *tlptr++) == NUL) {
|
||||
rtncode = 0; /* BAD return value */
|
||||
break;
|
||||
}
|
||||
if (isupper(c1)) c1 = tolower(c1);
|
||||
if (isupper(c2)) c2 = tolower(c2);
|
||||
if (c1 != c2) break;
|
||||
}
|
||||
}
|
||||
#endif /* NOREGEX */
|
||||
|
||||
|
||||
if (Debug) printf("matlin returned %s\n", rtncode ? "TRUE" : "FALSE");
|
||||
return(rtncode);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void regerror(s)
|
||||
const char *s;
|
||||
{
|
||||
printf("%s\n", (char *) s);
|
||||
exit(1);
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
SCRIPTS= checkhier.sh
|
||||
MAN=
|
||||
|
||||
.include <bsd.prog.mk>
|
||||
.include <minix.prog.mk>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
PROG= chmem
|
||||
MAN=
|
||||
|
||||
.include <bsd.prog.mk>
|
||||
.include <minix.prog.mk>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
PROG= chmod
|
||||
MAN=
|
||||
|
||||
.include <bsd.prog.mk>
|
||||
.include <minix.prog.mk>
|
||||
|
||||
@@ -3,4 +3,4 @@ MAN=
|
||||
|
||||
LINKS+= ${BINDIR}/chown ${BINDIR}/chgrp
|
||||
|
||||
.include <bsd.prog.mk>
|
||||
.include <minix.prog.mk>
|
||||
|
||||
@@ -2,4 +2,4 @@ PROG= chroot
|
||||
BINDIR= /bin
|
||||
MAN=
|
||||
|
||||
.include <bsd.prog.mk>
|
||||
.include <minix.prog.mk>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
PROG= ci
|
||||
MAN=
|
||||
|
||||
.include <bsd.prog.mk>
|
||||
.include <minix.prog.mk>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
PROG= cksum
|
||||
MAN=
|
||||
|
||||
.include <bsd.prog.mk>
|
||||
.include <minix.prog.mk>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
PROG= cleantmp
|
||||
MAN=
|
||||
|
||||
.include <bsd.prog.mk>
|
||||
.include <minix.prog.mk>
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user