Llvm-inspired code cleanup.
This commit is contained in:
parent
01fcee7d71
commit
9fd2d72ce8
@ -22,4 +22,7 @@ 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,7 +4,18 @@
|
||||
*/
|
||||
/* 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$";
|
||||
|
||||
@ -26,6 +37,9 @@ 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
|
||||
@ -101,9 +115,49 @@ char *temp_arch = &temp_buf[0];
|
||||
extern char *mktemp();
|
||||
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,
|
||||
#ifdef AAL
|
||||
"[acdrtxvlu]"
|
||||
@ -113,23 +167,7 @@ usage()
|
||||
);
|
||||
}
|
||||
|
||||
/*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;
|
||||
char *basename(char *path)
|
||||
{
|
||||
register char *ptr = path;
|
||||
register char *last = NULL;
|
||||
@ -150,16 +188,14 @@ char *path;
|
||||
|
||||
extern unsigned int rd_unsigned2();
|
||||
|
||||
open_archive(name, mode)
|
||||
register char *name;
|
||||
register int mode;
|
||||
int open_archive(char *name, int mode)
|
||||
{
|
||||
unsigned short magic = 0;
|
||||
int fd;
|
||||
|
||||
if (mode == CREATE) {
|
||||
if ((fd = creat(name, 0666)) < 0)
|
||||
error(TRUE, "cannot creat %s\n", name);
|
||||
error2(TRUE, "cannot creat %s\n", name);
|
||||
magic = MAGIC_NUMBER;
|
||||
wr_int2(fd, magic);
|
||||
return fd;
|
||||
@ -168,15 +204,15 @@ register int mode;
|
||||
if ((fd = open(name, mode)) < 0) {
|
||||
if (mode == APPEND) {
|
||||
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);
|
||||
}
|
||||
error(TRUE, "cannot open %s\n", name);
|
||||
error2(TRUE, "cannot open %s\n", name);
|
||||
}
|
||||
lseek(fd, 0L, 0);
|
||||
magic = rd_unsigned2(fd);
|
||||
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;
|
||||
}
|
||||
@ -191,9 +227,7 @@ catch()
|
||||
_exit (2);
|
||||
}
|
||||
|
||||
main(argc, argv)
|
||||
int argc;
|
||||
char *argv[];
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
register char *ptr;
|
||||
int needs_arg = 0;
|
||||
@ -280,7 +314,7 @@ char *argv[];
|
||||
#ifdef AAL
|
||||
tab = (struct ranlib *) malloc(512 * sizeof(struct ranlib));
|
||||
tstrtab = malloc(4096);
|
||||
if (!tab || !tstrtab) error(TRUE,"Out of core\n");
|
||||
if (!tab || !tstrtab) error1(TRUE,"Out of core\n");
|
||||
tabsz = 512;
|
||||
strtabsz = 4096;
|
||||
#endif
|
||||
@ -300,7 +334,7 @@ again:
|
||||
if (rd_arhdr(ar_fd, &member) == 0)
|
||||
return NULL;
|
||||
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
|
||||
if (equal(SYMDEF, member.ar_name)) {
|
||||
@ -313,9 +347,7 @@ again:
|
||||
|
||||
char *get_mode();
|
||||
|
||||
get(argc, argv)
|
||||
int argc;
|
||||
register char *argv[];
|
||||
static void get(int argc, char *argv[])
|
||||
{
|
||||
register MEMBER *member;
|
||||
int i = 0;
|
||||
@ -457,10 +489,7 @@ register char *argv[];
|
||||
close(ar_fd);
|
||||
}
|
||||
|
||||
add(name, fd, mess)
|
||||
char *name;
|
||||
int fd;
|
||||
char *mess;
|
||||
static void add(char *name, int fd, char *mess)
|
||||
{
|
||||
static MEMBER member;
|
||||
register int read_chars;
|
||||
@ -468,15 +497,15 @@ char *mess;
|
||||
int src_fd;
|
||||
|
||||
if (stat(name, &status) < 0) {
|
||||
error(FALSE, "cannot find %s\n", name);
|
||||
error2(FALSE, "cannot find %s\n", name);
|
||||
return;
|
||||
}
|
||||
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;
|
||||
}
|
||||
else if ((src_fd = open(name, 0)) < 0) {
|
||||
error(FALSE, "cannot open %s\n", name);
|
||||
error2(FALSE, "cannot open %s\n", name);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -512,7 +541,7 @@ char *mess;
|
||||
}
|
||||
else status.st_size -= x;
|
||||
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;
|
||||
}
|
||||
mwrite(fd, io_buffer, x);
|
||||
@ -523,8 +552,7 @@ char *mess;
|
||||
close(src_fd);
|
||||
}
|
||||
|
||||
extract(member)
|
||||
register MEMBER *member;
|
||||
static void extract(register MEMBER *member)
|
||||
{
|
||||
int fd = 1;
|
||||
char buf[sizeof(member->ar_name) + 1];
|
||||
@ -532,7 +560,7 @@ 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) {
|
||||
error(FALSE, "cannot create %s\n", buf);
|
||||
error2(FALSE, "cannot create %s\n", buf);
|
||||
fd = -1;
|
||||
}
|
||||
|
||||
@ -548,9 +576,7 @@ register MEMBER *member;
|
||||
if (pr_fl == FALSE) chmod(buf, member->ar_mode);
|
||||
}
|
||||
|
||||
copy_member(member, from, to, extracting)
|
||||
register MEMBER *member;
|
||||
int from, to;
|
||||
static void copy_member(MEMBER *member, int from, int to, int extracting)
|
||||
{
|
||||
register int rest;
|
||||
long mem_size = member->ar_size;
|
||||
@ -572,7 +598,7 @@ int from, to;
|
||||
|
||||
strncpy(buf, member->ar_name, sizeof(member->ar_name));
|
||||
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);
|
||||
mem_size -= (long) rest;
|
||||
@ -607,27 +633,23 @@ register int mode;
|
||||
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)
|
||||
int fd;
|
||||
register char *address;
|
||||
register int bytes;
|
||||
static void mwrite(int fd, char *address, int bytes)
|
||||
{
|
||||
if (write(fd, address, bytes) != bytes)
|
||||
error(TRUE, "write error\n");
|
||||
error1(TRUE, "write error\n");
|
||||
}
|
||||
|
||||
show(s, name)
|
||||
char *s, *name;
|
||||
static void show(char *s, char *name)
|
||||
{
|
||||
MEMBER x;
|
||||
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
|
||||
* table itself.
|
||||
*/
|
||||
write_symdef()
|
||||
static void write_symdef(void)
|
||||
{
|
||||
register struct ranlib *ran;
|
||||
register int i;
|
||||
@ -690,15 +712,12 @@ write_symdef()
|
||||
* The header is put in `headp'.
|
||||
*/
|
||||
int
|
||||
is_outhead(headp)
|
||||
register struct outhead *headp;
|
||||
is_outhead(register struct outhead *headp)
|
||||
{
|
||||
|
||||
return !BADMAGIC(*headp) && headp->oh_nname != 0;
|
||||
}
|
||||
|
||||
do_object(f, size)
|
||||
long size;
|
||||
static void do_object(int f, long size)
|
||||
{
|
||||
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
|
||||
* accordingly.
|
||||
*/
|
||||
do_names(headp)
|
||||
struct outhead *headp;
|
||||
static void do_names(struct outhead *headp)
|
||||
{
|
||||
register char *strings;
|
||||
register int nnames = headp->oh_nname;
|
||||
@ -736,7 +754,7 @@ do_names(headp)
|
||||
if ( headp->oh_nchar != (unsigned int)headp->oh_nchar ||
|
||||
(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);
|
||||
while (nnames) {
|
||||
@ -770,15 +788,14 @@ do_names(headp)
|
||||
free(strings);
|
||||
}
|
||||
|
||||
enter_name(namep)
|
||||
struct outname *namep;
|
||||
static void enter_name(struct outname *namep)
|
||||
{
|
||||
register char *cp;
|
||||
|
||||
if (tnum >= tabsz) {
|
||||
tab = (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_pos = offset;
|
||||
@ -786,7 +803,7 @@ enter_name(namep)
|
||||
for (cp = namep->on_mptr;; cp++) {
|
||||
if (tssiz >= strtabsz) {
|
||||
tstrtab = realloc(tstrtab, (strtabsz += 4096));
|
||||
if (! tstrtab) error(TRUE, "string table overflow\n");
|
||||
if (! tstrtab) error1(TRUE, "string table overflow\n");
|
||||
}
|
||||
tstrtab[tssiz++] = *cp;
|
||||
if (!*cp) break;
|
||||
|
3
commands/aal/archiver.h
Normal file
3
commands/aal/archiver.h
Normal file
@ -0,0 +1,3 @@
|
||||
|
||||
extern void rd_fatal();
|
||||
extern void wr_fatal();
|
@ -9,11 +9,12 @@
|
||||
#else
|
||||
#include <varargs.h>
|
||||
#endif
|
||||
#include <string.h>
|
||||
|
||||
extern char *long2str();
|
||||
|
||||
static int
|
||||
integral(c)
|
||||
integral(int c)
|
||||
{
|
||||
switch (c) {
|
||||
case 'b':
|
||||
@ -39,16 +40,14 @@ integral(c)
|
||||
%d = int
|
||||
$ */
|
||||
int
|
||||
_format(buf, fmt, argp)
|
||||
char *buf, *fmt;
|
||||
register va_list argp;
|
||||
_format(char *buf, char *fmt, va_list argp)
|
||||
{
|
||||
register char *pf = fmt;
|
||||
register char *pb = buf;
|
||||
|
||||
while (*pf) {
|
||||
if (*pf == '%') {
|
||||
register width, base, pad, npad;
|
||||
register int width, base, pad, npad;
|
||||
char *arg;
|
||||
char cbuf[2];
|
||||
char *badformat = "<bad format>";
|
||||
@ -78,7 +77,8 @@ _format(buf, fmt, argp)
|
||||
else
|
||||
if (*pf == 'l') {
|
||||
/* alignment ??? */
|
||||
if (base = integral(*++pf)) {
|
||||
base = integral(*++pf);
|
||||
if (base) {
|
||||
arg = long2str(va_arg(argp,long), base);
|
||||
}
|
||||
else {
|
||||
@ -87,7 +87,7 @@ _format(buf, fmt, argp)
|
||||
}
|
||||
}
|
||||
else
|
||||
if (base = integral(*pf)) {
|
||||
if ((base = integral(*pf))) {
|
||||
arg = long2str((long)va_arg(argp,int), base);
|
||||
}
|
||||
else
|
||||
|
2
commands/aal/format.h
Normal file
2
commands/aal/format.h
Normal file
@ -0,0 +1,2 @@
|
||||
|
||||
extern int _format(char *buf, char *fmt, va_list argp);
|
@ -15,7 +15,7 @@
|
||||
char *
|
||||
long2str(val, base)
|
||||
register long val;
|
||||
register base;
|
||||
register int 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 mod, i;
|
||||
register int mod, i;
|
||||
overflow:
|
||||
mod = 0;
|
||||
for (i = 0; i < 8 * sizeof val; i++) {
|
||||
|
@ -11,6 +11,8 @@
|
||||
#endif
|
||||
#include <system.h>
|
||||
#include "param.h"
|
||||
#include "format.h"
|
||||
#include "write.h"
|
||||
|
||||
/*VARARGS*/
|
||||
/*FORMAT0v $
|
||||
@ -20,7 +22,7 @@
|
||||
%[uxbo] = unsigned int
|
||||
%d = int
|
||||
$ */
|
||||
int
|
||||
void
|
||||
#if __STDC__
|
||||
print(char *fmt, ...)
|
||||
#else
|
||||
|
2
commands/aal/print.h
Normal file
2
commands/aal/print.h
Normal file
@ -0,0 +1,2 @@
|
||||
|
||||
extern void print(char *fmt, ...);
|
@ -31,4 +31,6 @@ 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,8 +3,13 @@
|
||||
* (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
|
||||
* 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 "rd.h"
|
||||
#include "rd_bytes.h"
|
||||
|
||||
extern long lseek();
|
||||
|
||||
@ -43,9 +48,7 @@ static long rd_base;
|
||||
static int sectionnr;
|
||||
|
||||
static
|
||||
OUTREAD(p, b, n)
|
||||
char *b;
|
||||
long n;
|
||||
void OUTREAD(int p, char *b, long n)
|
||||
{
|
||||
register long l = outseek[p];
|
||||
|
||||
@ -62,18 +65,17 @@ OUTREAD(p, b, n)
|
||||
* Open the output file according to the chosen strategy.
|
||||
*/
|
||||
int
|
||||
rd_open(f)
|
||||
char *f;
|
||||
rd_open(char *f)
|
||||
{
|
||||
|
||||
if ((outfile = open(f, 0)) < 0)
|
||||
int outfile = open(f, 0);
|
||||
if (outfile < 0)
|
||||
return 0;
|
||||
return rd_fdopen(outfile);
|
||||
}
|
||||
|
||||
static int offcnt;
|
||||
|
||||
rd_fdopen(fd)
|
||||
int rd_fdopen(int fd)
|
||||
{
|
||||
register int i;
|
||||
|
||||
@ -90,20 +92,19 @@ rd_fdopen(fd)
|
||||
return 1;
|
||||
}
|
||||
|
||||
rd_close()
|
||||
void rd_close()
|
||||
{
|
||||
|
||||
close(outfile);
|
||||
outfile = -1;
|
||||
}
|
||||
|
||||
rd_fd()
|
||||
int rd_fd()
|
||||
{
|
||||
return outfile;
|
||||
}
|
||||
|
||||
rd_ohead(head)
|
||||
register struct outhead *head;
|
||||
void rd_ohead(register struct outhead *head)
|
||||
{
|
||||
register long off;
|
||||
|
||||
@ -135,7 +136,7 @@ rd_ohead(head)
|
||||
#endif
|
||||
}
|
||||
|
||||
rd_rew_relos(head)
|
||||
void rd_rew_relos(head)
|
||||
register struct outhead *head;
|
||||
{
|
||||
register long off = OFF_RELO(*head) + rd_base;
|
||||
@ -143,7 +144,7 @@ rd_rew_relos(head)
|
||||
BEGINSEEK(PARTRELO, off);
|
||||
}
|
||||
|
||||
rd_sect(sect, cnt)
|
||||
void rd_sect(sect, cnt)
|
||||
register struct outsect *sect;
|
||||
register unsigned int cnt;
|
||||
{
|
||||
@ -173,7 +174,7 @@ rd_sect(sect, cnt)
|
||||
}
|
||||
}
|
||||
|
||||
rd_outsect(s)
|
||||
void rd_outsect(int s)
|
||||
{
|
||||
OUTSECT(s);
|
||||
sectionnr = s;
|
||||
@ -182,7 +183,7 @@ rd_outsect(s)
|
||||
/*
|
||||
* We don't have to worry about byte order here.
|
||||
*/
|
||||
rd_emit(emit, cnt)
|
||||
void rd_emit(emit, cnt)
|
||||
char *emit;
|
||||
long cnt;
|
||||
{
|
||||
@ -190,11 +191,10 @@ rd_emit(emit, cnt)
|
||||
offset[sectionnr] += cnt;
|
||||
}
|
||||
|
||||
rd_relo(relo, cnt)
|
||||
void 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,9 +213,7 @@ rd_relo(relo, cnt)
|
||||
}
|
||||
}
|
||||
|
||||
rd_name(name, cnt)
|
||||
register struct outname *name;
|
||||
register unsigned int cnt;
|
||||
void rd_name(struct outname *name, unsigned int cnt)
|
||||
{
|
||||
|
||||
OUTREAD(PARTNAME, (char *) name, (long) cnt * SZ_NAME);
|
||||
@ -236,18 +234,13 @@ rd_name(name, cnt)
|
||||
}
|
||||
}
|
||||
|
||||
rd_string(addr, len)
|
||||
char *addr;
|
||||
long len;
|
||||
void rd_string(char *addr, long len)
|
||||
{
|
||||
|
||||
OUTREAD(PARTCHAR, addr, len);
|
||||
}
|
||||
|
||||
#ifdef SYMDBUG
|
||||
rd_dbug(buf, size)
|
||||
char *buf;
|
||||
long size;
|
||||
void rd_dbug(char *buf, long size)
|
||||
{
|
||||
OUTREAD(PARTDBUG, buf, size);
|
||||
}
|
||||
|
10
commands/aal/rd.h
Normal file
10
commands/aal/rd.h
Normal 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[]);
|
@ -3,12 +3,16 @@
|
||||
* (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(fd, arhdr)
|
||||
register struct ar_hdr *arhdr;
|
||||
rd_arhdr(int fd, register struct ar_hdr *arhdr)
|
||||
{
|
||||
char buf[AR_TOTAL];
|
||||
register char *c = buf;
|
||||
|
@ -9,16 +9,19 @@
|
||||
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".
|
||||
*/
|
||||
int
|
||||
rd_bytes(fd, string, cnt)
|
||||
register char *string;
|
||||
register long cnt;
|
||||
void rd_bytes(int fd, char *string, long cnt)
|
||||
{
|
||||
|
||||
while (cnt) {
|
||||
|
2
commands/aal/rd_bytes.h
Normal file
2
commands/aal/rd_bytes.h
Normal file
@ -0,0 +1,2 @@
|
||||
|
||||
extern void rd_bytes(int fd, char *string, long cnt);
|
@ -4,9 +4,10 @@
|
||||
* See the copyright notice in the ACK home directory, in the file "Copyright".
|
||||
*/
|
||||
#include "object.h"
|
||||
#include "rd_bytes.h"
|
||||
|
||||
unsigned int
|
||||
rd_unsigned2(fd)
|
||||
rd_unsigned2(int fd)
|
||||
{
|
||||
char buf[2];
|
||||
|
||||
|
@ -11,6 +11,7 @@
|
||||
#endif
|
||||
#include <system.h>
|
||||
#include "param.h"
|
||||
#include "format.h"
|
||||
|
||||
/*VARARGS*/
|
||||
/*FORMAT1v $
|
||||
|
@ -43,5 +43,7 @@ extern File _sys_ftab[];
|
||||
#define ILL_BREAK ((char *)0)
|
||||
|
||||
/* system's idea of block */
|
||||
#ifndef BUFSIZ
|
||||
#define BUFSIZ 1024
|
||||
#endif
|
||||
#endif /* __SYSTEM_INCLUDED__ */
|
||||
|
@ -5,9 +5,11 @@
|
||||
*/
|
||||
#include <arch.h>
|
||||
#include "object.h"
|
||||
#include "arch.h"
|
||||
#include "write.h"
|
||||
#include "wr_bytes.h"
|
||||
|
||||
wr_arhdr(fd, arhdr)
|
||||
register struct ar_hdr *arhdr;
|
||||
void wr_arhdr(int fd, struct ar_hdr *arhdr)
|
||||
{
|
||||
char buf[AR_TOTAL];
|
||||
register char *c = buf;
|
||||
|
@ -9,14 +9,17 @@
|
||||
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".
|
||||
*/
|
||||
wr_bytes(fd, string, cnt)
|
||||
register char *string;
|
||||
register long cnt;
|
||||
void wr_bytes(int fd, register char *string, long cnt)
|
||||
{
|
||||
|
||||
while (cnt) {
|
||||
|
4
commands/aal/wr_bytes.h
Normal file
4
commands/aal/wr_bytes.h
Normal file
@ -0,0 +1,4 @@
|
||||
/*
|
||||
* Exported symbols of wr_bytes.c
|
||||
*/
|
||||
extern void wr_bytes(int fd, register char *string, long cnt);
|
@ -4,8 +4,10 @@
|
||||
* See the copyright notice in the ACK home directory, in the file "Copyright".
|
||||
*/
|
||||
#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];
|
||||
|
||||
|
2
commands/aal/wr_int2.h
Normal file
2
commands/aal/wr_int2.h
Normal file
@ -0,0 +1,2 @@
|
||||
|
||||
extern void wr_int2(int fd, int i);
|
@ -4,9 +4,10 @@
|
||||
* See the copyright notice in the ACK home directory, in the file "Copyright".
|
||||
*/
|
||||
#include "object.h"
|
||||
#include "wr_bytes.h"
|
||||
#include "wr_long.h"
|
||||
|
||||
wr_long(fd, l)
|
||||
long l;
|
||||
void wr_long(int fd, long l)
|
||||
{
|
||||
char buf[4];
|
||||
|
||||
|
2
commands/aal/wr_long.h
Normal file
2
commands/aal/wr_long.h
Normal file
@ -0,0 +1,2 @@
|
||||
|
||||
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"
|
||||
|
||||
wr_ranlib(fd, ran, cnt)
|
||||
register struct ranlib *ran;
|
||||
register long cnt;
|
||||
void wr_ranlib(int fd, struct ranlib *ran, 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(fp, bufptr, nbytes)
|
||||
File *fp;
|
||||
char *bufptr;
|
||||
int nbytes;
|
||||
sys_write(File *fp, char *bufptr, int nbytes)
|
||||
{
|
||||
if (! fp) return 0;
|
||||
return write(fp->o_fd, bufptr, nbytes) == nbytes;
|
||||
|
3
commands/aal/write.h
Normal file
3
commands/aal/write.h
Normal file
@ -0,0 +1,3 @@
|
||||
|
||||
#include "system.h"
|
||||
extern int sys_write(File *fp, char *bufptr, int nbytes);
|
Loading…
x
Reference in New Issue
Block a user