1 @section Opening and closing BFDs
5 @subsubsection @code{bfd_openr}
8 bfd *bfd_openr(CONST char *filename, CONST char *target);
10 @strong{Description}@*
11 Open the file @var{filename} (using @code{fopen}) with the target
12 @var{target}. Return a pointer to the created BFD.
14 Calls @code{bfd_find_target}, so @var{target} is interpreted as by
17 If @code{NULL} is returned then an error has occured. Possible errors
18 are @code{bfd_error_no_memory}, @code{bfd_error_invalid_target} or @code{system_call} error.
21 @subsubsection @code{bfd_fdopenr}
24 bfd *bfd_fdopenr(CONST char *filename, CONST char *target, int fd);
26 @strong{Description}@*
27 @code{bfd_fdopenr} is to @code{bfd_fopenr} much like @code{fdopen} is to @code{fopen}.
28 It opens a BFD on a file already described by the @var{fd}
31 When the file is later @code{bfd_close}d, the file descriptor will be closed.
33 If the caller desires that this file descriptor be cached by BFD
34 (opened as needed, closed as needed to free descriptors for
35 other opens), with the supplied @var{fd} used as an initial
36 file descriptor (but subject to closure at any time), call
37 bfd_set_cacheable(bfd, 1) on the returned BFD. The default is to
38 assume no cacheing; the file descriptor will remain open until
39 @code{bfd_close}, and will not be affected by BFD operations on other
42 Possible errors are @code{bfd_error_no_memory}, @code{bfd_error_invalid_target} and @code{bfd_error_system_call}.
44 @findex bfd_openstreamr
45 @subsubsection @code{bfd_openstreamr}
48 bfd *bfd_openstreamr(const char *, const char *, PTR);
50 @strong{Description}@*
51 Open a BFD for read access on an existing stdio stream. When
52 the BFD is passed to @code{bfd_close}, the stream will be closed.
55 @subsubsection @code{bfd_openw}
58 bfd *bfd_openw(CONST char *filename, CONST char *target);
60 @strong{Description}@*
61 Create a BFD, associated with file @var{filename}, using the
62 file format @var{target}, and return a pointer to it.
64 Possible errors are @code{bfd_error_system_call}, @code{bfd_error_no_memory},
65 @code{bfd_error_invalid_target}.
68 @subsubsection @code{bfd_close}
71 boolean bfd_close(bfd *abfd);
73 @strong{Description}@*
74 Close a BFD. If the BFD was open for writing,
75 then pending operations are completed and the file written out
76 and closed. If the created file is executable, then
77 @code{chmod} is called to mark it as such.
79 All memory attached to the BFD is released.
81 The file descriptor associated with the BFD is closed (even
82 if it was passed in to BFD by @code{bfd_fdopenr}).
85 @code{true} is returned if all is ok, otherwise @code{false}.
87 @findex bfd_close_all_done
88 @subsubsection @code{bfd_close_all_done}
91 boolean bfd_close_all_done(bfd *);
93 @strong{Description}@*
94 Close a BFD. Differs from @code{bfd_close}
95 since it does not complete any pending operations. This
96 routine would be used if the application had just used BFD for
97 swapping and didn't want to use any of the writing code.
99 If the created file is executable, then @code{chmod} is called
102 All memory attached to the BFD is released.
105 @code{true} is returned if all is ok, otherwise @code{false}.
108 @subsubsection @code{bfd_create}
111 bfd *bfd_create(CONST char *filename, bfd *templ);
113 @strong{Description}@*
114 Create a new BFD in the manner of
115 @code{bfd_openw}, but without opening a file. The new BFD
116 takes the target from the target used by @var{template}. The
117 format is always set to @code{bfd_object}.
120 @subsubsection @code{bfd_alloc}
123 PTR bfd_alloc (bfd *abfd, size_t wanted);
125 @strong{Description}@*
126 Allocate a block of @var{wanted} bytes of memory attached to
127 @code{abfd} and return a pointer to it.