Main Page Modules Class Hierarchy Data Structures File List Data Fields Globals Related Pages

# osclconfig_io.h File Reference

This file contains common typedefs based on the ANSI C limits.h header. More...

`#include "osclconfig.h"`
`#include <stdio.h>`
`#include <stdlib.h>`
`#include <stdarg.h>`
`#include <sys/socket.h>`
`#include <netinet/in.h>`
`#include <arpa/inet.h>`
`#include <fcntl.h>`
`#include <signal.h>`
`#include <netdb.h>`
`#include <sys/mman.h>`
`#include <sys/types.h>`
`#include <errno.h>`
`#include <sys/vfs.h>`
`#include <dirent.h>`
`#include <sys/stat.h>`
`#include "osclconfig_io_check.h"`

Go to the source code of this file.

## Defines
#define | OSCL_HAS_GLOB 0
#define | OSCL_HAS_ANSI_FILE_IO_SUPPORT 1
#define | OSCL_HAS_ANSI_64BIT_FILE_IO_SUPPORT 0
#define | OSCL_HAS_MSWIN_FILE_IO_SUPPORT 0
#define | OSCL_HAS_SYMBIAN_COMPATIBLE_IO_FUNCTION 0
#define | OSCL_HAS_NATIVE_FILE_CACHE_ENABLE 1
#define | OSCL_FILE_BUFFER_MAX_SIZE 32768
#define | OSCL_HAS_PV_FILE_CACHE 0
#define | OSCL_HAS_LARGE_FILE_SUPPORT 1
#define | OSCL_HAS_SYMBIAN_SOCKET_SERVER 0
#define | OSCL_HAS_SYMBIAN_DNS_SERVER 0
#define | OSCL_HAS_BERKELEY_SOCKETS 1
#define | OSCL_HAS_SOCKET_SUPPORT 1
#define | OsclValidInetAddr(addr) (inet_addr(addr)!=INADDR_NONE)
#define | OsclMakeSockAddr(sockaddr, port, addrstr, ok)
#define | OsclUnMakeSockAddr(sockaddr, addrstr) addrstr=inet_ntoa(sockaddr.sin_addr);
#define | OsclMakeInAddr(in_addr, addrstr, ok)
#define | OsclUnMakeInAddr(in_addr, addrstr) addrstr=inet_ntoa(in_addr);
#define | OsclSetRecvBufferSize(s, val, ok, err)
#define | OsclBind(s, addr, ok, err)
#define | OsclSetSockOpt(s, optLevel, optName, optVal, optLen, ok, err)
#define | OsclJoin(s, addr, ok, err)
#define | OsclListen(s, size, ok, err)
#define | OsclAccept(s, accept_s, ok, err, wouldblock)
#define | OsclSetNonBlocking(s, ok, err)
#define | OsclShutdown(s, how, ok, err)
#define | OsclSocket(s, fam, type, prot, ok, err)
#define | OsclSendTo(s, buf, len, addr, ok, err, nbytes, wouldblock)
#define | OsclSend(s, buf, len, ok, err, nbytes, wouldblock)
#define | OsclCloseSocket(s, ok, err)
#define | OsclConnect(s, addr, ok, err, wouldblock)
#define | OsclGetPeerName(s, name, namelen, ok, err)
#define | OsclGetAsyncSockErr(s, ok, err)
#define | OsclPipe(x) pipe(x)
#define | OsclReadFD(fd, buf, cnt) read(fd,buf,cnt)
#define | OsclWriteFD(fd, buf, cnt) write(fd,buf,cnt)
#define | OsclConnectComplete(s, wset, eset, success, fail, ok, err)
#define | OsclRecv(s, buf, len, ok, err, nbytes, wouldblock)
#define | OsclRecvFrom(s, buf, len, paddr, paddrlen, ok, err, nbytes, wouldblock)
#define | OsclSocketSelect(nfds, rd, wr, ex, timeout, ok, err, nhandles)
#define | OsclSocketStartup(ok)
#define | OsclSocketCleanup(ok)
#define | OsclGethostbyname(name, hostent, ok, err)
#define | OsclGetDottedAddr(hostent, dottedaddr, ok)
#define | OsclGetDottedAddrVector(hostent, dottedaddr, dottedaddrvect, ok)
#define | OSCL_SD_RECEIVE SHUT_RD
#define | OSCL_SD_SEND SHUT_WR
#define | OSCL_SD_BOTH SHUT_RDWR
#define | OSCL_AF_INET AF_INET
#define | OSCL_SOCK_STREAM SOCK_STREAM
#define | OSCL_SOCK_DATAGRAM SOCK_DGRAM
#define | OSCL_IPPROTO_IP IPPROTO_IP
#define | OSCL_IPPROTO_TCP IPPROTO_TCP
#define | OSCL_IPPROTO_UDP IPPROTO_UDP
#define | OSCL_SOL_SOCKET SOL_SOCKET
#define | OSCL_SOL_IP IPPROTO_IP
#define | OSCL_SOL_TCP IPPROTO_TCP
#define | OSCL_SOL_UDP IPPROTO_UDP
#define | OSCL_SOCKOPT_IP_MULTICAST_TTL IP_MULTICAST_TTL
#define | OSCL_SOCKOPT_IP_ADDMEMBERSHIP IP_ADD_MEMBERSHIP
#define | OSCL_SOCKOPT_IP_TOS IP_TOS
#define | OSCL_SOCKOPT_SOL_REUSEADDR SO_REUSEADDR
## Typedefs
typedef int | TOsclSocket
typedef sockaddr_in | TOsclSockAddr
typedef socklen_t | TOsclSockAddrLen
typedef ip_mreq | TIpMReq
typedef hostent | TOsclHostent
typedef off64_t | TOsclFileOffset

