Changeset 886
- Timestamp:
- Dec 8, 2003, 6:45:15 AM (22 years ago)
- Location:
- trunk/src/emx/src
- Files:
-
- 98 added
- 23 deleted
- 34 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/emx/src/lib/socket/accept.c
-
Property cvs2svn:cvs-rev
changed from
1.1
to1.2
r885 r886 1 /* accept.c (emx+gcc) -- Copyright (c) 1994-1996 by Eberhard Mattes */ 1 /* $Id: $ */ 2 /** @file 3 * 4 * accept(). 5 * 6 * Copyright (c) 2003 knut st. osmundsen <bird-srcspam@anduin.net> 7 * 8 * 9 * This file is part of Innotek LIBC. 10 * 11 * Innotek LIBC is free software; you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License as published 13 * by the Free Software Foundation; either version 2 of the License, or 14 * (at your option) any later version. 15 * 16 * Innotek LIBC is distributed in the hope that it will be useful, 17 * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 * GNU Lesser General Public License for more details. 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * along with Innotek LIBC; if not, write to the Free Software 23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 24 * 25 */ 2 26 27 /******************************************************************************* 28 * Header Files * 29 *******************************************************************************/ 30 #include "libc-alias.h" 31 #include <errno.h> 32 #include <sys/socket.h> 3 33 #include <sys/fcntl.h> 4 #include <errno.h>5 34 #include <emx/io.h> 6 #include <emx/syscalls.h>35 #include "socket.h" 7 36 8 int accept (int handle, struct sockaddr *addr, int *paddrlen)37 int accept(int socket, struct sockaddr *addr, int *addrlen) 9 38 { 10 int s, *pflags; 39 PLIBCSOCKETFH pFHSocket = __libsocket_FH(socket); 40 int s; 41 if (pFHSocket) 42 { 43 s = __libsocket_accept(pFHSocket->iSocket, addr, addrlen); 44 if (s >= 0) 45 { 46 int rc; 47 int fh; 48 PLIBCSOCKETFH pFH; 49 rc = __libc_FHAllocate(-1, O_RDWR | F_SOCKET, sizeof(LIBCSOCKETFH), &__libsocket_gSocketOps, (PLIBCFH*)&pFH, &fh); 50 if (!rc) 51 { 52 pFH->iSocket = s; 53 return fh; 54 } 55 else 56 __libsocket_soclose(s); 57 __libsocket_setSocketErrno(); 58 } 59 else 60 __libsocket_setLibcErrno(); 61 } 11 62 12 s = __accept (handle, addr, paddrlen);13 if (s < 0)14 63 return -1; 15 if ((pflags = _fd_init (s)) == NULL)16 {17 __close (s);18 errno = EMFILE;19 return -1;20 }21 *pflags = O_RDWR | F_SOCKET;22 return s;23 64 } 65 -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/socket/bind.c
-
Property cvs2svn:cvs-rev
changed from
1.1
to1.2
r885 r886 1 /* bind.c (emx+gcc) -- Copyright (c) 1994-1996 by Eberhard Mattes */ 1 /* $Id: $ */ 2 /** @file 3 * 4 * bind(). 5 * 6 * Copyright (c) 2003 knut st. osmundsen <bird-srcspam@anduin.net> 7 * 8 * 9 * This file is part of Innotek LIBC. 10 * 11 * Innotek LIBC is free software; you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License as published 13 * by the Free Software Foundation; either version 2 of the License, or 14 * (at your option) any later version. 15 * 16 * Innotek LIBC is distributed in the hope that it will be useful, 17 * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 * GNU Lesser General Public License for more details. 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * along with Innotek LIBC; if not, write to the Free Software 23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 24 * 25 */ 2 26 3 #include <emx/syscalls.h> 27 /******************************************************************************* 28 * Header Files * 29 *******************************************************************************/ 30 #include "libc-alias.h" 31 #include <errno.h> 32 #include <sys/socket.h> 33 #include <sys/fcntl.h> 34 #include <emx/io.h> 35 #include "socket.h" 4 36 5 int bind (int handle,struct sockaddr *addr, int addrlen)37 int bind(int socket, const struct sockaddr *addr, int addrlen) 6 38 { 7 return __bind (handle, addr, addrlen); 39 PLIBCSOCKETFH pFHSocket = __libsocket_FH(socket); 40 if (pFHSocket) 41 { 42 int rc; 43 rc = __libsocket_bind(pFHSocket->iSocket, addr, addrlen); 44 if (rc >= 0) 45 return rc; 46 __libsocket_setLibcErrno(); 47 } 48 49 return -1; 8 50 } 51 -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/socket/bsdselect.c
-
Property cvs2svn:cvs-rev
changed from
1.1
to1.2
r885 r886 1 /* $Id$ 2 * 3 * Wrapper for bsdselect() in BSD 4.4 mode. 4 * 5 * Copyright (c) 2003 InnoTek Systemberatung GmbH 6 * Author: knut st. osmundsen <bird@anduin.net> 7 * 8 * All Rights Reserved 9 * 10 */ 11 #include <stdlib.h> 12 #include <alloca.h> 13 #include <sys/types.h> 14 #include <sys/select.h> 15 16 17 #define V5_FD_SETSIZE 64 18 19 #pragma pack(4) 20 typedef struct v5_fd_set { 21 u_short fd_count; /* how many are SET? */ 22 int fd_array[V5_FD_SETSIZE];/* an array of SOCKETs */ 23 } v5_fd_set; 24 #pragma pack() 25 26 #define V5_FD_SET(fd, set) do { \ 27 if (((v5_fd_set *)(set))->fd_count < V5_FD_SETSIZE) \ 28 ((v5_fd_set *)(set))->fd_array[((v5_fd_set *)(set))->fd_count++]=fd;\ 29 } while(0) 30 31 int _System v5_bsdselect(int, struct v5_fd_set *, struct v5_fd_set *, struct v5_fd_set *, struct timeval *); 32 33 34 static inline void convert(int c, const struct fd_set *pFrom, struct v5_fd_set *pTo) 35 { 36 int i = 0; 37 38 memset(pTo, 0, sizeof(struct v5_fd_set)); 1 /* $Id$ */ 2 /** @file 3 * 4 * bsdselect(). 5 * 6 * Copyright (c) 2003 knut st. osmundsen <bird-srcspam@anduin.net> 7 * 8 * 9 * This file is part of Innotek LIBC. 10 * 11 * Innotek LIBC is free software; you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License as published 13 * by the Free Software Foundation; either version 2 of the License, or 14 * (at your option) any later version. 15 * 16 * Innotek LIBC is distributed in the hope that it will be useful, 17 * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 * GNU Lesser General Public License for more details. 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * along with Innotek LIBC; if not, write to the Free Software 23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 24 * 25 */ 26 27 /******************************************************************************* 28 * Header Files * 29 *******************************************************************************/ 30 #include "libc-alias.h" 31 #include <errno.h> 32 #include <sys/socket.h> 33 #include <sys/fcntl.h> 34 #include <emx/io.h> 35 #include "socket.h" 36 37 38 /******************************************************************************* 39 * Defined Constants And Macros * 40 *******************************************************************************/ 41 #ifdef TCPV40HDRS 42 43 #define MY_FD_SET(fd, set) FD_SET(fd, set) 44 #define MY_FD_ISSET(fd, set) FD_ISSET(fd, set) 45 #define MY_FD_ZERO(set, cb) memset(set, 0, cb); 46 #define my_fd_set fd_set 47 48 #else 49 50 #define MY_FD_SET(fd, set) V5_FD_SET(fd, set) 51 #define MY_FD_ISSET(fd, set) V5_FD_ISSET(fd, set) 52 #define MY_FD_ZERO(set, cb) memset(set, 0, cb); 53 #define my_fd_set v5_fd_set 54 55 #endif 56 57 58 /** 59 * Calculate the size required for the converted set structure. 60 * @returns number of bytes. 61 * @param c Number of file descriptors specified in the call. 62 * @param pFrom The select input fd_set structure. 63 */ 64 static inline int calcsize(int c, const struct fd_set *pFrom) 65 { 66 int cbRet; 67 #ifdef TCPV40HDRS 68 cbRet = (c + 7) / 8; 69 #else 70 int i; 71 for (cbRet = sizeof(u_short), i = 0; i < c; i++) 72 if (FD_ISSET(i, pFrom)) 73 cbRet++; 74 #endif 75 if (cbRet < sizeof(struct my_fd_set)) 76 return sizeof(struct my_fd_set); 77 return cbRet; 78 } 79 80 /** Converts the LIBC fd_set strcture pointed to by pFrom with it's LIBC socket handles, 81 * to the fd_set strcuture used by the OS/2 tcpip and the OS/2 socket handles. 82 * @returns 0 on success. 83 * @returns -1 on failure, both errnos set. 84 * @param c Number of file descriptors specified in the call. 85 * @param cb Size of pTo. (used for zeroing it) 86 * @param pFrom The select input fd_set structure. 87 * @param pTo The structure we present to OS/2 TCPIP. 88 * This will be initialized. 89 */ 90 static inline int convert(int c, int cb, const struct fd_set *pFrom, struct my_fd_set *pTo) 91 { 92 int i; 93 MY_FD_ZERO(pTo, cb) 39 94 for (i = 0; i < c; i++) 40 95 { 41 96 if (FD_ISSET(i, pFrom)) 42 V5_FD_SET(i, pTo); 43 } 44 /** @todo: check for overflow and return appropriate error code... */ 45 } 46 97 { 98 PLIBCSOCKETFH pFHSocket = __libsocket_FH(i); 99 if (!pFHSocket) 100 return -1; 101 MY_FD_SET(pFHSocket->iSocket, pTo); 102 } 103 } 104 return 0; 105 } 47 106 48 107 /** 49 * This wrapper is required to work around a new ushort field someone 50 * at IBM added to speed up the macros accessing the select structure. 51 * @remark Only BSD 4.4 mode. 52 */ 53 int _System bsdselect(int nfds, struct fd_set *readfds, struct fd_set *writefds, 54 struct fd_set *excptfds, struct timeval *timeout) 55 { 56 int rc; 57 struct v5_fd_set *pv5_readfds = NULL; 58 struct v5_fd_set *pv5_writefds = NULL; 59 struct v5_fd_set *pv5_excptfds = NULL; 60 int cfds = nfds <= 0 ? FD_SETSIZE : nfds; 61 108 * Updates the pTo structure with the fds marked ready in pFrom. 109 * 110 * @param c Number of file descriptors specified in the call. 111 * @param pFrom The structure returned from OS/2 TCPIP select. 112 * @param pTo The structure passed in to select which have to 113 * be updated for the return. 114 */ 115 static inline void update(int c, const struct my_fd_set *pFrom, struct fd_set *pTo) 116 { 117 int i; 118 for (i = 0; i < c; i++) 119 { 120 if (FD_ISSET(i, pTo)) 121 { 122 PLIBCSOCKETFH pFHSocket = __libsocket_FH(i); 123 if (pFHSocket) 124 { 125 if (!MY_FD_ISSET(pFHSocket->iSocket, pFrom)) 126 FD_CLR(i, pTo); 127 } 128 } 129 } 130 } 131 132 133 134 int bsdselect(int nfds, struct fd_set *readfds, struct fd_set *writefds, struct fd_set *exceptfds, struct timeval *tv) 135 { 136 #ifdef TCPV40HDRS 137 struct fd_set *pRead; 138 struct fd_set *pWrite; 139 struct fd_set *pExcept; 140 #else 141 struct v5_fd_set *pRead; 142 struct v5_fd_set *pWrite; 143 struct v5_fd_set *pExcept; 144 #endif 145 int cb; 146 int rc; 147 148 /* 149 * Allocate new bitmaps. 150 */ 151 pRead = NULL; 62 152 if (readfds) 63 153 { 64 pv5_readfds = alloca(sizeof(struct v5_fd_set)); 65 convert(cfds, readfds, pv5_readfds); 66 } 67 154 cb = calcsize(nfds, readfds); 155 pRead = alloca(cb); 156 if (!pRead) 157 { 158 __libsocket_setErrno(ENOMEM); 159 return -1; 160 } 161 if (convert(nfds, cb, readfds, pRead)) 162 return -1; 163 } 164 165 pWrite = NULL; 68 166 if (writefds) 69 167 { 70 pv5_writefds = alloca(sizeof(struct v5_fd_set)); 71 convert(cfds, writefds, pv5_writefds); 72 } 73 74 if (excptfds) 75 { 76 pv5_excptfds = alloca(sizeof(struct v5_fd_set)); 77 convert(cfds, excptfds, pv5_excptfds); 78 } 79 80 rc = v5_bsdselect(nfds, pv5_readfds, pv5_writefds, pv5_excptfds, timeout); 168 cb = calcsize(nfds, writefds); 169 pWrite = alloca(cb); 170 if (!pWrite) 171 { 172 __libsocket_setErrno(ENOMEM); 173 return -1; 174 } 175 if (convert(nfds, cb, writefds, pWrite)) 176 return -1; 177 } 178 179 pExcept = NULL; 180 if (exceptfds) 181 { 182 cb = calcsize(nfds, exceptfds); 183 pExcept = alloca(cb); 184 if (!pExcept) 185 { 186 __libsocket_setErrno(ENOMEM); 187 return -1; 188 } 189 if (convert(nfds, cb, exceptfds, pExcept)) 190 return -1; 191 } 192 193 /* 194 * Do the call. 195 */ 196 rc = __libsocket_bsdselect(nfds, pRead, pWrite, pExcept, tv); 197 if (rc < 0) 198 { 199 __libsocket_setLibcErrno(); 200 return rc; 201 } 202 203 /* 204 * Timeout? 205 * Just clear the bitmaps and return. 206 */ 207 if (rc == 0) 208 { 209 cb = (nfds + 7) / 8; 210 if (readfds) 211 memset(readfds, 0, cb); 212 if (writefds) 213 memset(writefds, 0, cb); 214 if (exceptfds) 215 memset(exceptfds, 0, cb); 216 return 0; 217 } 218 219 /* 220 * Convert the bitmaps. 221 */ 222 if (readfds) 223 update(nfds, pRead, readfds); 224 if (writefds) 225 update(nfds, pWrite, writefds); 226 if (exceptfds) 227 update(nfds, pExcept, exceptfds); 81 228 82 229 return rc; … … 84 231 85 232 233 -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/socket/connect.c
-
Property cvs2svn:cvs-rev
changed from
1.1
to1.2
r885 r886 1 /* connect.c (emx+gcc) -- Copyright (c) 1994-1996 by Eberhard Mattes */ 1 /* $Id: $ */ 2 /** @file 3 * 4 * connect(). 5 * 6 * Copyright (c) 2003 knut st. osmundsen <bird-srcspam@anduin.net> 7 * 8 * 9 * This file is part of Innotek LIBC. 10 * 11 * Innotek LIBC is free software; you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License as published 13 * by the Free Software Foundation; either version 2 of the License, or 14 * (at your option) any later version. 15 * 16 * Innotek LIBC is distributed in the hope that it will be useful, 17 * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 * GNU Lesser General Public License for more details. 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * along with Innotek LIBC; if not, write to the Free Software 23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 24 * 25 */ 2 26 3 #include <emx/syscalls.h> 27 /******************************************************************************* 28 * Header Files * 29 *******************************************************************************/ 30 #include "libc-alias.h" 31 #include <errno.h> 32 #include <sys/socket.h> 33 #include <sys/fcntl.h> 34 #include <emx/io.h> 35 #include "socket.h" 4 36 5 int connect (int handle,struct sockaddr *addr, int addrlen)37 int connect(int socket, const struct sockaddr *addr, int addrlen) 6 38 { 7 return __connect (handle, addr, addrlen); 39 PLIBCSOCKETFH pFHSocket = __libsocket_FH(socket); 40 if (pFHSocket) 41 { 42 int rc; 43 rc = __libsocket_connect(pFHSocket->iSocket, addr, addrlen); 44 if (rc >= 0) 45 return rc; 46 __libsocket_setLibcErrno(); 47 } 48 49 return -1; 8 50 } 51 -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/socket/herror.c
-
Property cvs2svn:cvs-rev
changed from
1.2
to1.3
r885 r886 1 1 /* herror.c (emx+gcc) -- Copyright (c) 1994 by Eberhard Mattes */ 2 2 3 #define TCPV40HDRS 3 #ifndef TCPV40HDRS 4 #error TCPV40HDRS only 5 #endif 6 7 #include "libc-alias.h" 4 8 #include <stdio.h> 5 9 #include <sys/types.h> … … 8 12 extern int h_errno; 9 13 10 void herror(const char *string)14 void TCPCALL herror(const char *string) 11 15 { 12 16 int e = h_errno; -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/socket/listen.c
-
Property cvs2svn:cvs-rev
changed from
1.1
to1.2
r885 r886 1 /* listen.c (emx+gcc) -- Copyright (c) 1994-1996 by Eberhard Mattes */ 1 /* $Id: $ */ 2 /** @file 3 * 4 * listen(). 5 * 6 * Copyright (c) 2003 knut st. osmundsen <bird-srcspam@anduin.net> 7 * 8 * 9 * This file is part of Innotek LIBC. 10 * 11 * Innotek LIBC is free software; you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License as published 13 * by the Free Software Foundation; either version 2 of the License, or 14 * (at your option) any later version. 15 * 16 * Innotek LIBC is distributed in the hope that it will be useful, 17 * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 * GNU Lesser General Public License for more details. 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * along with Innotek LIBC; if not, write to the Free Software 23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 24 * 25 */ 2 26 3 #include <emx/syscalls.h> 27 /******************************************************************************* 28 * Header Files * 29 *******************************************************************************/ 30 #include "libc-alias.h" 31 #include <errno.h> 32 #include <sys/socket.h> 33 #include <sys/fcntl.h> 34 #include <emx/io.h> 35 #include "socket.h" 4 36 5 int listen (int handle, int backlog)37 int listen(int socket, int backlog) 6 38 { 7 return __listen (handle, backlog); 39 PLIBCSOCKETFH pFHSocket = __libsocket_FH(socket); 40 if (pFHSocket) 41 { 42 int rc; 43 rc = __libsocket_listen(pFHSocket->iSocket, backlog); 44 if (rc >= 0) 45 return rc; 46 __libsocket_setLibcErrno(); 47 } 48 49 return -1; 8 50 } 51 52 -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/socket/recv.c
-
Property cvs2svn:cvs-rev
changed from
1.1
to1.2
r885 r886 1 /* recv.c (emx+gcc) -- Copyright (c) 1994-1996 by Eberhard Mattes */ 1 /* $Id: $ */ 2 /** @file 3 * 4 * recv(). 5 * 6 * Copyright (c) 2003 knut st. osmundsen <bird-srcspam@anduin.net> 7 * 8 * 9 * This file is part of Innotek LIBC. 10 * 11 * Innotek LIBC is free software; you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License as published 13 * by the Free Software Foundation; either version 2 of the License, or 14 * (at your option) any later version. 15 * 16 * Innotek LIBC is distributed in the hope that it will be useful, 17 * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 * GNU Lesser General Public License for more details. 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * along with Innotek LIBC; if not, write to the Free Software 23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 24 * 25 */ 2 26 3 #include <emx/syscalls.h> 27 /******************************************************************************* 28 * Header Files * 29 *******************************************************************************/ 30 #include "libc-alias.h" 31 #include <errno.h> 32 #include <sys/socket.h> 33 #include <sys/fcntl.h> 34 #include <emx/io.h> 35 #include "socket.h" 4 36 5 int recv (int handle, void *buf, int len, unsignedflags)37 int recv(int socket, void *buf, int len, int flags) 6 38 { 7 return __recv (handle, buf, len, flags); 39 PLIBCSOCKETFH pFHSocket = __libsocket_FH(socket); 40 if (pFHSocket) 41 { 42 int rc; 43 rc = __libsocket_recv(pFHSocket->iSocket, buf, len, flags); 44 if (rc >= 0) 45 return rc; 46 __libsocket_setLibcErrno(); 47 } 48 49 return -1; 8 50 } 51 52 -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/socket/recvfrom.c
-
Property cvs2svn:cvs-rev
changed from
1.1
to1.2
r885 r886 1 /* recvfrom.c (emx+gcc) -- Copyright (c) 1994-1996 by Eberhard Mattes */ 1 /* $Id: $ */ 2 /** @file 3 * 4 * recvfrom(). 5 * 6 * Copyright (c) 2003 knut st. osmundsen <bird-srcspam@anduin.net> 7 * 8 * 9 * This file is part of Innotek LIBC. 10 * 11 * Innotek LIBC is free software; you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License as published 13 * by the Free Software Foundation; either version 2 of the License, or 14 * (at your option) any later version. 15 * 16 * Innotek LIBC is distributed in the hope that it will be useful, 17 * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 * GNU Lesser General Public License for more details. 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * along with Innotek LIBC; if not, write to the Free Software 23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 24 * 25 */ 2 26 3 #include <emx/syscalls.h> 27 /******************************************************************************* 28 * Header Files * 29 *******************************************************************************/ 30 #include "libc-alias.h" 31 #include <errno.h> 32 #include <sys/socket.h> 33 #include <sys/fcntl.h> 34 #include <emx/io.h> 35 #include "socket.h" 4 36 5 int recvfrom (int handle, void *buf, int len, unsigned flags, 6 struct sockaddr *from, int *pfromlen) 37 int recvfrom(int socket, void *buf, int len, int flags, struct sockaddr *from, int *fromlen) 7 38 { 8 struct _recvfrom args; 39 PLIBCSOCKETFH pFHSocket = __libsocket_FH(socket); 40 if (pFHSocket) 41 { 42 int rc; 43 rc = __libsocket_recvfrom(pFHSocket->iSocket, buf, len, flags, from, fromlen); 44 if (rc >= 0) 45 return rc; 46 __libsocket_setLibcErrno(); 47 } 9 48 10 args.handle = handle; 11 args.buf = buf; 12 args.len = len; 13 args.flags = flags; 14 args.from = from; 15 args.pfromlen = pfromlen; 16 return __recvfrom (&args); 49 return -1; 17 50 } 51 52 -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/socket/send.c
-
Property cvs2svn:cvs-rev
changed from
1.1
to1.2
r885 r886 1 /* send.c (emx+gcc) -- Copyright (c) 1994-1996 by Eberhard Mattes */ 1 /* $Id: $ */ 2 /** @file 3 * 4 * send(). 5 * 6 * Copyright (c) 2003 knut st. osmundsen <bird-srcspam@anduin.net> 7 * 8 * 9 * This file is part of Innotek LIBC. 10 * 11 * Innotek LIBC is free software; you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License as published 13 * by the Free Software Foundation; either version 2 of the License, or 14 * (at your option) any later version. 15 * 16 * Innotek LIBC is distributed in the hope that it will be useful, 17 * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 * GNU Lesser General Public License for more details. 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * along with Innotek LIBC; if not, write to the Free Software 23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 24 * 25 */ 2 26 3 #include <emx/syscalls.h> 27 /******************************************************************************* 28 * Header Files * 29 *******************************************************************************/ 30 #include "libc-alias.h" 31 #include <errno.h> 32 #include <sys/socket.h> 33 #include <sys/fcntl.h> 34 #include <emx/io.h> 35 #include "socket.h" 4 36 5 int send (int handle, const void *buf, int len, unsignedflags)37 int send(int socket, const void *buf, int len, int flags) 6 38 { 7 return __send (handle, buf, len, flags); 39 PLIBCSOCKETFH pFHSocket = __libsocket_FH(socket); 40 if (pFHSocket) 41 { 42 int rc; 43 rc = __libsocket_send(pFHSocket->iSocket, buf, len, flags); 44 if (rc >= 0) 45 return rc; 46 __libsocket_setLibcErrno(); 47 } 48 49 return -1; 8 50 } 51 52 -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/socket/sendto.c
-
Property cvs2svn:cvs-rev
changed from
1.1
to1.2
r885 r886 1 /* sendto.c (emx+gcc) -- Copyright (c) 1994-1996 by Eberhard Mattes */ 1 /* $Id: $ */ 2 /** @file 3 * 4 * sendto(). 5 * 6 * Copyright (c) 2003 knut st. osmundsen <bird-srcspam@anduin.net> 7 * 8 * 9 * This file is part of Innotek LIBC. 10 * 11 * Innotek LIBC is free software; you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License as published 13 * by the Free Software Foundation; either version 2 of the License, or 14 * (at your option) any later version. 15 * 16 * Innotek LIBC is distributed in the hope that it will be useful, 17 * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 * GNU Lesser General Public License for more details. 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * along with Innotek LIBC; if not, write to the Free Software 23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 24 * 25 */ 2 26 3 #include <emx/syscalls.h> 27 /******************************************************************************* 28 * Header Files * 29 *******************************************************************************/ 30 #include "libc-alias.h" 31 #include <errno.h> 32 #include <sys/socket.h> 33 #include <sys/fcntl.h> 34 #include <emx/io.h> 35 #include "socket.h" 4 36 5 int sendto (int handle, const void *buf, int len, unsigned flags, 6 const struct sockaddr *to, int tolen) 37 int sendto(int socket, const void *buf, int len, int flags, const struct sockaddr *to, int tolen) 7 38 { 8 struct _sendto args; 39 PLIBCSOCKETFH pFHSocket = __libsocket_FH(socket); 40 if (pFHSocket) 41 { 42 int rc; 43 rc = __libsocket_sendto(pFHSocket->iSocket, buf, len, flags, to, tolen); 44 if (rc >= 0) 45 return rc; 46 __libsocket_setLibcErrno(); 47 } 9 48 10 args.handle = handle; 11 args.buf = buf; 12 args.len = len; 13 args.flags = flags; 14 args.to = to; 15 args.tolen = tolen; 16 return __sendto (&args); 49 return -1; 17 50 } 51 -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/socket/shutdown.c
-
Property cvs2svn:cvs-rev
changed from
1.1
to1.2
r885 r886 1 /* shutdown.c (emx+gcc) -- Copyright (c) 1994-1996 by Eberhard Mattes */ 1 /* $Id: $ */ 2 /** @file 3 * 4 * shutdown(). 5 * 6 * Copyright (c) 2003 knut st. osmundsen <bird-srcspam@anduin.net> 7 * 8 * 9 * This file is part of Innotek LIBC. 10 * 11 * Innotek LIBC is free software; you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License as published 13 * by the Free Software Foundation; either version 2 of the License, or 14 * (at your option) any later version. 15 * 16 * Innotek LIBC is distributed in the hope that it will be useful, 17 * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 * GNU Lesser General Public License for more details. 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * along with Innotek LIBC; if not, write to the Free Software 23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 24 * 25 */ 2 26 3 #include <emx/syscalls.h> 27 /******************************************************************************* 28 * Header Files * 29 *******************************************************************************/ 30 #include "libc-alias.h" 31 #include <errno.h> 32 #include <sys/socket.h> 33 #include <sys/fcntl.h> 34 #include <emx/io.h> 35 #include "socket.h" 4 36 5 int shutdown (int handle, int how)37 int shutdown(int socket, int how) 6 38 { 7 return __shutdown (handle, how); 39 PLIBCSOCKETFH pFHSocket = __libsocket_FH(socket); 40 if (pFHSocket) 41 { 42 int rc; 43 rc = __libsocket_shutdown(pFHSocket->iSocket, how); 44 if (rc >= 0) 45 return rc; 46 __libsocket_setLibcErrno(); 47 } 48 49 return -1; 8 50 } 51 52 -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/socket/sock_errno.c
-
Property cvs2svn:cvs-rev
changed from
1.2
to1.3
r885 r886 10 10 */ 11 11 12 #include <sys/types.h> 12 /******************************************************************************* 13 * Header Files * 14 *******************************************************************************/ 15 #include "libc-alias.h" 16 #include <errno.h> 13 17 #include <sys/socket.h> 18 #include <sys/fcntl.h> 19 #include <emx/io.h> 20 #include "socket.h" 21 14 22 15 23 /** … … 24 32 /* get the OS/2 error. */ 25 33 int err = os2_sock_errno(); 26 if (err > 10000 && err < 11000)27 err -= 10000;34 if (err > EOS2_TCPIP_OFFSET && err < EOS2_TCPIP_OFFSET + 1000) 35 err -= EOS2_TCPIP_OFFSET; 28 36 return err; 29 37 } -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/socket/socket.c
-
Property cvs2svn:cvs-rev
changed from
1.1
to1.2
r885 r886 1 /* socket.c (emx+gcc) -- Copyright (c) 1994-1996 by Eberhard Mattes */ 1 /* $Id: $ */ 2 /** @file 3 * 4 * socket(). 5 * 6 * Copyright (c) 2003 knut st. osmundsen <bird-srcspam@anduin.net> 7 * 8 * 9 * This file is part of Innotek LIBC. 10 * 11 * Innotek LIBC is free software; you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License as published 13 * by the Free Software Foundation; either version 2 of the License, or 14 * (at your option) any later version. 15 * 16 * Innotek LIBC is distributed in the hope that it will be useful, 17 * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 * GNU Lesser General Public License for more details. 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * along with Innotek LIBC; if not, write to the Free Software 23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 24 * 25 */ 2 26 27 /******************************************************************************* 28 * Header Files * 29 *******************************************************************************/ 30 #include "libc-alias.h" 31 #include <errno.h> 32 #include <sys/socket.h> 3 33 #include <sys/fcntl.h> 4 #include <errno.h>5 34 #include <emx/io.h> 6 #include <emx/syscalls.h>35 #include "socket.h" 7 36 8 int socket (int domain, int type, int protocol) 37 38 int socket(int af, int type, int protocol) 9 39 { 10 int s, *pflags;40 int s; 11 41 12 s = __socket (domain, type, protocol); 13 if (s < 0) 42 s = __libsocket_socket(af, type, protocol); 43 if (s >= 0) 44 { 45 int rc; 46 int fh; 47 PLIBCSOCKETFH pFH; 48 rc = __libc_FHAllocate(-1, O_RDWR | F_SOCKET, sizeof(LIBCSOCKETFH), &__libsocket_gSocketOps, (PLIBCFH*)&pFH, &fh); 49 if (!rc) 50 { 51 pFH->iSocket = s; 52 return fh; 53 } 54 else 55 __libsocket_soclose(s); 56 __libsocket_setSocketErrno(); 57 } 58 else 59 __libsocket_setLibcErrno(); 60 14 61 return -1; 15 if ((pflags = _fd_init (s)) == NULL)16 {17 __close (s);18 errno = EMFILE;19 return -1;20 }21 *pflags = O_RDWR | F_SOCKET;22 return s;23 62 } 63 -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/socket/socket.imp
-
Property cvs2svn:cvs-rev
changed from
1.5
to1.6
r885 r886 5 5 ; 6 6 ; -------- tcpip32.lib -------- 7 accept tcpip32 1 ? 8 _accept tcpip32 1 ? 9 bind tcpip32 2 ? 10 _bind tcpip32 2 ? 11 connect tcpip32 3 ? 12 _connect tcpip32 3 ? 7 __libsocket_accept tcpip32 1 ? 8 __libsocket_bind tcpip32 2 ? 9 __libsocket_connect tcpip32 3 ? 13 10 gethostid tcpip32 4 ? 14 11 _gethostid tcpip32 4 ? 15 getpeername tcpip32 5 ? 16 _getpeername tcpip32 5 ? 17 getsockname tcpip32 6 ? 18 _getsockname tcpip32 6 ? 19 getsockopt tcpip32 7 ? 20 _getsockopt tcpip32 7 ? 21 so_ioctl tcpip32 8 ? 22 _so_ioctl tcpip32 8 ? 23 listen tcpip32 9 ? 24 _listen tcpip32 9 ? 25 recv tcpip32 10 ? 26 _recv tcpip32 10 ? 27 recvfrom tcpip32 11 ? 28 _recvfrom tcpip32 11 ? 29 os2_select tcpip32 12 ? 30 _os2_select tcpip32 12 ? 31 send tcpip32 13 ? 32 _send tcpip32 13 ? 33 sendto tcpip32 14 ? 34 _sendto tcpip32 14 ? 35 setsockopt tcpip32 15 ? 36 _setsockopt tcpip32 15 ? 37 socket tcpip32 16 ? 38 _socket tcpip32 16 ? 39 soclose tcpip32 17 ? 40 _soclose tcpip32 17 ? 41 so_cancel tcpip32 18 ? 42 _so_cancel tcpip32 18 ? 43 soabort tcpip32 19 ? 44 _soabort tcpip32 19 ? 12 __libsocket_getpeername tcpip32 5 ? 13 __libsocket_getsockname tcpip32 6 ? 14 __libsocket_getsockopt tcpip32 7 ? 15 __libsocket_ioctl tcpip32 8 ? 16 __libsocket_listen tcpip32 9 ? 17 __libsocket_recv tcpip32 10 ? 18 __libsocket_recvfrom tcpip32 11 ? 19 __libsocket_os2_select tcpip32 12 ? 20 __libsocket_send tcpip32 13 ? 21 __libsocket_sendto tcpip32 14 ? 22 __libsocket_setsockopt tcpip32 15 ? 23 __libsocket_socket tcpip32 16 ? 24 __libsocket_soclose tcpip32 17 ? 25 __libsocket_so_cancel tcpip32 18 ? 26 __libsocket_soabort tcpip32 19 ? 45 27 os2_sock_errno tcpip32 20 ? 46 _os2_sock_errno tcpip32 20 ? 47 recvmsg tcpip32 21 ? 48 _recvmsg tcpip32 21 ? 49 sendmsg tcpip32 22 ? 50 _sendmsg tcpip32 22 ? 51 so_readv tcpip32 23 ? 52 _so_readv tcpip32 23 ? 53 so_writev tcpip32 24 ? 54 _so_writev tcpip32 24 ? 55 shutdown tcpip32 25 ? 56 _shutdown tcpip32 25 ? 28 _os2_sock_errno tcpip32 20 ? 29 __libsocket_recvmsg tcpip32 21 ? 30 __libsocket_sendmsg tcpip32 22 ? 31 __libsocket_so_readv tcpip32 23 ? 32 __libsocket_so_writev tcpip32 24 ? 33 __libsocket_shutdown tcpip32 25 ? 57 34 sock_init tcpip32 26 ? 58 35 _sock_init tcpip32 26 ? … … 67 44 getinetversion tcpip32 31 ? 68 45 _getinetversion tcpip32 31 ? 69 v5_bsdselect tcpip32 32 ? 70 set_errno tcpip32 35 ? 71 _set_errno tcpip32 35 ? 46 __libsocket_bsdselect tcpip32 32 ? 47 __libsocket_set_errno tcpip32 35 ? 72 48 winsockcleanupsockets tcpip32 38 ? 73 49 _winsockcleanupsockets tcpip32 38 ? … … 174 150 Rgethostbyname tcpip32 161 ? 175 151 _Rgethostbyname tcpip32 161 ? 176 os2_ioctl tcpip32 200 ? 177 _os2_ioctl tcpip32 200 ? 152 __libsocket_os2_ioctl tcpip32 200 ? 178 153 __TCPFDIsSet tcpip32 201 ? 179 154 ___TCPFDIsSet tcpip32 201 ? … … 282 257 inet_nsap_ntoa tcpip32 253 ? 283 258 _inet_nsap_ntoa tcpip32 253 ? 284 socketpair tcpip32 254 ? 285 _socketpair tcpip32 254 ? 259 __libsocket_socketpair tcpip32 254 ? 286 260 sock_strerror tcpip32 255 ? 287 261 _sock_strerror tcpip32 255 ? -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/socket/socket.smak
-
Property cvs2svn:cvs-rev
changed from
1.10
to1.11
r885 r886 3 3 .MODULE := libsocket 4 4 .MDESC := The socket library 5 _MDIRS := $.aout/tcpipv4 $.aout-prof/tcpipv4 $.aout/dep-tcpipv4 $.aout-prof/dep-tcpipv4 6 .MDEP := emxomf emximp $(_MDIRS) 7 TARGDIRS += $(_MDIRS) 5 #_MDIRS := $.aout/tcpipv4 $.aout-prof/tcpipv4 $.aout/dep-tcpipv4 $.aout-prof/dep-tcpipv4 6 .MDEP := emxomf emximp 7 #$(_MDIRS) 8 #TARGDIRS += $(_MDIRS) 8 9 9 10 .TARGET := libsocket_p.a 10 11 .TKIND := aout prof 11 .TSRC := $(wildcard src/lib/socket/386/*.s) 12 .TSRC += src/lib/socket/sock_errno.c src/lib/socket/bsdselect.c 12 .TSRC := $(wildcard src/lib/socket/386/*.s) \ 13 $(filter-out src/lib/socket/aliases/herror%, $(wildcard src/lib/socket/aliases/*.s)) \ 14 $(filter-out src/lib/socket/herror%, $(wildcard src/lib/socket/*.c)) 15 .TCF := -I$. 13 16 .IMPS := src/lib/socket/socket.imp 14 17 .INSDIR := lib/ … … 18 21 .TARGET := libsocket.a 19 22 .TKIND := aout 20 .TSRC := $(wildcard src/lib/socket/386/*.s)21 .TSRC += src/lib/socket/sock_errno.c src/lib/socket/bsdselect.c22 .IMPS := src/lib/socket/socket.imp23 .INSDIR := lib/24 23 .TKEEP := 1 25 24 include mkimplib.smak 26 25 27 26 28 .TARGET := tcpipv4/libsocket_p.a27 .TARGET := libsocket_p.a 29 28 .TKIND := aout prof 30 .TSRC := $(wildcard src/lib/socket/386/*.s) 31 .TSRC += src/lib/socket/herror.c src/lib/socket/sock_errno.c src/lib/socket/socketpair.c 32 .TSRC += src/lib/socket/socketpair-alias.s 29 .TKVAR := tcpipv4 30 .TSRC := $(wildcard src/lib/socket/386/*.s) $(wildcard src/lib/socket/aliases/*.s) \ 31 $(wildcard src/lib/socket/*.c) 32 .TCF := -I$. -DTCPV40HDRS 33 33 .IMPS := src/lib/socket/socket_tcpipv4.imp 34 .INSDIR := lib/ 34 .INSDIR := lib/tcpipv4 35 35 .TKEEP := 1 36 36 include mkimplib.smak 37 37 38 .TARGET := tcpipv4/libsocket.a38 .TARGET := libsocket.a 39 39 .TKIND := aout 40 .TSRC := $(wildcard src/lib/socket/386/*.s)41 .TSRC += src/lib/socket/herror.c src/lib/socket/sock_errno.c src/lib/socket/socketpair.c42 .TSRC += src/lib/socket/socketpair-alias.s43 .IMPS := src/lib/socket/socket_tcpipv4.imp44 .TKEEP := 145 40 include mkimplib.smak 46 47 #$.omf/tcpipv4 omf-prof/tcpipv448 41 49 42 -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/socket/socket_tcpipv4.imp
-
Property cvs2svn:cvs-rev
changed from
1.4
to1.5
r885 r886 5 5 ; 6 6 ; -------- so32dll.lib -------- 7 accept so32dll 1 ? 8 _accept so32dll 1 ? 9 bind so32dll 2 ? 10 _bind so32dll 2 ? 11 connect so32dll 3 ? 12 _connect so32dll 3 ? 7 __libsocket_accept so32dll 1 ? 8 __libsocket_bind so32dll 2 ? 9 __libsocket_connect so32dll 3 ? 13 10 gethostid so32dll 4 ? 14 11 _gethostid so32dll 4 ? 15 getpeername so32dll 5 ? 16 _getpeername so32dll 5 ? 17 getsockname so32dll 6 ? 18 _getsockname so32dll 6 ? 19 getsockopt so32dll 7 ? 20 _getsockopt so32dll 7 ? 21 os2_ioctl so32dll 8 ? 22 _os2_ioctl so32dll 8 ? 23 listen so32dll 9 ? 24 _listen so32dll 9 ? 25 recv so32dll 10 ? 26 _recv so32dll 10 ? 27 recvfrom so32dll 11 ? 28 _recvfrom so32dll 11 ? 29 os2_select so32dll 12 ? 30 _os2_select so32dll 12 ? 31 send so32dll 13 ? 32 _send so32dll 13 ? 33 sendto so32dll 14 ? 34 _sendto so32dll 14 ? 35 setsockopt so32dll 15 ? 36 _setsockopt so32dll 15 ? 37 socket so32dll 16 ? 38 _socket so32dll 16 ? 39 soclose so32dll 17 ? 40 _soclose so32dll 17 ? 41 so_cancel so32dll 18 ? 42 _so_cancel so32dll 18 ? 43 soabort so32dll 19 ? 44 _soabort so32dll 19 ? 12 __libsocket_getpeername so32dll 5 ? 13 __libsocket_getsockname so32dll 6 ? 14 __libsocket_getsockopt so32dll 7 ? 15 __libsocket_os2_ioctl so32dll 8 ? 16 __libsocket_listen so32dll 9 ? 17 __libsocket_recv so32dll 10 ? 18 __libsocket_recvfrom so32dll 11 ? 19 __libsocket_os2_select so32dll 12 ? 20 __libsocket_send so32dll 13 ? 21 __libsocket_sendto so32dll 14 ? 22 __libsocket_setsockopt so32dll 15 ? 23 __libsocket_socket so32dll 16 ? 24 __libsocket_soclose so32dll 17 ? 25 __libsocket_so_cancel so32dll 18 ? 26 __libsocket_soabort so32dll 19 ? 45 27 os2_sock_errno so32dll 20 ? 46 28 _os2_sock_errno so32dll 20 ? 47 recvmsg so32dll 21 ? 48 _recvmsg so32dll 21 ? 49 sendmsg so32dll 22 ? 50 _sendmsg so32dll 22 ? 51 so_readv so32dll 23 ? 52 _so_readv so32dll 23 ? 53 so_writev so32dll 24 ? 54 _so_writev so32dll 24 ? 55 shutdown so32dll 25 ? 56 _shutdown so32dll 25 ? 29 __libsocket_recvmsg so32dll 21 ? 30 __libsocket_sendmsg so32dll 22 ? 31 __libsocket_so_readv so32dll 23 ? 32 __libsocket_so_writev so32dll 24 ? 33 __libsocket_shutdown so32dll 25 ? 57 34 sock_init so32dll 26 ? 58 35 _sock_init so32dll 26 ? … … 65 42 getinetversion so32dll 31 ? 66 43 _getinetversion so32dll 31 ? 67 bsdselect so32dll 32 ? 68 _bsdselect so32dll 32 ? 69 set_errno so32dll 35 ? 70 _set_errno so32dll 35 ? 44 __libsocket_bsdselect so32dll 32 ? 45 __libsocket_set_errno so32dll 35 ? 71 46 getsocketfromlist so32dll 39 ? 72 47 _getsocketfromlist so32dll 39 ? -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/socket/socketpair.c
-
Property cvs2svn:cvs-rev
changed from
1.1
to1.2
r885 r886 12 12 */ 13 13 14 #define TCPV40HDRS 14 15 /******************************************************************************* 16 * Header Files * 17 *******************************************************************************/ 18 #include "libc-alias.h" 15 19 #include <sys/types.h> 16 20 #include <sys/time.h> … … 20 24 #include <stdio.h> 21 25 #include <string.h> 26 #include <errno.h> 27 #include <sys/socket.h> 28 #include <sys/fcntl.h> 29 #include <emx/io.h> 30 #include "socket.h" 22 31 23 32 … … 35 44 int TCPCALL socketpair(int af, int type, int flags, int *osfd) 36 45 { 46 #ifdef TCPV40HDRS 37 47 int rc; 38 48 int sock1 = -1; … … 106 116 soclose(sock2); 107 117 return -1; 118 119 #else 120 int rc; 121 int fh1; 122 int fh2; 123 PLIBCSOCKETFH pFH; 124 125 rc = __libsocket_pair(af, type, flags, osfd); 126 if (rc < 0) 127 { 128 __libsocket_setLibcErrno(); 129 return -1; 130 } 131 132 /* 133 * Allocate LIBC sockets. 134 */ 135 rc = __libc_FHAllocate(-1, O_RDWR | F_SOCKET, sizeof(LIBCSOCKETFH), &__libsocket_gSocketOps, (PLIBCFH*)&pFH, &fh1); 136 if (!rc) 137 { 138 pFH->iSocket = osfd[0]; 139 rc = __libc_FHAllocate(-1, O_RDWR | F_SOCKET, sizeof(LIBCSOCKETFH), &__libsocket_gSocketOps, (PLIBCFH*)&pFH, &fh2); 140 if (!rc) 141 { 142 pFH->iSocket = osfd[1]; 143 osfd[0] = fh1; 144 osfd[1] = fh2; 145 return 0; 146 } 147 __libc_FHClose(fh1); 148 } 149 150 __libsocket_soclose(osfd[0]); 151 __libsocket_soclose(osfd[1]); 152 return -1; 153 #endif 108 154 } 109 155 -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/libsocket/accept.c
-
Property cvs2svn:cvs-rev
changed from
1.1
to1.2
r885 r886 1 /* accept.c (emx+gcc) -- Copyright (c) 1994-1996 by Eberhard Mattes */ 1 /* $Id: $ */ 2 /** @file 3 * 4 * accept(). 5 * 6 * Copyright (c) 2003 knut st. osmundsen <bird-srcspam@anduin.net> 7 * 8 * 9 * This file is part of Innotek LIBC. 10 * 11 * Innotek LIBC is free software; you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License as published 13 * by the Free Software Foundation; either version 2 of the License, or 14 * (at your option) any later version. 15 * 16 * Innotek LIBC is distributed in the hope that it will be useful, 17 * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 * GNU Lesser General Public License for more details. 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * along with Innotek LIBC; if not, write to the Free Software 23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 24 * 25 */ 2 26 27 /******************************************************************************* 28 * Header Files * 29 *******************************************************************************/ 30 #include "libc-alias.h" 31 #include <errno.h> 32 #include <sys/socket.h> 3 33 #include <sys/fcntl.h> 4 #include <errno.h>5 34 #include <emx/io.h> 6 #include <emx/syscalls.h>35 #include "socket.h" 7 36 8 int accept (int handle, struct sockaddr *addr, int *paddrlen)37 int accept(int socket, struct sockaddr *addr, int *addrlen) 9 38 { 10 int s, *pflags; 39 PLIBCSOCKETFH pFHSocket = __libsocket_FH(socket); 40 int s; 41 if (pFHSocket) 42 { 43 s = __libsocket_accept(pFHSocket->iSocket, addr, addrlen); 44 if (s >= 0) 45 { 46 int rc; 47 int fh; 48 PLIBCSOCKETFH pFH; 49 rc = __libc_FHAllocate(-1, O_RDWR | F_SOCKET, sizeof(LIBCSOCKETFH), &__libsocket_gSocketOps, (PLIBCFH*)&pFH, &fh); 50 if (!rc) 51 { 52 pFH->iSocket = s; 53 return fh; 54 } 55 else 56 __libsocket_soclose(s); 57 __libsocket_setSocketErrno(); 58 } 59 else 60 __libsocket_setLibcErrno(); 61 } 11 62 12 s = __accept (handle, addr, paddrlen);13 if (s < 0)14 63 return -1; 15 if ((pflags = _fd_init (s)) == NULL)16 {17 __close (s);18 errno = EMFILE;19 return -1;20 }21 *pflags = O_RDWR | F_SOCKET;22 return s;23 64 } 65 -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/libsocket/bind.c
-
Property cvs2svn:cvs-rev
changed from
1.1
to1.2
r885 r886 1 /* bind.c (emx+gcc) -- Copyright (c) 1994-1996 by Eberhard Mattes */ 1 /* $Id: $ */ 2 /** @file 3 * 4 * bind(). 5 * 6 * Copyright (c) 2003 knut st. osmundsen <bird-srcspam@anduin.net> 7 * 8 * 9 * This file is part of Innotek LIBC. 10 * 11 * Innotek LIBC is free software; you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License as published 13 * by the Free Software Foundation; either version 2 of the License, or 14 * (at your option) any later version. 15 * 16 * Innotek LIBC is distributed in the hope that it will be useful, 17 * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 * GNU Lesser General Public License for more details. 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * along with Innotek LIBC; if not, write to the Free Software 23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 24 * 25 */ 2 26 3 #include <emx/syscalls.h> 27 /******************************************************************************* 28 * Header Files * 29 *******************************************************************************/ 30 #include "libc-alias.h" 31 #include <errno.h> 32 #include <sys/socket.h> 33 #include <sys/fcntl.h> 34 #include <emx/io.h> 35 #include "socket.h" 4 36 5 int bind (int handle,struct sockaddr *addr, int addrlen)37 int bind(int socket, const struct sockaddr *addr, int addrlen) 6 38 { 7 return __bind (handle, addr, addrlen); 39 PLIBCSOCKETFH pFHSocket = __libsocket_FH(socket); 40 if (pFHSocket) 41 { 42 int rc; 43 rc = __libsocket_bind(pFHSocket->iSocket, addr, addrlen); 44 if (rc >= 0) 45 return rc; 46 __libsocket_setLibcErrno(); 47 } 48 49 return -1; 8 50 } 51 -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/libsocket/bsdselect.c
-
Property cvs2svn:cvs-rev
changed from
1.1
to1.2
r885 r886 1 /* $Id$ 2 * 3 * Wrapper for bsdselect() in BSD 4.4 mode. 4 * 5 * Copyright (c) 2003 InnoTek Systemberatung GmbH 6 * Author: knut st. osmundsen <bird@anduin.net> 7 * 8 * All Rights Reserved 9 * 10 */ 11 #include <stdlib.h> 12 #include <alloca.h> 13 #include <sys/types.h> 14 #include <sys/select.h> 15 16 17 #define V5_FD_SETSIZE 64 18 19 #pragma pack(4) 20 typedef struct v5_fd_set { 21 u_short fd_count; /* how many are SET? */ 22 int fd_array[V5_FD_SETSIZE];/* an array of SOCKETs */ 23 } v5_fd_set; 24 #pragma pack() 25 26 #define V5_FD_SET(fd, set) do { \ 27 if (((v5_fd_set *)(set))->fd_count < V5_FD_SETSIZE) \ 28 ((v5_fd_set *)(set))->fd_array[((v5_fd_set *)(set))->fd_count++]=fd;\ 29 } while(0) 30 31 int _System v5_bsdselect(int, struct v5_fd_set *, struct v5_fd_set *, struct v5_fd_set *, struct timeval *); 32 33 34 static inline void convert(int c, const struct fd_set *pFrom, struct v5_fd_set *pTo) 35 { 36 int i = 0; 37 38 memset(pTo, 0, sizeof(struct v5_fd_set)); 1 /* $Id$ */ 2 /** @file 3 * 4 * bsdselect(). 5 * 6 * Copyright (c) 2003 knut st. osmundsen <bird-srcspam@anduin.net> 7 * 8 * 9 * This file is part of Innotek LIBC. 10 * 11 * Innotek LIBC is free software; you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License as published 13 * by the Free Software Foundation; either version 2 of the License, or 14 * (at your option) any later version. 15 * 16 * Innotek LIBC is distributed in the hope that it will be useful, 17 * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 * GNU Lesser General Public License for more details. 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * along with Innotek LIBC; if not, write to the Free Software 23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 24 * 25 */ 26 27 /******************************************************************************* 28 * Header Files * 29 *******************************************************************************/ 30 #include "libc-alias.h" 31 #include <errno.h> 32 #include <sys/socket.h> 33 #include <sys/fcntl.h> 34 #include <emx/io.h> 35 #include "socket.h" 36 37 38 /******************************************************************************* 39 * Defined Constants And Macros * 40 *******************************************************************************/ 41 #ifdef TCPV40HDRS 42 43 #define MY_FD_SET(fd, set) FD_SET(fd, set) 44 #define MY_FD_ISSET(fd, set) FD_ISSET(fd, set) 45 #define MY_FD_ZERO(set, cb) memset(set, 0, cb); 46 #define my_fd_set fd_set 47 48 #else 49 50 #define MY_FD_SET(fd, set) V5_FD_SET(fd, set) 51 #define MY_FD_ISSET(fd, set) V5_FD_ISSET(fd, set) 52 #define MY_FD_ZERO(set, cb) memset(set, 0, cb); 53 #define my_fd_set v5_fd_set 54 55 #endif 56 57 58 /** 59 * Calculate the size required for the converted set structure. 60 * @returns number of bytes. 61 * @param c Number of file descriptors specified in the call. 62 * @param pFrom The select input fd_set structure. 63 */ 64 static inline int calcsize(int c, const struct fd_set *pFrom) 65 { 66 int cbRet; 67 #ifdef TCPV40HDRS 68 cbRet = (c + 7) / 8; 69 #else 70 int i; 71 for (cbRet = sizeof(u_short), i = 0; i < c; i++) 72 if (FD_ISSET(i, pFrom)) 73 cbRet++; 74 #endif 75 if (cbRet < sizeof(struct my_fd_set)) 76 return sizeof(struct my_fd_set); 77 return cbRet; 78 } 79 80 /** Converts the LIBC fd_set strcture pointed to by pFrom with it's LIBC socket handles, 81 * to the fd_set strcuture used by the OS/2 tcpip and the OS/2 socket handles. 82 * @returns 0 on success. 83 * @returns -1 on failure, both errnos set. 84 * @param c Number of file descriptors specified in the call. 85 * @param cb Size of pTo. (used for zeroing it) 86 * @param pFrom The select input fd_set structure. 87 * @param pTo The structure we present to OS/2 TCPIP. 88 * This will be initialized. 89 */ 90 static inline int convert(int c, int cb, const struct fd_set *pFrom, struct my_fd_set *pTo) 91 { 92 int i; 93 MY_FD_ZERO(pTo, cb) 39 94 for (i = 0; i < c; i++) 40 95 { 41 96 if (FD_ISSET(i, pFrom)) 42 V5_FD_SET(i, pTo); 43 } 44 /** @todo: check for overflow and return appropriate error code... */ 45 } 46 97 { 98 PLIBCSOCKETFH pFHSocket = __libsocket_FH(i); 99 if (!pFHSocket) 100 return -1; 101 MY_FD_SET(pFHSocket->iSocket, pTo); 102 } 103 } 104 return 0; 105 } 47 106 48 107 /** 49 * This wrapper is required to work around a new ushort field someone 50 * at IBM added to speed up the macros accessing the select structure. 51 * @remark Only BSD 4.4 mode. 52 */ 53 int _System bsdselect(int nfds, struct fd_set *readfds, struct fd_set *writefds, 54 struct fd_set *excptfds, struct timeval *timeout) 55 { 56 int rc; 57 struct v5_fd_set *pv5_readfds = NULL; 58 struct v5_fd_set *pv5_writefds = NULL; 59 struct v5_fd_set *pv5_excptfds = NULL; 60 int cfds = nfds <= 0 ? FD_SETSIZE : nfds; 61 108 * Updates the pTo structure with the fds marked ready in pFrom. 109 * 110 * @param c Number of file descriptors specified in the call. 111 * @param pFrom The structure returned from OS/2 TCPIP select. 112 * @param pTo The structure passed in to select which have to 113 * be updated for the return. 114 */ 115 static inline void update(int c, const struct my_fd_set *pFrom, struct fd_set *pTo) 116 { 117 int i; 118 for (i = 0; i < c; i++) 119 { 120 if (FD_ISSET(i, pTo)) 121 { 122 PLIBCSOCKETFH pFHSocket = __libsocket_FH(i); 123 if (pFHSocket) 124 { 125 if (!MY_FD_ISSET(pFHSocket->iSocket, pFrom)) 126 FD_CLR(i, pTo); 127 } 128 } 129 } 130 } 131 132 133 134 int bsdselect(int nfds, struct fd_set *readfds, struct fd_set *writefds, struct fd_set *exceptfds, struct timeval *tv) 135 { 136 #ifdef TCPV40HDRS 137 struct fd_set *pRead; 138 struct fd_set *pWrite; 139 struct fd_set *pExcept; 140 #else 141 struct v5_fd_set *pRead; 142 struct v5_fd_set *pWrite; 143 struct v5_fd_set *pExcept; 144 #endif 145 int cb; 146 int rc; 147 148 /* 149 * Allocate new bitmaps. 150 */ 151 pRead = NULL; 62 152 if (readfds) 63 153 { 64 pv5_readfds = alloca(sizeof(struct v5_fd_set)); 65 convert(cfds, readfds, pv5_readfds); 66 } 67 154 cb = calcsize(nfds, readfds); 155 pRead = alloca(cb); 156 if (!pRead) 157 { 158 __libsocket_setErrno(ENOMEM); 159 return -1; 160 } 161 if (convert(nfds, cb, readfds, pRead)) 162 return -1; 163 } 164 165 pWrite = NULL; 68 166 if (writefds) 69 167 { 70 pv5_writefds = alloca(sizeof(struct v5_fd_set)); 71 convert(cfds, writefds, pv5_writefds); 72 } 73 74 if (excptfds) 75 { 76 pv5_excptfds = alloca(sizeof(struct v5_fd_set)); 77 convert(cfds, excptfds, pv5_excptfds); 78 } 79 80 rc = v5_bsdselect(nfds, pv5_readfds, pv5_writefds, pv5_excptfds, timeout); 168 cb = calcsize(nfds, writefds); 169 pWrite = alloca(cb); 170 if (!pWrite) 171 { 172 __libsocket_setErrno(ENOMEM); 173 return -1; 174 } 175 if (convert(nfds, cb, writefds, pWrite)) 176 return -1; 177 } 178 179 pExcept = NULL; 180 if (exceptfds) 181 { 182 cb = calcsize(nfds, exceptfds); 183 pExcept = alloca(cb); 184 if (!pExcept) 185 { 186 __libsocket_setErrno(ENOMEM); 187 return -1; 188 } 189 if (convert(nfds, cb, exceptfds, pExcept)) 190 return -1; 191 } 192 193 /* 194 * Do the call. 195 */ 196 rc = __libsocket_bsdselect(nfds, pRead, pWrite, pExcept, tv); 197 if (rc < 0) 198 { 199 __libsocket_setLibcErrno(); 200 return rc; 201 } 202 203 /* 204 * Timeout? 205 * Just clear the bitmaps and return. 206 */ 207 if (rc == 0) 208 { 209 cb = (nfds + 7) / 8; 210 if (readfds) 211 memset(readfds, 0, cb); 212 if (writefds) 213 memset(writefds, 0, cb); 214 if (exceptfds) 215 memset(exceptfds, 0, cb); 216 return 0; 217 } 218 219 /* 220 * Convert the bitmaps. 221 */ 222 if (readfds) 223 update(nfds, pRead, readfds); 224 if (writefds) 225 update(nfds, pWrite, writefds); 226 if (exceptfds) 227 update(nfds, pExcept, exceptfds); 81 228 82 229 return rc; … … 84 231 85 232 233 -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/libsocket/connect.c
-
Property cvs2svn:cvs-rev
changed from
1.1
to1.2
r885 r886 1 /* connect.c (emx+gcc) -- Copyright (c) 1994-1996 by Eberhard Mattes */ 1 /* $Id: $ */ 2 /** @file 3 * 4 * connect(). 5 * 6 * Copyright (c) 2003 knut st. osmundsen <bird-srcspam@anduin.net> 7 * 8 * 9 * This file is part of Innotek LIBC. 10 * 11 * Innotek LIBC is free software; you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License as published 13 * by the Free Software Foundation; either version 2 of the License, or 14 * (at your option) any later version. 15 * 16 * Innotek LIBC is distributed in the hope that it will be useful, 17 * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 * GNU Lesser General Public License for more details. 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * along with Innotek LIBC; if not, write to the Free Software 23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 24 * 25 */ 2 26 3 #include <emx/syscalls.h> 27 /******************************************************************************* 28 * Header Files * 29 *******************************************************************************/ 30 #include "libc-alias.h" 31 #include <errno.h> 32 #include <sys/socket.h> 33 #include <sys/fcntl.h> 34 #include <emx/io.h> 35 #include "socket.h" 4 36 5 int connect (int handle,struct sockaddr *addr, int addrlen)37 int connect(int socket, const struct sockaddr *addr, int addrlen) 6 38 { 7 return __connect (handle, addr, addrlen); 39 PLIBCSOCKETFH pFHSocket = __libsocket_FH(socket); 40 if (pFHSocket) 41 { 42 int rc; 43 rc = __libsocket_connect(pFHSocket->iSocket, addr, addrlen); 44 if (rc >= 0) 45 return rc; 46 __libsocket_setLibcErrno(); 47 } 48 49 return -1; 8 50 } 51 -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/libsocket/herror.c
-
Property cvs2svn:cvs-rev
changed from
1.2
to1.3
r885 r886 1 1 /* herror.c (emx+gcc) -- Copyright (c) 1994 by Eberhard Mattes */ 2 2 3 #define TCPV40HDRS 3 #ifndef TCPV40HDRS 4 #error TCPV40HDRS only 5 #endif 6 7 #include "libc-alias.h" 4 8 #include <stdio.h> 5 9 #include <sys/types.h> … … 8 12 extern int h_errno; 9 13 10 void herror(const char *string)14 void TCPCALL herror(const char *string) 11 15 { 12 16 int e = h_errno; -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/libsocket/listen.c
-
Property cvs2svn:cvs-rev
changed from
1.1
to1.2
r885 r886 1 /* listen.c (emx+gcc) -- Copyright (c) 1994-1996 by Eberhard Mattes */ 1 /* $Id: $ */ 2 /** @file 3 * 4 * listen(). 5 * 6 * Copyright (c) 2003 knut st. osmundsen <bird-srcspam@anduin.net> 7 * 8 * 9 * This file is part of Innotek LIBC. 10 * 11 * Innotek LIBC is free software; you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License as published 13 * by the Free Software Foundation; either version 2 of the License, or 14 * (at your option) any later version. 15 * 16 * Innotek LIBC is distributed in the hope that it will be useful, 17 * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 * GNU Lesser General Public License for more details. 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * along with Innotek LIBC; if not, write to the Free Software 23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 24 * 25 */ 2 26 3 #include <emx/syscalls.h> 27 /******************************************************************************* 28 * Header Files * 29 *******************************************************************************/ 30 #include "libc-alias.h" 31 #include <errno.h> 32 #include <sys/socket.h> 33 #include <sys/fcntl.h> 34 #include <emx/io.h> 35 #include "socket.h" 4 36 5 int listen (int handle, int backlog)37 int listen(int socket, int backlog) 6 38 { 7 return __listen (handle, backlog); 39 PLIBCSOCKETFH pFHSocket = __libsocket_FH(socket); 40 if (pFHSocket) 41 { 42 int rc; 43 rc = __libsocket_listen(pFHSocket->iSocket, backlog); 44 if (rc >= 0) 45 return rc; 46 __libsocket_setLibcErrno(); 47 } 48 49 return -1; 8 50 } 51 52 -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/libsocket/recv.c
-
Property cvs2svn:cvs-rev
changed from
1.1
to1.2
r885 r886 1 /* recv.c (emx+gcc) -- Copyright (c) 1994-1996 by Eberhard Mattes */ 1 /* $Id: $ */ 2 /** @file 3 * 4 * recv(). 5 * 6 * Copyright (c) 2003 knut st. osmundsen <bird-srcspam@anduin.net> 7 * 8 * 9 * This file is part of Innotek LIBC. 10 * 11 * Innotek LIBC is free software; you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License as published 13 * by the Free Software Foundation; either version 2 of the License, or 14 * (at your option) any later version. 15 * 16 * Innotek LIBC is distributed in the hope that it will be useful, 17 * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 * GNU Lesser General Public License for more details. 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * along with Innotek LIBC; if not, write to the Free Software 23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 24 * 25 */ 2 26 3 #include <emx/syscalls.h> 27 /******************************************************************************* 28 * Header Files * 29 *******************************************************************************/ 30 #include "libc-alias.h" 31 #include <errno.h> 32 #include <sys/socket.h> 33 #include <sys/fcntl.h> 34 #include <emx/io.h> 35 #include "socket.h" 4 36 5 int recv (int handle, void *buf, int len, unsignedflags)37 int recv(int socket, void *buf, int len, int flags) 6 38 { 7 return __recv (handle, buf, len, flags); 39 PLIBCSOCKETFH pFHSocket = __libsocket_FH(socket); 40 if (pFHSocket) 41 { 42 int rc; 43 rc = __libsocket_recv(pFHSocket->iSocket, buf, len, flags); 44 if (rc >= 0) 45 return rc; 46 __libsocket_setLibcErrno(); 47 } 48 49 return -1; 8 50 } 51 52 -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/libsocket/recvfrom.c
-
Property cvs2svn:cvs-rev
changed from
1.1
to1.2
r885 r886 1 /* recvfrom.c (emx+gcc) -- Copyright (c) 1994-1996 by Eberhard Mattes */ 1 /* $Id: $ */ 2 /** @file 3 * 4 * recvfrom(). 5 * 6 * Copyright (c) 2003 knut st. osmundsen <bird-srcspam@anduin.net> 7 * 8 * 9 * This file is part of Innotek LIBC. 10 * 11 * Innotek LIBC is free software; you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License as published 13 * by the Free Software Foundation; either version 2 of the License, or 14 * (at your option) any later version. 15 * 16 * Innotek LIBC is distributed in the hope that it will be useful, 17 * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 * GNU Lesser General Public License for more details. 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * along with Innotek LIBC; if not, write to the Free Software 23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 24 * 25 */ 2 26 3 #include <emx/syscalls.h> 27 /******************************************************************************* 28 * Header Files * 29 *******************************************************************************/ 30 #include "libc-alias.h" 31 #include <errno.h> 32 #include <sys/socket.h> 33 #include <sys/fcntl.h> 34 #include <emx/io.h> 35 #include "socket.h" 4 36 5 int recvfrom (int handle, void *buf, int len, unsigned flags, 6 struct sockaddr *from, int *pfromlen) 37 int recvfrom(int socket, void *buf, int len, int flags, struct sockaddr *from, int *fromlen) 7 38 { 8 struct _recvfrom args; 39 PLIBCSOCKETFH pFHSocket = __libsocket_FH(socket); 40 if (pFHSocket) 41 { 42 int rc; 43 rc = __libsocket_recvfrom(pFHSocket->iSocket, buf, len, flags, from, fromlen); 44 if (rc >= 0) 45 return rc; 46 __libsocket_setLibcErrno(); 47 } 9 48 10 args.handle = handle; 11 args.buf = buf; 12 args.len = len; 13 args.flags = flags; 14 args.from = from; 15 args.pfromlen = pfromlen; 16 return __recvfrom (&args); 49 return -1; 17 50 } 51 52 -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/libsocket/send.c
-
Property cvs2svn:cvs-rev
changed from
1.1
to1.2
r885 r886 1 /* send.c (emx+gcc) -- Copyright (c) 1994-1996 by Eberhard Mattes */ 1 /* $Id: $ */ 2 /** @file 3 * 4 * send(). 5 * 6 * Copyright (c) 2003 knut st. osmundsen <bird-srcspam@anduin.net> 7 * 8 * 9 * This file is part of Innotek LIBC. 10 * 11 * Innotek LIBC is free software; you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License as published 13 * by the Free Software Foundation; either version 2 of the License, or 14 * (at your option) any later version. 15 * 16 * Innotek LIBC is distributed in the hope that it will be useful, 17 * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 * GNU Lesser General Public License for more details. 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * along with Innotek LIBC; if not, write to the Free Software 23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 24 * 25 */ 2 26 3 #include <emx/syscalls.h> 27 /******************************************************************************* 28 * Header Files * 29 *******************************************************************************/ 30 #include "libc-alias.h" 31 #include <errno.h> 32 #include <sys/socket.h> 33 #include <sys/fcntl.h> 34 #include <emx/io.h> 35 #include "socket.h" 4 36 5 int send (int handle, const void *buf, int len, unsignedflags)37 int send(int socket, const void *buf, int len, int flags) 6 38 { 7 return __send (handle, buf, len, flags); 39 PLIBCSOCKETFH pFHSocket = __libsocket_FH(socket); 40 if (pFHSocket) 41 { 42 int rc; 43 rc = __libsocket_send(pFHSocket->iSocket, buf, len, flags); 44 if (rc >= 0) 45 return rc; 46 __libsocket_setLibcErrno(); 47 } 48 49 return -1; 8 50 } 51 52 -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/libsocket/sendto.c
-
Property cvs2svn:cvs-rev
changed from
1.1
to1.2
r885 r886 1 /* sendto.c (emx+gcc) -- Copyright (c) 1994-1996 by Eberhard Mattes */ 1 /* $Id: $ */ 2 /** @file 3 * 4 * sendto(). 5 * 6 * Copyright (c) 2003 knut st. osmundsen <bird-srcspam@anduin.net> 7 * 8 * 9 * This file is part of Innotek LIBC. 10 * 11 * Innotek LIBC is free software; you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License as published 13 * by the Free Software Foundation; either version 2 of the License, or 14 * (at your option) any later version. 15 * 16 * Innotek LIBC is distributed in the hope that it will be useful, 17 * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 * GNU Lesser General Public License for more details. 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * along with Innotek LIBC; if not, write to the Free Software 23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 24 * 25 */ 2 26 3 #include <emx/syscalls.h> 27 /******************************************************************************* 28 * Header Files * 29 *******************************************************************************/ 30 #include "libc-alias.h" 31 #include <errno.h> 32 #include <sys/socket.h> 33 #include <sys/fcntl.h> 34 #include <emx/io.h> 35 #include "socket.h" 4 36 5 int sendto (int handle, const void *buf, int len, unsigned flags, 6 const struct sockaddr *to, int tolen) 37 int sendto(int socket, const void *buf, int len, int flags, const struct sockaddr *to, int tolen) 7 38 { 8 struct _sendto args; 39 PLIBCSOCKETFH pFHSocket = __libsocket_FH(socket); 40 if (pFHSocket) 41 { 42 int rc; 43 rc = __libsocket_sendto(pFHSocket->iSocket, buf, len, flags, to, tolen); 44 if (rc >= 0) 45 return rc; 46 __libsocket_setLibcErrno(); 47 } 9 48 10 args.handle = handle; 11 args.buf = buf; 12 args.len = len; 13 args.flags = flags; 14 args.to = to; 15 args.tolen = tolen; 16 return __sendto (&args); 49 return -1; 17 50 } 51 -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/libsocket/shutdown.c
-
Property cvs2svn:cvs-rev
changed from
1.1
to1.2
r885 r886 1 /* shutdown.c (emx+gcc) -- Copyright (c) 1994-1996 by Eberhard Mattes */ 1 /* $Id: $ */ 2 /** @file 3 * 4 * shutdown(). 5 * 6 * Copyright (c) 2003 knut st. osmundsen <bird-srcspam@anduin.net> 7 * 8 * 9 * This file is part of Innotek LIBC. 10 * 11 * Innotek LIBC is free software; you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License as published 13 * by the Free Software Foundation; either version 2 of the License, or 14 * (at your option) any later version. 15 * 16 * Innotek LIBC is distributed in the hope that it will be useful, 17 * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 * GNU Lesser General Public License for more details. 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * along with Innotek LIBC; if not, write to the Free Software 23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 24 * 25 */ 2 26 3 #include <emx/syscalls.h> 27 /******************************************************************************* 28 * Header Files * 29 *******************************************************************************/ 30 #include "libc-alias.h" 31 #include <errno.h> 32 #include <sys/socket.h> 33 #include <sys/fcntl.h> 34 #include <emx/io.h> 35 #include "socket.h" 4 36 5 int shutdown (int handle, int how)37 int shutdown(int socket, int how) 6 38 { 7 return __shutdown (handle, how); 39 PLIBCSOCKETFH pFHSocket = __libsocket_FH(socket); 40 if (pFHSocket) 41 { 42 int rc; 43 rc = __libsocket_shutdown(pFHSocket->iSocket, how); 44 if (rc >= 0) 45 return rc; 46 __libsocket_setLibcErrno(); 47 } 48 49 return -1; 8 50 } 51 52 -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/libsocket/sock_errno.c
-
Property cvs2svn:cvs-rev
changed from
1.2
to1.3
r885 r886 10 10 */ 11 11 12 #include <sys/types.h> 12 /******************************************************************************* 13 * Header Files * 14 *******************************************************************************/ 15 #include "libc-alias.h" 16 #include <errno.h> 13 17 #include <sys/socket.h> 18 #include <sys/fcntl.h> 19 #include <emx/io.h> 20 #include "socket.h" 21 14 22 15 23 /** … … 24 32 /* get the OS/2 error. */ 25 33 int err = os2_sock_errno(); 26 if (err > 10000 && err < 11000)27 err -= 10000;34 if (err > EOS2_TCPIP_OFFSET && err < EOS2_TCPIP_OFFSET + 1000) 35 err -= EOS2_TCPIP_OFFSET; 28 36 return err; 29 37 } -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/libsocket/socket.c
-
Property cvs2svn:cvs-rev
changed from
1.1
to1.2
r885 r886 1 /* socket.c (emx+gcc) -- Copyright (c) 1994-1996 by Eberhard Mattes */ 1 /* $Id: $ */ 2 /** @file 3 * 4 * socket(). 5 * 6 * Copyright (c) 2003 knut st. osmundsen <bird-srcspam@anduin.net> 7 * 8 * 9 * This file is part of Innotek LIBC. 10 * 11 * Innotek LIBC is free software; you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License as published 13 * by the Free Software Foundation; either version 2 of the License, or 14 * (at your option) any later version. 15 * 16 * Innotek LIBC is distributed in the hope that it will be useful, 17 * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 * GNU Lesser General Public License for more details. 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * along with Innotek LIBC; if not, write to the Free Software 23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 24 * 25 */ 2 26 27 /******************************************************************************* 28 * Header Files * 29 *******************************************************************************/ 30 #include "libc-alias.h" 31 #include <errno.h> 32 #include <sys/socket.h> 3 33 #include <sys/fcntl.h> 4 #include <errno.h>5 34 #include <emx/io.h> 6 #include <emx/syscalls.h>35 #include "socket.h" 7 36 8 int socket (int domain, int type, int protocol) 37 38 int socket(int af, int type, int protocol) 9 39 { 10 int s, *pflags;40 int s; 11 41 12 s = __socket (domain, type, protocol); 13 if (s < 0) 42 s = __libsocket_socket(af, type, protocol); 43 if (s >= 0) 44 { 45 int rc; 46 int fh; 47 PLIBCSOCKETFH pFH; 48 rc = __libc_FHAllocate(-1, O_RDWR | F_SOCKET, sizeof(LIBCSOCKETFH), &__libsocket_gSocketOps, (PLIBCFH*)&pFH, &fh); 49 if (!rc) 50 { 51 pFH->iSocket = s; 52 return fh; 53 } 54 else 55 __libsocket_soclose(s); 56 __libsocket_setSocketErrno(); 57 } 58 else 59 __libsocket_setLibcErrno(); 60 14 61 return -1; 15 if ((pflags = _fd_init (s)) == NULL)16 {17 __close (s);18 errno = EMFILE;19 return -1;20 }21 *pflags = O_RDWR | F_SOCKET;22 return s;23 62 } 63 -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/libsocket/socket.imp
-
Property cvs2svn:cvs-rev
changed from
1.5
to1.6
r885 r886 5 5 ; 6 6 ; -------- tcpip32.lib -------- 7 accept tcpip32 1 ? 8 _accept tcpip32 1 ? 9 bind tcpip32 2 ? 10 _bind tcpip32 2 ? 11 connect tcpip32 3 ? 12 _connect tcpip32 3 ? 7 __libsocket_accept tcpip32 1 ? 8 __libsocket_bind tcpip32 2 ? 9 __libsocket_connect tcpip32 3 ? 13 10 gethostid tcpip32 4 ? 14 11 _gethostid tcpip32 4 ? 15 getpeername tcpip32 5 ? 16 _getpeername tcpip32 5 ? 17 getsockname tcpip32 6 ? 18 _getsockname tcpip32 6 ? 19 getsockopt tcpip32 7 ? 20 _getsockopt tcpip32 7 ? 21 so_ioctl tcpip32 8 ? 22 _so_ioctl tcpip32 8 ? 23 listen tcpip32 9 ? 24 _listen tcpip32 9 ? 25 recv tcpip32 10 ? 26 _recv tcpip32 10 ? 27 recvfrom tcpip32 11 ? 28 _recvfrom tcpip32 11 ? 29 os2_select tcpip32 12 ? 30 _os2_select tcpip32 12 ? 31 send tcpip32 13 ? 32 _send tcpip32 13 ? 33 sendto tcpip32 14 ? 34 _sendto tcpip32 14 ? 35 setsockopt tcpip32 15 ? 36 _setsockopt tcpip32 15 ? 37 socket tcpip32 16 ? 38 _socket tcpip32 16 ? 39 soclose tcpip32 17 ? 40 _soclose tcpip32 17 ? 41 so_cancel tcpip32 18 ? 42 _so_cancel tcpip32 18 ? 43 soabort tcpip32 19 ? 44 _soabort tcpip32 19 ? 12 __libsocket_getpeername tcpip32 5 ? 13 __libsocket_getsockname tcpip32 6 ? 14 __libsocket_getsockopt tcpip32 7 ? 15 __libsocket_ioctl tcpip32 8 ? 16 __libsocket_listen tcpip32 9 ? 17 __libsocket_recv tcpip32 10 ? 18 __libsocket_recvfrom tcpip32 11 ? 19 __libsocket_os2_select tcpip32 12 ? 20 __libsocket_send tcpip32 13 ? 21 __libsocket_sendto tcpip32 14 ? 22 __libsocket_setsockopt tcpip32 15 ? 23 __libsocket_socket tcpip32 16 ? 24 __libsocket_soclose tcpip32 17 ? 25 __libsocket_so_cancel tcpip32 18 ? 26 __libsocket_soabort tcpip32 19 ? 45 27 os2_sock_errno tcpip32 20 ? 46 _os2_sock_errno tcpip32 20 ? 47 recvmsg tcpip32 21 ? 48 _recvmsg tcpip32 21 ? 49 sendmsg tcpip32 22 ? 50 _sendmsg tcpip32 22 ? 51 so_readv tcpip32 23 ? 52 _so_readv tcpip32 23 ? 53 so_writev tcpip32 24 ? 54 _so_writev tcpip32 24 ? 55 shutdown tcpip32 25 ? 56 _shutdown tcpip32 25 ? 28 _os2_sock_errno tcpip32 20 ? 29 __libsocket_recvmsg tcpip32 21 ? 30 __libsocket_sendmsg tcpip32 22 ? 31 __libsocket_so_readv tcpip32 23 ? 32 __libsocket_so_writev tcpip32 24 ? 33 __libsocket_shutdown tcpip32 25 ? 57 34 sock_init tcpip32 26 ? 58 35 _sock_init tcpip32 26 ? … … 67 44 getinetversion tcpip32 31 ? 68 45 _getinetversion tcpip32 31 ? 69 v5_bsdselect tcpip32 32 ? 70 set_errno tcpip32 35 ? 71 _set_errno tcpip32 35 ? 46 __libsocket_bsdselect tcpip32 32 ? 47 __libsocket_set_errno tcpip32 35 ? 72 48 winsockcleanupsockets tcpip32 38 ? 73 49 _winsockcleanupsockets tcpip32 38 ? … … 174 150 Rgethostbyname tcpip32 161 ? 175 151 _Rgethostbyname tcpip32 161 ? 176 os2_ioctl tcpip32 200 ? 177 _os2_ioctl tcpip32 200 ? 152 __libsocket_os2_ioctl tcpip32 200 ? 178 153 __TCPFDIsSet tcpip32 201 ? 179 154 ___TCPFDIsSet tcpip32 201 ? … … 282 257 inet_nsap_ntoa tcpip32 253 ? 283 258 _inet_nsap_ntoa tcpip32 253 ? 284 socketpair tcpip32 254 ? 285 _socketpair tcpip32 254 ? 259 __libsocket_socketpair tcpip32 254 ? 286 260 sock_strerror tcpip32 255 ? 287 261 _sock_strerror tcpip32 255 ? -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/libsocket/socket.smak
-
Property cvs2svn:cvs-rev
changed from
1.10
to1.11
r885 r886 3 3 .MODULE := libsocket 4 4 .MDESC := The socket library 5 _MDIRS := $.aout/tcpipv4 $.aout-prof/tcpipv4 $.aout/dep-tcpipv4 $.aout-prof/dep-tcpipv4 6 .MDEP := emxomf emximp $(_MDIRS) 7 TARGDIRS += $(_MDIRS) 5 #_MDIRS := $.aout/tcpipv4 $.aout-prof/tcpipv4 $.aout/dep-tcpipv4 $.aout-prof/dep-tcpipv4 6 .MDEP := emxomf emximp 7 #$(_MDIRS) 8 #TARGDIRS += $(_MDIRS) 8 9 9 10 .TARGET := libsocket_p.a 10 11 .TKIND := aout prof 11 .TSRC := $(wildcard src/lib/socket/386/*.s) 12 .TSRC += src/lib/socket/sock_errno.c src/lib/socket/bsdselect.c 12 .TSRC := $(wildcard src/lib/socket/386/*.s) \ 13 $(filter-out src/lib/socket/aliases/herror%, $(wildcard src/lib/socket/aliases/*.s)) \ 14 $(filter-out src/lib/socket/herror%, $(wildcard src/lib/socket/*.c)) 15 .TCF := -I$. 13 16 .IMPS := src/lib/socket/socket.imp 14 17 .INSDIR := lib/ … … 18 21 .TARGET := libsocket.a 19 22 .TKIND := aout 20 .TSRC := $(wildcard src/lib/socket/386/*.s)21 .TSRC += src/lib/socket/sock_errno.c src/lib/socket/bsdselect.c22 .IMPS := src/lib/socket/socket.imp23 .INSDIR := lib/24 23 .TKEEP := 1 25 24 include mkimplib.smak 26 25 27 26 28 .TARGET := tcpipv4/libsocket_p.a27 .TARGET := libsocket_p.a 29 28 .TKIND := aout prof 30 .TSRC := $(wildcard src/lib/socket/386/*.s) 31 .TSRC += src/lib/socket/herror.c src/lib/socket/sock_errno.c src/lib/socket/socketpair.c 32 .TSRC += src/lib/socket/socketpair-alias.s 29 .TKVAR := tcpipv4 30 .TSRC := $(wildcard src/lib/socket/386/*.s) $(wildcard src/lib/socket/aliases/*.s) \ 31 $(wildcard src/lib/socket/*.c) 32 .TCF := -I$. -DTCPV40HDRS 33 33 .IMPS := src/lib/socket/socket_tcpipv4.imp 34 .INSDIR := lib/ 34 .INSDIR := lib/tcpipv4 35 35 .TKEEP := 1 36 36 include mkimplib.smak 37 37 38 .TARGET := tcpipv4/libsocket.a38 .TARGET := libsocket.a 39 39 .TKIND := aout 40 .TSRC := $(wildcard src/lib/socket/386/*.s)41 .TSRC += src/lib/socket/herror.c src/lib/socket/sock_errno.c src/lib/socket/socketpair.c42 .TSRC += src/lib/socket/socketpair-alias.s43 .IMPS := src/lib/socket/socket_tcpipv4.imp44 .TKEEP := 145 40 include mkimplib.smak 46 47 #$.omf/tcpipv4 omf-prof/tcpipv448 41 49 42 -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/libsocket/socket_tcpipv4.imp
-
Property cvs2svn:cvs-rev
changed from
1.4
to1.5
r885 r886 5 5 ; 6 6 ; -------- so32dll.lib -------- 7 accept so32dll 1 ? 8 _accept so32dll 1 ? 9 bind so32dll 2 ? 10 _bind so32dll 2 ? 11 connect so32dll 3 ? 12 _connect so32dll 3 ? 7 __libsocket_accept so32dll 1 ? 8 __libsocket_bind so32dll 2 ? 9 __libsocket_connect so32dll 3 ? 13 10 gethostid so32dll 4 ? 14 11 _gethostid so32dll 4 ? 15 getpeername so32dll 5 ? 16 _getpeername so32dll 5 ? 17 getsockname so32dll 6 ? 18 _getsockname so32dll 6 ? 19 getsockopt so32dll 7 ? 20 _getsockopt so32dll 7 ? 21 os2_ioctl so32dll 8 ? 22 _os2_ioctl so32dll 8 ? 23 listen so32dll 9 ? 24 _listen so32dll 9 ? 25 recv so32dll 10 ? 26 _recv so32dll 10 ? 27 recvfrom so32dll 11 ? 28 _recvfrom so32dll 11 ? 29 os2_select so32dll 12 ? 30 _os2_select so32dll 12 ? 31 send so32dll 13 ? 32 _send so32dll 13 ? 33 sendto so32dll 14 ? 34 _sendto so32dll 14 ? 35 setsockopt so32dll 15 ? 36 _setsockopt so32dll 15 ? 37 socket so32dll 16 ? 38 _socket so32dll 16 ? 39 soclose so32dll 17 ? 40 _soclose so32dll 17 ? 41 so_cancel so32dll 18 ? 42 _so_cancel so32dll 18 ? 43 soabort so32dll 19 ? 44 _soabort so32dll 19 ? 12 __libsocket_getpeername so32dll 5 ? 13 __libsocket_getsockname so32dll 6 ? 14 __libsocket_getsockopt so32dll 7 ? 15 __libsocket_os2_ioctl so32dll 8 ? 16 __libsocket_listen so32dll 9 ? 17 __libsocket_recv so32dll 10 ? 18 __libsocket_recvfrom so32dll 11 ? 19 __libsocket_os2_select so32dll 12 ? 20 __libsocket_send so32dll 13 ? 21 __libsocket_sendto so32dll 14 ? 22 __libsocket_setsockopt so32dll 15 ? 23 __libsocket_socket so32dll 16 ? 24 __libsocket_soclose so32dll 17 ? 25 __libsocket_so_cancel so32dll 18 ? 26 __libsocket_soabort so32dll 19 ? 45 27 os2_sock_errno so32dll 20 ? 46 28 _os2_sock_errno so32dll 20 ? 47 recvmsg so32dll 21 ? 48 _recvmsg so32dll 21 ? 49 sendmsg so32dll 22 ? 50 _sendmsg so32dll 22 ? 51 so_readv so32dll 23 ? 52 _so_readv so32dll 23 ? 53 so_writev so32dll 24 ? 54 _so_writev so32dll 24 ? 55 shutdown so32dll 25 ? 56 _shutdown so32dll 25 ? 29 __libsocket_recvmsg so32dll 21 ? 30 __libsocket_sendmsg so32dll 22 ? 31 __libsocket_so_readv so32dll 23 ? 32 __libsocket_so_writev so32dll 24 ? 33 __libsocket_shutdown so32dll 25 ? 57 34 sock_init so32dll 26 ? 58 35 _sock_init so32dll 26 ? … … 65 42 getinetversion so32dll 31 ? 66 43 _getinetversion so32dll 31 ? 67 bsdselect so32dll 32 ? 68 _bsdselect so32dll 32 ? 69 set_errno so32dll 35 ? 70 _set_errno so32dll 35 ? 44 __libsocket_bsdselect so32dll 32 ? 45 __libsocket_set_errno so32dll 35 ? 71 46 getsocketfromlist so32dll 39 ? 72 47 _getsocketfromlist so32dll 39 ? -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/libsocket/socketpair.c
-
Property cvs2svn:cvs-rev
changed from
1.1
to1.2
r885 r886 12 12 */ 13 13 14 #define TCPV40HDRS 14 15 /******************************************************************************* 16 * Header Files * 17 *******************************************************************************/ 18 #include "libc-alias.h" 15 19 #include <sys/types.h> 16 20 #include <sys/time.h> … … 20 24 #include <stdio.h> 21 25 #include <string.h> 26 #include <errno.h> 27 #include <sys/socket.h> 28 #include <sys/fcntl.h> 29 #include <emx/io.h> 30 #include "socket.h" 22 31 23 32 … … 35 44 int TCPCALL socketpair(int af, int type, int flags, int *osfd) 36 45 { 46 #ifdef TCPV40HDRS 37 47 int rc; 38 48 int sock1 = -1; … … 106 116 soclose(sock2); 107 117 return -1; 118 119 #else 120 int rc; 121 int fh1; 122 int fh2; 123 PLIBCSOCKETFH pFH; 124 125 rc = __libsocket_pair(af, type, flags, osfd); 126 if (rc < 0) 127 { 128 __libsocket_setLibcErrno(); 129 return -1; 130 } 131 132 /* 133 * Allocate LIBC sockets. 134 */ 135 rc = __libc_FHAllocate(-1, O_RDWR | F_SOCKET, sizeof(LIBCSOCKETFH), &__libsocket_gSocketOps, (PLIBCFH*)&pFH, &fh1); 136 if (!rc) 137 { 138 pFH->iSocket = osfd[0]; 139 rc = __libc_FHAllocate(-1, O_RDWR | F_SOCKET, sizeof(LIBCSOCKETFH), &__libsocket_gSocketOps, (PLIBCFH*)&pFH, &fh2); 140 if (!rc) 141 { 142 pFH->iSocket = osfd[1]; 143 osfd[0] = fh1; 144 osfd[1] = fh2; 145 return 0; 146 } 147 __libc_FHClose(fh1); 148 } 149 150 __libsocket_soclose(osfd[0]); 151 __libsocket_soclose(osfd[1]); 152 return -1; 153 #endif 108 154 } 109 155 -
Property cvs2svn:cvs-rev
changed from
Note:
See TracChangeset
for help on using the changeset viewer.