Files
harbour-core/harbour/include/hbsocket.h
Przemyslaw Czerpak 87cff88914 2010-02-20 18:05 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl)
* harbour/src/vm/task.c
    ! fixed casting for C++ builds

  * harbour/src/lang/msges.c
    ! added hack for Solaris builds where ES is macro
      TODDO: sync names of lang and corresponding code modules.

  * harbour/src/vm/dynlibhb.c
    * pacified warning

  * harbour/contrib/xpp/xppextrn.ch
  * harbour/contrib/xpp/dbcmdx.c
  * harbour/include/hbextern.ch
  * harbour/src/rdd/dbcmd53.c
    ! moved ordWildSeek() from XPP to HBRDD library.
      I have no idea if XPP has such function or if it's or not
      compatible with ORDWILDSEEK() functions I created for [x]Harbour
    * disable ordCount() and ordWildSeek() functions when HB_CLP_STRICT
      macro is set

  * harbour/include/hbsocket.ch
    + added macro values interface info flags: HB_SOCKET_IFF_*
    + added macro values for interface info array indexes: HB_SOCKET_IFINFO_*

  * harbour/include/hbsocket.h
  * harbour/src/rtl/hbsocket.c
    + added new C function:
         PHB_ITEM hb_socketGetIFaces( int af, HB_BOOL fNoAliases );
      it returns array with existing interfaces description.
      This code was added for non MS-Windows based platforms only.
      Support for MS-Windows has to be added yet.
      Some platforms may not fill all fields in the returned array.
      When some fields are not supported by platform or interface then
      they can contain NIL value.
      On some platforms this code can effectively work only with IP4
      interfaces and IP6 ones will need different implementation.
      TODO: add support for alternative long interface introduced in some
            new systems using 'struct lifreq' with SIOCGLIF* ioctls instead
            of 'struct ifreq' and SIOCGIF*
      TODO: add support for extracting hardware addreses (i.e. ethernet
            macaddresses) for systems which do not support SIOCGIFHWADDR.

      Please test this code with OS2 using OpenWatcom and GCC (old and
      new socket API). I enabled HB_HAS_SOCKADDR_SA_LEN in OS2 builds.
      OpenWatocm OS2 header files have such fields but I do know if it's
      also present in GCC socket API.

  * harbour/include/hbextern.ch
  * harbour/src/rtl/hbinet.c
    + added new PRG function:
         hb_inetIfInfo( [<lNoAliases>] [, <nAddrFamily>] ) -> <aInfo>
      <lNoAliases> is .F. by default so aliases are included
      <nAddrFamily> is HB_SOCKET_AF_INET by default
      <aInfo> is an array in which each entry is also array with the
      following fields:
         HB_SOCKET_IFINFO_FAMILY    1     // adress family
         HB_SOCKET_IFINFO_NAME      2     // interface name
         HB_SOCKET_IFINFO_FLAGS     3     // flags HB_SOCKET_IFF_*
         HB_SOCKET_IFINFO_ADDR      4     // interface address
         HB_SOCKET_IFINFO_NETMASK   5     // subnetmask
         HB_SOCKET_IFINFO_BROADCAST 6     // broadcast address
         HB_SOCKET_IFINFO_P2PADDR   7     // point-to-point address
         HB_SOCKET_IFINFO_HWADDR    8     // hardware address

      Please use this code on different non MS-Windows platforms:

            proc main( noAlias )
               local iface
               ? os(), version()
               ? "interfaces:"
               for each iface in hb_inetIfInfo( !empty( noAlias ), 0 )
                  ? hb_valToExp( iface )
               next
               ?
            return

      and check if it returns correct information about available
      interfaces.
2010-02-20 17:07:00 +00:00

123 lines
6.9 KiB
C

