I suggest that a look at the GRASS4.0 code for v.db.rim and s.db.rim will give hints at using RIM inside C code.