1*3d8817e4Smiod@section File caching 2*3d8817e4SmiodThe file caching mechanism is embedded within BFD and allows 3*3d8817e4Smiodthe application to open as many BFDs as it wants without 4*3d8817e4Smiodregard to the underlying operating system's file descriptor 5*3d8817e4Smiodlimit (often as low as 20 open files). The module in 6*3d8817e4Smiod@code{cache.c} maintains a least recently used list of 7*3d8817e4Smiod@code{BFD_CACHE_MAX_OPEN} files, and exports the name 8*3d8817e4Smiod@code{bfd_cache_lookup}, which runs around and makes sure that 9*3d8817e4Smiodthe required BFD is open. If not, then it chooses a file to 10*3d8817e4Smiodclose, closes it and opens the one wanted, returning its file 11*3d8817e4Smiodhandle. 12*3d8817e4Smiod 13*3d8817e4Smiod@subsection Caching functions 14*3d8817e4Smiod 15*3d8817e4Smiod 16*3d8817e4Smiod@findex bfd_cache_init 17*3d8817e4Smiod@subsubsection @code{bfd_cache_init} 18*3d8817e4Smiod@strong{Synopsis} 19*3d8817e4Smiod@example 20*3d8817e4Smiodbfd_boolean bfd_cache_init (bfd *abfd); 21*3d8817e4Smiod@end example 22*3d8817e4Smiod@strong{Description}@* 23*3d8817e4SmiodAdd a newly opened BFD to the cache. 24*3d8817e4Smiod 25*3d8817e4Smiod@findex bfd_cache_close 26*3d8817e4Smiod@subsubsection @code{bfd_cache_close} 27*3d8817e4Smiod@strong{Synopsis} 28*3d8817e4Smiod@example 29*3d8817e4Smiodbfd_boolean bfd_cache_close (bfd *abfd); 30*3d8817e4Smiod@end example 31*3d8817e4Smiod@strong{Description}@* 32*3d8817e4SmiodRemove the BFD @var{abfd} from the cache. If the attached file is open, 33*3d8817e4Smiodthen close it too. 34*3d8817e4Smiod 35*3d8817e4Smiod@strong{Returns}@* 36*3d8817e4Smiod@code{FALSE} is returned if closing the file fails, @code{TRUE} is 37*3d8817e4Smiodreturned if all is well. 38*3d8817e4Smiod 39*3d8817e4Smiod@findex bfd_cache_close_all 40*3d8817e4Smiod@subsubsection @code{bfd_cache_close_all} 41*3d8817e4Smiod@strong{Synopsis} 42*3d8817e4Smiod@example 43*3d8817e4Smiodbfd_boolean bfd_cache_close_all (void); 44*3d8817e4Smiod@end example 45*3d8817e4Smiod@strong{Description}@* 46*3d8817e4SmiodRemove all BFDs from the cache. If the attached file is open, 47*3d8817e4Smiodthen close it too. 48*3d8817e4Smiod 49*3d8817e4Smiod@strong{Returns}@* 50*3d8817e4Smiod@code{FALSE} is returned if closing one of the file fails, @code{TRUE} is 51*3d8817e4Smiodreturned if all is well. 52*3d8817e4Smiod 53*3d8817e4Smiod@findex bfd_open_file 54*3d8817e4Smiod@subsubsection @code{bfd_open_file} 55*3d8817e4Smiod@strong{Synopsis} 56*3d8817e4Smiod@example 57*3d8817e4SmiodFILE* bfd_open_file (bfd *abfd); 58*3d8817e4Smiod@end example 59*3d8817e4Smiod@strong{Description}@* 60*3d8817e4SmiodCall the OS to open a file for @var{abfd}. Return the @code{FILE *} 61*3d8817e4Smiod(possibly @code{NULL}) that results from this operation. Set up the 62*3d8817e4SmiodBFD so that future accesses know the file is open. If the @code{FILE *} 63*3d8817e4Smiodreturned is @code{NULL}, then it won't have been put in the 64*3d8817e4Smiodcache, so it won't have to be removed from it. 65*3d8817e4Smiod 66