## Detailed Description

This file contains common typedefs based on the ANSI C limits.h header.

This header file should work for any ANSI C compiler to determine the proper native C types to use for OSCL integer types.

## Define Documentation

#define OSCL_AF_INET AF_INET

#define OSCL_FILE_BUFFER_MAX_SIZE 32768

#define OSCL_HAS_ANSI_64BIT_FILE_IO_SUPPORT 0

#define OSCL_HAS_ANSI_FILE_IO_SUPPORT 1

#define OSCL_HAS_BERKELEY_SOCKETS 1

#define OSCL_HAS_GLOB 0

#define OSCL_HAS_LARGE_FILE_SUPPORT 1

#define OSCL_HAS_MSWIN_FILE_IO_SUPPORT 0

#define OSCL_HAS_NATIVE_FILE_CACHE_ENABLE 1

#define OSCL_HAS_PV_FILE_CACHE 0

#define OSCL_HAS_SOCKET_SUPPORT 1

#define OSCL_HAS_SYMBIAN_COMPATIBLE_IO_FUNCTION 0

#define OSCL_HAS_SYMBIAN_DNS_SERVER 0

#define OSCL_HAS_SYMBIAN_SOCKET_SERVER 0

#define OSCL_IPPROTO_IP IPPROTO_IP

#define OSCL_IPPROTO_TCP IPPROTO_TCP

#define OSCL_IPPROTO_UDP IPPROTO_UDP

#define OSCL_SD_BOTH SHUT_RDWR

#define OSCL_SD_RECEIVE SHUT_RD

#define OSCL_SD_SEND SHUT_WR

#define OSCL_SOCK_DATAGRAM SOCK_DGRAM

#define OSCL_SOCK_STREAM SOCK_STREAM

#define OSCL_SOCKOPT_IP_ADDMEMBERSHIP IP_ADD_MEMBERSHIP

#define OSCL_SOCKOPT_IP_MULTICAST_TTL IP_MULTICAST_TTL

#define OSCL_SOCKOPT_IP_TOS IP_TOS

#define OSCL_SOCKOPT_SOL_REUSEADDR SO_REUSEADDR

#define OSCL_SOL_IP IPPROTO_IP

#define OSCL_SOL_SOCKET SOL_SOCKET

#define OSCL_SOL_TCP IPPROTO_TCP

#define OSCL_SOL_UDP IPPROTO_UDP

#define OsclAccept | ( | s,
|  | accept_s,
|  | ok,
|  | err,
|  | wouldblock |  | ) |

| Value:
    accept_s=accept(s,NULL,NULL);\
        ok=(accept_s!=(-1));\
        if (!ok){err=errno;wouldblock=(err==EAGAIN||err==EWOULDBLOCK);}

#define OsclBind | ( | s,
|  | addr,
|  | ok,
|  | err |  | ) |

| Value:
    TOsclSockAddr* tmpadr = &addr;\
        sockaddr* sadr = OSCL_STATIC_CAST(sockaddr*, tmpadr);\
        ok=(bind(s,sadr,sizeof(addr))!=(-1));\
        if (!ok)err=errno

#define OsclCloseSocket | ( | s,
|  | ok,
|  | err |  | ) |

| Value:
    ok=(close(s)!=(-1));\
        if (!ok)err=errno

#define OsclConnect | ( | s,
|  | addr,
|  | ok,
|  | err,
|  | wouldblock |  | ) |

| Value:
    TOsclSockAddr* tmpadr = &addr;\
        sockaddr* sadr = OSCL_STATIC_CAST(sockaddr*, tmpadr);\
        ok=(connect(s,sadr,sizeof(addr))!=(-1));\
        if (!ok){err=errno;wouldblock=(err==EINPROGRESS);}

