add mkostemp, mkstemps, and mkostemps functions and reorganize temp internals