an easy port on Win32, hope it works all right