GETARHDR(3C) COMMAND REFERENCE GETARHDR(3C)
NAME
getarhdr, fgetarhdr - read archive header
SYNOPSIS
#include <ar.h>
int getarhdr(fd, header)
int fd;
struct arhdr *header;
#include <stdio.h>
#include <ar.h>
int fgetarhdr(fp, header);
FILE *fp;
struct arhdr *header;
DESCRIPTION
The subroutine getarhdr reads the archive header from the
file whose descriptor is fd and places this information in
the structure pointed to by header. The value returned is
the length of the name field in the archive file, including
slashes and padding, except when there is a problem or end-
of-file is reached (see RETURN VALUE). The subroutine
fgetarhdr is similar, except that it takes a FILE pointer
instead of a file descriptor.
The name field is terminated by a null. This means that by
using fgetarhdr or getarhdr, filenames with imbedded spaces
can be handled correctly.
The subroutine is needed because the archive format supports
long filenames by surrounding them by slashes instead of
making the name field longer. This means that it is no
longer possible to read the entire header into a structure
with a single read. See ar(1) and ar(5) for more
information on the archive format.
EXAMPLES
A typical program that reads archive files would read and
check the magic number and use getarhdr to get the header
for each member of the archive file.
DIAGNOSTICS
Getarhdr and fgetarhdr return 0 on end-of-file and -1 when
the archive file is malformed.
CAVEATS
Files opened via fopen(3s) should use fgetarhdr, especially
if seeks are performed.
The file is expected to be an archive file, but it can be
either a long or short format file (see ar(5) ).
Printed 10/17/86 1
GETARHDR(3C) COMMAND REFERENCE GETARHDR(3C)
SEE ALSO
ar(1), open(2), fopen(3s), ar(5), oldar(5).
Printed 10/17/86 2
%%index%%
na:72,77;
sy:149,1141;
de:1290,1300;
ex:2590,274;
di:2864,281;
ca:3145,337;
se:3626,198;
%%index%%000000000122