Copyright (C) 2000-2012 |
GNU Info (bfd.info)Opening and ClosingOpening 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_close'd, 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_make_writable' ................... *Synopsis* boolean bfd_make_writable(bfd *abfd); *Description* Takes a BFD as created by `bfd_create' and converts it into one like as returned by `bfd_openw'. It does this by converting the BFD to BFD_IN_MEMORY. It's assumed that you will call `bfd_make_readable' on this bfd later. *Returns* `true' is returned if all is ok, otherwise `false'. `bfd_make_readable' ................... *Synopsis* boolean bfd_make_readable(bfd *abfd); *Description* Takes a BFD as created by `bfd_create' and `bfd_make_writable' and converts it into one like as returned by `bfd_openr'. It does this by writing the contents out to the memory buffer, then reversing the direction. *Returns* `true' is returned if all is ok, otherwise `false'. `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. automatically generated by info2www version 1.2.2.9 |