added search function in C, untested.