C routines for automation control system