Edit: Did not notice the ad-hoc part the first time.. For ad-hoc, I don't really know.
For what it's worth and for infrastructure connections:
If you have wpa_supplicant, you should also have wpa_cli.
The command:
wpa_cli signal_poll
should give you screen scrapeable output.
You can (also) interface with wpa_supplicant via C, using wpa_ctrl_open() and wpa_ctrl_request():
Something in the line of:
#include "wpa_ctrl.h"
<needed declarations and definitions>
ctrl = wpa_ctrl_open(path);
wpa_ctrl_request(ctrl, "SIGNAL_POLL", 11, buf, &len, NULL);