libflib: New generic library.

* Extracted/generalised some code from libpacman/pacman-g2.