Enable sqlite3_unlock_notify()
Speed up vulnerability audit process

Sort VuXML entries using lexicographical ordering of largest
non-globbing prefixes and use few tricks to benefit from the
sorted array:

 * select the first entry for the given installed package using
   precomputed table for the first byte of the package name;

 * skip entries with identical non-globbing prefix if it does
   not match the package name;

 * once we found VuXML entry with the non-globbing prefix that
   is strictly larger than the prefix of the same size taken
   from the package name, there is no point to search any further.

This gives me up to 5x decrease in total processing time for
'pkg audit'.

Signed-off-by: Eygene Ryabinkin <rea@FreeBSD.org>
Fix compilation with gcc
Use mmap for packing files.

Instead of cycle of read/write mmap the whole file to allow
libarchive to make internal optimizations based on the whole file.
Use old read/write logic for large files.

If a file is too large to fit in process address space, do not try
to mmap it and use read/write approach instead.

Suggested by:	jilles
Add flags to pkg_open to allow some optimizations.

Add generic flag param to pkg_open and pkg_open2 that makes it
possible to perform partial load of packages, for instance skip
some parts of parsing, such as mtree or files parsing.
Fix compilation warning.

Use ssize_t for comparing with off_t as they both do have a sign.
Fix possible segfault.

Set variable that is freed to NULL initially.
Ensure incorrect option values are handled appropriately