Opening and Closing BFDs
========================

bfd_openr
.........

Synopsis

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

Description

This function opens the file supplied (using fopen) with the target supplied, it returns a pointer to the created BFD. If NULL is returned then an error has occured. Possible errors are no_memory, 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. Possible errors are no_memory, invalid_target and system_call error.

bfd_openw
.........

Synopsis

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

Description

Creates a BFD, associated with file FILENAME, using the file format TARGET, and returns a pointer to it. Possible errors are system_call_error, no_memory, invalid_target.

bfd_close
.........

Synopsis

     boolean bfd_close(bfd *);

Description

This function closes 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's obstacks is released. Returns

true is returned if all is ok, otherwise false.

bfd_close_all_done
..................

Synopsis

     boolean bfd_close_all_done(bfd *);

Description

This function closes a BFD. It 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's obstacks is released. Returns

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

     bfd_size_type bfd_alloc_size(bfd *abfd);

Description

Return the number of bytes in the obstacks connected to the supplied BFD.

bfd_create
..........

Synopsis

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

Description

This routine creates 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_by_size_t
...................

Synopsis

     PTR bfd_alloc_by_size_t(bfd *abfd, size_t wanted);

Description

This function allocates a block of memory in the obstack attatched to abfd and returns a pointer to it.