.TH OBJECT 3 "$Revision$" .ad .SH NAME 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, 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_int2, rd_unsigned2, rd_long, rd_bytes, rd_fd\ \-\ routines to read and write ACK-object files and libraries .SH SYNOPSIS .B #include .br .B #include .br .B #include .br .B #include .PP .B int wr_open(filename) .br .B char *filename; .PP .B void wr_close() .PP .B void wr_ohead(head) .br .B struct outhead *head; .PP .B void wr_sect(sect, cnt) .br .B struct outsect *sect; .br .B unsigned int cnt; .PP .B void wr_outsect(sectionnr) .br .B int sectionnr; .PP .B void wr_emit(emit, cnt) .br .B char *emit; .br .B long cnt; .PP .B void wr_putc(ch) .PP .B void wr_relo(relo, cnt) .br .B struct outrelo *relo; .br .B unsigned int cnt; .PP .B void wr_name(name, cnt) .br .B struct outname *name; .br .B unsigned int cnt; .PP .B void wr_string(stringaddr, cnt) .br .B char *stringaddr; .br .B long cnt; .PP .B void wr_arhdr(fd, arhdr) .br .B struct ar_hdr *arhdr; .PP .B void wr_ranlib(fd, ran, cnt) .br .B struct ranlib *ran; .br .B long cnt; .PP .B void wr_int2(fd, i) .PP .B void wr_long(fd, l) .br .B long l; .PP .B void wr_bytes(fd, buf, l) .br .B char *buf; .br .B long l; .PP .B int rd_open(filename) .br .B char *filename; .PP .B int rd_fdopen(fd) .PP .B void rd_close() .PP .B void rd_ohead(head) .br .B struct outhead *head; .PP .B void rd_sect(sect, cnt) .br .B struct outsect *sect; .br .B unsigned int cnt; .PP .B void rd_outsect(sectionnr) .br .B int sectionnr; .PP .B void rd_emit(emit, cnt) .br .B char *emit; .br .B long cnt; .PP .B void rd_relo(relo, cnt) .br .B struct outrelo *relo; .br .B unsigned int cnt; .PP .B void rd_rew_relo(head) .br .B struct outhead *head; .PP .B void rd_name(name, cnt) .br .B struct outname *name; .br .B unsigned int cnt; .PP .B void rd_string(stringaddr, cnt) .br .B char *stringaddr; .br .B long cnt; .PP .B int rd_arhdr(fd, arhdr) .br .B struct ar_hdr *arhdr; .PP .B void rd_ranlib(fd, ran, cnt) .br .B struct ranlib *ran; .br .B long cnt; .PP .B int rd_int2(fd) .PP .B unsigned int rd_unsigned2(fd) .PP .B long rd_long(fd) .PP .B void rd_bytes(fd, buf, l) .br .B char *buf; .br .B long l; .PP .B int rd_fd() .SH DESCRIPTION These routines come in handy when reading or writing ACK-object files or libraries. No checking is performed. .PP .I Wr_open opens the file .I filename for writing and initializes some of this modules local variables. It must be called before writing parts of the object file. It returns 1 if it succeeds, 0 if it fails. .PP .I Wr_close closes the object file. Don't forget to call it, because it might flush internal buffers. .PP .I Wr_ohead writes the .I head header structure. This routine must be called before the routines to write the other parts. .PP .I Wr_sect writes .I cnt section headers, starting at .IB sect . Before writing a section, its section header must be written. .PP .I Wr_outsect indicates that the next section to be written is .IB sectionnr . This routine can be used to switch between sections. .PP .I Wr_emit writes .I cnt bytes, starting at .IB emit , of the current section. .PP .I Wr_putc adds character .I ch to the current section. .PP .I Wr_relo writes .I cnt outrelo structures, indicated by .IB relo , in the relocation information part of the object file. .PP .I Wr_name writes .I cnt outname structures, indicated by .IB name , in the name-table part of the object file. .PP .I Wr_string writes .I cnt bytes, indicated by .IB stringaddr , in the string table part of the object file. .PP The next few routines can be used independantly: .I Wr_arhdr writes the archive member header .I arhdr to file descriptor .IB fd . .PP .I Wr_ranlib writes .I cnt ranlib structures, indicated by .IB ran , to file descriptor .IB fd. .PP .I Wr_int2 writes a 2-byte integer .I i to file descriptor .IB fd , low order byte first. .PP .I Wr_long writes a 4-byte integer .I l to file descriptor .IB fd , low order word first, low order byte first. .PP .I Wr_bytes writes .I l bytes from .I buf to file descriptor .IB fd . .PP Most of the .I rd_ routines are the opposite of the .I wr_ routines. However, a few of them deserve special mentioning: .PP .I Rd_fdopen initialises for reading an "object file" from file descriptor .IB fd , at its current position. This is useful for reading an object that resides in an archive. It returns 1 if it succeeds, 0 otherwise. When using this entry point for reading, .I rd_close does not have to be called. .PP .I Rd_rew_relo rewinds the relocation part, so that it can be read again. \fILed\fR(6) sometimes needs this. .PP .I Rd_unsigned2 reads two bytes from file descriptor .I fd and interpretes them as an unsigned integer. .PP .I Rd_arhdr returns 1 if a header was read, and 0 on end-of-file. .PP When using any of the reading routines, a routine named .I rd_fatal must be defined. It is called when a read fails, and is not supposed to return. Likewise, a routine .I wr_fatal must be defined when using any of the writing routines. .SH FILES ~em/h/out.h .br ~em/h/arch.h .br ~em/h/ranlib.h .br ~em/modules/lib/libobject.a: the library in which these routines reside .SH "SEE ALSO" ack.out(5), arch(1), aal(1) .SH DIAGNOSTICS The routines .IB wr_open , .IB rd_open , and .I rd_fdopen return 0 if they fail, and 1 if they succeed.