Changeset 886


Ignore:
Timestamp:
Dec 8, 2003, 6:45:15 AM (22 years ago)
Author:
bird
Message:

Initial recoding of the socket handle space.

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 to 1.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 */
    226
     27/*******************************************************************************
     28*   Header Files                                                               *
     29*******************************************************************************/
     30#include "libc-alias.h"
     31#include <errno.h>
     32#include <sys/socket.h>
    333#include <sys/fcntl.h>
    4 #include <errno.h>
    534#include <emx/io.h>
    6 #include <emx/syscalls.h>
     35#include "socket.h"
    736
    8 int accept (int handle, struct sockaddr *addr, int *paddrlen)
     37int accept(int socket, struct sockaddr *addr, int *addrlen)
    938{
    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    }
    1162
    12   s = __accept (handle, addr, paddrlen);
    13   if (s < 0)
    1463    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;
    2364}
     65
  • trunk/src/emx/src/lib/socket/bind.c

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.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 */
    226
    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"
    436
    5 int bind (int handle, struct sockaddr *addr, int addrlen)
     37int bind(int socket, const struct sockaddr *addr, int addrlen)
    638{
    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;
    850}
     51
  • trunk/src/emx/src/lib/socket/bsdselect.c

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.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 */
     64static 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 */
     90static 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)
    3994    for (i = 0; i < c; i++)
    4095    {
    4196        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}
    47106
    48107/**
    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 */
     115static 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
     134int 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;
    62152    if (readfds)
    63153    {
    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;
    68166    if (writefds)
    69167    {
    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);
    81228
    82229    return rc;
     
    84231
    85232
     233
  • trunk/src/emx/src/lib/socket/connect.c

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.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 */
    226
    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"
    436
    5 int connect (int handle, struct sockaddr *addr, int addrlen)
     37int connect(int socket, const struct sockaddr *addr, int addrlen)
    638{
    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;
    850}
     51
  • trunk/src/emx/src/lib/socket/herror.c

    • Property cvs2svn:cvs-rev changed from 1.2 to 1.3
    r885 r886  
    11/* herror.c (emx+gcc) -- Copyright (c) 1994 by Eberhard Mattes */
    22
    3 #define TCPV40HDRS
     3#ifndef TCPV40HDRS
     4#error TCPV40HDRS only
     5#endif
     6
     7#include "libc-alias.h"
    48#include <stdio.h>
    59#include <sys/types.h>
     
    812extern int h_errno;
    913
    10 void herror (const char *string)
     14void TCPCALL herror(const char *string)
    1115{
    1216  int e = h_errno;
  • trunk/src/emx/src/lib/socket/listen.c

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.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 */
    226
    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"
    436
    5 int listen (int handle, int backlog)
     37int listen(int socket, int backlog)
    638{
    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;
    850}
     51
     52
  • trunk/src/emx/src/lib/socket/recv.c

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.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 */
    226
    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"
    436
    5 int recv (int handle, void *buf, int len, unsigned flags)
     37int recv(int socket, void *buf, int len, int flags)
    638{
    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;
    850}
     51
     52
  • trunk/src/emx/src/lib/socket/recvfrom.c

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.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 */
    226
    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"
    436
    5 int recvfrom (int handle, void *buf, int len, unsigned flags,
    6               struct sockaddr *from, int *pfromlen)
     37int recvfrom(int socket, void *buf, int len, int flags, struct sockaddr *from, int *fromlen)
    738{
    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    }
    948
    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;
    1750}
     51
     52
  • trunk/src/emx/src/lib/socket/send.c

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.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 */
    226
    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"
    436
    5 int send (int handle, const void *buf, int len, unsigned flags)
     37int send(int socket, const void *buf, int len, int flags)
    638{
    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;
    850}
     51
     52
  • trunk/src/emx/src/lib/socket/sendto.c

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.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 */
    226
    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"
    436
    5 int sendto (int handle, const void *buf, int len, unsigned flags,
    6             const struct sockaddr *to, int tolen)
     37int sendto(int socket, const void *buf, int len, int flags, const struct sockaddr *to, int tolen)
    738{
    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    }
    948
    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;
    1750}
     51
  • trunk/src/emx/src/lib/socket/shutdown.c

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.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 */
    226
    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"
    436
    5 int shutdown (int handle, int how)
     37int shutdown(int socket, int how)
    638{
    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;
    850}
     51
     52
  • trunk/src/emx/src/lib/socket/sock_errno.c

    • Property cvs2svn:cvs-rev changed from 1.2 to 1.3
    r885 r886  
    1010 */
    1111
    12 #include <sys/types.h>
     12/*******************************************************************************
     13*   Header Files                                                               *
     14*******************************************************************************/
     15#include "libc-alias.h"
     16#include <errno.h>
    1317#include <sys/socket.h>
     18#include <sys/fcntl.h>
     19#include <emx/io.h>
     20#include "socket.h"
     21
    1422
    1523/**
     
    2432    /* get the OS/2 error. */
    2533    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;
    2836    return err;
    2937}
  • trunk/src/emx/src/lib/socket/socket.c

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.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 */
    226
     27/*******************************************************************************
     28*   Header Files                                                               *
     29*******************************************************************************/
     30#include "libc-alias.h"
     31#include <errno.h>
     32#include <sys/socket.h>
    333#include <sys/fcntl.h>
    4 #include <errno.h>
    534#include <emx/io.h>
    6 #include <emx/syscalls.h>
     35#include "socket.h"
    736
    8 int socket (int domain, int type, int protocol)
     37
     38int socket(int af, int type, int protocol)
    939{
    10   int s, *pflags;
     40    int s;
    1141
    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
    1461    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;
    2362}
     63
  • trunk/src/emx/src/lib/socket/socket.imp

    • Property cvs2svn:cvs-rev changed from 1.5 to 1.6
    r885 r886  
    55;
    66; -------- 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 ?
    1310gethostid               tcpip32    4 ?
    1411_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 ?
    4527os2_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 ?
    5734sock_init               tcpip32   26 ?
    5835_sock_init              tcpip32   26 ?
     
    6744getinetversion          tcpip32   31 ?
    6845_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 ?
    7248winsockcleanupsockets   tcpip32   38 ?
    7349_winsockcleanupsockets  tcpip32   38 ?
     
    174150Rgethostbyname          tcpip32  161 ?
    175151_Rgethostbyname         tcpip32  161 ?
    176 os2_ioctl               tcpip32  200 ?
    177 _os2_ioctl              tcpip32  200 ?
     152__libsocket_os2_ioctl   tcpip32  200 ?
    178153__TCPFDIsSet            tcpip32  201 ?
    179154___TCPFDIsSet           tcpip32  201 ?
     
    282257inet_nsap_ntoa          tcpip32  253 ?
    283258_inet_nsap_ntoa         tcpip32  253 ?
    284 socketpair              tcpip32  254 ?
    285 _socketpair             tcpip32  254 ?
     259__libsocket_socketpair  tcpip32  254 ?
    286260sock_strerror           tcpip32  255 ?
    287261_sock_strerror          tcpip32  255 ?
  • trunk/src/emx/src/lib/socket/socket.smak

    • Property cvs2svn:cvs-rev changed from 1.10 to 1.11
    r885 r886  
    33.MODULE := libsocket
    44.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)
    89
    910.TARGET := libsocket_p.a
    1011.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$.
    1316.IMPS   := src/lib/socket/socket.imp
    1417.INSDIR := lib/
     
    1821.TARGET := libsocket.a
    1922.TKIND  := aout
    20 .TSRC   := $(wildcard src/lib/socket/386/*.s)
    21 .TSRC   += src/lib/socket/sock_errno.c src/lib/socket/bsdselect.c
    22 .IMPS   := src/lib/socket/socket.imp
    23 .INSDIR := lib/
    2423.TKEEP  := 1
    2524include mkimplib.smak
    2625
    2726       
    28 .TARGET := tcpipv4/libsocket_p.a
     27.TARGET := libsocket_p.a
    2928.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
    3333.IMPS   := src/lib/socket/socket_tcpipv4.imp
    34 .INSDIR := lib/
     34.INSDIR := lib/tcpipv4
    3535.TKEEP  := 1
    3636include mkimplib.smak
    3737
    38 .TARGET := tcpipv4/libsocket.a
     38.TARGET := libsocket.a
    3939.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.c
    42 .TSRC   += src/lib/socket/socketpair-alias.s
    43 .IMPS   := src/lib/socket/socket_tcpipv4.imp
    44 .TKEEP  := 1
    4540include mkimplib.smak
    46 
    47 #$.omf/tcpipv4 omf-prof/tcpipv4
    4841
    4942
  • trunk/src/emx/src/lib/socket/socket_tcpipv4.imp

    • Property cvs2svn:cvs-rev changed from 1.4 to 1.5
    r885 r886  
    55;
    66; -------- 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 ?
    1310gethostid               so32dll    4 ?
    1411_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 ?
    4527os2_sock_errno          so32dll   20 ?
    4628_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 ?
    5734sock_init               so32dll   26 ?
    5835_sock_init              so32dll   26 ?
     
    6542getinetversion          so32dll   31 ?
    6643_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 ?
    7146getsocketfromlist       so32dll   39 ?
    7247_getsocketfromlist      so32dll   39 ?
  • trunk/src/emx/src/lib/socket/socketpair.c

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.2
    r885 r886  
    1212 */
    1313
    14 #define TCPV40HDRS
     14
     15/*******************************************************************************
     16*   Header Files                                                               *
     17*******************************************************************************/
     18#include "libc-alias.h"
    1519#include <sys/types.h>
    1620#include <sys/time.h>
     
    2024#include <stdio.h>
    2125#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"
    2231
    2332
     
    3544int     TCPCALL socketpair(int af, int type, int flags, int *osfd)
    3645{
     46#ifdef TCPV40HDRS
    3747    int     rc;
    3848    int     sock1 = -1;
     
    106116        soclose(sock2);
    107117    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
    108154}
    109155
  • trunk/src/emx/src/libsocket/accept.c

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.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 */
    226
     27/*******************************************************************************
     28*   Header Files                                                               *
     29*******************************************************************************/
     30#include "libc-alias.h"
     31#include <errno.h>
     32#include <sys/socket.h>
    333#include <sys/fcntl.h>
    4 #include <errno.h>
    534#include <emx/io.h>
    6 #include <emx/syscalls.h>
     35#include "socket.h"
    736
    8 int accept (int handle, struct sockaddr *addr, int *paddrlen)
     37int accept(int socket, struct sockaddr *addr, int *addrlen)
    938{
    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    }
    1162
    12   s = __accept (handle, addr, paddrlen);
    13   if (s < 0)
    1463    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;
    2364}
     65
  • trunk/src/emx/src/libsocket/bind.c

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.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 */
    226
    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"
    436
    5 int bind (int handle, struct sockaddr *addr, int addrlen)
     37int bind(int socket, const struct sockaddr *addr, int addrlen)
    638{
    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;
    850}
     51
  • trunk/src/emx/src/libsocket/bsdselect.c

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.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 */
     64static 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 */
     90static 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)
    3994    for (i = 0; i < c; i++)
    4095    {
    4196        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}
    47106
    48107/**
    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 */
     115static 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
     134int 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;
    62152    if (readfds)
    63153    {
    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;
    68166    if (writefds)
    69167    {
    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);
    81228
    82229    return rc;
     
    84231
    85232
     233
  • trunk/src/emx/src/libsocket/connect.c

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.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 */
    226
    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"
    436
    5 int connect (int handle, struct sockaddr *addr, int addrlen)
     37int connect(int socket, const struct sockaddr *addr, int addrlen)
    638{
    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;
    850}
     51
  • trunk/src/emx/src/libsocket/herror.c

    • Property cvs2svn:cvs-rev changed from 1.2 to 1.3
    r885 r886  
    11/* herror.c (emx+gcc) -- Copyright (c) 1994 by Eberhard Mattes */
    22
    3 #define TCPV40HDRS
     3#ifndef TCPV40HDRS
     4#error TCPV40HDRS only
     5#endif
     6
     7#include "libc-alias.h"
    48#include <stdio.h>
    59#include <sys/types.h>
     
    812extern int h_errno;
    913
    10 void herror (const char *string)
     14void TCPCALL herror(const char *string)
    1115{
    1216  int e = h_errno;
  • trunk/src/emx/src/libsocket/listen.c

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.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 */
    226
    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"
    436
    5 int listen (int handle, int backlog)
     37int listen(int socket, int backlog)
    638{
    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;
    850}
     51
     52
  • trunk/src/emx/src/libsocket/recv.c

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.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 */
    226
    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"
    436
    5 int recv (int handle, void *buf, int len, unsigned flags)
     37int recv(int socket, void *buf, int len, int flags)
    638{
    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;
    850}
     51
     52
  • trunk/src/emx/src/libsocket/recvfrom.c

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.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 */
    226
    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"
    436
    5 int recvfrom (int handle, void *buf, int len, unsigned flags,
    6               struct sockaddr *from, int *pfromlen)
     37int recvfrom(int socket, void *buf, int len, int flags, struct sockaddr *from, int *fromlen)
    738{
    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    }
    948
    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;
    1750}
     51
     52
  • trunk/src/emx/src/libsocket/send.c

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.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 */
    226
    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"
    436
    5 int send (int handle, const void *buf, int len, unsigned flags)
     37int send(int socket, const void *buf, int len, int flags)
    638{
    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;
    850}
     51
     52
  • trunk/src/emx/src/libsocket/sendto.c

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.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 */
    226
    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"
    436
    5 int sendto (int handle, const void *buf, int len, unsigned flags,
    6             const struct sockaddr *to, int tolen)
     37int sendto(int socket, const void *buf, int len, int flags, const struct sockaddr *to, int tolen)
    738{
    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    }
    948
    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;
    1750}
     51
  • trunk/src/emx/src/libsocket/shutdown.c

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.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 */
    226
    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"
    436
    5 int shutdown (int handle, int how)
     37int shutdown(int socket, int how)
    638{
    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;
    850}
     51
     52
  • trunk/src/emx/src/libsocket/sock_errno.c

    • Property cvs2svn:cvs-rev changed from 1.2 to 1.3
    r885 r886  
    1010 */
    1111
    12 #include <sys/types.h>
     12/*******************************************************************************
     13*   Header Files                                                               *
     14*******************************************************************************/
     15#include "libc-alias.h"
     16#include <errno.h>
    1317#include <sys/socket.h>
     18#include <sys/fcntl.h>
     19#include <emx/io.h>
     20#include "socket.h"
     21
    1422
    1523/**
     
    2432    /* get the OS/2 error. */
    2533    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;
    2836    return err;
    2937}
  • trunk/src/emx/src/libsocket/socket.c

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.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 */
    226
     27/*******************************************************************************
     28*   Header Files                                                               *
     29*******************************************************************************/
     30#include "libc-alias.h"
     31#include <errno.h>
     32#include <sys/socket.h>
    333#include <sys/fcntl.h>
    4 #include <errno.h>
    534#include <emx/io.h>
    6 #include <emx/syscalls.h>
     35#include "socket.h"
    736
    8 int socket (int domain, int type, int protocol)
     37
     38int socket(int af, int type, int protocol)
    939{
    10   int s, *pflags;
     40    int s;
    1141
    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
    1461    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;
    2362}
     63
  • trunk/src/emx/src/libsocket/socket.imp

    • Property cvs2svn:cvs-rev changed from 1.5 to 1.6
    r885 r886  
    55;
    66; -------- 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 ?
    1310gethostid               tcpip32    4 ?
    1411_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 ?
    4527os2_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 ?
    5734sock_init               tcpip32   26 ?
    5835_sock_init              tcpip32   26 ?
     
    6744getinetversion          tcpip32   31 ?
    6845_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 ?
    7248winsockcleanupsockets   tcpip32   38 ?
    7349_winsockcleanupsockets  tcpip32   38 ?
     
    174150Rgethostbyname          tcpip32  161 ?
    175151_Rgethostbyname         tcpip32  161 ?
    176 os2_ioctl               tcpip32  200 ?
    177 _os2_ioctl              tcpip32  200 ?
     152__libsocket_os2_ioctl   tcpip32  200 ?
    178153__TCPFDIsSet            tcpip32  201 ?
    179154___TCPFDIsSet           tcpip32  201 ?
     
    282257inet_nsap_ntoa          tcpip32  253 ?
    283258_inet_nsap_ntoa         tcpip32  253 ?
    284 socketpair              tcpip32  254 ?
    285 _socketpair             tcpip32  254 ?
     259__libsocket_socketpair  tcpip32  254 ?
    286260sock_strerror           tcpip32  255 ?
    287261_sock_strerror          tcpip32  255 ?
  • trunk/src/emx/src/libsocket/socket.smak

    • Property cvs2svn:cvs-rev changed from 1.10 to 1.11
    r885 r886  
    33.MODULE := libsocket
    44.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)
    89
    910.TARGET := libsocket_p.a
    1011.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$.
    1316.IMPS   := src/lib/socket/socket.imp
    1417.INSDIR := lib/
     
    1821.TARGET := libsocket.a
    1922.TKIND  := aout
    20 .TSRC   := $(wildcard src/lib/socket/386/*.s)
    21 .TSRC   += src/lib/socket/sock_errno.c src/lib/socket/bsdselect.c
    22 .IMPS   := src/lib/socket/socket.imp
    23 .INSDIR := lib/
    2423.TKEEP  := 1
    2524include mkimplib.smak
    2625
    2726       
    28 .TARGET := tcpipv4/libsocket_p.a
     27.TARGET := libsocket_p.a
    2928.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
    3333.IMPS   := src/lib/socket/socket_tcpipv4.imp
    34 .INSDIR := lib/
     34.INSDIR := lib/tcpipv4
    3535.TKEEP  := 1
    3636include mkimplib.smak
    3737
    38 .TARGET := tcpipv4/libsocket.a
     38.TARGET := libsocket.a
    3939.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.c
    42 .TSRC   += src/lib/socket/socketpair-alias.s
    43 .IMPS   := src/lib/socket/socket_tcpipv4.imp
    44 .TKEEP  := 1
    4540include mkimplib.smak
    46 
    47 #$.omf/tcpipv4 omf-prof/tcpipv4
    4841
    4942
  • trunk/src/emx/src/libsocket/socket_tcpipv4.imp

    • Property cvs2svn:cvs-rev changed from 1.4 to 1.5
    r885 r886  
    55;
    66; -------- 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 ?
    1310gethostid               so32dll    4 ?
    1411_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 ?
    4527os2_sock_errno          so32dll   20 ?
    4628_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 ?
    5734sock_init               so32dll   26 ?
    5835_sock_init              so32dll   26 ?
     
    6542getinetversion          so32dll   31 ?
    6643_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 ?
    7146getsocketfromlist       so32dll   39 ?
    7247_getsocketfromlist      so32dll   39 ?
  • trunk/src/emx/src/libsocket/socketpair.c

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.2
    r885 r886  
    1212 */
    1313
    14 #define TCPV40HDRS
     14
     15/*******************************************************************************
     16*   Header Files                                                               *
     17*******************************************************************************/
     18#include "libc-alias.h"
    1519#include <sys/types.h>
    1620#include <sys/time.h>
     
    2024#include <stdio.h>
    2125#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"
    2231
    2332
     
    3544int     TCPCALL socketpair(int af, int type, int flags, int *osfd)
    3645{
     46#ifdef TCPV40HDRS
    3747    int     rc;
    3848    int     sock1 = -1;
     
    106116        soclose(sock2);
    107117    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
    108154}
    109155
Note: See TracChangeset for help on using the changeset viewer.