Pull in r3828 from upstream (remove dead code, fix prototypes)
Import Apache apr-1.4.8 to vendor staging area.
Merge branch 'master' into atf
Merge branch 'master' into atf
Merge ^/head/usr.bin/mkimg@265546
Eliminate mkimg_seek() by moving the lseek(2) calls into fdcopy().
While here, minimize use of the global tmpfd by passing it as ofd
to mkimg.
Abstract the use of ftruncate(2) behind mkimg_set_size().
Add image.c and image.h. These files will contain functions to implement
the management of the raw image that's being created. The most notable of
the API is that there's no file descriptor argument. This is because the
image is managed in memory.

Once we have the in-memory (raw) image, we can write it out acording to
different formats. This two-pass approach shields schemes from formats
and formats from schemes.
Switch to the image API:
1.  Replace calls to mkimg_set_size() with calls to image_set_size()
2.  Remove the mkimg_set_size() function
3.  As above but for mkimg_write() and image_write()

Note that this breaks mkimg(1). The image API has no implementation.
Hence doing it on my branch :-)
Replace 2 instances of fdcopy() with image_copyin(). With this, the
mkimg() function does not need the ofd argument and all references
to an output file descriptor in the input phase are gone.
Provide a file-based implementation for the image API. This almost
copies the logic verbatim from mkimg.c to image.c. The difference
is that in image.c the temporary file is always created, whereas
before we only created a temporary file when writing to stdout.

Cleanup mkimg.c now that the song and dance of using a temporary
file is gone.
When write sparse files, make sure to truncate(2) the file. Otherwise
any hole at the end is lost and the file is not of the right size.
Add a linker set for output formats. This is mostly copied and trimmed
from the linker set for schemes. Add stubs for raw and vmdk output
formats so as to demonstrate that the usage message is correct.
Add the -f option for specifying the output format. Update the manpage
accordingly. Print the scheme and the format when running verbose.
Define the sparse extent header and document the steps to take
to create the VMDK file. Add some notes as well.

What I needed to know (roughly) is what interface the image API
is to provide and whether there are (knowledge) gaps that prevent
me from implementing it for real.
Have image_write() call sparse_write() so that we can use SEEK_HOLE
and SEEK_DATA to "quickly" find occupied sectors. This is all short-
lived, because the image should not be kept in a file, but in memory.
To be precise: the image API should be both efficient and scalable
and using a file is not efficient -- it works, which is what I need
right now.
Handle %E arguments appropriately
Add format_write() that calls the write() function of the output
format. Have the raw format use image_copyout() for now.
Add image_get_size() so formats can query about the image size.
Create the VMDK (embedded) descriptor file and round its size
to a multiple of 512.

TODO: We need the name of the output file -- it's in the extent
description. For now, just use "mkimg.vmdk".
Merge remote-tracking branch 'upstream/master'