OBJECT(3) Amsterdam Compiler Kit OBJECT(3) 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 SYNOPSIS #include #include #include #include int wr_open(filename) char *filename; void wr_close() void wr_ohead(head) struct outhead *head; void wr_sect(sect, cnt) struct outsect *sect; unsigned int cnt; void wr_outsect(sectionnr) int sectionnr; void wr_emit(emit, cnt) char *emit; long cnt; void wr_putc(ch) void wr_relo(relo, cnt) struct outrelo *relo; unsigned int cnt; void wr_name(name, cnt) struct outname *name; unsigned int cnt; void wr_string(stringaddr, cnt) char *stringaddr; long cnt; void wr_arhdr(fd, arhdr) struct ar_hdr *arhdr; 5th ACK distribution $Revision: 1.11 $ 1 OBJECT(3) Amsterdam Compiler Kit OBJECT(3) void wr_ranlib(fd, ran, cnt) struct ranlib *ran; long cnt; void wr_int2(fd, i) void wr_long(fd, l) long l; void wr_bytes(fd, buf, l) char *buf; long l; int rd_open(filename) char *filename; int rd_fdopen(fd) void rd_close() void rd_ohead(head) struct outhead *head; void rd_sect(sect, cnt) struct outsect *sect; unsigned int cnt; void rd_outsect(sectionnr) int sectionnr; void rd_emit(emit, cnt) char *emit; long cnt; void rd_relo(relo, cnt) struct outrelo *relo; unsigned int cnt; void rd_rew_relo(head) struct outhead *head; void rd_name(name, cnt) struct outname *name; unsigned int cnt; void rd_string(stringaddr, cnt) char *stringaddr; long cnt; int rd_arhdr(fd, arhdr) struct ar_hdr *arhdr; 5th ACK distribution $Revision: 1.11 $ 2 OBJECT(3) Amsterdam Compiler Kit OBJECT(3) void rd_ranlib(fd, ran, cnt) struct ranlib *ran; long cnt; int rd_int2(fd) unsigned int rd_unsigned2(fd) long rd_long(fd) void rd_bytes(fd, buf, l) char *buf; long l; int rd_fd() DESCRIPTION These routines come in handy when reading or writing ACK- object files or libraries. No checking is performed. _W_r__o_p_e_n opens the file _f_i_l_e_n_a_m_e 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. _W_r__c_l_o_s_e closes the object file. Don't forget to call it, because it might flush internal buffers. _W_r__o_h_e_a_d writes the _h_e_a_d header structure. This routine must be called before the routines to write the other parts. _W_r__s_e_c_t writes _c_n_t section headers, starting at _s_e_c_t. Before writing a section, its section header must be writ- ten. _W_r__o_u_t_s_e_c_t indicates that the next section to be written is _s_e_c_t_i_o_n_n_r. This routine can be used to switch between sec- tions. _W_r__e_m_i_t writes _c_n_t bytes, starting at _e_m_i_t, of the current section. _W_r__p_u_t_c adds character _c_h to the current section. _W_r__r_e_l_o writes _c_n_t outrelo structures, indicated by _r_e_l_o, in the relocation information part of the object file. _W_r__n_a_m_e writes _c_n_t outname structures, indicated by _n_a_m_e, in the name-table part of the object file. _W_r__s_t_r_i_n_g writes _c_n_t bytes, indicated by _s_t_r_i_n_g_a_d_d_r, in the string table part of the object file. 5th ACK distribution $Revision: 1.11 $ 3 OBJECT(3) Amsterdam Compiler Kit OBJECT(3) The next few routines can be used independantly: _W_r__a_r_h_d_r writes the archive member header _a_r_h_d_r to file descriptor _f_d. _W_r__r_a_n_l_i_b writes _c_n_t ranlib structures, indicated by _r_a_n, to file descriptor _f_d. _W_r__i_n_t_2 writes a 2-byte integer _i to file descriptor _f_d, low order byte first. _W_r__l_o_n_g writes a 4-byte integer _l to file descriptor _f_d, low order word first, low order byte first. _W_r__b_y_t_e_s writes _l bytes from _b_u_f to file descriptor _f_d. Most of the _r_d_ routines are the opposite of the _w_r_ rou- tines. However, a few of them deserve special mentioning: _R_d__f_d_o_p_e_n initialises for reading an "object file" from file descriptor _f_d, 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, _r_d__c_l_o_s_e does not have to be called. _R_d__r_e_w__r_e_l_o rewinds the relocation part, so that it can be read again. _L_e_d(6) sometimes needs this. _R_d__u_n_s_i_g_n_e_d_2 reads two bytes from file descriptor _f_d and interpretes them as an unsigned integer. _R_d__a_r_h_d_r returns 1 if a header was read, and 0 on end-of- file. When using any of the reading routines, a routine named _r_d__f_a_t_a_l must be defined. It is called when a read fails, and is not supposed to return. Likewise, a routine _w_r__f_a_t_a_l must be defined when using any of the writing routines. FILES ~em/h/out.h ~em/h/arch.h ~em/h/ranlib.h ~em/modules/lib/libobject.a: the library in which these rou- tines reside SEE ALSO ack.out(5), arch(1), aal(1) DIAGNOSTICS The routines _w_r__o_p_e_n, _r_d__o_p_e_n, and _r_d__f_d_o_p_e_n return 0 if they fail, and 1 if they succeed. 5th ACK distribution $Revision: 1.11 $ 4