Go to the first, previous, next, last section, table of contents.


Opening and closing BFDs

bfd_openr

Synopsis

bfd *bfd_openr(CONST char *filename, CONST char *target);

Description
Open the file filename (using fopen) with the target target. Return a pointer to the created BFD.

Calls bfd_find_target, so target is interpreted as by that function.

If NULL is returned then an error has occured. Possible errors are bfd_error_no_memory, bfd_error_invalid_target or system_call error.

bfd_fdopenr

Synopsis

bfd *bfd_fdopenr(CONST char *filename, CONST char *target, int fd);

Description
bfd_fdopenr is to bfd_fopenr much like fdopen is to fopen. It opens a BFD on a file already described by the fd supplied.

When the file is later bfd_closed, the file descriptor will be closed.

If the caller desires that this file descriptor be cached by BFD (opened as needed, closed as needed to free descriptors for other opens), with the supplied fd used as an initial file descriptor (but subject to closure at any time), call bfd_set_cacheable(bfd, 1) on the returned BFD. The default is to assume no cacheing; the file descriptor will remain open until bfd_close, and will not be affected by BFD operations on other files.

Possible errors are bfd_error_no_memory, bfd_error_invalid_target and bfd_error_system_call.

bfd_openstreamr

Synopsis

bfd *bfd_openstreamr(const char *, const char *, PTR);

Description
Open a BFD for read access on an existing stdio stream. When the BFD is passed to bfd_close, the stream will be closed.

bfd_openw

Synopsis

bfd *bfd_openw(CONST char *filename, CONST char *target);

Description
Create a BFD, associated with file filename, using the file format target, and return a pointer to it.

Possible errors are bfd_error_system_call, bfd_error_no_memory, bfd_error_invalid_target.

bfd_close

Synopsis

boolean bfd_close(bfd *abfd);

Description
Close a BFD. If the BFD was open for writing, then pending operations are completed and the file written out and closed. If the created file is executable, then chmod is called to mark it as such.

All memory attached to the BFD is released.

The file descriptor associated with the BFD is closed (even if it was passed in to BFD by bfd_fdopenr).

Returns
true is returned if all is ok, otherwise false.

bfd_close_all_done

Synopsis

boolean bfd_close_all_done(bfd *);

Description
Close a BFD. Differs from bfd_close since it does not complete any pending operations. This routine would be used if the application had just used BFD for swapping and didn't want to use any of the writing code.

If the created file is executable, then chmod is called to mark it as such.

All memory attached to the BFD is released.

Returns
true is returned if all is ok, otherwise false.

bfd_create

Synopsis

bfd *bfd_create(CONST char *filename, bfd *templ);

Description
Create a new BFD in the manner of bfd_openw, but without opening a file. The new BFD takes the target from the target used by template. The format is always set to bfd_object.

bfd_alloc

Synopsis

PTR bfd_alloc (bfd *abfd, size_t wanted);

Description
Allocate a block of wanted bytes of memory attached to abfd and return a pointer to it.


Go to the first, previous, next, last section, table of contents.