#define OsclConnectComplete | ( | s,
|  | wset,
|  | eset,
|  | success,
|  | fail,
|  | ok,
|  | err |  | ) |

| Value:
    success=fail=false;\
        if (FD_ISSET(s,&eset))\
        {fail=true;OsclGetAsyncSockErr(s,ok,err);}\
        else if (FD_ISSET(s,&wset))\
        {OsclGetAsyncSockErr(s,ok,err);if (ok && err==0)success=true;else fail=true;}

#define OsclGetAsyncSockErr | ( | s,
|  | ok,
|  | err |  | ) |

| Value:
    int opterr;socklen_t optlen=sizeof(opterr);\
        ok=(getsockopt(s,SOL_SOCKET,SO_ERROR,(void *)&opterr,&optlen)!=(-1));\
        if(ok)err=opterr;else err=errno;

#define OsclGetDottedAddr | ( | hostent,
|  | dottedaddr,
|  | ok |  | ) |

| Value:
    long *_hostaddr=(long*)hostent->h_addr_list[0];\
        struct in_addr _inaddr;\
        _inaddr.s_addr=*_hostaddr;\
        dottedaddr=inet_ntoa(_inaddr);\
        ok=(dottedaddr!=NULL);

#define OsclGetDottedAddrVector | ( | hostent,
|  | dottedaddr,
|  | dottedaddrvect,
|  | ok |  | ) |

| Value:
    if(dottedaddrvect)\
        {\
        long **_addrlist=(long**)hostent->h_addr_list;\
        for(int i = 0; _addrlist[i] != NULL; i++){\
            struct in_addr _inaddr;\
            _inaddr.s_addr=*_addrlist[i];\
            OsclNetworkAddress addr(inet_ntoa(_inaddr), 0);\
            dottedaddrvect->push_back(addr);\
        }\
        if (!dottedaddrvect->empty())\
            {dottedaddr->port = dottedaddrvect->front().port; dottedaddr->ipAddr.Set(dottedaddrvect->front().ipAddr.Str());}\
        ok=(!dottedaddrvect->empty() && (((*dottedaddrvect)[0]).ipAddr.Str() != NULL));\
        }\
        else\
        {\
            char *add;\
            OsclGetDottedAddr(hostent,add,ok);\
            if(ok) dottedaddr->ipAddr.Set(add);\
        }

#define OsclGethostbyname | ( | name,
|  | hostent,
|  | ok,
|  | err |  | ) |

| Value:
    hostent=gethostbyname((const char*)name);\
        ok=(hostent!=NULL);\
        if (!ok)err=errno;

#define OsclGetPeerName | ( | s,
|  | name,
|  | namelen,
|  | ok,
|  | err |  | ) |

| Value:
    ok=(getpeername(s,(sockaddr*)&name,(socklen_t*)&namelen) != (-1) );\
        if (!ok)err=errno

#define OsclJoin | ( | s,
|  | addr,
|  | ok,
|  | err |  | ) |

| Value:
    {\
            struct ip_mreq mreq; \
                void* p = &addr; \
            ok=(bind(s,(sockaddr*)p,sizeof(addr))!=(-1));\
            mreq.imr_multiaddr.s_addr = addr.sin_addr.s_addr ; \
            mreq.imr_interface.s_addr = htonl(INADDR_ANY); \
            ok=(setsockopt(s, IPPROTO_IP, IP_ADD_MEMBERSHIP, &mreq, sizeof(struct ip_mreq))!=(-1)); \
            if (!ok)err=errno;\
    }

#define OsclListen | ( | s,
|  | size,
|  | ok,
|  | err |  | ) |

| Value:
    ok=(listen(iSocket,qSize)!=(-1));\
        if (!ok)err=errno

#define OsclMakeInAddr | ( | in_addr,
|  | addrstr,
|  | ok |  | ) |

| Value:
    int32 result = inet_aton((const char*)addrstr, &in_addr);\
        ok=(result!=0);

#define OsclMakeSockAddr | ( | sockaddr,
|  | port,
|  | addrstr,
|  | ok |  | ) |

| Value:
    sockaddr.sin_family=OSCL_AF_INET;\
        sockaddr.sin_port=htons(port);\
        int32 result=inet_aton((const char*)addrstr,&sockaddr.sin_addr);\
        ok=(result!=0);

#define OsclPipe | ( | x |  | ) | pipe(x)

#define OsclReadFD | ( | fd,
|  | buf,
|  | cnt |  | ) | read(fd,buf,cnt)

