rename rd_long/wr_long to rd_int4/wr_int4 for consistency. Align declaration and definition name of parameters and adapt man page accordingly.
This commit is contained in:
parent
bb6540c5f4
commit
ccfd8a3e18
|
@ -5,7 +5,7 @@ wr_open, wr_close, wr_ohead, wr_sect, wr_outsect, wr_emit, wr_putc, wr_relo,
|
||||||
wr_name, wr_string, wr_arhdr, wr_ranlib, wr_int2, wr_long, wr_bytes,
|
wr_name, wr_string, wr_arhdr, wr_ranlib, wr_int2, wr_long, wr_bytes,
|
||||||
rd_open, rd_fdopen, rd_close, rd_ohead, rd_sect, rd_outsect,
|
rd_open, rd_fdopen, rd_close, rd_ohead, rd_sect, rd_outsect,
|
||||||
rd_emit, rd_relo, rd_rew_relo, rd_name, rd_string, rd_arhdr, rd_ranlib,
|
rd_emit, rd_relo, rd_rew_relo, rd_name, rd_string, rd_arhdr, rd_ranlib,
|
||||||
rd_int2, rd_unsigned2, rd_long, rd_bytes, rd_fd\ \-\ routines to read
|
rd_int2, rd_unsigned2, rd_int4, rd_bytes, rd_fd\ \-\ routines to read
|
||||||
and write ACK-object files and libraries
|
and write ACK-object files and libraries
|
||||||
.SH SYNOPSIS
|
.SH SYNOPSIS
|
||||||
.B #include <out.h>
|
.B #include <out.h>
|
||||||
|
@ -16,25 +16,25 @@ and write ACK-object files and libraries
|
||||||
.br
|
.br
|
||||||
.B #include <object.h>
|
.B #include <object.h>
|
||||||
.PP
|
.PP
|
||||||
.B FILE* wr_open(const char *filename)
|
.B int wr_open(const char *filename)
|
||||||
.PP
|
.PP
|
||||||
.B void wr_close()
|
.B void wr_close(void)
|
||||||
.PP
|
.PP
|
||||||
.B void wr_ohead(struct outhead *head)
|
.B void wr_ohead(const struct outhead *head)
|
||||||
.PP
|
.PP
|
||||||
.B void wr_sect(struct outsect *sect, unsigned int cnt)
|
.B void wr_sect(const struct outsect *sect, unsigned int cnt)
|
||||||
.PP
|
.PP
|
||||||
.B void wr_outsect(int sectionnr)
|
.B void wr_outsect(int sectno)
|
||||||
.PP
|
.PP
|
||||||
.B void wr_emit(const char *emit, long cnt)
|
.B void wr_emit(const char *emit, long cnt)
|
||||||
.PP
|
.PP
|
||||||
.B void wr_putc(int ch)
|
.B void wr_putc(int c)
|
||||||
.PP
|
.PP
|
||||||
.B void wr_relo(const struct outrelo *relo, unsigned int cnt)
|
.B void wr_relo(const struct outrelo *relo, unsigned int cnt)
|
||||||
.PP
|
.PP
|
||||||
.B void wr_name(struct outname *name, unsigned int cnt)
|
.B void wr_name(const struct outname *name, unsigned int cnt)
|
||||||
.PP
|
.PP
|
||||||
.B void wr_string(const char *stringaddr, long cnt)
|
.B void wr_string(const char *addr, long len)
|
||||||
.PP
|
.PP
|
||||||
.B void wr_arhdr(FILE* fd, struct ar_hdr *arhdr)
|
.B void wr_arhdr(FILE* fd, struct ar_hdr *arhdr)
|
||||||
.PP
|
.PP
|
||||||
|
@ -44,25 +44,25 @@ and write ACK-object files and libraries
|
||||||
.PP
|
.PP
|
||||||
.B void wr_long(FILE* fd, long l)
|
.B void wr_long(FILE* fd, long l)
|
||||||
.PP
|
.PP
|
||||||
.B void wr_bytes(FILE* fd, const char* buf, long l)
|
.B void wr_bytes(FILE* fd, const char* buf, long cnt)
|
||||||
.PP
|
.PP
|
||||||
.B int rd_open(const char *filename)
|
.B int rd_open(const char *filename)
|
||||||
.PP
|
.PP
|
||||||
.B int rd_fdopen(FILE* fd)
|
.B int rd_fdopen(FILE* fd)
|
||||||
.PP
|
.PP
|
||||||
.B void rd_close()
|
.B void rd_close(void)
|
||||||
.PP
|
.PP
|
||||||
.B void rd_ohead(struct outhead *head)
|
.B void rd_ohead(struct outhead *head)
|
||||||
.PP
|
.PP
|
||||||
.B void rd_sect(struct outsect *sect, unsigned int cnt)
|
.B void rd_sect(struct outsect *sect, unsigned int cnt)
|
||||||
.PP
|
.PP
|
||||||
.B void rd_outsect(int sectionnr)
|
.B void rd_outsect(int sectno)
|
||||||
.PP
|
.PP
|
||||||
.B void rd_emit(char *emit, long cnt)
|
.B void rd_emit(char *emit, long cnt)
|
||||||
.PP
|
.PP
|
||||||
.B void rd_relo(struct outrelo *relo, unsigned int cnt)
|
.B void rd_relo(struct outrelo *relo, unsigned int cnt)
|
||||||
.PP
|
.PP
|
||||||
.B void rd_rew_relo(struct outhead *head)
|
.B void rd_rew_relos(struct outhead *head)
|
||||||
.PP
|
.PP
|
||||||
.B void rd_name(struct outname *name, unsigned int cnt)
|
.B void rd_name(struct outname *name, unsigned int cnt)
|
||||||
.PP
|
.PP
|
||||||
|
@ -76,86 +76,86 @@ and write ACK-object files and libraries
|
||||||
.PP
|
.PP
|
||||||
.B unsigned int rd_unsigned2(FILE* fd)
|
.B unsigned int rd_unsigned2(FILE* fd)
|
||||||
.PP
|
.PP
|
||||||
.B long rd_long(FILE* fd)
|
.B long rd_int4FILE* fd)
|
||||||
.PP
|
.PP
|
||||||
.B void rd_bytes(FILE* fd, char *buf, long l)
|
.B void rd_bytes(FILE* fd, char *buf, long l)
|
||||||
.PP
|
.PP
|
||||||
.B FILE* rd_fd()
|
.B FILE* rd_fd(void)
|
||||||
.SH DESCRIPTION
|
.SH DESCRIPTION
|
||||||
These routines come in handy when reading or writing ACK-object files
|
These routines come in handy when reading or writing ACK-object files
|
||||||
or libraries. No checking is performed.
|
or libraries. No checking is performed.
|
||||||
.PP
|
.PP
|
||||||
.I Wr_open
|
.I wr_open
|
||||||
opens the file
|
opens the file
|
||||||
.I filename
|
.I filename
|
||||||
for writing and initializes some of this modules local variables.
|
for writing and initializes some of this modules local variables.
|
||||||
It must be called before writing parts of the object file.
|
It must be called before writing parts of the object file.
|
||||||
It returns 1 if it succeeds, 0 if it fails.
|
It returns 1 if it succeeds, 0 if it fails.
|
||||||
.PP
|
.PP
|
||||||
.I Wr_close
|
.I wr_close
|
||||||
closes the object file. Don't forget to call it, because it might
|
closes the object file. Don't forget to call it, because it might
|
||||||
flush internal buffers.
|
flush internal buffers.
|
||||||
.PP
|
.PP
|
||||||
.I Wr_ohead
|
.I wr_ohead
|
||||||
writes the
|
writes the
|
||||||
.I head
|
.I head
|
||||||
header structure.
|
header structure.
|
||||||
This routine must be called before the routines to write the other
|
This routine must be called before the routines to write the other
|
||||||
parts.
|
parts.
|
||||||
.PP
|
.PP
|
||||||
.I Wr_sect
|
.I wr_sect
|
||||||
writes
|
writes
|
||||||
.I cnt
|
.I cnt
|
||||||
section headers, starting at
|
section headers, starting at
|
||||||
.IB sect .
|
.IB sect .
|
||||||
Before writing a section, its section header must be written.
|
Before writing a section, its section header must be written.
|
||||||
.PP
|
.PP
|
||||||
.I Wr_outsect
|
.I wr_outsect
|
||||||
indicates that the next section to be written is
|
indicates that the next section to be written is
|
||||||
.IB sectionnr .
|
.IB secno .
|
||||||
This routine can be used to switch between sections.
|
This routine can be used to switch between sections.
|
||||||
.PP
|
.PP
|
||||||
.I Wr_emit
|
.I wr_emit
|
||||||
writes
|
writes
|
||||||
.I cnt
|
.I cnt
|
||||||
bytes, starting at
|
bytes, starting at
|
||||||
.IB emit ,
|
.IB emit ,
|
||||||
of the current section.
|
of the current section.
|
||||||
.PP
|
.PP
|
||||||
.I Wr_putc
|
.I wr_putc
|
||||||
adds character
|
adds byte
|
||||||
.I ch
|
.I ch
|
||||||
to the current section.
|
to the current section.
|
||||||
.PP
|
.PP
|
||||||
.I Wr_relo
|
.I wr_relo
|
||||||
writes
|
writes
|
||||||
.I cnt
|
.I cnt
|
||||||
outrelo structures, indicated by
|
outrelo structures, indicated by
|
||||||
.IB relo ,
|
.IB relo ,
|
||||||
in the relocation information part of the object file.
|
in the relocation information part of the object file.
|
||||||
.PP
|
.PP
|
||||||
.I Wr_name
|
.I wr_name
|
||||||
writes
|
writes
|
||||||
.I cnt
|
.I cnt
|
||||||
outname structures, indicated by
|
outname structures, indicated by
|
||||||
.IB name ,
|
.IB name ,
|
||||||
in the name-table part of the object file.
|
in the name-table part of the object file.
|
||||||
.PP
|
.PP
|
||||||
.I Wr_string
|
.I wr_string
|
||||||
writes
|
writes
|
||||||
.I cnt
|
.I cnt
|
||||||
bytes, indicated by
|
bytes, indicated by
|
||||||
.IB stringaddr ,
|
.IB addr,
|
||||||
in the string table part of the object file.
|
in the string table part of the object file.
|
||||||
.PP
|
.PP
|
||||||
The next few routines can be used independantly:
|
The next few routines can be used independantly:
|
||||||
.I Wr_arhdr
|
.I wr_arhdr
|
||||||
writes the archive member header
|
writes the archive member header
|
||||||
.I arhdr
|
.I arhdr
|
||||||
to file descriptor
|
to file descriptor
|
||||||
.IB fd .
|
.IB fd .
|
||||||
.PP
|
.PP
|
||||||
.I Wr_ranlib
|
.I wr_ranlib
|
||||||
writes
|
writes
|
||||||
.I cnt
|
.I cnt
|
||||||
ranlib structures, indicated by
|
ranlib structures, indicated by
|
||||||
|
@ -163,23 +163,23 @@ ranlib structures, indicated by
|
||||||
to file descriptor
|
to file descriptor
|
||||||
.IB fd.
|
.IB fd.
|
||||||
.PP
|
.PP
|
||||||
.I Wr_int2
|
.I wr_int2
|
||||||
writes a 2-byte integer
|
writes a 2-byte integer
|
||||||
.I i
|
.I i
|
||||||
to file descriptor
|
to file descriptor
|
||||||
.IB fd ,
|
.IB fd ,
|
||||||
low order byte first.
|
low order byte first.
|
||||||
.PP
|
.PP
|
||||||
.I Wr_long
|
.I wr_long
|
||||||
writes a 4-byte integer
|
writes a 4-byte integer
|
||||||
.I l
|
.I l
|
||||||
to file descriptor
|
to file descriptor
|
||||||
.IB fd ,
|
.IB fd ,
|
||||||
low order word first, low order byte first.
|
low order word first, low order byte first.
|
||||||
.PP
|
.PP
|
||||||
.I Wr_bytes
|
.I wr_bytes
|
||||||
writes
|
writes
|
||||||
.I l
|
.I cnt
|
||||||
bytes from
|
bytes from
|
||||||
.I buf
|
.I buf
|
||||||
to file descriptor
|
to file descriptor
|
||||||
|
@ -191,7 +191,7 @@ routines are the opposite of the
|
||||||
.I wr_
|
.I wr_
|
||||||
routines. However, a few of them deserve special mentioning:
|
routines. However, a few of them deserve special mentioning:
|
||||||
.PP
|
.PP
|
||||||
.I Rd_fdopen
|
.I rd_fdopen
|
||||||
initialises for reading an "object file" from file descriptor
|
initialises for reading an "object file" from file descriptor
|
||||||
.IB fd ,
|
.IB fd ,
|
||||||
at its current position.
|
at its current position.
|
||||||
|
@ -201,16 +201,16 @@ When using this entry point for reading,
|
||||||
.I rd_close
|
.I rd_close
|
||||||
does not have to be called.
|
does not have to be called.
|
||||||
.PP
|
.PP
|
||||||
.I Rd_rew_relo
|
.I rd_rew_relos
|
||||||
rewinds the relocation part, so that it can be read again.
|
rewinds the relocation part, so that it can be read again.
|
||||||
\fILed\fR(6) sometimes needs this.
|
\fILed\fR(6) sometimes needs this.
|
||||||
.PP
|
.PP
|
||||||
.I Rd_unsigned2
|
.I rd_unsigned2
|
||||||
reads two bytes from file descriptor
|
reads two bytes from file descriptor
|
||||||
.I fd
|
.I fd
|
||||||
and interpretes them as an unsigned integer.
|
and interprets them as an unsigned integer.
|
||||||
.PP
|
.PP
|
||||||
.I Rd_arhdr
|
.I rd_arhdr
|
||||||
returns 1 if a header was read, and 0 on end-of-file.
|
returns 1 if a header was read, and 0 on end-of-file.
|
||||||
.PP
|
.PP
|
||||||
When using any of the reading routines, a routine
|
When using any of the reading routines, a routine
|
||||||
|
|
|
@ -17,49 +17,40 @@ struct outsect;
|
||||||
struct ranlib;
|
struct ranlib;
|
||||||
struct outname;
|
struct outname;
|
||||||
|
|
||||||
int wr_open(const char *f);
|
int wr_open(const char *filename);
|
||||||
void wr_close(void);
|
void wr_close(void);
|
||||||
void wr_ohead(const struct outhead *h);
|
void wr_ohead(const struct outhead *head);
|
||||||
void wr_sect(const struct outsect *s, unsigned int c);
|
void wr_sect(const struct outsect *sect, unsigned int cnt);
|
||||||
void wr_outsect(int sectno);
|
void wr_outsect(int sectno);
|
||||||
void wr_emit(const char *b, long c);
|
void wr_emit(const char *emit, long cnt);
|
||||||
void wr_putc(int c);
|
void wr_putc(int c);
|
||||||
void wr_relo(const struct outrelo *r, unsigned int c);
|
void wr_relo(const struct outrelo *relo, unsigned int cnt);
|
||||||
void wr_name(const struct outname *n, unsigned int c);
|
void wr_name(const struct outname *name, unsigned int cnt);
|
||||||
void wr_string(const char *s, long c);
|
void wr_string(const char *addr, long len);
|
||||||
|
|
||||||
|
void wr_arhdr(FILE* fd, struct ar_hdr *arhdr);
|
||||||
void wr_arhdr(FILE* fd, struct ar_hdr *a);
|
void wr_ranlib(FILE* fd, struct ranlib *ran, long cnt);
|
||||||
void wr_ranlib(FILE* fd, struct ranlib *r, long cnt);
|
|
||||||
void wr_int2(FILE* fd, int i);
|
void wr_int2(FILE* fd, int i);
|
||||||
void wr_long(FILE* fd, long l);
|
void wr_int4(FILE* fd, long l);
|
||||||
void wr_bytes(FILE* fd, const char *buf, long l);
|
void wr_bytes(FILE* fd, const char *buf, long cnt);
|
||||||
|
|
||||||
|
|
||||||
int rd_open(const char *f);
|
int rd_open(const char *filename);
|
||||||
int rd_fdopen(FILE* fd);
|
int rd_fdopen(FILE* fd);
|
||||||
void rd_close(void);
|
void rd_close(void);
|
||||||
void rd_ohead(struct outhead *h);
|
void rd_ohead(struct outhead* head);
|
||||||
void rd_sect(struct outsect *s, unsigned int c);
|
void rd_sect(struct outsect* sect, unsigned int cnt);
|
||||||
void rd_outsect(int sectno);
|
void rd_outsect(int sectno);
|
||||||
void rd_emit(char *b, long c);
|
void rd_emit(char* emit, long cnt);
|
||||||
void rd_relo(struct outrelo *r, unsigned int c);
|
void rd_relo(struct outrelo* relo, unsigned int cnt);
|
||||||
void rd_rew_relos(struct outhead *head);
|
void rd_rew_relos(struct outhead *head);
|
||||||
void rd_name(struct outname *n, unsigned int c);
|
void rd_name(struct outname* name, unsigned int cnt);
|
||||||
void rd_string(char *s, long c);
|
void rd_string(char* addr, long len);
|
||||||
|
|
||||||
/** Reads an archive header and returns the filled
|
int rd_arhdr(FILE* fd, register struct ar_hdr *arhdr);
|
||||||
* up archive header structure. Returns 0 if failure
|
void rd_ranlib(FILE* fd, register struct ranlib *ran, register long cnt);
|
||||||
* otherwise returns 1.
|
|
||||||
*
|
|
||||||
* @param[in] fd Opened file descriptor to read from.
|
|
||||||
* @param[out] a Archive header structure.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
int rd_arhdr(FILE* fd, struct ar_hdr *a);
|
|
||||||
void rd_ranlib(FILE* fd, struct ranlib *r, long cnt);
|
|
||||||
int rd_int2(FILE* fd);
|
int rd_int2(FILE* fd);
|
||||||
long rd_long(FILE* fd);
|
long rd_int4(FILE* fd);
|
||||||
unsigned int rd_unsigned2(FILE* fd);
|
unsigned int rd_unsigned2(FILE* fd);
|
||||||
void rd_bytes(FILE* fd, char *buf, long l);
|
void rd_bytes(FILE* fd, char *buf, long l);
|
||||||
FILE* rd_fd(void);
|
FILE* rd_fd(void);
|
||||||
|
|
|
@ -61,10 +61,10 @@ OUTREAD(int p, char* b, long n)
|
||||||
/*
|
/*
|
||||||
* Open the output file according to the chosen strategy.
|
* Open the output file according to the chosen strategy.
|
||||||
*/
|
*/
|
||||||
int rd_open(const char* f)
|
int rd_open(const char* filename)
|
||||||
{
|
{
|
||||||
|
|
||||||
if ((outfile = fopen(f, "rb")) == NULL)
|
if ((outfile = fopen(filename, "rb")) == NULL)
|
||||||
return 0;
|
return 0;
|
||||||
return rd_fdopen(outfile);
|
return rd_fdopen(outfile);
|
||||||
}
|
}
|
||||||
|
@ -160,10 +160,10 @@ rd_sect(struct outsect* sect, unsigned int cnt)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
rd_outsect(int s)
|
rd_outsect(int sectno)
|
||||||
{
|
{
|
||||||
OUTSECT(s);
|
OUTSECT(sectno);
|
||||||
sectionnr = s;
|
sectionnr = sectno;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
|
|
||||||
extern void rd_fatal(void);
|
extern void rd_fatal(void);
|
||||||
|
|
||||||
|
|
||||||
int rd_arhdr(FILE* fd, register struct ar_hdr *arhdr)
|
int rd_arhdr(FILE* fd, register struct ar_hdr *arhdr)
|
||||||
{
|
{
|
||||||
char buf[AR_TOTAL];
|
char buf[AR_TOTAL];
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
#include "obj.h"
|
#include "obj.h"
|
||||||
|
|
||||||
|
|
||||||
long rd_long(FILE* fd)
|
long rd_int4(FILE* fd)
|
||||||
{
|
{
|
||||||
char buf[4];
|
char buf[4];
|
||||||
|
|
|
@ -144,18 +144,18 @@ static void BEGINSEEK(int p, long o)
|
||||||
/*
|
/*
|
||||||
* Open the output file according to the chosen strategy.
|
* Open the output file according to the chosen strategy.
|
||||||
*/
|
*/
|
||||||
int wr_open(const char *f)
|
int wr_open(const char *filename)
|
||||||
{
|
{
|
||||||
struct fil *fdp;
|
struct fil *fdp;
|
||||||
|
|
||||||
fclose(fopen(f,"wb"));
|
fclose(fopen(filename,"wb"));
|
||||||
#ifdef OUTSEEK
|
#ifdef OUTSEEK
|
||||||
if ((outfile = fopen(f, "ab+")) == NULL)
|
if ((outfile = fopen(filename, "ab+")) == NULL)
|
||||||
return 0;
|
return 0;
|
||||||
currpos = 0;
|
currpos = 0;
|
||||||
#else /* not OUTSEEK */
|
#else /* not OUTSEEK */
|
||||||
for (fdp = &__parts[PARTEMIT]; fdp < &__parts[NPARTS]; fdp++)
|
for (fdp = &__parts[PARTEMIT]; fdp < &__parts[NPARTS]; fdp++)
|
||||||
if ((fdp->fd = fopen(f, "wb+")) == NULL)
|
if ((fdp->fd = fopen(filename, "wb+")) == NULL)
|
||||||
return 0;
|
return 0;
|
||||||
#endif /* not OUTSEEK */
|
#endif /* not OUTSEEK */
|
||||||
offcnt = 0;
|
offcnt = 0;
|
||||||
|
@ -254,12 +254,12 @@ wr_sect(const struct outsect *sect, unsigned int cnt)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
wr_outsect(int s)
|
wr_outsect(int sectno)
|
||||||
/* s = section number */
|
/* s = section number */
|
||||||
{
|
{
|
||||||
struct fil *ptr = &__parts[PARTEMIT + getsect(sectionnr)];
|
struct fil *ptr = &__parts[PARTEMIT + getsect(sectionnr)];
|
||||||
|
|
||||||
if (s != sectionnr && s >= (SECTCNT-1) && sectionnr >= (SECTCNT-1)) {
|
if (sectno != sectionnr && sectno >= (SECTCNT-1) && sectionnr >= (SECTCNT-1)) {
|
||||||
#ifdef OUTSEEK
|
#ifdef OUTSEEK
|
||||||
if (currpos != ptr->currpos)
|
if (currpos != ptr->currpos)
|
||||||
{
|
{
|
||||||
|
@ -273,18 +273,18 @@ wr_outsect(int s)
|
||||||
currpos = ptr->currpos;
|
currpos = ptr->currpos;
|
||||||
#endif
|
#endif
|
||||||
offset[sectionnr] = ptr->currpos;
|
offset[sectionnr] = ptr->currpos;
|
||||||
if (offset[s] != ptr->currpos) {
|
if (offset[sectno] != ptr->currpos) {
|
||||||
fseek(ptr->fd, offset[s], SEEK_SET);
|
fseek(ptr->fd, offset[sectno], SEEK_SET);
|
||||||
ptr->currpos = offset[s];
|
ptr->currpos = offset[sectno];
|
||||||
#ifdef OUTSEEK
|
#ifdef OUTSEEK
|
||||||
currpos = ptr->currpos;
|
currpos = ptr->currpos;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
ptr->cnt = WBUFSIZ - ((int)offset[s] & (WBUFSIZ-1));
|
ptr->cnt = WBUFSIZ - ((int)offset[sectno] & (WBUFSIZ-1));
|
||||||
ptr->pbegin = ptr->pbuf + (WBUFSIZ - ptr->cnt);
|
ptr->pbegin = ptr->pbuf + (WBUFSIZ - ptr->cnt);
|
||||||
ptr->pnow = ptr->pbegin;
|
ptr->pnow = ptr->pbegin;
|
||||||
}
|
}
|
||||||
sectionnr = s;
|
sectionnr = sectno;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -22,7 +22,7 @@ extern void wr_fatal(void);
|
||||||
/*
|
/*
|
||||||
* Just write "cnt" bytes to file-descriptor "fd".
|
* Just write "cnt" bytes to file-descriptor "fd".
|
||||||
*/
|
*/
|
||||||
void wr_bytes(FILE* fd, const char *string, long cnt)
|
void wr_bytes(FILE* fd, const char *buf, long cnt)
|
||||||
{
|
{
|
||||||
|
|
||||||
size_t written_bytes;
|
size_t written_bytes;
|
||||||
|
@ -30,12 +30,12 @@ void wr_bytes(FILE* fd, const char *string, long cnt)
|
||||||
{
|
{
|
||||||
int n = cnt >= maxchunk ? maxchunk : cnt;
|
int n = cnt >= maxchunk ? maxchunk : cnt;
|
||||||
|
|
||||||
written_bytes = fwrite(string, 1, n, fd);
|
written_bytes = fwrite(buf, 1, n, fd);
|
||||||
if (written_bytes != (size_t)n)
|
if (written_bytes != (size_t)n)
|
||||||
{
|
{
|
||||||
wr_fatal();
|
wr_fatal();
|
||||||
}
|
}
|
||||||
string += n;
|
buf += n;
|
||||||
cnt -= n;
|
cnt -= n;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
#include "object.h"
|
#include "object.h"
|
||||||
#include "obj.h"
|
#include "obj.h"
|
||||||
|
|
||||||
void wr_long(FILE* fd, long l)
|
void wr_int4(FILE* fd, long l)
|
||||||
{
|
{
|
||||||
char buf[4];
|
char buf[4];
|
||||||
|
|
|
@ -12,10 +12,10 @@
|
||||||
#include "obj.h"
|
#include "obj.h"
|
||||||
#include "ranlib.h"
|
#include "ranlib.h"
|
||||||
|
|
||||||
void wr_ranlib(FILE* fd, struct ranlib *ran, long cnt1)
|
void wr_ranlib(FILE* fd, struct ranlib *ran, long cnt)
|
||||||
{
|
{
|
||||||
struct ranlib *r;
|
struct ranlib *r;
|
||||||
long cnt, val;
|
long cnt2, val;
|
||||||
char *c;
|
char *c;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -30,11 +30,11 @@ void wr_ranlib(FILE* fd, struct ranlib *ran, long cnt1)
|
||||||
*/
|
*/
|
||||||
r = ran;
|
r = ran;
|
||||||
c = (char *)r;
|
c = (char *)r;
|
||||||
cnt = cnt1;
|
cnt2 = cnt;
|
||||||
while (cnt--) {
|
while (cnt2--) {
|
||||||
val = r->ran_off; put4(val, c); c += 4;
|
val = r->ran_off; put4(val, c); c += 4;
|
||||||
val = r->ran_pos; put4(val, c); c += 4;
|
val = r->ran_pos; put4(val, c); c += 4;
|
||||||
r++;
|
r++;
|
||||||
}
|
}
|
||||||
wr_bytes(fd, (char *) ran, cnt1 * SZ_RAN);
|
wr_bytes(fd, (char *) ran, cnt * SZ_RAN);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue