Start moving to secure *_s functions

Use compat.h fix from https://github.com/oboroc/bdecli/ project to make
compilation work with Visual C++ 6.0 - 2003 and Open Watcom C32 1.9