if you have synclient installed then enabling is synclient TouchpadOff=0 and disabling is synclient TouchpadOff=1
you can read the state via synclient -l I have a few lines of sh bound to mod-n to toggle. I really don't think this needs to be written in c considering it is just a few lines of sh, I guess if you really don't want synclient installed then maybe yours is advantageous. ~cjh