/*
* $Id$
*/
/*
* Harbour Project source code:
* socket C API
*
* Copyright 2009 Przemyslaw Czerpak <druzus / at / priv.onet.pl>
* www - http://www.harbour-project.org
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this software; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
* Boston, MA 02111-1307 USA (or visit the web site http://www.gnu.org/).
*
* As a special exception, the Harbour Project gives permission for
* additional uses of the text contained in its release of Harbour.
*
* The exception is that, if you link the Harbour libraries with other
* files to produce an executable, this does not by itself cause the
* resulting executable to be covered by the GNU General Public License.
* Your use of that executable is in no way restricted on account of
* linking the Harbour library code into it.
*
* This exception does not however invalidate any other reasons why
* the executable file might be covered by the GNU General Public License.
*
* This exception applies only to the code released by the Harbour
* Project under the name Harbour. If you copy code from other
* Harbour Project or Free Software Foundation releases into a copy of
* Harbour, as the General Public License permits, the exception does
* not apply to the code that you add in this way. To avoid misleading
* anyone as to the status of such modified files, you must delete
* this exception notice from them.
*
* If you write modifications of your own for Harbour, it is your choice
* whether to permit this exception to apply to your modifications.
* If you do not wish that, delete this exception notice.
*
*/
#ifndef HB_SOCKET_H_
#define HB_SOCKET_H_
#include "hbapi.h"
#include "hbsocket.ch"
HB_EXTERN_BEGIN
#if defined( HB_OS_WIN ) && ! defined( HB_OS_UNIX )
typedef HB_PTRUINT HB_SOCKET;
#else
typedef int HB_SOCKET;
#endif
typedef HB_SOCKET ( * HB_SOCKET_FUNC )( PHB_ITEM );
#define HB_NO_SOCKET ( ( HB_SOCKET ) -1 )
HB_EXPORT extern int hb_socketInit( void );
HB_EXPORT extern void hb_socketCleanup( void );
HB_EXPORT extern int hb_socketGetError( void );
HB_EXPORT extern int hb_socketGetOsError( void );
HB_EXPORT extern const char * hb_socketErrorStr( int iError );
HB_EXPORT extern int hb_socketGetAddrFamilly( const void * pSockAddr, unsigned len );
HB_EXPORT extern HB_BOOL hb_socketLocalAddr( void ** pSockAddr, unsigned * puiLen, const char * szAddr );
HB_EXPORT extern HB_BOOL hb_socketInetAddr( void ** pSockAddr, unsigned * puiLen, const char * szAddr, int iPort );
HB_EXPORT extern HB_BOOL hb_socketInet6Addr( void ** pSockAddr, unsigned * puiLen, const char * szAddr, int iPort );
HB_EXPORT extern char * hb_socketAddrGetName( const void * pSockAddr, unsigned len );
HB_EXPORT extern HB_BOOL hb_socketResolveInetAddr( void ** pSockAddr, unsigned * puiLen, const char * szAddr, int iPort );
HB_EXPORT extern char * hb_socketResolveAddr( const char * szAddr, int af );
HB_EXPORT extern PHB_ITEM hb_socketGetHosts( const char * szAddr, int af );
HB_EXPORT extern PHB_ITEM hb_socketGetAliases( const char * szAddr, int af );
HB_EXPORT extern PHB_ITEM hb_socketGetIFaces( int af, HB_BOOL fNoAliases );
HB_EXPORT extern int hb_socketAddrGetPort( const void * pSockAddr, unsigned len );
HB_EXPORT extern HB_BOOL hb_socketAddrFromItem( void ** pSockAddr, unsigned * puiLen, PHB_ITEM pAddrItm );
HB_EXPORT extern PHB_ITEM hb_socketAddrToItem( const void * pSockAddr, unsigned len );
HB_EXPORT extern int hb_socketGetSockName( HB_SOCKET sd, void ** pSockAddr, unsigned * puiLen );
HB_EXPORT extern int hb_socketGetPeerName( HB_SOCKET sd, void ** pSockAddr, unsigned * puiLen );
HB_EXPORT extern HB_SOCKET hb_socketOpen( int domain, int type, int protocol );
HB_EXPORT extern int hb_socketClose( HB_SOCKET sd );
HB_EXPORT extern int hb_socketShutdown( HB_SOCKET sd, int iMode );
HB_EXPORT extern int hb_socketBind( HB_SOCKET sd, const void * pSockAddr, unsigned uiLen );
HB_EXPORT extern int hb_socketListen( HB_SOCKET sd, int iBacklog );
HB_EXPORT extern HB_SOCKET hb_socketAccept( HB_SOCKET sd, void ** pSockAddr, unsigned * puiLen, HB_MAXINT timeout );
HB_EXPORT extern int hb_socketConnect( HB_SOCKET sd, const void * pSockAddr, unsigned uiLen, HB_MAXINT timeout );
HB_EXPORT extern long hb_socketSend( HB_SOCKET sd, const void * data, long len, int flags, HB_MAXINT timeout );
HB_EXPORT extern long hb_socketSendTo( HB_SOCKET sd, const void * data, long len, int flags, const void * pSockAddr, unsigned uiSockLen, HB_MAXINT timeout );
HB_EXPORT extern long hb_socketRecv( HB_SOCKET sd, void * data, long len, int flags, HB_MAXINT timeout );
HB_EXPORT extern long hb_socketRecvFrom( HB_SOCKET sd, void * data, long len, int flags, void ** pSockAddr, unsigned * puiSockLen, HB_MAXINT timeout );
HB_EXPORT extern int hb_socketSetBlockingIO( HB_SOCKET sd, HB_BOOL fBlocking );
HB_EXPORT extern int hb_socketSetNoDelay( HB_SOCKET sd, HB_BOOL fNoDelay );
HB_EXPORT extern int hb_socketSetReuseAddr( HB_SOCKET sd, HB_BOOL fReuse );
HB_EXPORT extern int hb_socketSetKeepAlive( HB_SOCKET sd, HB_BOOL fKeepAlive );
HB_EXPORT extern int hb_socketSetBroadcast( HB_SOCKET sd, HB_BOOL fBroadcast );
HB_EXPORT extern int hb_socketSetSndBufSize( HB_SOCKET sd, int iSize );
HB_EXPORT extern int hb_socketSetRcvBufSize( HB_SOCKET sd, int iSize );
HB_EXPORT extern int hb_socketGetRcvBufSize( HB_SOCKET sd, int * piSize );
HB_EXPORT extern int hb_socketGetSndBufSize( HB_SOCKET sd, int * piSize );
HB_EXPORT extern int hb_socketSetMulticast( HB_SOCKET sd, int af, const char * szAddr );
HB_EXPORT extern int hb_socketSelectRead( HB_SOCKET sd, HB_MAXINT timeout );
HB_EXPORT extern int hb_socketSelectWrite( HB_SOCKET sd, HB_MAXINT timeout );
HB_EXPORT extern int hb_socketSelectWriteEx( HB_SOCKET sd, HB_MAXINT timeout );
HB_EXPORT extern int hb_socketSelect( PHB_ITEM pArrayRD, HB_BOOL fSetRD,
PHB_ITEM pArrayWR, HB_BOOL fSetWR,
PHB_ITEM pArrayEX, HB_BOOL fSetEX,
HB_MAXINT timeout, HB_SOCKET_FUNC pFunc );
HB_EXTERN_END
#endif /* HB_SOCKET_H_ */