Llvm-inspired code cleanup.

This commit is contained in:
Kees van Reeuwijk 2010-07-04 23:01:32 +00:00
parent 01fcee7d71
commit 9fd2d72ce8
27 changed files with 201 additions and 135 deletions

View File

@ -22,4 +22,7 @@ struct ar_hdr {
#define AR_TOTAL 26 #define AR_TOTAL 26
#define AR_SIZE 22 #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 */ #endif /* __ARCH_H_INCLUDED */

View File

@ -4,7 +4,18 @@
*/ */
/* ar - archiver Author: Michiel Huisjes */ /* ar - archiver Author: Michiel Huisjes */
/* Made into arch/aal by Ceriel Jacobs /* 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$"; static char RcsId[] = "$Header$";
@ -26,6 +37,9 @@ static char RcsId[] = "$Header$";
*/ */
#include <stdlib.h> #include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <unistd.h>
#include <sys/types.h> #include <sys/types.h>
#include <sys/stat.h> #include <sys/stat.h>
#ifndef S_IREAD #ifndef S_IREAD
@ -101,9 +115,49 @@ char *temp_arch = &temp_buf[0];
extern char *mktemp(); extern char *mktemp();
extern char *ctime(); extern char *ctime();
usage() /* 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)
{ {
error(TRUE, "usage: %s %s archive [file] ...\n", 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",
progname, progname,
#ifdef AAL #ifdef AAL
"[acdrtxvlu]" "[acdrtxvlu]"
@ -113,23 +167,7 @@ usage()
); );
} }
/*VARARGS2*/ char *basename(char *path)
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 *ptr = path;
register char *last = NULL; register char *last = NULL;
@ -150,16 +188,14 @@ char *path;
extern unsigned int rd_unsigned2(); extern unsigned int rd_unsigned2();
open_archive(name, mode) int open_archive(char *name, int mode)
register char *name;
register int mode;
{ {
unsigned short magic = 0; unsigned short magic = 0;
int fd; int fd;
if (mode == CREATE) { if (mode == CREATE) {
if ((fd = creat(name, 0666)) < 0) if ((fd = creat(name, 0666)) < 0)
error(TRUE, "cannot creat %s\n", name); error2(TRUE, "cannot creat %s\n", name);
magic = MAGIC_NUMBER; magic = MAGIC_NUMBER;
wr_int2(fd, magic); wr_int2(fd, magic);
return fd; return fd;
@ -168,15 +204,15 @@ register int mode;
if ((fd = open(name, mode)) < 0) { if ((fd = open(name, mode)) < 0) {
if (mode == APPEND) { if (mode == APPEND) {
close(open_archive(name, CREATE)); close(open_archive(name, CREATE));
if (!nocr_fl) error(FALSE, "%s: creating %s\n", progname, name); if (!nocr_fl) error3(FALSE, "%s: creating %s\n", progname, name);
return open_archive(name, APPEND); return open_archive(name, APPEND);
} }
error(TRUE, "cannot open %s\n", name); error2(TRUE, "cannot open %s\n", name);
} }
lseek(fd, 0L, 0); lseek(fd, 0L, 0);
magic = rd_unsigned2(fd); magic = rd_unsigned2(fd);
if (magic != AALMAG && magic != ARMAG) if (magic != AALMAG && magic != ARMAG)
error(TRUE, "%s is not in ar format\n", name); error2(TRUE, "%s is not in ar format\n", name);
return fd; return fd;
} }
@ -191,9 +227,7 @@ catch()
_exit (2); _exit (2);
} }
main(argc, argv) int main(int argc, char *argv[])
int argc;
char *argv[];
{ {
register char *ptr; register char *ptr;
int needs_arg = 0; int needs_arg = 0;
@ -280,7 +314,7 @@ char *argv[];
#ifdef AAL #ifdef AAL
tab = (struct ranlib *) malloc(512 * sizeof(struct ranlib)); tab = (struct ranlib *) malloc(512 * sizeof(struct ranlib));
tstrtab = malloc(4096); tstrtab = malloc(4096);
if (!tab || !tstrtab) error(TRUE,"Out of core\n"); if (!tab || !tstrtab) error1(TRUE,"Out of core\n");
tabsz = 512; tabsz = 512;
strtabsz = 4096; strtabsz = 4096;
#endif #endif
@ -300,7 +334,7 @@ again:
if (rd_arhdr(ar_fd, &member) == 0) if (rd_arhdr(ar_fd, &member) == 0)
return NULL; return NULL;
if (member.ar_size < 0) { if (member.ar_size < 0) {
error(TRUE, "archive has member with negative size\n"); error1(TRUE, "archive has member with negative size\n");
} }
#ifdef AAL #ifdef AAL
if (equal(SYMDEF, member.ar_name)) { if (equal(SYMDEF, member.ar_name)) {
@ -313,9 +347,7 @@ again:
char *get_mode(); char *get_mode();
get(argc, argv) static void get(int argc, char *argv[])
int argc;
register char *argv[];
{ {
register MEMBER *member; register MEMBER *member;
int i = 0; int i = 0;
@ -457,10 +489,7 @@ register char *argv[];
close(ar_fd); close(ar_fd);
} }
add(name, fd, mess) static void add(char *name, int fd, char *mess)
char *name;
int fd;
char *mess;
{ {
static MEMBER member; static MEMBER member;
register int read_chars; register int read_chars;
@ -468,15 +497,15 @@ char *mess;
int src_fd; int src_fd;
if (stat(name, &status) < 0) { if (stat(name, &status) < 0) {
error(FALSE, "cannot find %s\n", name); error2(FALSE, "cannot find %s\n", name);
return; return;
} }
else if (S_ISDIR(status.st_mode)) { else if (S_ISDIR(status.st_mode)) {
error(FALSE, "%s is a directory (ignored)\n", name); error2(FALSE, "%s is a directory (ignored)\n", name);
return; return;
} }
else if ((src_fd = open(name, 0)) < 0) { else if ((src_fd = open(name, 0)) < 0) {
error(FALSE, "cannot open %s\n", name); error2(FALSE, "cannot open %s\n", name);
return; return;
} }
@ -512,7 +541,7 @@ char *mess;
} }
else status.st_size -= x; else status.st_size -= x;
if (read(src_fd, io_buffer, read_chars) != read_chars) { if (read(src_fd, io_buffer, read_chars) != read_chars) {
error(FALSE,"%s seems to shrink\n", name); error2(FALSE,"%s seems to shrink\n", name);
break; break;
} }
mwrite(fd, io_buffer, x); mwrite(fd, io_buffer, x);
@ -523,8 +552,7 @@ char *mess;
close(src_fd); close(src_fd);
} }
extract(member) static void extract(register MEMBER *member)
register MEMBER *member;
{ {
int fd = 1; int fd = 1;
char buf[sizeof(member->ar_name) + 1]; char buf[sizeof(member->ar_name) + 1];
@ -532,7 +560,7 @@ register MEMBER *member;
strncpy(buf, member->ar_name, sizeof(member->ar_name)); strncpy(buf, member->ar_name, sizeof(member->ar_name));
buf[sizeof(member->ar_name)] = 0; buf[sizeof(member->ar_name)] = 0;
if (pr_fl == FALSE && (fd = creat(buf, 0666)) < 0) { if (pr_fl == FALSE && (fd = creat(buf, 0666)) < 0) {
error(FALSE, "cannot create %s\n", buf); error2(FALSE, "cannot create %s\n", buf);
fd = -1; fd = -1;
} }
@ -548,9 +576,7 @@ register MEMBER *member;
if (pr_fl == FALSE) chmod(buf, member->ar_mode); if (pr_fl == FALSE) chmod(buf, member->ar_mode);
} }
copy_member(member, from, to, extracting) static void copy_member(MEMBER *member, int from, int to, int extracting)
register MEMBER *member;
int from, to;
{ {
register int rest; register int rest;
long mem_size = member->ar_size; long mem_size = member->ar_size;
@ -572,7 +598,7 @@ int from, to;
strncpy(buf, member->ar_name, sizeof(member->ar_name)); strncpy(buf, member->ar_name, sizeof(member->ar_name));
buf[sizeof(member->ar_name)] = 0; buf[sizeof(member->ar_name)] = 0;
error(TRUE, "read error on %s\n", buf); error2(TRUE, "read error on %s\n", buf);
} }
if (to >= 0) mwrite(to, io_buffer, rest); if (to >= 0) mwrite(to, io_buffer, rest);
mem_size -= (long) rest; mem_size -= (long) rest;
@ -607,27 +633,23 @@ register int mode;
return mode_buf; return mode_buf;
} }
wr_fatal() void wr_fatal()
{ {
error(TRUE, "write error\n"); error1(TRUE, "write error\n");
} }
rd_fatal() void rd_fatal()
{ {
error(TRUE, "read error\n"); error1(TRUE, "read error\n");
} }
mwrite(fd, address, bytes) static void mwrite(int fd, char *address, int bytes)
int fd;
register char *address;
register int bytes;
{ {
if (write(fd, address, bytes) != bytes) if (write(fd, address, bytes) != bytes)
error(TRUE, "write error\n"); error1(TRUE, "write error\n");
} }
show(s, name) static void show(char *s, char *name)
char *s, *name;
{ {
MEMBER x; MEMBER x;
char buf[sizeof(x.ar_name)+1]; char buf[sizeof(x.ar_name)+1];
@ -645,7 +667,7 @@ char *s, *name;
* then 4 bytes giving the size of the string table, followed by the string * then 4 bytes giving the size of the string table, followed by the string
* table itself. * table itself.
*/ */
write_symdef() static void write_symdef(void)
{ {
register struct ranlib *ran; register struct ranlib *ran;
register int i; register int i;
@ -690,15 +712,12 @@ write_symdef()
* The header is put in `headp'. * The header is put in `headp'.
*/ */
int int
is_outhead(headp) is_outhead(register struct outhead *headp)
register struct outhead *headp;
{ {
return !BADMAGIC(*headp) && headp->oh_nname != 0; return !BADMAGIC(*headp) && headp->oh_nname != 0;
} }
do_object(f, size) static void do_object(int f, long size)
long size;
{ {
struct outhead headbuf; struct outhead headbuf;
@ -724,8 +743,7 @@ do_object(f, size)
* name table and read and write the names one by one. Update the ranlib table * name table and read and write the names one by one. Update the ranlib table
* accordingly. * accordingly.
*/ */
do_names(headp) static void do_names(struct outhead *headp)
struct outhead *headp;
{ {
register char *strings; register char *strings;
register int nnames = headp->oh_nname; register int nnames = headp->oh_nname;
@ -736,7 +754,7 @@ do_names(headp)
if ( headp->oh_nchar != (unsigned int)headp->oh_nchar || if ( headp->oh_nchar != (unsigned int)headp->oh_nchar ||
(strings = malloc((unsigned int)headp->oh_nchar)) == (char *)0 (strings = malloc((unsigned int)headp->oh_nchar)) == (char *)0
) { ) {
error(TRUE, "string table too big\n"); error1(TRUE, "string table too big\n");
} }
rd_string(strings, headp->oh_nchar); rd_string(strings, headp->oh_nchar);
while (nnames) { while (nnames) {
@ -770,15 +788,14 @@ do_names(headp)
free(strings); free(strings);
} }
enter_name(namep) static void enter_name(struct outname *namep)
struct outname *namep;
{ {
register char *cp; register char *cp;
if (tnum >= tabsz) { if (tnum >= tabsz) {
tab = (struct ranlib *) tab = (struct ranlib *)
realloc((char *) tab, (tabsz += 512) * sizeof(struct ranlib)); realloc((char *) tab, (tabsz += 512) * sizeof(struct ranlib));
if (! tab) error(TRUE, "Out of core\n"); if (! tab) error1(TRUE, "Out of core\n");
} }
tab[tnum].ran_off = tssiz; tab[tnum].ran_off = tssiz;
tab[tnum].ran_pos = offset; tab[tnum].ran_pos = offset;
@ -786,7 +803,7 @@ enter_name(namep)
for (cp = namep->on_mptr;; cp++) { for (cp = namep->on_mptr;; cp++) {
if (tssiz >= strtabsz) { if (tssiz >= strtabsz) {
tstrtab = realloc(tstrtab, (strtabsz += 4096)); tstrtab = realloc(tstrtab, (strtabsz += 4096));
if (! tstrtab) error(TRUE, "string table overflow\n"); if (! tstrtab) error1(TRUE, "string table overflow\n");
} }
tstrtab[tssiz++] = *cp; tstrtab[tssiz++] = *cp;
if (!*cp) break; if (!*cp) break;

3
commands/aal/archiver.h Normal file
View File

@ -0,0 +1,3 @@
extern void rd_fatal();
extern void wr_fatal();

View File

@ -9,11 +9,12 @@
#else #else
#include <varargs.h> #include <varargs.h>
#endif #endif
#include <string.h>
extern char *long2str(); extern char *long2str();
static int static int
integral(c) integral(int c)
{ {
switch (c) { switch (c) {
case 'b': case 'b':
@ -39,16 +40,14 @@ integral(c)
%d = int %d = int
$ */ $ */
int int
_format(buf, fmt, argp) _format(char *buf, char *fmt, va_list argp)
char *buf, *fmt;
register va_list argp;
{ {
register char *pf = fmt; register char *pf = fmt;
register char *pb = buf; register char *pb = buf;
while (*pf) { while (*pf) {
if (*pf == '%') { if (*pf == '%') {
register width, base, pad, npad; register int width, base, pad, npad;
char *arg; char *arg;
char cbuf[2]; char cbuf[2];
char *badformat = "<bad format>"; char *badformat = "<bad format>";
@ -78,7 +77,8 @@ _format(buf, fmt, argp)
else else
if (*pf == 'l') { if (*pf == 'l') {
/* alignment ??? */ /* alignment ??? */
if (base = integral(*++pf)) { base = integral(*++pf);
if (base) {
arg = long2str(va_arg(argp,long), base); arg = long2str(va_arg(argp,long), base);
} }
else { else {
@ -87,7 +87,7 @@ _format(buf, fmt, argp)
} }
} }
else else
if (base = integral(*pf)) { if ((base = integral(*pf))) {
arg = long2str((long)va_arg(argp,int), base); arg = long2str((long)va_arg(argp,int), base);
} }
else else

2
commands/aal/format.h Normal file
View File

@ -0,0 +1,2 @@
extern int _format(char *buf, char *fmt, va_list argp);

View File

@ -15,7 +15,7 @@
char * char *
long2str(val, base) long2str(val, base)
register long val; register long val;
register base; register int base;
{ {
static char numbuf[MAXWIDTH]; static char numbuf[MAXWIDTH];
static char vec[] = "0123456789ABCDEF"; static char vec[] = "0123456789ABCDEF";
@ -38,7 +38,7 @@ long2str(val, base)
if (base < 0) { /* unsigned */ if (base < 0) { /* unsigned */
base = -base; base = -base;
if (val < 0L) { /* taken from Amoeba src */ if (val < 0L) { /* taken from Amoeba src */
register mod, i; register int mod, i;
overflow: overflow:
mod = 0; mod = 0;
for (i = 0; i < 8 * sizeof val; i++) { for (i = 0; i < 8 * sizeof val; i++) {

View File

@ -11,6 +11,8 @@
#endif #endif
#include <system.h> #include <system.h>
#include "param.h" #include "param.h"
#include "format.h"
#include "write.h"
/*VARARGS*/ /*VARARGS*/
/*FORMAT0v $ /*FORMAT0v $
@ -20,7 +22,7 @@
%[uxbo] = unsigned int %[uxbo] = unsigned int
%d = int %d = int
$ */ $ */
int void
#if __STDC__ #if __STDC__
print(char *fmt, ...) print(char *fmt, ...)
#else #else

2
commands/aal/print.h Normal file
View File

@ -0,0 +1,2 @@
extern void print(char *fmt, ...);

View File

@ -31,4 +31,6 @@ struct ranlib {
#define SZ_RAN 8 #define SZ_RAN 8
#define SF_RAN "44" #define SF_RAN "44"
extern void wr_ranlib(int fd, struct ranlib ran[], long cnt);
#endif /* __RANLIB_H_INCLUDED */ #endif /* __RANLIB_H_INCLUDED */

View File

@ -3,8 +3,13 @@
* (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands. * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
* See the copyright notice in the ACK home directory, in the file "Copyright". * See the copyright notice in the ACK home directory, in the file "Copyright".
*/ */
#include <out.h> #include <sys/types.h>
#include <fcntl.h>
#include <unistd.h>
#include "out.h"
#include "object.h" #include "object.h"
#include "rd.h"
#include "rd_bytes.h"
extern long lseek(); extern long lseek();
@ -43,9 +48,7 @@ static long rd_base;
static int sectionnr; static int sectionnr;
static static
OUTREAD(p, b, n) void OUTREAD(int p, char *b, long n)
char *b;
long n;
{ {
register long l = outseek[p]; register long l = outseek[p];
@ -62,18 +65,17 @@ OUTREAD(p, b, n)
* Open the output file according to the chosen strategy. * Open the output file according to the chosen strategy.
*/ */
int int
rd_open(f) rd_open(char *f)
char *f;
{ {
int outfile = open(f, 0);
if ((outfile = open(f, 0)) < 0) if (outfile < 0)
return 0; return 0;
return rd_fdopen(outfile); return rd_fdopen(outfile);
} }
static int offcnt; static int offcnt;
rd_fdopen(fd) int rd_fdopen(int fd)
{ {
register int i; register int i;
@ -90,20 +92,19 @@ rd_fdopen(fd)
return 1; return 1;
} }
rd_close() void rd_close()
{ {
close(outfile); close(outfile);
outfile = -1; outfile = -1;
} }
rd_fd() int rd_fd()
{ {
return outfile; return outfile;
} }
rd_ohead(head) void rd_ohead(register struct outhead *head)
register struct outhead *head;
{ {
register long off; register long off;
@ -135,7 +136,7 @@ rd_ohead(head)
#endif #endif
} }
rd_rew_relos(head) void rd_rew_relos(head)
register struct outhead *head; register struct outhead *head;
{ {
register long off = OFF_RELO(*head) + rd_base; register long off = OFF_RELO(*head) + rd_base;
@ -143,7 +144,7 @@ rd_rew_relos(head)
BEGINSEEK(PARTRELO, off); BEGINSEEK(PARTRELO, off);
} }
rd_sect(sect, cnt) void rd_sect(sect, cnt)
register struct outsect *sect; register struct outsect *sect;
register unsigned int cnt; register unsigned int cnt;
{ {
@ -173,7 +174,7 @@ rd_sect(sect, cnt)
} }
} }
rd_outsect(s) void rd_outsect(int s)
{ {
OUTSECT(s); OUTSECT(s);
sectionnr = s; sectionnr = s;
@ -182,7 +183,7 @@ rd_outsect(s)
/* /*
* We don't have to worry about byte order here. * We don't have to worry about byte order here.
*/ */
rd_emit(emit, cnt) void rd_emit(emit, cnt)
char *emit; char *emit;
long cnt; long cnt;
{ {
@ -190,11 +191,10 @@ rd_emit(emit, cnt)
offset[sectionnr] += cnt; offset[sectionnr] += cnt;
} }
rd_relo(relo, cnt) void rd_relo(relo, cnt)
register struct outrelo *relo; register struct outrelo *relo;
register unsigned int cnt; register unsigned int cnt;
{ {
OUTREAD(PARTRELO, (char *) relo, (long) cnt * SZ_RELO); OUTREAD(PARTRELO, (char *) relo, (long) cnt * SZ_RELO);
#if ! (BYTES_REVERSED || WORDS_REVERSED) #if ! (BYTES_REVERSED || WORDS_REVERSED)
if (sizeof(struct outrelo) != SZ_RELO) if (sizeof(struct outrelo) != SZ_RELO)
@ -213,9 +213,7 @@ rd_relo(relo, cnt)
} }
} }
rd_name(name, cnt) void rd_name(struct outname *name, unsigned int cnt)
register struct outname *name;
register unsigned int cnt;
{ {
OUTREAD(PARTNAME, (char *) name, (long) cnt * SZ_NAME); OUTREAD(PARTNAME, (char *) name, (long) cnt * SZ_NAME);
@ -236,18 +234,13 @@ rd_name(name, cnt)
} }
} }
rd_string(addr, len) void rd_string(char *addr, long len)
char *addr;
long len;
{ {
OUTREAD(PARTCHAR, addr, len); OUTREAD(PARTCHAR, addr, len);
} }
#ifdef SYMDBUG #ifdef SYMDBUG
rd_dbug(buf, size) void rd_dbug(char *buf, long size)
char *buf;
long size;
{ {
OUTREAD(PARTDBUG, buf, size); OUTREAD(PARTDBUG, buf, size);
} }

10
commands/aal/rd.h Normal file
View File

@ -0,0 +1,10 @@
/*
* 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[]);

View File

@ -3,12 +3,16 @@
* (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands. * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
* See the copyright notice in the ACK home directory, in the file "Copyright". * See the copyright notice in the ACK home directory, in the file "Copyright".
*/ */
#include <sys/types.h>
#include <unistd.h>
#include <arch.h> #include <arch.h>
#include "object.h" #include "object.h"
#include "arch.h"
#include "archiver.h"
int int
rd_arhdr(fd, arhdr) rd_arhdr(int fd, register struct ar_hdr *arhdr)
register struct ar_hdr *arhdr;
{ {
char buf[AR_TOTAL]; char buf[AR_TOTAL];
register char *c = buf; register char *c = buf;

View File

@ -9,16 +9,19 @@
an int! an int!
*/ */
#include <sys/types.h>
#include <unistd.h>
#include "archiver.h"
#include "rd_bytes.h"
static int maxchunk = MAXCHUNK; static int maxchunk = MAXCHUNK;
/* /*
* We don't have to worry about byte order here. * We don't have to worry about byte order here.
* Just read "cnt" bytes from file-descriptor "fd". * Just read "cnt" bytes from file-descriptor "fd".
*/ */
int void rd_bytes(int fd, char *string, long cnt)
rd_bytes(fd, string, cnt)
register char *string;
register long cnt;
{ {
while (cnt) { while (cnt) {

2
commands/aal/rd_bytes.h Normal file
View File

@ -0,0 +1,2 @@
extern void rd_bytes(int fd, char *string, long cnt);

View File

@ -4,9 +4,10 @@
* See the copyright notice in the ACK home directory, in the file "Copyright". * See the copyright notice in the ACK home directory, in the file "Copyright".
*/ */
#include "object.h" #include "object.h"
#include "rd_bytes.h"
unsigned int unsigned int
rd_unsigned2(fd) rd_unsigned2(int fd)
{ {
char buf[2]; char buf[2];

View File

@ -11,6 +11,7 @@
#endif #endif
#include <system.h> #include <system.h>
#include "param.h" #include "param.h"
#include "format.h"
/*VARARGS*/ /*VARARGS*/
/*FORMAT1v $ /*FORMAT1v $

View File

@ -43,5 +43,7 @@ extern File _sys_ftab[];
#define ILL_BREAK ((char *)0) #define ILL_BREAK ((char *)0)
/* system's idea of block */ /* system's idea of block */
#ifndef BUFSIZ
#define BUFSIZ 1024 #define BUFSIZ 1024
#endif
#endif /* __SYSTEM_INCLUDED__ */ #endif /* __SYSTEM_INCLUDED__ */

View File

@ -5,9 +5,11 @@
*/ */
#include <arch.h> #include <arch.h>
#include "object.h" #include "object.h"
#include "arch.h"
#include "write.h"
#include "wr_bytes.h"
wr_arhdr(fd, arhdr) void wr_arhdr(int fd, struct ar_hdr *arhdr)
register struct ar_hdr *arhdr;
{ {
char buf[AR_TOTAL]; char buf[AR_TOTAL];
register char *c = buf; register char *c = buf;

View File

@ -9,14 +9,17 @@
You have to put it in an int! 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; static int maxchunk = MAXCHUNK;
/* /*
* Just write "cnt" bytes to file-descriptor "fd". * Just write "cnt" bytes to file-descriptor "fd".
*/ */
wr_bytes(fd, string, cnt) void wr_bytes(int fd, register char *string, long cnt)
register char *string;
register long cnt;
{ {
while (cnt) { while (cnt) {

4
commands/aal/wr_bytes.h Normal file
View File

@ -0,0 +1,4 @@
/*
* Exported symbols of wr_bytes.c
*/
extern void wr_bytes(int fd, register char *string, long cnt);

View File

@ -4,8 +4,10 @@
* See the copyright notice in the ACK home directory, in the file "Copyright". * See the copyright notice in the ACK home directory, in the file "Copyright".
*/ */
#include "object.h" #include "object.h"
#include "wr_int2.h"
#include "wr_bytes.h"
wr_int2(fd, i) void wr_int2(int fd, int i)
{ {
char buf[2]; char buf[2];

2
commands/aal/wr_int2.h Normal file
View File

@ -0,0 +1,2 @@
extern void wr_int2(int fd, int i);

View File

@ -4,9 +4,10 @@
* See the copyright notice in the ACK home directory, in the file "Copyright". * See the copyright notice in the ACK home directory, in the file "Copyright".
*/ */
#include "object.h" #include "object.h"
#include "wr_bytes.h"
#include "wr_long.h"
wr_long(fd, l) void wr_long(int fd, long l)
long l;
{ {
char buf[4]; char buf[4];

2
commands/aal/wr_long.h Normal file
View File

@ -0,0 +1,2 @@
extern void wr_long(int fd, long l);

View File

@ -5,10 +5,10 @@
*/ */
#include <ranlib.h> #include <ranlib.h>
#include "object.h" #include "object.h"
#include "wr_bytes.h"
#include "ranlib.h"
wr_ranlib(fd, ran, cnt) void wr_ranlib(int fd, struct ranlib *ran, long cnt)
register struct ranlib *ran;
register long cnt;
{ {
#if ! (BYTES_REVERSED || WORDS_REVERSED) #if ! (BYTES_REVERSED || WORDS_REVERSED)
if (sizeof (struct ranlib) != SZ_RAN) if (sizeof (struct ranlib) != SZ_RAN)

View File

@ -4,13 +4,13 @@
*/ */
/* $Header$ */ /* $Header$ */
#include <sys/types.h>
#include <unistd.h>
#include <system.h> #include <system.h>
#include "write.h"
int int
sys_write(fp, bufptr, nbytes) sys_write(File *fp, char *bufptr, int nbytes)
File *fp;
char *bufptr;
int nbytes;
{ {
if (! fp) return 0; if (! fp) return 0;
return write(fp->o_fd, bufptr, nbytes) == nbytes; return write(fp->o_fd, bufptr, nbytes) == nbytes;

3
commands/aal/write.h Normal file
View File

@ -0,0 +1,3 @@
#include "system.h"
extern int sys_write(File *fp, char *bufptr, int nbytes);