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

Mikulas Patocka mikulas at artax.karlin.mff.cuni.cz
Fri Jun 1 17:38:11 PDT 2001


> 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).
> 
> *** session.c.old       Sun Dec 31 22:26:52 2000
> --- session.c   Tue May 15 17:10:43 2001
> ***************
> *** 595,601 ****
> --- 595,605 ----
>                         }
>                 }
>         }
> + #ifdef __CYGWIN__
> +       h = open(file, O_BINARY|O_CREAT|O_WRONLY|O_TRUNC|(sf?O_EXCL:0), sf ? 0600 : 0666);
> + #else
>         h = open(file, O_CREAT|O_WRONLY|O_TRUNC|(sf?O_EXCL:0), sf ? 0600 : 0666);
> + #endif
>         if (wd) set_cwd(wd), mem_free(wd);
>         if (h == -1) {
>                 unsigned char *msg = stracpy(file);

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.

Mikulas


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



More information about the links-list mailing list