Octave-Forge - Extra packages for GNU Octave | |
Home · Packages · Developers · Documentation · FAQ · Bugs · Mailing Lists · Links · Code |
00001 /* -*- buffer-read-only: t -*- vi: set ro: */ 00002 /* DO NOT EDIT! GENERATED AUTOMATICALLY! */ 00003 /* w32sock.h --- internal auxilliary functions for Windows socket functions 00004 00005 Copyright (C) 2008-2011 Free Software Foundation, Inc. 00006 00007 This program is free software: you can redistribute it and/or modify 00008 it under the terms of the GNU General Public License as published by 00009 the Free Software Foundation; either version 3 of the License, or 00010 (at your option) any later version. 00011 00012 This program is distributed in the hope that it will be useful, 00013 but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 GNU General Public License for more details. 00016 00017 You should have received a copy of the GNU General Public License 00018 along with this program. If not, see <http://www.gnu.org/licenses/>. */ 00019 00020 /* Written by Paolo Bonzini */ 00021 00022 #include <errno.h> 00023 00024 /* Get O_RDWR and O_BINARY. */ 00025 #include <fcntl.h> 00026 00027 /* Get _get_osfhandle() and _open_osfhandle(). */ 00028 #include <io.h> 00029 00030 #define FD_TO_SOCKET(fd) ((SOCKET) _get_osfhandle ((fd))) 00031 #define SOCKET_TO_FD(fh) (_open_osfhandle ((long) (fh), O_RDWR | O_BINARY)) 00032 00033 static inline void 00034 set_winsock_errno (void) 00035 { 00036 int err = WSAGetLastError (); 00037 00038 /* Map some WSAE* errors to the runtime library's error codes. */ 00039 switch (err) 00040 { 00041 case WSA_INVALID_HANDLE: 00042 errno = EBADF; 00043 break; 00044 case WSA_NOT_ENOUGH_MEMORY: 00045 errno = ENOMEM; 00046 break; 00047 case WSA_INVALID_PARAMETER: 00048 errno = EINVAL; 00049 break; 00050 case WSAEWOULDBLOCK: 00051 errno = EWOULDBLOCK; 00052 break; 00053 case WSAENAMETOOLONG: 00054 errno = ENAMETOOLONG; 00055 break; 00056 case WSAENOTEMPTY: 00057 errno = ENOTEMPTY; 00058 break; 00059 default: 00060 errno = (err > 10000 && err < 10025) ? err - 10000 : err; 00061 break; 00062 } 00063 }