#define OsclRecv | ( | s,
|  | buf,
|  | len,
|  | ok,
|  | err,
|  | nbytes,
|  | wouldblock |  | ) |

| Value:
    nbytes=recv(s,(void *)(buf),(size_t)(len),0);\
        ok=(nbytes!=(-1));\
        if (!ok){err=errno;wouldblock=(err==EAGAIN);}

#define OsclRecvFrom | ( | s,
|  | buf,
|  | len,
|  | paddr,
|  | paddrlen,
|  | ok,
|  | err,
|  | nbytes,
|  | wouldblock |  | ) |

| Value:
    {\
    void* p=paddr;\
    nbytes=recvfrom(s,(void*)(buf),(size_t)(len),0,(struct sockaddr*)p,paddrlen);\
        ok=(nbytes!=(-1));\
        if (!ok){err=errno;wouldblock=(err==EAGAIN);}\
    }

#define OsclSend | ( | s,
|  | buf,
|  | len,
|  | ok,
|  | err,
|  | nbytes,
|  | wouldblock |  | ) |

| Value:
    nbytes=send(s,(const void*)(buf),(size_t)(len),0);\
        ok=(nbytes!=(-1));\
        if (!ok){err=errno;wouldblock=(err==EAGAIN||err==EWOULDBLOCK);}

#define OsclSendTo | ( | s,
|  | buf,
|  | len,
|  | addr,
|  | ok,
|  | err,
|  | nbytes,
|  | wouldblock |  | ) |

| Value:
    TOsclSockAddr* tmpadr = &addr;\
        sockaddr* sadr = OSCL_STATIC_CAST(sockaddr*, tmpadr);\
        nbytes=sendto(s,(const void*)(buf),(size_t)(len),0,sadr,(socklen_t)sizeof(addr));\
        ok=(nbytes!=(-1));\
        if (!ok){err=errno;wouldblock=(err==EAGAIN||err==EWOULDBLOCK);}

#define OsclSetNonBlocking | ( | s,
|  | ok,
|  | err |  | ) |

| Value:
    ok=(fcntl(s,F_SETFL,O_NONBLOCK)!=(-1));\
        if (!ok)err=errno

#define OsclSetRecvBufferSize | ( | s,
|  | val,
|  | ok,
|  | err |  | ) |

| Value:
    ok=(setsockopt(s,SOL_SOCKET,SO_RCVBUF,(char*)&val, sizeof(int)) !=-1);\
            if (!ok)err=errno

#define OsclSetSockOpt | ( | s,
|  | optLevel,
|  | optName,
|  | optVal,
|  | optLen,
|  | ok,
|  | err |  | ) |

| Value:
    ok=(setsockopt(s,optLevel,optName,OSCL_STATIC_CAST(const char*,optVal),optLen) != (-1));\
        if (!ok)err=errno

#define OsclShutdown | ( | s,
|  | how,
|  | ok,
|  | err |  | ) |

| Value:
    ok=(shutdown(iSocket,how)!=(-1));\
        if (!ok)err=errno

#define OsclSocket | ( | s,
|  | fam,
|  | type,
|  | prot,
|  | ok,
|  | err |  | ) |

| Value:
    s=socket(fam,type,prot);\
        ok=(s!=(-1));\
        if (!ok)err=errno

#define OsclSocketCleanup | ( | ok |  | ) |

| Value:
    signal(SIGPIPE,SIG_DFL);\
        ok=true

#define OsclSocketSelect | ( | nfds,
|  | rd,
|  | wr,
|  | ex,
|  | timeout,
|  | ok,
|  | err,
|  | nhandles |  | ) |

| Value:
    nhandles=select(nfds,&rd,&wr,&ex,&timeout);\
        ok=(nhandles!=(-1));\
        if (!ok)err=errno

#define OsclSocketStartup | ( | ok |  | ) |

| Value:
    signal(SIGPIPE,SIG_IGN);\
        ok=true

#define OsclUnMakeInAddr | ( | in_addr,
|  | addrstr |  | ) | addrstr=inet_ntoa(in_addr);

#define OsclUnMakeSockAddr | ( | sockaddr,
|  | addrstr |  | ) | addrstr=inet_ntoa(sockaddr.sin_addr);

#define OsclValidInetAddr | ( | addr |  | ) | (inet_addr(addr)!=INADDR_NONE)

#define OsclWriteFD | ( | fd,
|  | buf,
|  | cnt |  | ) | write(fd,buf,cnt)

## Typedef Documentation

typedef struct ip_mreq TIpMReq

typedef off64_t TOsclFileOffset

typedef struct hostent TOsclHostent

typedef struct sockaddr_in TOsclSockAddr

typedef socklen_t TOsclSockAddrLen

typedef int TOsclSocket