"Hrvoje Niksic" <[EMAIL PROTECTED]> said:

> OK.  So the whole thing with errno is only necessary when dealing with
> Winsock errors.  For errors from, say, fopen it's fine to use errno?

Yes.
 
> There is another possible approach.  We already #define read and write
> to call Winsock stuff.  We could add some more magic so that they and
> other Winsock invocations automatically set errno to last error value,
> translating Windows errors to errno errors. 

Then all Winsock functions must be wrapped in such macro.
E.g (untested):
#define SOCK_SELECT(fd,rd,wr,ex,tv)  ( \
        int _rc = select (fd,rd,wr,ex,tv), \
        (int)(WSAGetLastError() ? (errno = WSAGetLastError()) : (0)), \
        _rc)

which could get messy; hard to return with a value from such a
macro.

> static struct errentry errtable[] = {
>   {  ERROR_INVALID_FUNCTION,       EINVAL    },  /* 1 */
>   {  ERROR_FILE_NOT_FOUND,         ENOENT    },  /* 2 */

XEmacs is probably using native Win functions (e.g CreateFile
instead of fopen), so it needs to map them to Unix errnos. Wget only 
uses ANSI/Winsock functions, so only WS errors need attention.

Besides, on Windows there is no suiteable <errno.h> value for
e.g. ENOTCONN; we must use the <winsock*.h> value WSAENOTCONN.
So the XEmacs method wouldn't work.

--gv

Reply via email to