Version 3.0, 2017-03-14
Rewritten in Swift.
(Full Revision History)
macOS 10.12 SDK or later
OS X 10.11 - While the sample itself requires 10.11 or later, the core code should work on older versions of macOS, at least as far back as 10.7. Additionally, that same core code will work unmodified on recent versions of iOS.
The main program is a simple command line tool that accepts parameters, creates query objects, runs them, and prints the results.
The various query classes are each a simple wrapper around CFHost; each has extensive comments explaining how to use the class and how the class works internally.