sofia_reg_check_expire, start fixing the 2038 issues and strip
calls to switch_mprintf to either asprintf or sqlite3_mprintf.

On the way, format the code so it doesn't make my eyes bleed.

Oh yeah, also check dynamic pointers before dereferencing them.