[links-list] Downloaded files are not in binary mode

Chris Croughton chris at keris.net
Mon Jun 4 03:06:24 PDT 2001


On Sat, Jun 02, 2001 at 02:38:11AM +0200, Mikulas Patocka wrote:
> > I'm running links using Cygwin under WinNT (it compiles and runs just
> > fine, ./configure gets all the right options etc.).  However, Cygwin
> > defaults file operations to text mode which on Win systems gives \r\n as
> > end of line.  This is fine for configuration files, HTML and the like,
> > but when a file is opened for download it also defaults to text mode and
> > gets corrupted (as per the ANSI C standard).
> > 
> > The solution is the following patch, to do the open with O_BINARY and
> > force binary mode.  I've enclosed it in a #ifdef for Cygwin, but it can
> > probably by made standard (I think, but am not certain, that O_BINARY is
> > a valid flag even on Unix systems which are always binary).
> 
> I use set_bin function to set binary mode for file. Please try to fix this
> function instead. There are more places where links is opening files, they
> all are using set_bin and it would be better to fix it there.

OK, I see the problem.  Cygwin gcc sets both UNIX and WIN32 variables
(and wants to use 'real' pipes but alse setmode to binary).  The
following patch does this:

*** os_dep.c~   Sun Dec 31 22:26:52 2000
--- os_dep.c    Mon Jun  4 10:57:15 2001
***************
*** 201,207 ****

  /* Pipe */

! #if defined(UNIX) || defined(BEOS)

  void set_bin(int fd)
  {
--- 201,219 ----

  /* Pipe */

! #ifdef __CYGWIN__
!
! void set_bin(int fd)
! {
!       setmode(fd, O_BINARY);
! }
!
! int c_pipe(int *fd)
! {
!         return pipe(fd);
! }
!
! #elif defined(UNIX) || defined(BEOS)

  void set_bin(int fd)
  {


Note that __CYGWIN__ has to be tested before the others...

Chris C

_______________________________________________
links-list mailing list
links-list at appwatch.com
http://mailman.appwatch.com/listinfo/links-list



More information about the links-list mailing list