binmode.c doesn't work as expected. It should be changed to similar pattern as textmode. Also it would be great to create a lib file with it as well (it is already done in cygwin) which will make enabling this options with just -l command. As in binmode.o case i have to specify exact path to file location
Do you have a test case to demonstrte the problem, or a proposed patch to fix?
Sure, background info from http://www.cygwin.com/cygwin-ug-net/using-textbinary.html
On a UNIX system, when an application reads from a file it gets exactly what's in the file on disk and the converse is true for writing. The situation is different in the DOS/Windows world where a file can be opened in one of two modes, binary or text. In the binary mode the system behaves exactly as in UNIX. However on writing in text mode, a NL (\n, ^J) is transformed into the sequence CR (\r, ^M) NL.
In other words on Windows it opens file detault in text mode and when writing bytes it will auto replace \n with \n\r which breaks everything . When porting unix stuff this is sensitive. For this there was binmode.o file introduced and once it is linked it is intended to switch default mode to bin mode. Check link above.
Existing binmode.c is broken as did nothing. I workarounded this by just adding following to my code (same that has to be in binmode):
if (defined _WIN32 || defined WIN32) && ! defined CYGWIN
include <fcntl.h>
int _fmode = _O_BINARY;</fcntl.h>
endif
Beside fixing binmode.o it would also be GREAT to add libbinmode.a (which includes only this file) as it would be then easy to enable this mode by just likning with this lib. As linking with .o file is tricky as it is not on library path