Пример #1
0
static void s_sslSocketNew( HB_BOOL fServer )
{
   HB_SOCKET sd = hb_socketParam( 1 );

   if( sd != HB_NO_SOCKET )
   {
      PHB_SOCKEX pSock = NULL;
      SSL * ssl = hb_SSL_par( 2 );

      if( ssl )
         pSock = hb_sockexNewSSL( sd, ssl, fServer, hb_parnintdef( 3, - 1 ), hb_param( 2, HB_IT_ANY ) );
      else if( HB_ISHASH( 2 ) )
         pSock = hb_sockexNew( sd, s_sockFilter.pszName, hb_param( 2, HB_IT_ANY ) );
      else
         hb_errRT_BASE( EG_ARG, 2010, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );

      if( pSock )
      {
         PHB_ITEM pSockItm = hb_param( 1, HB_IT_POINTER );

         if( HB_ISBYREF( 1 ) && hb_sockexItemReplace( pSockItm, pSock ) )
            hb_itemReturn( pSockItm );
         else
         {
            hb_socketItemClear( pSockItm );
            hb_sockexItemPut( hb_param( -1, HB_IT_ANY ), pSock );
         }
      }
   }
}
Пример #2
0
static PHB_SOCKEX s_sockexNew( HB_SOCKET sd, PHB_ITEM pParams )
{
   PHB_SOCKEX pSock;
   HB_BOOL fServer = HB_FALSE;
   HB_MAXINT timeout = -1;
   SSL * ssl = NULL;

   if( pParams && HB_IS_HASH( pParams ) )
   {
      PHB_ITEM pItem;

      if( ssl == NULL && ( pItem = hb_hashGetCItemPtr( pParams, "ssl" ) ) != NULL )
         ssl = hb_SSL_itemGet( pItem );
      if( ssl == NULL && ( pItem = hb_hashGetCItemPtr( pParams, "ctx" ) ) != NULL )
         ssl = hb_SSL_itemGet( pItem );
      if( ssl == NULL && ( pItem = hb_hashGetCItemPtr( pParams, "key" ) ) != NULL )
         ssl = hb_SSL_itemGet( pItem );
      if( ( pItem = hb_hashGetCItemPtr( pParams, "timeout" ) ) != NULL &&
          HB_IS_NUMERIC( pItem ) )
         timeout = hb_itemGetNInt( pItem );
      if( ( pItem = hb_hashGetCItemPtr( pParams, "server" ) ) != NULL &&
          HB_IS_LOGICAL( pItem ) )
         fServer = hb_itemGetL( pItem );
      else if( ( pItem = hb_hashGetCItemPtr( pParams, "client" ) ) != NULL &&
               HB_IS_LOGICAL( pItem ) )
         fServer = ! hb_itemGetL( pItem );
   }

   pSock = hb_sockexNewSSL( sd, ssl, fServer, timeout );
   if( pSock )
      hb_socekxParamsInit( pSock, pParams );

   return pSock;
}